Commit 8ec107c8 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Paolo Bonzini

selftests: kvm: fix smm test on SVM

KVM_CAP_NESTED_STATE is now supported for AMD too but smm test acts like
it is still Intel only.
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20200529130407.57176-2-vkuznets@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 10b910cb
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "kvm_util.h" #include "kvm_util.h"
#include "vmx.h" #include "vmx.h"
#include "svm_util.h"
#define VCPU_ID 1 #define VCPU_ID 1
...@@ -58,7 +59,7 @@ void self_smi(void) ...@@ -58,7 +59,7 @@ void self_smi(void)
APIC_DEST_SELF | APIC_INT_ASSERT | APIC_DM_SMI); APIC_DEST_SELF | APIC_INT_ASSERT | APIC_DM_SMI);
} }
void guest_code(struct vmx_pages *vmx_pages) void guest_code(void *arg)
{ {
uint64_t apicbase = rdmsr(MSR_IA32_APICBASE); uint64_t apicbase = rdmsr(MSR_IA32_APICBASE);
...@@ -72,8 +73,11 @@ void guest_code(struct vmx_pages *vmx_pages) ...@@ -72,8 +73,11 @@ void guest_code(struct vmx_pages *vmx_pages)
sync_with_host(4); sync_with_host(4);
if (vmx_pages) { if (arg) {
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages)); if (cpu_has_svm())
generic_svm_setup(arg, NULL, NULL);
else
GUEST_ASSERT(prepare_for_vmx_operation(arg));
sync_with_host(5); sync_with_host(5);
...@@ -87,7 +91,7 @@ void guest_code(struct vmx_pages *vmx_pages) ...@@ -87,7 +91,7 @@ void guest_code(struct vmx_pages *vmx_pages)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
vm_vaddr_t vmx_pages_gva = 0; vm_vaddr_t nested_gva = 0;
struct kvm_regs regs; struct kvm_regs regs;
struct kvm_vm *vm; struct kvm_vm *vm;
...@@ -114,8 +118,11 @@ int main(int argc, char *argv[]) ...@@ -114,8 +118,11 @@ int main(int argc, char *argv[])
vcpu_set_msr(vm, VCPU_ID, MSR_IA32_SMBASE, SMRAM_GPA); vcpu_set_msr(vm, VCPU_ID, MSR_IA32_SMBASE, SMRAM_GPA);
if (kvm_check_cap(KVM_CAP_NESTED_STATE)) { if (kvm_check_cap(KVM_CAP_NESTED_STATE)) {
vcpu_alloc_vmx(vm, &vmx_pages_gva); if (kvm_get_supported_cpuid_entry(0x80000001)->ecx & CPUID_SVM)
vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva); vcpu_alloc_svm(vm, &nested_gva);
else
vcpu_alloc_vmx(vm, &nested_gva);
vcpu_args_set(vm, VCPU_ID, 1, nested_gva);
} else { } else {
pr_info("will skip SMM test with VMX enabled\n"); pr_info("will skip SMM test with VMX enabled\n");
vcpu_args_set(vm, VCPU_ID, 1, 0); vcpu_args_set(vm, VCPU_ID, 1, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment