|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v4 2/2] x86/nestedsvm: honour L2's EFLAGS.IF when L1 clears V_INTR_MASKING
From: Chunjie Zhu <chunjie.zhu@xxxxxxxxxx>
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.
Fixes: 3a1ef3c33fa7 ("Implement SVM specific interrupt handling")
Signed-off-by: Chunjie Zhu <chunjie.zhu@xxxxxxxxxx>
Reviewed-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
---
v3->v4: add Fixes: tag(s), collect Reviewed-by (Ross)
xen/arch/x86/hvm/svm/nestedsvm.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index f366d9b92be3..c75fb8efbac9 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -1146,6 +1146,7 @@ enum hvm_intblk cf_check nsvm_intr_blocked(struct vcpu *v)
struct nestedsvm *svm = &vcpu_nestedsvm(v);
struct nestedvcpu *nv = &vcpu_nestedhvm(v);
+ ASSERT(v == current);
ASSERT(nestedhvm_enabled(v->domain));
if ( !nestedsvm_gif_isset(v) )
@@ -1155,7 +1156,16 @@ enum hvm_intblk cf_check nsvm_intr_blocked(struct vcpu
*v)
{
struct vmcb *n2vmcb = nv->nv_n2vmcx;
- if ( svm->ns_hostflags.vintrmask && !svm->ns_hostflags.rflagsif )
+ /*
+ * With V_INTR_MASKING, L1's EFLAGS.IF masks physical interrupts.
+ * Without it, L2's EFLAGS.IF does (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.
+ */
+ if ( svm->ns_hostflags.vintrmask
+ ? !svm->ns_hostflags.rflagsif
+ : !(guest_cpu_user_regs()->eflags & X86_EFLAGS_IF) )
return hvm_intblk_rflags_ie;
/* when l1 guest passes its devices through to the l2 guest
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |