x86/hvm: Fix the unknown nested vmexit reason 80000021 bug
PATCH 1/1 x86/hvm: Fix the unknown nested vmexit reason 80000021 bug
This bug will be trigged when NMI happen in the L2 guest. The current code handles the NMI incorrectly. According to Intel SDM 31.7.1.2 (Resuming Guest Software after Handling an Exception), If bit 31 of the IDT-vectoring information fields is set, and the virtual NMIs VM-execution control is 1, while bits 10:8 in the IDT-vectoring information field is 2, bit 3 in the interruptibility-state field should be cleared to avoid the next VM entry fail.
--- xen/arch/x86/hvm/vmx/vmx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +3 -3
@@ -2621,7 +2621,8 @@ static void vmx_idtv_reinject(unsigned long idtv_info)* Clear NMI-blocking interruptibility info if an NMI delivery faulted. * Re-delivery will re-set it (see SDM 3B 25.7.1.2). */ -if ( (idtv_info &INTR_INFO_INTR_TYPE_MASK ) == (X86_EVENTTYPE_NMI <<8 ) ) +if ( cpu_has_vmx_vnmi && ((idtv_info &INTR_INFO_INTR_TYPE_MASK ) == + (X86_EVENTTYPE_NMI <<8 )) ) {unsigned long intr_info;
@@ -2772,8 +2773,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)hvm_maybe_deassert_evtchn_irq ();__vmread (IDT_VECTORING_INFO , &idtv_info); -if ( !nestedhvm_vcpu_in_guestmode (v) && - exit_reason !=EXIT_REASON_TASK_SWITCH ) +if ( exit_reason !=EXIT_REASON_TASK_SWITCH )vmx_idtv_reinject (idtv_info); switch ( exit_reason )
Signature · 1 line
1.9.1
Quoted 18 lines · Liang Li
This bug will be trigged when NMI happen in the L2 guest. The current code handles the NMI incorrectly. According to Intel SDM 31.7.1.2 (Resuming Guest Software after Handling an Exception), If bit 31 of the IDT-vectoring information fields is set, and the virtual NMIs VM-execution control is 1, while bits 10:8 in the IDT-vectoring information field is 2, bit 3 in the interruptibility-state field should be cleared to avoid the next VM entry fail.
Signed-off-by Liang Li <[email protected]>--- xen/arch/x86/hvm/vmx/vmx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)xen/arch/x86/hvm/vmx/vmx.c +0
-0
xen/arch/x86/hvm/vmx/vmx.c static void vmx_idtv_reinject(unsigned long idtv_info) · line 2625
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmx.c +2
-1@@ -2621,7 +2621,8 @@ static void vmx_idtv_reinject(unsigned long idtv_info)* Clear NMI-blocking interruptibility info if an NMI delivery faulted. * Re-delivery will re-set it (see SDM 3B 25.7.1.2). */ -if ( (idtv_info &INTR_INFO_INTR_TYPE_MASK ) == (X86_EVENTTYPE_NMI <<8 ) ) +if ( cpu_has_vmx_vnmi && ((idtv_info &INTR_INFO_INTR_TYPE_MASK ) == + (X86_EVENTTYPE_NMI <<8 )) )
This would be easier to read as
if ( cpu_has_vmx_vnmi &&
(idtv_info & INTR_INFO_INTR_TYPE_MASK) == (X86_EVENTTYPE_NMI<<8)) )
~Andrew
Quoted 13 lines
xen/arch/x86/hvm/vmx/vmx.c +1
-2{unsigned long intr_info;@@ -2772,8 +2773,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)hvm_maybe_deassert_evtchn_irq ();__vmread (IDT_VECTORING_INFO , &idtv_info); -if ( !nestedhvm_vcpu_in_guestmode (v) && - exit_reason !=EXIT_REASON_TASK_SWITCH ) +if ( exit_reason !=EXIT_REASON_TASK_SWITCH )vmx_idtv_reinject (idtv_info); switch ( exit_reason )
Quoted 28 lines · Andrew Cooper
Quoted 18 lines · Liang Li
This bug will be trigged when NMI happen in the L2 guest. The current code handles the NMI incorrectly. According to Intel SDM 31.7.1.2 (Resuming Guest Software after Handling an Exception), If bit 31 of the IDT-vectoring information fields is set, and the virtual NMIs VM-execution control is 1, while bits 10:8 in the IDT-vectoring information field is 2, bit 3 in the interruptibility-state field should be cleared to avoid the next VM entry fail.
Signed-off-by Liang Li <[email protected]>--- xen/arch/x86/hvm/vmx/vmx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)xen/arch/x86/hvm/vmx/vmx.c +0
-0xen/arch/x86/hvm/vmx/vmx.c static void vmx_idtv_reinject(unsigned long idtv_info) · line 2625
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmx.c +2
-1@@ -2621,7 +2621,8 @@ static void vmx_idtv_reinject(unsigned long idtv_info)* Clear NMI-blocking interruptibility info if an NMI delivery faulted. * Re-delivery will re-set it (see SDM 3B 25.7.1.2). */ -if ( (idtv_info &INTR_INFO_INTR_TYPE_MASK ) == (X86_EVENTTYPE_NMI <<8 ) ) +if ( cpu_has_vmx_vnmi && ((idtv_info &INTR_INFO_INTR_TYPE_MASK ) == + (X86_EVENTTYPE_NMI <<8 )) )This would be easier to read as
Quoted 2 lines
if (
cpu_has_vmx_vnmi&&(idtv_info & INTR_INFO_INTR_TYPE_MASK) == (X86_EVENTTYPE_NMI<<8)) )
I was going to say something similar, but I think in the past Jan has said that Liang's original is more in line with the coding style.
But I'll let him comment.
-George
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 08.04.15 at 11:20, <[email protected]> wrote:
Quoted 14 lines · Andrew Cooper
Quoted 13 lines · Liang Li
This bug will be trigged when NMI happen in the L2 guest. The current code handles the NMI incorrectly. According to Intel SDM 31.7.1.2 (Resuming Guest Software after Handling an Exception), If bit 31 of the IDT-vectoring information fields is set, and the virtual NMIs VM-execution control is 1, while bits 10:8 in the IDT-vectoring information field is 2, bit 3 in the interruptibility-state field should be cleared to avoid the next VM entry fail.
Signed-off-by Liang Li <[email protected]>--- xen/arch/x86/hvm/vmx/vmx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Quoted 6 lines
xen/arch/x86/hvm/vmx/vmx.c static void vmx_idtv_reinject(unsigned long idtv_info) · line 2621
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -2621,7 +2621,8 @@ static void vmx_idtv_reinject(unsigned long idtv_info)* Clear NMI-blocking interruptibility info if an NMI delivery faulted.
Quoted 6 lines
Quoted 5 lines
xen/arch/x86/hvm/vmx/vmx.c +2
-1* Re-delivery will re-set it (see SDM 3B 25.7.1.2). */ -if ( (idtv_info &INTR_INFO_INTR_TYPE_MASK ) == (X86_EVENTTYPE_NMI <<8 ) ) +if ( cpu_has_vmx_vnmi && ((idtv_info &INTR_INFO_INTR_TYPE_MASK ) == + (X86_EVENTTYPE_NMI <<8 )) )
Quoted 7 lines
Quoted 4 lines
This would be easier to read as
if (
cpu_has_vmx_vnmi&&(idtv_info & INTR_INFO_INTR_TYPE_MASK) == (X86_EVENTTYPE_NMI<<8)) )I was going to say something similar, but I think in the past Jan has said that Liang's original is more in line with the coding style.
No, my complaint here wouldn't be about coding style, but about the hard-coded 8 - it's not been that long ago that I replaced may of them, and I'd really like to see it replaced here too. Liang - can you please submit an incremental change (as the original one got committed already)? There should be several examples in VMX code on how the 8 can be avoided.
Jan
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
This would be easier to read as
if (
cpu_has_vmx_vnmi&&(idtv_info & INTR_INFO_INTR_TYPE_MASK) ==(X86_EVENTTYPE_NMI<<8)) )
I was going to say something similar, but I think in the past Jan has said that Liang's original is more in line with the coding style.
Quoted 7 lines
No, my complaint here wouldn't be about coding style, but about the hard- coded 8 - it's not been that long ago that I replaced may of them, and I'd really like to see it replaced here too. Liang - can you please submit an incremental change (as the original one got committed already)? There should be several examples in VMX code on how the 8 can be avoided.
Jan
Of course, with pleasure.
Liang
Quoted 11 lines
From: Li, Liang Z
Sent: Tuesday, April 07, 2015 9:27 PMThis bug will be trigged when NMI happen in the L2 guest. The current code handles the NMI incorrectly. According to Intel SDM 31.7.1.2 (Resuming Guest Software after Handling an Exception), If bit 31 of the IDT-vectoring information fields is set, and the virtual NMIs VM-execution control is 1, while bits 10:8 in the IDT-vectoring information field is 2, bit 3 in the interruptibility-state field should be cleared to avoid the next VM entry fail.
Quoted 1 line
Signed-off-by Liang Li <[email protected]>
Quoted 35 lines
--- xen/arch/x86/hvm/vmx/vmx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -2621,7 +2621,8 @@ static void vmx_idtv_reinject(unsigned long idtv_info) * Clear NMI-blocking interruptibility info if an NMI deliveryfaulted.
* Re-delivery will re-set it (see SDM 3B 25.7.1.2). */
- if ( (idtv_info&INTR_INFO_INTR_TYPE_MASK) ==
(X86_EVENTTYPE_NMI<<8) )
+ if (cpu_has_vmx_vnmi&& ((idtv_info&INTR_INFO_INTR_TYPE_MASK) ==xen/arch/x86/hvm/vmx/vmx.c +2
-2+ (X86_EVENTTYPE_NMI<<8)) ) {unsigned long intr_info;@@ -2772,8 +2773,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)hvm_maybe_deassert_evtchn_irq ();__vmread (IDT_VECTORING_INFO , &idtv_info); -if ( !nestedhvm_vcpu_in_guestmode (v) && - exit_reason !=EXIT_REASON_TASK_SWITCH ) +if ( exit_reason !=EXIT_REASON_TASK_SWITCH )vmx_idtv_reinject (idtv_info);switch (
exit_reason)
--
1.9.1