aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/include/x86_64/svm_util.h
diff options
context:
space:
mode:
authorEric Auger <eric.auger@redhat.com>2020-02-06 11:47:09 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2020-02-12 20:09:39 +0100
commit20ba262f8631aadefa87921481fe569ecc387f20 (patch)
treec8dbce7a011f4c83765bbe2b20de83a2359f94aa /tools/testing/selftests/kvm/include/x86_64/svm_util.h
parentselftests: KVM: Replace get_{gdt,idt}_base() by get_{gdt,idt}() (diff)
downloadlinux-dev-20ba262f8631aadefa87921481fe569ecc387f20.tar.xz
linux-dev-20ba262f8631aadefa87921481fe569ecc387f20.zip
selftests: KVM: AMD Nested test infrastructure
Add the basic infrastructure needed to test AMD nested SVM. This is largely copied from the KVM unit test infrastructure. Signed-off-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/include/x86_64/svm_util.h')
-rw-r--r--tools/testing/selftests/kvm/include/x86_64/svm_util.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/x86_64/svm_util.h b/tools/testing/selftests/kvm/include/x86_64/svm_util.h
new file mode 100644
index 000000000000..cd037917fece
--- /dev/null
+++ b/tools/testing/selftests/kvm/include/x86_64/svm_util.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * tools/testing/selftests/kvm/include/x86_64/svm_utils.h
+ * Header for nested SVM testing
+ *
+ * Copyright (C) 2020, Red Hat, Inc.
+ */
+
+#ifndef SELFTEST_KVM_SVM_UTILS_H
+#define SELFTEST_KVM_SVM_UTILS_H
+
+#include <stdint.h>
+#include "svm.h"
+#include "processor.h"
+
+#define CPUID_SVM_BIT 2
+#define CPUID_SVM BIT_ULL(CPUID_SVM_BIT)
+
+#define SVM_EXIT_VMMCALL 0x081
+
+struct svm_test_data {
+ /* VMCB */
+ struct vmcb *vmcb; /* gva */
+ void *vmcb_hva;
+ uint64_t vmcb_gpa;
+
+ /* host state-save area */
+ struct vmcb_save_area *save_area; /* gva */
+ void *save_area_hva;
+ uint64_t save_area_gpa;
+};
+
+struct svm_test_data *vcpu_alloc_svm(struct kvm_vm *vm, vm_vaddr_t *p_svm_gva);
+void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_rsp);
+void run_guest(struct vmcb *vmcb, uint64_t vmcb_gpa);
+void nested_svm_check_supported(void);
+
+#endif /* SELFTEST_KVM_SVM_UTILS_H */