From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Roger Pau Monne <roger.pau@citrix.com>,
Jun Nakajima <jun.nakajima@intel.com>,
Kevin Tian <kevin.tian@intel.com>,
Jan Beulich <jbeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>
Subject: [PATCH v2 2/3] x86/vmx: introduce helper to set VMX_INTR_SHADOW_NMI
Date: Thu, 26 May 2022 13:11:56 +0200 [thread overview]
Message-ID: <20220526111157.24479-3-roger.pau@citrix.com> (raw)
In-Reply-To: <20220526111157.24479-1-roger.pau@citrix.com>
Introduce a small helper to OR VMX_INTR_SHADOW_NMI in
GUEST_INTERRUPTIBILITY_INFO in order to help dealing with the NMI
unblocked by IRET case. Replace the existing usage in handling
EXIT_REASON_EXCEPTION_NMI and also add such handling to EPT violations
and page-modification log-full events.
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
- New in this version.
---
xen/arch/x86/hvm/vmx/vmx.c | 28 +++++++++++++++++++-------
xen/arch/x86/include/asm/hvm/vmx/vmx.h | 3 +++
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 476ab72463..69980c8e31 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -3935,6 +3935,15 @@ static int vmx_handle_apic_write(void)
return vlapic_apicv_write(current, exit_qualification & 0xfff);
}
+static void undo_nmis_unblocked_by_iret(void)
+{
+ unsigned long guest_info;
+
+ __vmread(GUEST_INTERRUPTIBILITY_INFO, &guest_info);
+ __vmwrite(GUEST_INTERRUPTIBILITY_INFO,
+ guest_info | VMX_INTR_SHADOW_NMI);
+}
+
void vmx_vmexit_handler(struct cpu_user_regs *regs)
{
unsigned long exit_qualification, exit_reason, idtv_info, intr_info = 0;
@@ -4139,13 +4148,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
if ( unlikely(intr_info & INTR_INFO_NMI_UNBLOCKED_BY_IRET) &&
!(idtv_info & INTR_INFO_VALID_MASK) &&
(vector != TRAP_double_fault) )
- {
- unsigned long guest_info;
-
- __vmread(GUEST_INTERRUPTIBILITY_INFO, &guest_info);
- __vmwrite(GUEST_INTERRUPTIBILITY_INFO,
- guest_info | VMX_INTR_SHADOW_NMI);
- }
+ undo_nmis_unblocked_by_iret();
perfc_incra(cause_vector, vector);
@@ -4511,6 +4514,11 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
__vmread(GUEST_PHYSICAL_ADDRESS, &gpa);
__vmread(EXIT_QUALIFICATION, &exit_qualification);
+
+ if ( unlikely(exit_qualification & INTR_INFO_NMI_UNBLOCKED_BY_IRET) &&
+ !(idtv_info & INTR_INFO_VALID_MASK) )
+ undo_nmis_unblocked_by_iret();
+
ept_handle_violation(exit_qualification, gpa);
break;
}
@@ -4555,6 +4563,12 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
break;
case EXIT_REASON_PML_FULL:
+ __vmread(EXIT_QUALIFICATION, &exit_qualification);
+
+ if ( unlikely(exit_qualification & INTR_INFO_NMI_UNBLOCKED_BY_IRET) &&
+ !(idtv_info & INTR_INFO_VALID_MASK) )
+ undo_nmis_unblocked_by_iret();
+
vmx_vcpu_flush_pml_buffer(v);
break;
diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/asm/hvm/vmx/vmx.h
index 03995701a1..bc0caad6fb 100644
--- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h
+++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h
@@ -225,6 +225,9 @@ static inline void pi_clear_sn(struct pi_desc *pi_desc)
/*
* Interruption-information format
+ *
+ * Note INTR_INFO_NMI_UNBLOCKED_BY_IRET is also used with Exit Qualification
+ * field under some circumstances.
*/
#define INTR_INFO_VECTOR_MASK 0xff /* 7:0 */
#define INTR_INFO_INTR_TYPE_MASK 0x700 /* 10:8 */
--
2.36.0
next prev parent reply other threads:[~2022-05-26 11:12 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-26 11:11 [PATCH v2 0/3] x86/vmx: implement Bus Lock and VM Notify Roger Pau Monne
2022-05-26 11:11 ` [PATCH v2 1/3] x86/vmx: implement Bus Lock detection Roger Pau Monne
2022-06-03 12:16 ` Jan Beulich
2022-06-03 14:29 ` Roger Pau Monné
2022-06-07 7:20 ` Jan Beulich
2022-06-06 13:27 ` Andrew Cooper
2022-06-07 6:54 ` Jan Beulich
2022-06-07 10:03 ` Roger Pau Monné
2022-05-26 11:11 ` Roger Pau Monne [this message]
2022-06-03 12:20 ` [PATCH v2 2/3] x86/vmx: introduce helper to set VMX_INTR_SHADOW_NMI Jan Beulich
2022-05-26 11:11 ` [PATCH v2 3/3] x86/vmx: implement Notify VM Exit Roger Pau Monne
2022-06-03 12:49 ` Jan Beulich
2022-06-03 14:46 ` Roger Pau Monné
2022-06-07 7:43 ` Jan Beulich
2022-06-07 10:05 ` Roger Pau Monné
2022-06-08 3:51 ` Tian, Kevin
2022-06-09 7:04 ` Tian, Kevin
2022-06-09 7:39 ` Xiaoyao Li
2022-06-09 10:09 ` Roger Pau Monné
2022-06-16 11:17 ` Roger Pau Monné
2022-06-16 11:57 ` Xiaoyao Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220526111157.24479-3-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.