KVM: selftests: add Enlightened VMCS test
Modify test library and add eVMCS test. This includes nVMX save/restore testing. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:

committed by
Paolo Bonzini

parent
c939989d74
commit
18178ff862
1098
tools/testing/selftests/kvm/include/evmcs.h
Normal file
1098
tools/testing/selftests/kvm/include/evmcs.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -339,6 +339,8 @@ struct vmx_msr_entry {
|
||||
uint64_t value;
|
||||
} __attribute__ ((aligned(16)));
|
||||
|
||||
#include "evmcs.h"
|
||||
|
||||
static inline int vmxon(uint64_t phys)
|
||||
{
|
||||
uint8_t ret;
|
||||
@@ -372,6 +374,9 @@ static inline int vmptrld(uint64_t vmcs_pa)
|
||||
{
|
||||
uint8_t ret;
|
||||
|
||||
if (enable_evmcs)
|
||||
return -1;
|
||||
|
||||
__asm__ __volatile__ ("vmptrld %[pa]; setna %[ret]"
|
||||
: [ret]"=rm"(ret)
|
||||
: [pa]"m"(vmcs_pa)
|
||||
@@ -385,6 +390,9 @@ static inline int vmptrst(uint64_t *value)
|
||||
uint64_t tmp;
|
||||
uint8_t ret;
|
||||
|
||||
if (enable_evmcs)
|
||||
return evmcs_vmptrst(value);
|
||||
|
||||
__asm__ __volatile__("vmptrst %[value]; setna %[ret]"
|
||||
: [value]"=m"(tmp), [ret]"=rm"(ret)
|
||||
: : "cc", "memory");
|
||||
@@ -411,6 +419,9 @@ static inline int vmlaunch(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (enable_evmcs)
|
||||
return evmcs_vmlaunch();
|
||||
|
||||
__asm__ __volatile__("push %%rbp;"
|
||||
"push %%rcx;"
|
||||
"push %%rdx;"
|
||||
@@ -443,6 +454,9 @@ static inline int vmresume(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (enable_evmcs)
|
||||
return evmcs_vmresume();
|
||||
|
||||
__asm__ __volatile__("push %%rbp;"
|
||||
"push %%rcx;"
|
||||
"push %%rdx;"
|
||||
@@ -482,6 +496,9 @@ static inline int vmread(uint64_t encoding, uint64_t *value)
|
||||
uint64_t tmp;
|
||||
uint8_t ret;
|
||||
|
||||
if (enable_evmcs)
|
||||
return evmcs_vmread(encoding, value);
|
||||
|
||||
__asm__ __volatile__("vmread %[encoding], %[value]; setna %[ret]"
|
||||
: [value]"=rm"(tmp), [ret]"=rm"(ret)
|
||||
: [encoding]"r"(encoding)
|
||||
@@ -506,6 +523,9 @@ static inline int vmwrite(uint64_t encoding, uint64_t value)
|
||||
{
|
||||
uint8_t ret;
|
||||
|
||||
if (enable_evmcs)
|
||||
return evmcs_vmwrite(encoding, value);
|
||||
|
||||
__asm__ __volatile__ ("vmwrite %[value], %[encoding]; setna %[ret]"
|
||||
: [ret]"=rm"(ret)
|
||||
: [value]"rm"(value), [encoding]"r"(encoding)
|
||||
@@ -543,6 +563,14 @@ struct vmx_pages {
|
||||
void *vmwrite_hva;
|
||||
uint64_t vmwrite_gpa;
|
||||
void *vmwrite;
|
||||
|
||||
void *vp_assist_hva;
|
||||
uint64_t vp_assist_gpa;
|
||||
void *vp_assist;
|
||||
|
||||
void *enlightened_vmcs_hva;
|
||||
uint64_t enlightened_vmcs_gpa;
|
||||
void *enlightened_vmcs;
|
||||
};
|
||||
|
||||
struct vmx_pages *vcpu_alloc_vmx(struct kvm_vm *vm, vm_vaddr_t *p_vmx_gva);
|
||||
|
Reference in New Issue
Block a user