[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/3] x86/mm: Consolidate all Xen L2 slot writing into init_xen_pae_l2_slots()
Having all of this logic together makes it easier to follow Xen's virtual setup across the whole system. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Tim Deegan <tim@xxxxxxx> CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> CC: Julien Grall <julien.grall@xxxxxxx> --- xen/arch/x86/mm.c | 16 +++++++++------- xen/arch/x86/mm/shadow/multi.c | 42 +++++++++++++++--------------------------- xen/include/asm-x86/mm.h | 1 + 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index f90a42a..ea4af16 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1433,13 +1433,7 @@ static int alloc_l2_table(struct page_info *page, unsigned long type, } if ( rc >= 0 && (type & PGT_pae_xen_l2) ) - { - /* Xen private mappings. */ - memcpy(&pl2e[COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d)], - &compat_idle_pg_table_l2[ - l2_table_offset(HIRO_COMPAT_MPT_VIRT_START)], - COMPAT_L2_PAGETABLE_XEN_SLOTS(d) * sizeof(*pl2e)); - } + init_xen_pae_l2_slots(pl2e, d); unmap_domain_page(pl2e); return rc > 0 ? 0 : rc; @@ -1518,6 +1512,14 @@ static int alloc_l3_table(struct page_info *page) return rc > 0 ? 0 : rc; } +void init_xen_pae_l2_slots(l2_pgentry_t *l2t, const struct domain *d) +{ + memcpy(&l2t[COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d)], + &compat_idle_pg_table_l2[ + l2_table_offset(HIRO_COMPAT_MPT_VIRT_START)], + COMPAT_L2_PAGETABLE_XEN_SLOTS(d) * sizeof(*l2t)); +} + /* * This function must write all ROOT_PAGETABLE_PV_XEN_SLOTS, to clobber any * values a guest may have left there from alloc_l4_table(). diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index d540af1..1b76e0c 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -1521,31 +1521,6 @@ void sh_install_xen_entries_in_l4(struct domain *d, mfn_t gl4mfn, mfn_t sl4mfn) } #endif -#if GUEST_PAGING_LEVELS >= 3 -// For 3-on-3 PV guests, we need to make sure the xen mappings are in -// place, which means that we need to populate the l2h entry in the l3 -// table. - -static void sh_install_xen_entries_in_l2h(struct domain *d, mfn_t sl2hmfn) -{ - shadow_l2e_t *sl2e; - - if ( !is_pv_32bit_domain(d) ) - return; - - sl2e = map_domain_page(sl2hmfn); - BUILD_BUG_ON(sizeof (l2_pgentry_t) != sizeof (shadow_l2e_t)); - - /* Copy the common Xen mappings from the idle domain */ - memcpy( - &sl2e[COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d)], - &compat_idle_pg_table_l2[l2_table_offset(HIRO_COMPAT_MPT_VIRT_START)], - COMPAT_L2_PAGETABLE_XEN_SLOTS(d) * sizeof(*sl2e)); - - unmap_domain_page(sl2e); -} -#endif - /**************************************************************************/ /* Create a shadow of a given guest page. @@ -1610,7 +1585,14 @@ sh_make_shadow(struct vcpu *v, mfn_t gmfn, u32 shadow_type) #endif #if GUEST_PAGING_LEVELS >= 3 case SH_type_l2h_shadow: - sh_install_xen_entries_in_l2h(v->domain, smfn); + BUILD_BUG_ON(sizeof(l2_pgentry_t) != sizeof(shadow_l2e_t)); + if ( is_pv_32bit_domain(d) ) + { + shadow_l2e_t *l2t = map_domain_page(smfn); + + init_xen_pae_l2_slots(l2t, d); + unmap_domain_page(l2t); + } break; #endif default: /* Do nothing */ break; @@ -1677,6 +1659,8 @@ sh_make_monitor_table(struct vcpu *v) if ( is_pv_32bit_domain(d) ) { + l2_pgentry_t *l2t; + /* For 32-bit PV guests, we need to map the 32-bit Xen * area into its usual VAs in the monitor tables */ m3mfn = shadow_alloc(d, SH_type_monitor_table, 0); @@ -1687,7 +1671,11 @@ sh_make_monitor_table(struct vcpu *v) mfn_to_page(m2mfn)->shadow_flags = 2; l3e = map_domain_page(m3mfn); l3e[3] = l3e_from_mfn(m2mfn, _PAGE_PRESENT); - sh_install_xen_entries_in_l2h(d, m2mfn); + + l2t = map_domain_page(m2mfn); + init_xen_pae_l2_slots(l2t, d); + unmap_domain_page(l2t); + unmap_domain_page(l3e); } diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index eeac4d7..da3c5e2 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -340,6 +340,7 @@ static inline void *__page_to_virt(const struct page_info *pg) int free_page_type(struct page_info *page, unsigned long type, int preemptible); +void init_xen_pae_l2_slots(l2_pgentry_t *l2t, const struct domain *d); void init_guest_l4_table(l4_pgentry_t[], const struct domain *, bool_t zap_ro_mpt); bool fill_ro_mpt(mfn_t mfn); -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |