Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796354187; b=BxhAcF6Se11mwKrqwgZC9PveBbehairJFIy7c1H+39ZL01yVbzMzg+85U4IdCN4ZsmVb hRr71TNl7rbUhDfBpIyugwlhCAsAWhAUQDcCyQBMcAG3nZk/tOMV5P1UQZ6lfhWkaJWoz IOdzBPitPdavyB1s3y6vZBug82iUnQtPoQ1LX7pBLaFemjs2ViBX4cFkGlDOIr6zNJMxq JmtAPV37aMFx/eK+LKuAMcGTZxwGoyG5Beau6eVvG+e9jLbP2Pw1/YoryrG7vF934eJRQ jKqHObbdtoa6/BeN2qPQefTxQQaKgkThO6Xs3frMFUsEqaIdVeb4+2oIuMrZ1QrHZpw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796354187; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=1cRU3pCG+2hHZ3z6vZvvgVf+E8mhnuUvqcOFAk4kw+M=; b=m7ERvWss8pPVL8969KWuSs9k1q+1M1eZv+kPX38fxk5msF0KyGzxWNthDN+3cgQGGEhJ IiaWftARkqKdth3MD2kYx414Mg3Dw8TllSydw9IC5gkmB8OEXB21s/MlQL86YAnGxPf31 8Q6R8QakYs/43t2wgXTzBwOxVYBC04vH+VDk8Isfdk3zIdi/UYzVTsoPkZH8FO2rw//TF xG6hdpuLUNYlgpXSezcNZhP5W7GpiaElYp+i46zdlJFwdExIjAgxDljmdypyGUoqtc426 t0N6iJJGB1G25Y8dgWrkopZVVJZjrgMJKPirwb+BgGEaM2hEaFhEwk0r2EseT8qt8tw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Nae/85Ub"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 752AD606A322 for ; Fri, 4 Dec 2026 03:16:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nae/85Ub Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFF511F0092C; Fri, 4 Dec 2026 03:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796354187; bh=1cRU3pCG+2hHZ3z6vZvvgVf+E8mhnuUvqcOFAk4kw+M=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Nae/85UbE84CQN1LvZe7JsVyLcc+AkCl3qOxhRoYZY4mAF0avZivIRqzSjPAHsjdj NpMj0ZPRD5l0VrKrk92nszn+ydCvjifgpuaumbeH4TqrX/grY0N0y4BYcjDQAFcKBM tLmH5tmQjwHOF9vB4atuUvet22AGPIWk3YHEdpXDtpWuIvXr/5pwj1d8QA9a5B/cF9 ys+eF5gDKctDEljqSLWPaqWdgn6bFWCMEJx9NxzJrli5VtOEQbWxuJF6JGvfTsdcRz 8/3RHmSUqVuXbZ1PP7ER5rE/gV1E6lgWw6v1VREz0ayjULD9aVcboqpMY/apv0bG8O 2DgizJI1ppZww== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 3/3] x86/hyperv: Handle hypercall timeouts on hw confidential VMs Reply-To: sashiko-reviews@lists.linux.dev To: "Mukesh R" , linux-hyperv@vger.kernel.org In-Reply-To: <20261204025836.3855312-4-mrathor@linux.microsoft.com> References: <20261204025836.3855312-1-mrathor@linux.microsoft.com> <20261204025836.3855312-4-mrathor@linux.microsoft.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 03:16:26 +0000 X-Mailing-List: linux-hyperv@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [High] x86/hyperv: unbounded timeout retry loops without watchdog or rep_comp checks - [Medium] x86/hyperv: reuse of dirty tdx_module_args on retry in hv_tdx_hypercall() - [Medium] x86/hyperv: missing timeout retry in hv_ghcb_hypercall() for SNP paravisor - [Medium] x86/hyperv: dead retry loop and lost retry cap in hv_snp_boot_ap() -- commit 6d87e857871bbab96f5f0cd1dc1cd6280f5a9405 Author: Mukesh R x86/hyperv: Handle hypercall timeouts on hw confidential VMs This commit adds retry loops for HV_STATUS_TIMEOUT to hv_snp_hypercall() and hv_tdx_hypercall(), updating the repeat start index on repeat hypercalls, a= nd introduces hv_result_timeout() and hv_repcount() helpers. > to adjust the repeat start index in the input control parameter. Note, > this does not apply when running with paravisors. A paravisor will never > return with timeouts. [Severity: Medium] Does hv_ghcb_hypercall() also need timeout retry handling for SNP guests running with a paravisor? When ms_hyperv.paravisor_present is true, hv_post_message() (for non-confidential VMBus) and vmbus_set_event() bypass the paravisor and call the host hypervisor directly via hv_tdx_hypercall() on TDX and hv_ghcb_hypercall() on SNP. Unlike hv_tdx_hypercall(), hv_ghcb_hypercall() is not updated to retry on HV_STATUS_TIMEOUT. If the host returns a timeout there, vmbus_post_msg() fails immediately with -EINVAL and vmbus_set_event() silently drops the event signal. > diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c > index 87857b2b2fdb9..0cbfaf53d28c3 100644 > --- a/arch/x86/hyperv/ivm.c > +++ b/arch/x86/hyperv/ivm.c > @@ -365,7 +365,7 @@ int hv_snp_boot_ap(u32 apic_id, unsigned long start_i= p, unsigned int cpu) > do { > ret =3D hv_do_hypercall(HVCALL_START_VP, > start_vp_input, NULL); > - } while (hv_result(ret) =3D=3D HV_STATUS_TIMEOUT && retry--); > + } while (hv_result_timeout(ret) && retry--); > =20 > local_irq_restore(flags); [Severity: Medium] Can hv_result_timeout(ret) ever be true here now? hv_snp_boot_ap() is only registered on SEV-SNP guests without a paravisor, where hv_do_hypercall() dispatches to hv_snp_hypercall(). Because hv_snp_hypercall() now loops until the status is no longer HV_STATUS_TIMEOU= T, the retry =3D 5 loop becomes dead code, and persistent HVCALL_START_VP time= outs spin forever with interrupts disabled instead of aborting and cleaning up t= he VMSA page via snp_cleanup_vmsa(). > @@ -389,12 +389,26 @@ int hv_snp_boot_ap(u32 apic_id, unsigned long start= _ip, unsigned int cpu) > u64 hv_snp_hypercall(u64 control, u64 param1, u64 param2) > { > u64 hv_status; > + bool rep_hcall =3D !!hv_repcount(control); > =20 > - register u64 __r8 asm("r8") =3D param2; > - asm volatile("vmmcall" > - : "=3Da" (hv_status), > - "+c" (control), "+d" (param1), "+r" (__r8) > - : : "cc", "memory", "r9", "r10", "r11"); > + for (;;) { > + register u64 __r8 asm("r8") =3D param2; > + asm volatile("vmmcall" > + : "=3Da" (hv_status), > + "+c" (control), "+d" (param1), "+r" (__r8) > + : : "cc", "memory", "r9", "r10", "r11"); > + > + if (!hv_result_timeout(hv_status)) > + break; > + > + if (rep_hcall) { > + u16 rep_comp =3D hv_repcomp(hv_status); > + > + control &=3D ~HV_HYPERCALL_REP_START_MASK; > + control |=3D > + (u64)rep_comp << HV_HYPERCALL_REP_START_OFFSET; > + } > + } > =20 > return hv_status; > } [Severity: High] Can this unbounded retry loop (and the matching one in hv_tdx_hypercall() below) trigger NMI hardlockup watchdog panics or hang the vCPU with IRQs disabled? Long IRQ-disabled repeat hypercalls such as hv_mark_gpa_visibility() rely on touch_nmi_watchdog() in hv_do_rep_hypercall_ex() across continuation slices, which is bypassed while spinning inside these leaf loops. In addition, rep_comp from the hypervisor is not checked against rep_count = or the previous rep_start for forward progress, and zero-progress retries are unbounded. Persistent timeouts or a non-advancing rep_comp will wedge the vCPU indefinitely instead of returning an error to callers that have recove= ry or native fallback paths (such as native_flush_tlb_multi()). > @@ -438,15 +452,31 @@ static void hv_tdx_msr_read(u64 msr, u64 *val) > =20 > u64 hv_tdx_hypercall(u64 control, u64 param1, u64 param2) > { > + u64 hv_status; > + bool rep_hcall =3D !!hv_repcount(control); > struct tdx_module_args args =3D { }; > =20 > - args.r10 =3D control; > - args.rdx =3D param1; > - args.r8 =3D param2; > + for (;;) { > + args.r10 =3D control; > + args.rdx =3D param1; > + args.r8 =3D param2; > =20 > - (void)__tdx_hypercall(&args); > + (void)__tdx_hypercall(&args); > + hv_status =3D args.r11; [Severity: Medium] Should struct tdx_module_args args be re-initialized inside the retry loop? __tdx_hypercall() loads all 13 register fields from args (exposed via TDVMCALL_EXPOSE_REGS_MASK) and writes VMM output back into all of them on return. On a timeout retry, only r10, rdx, and r8 (plus rcx in __tdx_hypercall()) are rewritten, leaving stale VMM-returned values includi= ng HV_STATUS_TIMEOUT in args.r11 across iterations. Because the return value of __tdx_hypercall() is ignored, if a retry fails without the VMM updating r11, hv_status =3D args.r11 will observe the stale HV_STATUS_TIMEOUT and spin indefinitely. Declaring and zero-initializing args inside the loop (as tdx_map_gpa() does) avoids reusing dirty state. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204025836.3855= 312-1-mrathor@linux.microsoft.com?part=3D3