ia64/xen-unstable

changeset 15780:f279d776fcb0

x86: Fix paging_init() to not overwrite existing page-directory entry
for fixmap area.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Fri Aug 24 16:19:14 2007 +0100 (2007-08-24)
parents 1892f4a9822f
children 58d131f1fb35
files xen/arch/x86/x86_32/mm.c xen/arch/x86/x86_64/mm.c
line diff
     1.1 --- a/xen/arch/x86/x86_32/mm.c	Fri Aug 17 16:48:10 2007 +0100
     1.2 +++ b/xen/arch/x86/x86_32/mm.c	Fri Aug 24 16:19:14 2007 +0100
     1.3 @@ -68,7 +68,6 @@ l2_pgentry_t *virt_to_xen_l2e(unsigned l
     1.4  
     1.5  void __init paging_init(void)
     1.6  {
     1.7 -    void *ioremap_pt;
     1.8      unsigned long v;
     1.9      struct page_info *pg;
    1.10      int i;
    1.11 @@ -115,13 +114,17 @@ void __init paging_init(void)
    1.12      for ( i = 0; i < (mpt_size / BYTES_PER_LONG); i++)
    1.13          set_gpfn_from_mfn(i, 0x55555555);
    1.14  
    1.15 -    /* Create page tables for ioremap(). */
    1.16 +    /* Create page tables for ioremap()/map_domain_page_global(). */
    1.17      for ( i = 0; i < (IOREMAP_MBYTES >> (L2_PAGETABLE_SHIFT - 20)); i++ )
    1.18      {
    1.19 -        ioremap_pt = alloc_xenheap_page();
    1.20 -        clear_page(ioremap_pt);
    1.21 -        l2e_write(&idle_pg_table_l2[l2_linear_offset(IOREMAP_VIRT_START) + i],
    1.22 -                  l2e_from_page(virt_to_page(ioremap_pt), __PAGE_HYPERVISOR));
    1.23 +        void *p;
    1.24 +        l2_pgentry_t *pl2e;
    1.25 +        pl2e = &idle_pg_table_l2[l2_linear_offset(IOREMAP_VIRT_START) + i];
    1.26 +        if ( l2e_get_flags(*pl2e) & _PAGE_PRESENT )
    1.27 +            continue;
    1.28 +        p = alloc_xenheap_page();
    1.29 +        clear_page(p);
    1.30 +        l2e_write(pl2e, l2e_from_page(virt_to_page(p), __PAGE_HYPERVISOR));
    1.31      }
    1.32  }
    1.33  
     2.1 --- a/xen/arch/x86/x86_64/mm.c	Fri Aug 17 16:48:10 2007 +0100
     2.2 +++ b/xen/arch/x86/x86_64/mm.c	Fri Aug 24 16:19:14 2007 +0100
     2.3 @@ -100,15 +100,15 @@ void __init paging_init(void)
     2.4      unsigned long i, mpt_size, va;
     2.5      l3_pgentry_t *l3_ro_mpt;
     2.6      l2_pgentry_t *l2_ro_mpt = NULL;
     2.7 -    struct page_info *l1_pg, *l2_pg;
     2.8 +    struct page_info *l1_pg, *l2_pg, *l3_pg;
     2.9  
    2.10      /* Create user-accessible L2 directory to map the MPT for guests. */
    2.11 -    if ( (l2_pg = alloc_domheap_page(NULL)) == NULL )
    2.12 +    if ( (l3_pg = alloc_domheap_page(NULL)) == NULL )
    2.13          goto nomem;
    2.14 -    l3_ro_mpt = page_to_virt(l2_pg);
    2.15 +    l3_ro_mpt = page_to_virt(l3_pg);
    2.16      clear_page(l3_ro_mpt);
    2.17      l4e_write(&idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)],
    2.18 -              l4e_from_page(l2_pg, __PAGE_HYPERVISOR | _PAGE_USER));
    2.19 +              l4e_from_page(l3_pg, __PAGE_HYPERVISOR | _PAGE_USER));
    2.20  
    2.21      /*
    2.22       * Allocate and map the machine-to-phys table.