From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796511568; b=RWyiR1Qq3qS3RZlvP+Go9Vcu0Uj6yYat+W/ZwgWVitCOk26FbbNePn3skfNwg78MrZ7Q Vm6UZnwMaX1e4LYqG/ZtuT2eoVJPkl67+1ur92audNZuMPLCMF0doOeQ8hekS28F0HVlg tOYhuZu+LafOJ+7S5lNHfc88OjbTKh5vZ3weKnKCL8DgdJYxwKMw4N9RWqXglH/ZoWv3j uvplctz+Spx8xBLEKb27zpl/REaIc2APxg1cN/cz9/mXMkmjGIePcAFBiAnAApxApLrvA AkR80Atr1uK4R6z5yIsly3xuszHgSd9Co6Awflx7pN48OAWjHXCYydqM04ryBmfGchA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796511568; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=PdbTn9zVPGtoVAR7aKUt2UIGjvhrnpSFT1ZBVr2Pdwg=; b=3AwTOYP7faXSbcYID/cke5Pb3Z9fAR4TLinFpmolsqg/PGH7gV/E1Lr7mIZyJEMfmnK3 8lnnc5rgooOWZNj1knUjX/F398eDDaKgoNFCu+CqDLhCn4UM4rWR+R36vnPTKBpqJZd9A ZFbuov0NTie6Ir/mUSdTPtU6Lej9ZbO37YjVVmZPmYwZvPcLKq7K1Ta70D+Co5Sqsdg7M cYgSJzKIrtBWCNwkL0UEQzDaYNkkpv86mCQXwZ/kq47yM/VG0apUyY+1yTyhnIelEPEFU 7nQ3DnMLaoFDMKXRcF6XuUvbgcrlvMGxHHQHD0PWMnIit2M6AsOPmTr2L6Fziy+lOdw== 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=iEYfjq9G; 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 CE35F606A322 for ; Sat, 5 Dec 2026 22:59:28 +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=iEYfjq9G Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FB591F0092B; Sat, 5 Dec 2026 22:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796511568; bh=PdbTn9zVPGtoVAR7aKUt2UIGjvhrnpSFT1ZBVr2Pdwg=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=iEYfjq9GmMmMNjqP/bKBnpV4yCSz1dLywWnZSY8y7j1izXvNLAeraQngnOiI/9p2G 2uwsgqqnaKPfoA0BtpQ+uLYHwoglXHyD3ExAyRZ+TGb7Z2erOy9rZN/0eGBOGAWt1g AtALuwuwjnG4jsw7D6cSosHwvdCqGerUnrAtPBjyiCl3+1QCab5UFPnWiEkS2ZM5r/ 4YczS2gcNzCVMkVy+SyahK+O4p6rj+gB1N6Eyv25rbI12/p0YuCop9RWbjaZ1dFHrP srYDbt3BwsvdqYelP2u50esEITbuEzuSRIMFUJlLHq9N26stHOblT16PAguyissFFS qYVuscjGegweQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [Patch v6 1/3] KVM: SVM: Re-queue events that were never injected Reply-To: sashiko-reviews@lists.linux.dev To: "Pratik R. Sampat" , kvm@vger.kernel.org In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 22:59:28 +0000 X-Mailing-List: kvm@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 3 potential issues to consider: - [Medium] KVM: SVM: force_immediate_exit self-IPI aborts stalled ESMTP VMRUN in a loop - [Low] KVM: SVM: svm_complete_interrupts() clobbers VMCB exit_int_info and event_inj - [Low] KVM: SVM: inaccurate EVENTINJ clear comment in svm_complete_interrupts() -- commit 9b4d36c2e80540d699ee7d2ba230910d0fc05661 Author: Pratik R. Sampat KVM: SVM: Re-queue events that were never injected This commit updates svm_complete_interrupts() to migrate a non-zero control->event_inj into control->exit_int_info so undelivered events are re-queued on pre-entry #VMEXITs, and folds svm_cancel_injection() into it. > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index 2dd05cd6b7571..1d45bcc04112c 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c [ ... ] > @@ -4489,6 +4490,27 @@ static void svm_complete_interrupts(struct kvm_vcp= u *vcpu) > svm->nmi_l1_to_l2 =3D false; > svm->soft_int_injected =3D false; > =20 > + /* > + * Hardware clears EVENTINJ field when it injects an event. > + * A non-empty EVENTINJ on #VMEXIT means the vCPU never entered guest > + * mode, and thus that the event was never delivered. Migrate the event > + * to EXITINTINFO so that it's requeued instead of being dropped. [Severity: Low] As reported by Sean Christopherson on v1 [1], is this comment accurate about when hardware clears EVENTINJ? Per the AMD APM and commit 69b721a86d0d ("KVM: nSVM: Clear EVENTINJ fields = in vmcb12 on nested #VMEXIT"), hardware clears EVENTINJ unconditionally on #VMEXIT out of guest mode, not when it injects an event; pre-entry exits leave EVENTINJ intact. > + * > + * An undelivered event doesn't imply a fatal VMEXIT_INVALID. With > + * SMT Protection and Enhanced SMT Protection, VMRUN may exit with an > + * ordinary #VMEXIT without having injected that event into the guest. > + * > + * Clobbering EXITINTINFO is safe precisely because the vCPU never > + * entered guest mode. > + */ > + if (control->event_inj) { > + control->exit_int_info =3D control->event_inj; > + control->exit_int_info_err =3D control->event_inj_err; > + control->event_inj =3D 0; > + > + exitintinfo =3D control->exit_int_info; > + } [Severity: Low] Does overwriting control->exit_int_info, control->exit_int_info_err, and control->event_inj in place corrupt the VMCB fields before svm_handle_exit() runs? On a failed VMRUN (SVM_EXIT_ERR), dump_vmcb() then logs event_inj as 0 and reports the staged event under exit_int_info, obscuring VMRUN failure diagnosis. svm_get_exit_info() also reports the synthetic exit_int_info to downstream callers such as trace_kvm_nested_vmexit(). Passing local exitintinfo and exitintinfo_err values to a helper, similar to __vmx_complete_interrupts(), would avoid mutating the VMCB fields. [Severity: Medium] As reported by Sean Christopherson on v1 [2], how is KVM_RUN_FORCE_IMMEDIATE_EXIT supposed to work with ESMTP? On an SEV-SNP guest (where AVIC is inhibited), two pending injectable events make kvm_check_and_inject_events() set *req_immediate_exit, so svm_vcpu_run= () sends a physical self-IPI via smp_send_reschedule() before VMRUN. With ESMTP enabled, that pending self-IPI immediately aborts a stalled VMRUN with SVM_EXIT_INTR before guest entry. svm_complete_interrupts() then requeues control->event_inj and raises KVM_REQ_EVENT, so every retry queues another self-IPI. The vCPU can never wait at the ESMTP synchronization point for its sibling: it spins firing self-IPIs while the sibling is in host mode, and if both siblings have KVM_RUN_FORCE_IMMEDIATE_EXIT set, they livelock in repeated SVM_EXIT_INTR exits. [1] https://lore.kernel.org/r/arFYHRzNFT886BME@google.com [2] https://lore.kernel.org/r/arEuMojZa_kv9VXA@google.com --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796503783.gi= t.prsampat@amd.com?part=3D1