[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 03/19] xen/arm: Set and restore HCR_EL2 register for each vCPU separately
Different domains may have different HCR_EL2 flags. For example, the 64-bit domain needs HCR_RW flag but the 32-bit does not need it. So we give each domain a default HCR_EL2 value and save it in the vCPU's context. HCR_EL2 register has only one bit can be updated automatically without explicit write (HCR_VSE). But we haven't used this bit currently, so we can consider that the HCR_EL2 register will not be modified while the guest is running. So save the HCR_EL2 while guest exiting to hypervisor is not neccessary. We just have to restore this register for each vCPU while context switching. The p2m_restore_state which will be invoked in context switch progress has included the writing of HCR_EL2 already. It updates the HCR_EL2.RW bit to tell the hardware how to interpret the stage-1 page table as the encodings are different between AArch64 and AArch32. We can reuse this write to restore the HCR_EL2 for each vCPU. Of course, the value of each vCPU's HCR_EL2 should be adjusted to have proper HCR_EL2.RW bit in this function. In the later patch of this series, we will set the HCR_EL2.RW for each vCPU while the domain is creating. Signed-off-by: wei chen <Wei.Chen@xxxxxxx> --- v2->v3: 1. Squash #2 #3 patchs of v2 into this patch. 2. Remove HCR_EL2 initialization of idle vCPU, it would be used. 3. Revert the change of vwfi. 4. Use the helper that introduced in previous patch to initialize HCR_EL2 for each vCPU. 5. Restore the initialization of HCR_EL2 in init_traps. --- xen/arch/arm/domain.c | 2 ++ xen/arch/arm/p2m.c | 9 +++------ xen/include/asm-arm/domain.h | 3 +++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index bb327da..5d18bb0 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -513,6 +513,8 @@ int vcpu_initialise(struct vcpu *v) v->arch.actlr = READ_SYSREG32(ACTLR_EL1); + v->arch.hcr_el2 = get_default_hcr_flags(); + processor_vcpu_initialise(v); if ( (rc = vcpu_vgic_init(v)) != 0 ) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 6263760..83c4b7d 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -128,27 +128,24 @@ void p2m_save_state(struct vcpu *p) void p2m_restore_state(struct vcpu *n) { - register_t hcr; struct p2m_domain *p2m = &n->domain->arch.p2m; uint8_t *last_vcpu_ran; if ( is_idle_vcpu(n) ) return; - hcr = READ_SYSREG(HCR_EL2); - WRITE_SYSREG64(p2m->vttbr, VTTBR_EL2); isb(); if ( is_32bit_domain(n->domain) ) - hcr &= ~HCR_RW; + n->arch.hcr_el2 &= ~HCR_RW; else - hcr |= HCR_RW; + n->arch.hcr_el2 |= HCR_RW; WRITE_SYSREG(n->arch.sctlr, SCTLR_EL1); isb(); - WRITE_SYSREG(hcr, HCR_EL2); + WRITE_SYSREG(n->arch.hcr_el2, HCR_EL2); isb(); last_vcpu_ran = &p2m->last_vcpu_ran[smp_processor_id()]; diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 09fe502..7b1dacc 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -204,6 +204,9 @@ struct arch_vcpu register_t tpidr_el1; register_t tpidrro_el0; + /* HYP configuration */ + register_t hcr_el2; + uint32_t teecr, teehbr; /* ThumbEE, 32-bit guests only */ #ifdef CONFIG_ARM_32 /* -- 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |