mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 17:42:03 +02:00
KVM: selftests: Drop L1-provided stacks for L2 guests on x86
Now that a dedicated page is allocated for L2's stack and stuffed in RSP, the L1-provided stack is unused. Drop the stacks allocated by L1 guest code for L2 in all x86 tests. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Yosry Ahmed <yosry@kernel.org> Link: https://patch.msgid.link/20260610003030.2957261-4-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
54adab32d3
commit
4c396f19de
|
|
@ -60,7 +60,7 @@ static inline void vmmcall(void)
|
|||
)
|
||||
|
||||
struct svm_test_data *vcpu_alloc_svm(struct kvm_vm *vm, gva_t *p_svm_gva);
|
||||
void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_rsp);
|
||||
void generic_svm_setup(struct svm_test_data *svm, void *guest_rip);
|
||||
void run_guest(struct vmcb *vmcb, u64 vmcb_gpa);
|
||||
|
||||
static inline bool kvm_cpu_has_npt(void)
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ union vmx_ctrl_msr {
|
|||
|
||||
struct vmx_pages *vcpu_alloc_vmx(struct kvm_vm *vm, gva_t *p_vmx_gva);
|
||||
bool prepare_for_vmx_operation(struct vmx_pages *vmx);
|
||||
void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip, void *guest_rsp);
|
||||
void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip);
|
||||
bool load_vmcs(struct vmx_pages *vmx);
|
||||
|
||||
bool ept_1g_pages_supported(void);
|
||||
|
|
|
|||
|
|
@ -30,21 +30,15 @@ __asm__(
|
|||
" ud2;"
|
||||
);
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
static void l1_vmx_code(struct vmx_pages *vmx, u64 vcpu_id)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
unsigned long *rsp;
|
||||
|
||||
GUEST_ASSERT(vmx->vmcs_gpa);
|
||||
GUEST_ASSERT(prepare_for_vmx_operation(vmx));
|
||||
GUEST_ASSERT(load_vmcs(vmx));
|
||||
GUEST_ASSERT(ept_1g_pages_supported());
|
||||
|
||||
rsp = &l2_guest_stack[L2_GUEST_STACK_SIZE - 1];
|
||||
*(u64 *)vmx->stack = vcpu_id;
|
||||
prepare_vmcs(vmx, memstress_l2_guest_entry, rsp);
|
||||
prepare_vmcs(vmx, memstress_l2_guest_entry);
|
||||
|
||||
GUEST_ASSERT(!vmlaunch());
|
||||
GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_VMCALL);
|
||||
|
|
@ -53,12 +47,8 @@ static void l1_vmx_code(struct vmx_pages *vmx, u64 vcpu_id)
|
|||
|
||||
static void l1_svm_code(struct svm_test_data *svm, u64 vcpu_id)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
unsigned long *rsp;
|
||||
|
||||
rsp = &l2_guest_stack[L2_GUEST_STACK_SIZE - 1];
|
||||
*(u64 *)svm->stack = vcpu_id;
|
||||
generic_svm_setup(svm, memstress_l2_guest_entry, rsp);
|
||||
generic_svm_setup(svm, memstress_l2_guest_entry);
|
||||
|
||||
run_guest(svm->vmcb, svm->vmcb_gpa);
|
||||
GUEST_ASSERT_EQ(svm->vmcb->control.exit_code, SVM_EXIT_VMMCALL);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ void vm_enable_npt(struct kvm_vm *vm)
|
|||
tdp_mmu_init(vm, vm->mmu.pgtable_levels, &pte_masks);
|
||||
}
|
||||
|
||||
void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_rsp)
|
||||
void generic_svm_setup(struct svm_test_data *svm, void *guest_rip)
|
||||
{
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
u64 vmcb_gpa = svm->vmcb_gpa;
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ static inline void init_vmcs_guest_state(void *rip, void *rsp)
|
|||
vmwrite(GUEST_SYSENTER_EIP, vmreadz(HOST_IA32_SYSENTER_EIP));
|
||||
}
|
||||
|
||||
void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip, void *guest_rsp)
|
||||
void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip)
|
||||
{
|
||||
init_vmcs_control_fields(vmx);
|
||||
init_vmcs_host_state();
|
||||
|
|
|
|||
|
|
@ -54,8 +54,6 @@ static void guest_read_aperf_mperf(void)
|
|||
GUEST_SYNC2(rdmsr(MSR_IA32_APERF), rdmsr(MSR_IA32_MPERF));
|
||||
}
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
static void l2_guest_code(void)
|
||||
{
|
||||
guest_read_aperf_mperf();
|
||||
|
|
@ -64,21 +62,18 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_svm_code(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
|
||||
generic_svm_setup(svm, l2_guest_code, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
run_guest(vmcb, svm->vmcb_gpa);
|
||||
}
|
||||
|
||||
static void l1_vmx_code(struct vmx_pages *vmx)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
GUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);
|
||||
GUEST_ASSERT_EQ(load_vmcs(vmx), true);
|
||||
|
||||
prepare_vmcs(vmx, NULL, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx, NULL);
|
||||
|
||||
/*
|
||||
* Enable MSR bitmaps (the bitmap itself is allocated, zeroed, and set
|
||||
|
|
|
|||
|
|
@ -52,8 +52,6 @@ static void l2_guest_code(void)
|
|||
static void guest_code(struct vmx_pages *vmx_pages,
|
||||
struct hyperv_test_pages *hv_pages)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
/* Set up Hyper-V enlightenments and eVMCS */
|
||||
wrmsr(HV_X64_MSR_GUEST_OS_ID, HYPERV_LINUX_OS_ID);
|
||||
|
|
@ -62,8 +60,7 @@ static void guest_code(struct vmx_pages *vmx_pages,
|
|||
|
||||
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
|
||||
GUEST_ASSERT(load_evmcs(hv_pages));
|
||||
prepare_vmcs(vmx_pages, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
|
||||
GUEST_ASSERT(!vmlaunch());
|
||||
|
||||
|
|
|
|||
|
|
@ -78,9 +78,6 @@ void l2_guest_code(void)
|
|||
void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
|
||||
gpa_t hv_hcall_page_gpa)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
wrmsr(HV_X64_MSR_GUEST_OS_ID, HYPERV_LINUX_OS_ID);
|
||||
wrmsr(HV_X64_MSR_HYPERCALL, hv_hcall_page_gpa);
|
||||
|
||||
|
|
@ -100,8 +97,7 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages,
|
|||
GUEST_SYNC(4);
|
||||
GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa);
|
||||
|
||||
prepare_vmcs(vmx_pages, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
|
||||
GUEST_SYNC(5);
|
||||
GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa);
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
#include "svm_util.h"
|
||||
#include "hyperv.h"
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 256
|
||||
|
||||
/* Exit to L1 from L2 with RDMSR instruction */
|
||||
static inline void rdmsr_from_l2(u32 msr)
|
||||
{
|
||||
|
|
@ -69,7 +67,6 @@ static void __attribute__((__flatten__)) guest_code(struct svm_test_data *svm,
|
|||
struct hyperv_test_pages *hv_pages,
|
||||
gpa_t pgs_gpa)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
struct hv_vmcb_enlightenments *hve = &vmcb->control.hv_enlightenments;
|
||||
|
||||
|
|
@ -81,8 +78,7 @@ static void __attribute__((__flatten__)) guest_code(struct svm_test_data *svm,
|
|||
|
||||
GUEST_ASSERT(svm->vmcb_gpa);
|
||||
/* Prepare for L2 execution. */
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
/* L2 TLB flush setup */
|
||||
hve->partition_assist_page = hv_pages->partition_assist_gpa;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ static void guest_generate_buslocks(void)
|
|||
atomic_inc(val);
|
||||
}
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
static void l2_guest_code(void)
|
||||
{
|
||||
guest_generate_buslocks();
|
||||
|
|
@ -36,21 +34,18 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_svm_code(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
|
||||
generic_svm_setup(svm, l2_guest_code, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
run_guest(vmcb, svm->vmcb_gpa);
|
||||
}
|
||||
|
||||
static void l1_vmx_code(struct vmx_pages *vmx)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
GUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);
|
||||
GUEST_ASSERT_EQ(load_vmcs(vmx), true);
|
||||
|
||||
prepare_vmcs(vmx, NULL, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx, NULL);
|
||||
|
||||
GUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_guest_code));
|
||||
GUEST_ASSERT(!vmlaunch());
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ enum {
|
|||
PORT_L0_EXIT = 0x2000,
|
||||
};
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
static void l2_guest_code(void)
|
||||
{
|
||||
/* Exit to L0 */
|
||||
|
|
@ -32,14 +30,11 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_vmx_code(struct vmx_pages *vmx_pages)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
|
||||
GUEST_ASSERT(load_vmcs(vmx_pages));
|
||||
|
||||
/* Prepare the VMCS for L2 execution. */
|
||||
prepare_vmcs(vmx_pages, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
|
||||
GUEST_ASSERT(!vmlaunch());
|
||||
GUEST_ASSERT(0);
|
||||
|
|
@ -47,11 +42,8 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)
|
|||
|
||||
static void l1_svm_code(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
/* Prepare the VMCB for L2 execution. */
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
run_guest(svm->vmcb, svm->vmcb_gpa);
|
||||
GUEST_ASSERT(0);
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@
|
|||
|
||||
#define TEST_HVA(vm, idx) addr_gpa2hva(vm, TEST_GPA(idx))
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
/* Use the page offset bits to communicate the access+fault type. */
|
||||
#define TEST_SYNC_READ_FAULT BIT(0)
|
||||
#define TEST_SYNC_WRITE_FAULT BIT(1)
|
||||
|
|
@ -92,7 +90,6 @@ static void l2_guest_code_tdp_disabled(void)
|
|||
|
||||
void l1_vmx_code(struct vmx_pages *vmx)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
void *l2_rip;
|
||||
|
||||
GUEST_ASSERT(vmx->vmcs_gpa);
|
||||
|
|
@ -104,7 +101,7 @@ void l1_vmx_code(struct vmx_pages *vmx)
|
|||
else
|
||||
l2_rip = l2_guest_code_tdp_disabled;
|
||||
|
||||
prepare_vmcs(vmx, l2_rip, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx, l2_rip);
|
||||
|
||||
GUEST_SYNC(TEST_SYNC_NO_FAULT);
|
||||
GUEST_ASSERT(!vmlaunch());
|
||||
|
|
@ -115,7 +112,6 @@ void l1_vmx_code(struct vmx_pages *vmx)
|
|||
|
||||
static void l1_svm_code(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
void *l2_rip;
|
||||
|
||||
if (svm->ncr3_gpa)
|
||||
|
|
@ -123,7 +119,7 @@ static void l1_svm_code(struct svm_test_data *svm)
|
|||
else
|
||||
l2_rip = l2_guest_code_tdp_disabled;
|
||||
|
||||
generic_svm_setup(svm, l2_rip, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_rip);
|
||||
|
||||
GUEST_SYNC(TEST_SYNC_NO_FAULT);
|
||||
run_guest(svm->vmcb, svm->vmcb_gpa);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ static void guest_code(void *test_data)
|
|||
struct svm_test_data *svm = test_data;
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
|
||||
generic_svm_setup(svm, NULL, NULL);
|
||||
generic_svm_setup(svm, NULL);
|
||||
vmcb->save.idtr.limit = 0;
|
||||
vmcb->save.rip = (u64)l2_guest_code;
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ static void guest_code(void *test_data)
|
|||
GUEST_ASSERT(prepare_for_vmx_operation(test_data));
|
||||
GUEST_ASSERT(load_vmcs(test_data));
|
||||
|
||||
prepare_vmcs(test_data, NULL, NULL);
|
||||
prepare_vmcs(test_data, NULL);
|
||||
GUEST_ASSERT(!vmwrite(GUEST_IDTR_LIMIT, 0));
|
||||
GUEST_ASSERT(!vmwrite(GUEST_RIP, (u64)l2_guest_code));
|
||||
GUEST_ASSERT(!vmwrite(EXCEPTION_BITMAP, 0));
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@
|
|||
#include "vmx.h"
|
||||
#include "svm_util.h"
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 256
|
||||
|
||||
/*
|
||||
* Arbitrary, never shoved into KVM/hardware, just need to avoid conflict with
|
||||
* the "real" exceptions used, #SS/#GP/#DF (12/13/8).
|
||||
|
|
@ -91,9 +89,8 @@ static void svm_run_l2(struct svm_test_data *svm, void *l2_code, int vector,
|
|||
static void l1_svm_code(struct svm_test_data *svm)
|
||||
{
|
||||
struct vmcb_control_area *ctrl = &svm->vmcb->control;
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
generic_svm_setup(svm, NULL, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, NULL);
|
||||
svm->vmcb->save.idtr.limit = 0;
|
||||
ctrl->intercept |= BIT_ULL(INTERCEPT_SHUTDOWN);
|
||||
|
||||
|
|
@ -128,13 +125,11 @@ static void vmx_run_l2(void *l2_code, int vector, u32 error_code)
|
|||
|
||||
static void l1_vmx_code(struct vmx_pages *vmx)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
GUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);
|
||||
|
||||
GUEST_ASSERT_EQ(load_vmcs(vmx), true);
|
||||
|
||||
prepare_vmcs(vmx, NULL, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx, NULL);
|
||||
GUEST_ASSERT_EQ(vmwrite(GUEST_IDTR_LIMIT, 0), 0);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
#include "kselftest.h"
|
||||
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
static void l2_guest_code(void)
|
||||
{
|
||||
vmcall();
|
||||
|
|
@ -20,11 +18,9 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_svm_code(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
uintptr_t save_cr3;
|
||||
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
/* Try to run L2 with invalid CR3 and make sure it fails */
|
||||
save_cr3 = svm->vmcb->save.cr3;
|
||||
|
|
@ -42,14 +38,12 @@ static void l1_svm_code(struct svm_test_data *svm)
|
|||
|
||||
static void l1_vmx_code(struct vmx_pages *vmx_pages)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
uintptr_t save_cr3;
|
||||
|
||||
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
|
||||
GUEST_ASSERT(load_vmcs(vmx_pages));
|
||||
|
||||
prepare_vmcs(vmx_pages, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
|
||||
/* Try to run L2 with invalid CR3 and make sure it fails */
|
||||
save_cr3 = vmreadz(GUEST_CR3);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@
|
|||
#include "svm_util.h"
|
||||
#include "vmx.h"
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
enum test_type {
|
||||
TEST_FINAL_PAGE_UNMAPPED, /* Final data page not present */
|
||||
TEST_PT_PAGE_UNMAPPED, /* Page table page not present */
|
||||
|
|
@ -54,14 +52,13 @@ static void l2_guest_code_ins(void)
|
|||
static void l1_vmx_code(struct vmx_pages *vmx, u64 expected_fault_gpa,
|
||||
u64 test_type)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
u64 exit_qual;
|
||||
|
||||
GUEST_ASSERT(vmx->vmcs_gpa);
|
||||
GUEST_ASSERT(prepare_for_vmx_operation(vmx));
|
||||
GUEST_ASSERT(load_vmcs(vmx));
|
||||
|
||||
prepare_vmcs(vmx, l2_entry, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx, l2_entry);
|
||||
|
||||
GUEST_ASSERT(!vmlaunch());
|
||||
|
||||
|
|
@ -120,12 +117,10 @@ static void l1_vmx_code(struct vmx_pages *vmx, u64 expected_fault_gpa,
|
|||
static void l1_svm_code(struct svm_test_data *svm, u64 expected_fault_gpa,
|
||||
u64 test_type)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
u64 exit_info_1;
|
||||
|
||||
generic_svm_setup(svm, l2_entry,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_entry);
|
||||
|
||||
run_guest(vmcb, svm->vmcb_gpa);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@
|
|||
#define TSC_ADJUST_VALUE (1ll << 32)
|
||||
#define TSC_OFFSET_VALUE -(1ll << 48)
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
enum {
|
||||
PORT_ABORT = 0x1000,
|
||||
PORT_REPORT,
|
||||
|
|
@ -75,8 +73,6 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_guest_code(void *data)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
/* Set TSC from L1 and make sure TSC_ADJUST is updated correctly */
|
||||
GUEST_ASSERT(rdtsc() < TSC_ADJUST_VALUE);
|
||||
wrmsr(MSR_IA32_TSC, rdtsc() - TSC_ADJUST_VALUE);
|
||||
|
|
@ -93,8 +89,7 @@ static void l1_guest_code(void *data)
|
|||
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
|
||||
GUEST_ASSERT(load_vmcs(vmx_pages));
|
||||
|
||||
prepare_vmcs(vmx_pages, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
control = vmreadz(CPU_BASED_VM_EXEC_CONTROL);
|
||||
control |= CPU_BASED_USE_MSR_BITMAPS | CPU_BASED_USE_TSC_OFFSETTING;
|
||||
vmwrite(CPU_BASED_VM_EXEC_CONTROL, control);
|
||||
|
|
@ -105,8 +100,7 @@ static void l1_guest_code(void *data)
|
|||
} else {
|
||||
struct svm_test_data *svm = data;
|
||||
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
svm->vmcb->control.tsc_offset = TSC_OFFSET_VALUE;
|
||||
run_guest(svm->vmcb, svm->vmcb_gpa);
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@
|
|||
#define TSC_OFFSET_L2 ((u64)-33125236320908)
|
||||
#define TSC_MULTIPLIER_L2 (L2_SCALE_FACTOR << 48)
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
enum { USLEEP, UCHECK_L1, UCHECK_L2 };
|
||||
#define GUEST_SLEEP(sec) ucall(UCALL_SYNC, 2, USLEEP, sec)
|
||||
#define GUEST_CHECK(level, freq) ucall(UCALL_SYNC, 2, level, freq)
|
||||
|
|
@ -82,13 +80,10 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_svm_code(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
/* check that L1's frequency looks alright before launching L2 */
|
||||
check_tsc_freq(UCHECK_L1);
|
||||
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
/* enable TSC scaling for L2 */
|
||||
wrmsr(MSR_AMD64_TSC_RATIO, L2_SCALE_FACTOR << 32);
|
||||
|
|
@ -105,7 +100,6 @@ static void l1_svm_code(struct svm_test_data *svm)
|
|||
|
||||
static void l1_vmx_code(struct vmx_pages *vmx_pages)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
u32 control;
|
||||
|
||||
/* check that L1's frequency looks alright before launching L2 */
|
||||
|
|
@ -115,7 +109,7 @@ static void l1_vmx_code(struct vmx_pages *vmx_pages)
|
|||
GUEST_ASSERT(load_vmcs(vmx_pages));
|
||||
|
||||
/* prepare the VMCS for L2 execution */
|
||||
prepare_vmcs(vmx_pages, l2_guest_code, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
|
||||
/* enable TSC offsetting and TSC scaling for L2 */
|
||||
control = vmreadz(CPU_BASED_VM_EXEC_CONTROL);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@
|
|||
|
||||
#define TEST_VMCB_L2_GPA TEST_VMCB_L1_GPA(0)
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
static void l2_guest_code_vmsave(void)
|
||||
{
|
||||
asm volatile("vmsave %0" : : "a"(TEST_VMCB_L2_GPA) : "memory");
|
||||
|
|
@ -70,10 +68,8 @@ static void l2_guest_code_vmcb1(void)
|
|||
|
||||
static void l1_guest_code(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
/* Each test case initializes the guest RIP below */
|
||||
generic_svm_setup(svm, NULL, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, NULL);
|
||||
|
||||
/* Set VMSAVE/VMLOAD intercepts and make sure they work with.. */
|
||||
svm->vmcb->control.intercept |= (BIT_ULL(INTERCEPT_VMSAVE) |
|
||||
|
|
|
|||
|
|
@ -63,8 +63,6 @@ static void l2_guest_code(void)
|
|||
|
||||
static void guest_code(void *arg)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
u64 apicbase = rdmsr(MSR_IA32_APICBASE);
|
||||
struct svm_test_data *svm = arg;
|
||||
struct vmx_pages *vmx_pages = arg;
|
||||
|
|
@ -81,13 +79,11 @@ static void guest_code(void *arg)
|
|||
|
||||
if (arg) {
|
||||
if (this_cpu_has(X86_FEATURE_SVM)) {
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
} else {
|
||||
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
|
||||
GUEST_ASSERT(load_vmcs(vmx_pages));
|
||||
prepare_vmcs(vmx_pages, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
}
|
||||
|
||||
sync_with_host(5);
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@
|
|||
#include "vmx.h"
|
||||
#include "svm_util.h"
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 256
|
||||
|
||||
void svm_l2_guest_code(void)
|
||||
{
|
||||
GUEST_SYNC(4);
|
||||
|
|
@ -35,13 +33,11 @@ void svm_l2_guest_code(void)
|
|||
|
||||
static void svm_l1_guest_code(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
|
||||
GUEST_ASSERT(svm->vmcb_gpa);
|
||||
/* Prepare for L2 execution. */
|
||||
generic_svm_setup(svm, svm_l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, svm_l2_guest_code);
|
||||
|
||||
vmcb->control.int_ctl |= (V_GIF_ENABLE_MASK | V_GIF_MASK);
|
||||
|
||||
|
|
@ -78,8 +74,6 @@ void vmx_l2_guest_code(void)
|
|||
|
||||
static void vmx_l1_guest_code(struct vmx_pages *vmx_pages)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
GUEST_ASSERT(vmx_pages->vmcs_gpa);
|
||||
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
|
||||
GUEST_SYNC(3);
|
||||
|
|
@ -89,8 +83,7 @@ static void vmx_l1_guest_code(struct vmx_pages *vmx_pages)
|
|||
GUEST_SYNC(4);
|
||||
GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
|
||||
|
||||
prepare_vmcs(vmx_pages, vmx_l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, vmx_l2_guest_code);
|
||||
|
||||
GUEST_SYNC(5);
|
||||
GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
|
||||
|
|
|
|||
|
|
@ -54,15 +54,12 @@ static void l2_guest_code(struct svm_test_data *svm)
|
|||
|
||||
static void l1_guest_code(struct svm_test_data *svm)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
|
||||
x2apic_enable();
|
||||
|
||||
/* Prepare for L2 execution. */
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
/* No virtual interrupt masking */
|
||||
vmcb->control.int_ctl &= ~V_INTR_MASKING_MASK;
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@
|
|||
#include "svm_util.h"
|
||||
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
#define DO_BRANCH() do { asm volatile("jmp 1f\n 1: nop"); } while (0)
|
||||
|
||||
struct lbr_branch {
|
||||
|
|
@ -55,7 +53,6 @@ static void l2_guest_code(struct svm_test_data *svm)
|
|||
|
||||
static void l1_guest_code(struct svm_test_data *svm, bool nested_lbrv)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
struct lbr_branch l1_branch;
|
||||
|
||||
|
|
@ -65,8 +62,7 @@ static void l1_guest_code(struct svm_test_data *svm, bool nested_lbrv)
|
|||
CHECK_BRANCH_MSRS(&l1_branch);
|
||||
|
||||
/* Run L2, which will also do the same */
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
if (nested_lbrv)
|
||||
vmcb->control.misc_ctl2 = SVM_MISC2_ENABLE_V_LBR;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
#include "kselftest.h"
|
||||
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
static void l2_guest_code(void)
|
||||
{
|
||||
unsigned long efer = rdmsr(MSR_EFER);
|
||||
|
|
@ -24,10 +22,7 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_guest_code(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
run_guest(svm->vmcb, svm->vmcb_gpa);
|
||||
|
||||
/* Unreachable, L1 should be shutdown */
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@
|
|||
#include "processor.h"
|
||||
#include "svm_util.h"
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 256
|
||||
|
||||
#define PAT_DEFAULT 0x0007040600070406ULL
|
||||
#define L1_PAT_VALUE 0x0007040600070404ULL /* Change PA0 to WT */
|
||||
#define L2_VMCB12_PAT 0x0606060606060606ULL /* All WB */
|
||||
|
|
@ -59,14 +57,13 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_guest_code(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
int i;
|
||||
|
||||
wrmsr(MSR_IA32_CR_PAT, L1_PAT_VALUE);
|
||||
GUEST_ASSERT_EQ(rdmsr(MSR_IA32_CR_PAT), L1_PAT_VALUE);
|
||||
|
||||
generic_svm_setup(svm, l2_guest_code, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
vmcb->save.g_pat = L2_VMCB12_PAT;
|
||||
vmcb->control.intercept &= ~(1ULL << INTERCEPT_MSR_PROT);
|
||||
|
|
@ -94,11 +91,10 @@ static void l1_guest_code(struct svm_test_data *svm)
|
|||
|
||||
static void l1_guest_code_invalid_gpat(struct svm_test_data *svm)
|
||||
{
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
|
||||
/* VMRUN should fail without running L2 */
|
||||
generic_svm_setup(svm, NULL, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, NULL);
|
||||
|
||||
vmcb->save.g_pat = INVALID_PAT_VALUE;
|
||||
run_guest(vmcb, svm->vmcb_gpa);
|
||||
|
|
|
|||
|
|
@ -19,12 +19,9 @@ static void l2_guest_code(struct svm_test_data *svm)
|
|||
|
||||
static void l1_guest_code(struct svm_test_data *svm, struct idt_entry *idt)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
vmcb->control.intercept &= ~(BIT(INTERCEPT_SHUTDOWN));
|
||||
|
||||
|
|
|
|||
|
|
@ -78,17 +78,13 @@ static void l2_guest_code_nmi(void)
|
|||
|
||||
static void l1_guest_code(struct svm_test_data *svm, u64 is_nmi, u64 idt_alt)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
|
||||
if (is_nmi)
|
||||
x2apic_enable();
|
||||
|
||||
/* Prepare for L2 execution. */
|
||||
generic_svm_setup(svm,
|
||||
is_nmi ? l2_guest_code_nmi : l2_guest_code_int,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, is_nmi ? l2_guest_code_nmi : l2_guest_code_int);
|
||||
|
||||
vmcb->control.intercept_exceptions |= BIT(PF_VECTOR) | BIT(UD_VECTOR);
|
||||
vmcb->control.intercept |= BIT(INTERCEPT_NMI) | BIT(INTERCEPT_HLT);
|
||||
|
|
|
|||
|
|
@ -9,14 +9,9 @@
|
|||
#include "kvm_test_harness.h"
|
||||
#include "test_util.h"
|
||||
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
|
||||
#define SYNC_GP 101
|
||||
#define SYNC_L2_STARTED 102
|
||||
|
||||
static unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
static void guest_gp_handler(struct ex_regs *regs)
|
||||
{
|
||||
GUEST_SYNC(SYNC_GP);
|
||||
|
|
@ -30,28 +25,28 @@ static void l2_code(void)
|
|||
|
||||
static void l1_vmrun(struct svm_test_data *svm, gpa_t gpa)
|
||||
{
|
||||
generic_svm_setup(svm, l2_code, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_code);
|
||||
|
||||
asm volatile ("vmrun %[gpa]" : : [gpa] "a" (gpa) : "memory");
|
||||
}
|
||||
|
||||
static void l1_vmload(struct svm_test_data *svm, gpa_t gpa)
|
||||
{
|
||||
generic_svm_setup(svm, l2_code, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_code);
|
||||
|
||||
asm volatile ("vmload %[gpa]" : : [gpa] "a" (gpa) : "memory");
|
||||
}
|
||||
|
||||
static void l1_vmsave(struct svm_test_data *svm, gpa_t gpa)
|
||||
{
|
||||
generic_svm_setup(svm, l2_code, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_code);
|
||||
|
||||
asm volatile ("vmsave %[gpa]" : : [gpa] "a" (gpa) : "memory");
|
||||
}
|
||||
|
||||
static void l1_vmexit(struct svm_test_data *svm, gpa_t gpa)
|
||||
{
|
||||
generic_svm_setup(svm, l2_code, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_code);
|
||||
|
||||
run_guest(svm->vmcb, svm->vmcb_gpa);
|
||||
GUEST_ASSERT(svm->vmcb->control.exit_code == SVM_EXIT_VMMCALL);
|
||||
|
|
|
|||
|
|
@ -19,13 +19,10 @@ static void l2_guest_code(struct svm_test_data *svm)
|
|||
|
||||
static void l1_guest_code(struct svm_test_data *svm)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
|
||||
/* Prepare for L2 execution. */
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
run_guest(vmcb, svm->vmcb_gpa);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ static void l2_guest_code(void)
|
|||
: : [port] "d" (ARBITRARY_IO_PORT) : "rax");
|
||||
}
|
||||
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
void l1_guest_code_vmx(struct vmx_pages *vmx)
|
||||
{
|
||||
|
||||
|
|
@ -31,8 +28,7 @@ void l1_guest_code_vmx(struct vmx_pages *vmx)
|
|||
GUEST_ASSERT(prepare_for_vmx_operation(vmx));
|
||||
GUEST_ASSERT(load_vmcs(vmx));
|
||||
|
||||
prepare_vmcs(vmx, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx, l2_guest_code);
|
||||
|
||||
GUEST_ASSERT(!vmlaunch());
|
||||
/* L2 should triple fault after a triple fault event injected. */
|
||||
|
|
@ -44,8 +40,7 @@ void l1_guest_code_svm(struct svm_test_data *svm)
|
|||
{
|
||||
struct vmcb *vmcb = svm->vmcb;
|
||||
|
||||
generic_svm_setup(svm, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
generic_svm_setup(svm, l2_guest_code);
|
||||
|
||||
/* don't intercept shutdown to test the case of SVM allowing to do so */
|
||||
vmcb->control.intercept &= ~(BIT(INTERCEPT_SHUTDOWN));
|
||||
|
|
|
|||
|
|
@ -36,16 +36,13 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_guest_code(struct vmx_pages *vmx_pages, unsigned long high_gpa)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
u32 control;
|
||||
|
||||
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
|
||||
GUEST_ASSERT(load_vmcs(vmx_pages));
|
||||
|
||||
/* Prepare the VMCS for L2 execution. */
|
||||
prepare_vmcs(vmx_pages, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
control = vmreadz(CPU_BASED_VM_EXEC_CONTROL);
|
||||
control |= CPU_BASED_ACTIVATE_SECONDARY_CONTROLS;
|
||||
vmwrite(CPU_BASED_VM_EXEC_CONTROL, control);
|
||||
|
|
|
|||
|
|
@ -31,15 +31,13 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_guest_code(struct vmx_pages *vmx_pages)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
u32 control;
|
||||
|
||||
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
|
||||
GUEST_ASSERT(load_vmcs(vmx_pages));
|
||||
|
||||
/* Prepare the VMCS for L2 execution. */
|
||||
prepare_vmcs(vmx_pages, l2_guest_code, &l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
control = vmreadz(CPU_BASED_VM_EXEC_CONTROL);
|
||||
control |= CPU_BASED_USE_MSR_BITMAPS;
|
||||
vmwrite(CPU_BASED_VM_EXEC_CONTROL, control);
|
||||
|
|
|
|||
|
|
@ -25,15 +25,11 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_guest_code(struct vmx_pages *vmx_pages)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
|
||||
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
|
||||
GUEST_ASSERT(load_vmcs(vmx_pages));
|
||||
|
||||
/* Prepare the VMCS for L2 execution. */
|
||||
prepare_vmcs(vmx_pages, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
|
||||
/*
|
||||
* L2 must be run without unrestricted guest, verify that the selftests
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ static void l2_guest_code(void)
|
|||
|
||||
static void l1_guest_code(struct vmx_pages *vmx_pages)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
u64 guest_cr4;
|
||||
gpa_t pml5_pa, pml4_pa;
|
||||
u64 *pml5;
|
||||
|
|
@ -42,8 +40,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
|
|||
GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
|
||||
GUEST_ASSERT(load_vmcs(vmx_pages));
|
||||
|
||||
prepare_vmcs(vmx_pages, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
|
||||
/*
|
||||
* Set up L2 with a 4-level page table by pointing its CR3 to
|
||||
|
|
|
|||
|
|
@ -66,8 +66,6 @@ void l2_guest_code(void)
|
|||
|
||||
void l1_guest_code(struct vmx_pages *vmx_pages)
|
||||
{
|
||||
#define L2_GUEST_STACK_SIZE 64
|
||||
unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
|
||||
u64 l1_vmx_pt_start;
|
||||
u64 l1_vmx_pt_finish;
|
||||
u64 l1_tsc_deadline, l2_tsc_deadline;
|
||||
|
|
@ -77,8 +75,7 @@ void l1_guest_code(struct vmx_pages *vmx_pages)
|
|||
GUEST_ASSERT(load_vmcs(vmx_pages));
|
||||
GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa);
|
||||
|
||||
prepare_vmcs(vmx_pages, l2_guest_code,
|
||||
&l2_guest_stack[L2_GUEST_STACK_SIZE]);
|
||||
prepare_vmcs(vmx_pages, l2_guest_code);
|
||||
|
||||
/*
|
||||
* Check for Preemption timer support
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user