VMCS shadow high access consistency
PATCH 1/1 VMCS shadow high access consistency
Test for consistency of mixed accesses to full and high parts of 64-bit VMCS fields. (Currently just tests TSC_OFFSET, which is one of the fields shadowed by kvm.)
Signed-off-by Jim Mattson <[email protected]>
--- x86/unittests.cfg | 6 ++++++ x86/vmx.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)
x86/unittests.cfg +6 -0
@@ -242,6 +242,12 @@ extra_params = -cpu host,+vmx -append test_vmwrite_vmread arch = x86_64 groups = vmx +[vmx_test_vmcs_high] +file = vmx.flat +extra_params = -cpu host,+vmx -append test_vmcs_high +arch = x86_64 +groups = vmx + [vmx_test_vmcs_lifecycle] file = vmx.flat extra_params = -cpu host,+vmx -append test_vmcs_lifecycle
x86/vmx.c +26 -0
@@ -318,6 +318,30 @@ void test_vmwrite_vmread(void)free_page (vmcs); } +void test_vmcs_high (void ) +{ +struct vmcs *vmcs =alloc_page (); + +memset (vmcs,0 ,PAGE_SIZE ); + vmcs->revision_id = basic.revision; +assert (!vmcs_clear (vmcs)); +assert (!make_vmcs_current (vmcs)); + +vmcs_write (TSC_OFFSET ,0x0123456789ABCDEFull ); +report ("VMREAD TSC_OFFSET after VMWRITE TSC_OFFSET" , +vmcs_read (TSC_OFFSET ) ==0x0123456789ABCDEFull ); +report ("VMREAD TSC_OFFSET_HI after VMWRITE TSC_OFFSET" , +vmcs_read (TSC_OFFSET_HI ) ==0x01234567ull ); +vmcs_write (TSC_OFFSET_HI ,0x76543210ul ); +report ("VMREAD TSC_OFFSET_HI after VMWRITE TSC_OFFSET_HI" , +vmcs_read (TSC_OFFSET_HI ) ==0x76543210ul ); +report ("VMREAD TSC_OFFSET after VMWRITE TSC_OFFSET_HI" , +vmcs_read (TSC_OFFSET ) ==0x7654321089ABCDEFull ); + +assert (!vmcs_clear (vmcs)); +free_page (vmcs); +} +void test_vmcs_lifecycle (void ) {struct vmcs *vmcs[2 ] = {};
@@ -1824,6 +1848,8 @@ int main(int argc, const char *argv[])test_vmptrst ();if (test_wanted ("test_vmwrite_vmread" , argv, argc))test_vmwrite_vmread (); +if (test_wanted ("test_vmcs_high" , argv, argc)) +test_vmcs_high ();if (test_wanted ("test_vmcs_lifecycle" , argv, argc))test_vmcs_lifecycle ();if (test_wanted ("test_vmx_caps" , argv, argc))
Signature · 1 line
2.13.2.725.g09c95d1e9-goog
Quoted 64 lines · Jim Mattson
Test for consistency of mixed accesses to full and high parts of 64-bit VMCS fields. (Currently just tests
TSC_OFFSET, which is one of the fields shadowed by kvm.)Signed-off-by Jim Mattson <[email protected]>--- x86/unittests.cfg | 6 ++++++ x86/vmx.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)x86/unittests.cfg +6
-0@@ -242,6 +242,12 @@ extra_params = -cpu host,+vmx -append test_vmwrite_vmread arch = x86_64 groups = vmx +[vmx_test_vmcs_high] +file = vmx.flat +extra_params = -cpu host,+vmx -append test_vmcs_high +arch = x86_64 +groups = vmx + [vmx_test_vmcs_lifecycle] file = vmx.flat extra_params = -cpu host,+vmx -append test_vmcs_lifecyclex86/vmx.c +24
-0@@ -318,6 +318,30 @@ void test_vmwrite_vmread(void)free_page (vmcs); } +void test_vmcs_high (void ) +{ +struct vmcs *vmcs =alloc_page (); + +memset (vmcs,0 ,PAGE_SIZE ); + vmcs->revision_id = basic.revision; +assert (!vmcs_clear (vmcs)); +assert (!make_vmcs_current (vmcs)); + +vmcs_write (TSC_OFFSET ,0x0123456789ABCDEFull ); +report ("VMREAD TSC_OFFSET after VMWRITE TSC_OFFSET" , +vmcs_read (TSC_OFFSET ) ==0x0123456789ABCDEFull ); +report ("VMREAD TSC_OFFSET_HI after VMWRITE TSC_OFFSET" , +vmcs_read (TSC_OFFSET_HI ) ==0x01234567ull ); +vmcs_write (TSC_OFFSET_HI ,0x76543210ul ); +report ("VMREAD TSC_OFFSET_HI after VMWRITE TSC_OFFSET_HI" , +vmcs_read (TSC_OFFSET_HI ) ==0x76543210ul ); +report ("VMREAD TSC_OFFSET after VMWRITE TSC_OFFSET_HI" , +vmcs_read (TSC_OFFSET ) ==0x7654321089ABCDEFull ); + +assert (!vmcs_clear (vmcs)); +free_page (vmcs); +} +void test_vmcs_lifecycle (void ) {struct vmcs *vmcs[2 ] = {};
x86/vmx.c int main(int argc, const char *argv[]) · line 1855
Quoted 8 lines
x86/vmx.c +2
-0@@ -1824,6 +1848,8 @@ int main(int argc, const char *argv[])test_vmptrst ();if (test_wanted ("test_vmwrite_vmread" , argv, argc))test_vmwrite_vmread (); +if (test_wanted ("test_vmcs_high" , argv, argc)) +test_vmcs_high ();if (test_wanted ("test_vmcs_lifecycle" , argv, argc))test_vmcs_lifecycle ();if (test_wanted ("test_vmx_caps" , argv, argc))
Reviewed-by Paolo Bonzini <[email protected]>