Date: Mon, 10 Aug 2015 18:42:18 GMT From: mihai@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289533 - soc2015/mihai/bhyve-on-arm-head/sys/arm/vmm Message-ID: <201508101842.t7AIgIOe075498@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mihai Date: Mon Aug 10 18:42:18 2015 New Revision: 289533 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289533 Log: sys: arm: arm: vmm: arm.c: fix gpa for inst_emul, probe vgic and map timers to the guest Modified: soc2015/mihai/bhyve-on-arm-head/sys/arm/vmm/arm.c Modified: soc2015/mihai/bhyve-on-arm-head/sys/arm/vmm/arm.c ============================================================================== --- soc2015/mihai/bhyve-on-arm-head/sys/arm/vmm/arm.c Mon Aug 10 18:40:58 2015 (r289532) +++ soc2015/mihai/bhyve-on-arm-head/sys/arm/vmm/arm.c Mon Aug 10 18:42:18 2015 (r289533) @@ -21,6 +21,7 @@ #include "mmu.h" #include "arm.h" #include "hyp.h" +#include "vgic.h" #define HANDLED 1 #define UNHANDLED 0 @@ -146,6 +147,11 @@ printf("%s hyp_l1pd: %p, phys_hyp_l1pd %p\n", __func__, (void*) hyp_l1pd, (void*)phys_hyp_l1pd); vmm_call_hyp(&hyp_vector[0], stack_top, LOW(phys_hyp_l1pd), HIGH(phys_hyp_l1pd)); + /* Initialize VGIC infrastructure */ + if (vgic_hyp_init()) { + return (ENXIO); + } + return 0; } @@ -190,6 +196,8 @@ } hyp->vm = vm; + hyp->vgic_attached = false; + hyp->l1pd_phys = (lpae_pd_entry_t) vtophys(&hyp->l1pd[0]); set_vttbr(hyp); @@ -197,7 +205,7 @@ hypctx = &hyp->ctx[i]; hypctx->vcpu = i; hypctx->hyp = hyp; - hypctx->hcr = HCR_GUEST_MASK; + hypctx->hcr = HCR_GUEST_MASK & ~HCR_TSW & ~HCR_TAC & ~HCR_IMO & ~HCR_FMO; hypctx->midr = cpu_ident(); hypctx->mpidr = (cp15_mpidr_get() & MPIDR_SMP_MASK) | MPIDR_AFF1_LEVEL(i) | @@ -211,6 +219,20 @@ sizeof(struct hyp), VM_PROT_READ | VM_PROT_WRITE); + /* Map Timer0 SP804 */ + lpae_vmmmap_set(hyp, + (lpae_vm_vaddr_t)0x1c110000, + (lpae_vm_paddr_t)0x1c110000, + PAGE_SIZE, + VM_PROT_READ | VM_PROT_WRITE); + + lpae_vmmmap_set(hyp, + (lpae_vm_vaddr_t)0x1c120000, + (lpae_vm_paddr_t)0x1c120000, + PAGE_SIZE, + VM_PROT_READ | VM_PROT_WRITE); + + return (hyp); } @@ -367,7 +389,8 @@ * Build the instruction info and return to user to emulate */ vmexit->exitcode = VM_EXITCODE_INST_EMUL; - vmexit->u.inst_emul.gpa = vmexit->u.hyp.hdfar; + vmexit->u.inst_emul.gpa = ((uint64_t)(vmexit->u.hyp.hpfar >> 4) << 12) | + (vmexit->u.hyp.hdfar & ((1 << 12) - 1)); vmexit->u.inst_emul.vie.access_size = HSR_ISS_ACCESS_SIZE(HSR_ISS_SAS(hsr_iss)); vmexit->u.inst_emul.vie.sign_extend = HSR_ISS_SSE(hsr_iss); vmexit->u.inst_emul.vie.dir = HSR_ISS_WnR(hsr_iss); @@ -378,12 +401,12 @@ // vmexit->u.inst_emul.vie.dir, vmexit->u.inst_emul.vie.reg); } else { - printf("%s:%d DABT from guest at address %x witho a stage-2 fault != translation\n", - __func__, __LINE__, vmexit->u.hyp.hdfar); + printf("%s:%d DABT from guest at address %x with hsr %x with a stage-2 fault != translation\n", + __func__, __LINE__, vmexit->u.hyp.hdfar, vmexit->u.hyp.hsr); } } else { - printf("%s:%d DABT from guest at address %x without a stage-2 fault translation\n", - __func__, __LINE__, vmexit->u.hyp.hdfar); + printf("%s:%d DABT from guest at address %x with hsr %x, hpfar: %x without a stage-2 fault translation\n", + __func__, __LINE__, vmexit->u.hyp.hdfar, vmexit->u.hyp.hsr, vmexit->u.hyp.hpfar); } break; case HSR_EC_DABT_HYP:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508101842.t7AIgIOe075498>