Fix vmptrst result type
PATCH 1/2 Fix vmptrst result type
vmptrst stores a 64-bit physical address to memory (or -1 if there is no current VMCS).
Signed-off-by Jim Mattson <[email protected]>
--- x86/vmx.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
x86/vmx.h +5 -2
@@ -5,6 +5,7 @@#include "processor.h" #include "bitops.h" #include "asm/page.h" +#include "asm/io.h" struct vmcs {u32 revision_id;/* vmcs revision identifier */
@@ -646,10 +647,12 @@ static inline int vmcs_write(enum Encoding enc, u64 val)static inline int vmcs_save (struct vmcs **vmcs) {bool ret; +unsigned long pa;u64 rflags =read_rflags () |X86_EFLAGS_CF |X86_EFLAGS_ZF ; - asmvolatile ("push %1; popf; vmptrst %2; setbe %0" - :"=q" (ret) :"q" (rflags),"m" (*vmcs) :"cc" ); + asmvolatile ("push %2; popf; vmptrst %1; setbe %0" + :"=q" (ret),"=m" (pa) :"r" (rflags) :"cc" ); + *vmcs = (pa ==-1ull ) ?NULL :phys_to_virt (pa);return ret; }
Signature · 1 line
2.13.2.932.g7449e964c-goog
PATCH 2/2 Test VM-entry in MOVSS shadow
VM-entry is disallowed in the shadow of a MOV-to-SS instruction. When the current-VMCS is valid, check that the instruction pointer falls through to the next instruction, the ALU flags are set to ZF (VMfailValid), and the VM-instruction error field contains 26 ("VM entry with events blocked by MOV SS.").
Signed-off-by Jim Mattson <[email protected]>
--- lib/x86/processor.h | 16 +++++---- x86/unittests.cfg | 6 ++++ x86/vmx_tests.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 7 deletions(-)
lib/x86/processor.h +9 -7
@@ -30,13 +30,15 @@#define X86_CR4_SMAP 0x00200000#define X86_CR4_PKE 0x00400000 -#define X86_EFLAGS_CF 0x00000001 -#define X86_EFLAGS_PF 0x00000004 -#define X86_EFLAGS_AF 0x00000010 -#define X86_EFLAGS_ZF 0x00000040 -#define X86_EFLAGS_SF 0x00000080 -#define X86_EFLAGS_OF 0x00000800 -#define X86_EFLAGS_AC 0x00040000 +#define X86_EFLAGS_CF 0x00000001 +#define X86_EFLAGS_FIXED 0x00000002 +#define X86_EFLAGS_PF 0x00000004 +#define X86_EFLAGS_AF 0x00000010 +#define X86_EFLAGS_ZF 0x00000040 +#define X86_EFLAGS_SF 0x00000080 +#define X86_EFLAGS_IF 0x00000200 +#define X86_EFLAGS_OF 0x00000800 +#define X86_EFLAGS_AC 0x00040000#define X86_IA32_EFER 0xc0000080#define X86_EFER_LMA (1UL << 8)
x86/unittests.cfg +6 -0
@@ -494,6 +494,12 @@ extra_params = -cpu host,+vmx -m 2048 -append ept_access_test_force_2m_page arch = x86_64 groups = vmx +[vmx_vmentry_movss_shadow_test] +file = vmx.flat +extra_params = -cpu host,+vmx -m 2048 -append vmentry_movss_shadow_test +arch = x86_64 +groups = vmx + [debug] file = debug.flat arch = x86_64
x86/vmx_tests.c +96 -0
107 lines not on this page · raw message
Signature · 1 line
2.13.2.932.g7449e964c-goog