ia64/xen-unstable

changeset 6417:f7cdd99d1106

Fix MPT mapping for x86/64. Also i386 no longer needs
4MB mapping for PAE, as xenlinux can handle faults when
accessing unmapped sections of the table.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Aug 25 17:15:41 2005 +0000 (2005-08-25)
parents 98a6eb458c78
children b4b3f6be5226
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	Thu Aug 25 16:25:26 2005 +0000
     1.2 +++ b/xen/arch/x86/x86_32/mm.c	Thu Aug 25 17:15:41 2005 +0000
     1.3 @@ -93,15 +93,10 @@ void __init paging_init(void)
     1.4  
     1.5      /*
     1.6       * Allocate and map the machine-to-phys table and create read-only mapping 
     1.7 -     * of MPT for guest-OS use.  Without PAE we'll end up with one 4MB page, 
     1.8 -     * with PAE we'll allocate 2MB pages depending on the amount of memory 
     1.9 -     * installed, but at least 4MB to cover 4GB address space.  This is needed 
    1.10 -     * to make PCI I/O memory address lookups work in guests.
    1.11 +     * of MPT for guest-OS use.
    1.12       */
    1.13      mpt_size  = (max_page * 4) + (1UL << L2_PAGETABLE_SHIFT) - 1UL;
    1.14      mpt_size &= ~((1UL << L2_PAGETABLE_SHIFT) - 1UL);
    1.15 -    if ( mpt_size < (4 << 20) )
    1.16 -        mpt_size = 4 << 20;
    1.17      for ( i = 0; i < (mpt_size >> L2_PAGETABLE_SHIFT); i++ )
    1.18      {
    1.19          if ( (pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER, 0)) == NULL )
     2.1 --- a/xen/arch/x86/x86_64/mm.c	Thu Aug 25 16:25:26 2005 +0000
     2.2 +++ b/xen/arch/x86/x86_64/mm.c	Thu Aug 25 17:15:41 2005 +0000
     2.3 @@ -74,7 +74,7 @@ l2_pgentry_t *virt_to_xen_l2e(unsigned l
     2.4  
     2.5  void __init paging_init(void)
     2.6  {
     2.7 -    unsigned long i;
     2.8 +    unsigned long i, mpt_size;
     2.9      l3_pgentry_t *l3_ro_mpt;
    2.10      l2_pgentry_t *l2_ro_mpt;
    2.11      struct pfn_info *pg;
    2.12 @@ -98,16 +98,17 @@ void __init paging_init(void)
    2.13       * Allocate and map the machine-to-phys table.
    2.14       * This also ensures L3 is present for fixmaps.
    2.15       */
    2.16 -    for ( i = 0; i < max_page; i += ((1UL << L2_PAGETABLE_SHIFT) / 4) )
    2.17 +    mpt_size  = (max_page * 4) + (1UL << L2_PAGETABLE_SHIFT) - 1UL;
    2.18 +    mpt_size &= ~((1UL << L2_PAGETABLE_SHIFT) - 1UL);
    2.19 +    for ( i = 0; i < (mpt_size >> L2_PAGETABLE_SHIFT); i++ )
    2.20      {
    2.21 -        pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER, 0);
    2.22 -        if ( pg == NULL )
    2.23 +        if ( (pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER, 0)) == NULL )
    2.24              panic("Not enough memory for m2p table\n");
    2.25          map_pages_to_xen(
    2.26 -            RDWR_MPT_VIRT_START + i*8, page_to_pfn(pg), 
    2.27 +            RDWR_MPT_VIRT_START + (i << L2_PAGETABLE_SHIFT), page_to_pfn(pg), 
    2.28              1UL << PAGETABLE_ORDER,
    2.29              PAGE_HYPERVISOR);
    2.30 -        memset((void *)(RDWR_MPT_VIRT_START + i*8), 0x55,
    2.31 +        memset((void *)(RDWR_MPT_VIRT_START + (i << L2_PAGETABLE_SHIFT)), 0x55,
    2.32                 1UL << L2_PAGETABLE_SHIFT);
    2.33          *l2_ro_mpt++ = l2e_from_page(
    2.34              pg, _PAGE_GLOBAL|_PAGE_PSE|_PAGE_USER|_PAGE_PRESENT);