summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/amd64/pmap.c31
-rw-r--r--sys/arch/amd64/amd64/vmm.c36
-rw-r--r--sys/arch/amd64/include/pmap.h4
3 files changed, 18 insertions, 53 deletions
diff --git a/sys/arch/amd64/amd64/pmap.c b/sys/arch/amd64/amd64/pmap.c
index bb26a571a9e..0b61f1b488b 100644
--- a/sys/arch/amd64/amd64/pmap.c
+++ b/sys/arch/amd64/amd64/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.97 2015/11/10 08:57:39 mlarkin Exp $ */
+/* $OpenBSD: pmap.c,v 1.98 2016/02/08 18:23:04 stefan Exp $ */
/* $NetBSD: pmap.c,v 1.3 2003/05/08 18:13:13 thorpej Exp $ */
/*
@@ -413,27 +413,23 @@ pmap_unmap_ptes(struct pmap *pmap, paddr_t save_cr3)
* Parameters:
* pm: The pmap in question
* va: The VA to fix up
- * offs: (out) return the offset into the PD/PT for this va
- *
- * Return value:
- * int value corresponding to the level this VA was found
*/
-int
-pmap_fix_ept(struct pmap *pm, vaddr_t va, int *offs)
+void
+pmap_fix_ept(struct pmap *pm, vaddr_t va)
{
u_long mask, shift;
pd_entry_t pde, *pd;
paddr_t pdpa;
- int lev;
+ int lev, offs;
pdpa = pm->pm_pdirpa;
shift = L4_SHIFT;
mask = L4_MASK;
for (lev = PTP_LEVELS; lev > 0; lev--) {
pd = (pd_entry_t *)PMAP_DIRECT_MAP(pdpa);
- *offs = (VA_SIGN_POS(va) & mask) >> shift;
+ offs = (VA_SIGN_POS(va) & mask) >> shift;
- pd[*offs] |= EPT_R | EPT_W | EPT_X;
+ pd[offs] |= EPT_R | EPT_W | EPT_X;
/*
* Levels 3-4 have bits 3:7 'must be 0'
* Level 2 has bits 3:6 'must be 0', and bit 7 is always
@@ -444,25 +440,23 @@ pmap_fix_ept(struct pmap *pm, vaddr_t va, int *offs)
case 3:
case 2:
/* Bits 3:7 = 0 */
- pd[*offs] &= ~(0xF8);
+ pd[offs] &= ~(0xF8);
break;
- case 1: pd[*offs] |= EPT_WB;
+ case 1: pd[offs] |= EPT_WB;
break;
}
- pde = pd[*offs];
+ pde = pd[offs];
/* Large pages are different, break early if we run into one. */
if ((pde & (PG_PS|PG_V)) != PG_V)
- return (lev - 1);
+ panic("pmap_fix_ept: large page in EPT");
- pdpa = (pd[*offs] & PG_FRAME);
+ pdpa = (pd[offs] & PG_FRAME);
/* 4096/8 == 512 == 2^9 entries per level */
shift -= 9;
mask >>= 9;
}
-
- return (0);
}
int
@@ -2187,6 +2181,9 @@ enter_now:
error = 0;
+ if (pmap->pm_type == PMAP_TYPE_EPT)
+ pmap_fix_ept(pmap, va);
+
out:
if (pve)
pool_put(&pmap_pv_pool, pve);
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c
index b7a16037168..f03aa20d200 100644
--- a/sys/arch/amd64/amd64/vmm.c
+++ b/sys/arch/amd64/amd64/vmm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm.c,v 1.33 2016/01/29 00:47:51 jsg Exp $ */
+/* $OpenBSD: vmm.c,v 1.34 2016/02/08 18:23:04 stefan Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@@ -148,7 +148,6 @@ int svm_get_guest_faulttype(void);
int vmx_get_exit_qualification(uint64_t *);
int vmx_fault_page(struct vcpu *, paddr_t);
int vmx_handle_np_fault(struct vcpu *);
-int vmx_fix_ept_pte(struct pmap *, vaddr_t);
const char *vmx_exit_reason_decode(uint32_t);
const char *vmx_instruction_error_decode(uint32_t);
void dump_vcpu(struct vcpu *);
@@ -634,13 +633,6 @@ vm_writepage(struct vm_writepage_params *vwp)
free(pagedata, M_DEVBUF, PAGE_SIZE);
- /* Fixup the EPT map for this page */
- if (vmx_fix_ept_pte(vm->vm_map->pmap, vw_page)) {
- DPRINTF("vm_writepage: cant fixup ept pte for gpa 0x%llx\n",
- (uint64_t)vwp->vwp_paddr);
- rw_exit_read(&vmm_softc->vm_lock);
- return (EFAULT);
- }
rw_exit_read(&vmm_softc->vm_lock);
return (0);
@@ -3069,7 +3061,6 @@ int
vmx_fault_page(struct vcpu *vcpu, paddr_t gpa)
{
int fault_type, ret;
- struct pmap *pmap;
fault_type = vmx_get_guest_faulttype();
if (fault_type == -1) {
@@ -3079,15 +3070,8 @@ vmx_fault_page(struct vcpu *vcpu, paddr_t gpa)
ret = uvm_fault(vcpu->vc_parent->vm_map, gpa, fault_type,
PROT_READ | PROT_WRITE | PROT_EXEC);
- if (!ret) {
- pmap = vcpu->vc_parent->vm_map->pmap;
- if (vmx_fix_ept_pte(pmap, gpa)) {
- printf("vmx_fault_page: ept fixup failure\n");
- ret = EINVAL;
- }
- } else {
+ if (ret)
printf("vmx_fault_page: uvm_fault returns %d\n", ret);
- }
return (ret);
}
@@ -3463,22 +3447,6 @@ vcpu_run_svm(struct vcpu *vcpu, uint8_t from_exit)
}
/*
- * vmx_fix_ept_pte
- *
- * Fixes up the pmap PTE entry for 'addr' to reflect proper EPT format
- */
-int
-vmx_fix_ept_pte(struct pmap *pmap, vaddr_t addr)
-{
- int offs, level;
-
- level = pmap_fix_ept(pmap, addr, &offs);
- KASSERT(level == 0);
-
- return (0);
-}
-
-/*
* vmx_exit_reason_decode
*
* Returns a human readable string describing exit type 'code'
diff --git a/sys/arch/amd64/include/pmap.h b/sys/arch/amd64/include/pmap.h
index 2a87c431671..7e7362e9ac6 100644
--- a/sys/arch/amd64/include/pmap.h
+++ b/sys/arch/amd64/include/pmap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.h,v 1.61 2015/11/13 07:52:20 mlarkin Exp $ */
+/* $OpenBSD: pmap.h,v 1.62 2016/02/08 18:23:04 stefan Exp $ */
/* $NetBSD: pmap.h,v 1.1 2003/04/26 18:39:46 fvdl Exp $ */
/*
@@ -369,7 +369,7 @@ static void pmap_update_pg(vaddr_t);
static void pmap_update_2pg(vaddr_t,vaddr_t);
void pmap_write_protect(struct pmap *, vaddr_t,
vaddr_t, vm_prot_t);
-int pmap_fix_ept(struct pmap *, vaddr_t, int *);
+void pmap_fix_ept(struct pmap *, vaddr_t);
vaddr_t reserve_dumppages(vaddr_t); /* XXX: not a pmap fn */