x86: nvmx: fix bug in __enter_guest()
Subsystems (2)
PATCH v4 1/2 x86: nvmx: fix bug in __enter_guest()
__enter_guest() should only set the launched flag when a launch has succeeded. Thus, don't set the launched flag when the VMX_ENTRY_FAILURE, bit 31, is set in the VMCS exit reason.
--- x86/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
x86/vmx.c +1 -1
@@ -1820,7 +1820,7 @@ static void __enter_guest(u8 abort_flag, struct vmentry_failure *failure)abort (); } -if (!failure->early) { +if (!failure->early && !(vmcs_read (EXI_REASON ) &VMX_ENTRY_FAILURE )) { launched =1 ;check_for_guest_termination (); }
Signature · 1 line
2.23.0.237.gc6a4ce50a0-goog
PATCH v4 2/2 x86: nvmx: test max atomic switch MSRs
Excerise nested VMX's atomic MSR switch code (e.g., VM-entry MSR-load list) at the maximum number of MSRs supported, as described in the SDM, in the appendix chapter titled "MISCELLANEOUS DATA".
---
v3 -> v4
* Replace spaces w/ tabs.
* Replace comment as suggested by Sean.
* Make use of MIN().
* Refactor cleanup code so that only failure code path reenters guest an extra time.
lib/alloc_page.c | 5 ++ lib/alloc_page.h | 1 + x86/unittests.cfg | 2 +- x86/vmx_tests.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 1 deletion(-)
lib/alloc_page.c +5 -0
@@ -53,6 +53,11 @@ void free_pages(void *mem, unsigned long size)spin_unlock (&lock); } +void free_pages_by_order (void *mem,unsigned long order) +{ +free_pages (mem,1ul << (order +PAGE_SHIFT )); +} +void *alloc_page () {void *p;
lib/alloc_page.h +1 -0
@@ -14,5 +14,6 @@ void *alloc_page(void);void *alloc_pages (unsigned long order);void free_page (void *page);void free_pages (void *mem,unsigned long size); +void free_pages_by_order (void *mem,unsigned long order);#endif
x86/unittests.cfg +1 -1
@@ -227,7 +227,7 @@ extra_params = -cpu qemu64,+umip [vmx] file = vmx.flat -extra_params = -cpu host,+vmx -append "-exit_monitor_from_l2_test -ept_access* -vmx_smp* -vmx_vmcs_shadow_test" +extra_params = -cpu host,+vmx -append "-exit_monitor_from_l2_test -ept_access* -vmx_smp* -vmx_vmcs_shadow_test -atomic_switch_overflow_msrs_test" arch = x86_64 groups = vmx
x86/vmx_tests.c +134 -0
145 lines not on this page · raw message
Signature · 1 line
2.23.0.237.gc6a4ce50a0-goog
Quoted 15 lines · Marc Orr
__enter_guest()should only set the launched flag when a launch has succeeded. Thus, don't set the launched flag when theVMX_ENTRY_FAILURE, bit 31, is set in the VMCS exit reason.Reviewed-by Krish Sadhukhan <[email protected]>Signed-off-by Marc Orr <[email protected]>--- x86/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)x86/vmx.c +0
-0
x86/vmx.c static void __enter_guest(u8 abort_flag, struct vmentry_failure *failure) · line 1823
Quoted 5 lines
x86/vmx.c +1
-1@@ -1820,7 +1820,7 @@ static void __enter_guest(u8 abort_flag, struct vmentry_failure *failure)abort (); } -if (!failure->early) { +if (!failure->early && !(vmcs_read (EXI_REASON ) &VMX_ENTRY_FAILURE )) {
Good enough for now, but struct vmentry_failure really needs to be cleaned up and renamed.
Quoted 6 lines
x86/vmx.c +0
-0launched =1 ;check_for_guest_termination (); }Signature · 1 line
2.23.0.237.gc6a4ce50a0-goog