From 15a89f9de7be49cc53d24c334bf793dbd550bf6e Mon Sep 17 00:00:00 2001 From: Alexander Kudryavtsev Date: Wed, 12 Oct 2011 16:43:02 +0400 Subject: [PATCH 24/32] Added invept and do not ignore PAT --- palacios/src/palacios/vmx.c | 16 ++++++++++++++++ palacios/src/palacios/vmx_ept.c | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index b592f15..bdaf598 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -94,7 +94,21 @@ static addr_t allocate_vmcs() { return (addr_t)V3_PAddr((void *)vmcs_page); } +#define VMX_EPT_EXTENT_INDIVIDUAL_ADDR 0 +#define VMX_EPT_EXTENT_CONTEXT 1 +#define VMX_EPT_EXTENT_GLOBAL 2 +#define ASM_VMX_INVEPT ".byte 0x66, 0x0f, 0x38, 0x80, 0x08" +static inline void __invept(int ext, uint64_t eptp, uint64_t gpa) +{ + struct { + uint64_t eptp, gpa; + } operand = {eptp, gpa}; + asm volatile (".byte 0x66, 0x0f, 0x38, 0x80, 0x08" + /* CF==1 or ZF==1 --> rc = -1 */ + "; ja 1f ; ud2 ; 1:\n" + : : "a" (&operand), "c" (ext) : "cc", "memory"); +} static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) { @@ -292,6 +306,8 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) vmx_state->sec_proc_ctrls.enable_vpid = 1; vmcs_write(VMCS_VPID, core->vcpu_id + 1); + __invept(VMX_EPT_EXTENT_GLOBAL, 0, 0); + if (v3_init_ept(core, &hw_info) == -1) { diff --git a/palacios/src/palacios/vmx_ept.c b/palacios/src/palacios/vmx_ept.c index a23dccd..b89bc04 100644 --- a/palacios/src/palacios/vmx_ept.c +++ b/palacios/src/palacios/vmx_ept.c @@ -151,7 +151,7 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_ pde2mb[pde_index].write = 0; } - pde2mb[pde_index].ipat = 1; // ignore PAT + //pde2mb[pde_index].ipat = 1; // ignore PAT pde2mb[pde_index].mt = region->flags.mt; if (v3_gpa_to_hpa(core, fault_addr, &host_addr) == -1) { @@ -207,7 +207,7 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_ pte[pte_index].write = 0; } - pte[pte_index].ipat = 1; // ignore PAT + //pte[pte_index].ipat = 1; // ignore PAT pte[pte_index].mt = region->flags.mt; if (v3_gpa_to_hpa(core, fault_addr, &host_addr) == -1) { -- 1.7.5.4