KVM: selftests: Test SET_NESTED_STATE with 48-bit L2 on 57-bit L1
v2 cover KVM: selftests: Test SET_NESTED_STATE with 48-bit L2 on 57-bit L1
Prior to commit 9245fd6b8531 ("KVM: x86: model canonical checks more precisely"), KVM_SET_NESTED_STATE would fail if the state was captured with L2 active, L1 had CR4.LA57 set, L2 did not, and the VMCS12.HOST_GSBASE (or other host-state field checked for canonicality) had an address greater than 48 bits wide.
Add a regression test that reproduces the KVM_SET_NESTED_STATE failure conditions. To do so, the first three patches add support for 5-level paging in the selftest L1 VM.
v1 -> v2
Ended the page walking loops before visiting 4K mappings [Yosry] Changed VM_MODE_PXXV48_4K into VM_MODE_PXXVYY_4K;
use 5-level paging when possible [Sean]
Removed the check for non-NULL vmx_pages in guest_code() [Yosry]
Jim Mattson (4):
KVM: selftests: Use a loop to create guest page tables
KVM: selftests: Use a loop to walk guest page tables
KVM: selftests: Change VM_MODE_PXXV48_4K to VM_MODE_PXXVYY_4K
KVM: selftests: Add a VMX test for LA57 nested state
tools/testing/selftests/kvm/Makefile.kvm | 1 + .../testing/selftests/kvm/include/kvm_util.h | 4 +- .../selftests/kvm/include/x86/processor.h | 2 +- .../selftests/kvm/lib/arm64/processor.c | 2 +- tools/testing/selftests/kvm/lib/kvm_util.c | 30 ++-- .../testing/selftests/kvm/lib/x86/processor.c | 80 +++++------ tools/testing/selftests/kvm/lib/x86/vmx.c | 6 +- .../kvm/x86/vmx_la57_nested_state_test.c | 134 ++++++++++++++++++ 8 files changed, 197 insertions(+), 62 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86/vmx_la57_nested_state_test.c
Signature · 1 line
2.51.1.851.g4ebd6896fd-goog
PATCH v2 1/4 KVM: selftests: Use a loop to create guest page tables
Walk the guest page tables via a loop when creating new mappings, instead of using unique variables for each level of the page tables.
This simplifies the code and makes it easier to support 5-level paging in the future.
--- .../testing/selftests/kvm/lib/x86/processor.c | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-)
tools/testing/selftests/kvm/lib/x86/processor.c +11 -14
@@ -218,8 +218,8 @@ static uint64_t *virt_create_upper_pte(struct kvm_vm *vm,void __virt_pg_map (struct kvm_vm *vm,uint64_t vaddr,uint64_t paddr,int level) {const uint64_t pg_size =PG_LEVEL_SIZE (level); -uint64_t *pml4e, *pdpe, *pde; -uint64_t *pte; +uint64_t *pte = &vm->pgd; +int current_level;TEST_ASSERT (vm->mode ==VM_MODE_PXXV48_4K ,"Unknown or unsupported guest mode, mode: 0x%x" , vm->mode);
@@ -243,20 +243,17 @@ void __virt_pg_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr, int level)* Allocate upper level page tables, if not already present. Return * early if a hugepage was created. */ - pml4e =virt_create_upper_pte (vm, &vm->pgd, vaddr, paddr,PG_LEVEL_512G , level); -if (*pml4e &PTE_LARGE_MASK ) -return ; - - pdpe =virt_create_upper_pte (vm, pml4e, vaddr, paddr,PG_LEVEL_1G , level); -if (*pdpe &PTE_LARGE_MASK ) -return ; - - pde =virt_create_upper_pte (vm, pdpe, vaddr, paddr,PG_LEVEL_2M , level); -if (*pde &PTE_LARGE_MASK ) -return ; +for (current_level = vm->pgtable_levels; + current_level >PG_LEVEL_4K ; + current_level--) { + pte =virt_create_upper_pte (vm, pte, vaddr, paddr, + current_level, level); +if (*pte &PTE_LARGE_MASK ) +return ; + }/* Fill in page table entry. */ - pte =virt_get_pte (vm, pde, vaddr,PG_LEVEL_4K ); + pte =virt_get_pte (vm, pte, vaddr,PG_LEVEL_4K );TEST_ASSERT (!(*pte &PTE_PRESENT_MASK ),"PTE already present for 4k page at vaddr: 0x%lx" , vaddr); *pte =PTE_PRESENT_MASK |PTE_WRITABLE_MASK | (paddr &PHYSICAL_PAGE_MASK );
Signature · 1 line
2.51.1.851.g4ebd6896fd-goog
Re: [PATCH v2 1/4] KVM: selftests: Use a loop to create guest page tables
Quoted 7 lines · Jim Mattson
Walk the guest page tables via a loop when creating new mappings, instead of using unique variables for each level of the page tables.
This simplifies the code and makes it easier to support 5-level paging in the future.
Signed-off-by Jim Mattson <[email protected]>
Quoted 52 lines
--- .../testing/selftests/kvm/lib/x86/processor.c | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-)tools/testing/selftests/kvm/lib/x86/processor.c +11
-14@@ -218,8 +218,8 @@ static uint64_t *virt_create_upper_pte(struct kvm_vm *vm,void __virt_pg_map (struct kvm_vm *vm,uint64_t vaddr,uint64_t paddr,int level) {const uint64_t pg_size =PG_LEVEL_SIZE (level); -uint64_t *pml4e, *pdpe, *pde; -uint64_t *pte; +uint64_t *pte = &vm->pgd; +int current_level;TEST_ASSERT (vm->mode ==VM_MODE_PXXV48_4K ,"Unknown or unsupported guest mode, mode: 0x%x" , vm->mode);@@ -243,20 +243,17 @@ void __virt_pg_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr, int level)* Allocate upper level page tables, if not already present. Return * early if a hugepage was created. */ - pml4e =virt_create_upper_pte (vm, &vm->pgd, vaddr, paddr,PG_LEVEL_512G , level); -if (*pml4e &PTE_LARGE_MASK ) -return ; - - pdpe =virt_create_upper_pte (vm, pml4e, vaddr, paddr,PG_LEVEL_1G , level); -if (*pdpe &PTE_LARGE_MASK ) -return ; - - pde =virt_create_upper_pte (vm, pdpe, vaddr, paddr,PG_LEVEL_2M , level); -if (*pde &PTE_LARGE_MASK ) -return ; +for (current_level = vm->pgtable_levels; + current_level >PG_LEVEL_4K ; + current_level--) { + pte =virt_create_upper_pte (vm, pte, vaddr, paddr, + current_level, level); +if (*pte &PTE_LARGE_MASK ) +return ; + }/* Fill in page table entry. */ - pte =virt_get_pte (vm, pde, vaddr,PG_LEVEL_4K ); + pte =virt_get_pte (vm, pte, vaddr,PG_LEVEL_4K );TEST_ASSERT (!(*pte &PTE_PRESENT_MASK ),"PTE already present for 4k page at vaddr: 0x%lx" , vaddr); *pte =PTE_PRESENT_MASK |PTE_WRITABLE_MASK | (paddr &PHYSICAL_PAGE_MASK );Signature · 1 line
2.51.1.851.g4ebd6896fd-goog
PATCH v2 2/4 KVM: selftests: Use a loop to walk guest page tables
In reply to Jim MattsonWalk the guest page tables via a loop when searching for a PTE, instead of using unique variables for each level of the page tables.
This simplifies the code and makes it easier to support 5-level paging in the future.
--- .../testing/selftests/kvm/lib/x86/processor.c | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-)
tools/testing/selftests/kvm/lib/x86/processor.c +10 -13
@@ -307,7 +307,8 @@ static bool vm_is_target_pte(uint64_t *pte, int *level, int current_level)uint64_t *__vm_get_page_table_entry (struct kvm_vm *vm,uint64_t vaddr,int *level) { -uint64_t *pml4e, *pdpe, *pde; +uint64_t *pte = &vm->pgd; +int current_level;TEST_ASSERT (!vm->arch.is_pt_protected,"Walking page tables of protected guests is impossible" );
@@ -328,19 +329,15 @@ uint64_t *__vm_get_page_table_entry(struct kvm_vm *vm, uint64_t vaddr,TEST_ASSERT (vaddr == (((int64_t )vaddr <<16 ) >>16 ),"Canonical check failed. The virtual address is invalid." ); - pml4e =virt_get_pte (vm, &vm->pgd, vaddr,PG_LEVEL_512G ); -if (vm_is_target_pte (pml4e, level,PG_LEVEL_512G )) -return pml4e; - - pdpe =virt_get_pte (vm, pml4e, vaddr,PG_LEVEL_1G ); -if (vm_is_target_pte (pdpe, level,PG_LEVEL_1G )) -return pdpe; - - pde =virt_get_pte (vm, pdpe, vaddr,PG_LEVEL_2M ); -if (vm_is_target_pte (pde, level,PG_LEVEL_2M )) -return pde; +for (current_level = vm->pgtable_levels; + current_level >PG_LEVEL_4K ; + current_level--) { + pte =virt_get_pte (vm, pte, vaddr, current_level); +if (vm_is_target_pte (pte, level, current_level)) +return pte; + } -return virt_get_pte (vm, pde, vaddr,PG_LEVEL_4K ); +return virt_get_pte (vm, pte, vaddr,PG_LEVEL_4K ); }uint64_t *vm_get_page_table_entry (struct kvm_vm *vm,uint64_t vaddr)
Signature · 1 line
2.51.1.851.g4ebd6896fd-goog
Re: [PATCH v2 2/4] KVM: selftests: Use a loop to walk guest page tables
Quoted 7 lines · Jim Mattson
Walk the guest page tables via a loop when searching for a PTE, instead of using unique variables for each level of the page tables.
This simplifies the code and makes it easier to support 5-level paging in the future.
Signed-off-by Jim Mattson <[email protected]>
Quoted 49 lines
--- .../testing/selftests/kvm/lib/x86/processor.c | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-)tools/testing/selftests/kvm/lib/x86/processor.c +10
-13@@ -307,7 +307,8 @@ static bool vm_is_target_pte(uint64_t *pte, int *level, int current_level)uint64_t *__vm_get_page_table_entry (struct kvm_vm *vm,uint64_t vaddr,int *level) { -uint64_t *pml4e, *pdpe, *pde; +uint64_t *pte = &vm->pgd; +int current_level;TEST_ASSERT (!vm->arch.is_pt_protected,"Walking page tables of protected guests is impossible" );@@ -328,19 +329,15 @@ uint64_t *__vm_get_page_table_entry(struct kvm_vm *vm, uint64_t vaddr,TEST_ASSERT (vaddr == (((int64_t )vaddr <<16 ) >>16 ),"Canonical check failed. The virtual address is invalid." ); - pml4e =virt_get_pte (vm, &vm->pgd, vaddr,PG_LEVEL_512G ); -if (vm_is_target_pte (pml4e, level,PG_LEVEL_512G )) -return pml4e; - - pdpe =virt_get_pte (vm, pml4e, vaddr,PG_LEVEL_1G ); -if (vm_is_target_pte (pdpe, level,PG_LEVEL_1G )) -return pdpe; - - pde =virt_get_pte (vm, pdpe, vaddr,PG_LEVEL_2M ); -if (vm_is_target_pte (pde, level,PG_LEVEL_2M )) -return pde; +for (current_level = vm->pgtable_levels; + current_level >PG_LEVEL_4K ; + current_level--) { + pte =virt_get_pte (vm, pte, vaddr, current_level); +if (vm_is_target_pte (pte, level, current_level)) +return pte; + } -return virt_get_pte (vm, pde, vaddr,PG_LEVEL_4K ); +return virt_get_pte (vm, pte, vaddr,PG_LEVEL_4K ); }uint64_t *vm_get_page_table_entry (struct kvm_vm *vm,uint64_t vaddr)Signature · 1 line
2.51.1.851.g4ebd6896fd-goog
PATCH v2 3/4 KVM: selftests: Change VM_MODE_PXXV48_4K to VM_MODE_PXXVYY_4K
In reply to Jim MattsonUse 57-bit addresses with 5-level paging on hardware that supports LA57. Continue to use 48-bit addresses with 4-level paging on hardware that doesn't support LA57.
--- .../testing/selftests/kvm/include/kvm_util.h | 4 +-- .../selftests/kvm/include/x86/processor.h | 2 +- .../selftests/kvm/lib/arm64/processor.c | 2 +- tools/testing/selftests/kvm/lib/kvm_util.c | 30 ++++++++++--------- .../testing/selftests/kvm/lib/x86/processor.c | 30 +++++++++++-------- tools/testing/selftests/kvm/lib/x86/vmx.c | 6 ++-- 6 files changed, 40 insertions(+), 34 deletions(-)
tools/testing/selftests/kvm/include/kvm_util.h +2 -2
@@ -177,7 +177,7 @@ enum vm_guest_mode {VM_MODE_P40V48_4K ,VM_MODE_P40V48_16K ,VM_MODE_P40V48_64K , -VM_MODE_PXXV48_4K ,/* For 48bits VA but ANY bits PA */ +VM_MODE_PXXVYY_4K ,/* For 48-bit or 57-bit VA, depending on host support */ VM_MODE_P47V64_4K ,VM_MODE_P44V64_4K , VM_MODE_P36V48_4K,
@@ -219,7 +219,7 @@ extern enum vm_guest_mode vm_mode_default;#elif defined(__x86_64__) -#define VM_MODE_DEFAULT VM_MODE_PXXV48_4K +#define VM_MODE_DEFAULT VM_MODE_PXXVYY_4K#define MIN_PAGE_SHIFT 12U#define ptes_per_page (page_size) ((page_size) / 8)
tools/testing/selftests/kvm/include/x86/processor.h +1 -1
@@ -1441,7 +1441,7 @@ enum pg_level {PG_LEVEL_2M ,PG_LEVEL_1G ,PG_LEVEL_512G , - PG_LEVEL_NUM + PG_LEVEL_256T };#define PG_LEVEL_SHIFT (_level) ((_level - 1) * 9 + 12)
tools/testing/selftests/kvm/lib/arm64/processor.c +1 -1
@@ -324,7 +324,7 @@ void aarch64_vcpu_setup(struct kvm_vcpu *vcpu, struct kvm_vcpu_init *init)/* Configure base granule size */ switch (vm->mode) { -case VM_MODE_PXXV48_4K : +case VM_MODE_PXXVYY_4K :TEST_FAIL ("AArch64 does not support 4K sized pages " "with ANY-bit physical address ranges" );case VM_MODE_P52V48_64K :
tools/testing/selftests/kvm/lib/kvm_util.c +16 -14
@@ -201,7 +201,7 @@ const char *vm_guest_mode_string(uint32_t i) [VM_MODE_P40V48_4K] = "PA-bits:40, VA-bits:48, 4K pages", [VM_MODE_P40V48_16K] = "PA-bits:40, VA-bits:48, 16K pages", [VM_MODE_P40V48_64K] = "PA-bits:40, VA-bits:48, 64K pages", - [VM_MODE_PXXV48_4K] = "PA-bits:ANY, VA-bits:48, 4K pages", + [VM_MODE_PXXVYY_4K] = "PA-bits:ANY, VA-bits:48 or 57, 4K pages", [VM_MODE_P47V64_4K] = "PA-bits:47, VA-bits:64, 4K pages", [VM_MODE_P44V64_4K] = "PA-bits:44, VA-bits:64, 4K pages", [VM_MODE_P36V48_4K] = "PA-bits:36, VA-bits:48, 4K pages",
@@ -228,7 +228,7 @@ const struct vm_guest_mode_params vm_guest_mode_params[] = { [VM_MODE_P40V48_4K] = { 40, 48, 0x1000, 12 }, [VM_MODE_P40V48_16K] = { 40, 48, 0x4000, 14 }, [VM_MODE_P40V48_64K] = { 40, 48, 0x10000, 16 }, - [VM_MODE_PXXV48_4K] = { 0, 0, 0x1000, 12 }, + [VM_MODE_PXXVYY_4K] = { 0, 0, 0x1000, 12 }, [VM_MODE_P47V64_4K] = { 47, 64, 0x1000, 12 }, [VM_MODE_P44V64_4K] = { 44, 64, 0x1000, 12 }, [VM_MODE_P36V48_4K] = { 36, 48, 0x1000, 12 },
@@ -310,24 +310,26 @@ struct kvm_vm *____vm_create(struct vm_shape shape)case VM_MODE_P36V47_16K : vm->pgtable_levels =3 ;break ; -case VM_MODE_PXXV48_4K : +case VM_MODE_PXXVYY_4K :#ifdef __x86_64__kvm_get_cpu_address_width (&vm->pa_bits, &vm->va_bits);kvm_init_vm_address_properties (vm); -/* -* Ignore KVM support for 5-level paging (vm->va_bits == 57), -* it doesn't take effect unless a CR4.LA57 is set, which it -* isn't for this mode (48-bit virtual address space). -*/ -TEST_ASSERT (vm->va_bits ==48 || vm->va_bits ==57 , -"Linear address width (%d bits) not supported" , - vm->va_bits); +pr_debug ("Guest physical address width detected: %d\n" , vm->pa_bits); - vm->pgtable_levels =4 ; - vm->va_bits =48 ; +pr_debug ("Guest virtual address width detected: %d\n" , + vm->va_bits); + +if (vm->va_bits ==57 ) { + vm->pgtable_levels =5 ; + }else { +TEST_ASSERT (vm->va_bits ==48 , +"Unexpected guest virtual address width: %d" , + vm->va_bits); + vm->pgtable_levels =4 ; + }#else -TEST_FAIL ("VM_MODE_PXXV48_4K not supported on non-x86 platforms" ); +TEST_FAIL ("VM_MODE_PXXVYY_4K not supported on non-x86 platforms" );#endif break ;case VM_MODE_P47V64_4K :
tools/testing/selftests/kvm/lib/x86/processor.c +17 -13
@@ -158,10 +158,10 @@ bool kvm_is_tdp_enabled(void)void virt_arch_pgd_alloc (struct kvm_vm *vm) { -TEST_ASSERT (vm->mode ==VM_MODE_PXXV48_4K ,"Attempt to use " -"unknown or unsupported guest mode, mode: 0x%x" , vm->mode); +TEST_ASSERT (vm->mode ==VM_MODE_PXXVYY_4K , +"Unknown or unsupported guest mode: 0x%x" , vm->mode); -/* If needed, create page map l4 table. */ +/* If needed, create the top-level page table. */ if (!vm->pgd_created) { vm->pgd =vm_alloc_page_table (vm); vm->pgd_created = true;
@@ -221,8 +221,8 @@ void __virt_pg_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr, int level)uint64_t *pte = &vm->pgd;int current_level; -TEST_ASSERT (vm->mode ==VM_MODE_PXXV48_4K , -"Unknown or unsupported guest mode, mode: 0x%x" , vm->mode); +TEST_ASSERT (vm->mode ==VM_MODE_PXXVYY_4K , +"Unknown or unsupported guest mode: 0x%x" , vm->mode);TEST_ASSERT ((vaddr % pg_size) ==0 , "Virtual address not aligned,\n"
@@ -307,27 +307,28 @@ static bool vm_is_target_pte(uint64_t *pte, int *level, int current_level)uint64_t *__vm_get_page_table_entry (struct kvm_vm *vm,uint64_t vaddr,int *level) { +int va_width =12 + (vm->pgtable_levels) *9 ;uint64_t *pte = &vm->pgd;int current_level;TEST_ASSERT (!vm->arch.is_pt_protected,"Walking page tables of protected guests is impossible" ); -TEST_ASSERT (*level >=PG_LEVEL_NONE && *level <PG_LEVEL_NUM , +TEST_ASSERT (*level >=PG_LEVEL_NONE && *level <= vm->pgtable_levels,"Invalid PG_LEVEL_* '%d'" , *level); -TEST_ASSERT (vm->mode ==VM_MODE_PXXV48_4K ,"Attempt to use " -"unknown or unsupported guest mode, mode: 0x%x" , vm->mode); +TEST_ASSERT (vm->mode ==VM_MODE_PXXVYY_4K , +"Unknown or unsupported guest mode: 0x%x" , vm->mode);TEST_ASSERT (sparsebit_is_set (vm->vpages_valid, (vaddr >> vm->page_shift)),"Invalid virtual address, vaddr: 0x%lx" , vaddr);/* -* Based on the mode check above there are 48 bits in the vaddr, so -* shift 16 to sign extend the last bit (bit-47), +* Check that the vaddr is a sign-extended va_width value. */ -TEST_ASSERT (vaddr == (((int64_t )vaddr <<16 ) >>16 ), -"Canonical check failed. The virtual address is invalid." ); +TEST_ASSERT (vaddr == + (((int64_t )vaddr << (64 - va_width) >> (64 - va_width))), +"Canonical check failed. The virtual address is invalid." ); for (current_level = vm->pgtable_levels; current_level > PG_LEVEL_4K;
@@ -520,7 +521,8 @@ static void vcpu_init_sregs(struct kvm_vm *vm, struct kvm_vcpu *vcpu) {struct kvm_sregs sregs; -TEST_ASSERT_EQ (vm->mode,VM_MODE_PXXV48_4K ); +TEST_ASSERT (vm->mode ==VM_MODE_PXXVYY_4K , +"Unknown or unsupported guest mode: 0x%x" , vm->mode);/* Set mode specific system register values. */ vcpu_sregs_get (vcpu, &sregs);
@@ -534,6 +536,8 @@ static void vcpu_init_sregs(struct kvm_vm *vm, struct kvm_vcpu *vcpu) sregs.cr4 |=X86_CR4_PAE |X86_CR4_OSFXSR ;if (kvm_cpu_has (X86_FEATURE_XSAVE )) sregs.cr4 |=X86_CR4_OSXSAVE ; +if (vm->pgtable_levels ==5 ) + sregs.cr4 |=X86_CR4_LA57 ; sregs.efer |= (EFER_LME |EFER_LMA |EFER_NX );kvm_seg_set_unusable (&sregs.ldt);
tools/testing/selftests/kvm/lib/x86/vmx.c +3 -3
@@ -401,11 +401,11 @@ void __nested_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm,struct eptPageTableEntry *pt = vmx->eptp_hva, *pte;uint16_t index; -TEST_ASSERT (vm->mode ==VM_MODE_PXXV48_4K ,"Attempt to use " -"unknown or unsupported guest mode, mode: 0x%x" , vm->mode); +TEST_ASSERT (vm->mode ==VM_MODE_PXXVYY_4K , +"Unknown or unsupported guest mode: 0x%x" , vm->mode);TEST_ASSERT ((nested_paddr >>48 ) ==0 , -"Nested physical address 0x%lx requires 5-level paging" , +"Nested physical address 0x%lx is > 48-bits and requires 5-level EPT" , nested_paddr);TEST_ASSERT ((nested_paddr % page_size) ==0 , "Nested physical address not on page boundary,\n"
Signature · 1 line
2.51.1.851.g4ebd6896fd-goog
PATCH v2 4/4 KVM: selftests: Add a VMX test for LA57 nested state
In reply to Jim MattsonAdd a selftest that verifies KVM's ability to save and restore nested state when the L1 guest is using 5-level paging and the L2 guest is using 4-level paging. Specifically, canonicality tests of the VMCS12 host-state fields should accept 57-bit virtual addresses.
--- tools/testing/selftests/kvm/Makefile.kvm | 1 + .../kvm/x86/vmx_la57_nested_state_test.c | 134 ++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 tools/testing/selftests/kvm/x86/vmx_la57_nested_state_test.c
tools/testing/selftests/kvm/Makefile.kvm +1 -0
@@ -117,6 +117,7 @@ TEST_GEN_PROGS_x86 += x86/vmx_exception_with_invalid_guest_state TEST_GEN_PROGS_x86 += x86/vmx_msrs_test TEST_GEN_PROGS_x86 += x86/vmx_invalid_nested_guest_state TEST_GEN_PROGS_x86 += x86/vmx_set_nested_state_test +TEST_GEN_PROGS_x86 += x86/vmx_la57_nested_state_test TEST_GEN_PROGS_x86 += x86/vmx_tsc_adjust_test TEST_GEN_PROGS_x86 += x86/vmx_nested_tsc_scaling_test TEST_GEN_PROGS_x86 += x86/apic_bus_clock_test
tools/testing/selftests/kvm/x86/vmx_la57_nested_state_test.c new file +134 -0
134 lines not on this page · raw message
Signature · 1 line
2.51.1.851.g4ebd6896fd-goog
Sean Christopherson
maintainerQuoted 11 lines · Jim Mattson
Prior to commit
9245fd6b8531("KVM: x86: model canonical checks more precisely"),KVM_SET_NESTED_STATEwould fail if the state was captured with L2 active, L1 had CR4.LA57 set, L2 did not, and the VMCS12.HOST_GSBASE (or other host-state field checked for canonicality) had an address greater than 48 bits wide.Add a regression test that reproduces the
KVM_SET_NESTED_STATEfailure conditions. To do so, the first three patches add support for 5-level paging in the selftest L1 VM.[...]
Applied to kvm-x86 selftests, thanks!
[1/4] KVM: selftests: Use a loop to create guest page tables
https://github.com/kvm-x86/linux/commit/ae5b498b8da9 [2/4] KVM: selftests: Use a loop to walk guest page tables https://github.com/kvm-x86/linux/commit/2103a8baf5cb [3/4] KVM: selftests: Change VM_MODE_PXXV48_4K to VM_MODE_PXXVYY_4K https://github.com/kvm-x86/linux/commit/ec5806639e39 [4/4] KVM: selftests: Add a VMX test for LA57 nested state https://github.com/kvm-x86/linux/commit/6a8818de21d2