All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] x86/nestedsvm: honour L2's EFLAGS.IF when L1 clears V_INTR_MASKING
@ 2026-10-16 10:00 chunjie.zhu
  2026-10-29 17:20 ` Ross Lagerwall
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: chunjie.zhu @ 2026-10-16 10:00 UTC (permalink / raw)
  To: xen-devel
  Cc: jbeulich, andrew.cooper3, roger, jason.andryuk, teddy.astie,
	Chunjie Zhu

From: Chunjie Zhu <chunjie.zhu@citrix.com>

L0 always runs L2 with V_INTR_MASKING set, so a physical interrupt exits to
L0 regardless of L2's EFLAGS.IF.  nsvm_intr_blocked() only blocks when L1
requested V_INTR_MASKING=1 and L1's IF was clear.  With V_INTR_MASKING=0
and L2's IF clear, nestedsvm_vcpu_interrupt() would still inject
VMEXIT(INTR) into L1.

Per the APM (vol.2 rev 3.44 "Physical Interrupt Masking in EFLAGS"), with
V_INTR_MASKING=0 L2's IF masks physical interrupts, and a masked interrupt
must stay pending.  Return NSVM_INTR_MASKED for external interrupts in
that case.

Signed-off-by: Chunjie Zhu <chunjie.zhu@citrix.com>
---
 xen/arch/x86/hvm/svm/nestedsvm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index faacfe007832..a419b47eb5f6 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -1514,6 +1514,17 @@ nestedsvm_vcpu_interrupt(struct vcpu *v, const struct hvm_intack intack)
     case hvm_intsrc_pic:
     case hvm_intsrc_lapic:
     case hvm_intsrc_vector:
+        /*
+         * Without V_INTR_MASKING, L2's EFLAGS.IF masks physical interrupts
+         * (APM vol.2 rev 3.44 "Physical Interrupt Masking in EFLAGS").  L0
+         * always runs L2 with V_INTR_MASKING set, so the interrupt would
+         * otherwise exit to L0 and be forwarded to L1 even with L2's IF
+         * clear.  Leave it pending instead.
+         */
+        if ( !vcpu_nestedsvm(v).ns_hostflags.fields.vintrmask &&
+             !(guest_cpu_user_regs()->eflags & X86_EFLAGS_IF) )
+            return NSVM_INTR_MASKED;
+
         exitcode = VMEXIT_INTR;
         exitinfo2 = intack.vector;
         break;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-11-12 14:16 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 10:00 [PATCH v1] x86/nestedsvm: honour L2's EFLAGS.IF when L1 clears V_INTR_MASKING chunjie.zhu
2026-10-29 17:20 ` Ross Lagerwall
2026-11-03 10:11   ` chunjie.zhu
2026-11-03 17:07     ` Ross Lagerwall
2026-11-10  8:57 ` [PATCH v2 0/2] " chunjie.zhu
2026-11-10  8:57 ` [PATCH v2 1/2] x86/hvm: don't let EFLAGS.IF block NMI/#MC due to nested state chunjie.zhu
2026-11-10 16:58   ` Ross Lagerwall
2026-11-10 17:36   ` Ross Lagerwall
2026-11-10  8:57 ` [PATCH v2 2/2] x86/nestedsvm: honour L2's EFLAGS.IF when L1 clears V_INTR_MASKING chunjie.zhu
2026-11-10 17:03   ` Ross Lagerwall
2026-11-12 11:35     ` [PATCH v3 0/3] x86/hvm: fix EFLAGS.IF handling of pending events with nested virt chunjie.zhu
2026-11-12 11:35       ` [PATCH v3 1/3] x86/hvm: don't let EFLAGS.IF block NMI/#MC due to nested state chunjie.zhu
2026-11-12 11:35       ` [PATCH v3 2/3] x86/nestedsvm: honour L2's EFLAGS.IF when L1 clears V_INTR_MASKING chunjie.zhu
2026-11-12 11:35       ` [PATCH v3 3/3] x86/hvm: don't let EFLAGS.IF block #MC in hvm_interrupt_blocked chunjie.zhu
2026-11-12 14:15         ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.