KVM: selftests: Introduce selftests for enlightened MSR-Bitmap feature
cover KVM: selftests: Introduce selftests for enlightened MSR-Bitmap feature
KVM gained support for enlightened MSR-Bitmap Hyper-V feature (Hyper-V on KVM) for both nVMX and nSVM, test it in selftests.
Vitaly Kuznetsov (6):
KVM: selftests: Adapt hyperv_cpuid test to the newly introduced
Enlightened MSR-Bitmap
KVM: selftests: nVMX: Properly deal with 'hv_clean_fields'
KVM: selftests: nVMX: Add enlightened MSR-Bitmap selftest
KVM: selftests: nSVM: Set up MSR-Bitmap for SVM guests
KVM: selftests: nSVM: Update 'struct vmcb_control_area' definition
KVM: selftests: nSVM: Add enlightened MSR-Bitmap selftest
tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/include/x86_64/evmcs.h | 150 ++++++++++++++- .../selftests/kvm/include/x86_64/svm.h | 9 +- .../selftests/kvm/include/x86_64/svm_util.h | 6 + tools/testing/selftests/kvm/lib/x86_64/svm.c | 6 + .../testing/selftests/kvm/x86_64/evmcs_test.c | 64 ++++++- .../selftests/kvm/x86_64/hyperv_cpuid.c | 29 +-- .../selftests/kvm/x86_64/hyperv_svm_test.c | 175 ++++++++++++++++++ 8 files changed, 424 insertions(+), 16 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
Signature · 1 line
2.34.1
PATCH 1/6 KVM: selftests: Adapt hyperv_cpuid test to the newly introduced Enlightened MSR-Bitmap
CPUID 0x40000000.EAX is now always present as it has Enlightened MSR-Bitmap feature bit set. Adapt the test accordingly. Opportunistically add a check for the supported eVMCS version range.
--- .../selftests/kvm/x86_64/hyperv_cpuid.c | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-)
tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c +17 -12
@@ -49,16 +49,13 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries, bool evmcs_expected) {int i; -int nent =9 ; +int nent_expected =10 ;u32 test_val; -if (evmcs_expected) - nent +=1 ;/* 0x4000000A */ - -TEST_ASSERT (hv_cpuid_entries->nent == nent, +TEST_ASSERT (hv_cpuid_entries->nent == nent_expected,"KVM_GET_SUPPORTED_HV_CPUID should return %d entries" -" with evmcs=%d (returned %d)" , - nent, evmcs_expected, hv_cpuid_entries->nent); +" (returned %d)" , + nent_expected, hv_cpuid_entries->nent);for (i =0 ; i < hv_cpuid_entries->nent; i++) {struct kvm_cpuid_entry2 *entry = &hv_cpuid_entries->entries[i];
@@ -68,9 +65,6 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries,"function %x is our of supported range" , entry->function); -TEST_ASSERT (evmcs_expected || (entry->function !=0x4000000A ), -"0x4000000A leaf should not be reported" ); -TEST_ASSERT (entry->index ==0 ,".index field should be zero" );
@@ -97,8 +91,20 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries,"NoNonArchitecturalCoreSharing bit" " doesn't reflect SMT setting");break ; - } +case 0x4000000A : +TEST_ASSERT (entry->eax & (1UL <<19 ), +"Enlightened MSR-Bitmap should always be supported" +" 0x40000000.EAX: %x" , entry->eax); +if (evmcs_expected) +TEST_ASSERT ((entry->eax &0xffff ) ==0x101 , +"Supported Enlightened VMCS version range is supposed to be 1:1" +" 0x40000000.EAX: %x" , entry->eax); + +break ; +default : +break ; + }/* * If needed for debug: * fprintf(stdout,
@@ -107,7 +113,6 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries,* entry->edx); */ } - }void test_hv_cpuid_e2big (struct kvm_vm *vm,bool system)
Signature · 1 line
2.34.1
PATCH 2/6 KVM: selftests: nVMX: Properly deal with 'hv_clean_fields'
In reply to Vitaly KuznetsovInstead of just resetting 'hv_clean_fields' to 0 on every enlightened vmresume, do the expected cleaning of the corresponding bit on enlightened vmwrite. Avoid direct access to 'current_evmcs' from evmcs_test to support the change.
--- .../selftests/kvm/include/x86_64/evmcs.h | 150 +++++++++++++++++- .../testing/selftests/kvm/x86_64/evmcs_test.c | 5 +- 2 files changed, 152 insertions(+), 3 deletions(-)
tools/testing/selftests/kvm/include/x86_64/evmcs.h +149 -1
@@ -213,6 +213,25 @@ struct hv_enlightened_vmcs {u64 padding64_6[7 ]; }; +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE 0 +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_IO_BITMAP BIT(0) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP BIT(1) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2 BIT(2) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1 BIT(3) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_PROC BIT(4) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EVENT BIT(5) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_ENTRY BIT(6) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EXCPN BIT(7) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR BIT(8) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_XLAT BIT(9) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC BIT(10) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 BIT(11) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 BIT(12) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER BIT(13) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 BIT(14) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ENLIGHTENMENTSCONTROL BIT(15) +#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL 0xFFFF +#define HV_X64_MSR_VP_ASSIST_PAGE 0x40000073#define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE 0x00000001#define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT 12
@@ -648,381 +667,507 @@ static inline int evmcs_vmwrite(uint64_t encoding, uint64_t value)switch (encoding) {case GUEST_RIP : current_evmcs->guest_rip = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case GUEST_RSP : current_evmcs->guest_rsp = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC ;break ;case GUEST_RFLAGS : current_evmcs->guest_rflags = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC ;break ;case HOST_IA32_PAT : current_evmcs->host_ia32_pat = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_IA32_EFER : current_evmcs->host_ia32_efer = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_CR0 : current_evmcs->host_cr0 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_CR3 : current_evmcs->host_cr3 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_CR4 : current_evmcs->host_cr4 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_IA32_SYSENTER_ESP : current_evmcs->host_ia32_sysenter_esp = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_IA32_SYSENTER_EIP : current_evmcs->host_ia32_sysenter_eip = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_RIP : current_evmcs->host_rip = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case IO_BITMAP_A : current_evmcs->io_bitmap_a = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_IO_BITMAP ;break ;case IO_BITMAP_B : current_evmcs->io_bitmap_b = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_IO_BITMAP ;break ;case MSR_BITMAP : current_evmcs->msr_bitmap = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP ;break ;case GUEST_ES_BASE : current_evmcs->guest_es_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_CS_BASE : current_evmcs->guest_cs_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_SS_BASE : current_evmcs->guest_ss_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_DS_BASE : current_evmcs->guest_ds_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_FS_BASE : current_evmcs->guest_fs_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_GS_BASE : current_evmcs->guest_gs_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_LDTR_BASE : current_evmcs->guest_ldtr_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_TR_BASE : current_evmcs->guest_tr_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_GDTR_BASE : current_evmcs->guest_gdtr_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_IDTR_BASE : current_evmcs->guest_idtr_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case TSC_OFFSET : current_evmcs->tsc_offset = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2 ;break ;case VIRTUAL_APIC_PAGE_ADDR : current_evmcs->virtual_apic_page_addr = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2 ;break ;case VMCS_LINK_POINTER : current_evmcs->vmcs_link_pointer = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_IA32_DEBUGCTL : current_evmcs->guest_ia32_debugctl = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_IA32_PAT : current_evmcs->guest_ia32_pat = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_IA32_EFER : current_evmcs->guest_ia32_efer = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_PDPTR0 : current_evmcs->guest_pdptr0 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_PDPTR1 : current_evmcs->guest_pdptr1 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_PDPTR2 : current_evmcs->guest_pdptr2 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_PDPTR3 : current_evmcs->guest_pdptr3 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_PENDING_DBG_EXCEPTIONS : current_evmcs->guest_pending_dbg_exceptions = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_SYSENTER_ESP : current_evmcs->guest_sysenter_esp = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_SYSENTER_EIP : current_evmcs->guest_sysenter_eip = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case CR0_GUEST_HOST_MASK : current_evmcs->cr0_guest_host_mask = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR ;break ;case CR4_GUEST_HOST_MASK : current_evmcs->cr4_guest_host_mask = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR ;break ;case CR0_READ_SHADOW : current_evmcs->cr0_read_shadow = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR ;break ;case CR4_READ_SHADOW : current_evmcs->cr4_read_shadow = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR ;break ;case GUEST_CR0 : current_evmcs->guest_cr0 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR ;break ;case GUEST_CR3 : current_evmcs->guest_cr3 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR ;break ;case GUEST_CR4 : current_evmcs->guest_cr4 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR ;break ;case GUEST_DR7 : current_evmcs->guest_dr7 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR ;break ;case HOST_FS_BASE : current_evmcs->host_fs_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER ;break ;case HOST_GS_BASE : current_evmcs->host_gs_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER ;break ;case HOST_TR_BASE : current_evmcs->host_tr_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER ;break ;case HOST_GDTR_BASE : current_evmcs->host_gdtr_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER ;break ;case HOST_IDTR_BASE : current_evmcs->host_idtr_base = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER ;break ;case HOST_RSP : current_evmcs->host_rsp = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER ;break ;case EPT_POINTER : current_evmcs->ept_pointer = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_XLAT ;break ;case GUEST_BNDCFGS : current_evmcs->guest_bndcfgs = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case XSS_EXIT_BITMAP : current_evmcs->xss_exit_bitmap = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2 ;break ;case GUEST_PHYSICAL_ADDRESS : current_evmcs->guest_physical_address = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case EXIT_QUALIFICATION : current_evmcs->exit_qualification = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case GUEST_LINEAR_ADDRESS : current_evmcs->guest_linear_address = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case VM_EXIT_MSR_STORE_ADDR : current_evmcs->vm_exit_msr_store_addr = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case VM_EXIT_MSR_LOAD_ADDR : current_evmcs->vm_exit_msr_load_addr = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case VM_ENTRY_MSR_LOAD_ADDR : current_evmcs->vm_entry_msr_load_addr = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case CR3_TARGET_VALUE0 : current_evmcs->cr3_target_value0 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case CR3_TARGET_VALUE1 : current_evmcs->cr3_target_value1 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case CR3_TARGET_VALUE2 : current_evmcs->cr3_target_value2 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case CR3_TARGET_VALUE3 : current_evmcs->cr3_target_value3 = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case TPR_THRESHOLD : current_evmcs->tpr_threshold = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case GUEST_INTERRUPTIBILITY_INFO : current_evmcs->guest_interruptibility_info = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC ;break ;case CPU_BASED_VM_EXEC_CONTROL : current_evmcs->cpu_based_vm_exec_control = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_PROC ;break ;case EXCEPTION_BITMAP : current_evmcs->exception_bitmap = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EXCPN ;break ;case VM_ENTRY_CONTROLS : current_evmcs->vm_entry_controls = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_ENTRY ;break ;case VM_ENTRY_INTR_INFO_FIELD : current_evmcs->vm_entry_intr_info_field = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EVENT ;break ;case VM_ENTRY_EXCEPTION_ERROR_CODE : current_evmcs->vm_entry_exception_error_code = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EVENT ;break ;case VM_ENTRY_INSTRUCTION_LEN : current_evmcs->vm_entry_instruction_len = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EVENT ;break ;case HOST_IA32_SYSENTER_CS : current_evmcs->host_ia32_sysenter_cs = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case PIN_BASED_VM_EXEC_CONTROL : current_evmcs->pin_based_vm_exec_control = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1 ;break ;case VM_EXIT_CONTROLS : current_evmcs->vm_exit_controls = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1 ;break ;case SECONDARY_VM_EXEC_CONTROL : current_evmcs->secondary_vm_exec_control = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1 ;break ;case GUEST_ES_LIMIT : current_evmcs->guest_es_limit = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_CS_LIMIT : current_evmcs->guest_cs_limit = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_SS_LIMIT : current_evmcs->guest_ss_limit = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_DS_LIMIT : current_evmcs->guest_ds_limit = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_FS_LIMIT : current_evmcs->guest_fs_limit = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_GS_LIMIT : current_evmcs->guest_gs_limit = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_LDTR_LIMIT : current_evmcs->guest_ldtr_limit = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_TR_LIMIT : current_evmcs->guest_tr_limit = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_GDTR_LIMIT : current_evmcs->guest_gdtr_limit = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_IDTR_LIMIT : current_evmcs->guest_idtr_limit = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_ES_AR_BYTES : current_evmcs->guest_es_ar_bytes = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_CS_AR_BYTES : current_evmcs->guest_cs_ar_bytes = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_SS_AR_BYTES : current_evmcs->guest_ss_ar_bytes = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_DS_AR_BYTES : current_evmcs->guest_ds_ar_bytes = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_FS_AR_BYTES : current_evmcs->guest_fs_ar_bytes = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_GS_AR_BYTES : current_evmcs->guest_gs_ar_bytes = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_LDTR_AR_BYTES : current_evmcs->guest_ldtr_ar_bytes = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_TR_AR_BYTES : current_evmcs->guest_tr_ar_bytes = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_ACTIVITY_STATE : current_evmcs->guest_activity_state = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case GUEST_SYSENTER_CS : current_evmcs->guest_sysenter_cs = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 ;break ;case VM_INSTRUCTION_ERROR : current_evmcs->vm_instruction_error = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case VM_EXIT_REASON : current_evmcs->vm_exit_reason = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case VM_EXIT_INTR_INFO : current_evmcs->vm_exit_intr_info = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case VM_EXIT_INTR_ERROR_CODE : current_evmcs->vm_exit_intr_error_code = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case IDT_VECTORING_INFO_FIELD : current_evmcs->idt_vectoring_info_field = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case IDT_VECTORING_ERROR_CODE : current_evmcs->idt_vectoring_error_code = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case VM_EXIT_INSTRUCTION_LEN : current_evmcs->vm_exit_instruction_len = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case VMX_INSTRUCTION_INFO : current_evmcs->vmx_instruction_info = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE ;break ;case PAGE_FAULT_ERROR_CODE_MASK : current_evmcs->page_fault_error_code_mask = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case PAGE_FAULT_ERROR_CODE_MATCH : current_evmcs->page_fault_error_code_match = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case CR3_TARGET_COUNT : current_evmcs->cr3_target_count = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case VM_EXIT_MSR_STORE_COUNT : current_evmcs->vm_exit_msr_store_count = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case VM_EXIT_MSR_LOAD_COUNT : current_evmcs->vm_exit_msr_load_count = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case VM_ENTRY_MSR_LOAD_COUNT : current_evmcs->vm_entry_msr_load_count = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;break ;case HOST_ES_SELECTOR : current_evmcs->host_es_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_CS_SELECTOR : current_evmcs->host_cs_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_SS_SELECTOR : current_evmcs->host_ss_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_DS_SELECTOR : current_evmcs->host_ds_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_FS_SELECTOR : current_evmcs->host_fs_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_GS_SELECTOR : current_evmcs->host_gs_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case HOST_TR_SELECTOR : current_evmcs->host_tr_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ;break ;case GUEST_ES_SELECTOR : current_evmcs->guest_es_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_CS_SELECTOR : current_evmcs->guest_cs_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_SS_SELECTOR : current_evmcs->guest_ss_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_DS_SELECTOR : current_evmcs->guest_ds_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_FS_SELECTOR : current_evmcs->guest_fs_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_GS_SELECTOR : current_evmcs->guest_gs_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_LDTR_SELECTOR : current_evmcs->guest_ldtr_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case GUEST_TR_SELECTOR : current_evmcs->guest_tr_selector = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 ;break ;case VIRTUAL_PROCESSOR_ID : current_evmcs->virtual_processor_id = value; + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_XLAT ;break ;default :return 1 ; }
@@ -1070,7 +1215,10 @@ static inline int evmcs_vmresume(void) {int ret; - current_evmcs->hv_clean_fields =0 ; +/* HOST_RIP */ + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 ; +/* HOST_RSP */ + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER ; __asm__ __volatile__("push %%rbp;" "push %%rcx;"
tools/testing/selftests/kvm/x86_64/evmcs_test.c +3 -2
@@ -76,8 +76,9 @@ void guest_code(struct vmx_pages *vmx_pages) current_evmcs->revision_id =EVMCS_VERSION ;GUEST_SYNC (6 ); - current_evmcs->pin_based_vm_exec_control |= -PIN_BASED_NMI_EXITING ; +vmwrite (PIN_BASED_VM_EXEC_CONTROL ,vmreadz (PIN_BASED_VM_EXEC_CONTROL ) | +PIN_BASED_NMI_EXITING ); +GUEST_ASSERT (!vmlaunch ());GUEST_ASSERT (vmptrstz () == vmx_pages->enlightened_vmcs_gpa);
Signature · 1 line
2.34.1
PATCH 3/6 KVM: selftests: nVMX: Add enlightened MSR-Bitmap selftest
In reply to Vitaly KuznetsovIntroduce a test for enlightened MSR-Bitmap feature (Hyper-V on KVM):
- Intercept access to MSR_FS_BASE in L1 and check that this works with enlightened MSR-Bitmap disabled.
- Enabled enlightened MSR-Bitmap and check that the intercept still works as expected.
- Intercept access to MSR_GS_BASE but don't clear the corresponding bit from 'hv_clean_fields', KVM is supposed to skip updating MSR-Bitmap02 and thus the consequent access to the MSR from L2 will not get intercepted.
- Finally, clear the corresponding bit from 'hv_clean_fields' and check that access to MSR_GS_BASE is now intercepted.
The test works with the assumption, that access to MSR_FS_BASE/MSR_GS_BASE is not intercepted for L1. If this ever becomes not true the test will fail as nested_vmx_exit_handled_msr() always checks L1's MSR-Bitmap for L2 irrespective of 'hv_clean_fields'. The behavior is correct as enlightened MSR-Bitmap feature is just an optimization, KVM is not obliged to ignore updates when the corresponding bit in 'hv_clean_fields' stays clear.
--- .../testing/selftests/kvm/x86_64/evmcs_test.c | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+)
tools/testing/selftests/kvm/x86_64/evmcs_test.c +59 -0
@@ -10,6 +10,7 @@#include <stdlib.h> #include <string.h> #include <sys/ioctl.h> +#include <linux/bitmap.h> #include "test_util.h"
@@ -32,6 +33,22 @@ static void guest_nmi_handler(struct ex_regs *regs) { } +/* Exits to L1 destroy GRPs! */ +static inline void rdmsr_fs_base (void ) +{ + __asm__ __volatile__ ("mov $0xc0000100, %%rcx; rdmsr" : : : +"rax" ,"rbx" ,"rcx" ,"rdx" , +"rsi" ,"rdi" ,"r8" ,"r9" ,"r10" ,"r11" ,"r12" , +"r13" ,"r14" ,"r15" ); +} +static inline void rdmsr_gs_base (void ) +{ + __asm__ __volatile__ ("mov $0xc0000101, %%rcx; rdmsr" : : : +"rax" ,"rbx" ,"rcx" ,"rdx" , +"rsi" ,"rdi" ,"r8" ,"r9" ,"r10" ,"r11" ,"r12" , +"r13" ,"r14" ,"r15" ); +} +void l2_guest_code (void ) {GUEST_SYNC (7 );
@@ -41,6 +58,15 @@ void l2_guest_code(void)/* Forced exit to L1 upon restore */ GUEST_SYNC (9 ); +vmcall (); + +/* MSR-Bitmap tests */ +rdmsr_fs_base ();/* intercepted */ +rdmsr_fs_base ();/* intercepted */ +rdmsr_gs_base ();/* not intercepted */ +vmcall (); +rdmsr_gs_base ();/* intercepted */ +/* Done, exit to L1 and never come back. */ vmcall (); }
@@ -91,6 +117,39 @@ void guest_code(struct vmx_pages *vmx_pages)GUEST_SYNC (10 ); +GUEST_ASSERT (vmreadz (VM_EXIT_REASON ) ==EXIT_REASON_VMCALL ); + current_evmcs->guest_rip +=3 ;/* vmcall */ + +/* Intercept RDMSR 0xc0000100 */ +vmwrite (CPU_BASED_VM_EXEC_CONTROL ,vmreadz (CPU_BASED_VM_EXEC_CONTROL ) | +CPU_BASED_USE_MSR_BITMAPS ); +set_bit (MSR_FS_BASE &0x1fff , vmx_pages->msr +0x400 ); +GUEST_ASSERT (!vmresume ()); +GUEST_ASSERT (vmreadz (VM_EXIT_REASON ) ==EXIT_REASON_MSR_READ ); + current_evmcs->guest_rip +=2 ;/* rdmsr */ + +/* Enable enlightened MSR bitmap */ + current_evmcs->hv_enlightenments_control.msr_bitmap =1 ; +GUEST_ASSERT (!vmresume ()); +GUEST_ASSERT (vmreadz (VM_EXIT_REASON ) ==EXIT_REASON_MSR_READ ); + current_evmcs->guest_rip +=2 ;/* rdmsr */ + +/* Intercept RDMSR 0xc0000101 without telling KVM about it */ +set_bit (MSR_GS_BASE &0x1fff , vmx_pages->msr +0x400 ); +/* Make sure HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP is set */ + current_evmcs->hv_clean_fields |=HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP ; +GUEST_ASSERT (!vmresume ()); +/* Make sure we don't see EXIT_REASON_MSR_READ here so eMSR bitmap works */ +GUEST_ASSERT (vmreadz (VM_EXIT_REASON ) ==EXIT_REASON_VMCALL ); + current_evmcs->guest_rip +=3 ;/* vmcall */ + +/* Now tell KVM we've changed MSR-Bitmap */ + current_evmcs->hv_clean_fields &= ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP ; +GUEST_ASSERT (!vmresume ()); +GUEST_ASSERT (vmreadz (VM_EXIT_REASON ) ==EXIT_REASON_MSR_READ ); + current_evmcs->guest_rip +=2 ;/* rdmsr */ + +GUEST_ASSERT (!vmresume ());GUEST_ASSERT (vmreadz (VM_EXIT_REASON ) ==EXIT_REASON_VMCALL );GUEST_SYNC (11 );
Signature · 1 line
2.34.1
PATCH 4/6 KVM: selftests: nSVM: Set up MSR-Bitmap for SVM guests
In reply to Vitaly KuznetsovSimilar to VMX, allocate memory for MSR-Bitmap and fill in 'msrpm_base_pa' in VMCB. To use it, tests will need to set INTERCEPT_MSR_PROT interception along with the required bits in the MSR-Bitmap.
--- tools/testing/selftests/kvm/include/x86_64/svm_util.h | 5 +++++ tools/testing/selftests/kvm/lib/x86_64/svm.c | 6 ++++++ 2 files changed, 11 insertions(+)
tools/testing/selftests/kvm/include/x86_64/svm_util.h +5 -0
@@ -28,6 +28,11 @@ struct svm_test_data {struct vmcb_save_area *save_area;/* gva */ void *save_area_hva;uint64_t save_area_gpa; + +/* MSR-Bitmap */ +void *msr;/* gva */ +void *msr_hva; +uint64_t msr_gpa; };struct svm_test_data *vcpu_alloc_svm (struct kvm_vm *vm,vm_vaddr_t *p_svm_gva);
tools/testing/selftests/kvm/lib/x86_64/svm.c +6 -0
@@ -43,6 +43,11 @@ vcpu_alloc_svm(struct kvm_vm *vm, vm_vaddr_t *p_svm_gva) svm->save_area_hva =addr_gva2hva (vm, (uintptr_t )svm->save_area); svm->save_area_gpa =addr_gva2gpa (vm, (uintptr_t )svm->save_area); + svm->msr = (void *)vm_vaddr_alloc_page (vm); + svm->msr_hva =addr_gva2hva (vm, (uintptr_t )svm->msr); + svm->msr_gpa =addr_gva2gpa (vm, (uintptr_t )svm->msr); +memset (svm->msr_hva,0 ,getpagesize ()); + *p_svm_gva = svm_gva;return svm; }
@@ -106,6 +111,7 @@ void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_r save->dbgctl =rdmsr (MSR_IA32_DEBUGCTLMSR ); ctrl->intercept = (1ULL <<INTERCEPT_VMRUN ) | (1ULL <<INTERCEPT_VMMCALL ); + ctrl->msrpm_base_pa = svm->msr_gpa; vmcb->save.rip = (u64 )guest_rip; vmcb->save.rsp = (u64 )guest_rsp;
Signature · 1 line
2.34.1
PATCH 5/6 KVM: selftests: nSVM: Update 'struct vmcb_control_area' definition
In reply to Vitaly KuznetsovThere's a copy of 'struct vmcb_control_area' definition in KVM selftests, update it to allow testing of the newly introduced features.
--- tools/testing/selftests/kvm/include/x86_64/svm.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/testing/selftests/kvm/include/x86_64/svm.h +8 -1
@@ -99,7 +99,14 @@ struct __attribute__ ((__packed__)) vmcb_control_area {u8 reserved_6[8 ];/* Offset 0xe8 */ u64 avic_logical_id;/* Offset 0xf0 */ u64 avic_physical_id;/* Offset 0xf8 */ -u8 reserved_7[768 ]; +u8 reserved_7[8 ]; +u64 vmsa_pa;/* Used for an SEV-ES guest */ +u8 reserved_8[720 ]; +/* +* Offset 0x3e0, 32 bytes reserved +* for use by hypervisor/software. +*/ +u8 reserved_sw[32 ]; };
Signature · 1 line
2.34.1
PATCH 6/6 KVM: selftests: nSVM: Add enlightened MSR-Bitmap selftest
In reply to Vitaly KuznetsovIntroduce a new test for Hyper-V nSVM extensions (Hyper-V on KVM) and add a test for enlightened MSR-Bitmap feature:
- Intercept access to MSR_FS_BASE in L1 and check that this works with enlightened MSR-Bitmap disabled.
- Enabled enlightened MSR-Bitmap and check that the intercept still works as expected.
- Intercept access to MSR_GS_BASE but don't clear the corresponding bit from clean fields mask, KVM is supposed to skip updating MSR-Bitmap02 and thus the consequent access to the MSR from L2 will not get intercepted.
- Finally, clear the corresponding bit from clean fields mask and check that access to MSR_GS_BASE is now intercepted.
The test works with the assumption, that access to MSR_FS_BASE/MSR_GS_BASE is not intercepted for L1. If this ever becomes not true the test will fail as nested_svm_exit_handled_msr() always checks L1's MSR-Bitmap for L2 irrespective of clean fields. The behavior is correct as enlightened MSR-Bitmap feature is just an optimization, KVM is not obliged to ignore updates when the corresponding bit in clean fields stays clear.
--- tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/include/x86_64/svm_util.h | 1 + .../selftests/kvm/x86_64/hyperv_svm_test.c | 175 ++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
tools/testing/selftests/kvm/Makefile +1 -0
@@ -51,6 +51,7 @@ TEST_GEN_PROGS_x86_64 += x86_64/emulator_error_test TEST_GEN_PROGS_x86_64 += x86_64/hyperv_clock TEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid TEST_GEN_PROGS_x86_64 += x86_64/hyperv_features +TEST_GEN_PROGS_x86_64 += x86_64/hyperv_svm_test TEST_GEN_PROGS_x86_64 += x86_64/kvm_clock_test TEST_GEN_PROGS_x86_64 += x86_64/kvm_pv_test TEST_GEN_PROGS_x86_64 += x86_64/mmio_warning_test
tools/testing/selftests/kvm/include/x86_64/svm_util.h +1 -0
@@ -16,6 +16,7 @@#define CPUID_SVM_BIT 2#define CPUID_SVM BIT_ULL(CPUID_SVM_BIT) +#define SVM_EXIT_MSR 0x07c#define SVM_EXIT_VMMCALL 0x081struct svm_test_data {
tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c new file +175 -0
175 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 21 lines · Vitaly Kuznetsov
KVM gained support for enlightened MSR-Bitmap Hyper-V feature (Hyper-V on KVM) for both nVMX and nSVM, test it in selftests.
Vitaly Kuznetsov (6):
KVM: selftests: Adapthyperv_cpuidtest to the newly introduced
Enlightened MSR-Bitmap
KVM: selftests: nVMX: Properly deal with 'hv_clean_fields'
KVM: selftests: nVMX: Add enlightened MSR-Bitmap selftest
KVM: selftests: nSVM: Set up MSR-Bitmap for SVM guests
KVM: selftests: nSVM: Update 'structvmcb_control_area' definition
KVM: selftests: nSVM: Add enlightened MSR-Bitmap selftesttools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/include/x86_64/evmcs.h | 150 ++++++++++++++- .../selftests/kvm/include/x86_64/svm.h | 9 +- .../selftests/kvm/include/x86_64/svm_util.h | 6 + tools/testing/selftests/kvm/lib/x86_64/svm.c | 6 + .../testing/selftests/kvm/x86_64/evmcs_test.c | 64 ++++++- .../selftests/kvm/x86_64/hyperv_cpuid.c | 29 +-- .../selftests/kvm/x86_64/hyperv_svm_test.c | 175 ++++++++++++++++++ 8 files changed, 424 insertions(+), 16 deletions(-)
Quoted 2 lines
create mode 100644
tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
Queued, thanks.
Paolo