[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.4] xen/arm: Move p2m context save/restore in a separate function
commit 9ca83a4bd3bf8d21886bccdd7c4710b798eec326 Author: Julien Grall <julien.grall@xxxxxxxxxx> AuthorDate: Wed Mar 19 15:43:37 2014 +0000 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Thu Jun 5 13:14:55 2014 +0100 xen/arm: Move p2m context save/restore in a separate function Introduce p2m_{save,restore}_state to save/restore p2m context. The both functions will take care of: - VTTBR: contains the pointer to the domain P2M - Update HCR_RW if the domain is 64 bit - SCTLR: contains bit to know if the MMU is enabled or not Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx> Acked-by: Tim Deegan <tim@xxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> (cherry picked from commit 84ca4629d0aa71dc45c969f625d069373fb88828) [ ijc -- s/is_32bit_domain/is_pv32_domain ] --- xen/arch/arm/domain.c | 21 +++------------------ xen/arch/arm/p2m.c | 25 +++++++++++++++++++++++++ xen/include/asm-arm/p2m.h | 4 ++++ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index ba07846..c0c5af3 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -59,11 +59,12 @@ void idle_loop(void) static void ctxt_switch_from(struct vcpu *p) { + p2m_save_state(p); + /* CP 15 */ p->arch.csselr = READ_SYSREG(CSSELR_EL1); /* Control Registers */ - p->arch.sctlr = READ_SYSREG(SCTLR_EL1); p->arch.cpacr = READ_SYSREG(CPACR_EL1); p->arch.contextidr = READ_SYSREG(CONTEXTIDR_EL1); @@ -135,14 +136,7 @@ static void ctxt_switch_from(struct vcpu *p) static void ctxt_switch_to(struct vcpu *n) { - register_t hcr; - - hcr = READ_SYSREG(HCR_EL2); - WRITE_SYSREG(hcr & ~HCR_VM, HCR_EL2); - isb(); - - p2m_load_VTTBR(n->domain); - isb(); + p2m_restore_state(n); WRITE_SYSREG32(n->domain->arch.vpidr, VPIDR_EL2); WRITE_SYSREG(n->arch.vmpidr, VMPIDR_EL2); @@ -190,7 +184,6 @@ static void ctxt_switch_to(struct vcpu *n) isb(); /* Control Registers */ - WRITE_SYSREG(n->arch.sctlr, SCTLR_EL1); WRITE_SYSREG(n->arch.cpacr, CPACR_EL1); WRITE_SYSREG(n->arch.contextidr, CONTEXTIDR_EL1); @@ -215,14 +208,6 @@ static void ctxt_switch_to(struct vcpu *n) isb(); - if ( is_pv32_domain(n->domain) ) - hcr &= ~HCR_RW; - else - hcr |= HCR_RW; - - WRITE_SYSREG(hcr, HCR_EL2); - isb(); - /* This is could trigger an hardware interrupt from the virtual * timer. The interrupt needs to be injected into the guest. */ WRITE_SYSREG32(n->arch.cntkctl, CNTKCTL_EL1); diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 7fd5920..e068f74 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -44,6 +44,31 @@ void p2m_load_VTTBR(struct domain *d) isb(); /* Ensure update is visible */ } +void p2m_save_state(struct vcpu *p) +{ + p->arch.sctlr = READ_SYSREG(SCTLR_EL1); +} + +void p2m_restore_state(struct vcpu *n) +{ + register_t hcr; + + hcr = READ_SYSREG(HCR_EL2); + WRITE_SYSREG(hcr & ~HCR_VM, HCR_EL2); + isb(); + + p2m_load_VTTBR(n->domain); + isb(); + + if ( is_pv32_domain(n->domain) ) + hcr &= ~HCR_RW; + else + hcr |= HCR_RW; + + WRITE_SYSREG(hcr, HCR_EL2); + isb(); +} + static int p2m_first_level_index(paddr_t addr) { /* diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 3b39c45..e1013c8 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -75,6 +75,10 @@ int p2m_alloc_table(struct domain *d); /* */ void p2m_load_VTTBR(struct domain *d); +/* Context switch */ +void p2m_save_state(struct vcpu *p); +void p2m_restore_state(struct vcpu *n); + /* Look up the MFN corresponding to a domain's PFN. */ paddr_t p2m_lookup(struct domain *d, paddr_t gpfn, p2m_type_t *t); -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.4 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |