ia64/xen-unstable

changeset 85:c3e6a52cd801

bitkeeper revision 1.14 (3e20b83dPg-clJ56YPGnFMviq9LI1Q)

Many files:
Reduce Xen's memory footprint
domain_page.h:
new file
.del-fixmap.h~4336e0fb2759a2f1:
Delete: xenolinux-2.4.16-sparse/include/asm-xeno/fixmap.h
.del-bootmem.h~68c209d2dc07efd5:
Delete: xen-2.4.16/include/xeno/bootmem.h
author kaf24@labyrinth.cl.cam.ac.uk
date Sun Jan 12 00:35:09 2003 +0000 (2003-01-12)
parents af2f305e6020
children 4a10fe9b20ec 3b0238779bd5
files .rootkeys xen-2.4.16/arch/i386/Rules.mk xen-2.4.16/arch/i386/boot/boot.S xen-2.4.16/arch/i386/entry.S xen-2.4.16/arch/i386/ioremap.c xen-2.4.16/arch/i386/mm.c xen-2.4.16/arch/i386/setup.c xen-2.4.16/arch/i386/smpboot.c xen-2.4.16/arch/i386/traps.c xen-2.4.16/arch/i386/xeno.lds xen-2.4.16/common/domain.c xen-2.4.16/common/kernel.c xen-2.4.16/common/memory.c xen-2.4.16/include/asm-i386/domain_page.h xen-2.4.16/include/asm-i386/page.h xen-2.4.16/include/asm-i386/system.h xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h xen-2.4.16/include/xeno/bootmem.h xen-2.4.16/include/xeno/config.h xen-2.4.16/include/xeno/mm.h xen-2.4.16/include/xeno/sched.h xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c xenolinux-2.4.16-sparse/arch/xeno/kernel/time.c xenolinux-2.4.16-sparse/arch/xeno/mm/init.c xenolinux-2.4.16-sparse/include/asm-xeno/fixmap.h xenolinux-2.4.16-sparse/include/asm-xeno/highmem.h xenolinux-2.4.16-sparse/include/asm-xeno/pgalloc.h xenolinux-2.4.16-sparse/include/asm-xeno/pgtable.h xenolinux-2.4.16-sparse/include/asm-xeno/smp.h
line diff
     1.1 --- a/.rootkeys	Fri Jan 03 18:24:03 2003 +0000
     1.2 +++ b/.rootkeys	Sun Jan 12 00:35:09 2003 +0000
     1.3 @@ -131,6 +131,7 @@ 3ddb79c2ADvRmdexd9y3AYK9_NTx-Q xen-2.4.1
     1.4  3ddb79c2jFkPAZTDmU35L6IUssYMgQ xen-2.4.16/include/asm-i386/debugreg.h
     1.5  3ddb79c3r9-31dIsewPV3P3i8HALsQ xen-2.4.16/include/asm-i386/delay.h
     1.6  3ddb79c34BFiXjBJ_cCKB0aCsV1IDw xen-2.4.16/include/asm-i386/desc.h
     1.7 +3e20b82fl1jmQiKdLy7fxMcutfpjWA xen-2.4.16/include/asm-i386/domain_page.h
     1.8  3ddb79c2O729EttZTYu1c8LcsUO_GQ xen-2.4.16/include/asm-i386/elf.h
     1.9  3ddb79c3NU8Zy40OTrq3D-i30Y3t4A xen-2.4.16/include/asm-i386/fixmap.h
    1.10  3ddb79c39o75zPP0T1aQQ4mNrCAN2w xen-2.4.16/include/asm-i386/hardirq.h
    1.11 @@ -170,7 +171,6 @@ 3ddb79c0nTsjSpVK4ZVTI9WwN24xtQ xen-2.4.1
    1.12  3ddb79c0dVhTHLsv6CPTf4baKix4mA xen-2.4.16/include/xeno/blkdev.h
    1.13  3ddb79c18ePBgitnOs7GiOCFilODVw xen-2.4.16/include/xeno/blkpg.h
    1.14  3ddb79c2SisDOHDyTeK5-MV3m7pNbA xen-2.4.16/include/xeno/block.h
    1.15 -3ddb79c2JOriBs0mWh-Tlolq78tg3w xen-2.4.16/include/xeno/bootmem.h
    1.16  3ddb79c1oOjpQbp68MW7yiUpoi-S-w xen-2.4.16/include/xeno/brlock.h
    1.17  3ddb79c1x7Ie3kifu7dQRx8y7HVyvA xen-2.4.16/include/xeno/byteorder/big_endian.h
    1.18  3ddb79c1qFXOEX1eD0yXJ_gsGkUt8w xen-2.4.16/include/xeno/byteorder/generic.h
    1.19 @@ -312,7 +312,6 @@ 3ddb79b80Z4ZUIqbD1Xu_t4OCuEHeQ xenolinux
    1.20  3ddb79bac26NkKcPIEsfxETc5Snyag xenolinux-2.4.16-sparse/include/asm-xeno/elf.h
    1.21  3ddb79ba722pCJ_g_xI8ebsE31IK-Q xenolinux-2.4.16-sparse/include/asm-xeno/errno.h
    1.22  3ddb79b8vIpUpgaSNEneFkg5hYSvNg xenolinux-2.4.16-sparse/include/asm-xeno/fcntl.h
    1.23 -3ddb79b8c_oKu2_BGNJctM4DBET31Q xenolinux-2.4.16-sparse/include/asm-xeno/fixmap.h
    1.24  3ddb79b8780YvqvK1g5KPIWzQ6P15w xenolinux-2.4.16-sparse/include/asm-xeno/floppy.h
    1.25  3ddb79bas-nFywnmilbUeT34PEAA0g xenolinux-2.4.16-sparse/include/asm-xeno/hardirq.h
    1.26  3ddb79batzR40ZFY9dvgs5f1aM9I6g xenolinux-2.4.16-sparse/include/asm-xeno/hdreg.h
     2.1 --- a/xen-2.4.16/arch/i386/Rules.mk	Fri Jan 03 18:24:03 2003 +0000
     2.2 +++ b/xen-2.4.16/arch/i386/Rules.mk	Sun Jan 12 00:35:09 2003 +0000
     2.3 @@ -4,7 +4,7 @@
     2.4  CC := gcc
     2.5  LD := ld
     2.6  # Linker should relocate monitor to this address
     2.7 -MONITOR_BASE := 0xE0100000
     2.8 +MONITOR_BASE := 0xFC100000
     2.9  # Bootloader should load monitor to this real address
    2.10  LOAD_BASE    := 0x00100000
    2.11  CFLAGS  := -fno-builtin -O3 -Wall -DMONITOR_BASE=$(MONITOR_BASE) 
     3.1 --- a/xen-2.4.16/arch/i386/boot/boot.S	Fri Jan 03 18:24:03 2003 +0000
     3.2 +++ b/xen-2.4.16/arch/i386/boot/boot.S	Sun Jan 12 00:35:09 2003 +0000
     3.3 @@ -91,7 +91,7 @@ continue_boot_cpu:
     3.4  1:      mov     %eax,__PAGE_OFFSET>>20(%edi) /* high mapping */
     3.5          stosl                                /* low mapping */
     3.6          add     $(1<<L2_PAGETABLE_SHIFT),%eax
     3.7 -        cmp     $MAX_USABLE_ADDRESS+0x1e3,%eax
     3.8 +        cmp     $MAX_DIRECTMAP_ADDRESS+0x1e3,%eax
     3.9          jne     1b
    3.10  
    3.11          call    start_paging        
    3.12 @@ -219,12 +219,12 @@ nopaging_gdt_descr:
    3.13  ENTRY(gdt_table)
    3.14          .quad 0x0000000000000000     /* NULL descriptor */
    3.15          .quad 0x0000000000000000     /* not used */
    3.16 -        .quad 0x00cdba000000ffff     /* 0x11 ring 1 3.5GB code at 0x00000000 */
    3.17 -        .quad 0x00cdb2000000ffff     /* 0x19 ring 1 3.5GB data at 0x00000000 */
    3.18 -        .quad 0x00cdfa000000ffff     /* 0x23 ring 3 3.5GB code at 0x00000000 */
    3.19 -        .quad 0x00cdf2000000ffff     /* 0x2b ring 3 3.5GB data at 0x00000000 */
    3.20 -        .quad 0x00cf9a000000ffff     /* 0x30 ring 0 4.0GB code at 0x00000000 */
    3.21 -        .quad 0x00cf92000000ffff     /* 0x38 ring 0 4.0GB data at 0x00000000 */
    3.22 +        .quad 0x00cfba000000bfff     /* 0x11 ring 1 3.95GB code at 0x0 */
    3.23 +        .quad 0x00cfb2000000bfff     /* 0x19 ring 1 3.95GB data at 0x0 */
    3.24 +        .quad 0x00cffa000000bfff     /* 0x23 ring 3 3.95GB code at 0x0 */
    3.25 +        .quad 0x00cff2000000bfff     /* 0x2b ring 3 3.95GB data at 0x0 */
    3.26 +        .quad 0x00cf9a000000ffff     /* 0x30 ring 0 4.00GB code at 0x0 */
    3.27 +        .quad 0x00cf92000000ffff     /* 0x38 ring 0 4.00GB data at 0x0 */
    3.28          .quad 0x0000000000000000
    3.29          .quad 0x0000000000000000
    3.30          .quad 0x0000000000000000
     4.1 --- a/xen-2.4.16/arch/i386/entry.S	Fri Jan 03 18:24:03 2003 +0000
     4.2 +++ b/xen-2.4.16/arch/i386/entry.S	Sun Jan 12 00:35:09 2003 +0000
     4.3 @@ -254,9 +254,9 @@ failsafe_callback:
     4.4          call create_bounce_frame
     4.5          subl $8,%esi                 # add DS/ES to failsafe stack frame
     4.6          movl DS(%esp),%eax
     4.7 -FAULT3: movl %eax,(%esi) 
     4.8 +FAULT1: movl %eax,(%esi) 
     4.9          movl ES(%esp),%eax
    4.10 -FAULT4: movl %eax,4(%esi)
    4.11 +FAULT2: movl %eax,4(%esi)
    4.12          movl %esi,OLDESP(%esp)
    4.13          popl %ebx
    4.14          popl %ecx
    4.15 @@ -266,7 +266,7 @@ FAULT4: movl %eax,4(%esi)
    4.16          popl %ebp
    4.17          popl %eax
    4.18          addl $12,%esp
    4.19 -FAULT5: iret 
    4.20 +FAULT3: iret 
    4.21  
    4.22          
    4.23  /* CREATE A BASIC EXCEPTION FRAME ON GUEST OS (RING-1) STACK:         */
    4.24 @@ -282,25 +282,25 @@ create_bounce_frame:
    4.25          shll $8,%eax /* multiply by 256 */
    4.26          addl $init_tss + 12,%eax
    4.27          movl (%eax),%esi /* tss->esp1 */
    4.28 -FAULT6: movl 4(%eax),%ds /* tss->ss1  */
    4.29 +FAULT4: movl 4(%eax),%ds /* tss->ss1  */
    4.30          /* base of stack frame must contain ss/esp (inter-priv iret) */
    4.31          subl $8,%esi
    4.32          movl OLDESP+4(%esp),%eax
    4.33 -FAULT7: movl %eax,(%esi) 
    4.34 +FAULT5: movl %eax,(%esi) 
    4.35          movl OLDSS+4(%esp),%eax
    4.36 -FAULT8: movl %eax,4(%esi) 
    4.37 +FAULT6: movl %eax,4(%esi) 
    4.38          jmp 2f
    4.39  1:      /* obtain ss/esp from oldss/oldesp -- a ring-1 activation exists */
    4.40          movl OLDESP+4(%esp),%esi
    4.41 -FAULT9: movl OLDSS+4(%esp),%ds 
    4.42 +FAULT7: movl OLDSS+4(%esp),%ds 
    4.43  2:      /* Construct a stack frame: EFLAGS, CS/EIP */
    4.44          subl $12,%esi
    4.45          movl EIP+4(%esp),%eax
    4.46 -FAULT10:movl %eax,(%esi) 
    4.47 +FAULT8: movl %eax,(%esi) 
    4.48          movl CS+4(%esp),%eax
    4.49 -FAULT11:movl %eax,4(%esi) 
    4.50 +FAULT9: movl %eax,4(%esi) 
    4.51          movl EFLAGS+4(%esp),%eax
    4.52 -FAULT12:movl %eax,8(%esi)
    4.53 +FAULT10:movl %eax,8(%esi)
    4.54          /* Rewrite our stack frame and return to ring 1. */
    4.55          /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. */
    4.56          andl $0xfffcbeff,%eax
    4.57 @@ -318,16 +318,16 @@ FAULT12:movl %eax,8(%esi)
    4.58          .align 4
    4.59          .long FAULT1, kill_domain_fixup3 # Fault writing to ring-1 stack
    4.60          .long FAULT2, kill_domain_fixup3 # Fault writing to ring-1 stack
    4.61 -        .long FAULT3, kill_domain_fixup3 # Fault writing to ring-1 stack
    4.62 -        .long FAULT4, kill_domain_fixup3 # Fault writing to ring-1 stack
    4.63 -        .long FAULT5, kill_domain_fixup1 # Fault executing failsafe iret
    4.64 -        .long FAULT6, kill_domain_fixup2 # Fault loading ring-1 stack selector
    4.65 -        .long FAULT7, kill_domain_fixup2 # Fault writing to ring-1 stack
    4.66 +        .long FAULT3, kill_domain_fixup1 # Fault executing failsafe iret
    4.67 +        .long FAULT4, kill_domain_fixup2 # Fault loading ring-1 stack selector
    4.68 +        .long FAULT5, kill_domain_fixup2 # Fault writing to ring-1 stack
    4.69 +        .long FAULT6, kill_domain_fixup2 # Fault writing to ring-1 stack
    4.70 +        .long FAULT7, kill_domain_fixup2 # Fault loading ring-1 stack selector
    4.71          .long FAULT8, kill_domain_fixup2 # Fault writing to ring-1 stack
    4.72 -        .long FAULT9, kill_domain_fixup2 # Fault loading ring-1 stack selector
    4.73 +        .long FAULT9, kill_domain_fixup2 # Fault writing to ring-1 stack
    4.74          .long FAULT10,kill_domain_fixup2 # Fault writing to ring-1 stack
    4.75 -        .long FAULT11,kill_domain_fixup2 # Fault writing to ring-1 stack
    4.76 -        .long FAULT12,kill_domain_fixup2 # Fault writing to ring-1 stack
    4.77 +        .long FAULT11,kill_domain_fixup3 # Fault writing to ring-1 stack
    4.78 +        .long FAULT12,kill_domain_fixup3 # Fault writing to ring-1 stack
    4.79  .previous
    4.80                 
    4.81  # This handler kills domains which experience unrecoverable faults.
    4.82 @@ -357,12 +357,12 @@ process_guest_exception_and_events:
    4.83          jnz  2f
    4.84          subl $4,%esi                    # push error_code onto guest frame
    4.85          movl %es:GTB_ERROR_CODE(%edx),%eax
    4.86 -FAULT1: movl %eax,(%esi)
    4.87 +FAULT11:movl %eax,(%esi)
    4.88          test $GTBF_TRAP_CR2,%cl
    4.89          jz   1f
    4.90          subl $4,%esi                    # push %cr2 onto guest frame
    4.91          movl %es:GTB_CR2(%edx),%eax
    4.92 -FAULT2: movl %eax,(%esi)
    4.93 +FAULT12:movl %eax,(%esi)
    4.94  1:      movl %esi,OLDESP(%esp)        
    4.95  2:      push %es                        # unclobber %ds
    4.96          pop  %ds 
     5.1 --- a/xen-2.4.16/arch/i386/ioremap.c	Fri Jan 03 18:24:03 2003 +0000
     5.2 +++ b/xen-2.4.16/arch/i386/ioremap.c	Sun Jan 12 00:35:09 2003 +0000
     5.3 @@ -28,6 +28,7 @@ static void new_l2e(l2_pgentry_t *pl2e)
     5.4      *pl2e = mk_l2_pgentry(__pa(pl1e)|L2_PROT);
     5.5  }
     5.6  
     5.7 +
     5.8  void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
     5.9  {
    5.10      unsigned long vaddr;
    5.11 @@ -35,9 +36,8 @@ void * __ioremap(unsigned long phys_addr
    5.12      l2_pgentry_t *pl2e;
    5.13      l1_pgentry_t *pl1e;
    5.14  
    5.15 -    /* First time through, start allocating from end of real memory. */
    5.16 -    if ( !remap_base ) 
    5.17 -        remap_base = (unsigned long)phys_to_virt(MAX_USABLE_ADDRESS);
    5.18 +    /* First time through, start allocating from far end of virtual memory. */
    5.19 +    if ( !remap_base ) remap_base = IOREMAP_VIRT_START;
    5.20  
    5.21      /* Don't allow wraparound or zero size */
    5.22      last_addr = phys_addr + size - 1;
     6.1 --- a/xen-2.4.16/arch/i386/mm.c	Fri Jan 03 18:24:03 2003 +0000
     6.2 +++ b/xen-2.4.16/arch/i386/mm.c	Sun Jan 12 00:35:09 2003 +0000
     6.3 @@ -56,6 +56,7 @@ static void __init fixrange_init (unsign
     6.4  void __init paging_init(void)
     6.5  {
     6.6      unsigned long addr;
     6.7 +    void *ioremap_pt;
     6.8  
     6.9      /* XXX initialised in boot.S */
    6.10      /*if ( cpu_has_pge ) set_in_cr4(X86_CR4_PGE);*/
    6.11 @@ -68,13 +69,24 @@ void __init paging_init(void)
    6.12       */
    6.13      addr = FIXADDR_START & ~((1<<L2_PAGETABLE_SHIFT)-1);
    6.14      fixrange_init(addr, 0, idle0_pg_table);
    6.15 +
    6.16 +    /* Create page table for ioremap(). */
    6.17 +    ioremap_pt = (void *)get_free_page(GFP_KERNEL);
    6.18 +    clear_page(ioremap_pt);
    6.19 +    idle0_pg_table[MAPCACHE_VIRT_START >> L2_PAGETABLE_SHIFT] = 
    6.20 +        mk_l2_pgentry(__pa(ioremap_pt) | PAGE_HYPERVISOR);
    6.21  }
    6.22  
    6.23  void __init zap_low_mappings (void)
    6.24  {
    6.25 -    int i;
    6.26 -    for (i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ )
    6.27 -        idle0_pg_table[i] = mk_l2_pgentry(0);
    6.28 +    int i, j;
    6.29 +    for ( i = 0; i < smp_num_cpus; i++ )
    6.30 +    {
    6.31 +        for ( j = 0; j < DOMAIN_ENTRIES_PER_L2_PAGETABLE; j++ )
    6.32 +        {
    6.33 +            idle_pg_table[i][j] = mk_l2_pgentry(0);
    6.34 +        }
    6.35 +    }
    6.36      flush_tlb_all();
    6.37  }
    6.38  
     7.1 --- a/xen-2.4.16/arch/i386/setup.c	Fri Jan 03 18:24:03 2003 +0000
     7.2 +++ b/xen-2.4.16/arch/i386/setup.c	Sun Jan 12 00:35:09 2003 +0000
     7.3 @@ -4,7 +4,6 @@
     7.4  #include <xeno/interrupt.h>
     7.5  #include <xeno/lib.h>
     7.6  #include <xeno/sched.h>
     7.7 -#include <xeno/bootmem.h>
     7.8  #include <xeno/pci.h>
     7.9  #include <asm/bitops.h>
    7.10  #include <asm/smp.h>
    7.11 @@ -12,12 +11,19 @@
    7.12  #include <asm/mpspec.h>
    7.13  #include <asm/apic.h>
    7.14  #include <asm/desc.h>
    7.15 +#include <asm/domain_page.h>
    7.16  
    7.17  struct cpuinfo_x86 boot_cpu_data = { 0 };
    7.18  /* Lots of nice things, since we only target PPro+. */
    7.19  unsigned long mmu_cr4_features = X86_CR4_PSE | X86_CR4_PGE;
    7.20  unsigned long wait_init_idle;
    7.21  
    7.22 +/* Basic page table for each CPU in the system. */
    7.23 +l2_pgentry_t *idle_pg_table[NR_CPUS] = { idle0_pg_table };
    7.24 +
    7.25 +/* for asm/domain_page.h, map_domain_page() */
    7.26 +unsigned long *mapcache[NR_CPUS];
    7.27 +
    7.28  /* Standard macro to see if a specific flag is changeable */
    7.29  static inline int flag_is_changeable_p(u32 flag)
    7.30  {
    7.31 @@ -182,7 +188,8 @@ void __init cpu_init(void)
    7.32  {
    7.33      int nr = smp_processor_id();
    7.34      struct tss_struct * t = &init_tss[nr];
    7.35 -    
    7.36 +    l2_pgentry_t *pl2e;
    7.37 +
    7.38      if ( test_and_set_bit(nr, &cpu_initialized) )
    7.39          panic("CPU#%d already initialized!!!\n", nr);
    7.40      printk("Initializing CPU#%d\n", nr);
    7.41 @@ -208,6 +215,16 @@ void __init cpu_init(void)
    7.42      CD(0); CD(1); CD(2); CD(3); /* no db4 and db5 */; CD(6); CD(7);
    7.43  #undef CD
    7.44  
    7.45 +    /* Install correct page table. */
    7.46 +    __asm__ __volatile__ ("movl %%eax,%%cr3"
    7.47 +                          : : "a" (pagetable_val(current->mm.pagetable)));
    7.48 +
    7.49 +    /* Set up mapping cache for domain pages. */
    7.50 +    pl2e = idle_pg_table[nr] + (MAPCACHE_VIRT_START >> L2_PAGETABLE_SHIFT);
    7.51 +    mapcache[nr] = (unsigned long *)get_free_page(GFP_KERNEL);
    7.52 +    clear_page(mapcache[nr]);
    7.53 +    *pl2e = mk_l2_pgentry(__pa(mapcache[nr]) | PAGE_HYPERVISOR);
    7.54 +
    7.55      /* Stick the idle task on the run queue. */
    7.56      (void)wake_up(current);
    7.57  }
    7.58 @@ -283,12 +300,7 @@ void __init start_of_day(void)
    7.59      paging_init();                /* not much here now, but sets up fixmap */
    7.60      if ( smp_found_config ) get_smp_config();
    7.61      domain_init();
    7.62 -    trap_init(); /*
    7.63 -                  * installs trap (s/w exception) wrappers.
    7.64 -                  * Most route via entry.S and thence back into traps.c
    7.65 -                  * where a really simple handler does a panic.
    7.66 -                  * Instead, we'll want to pass most back to a domain.
    7.67 -                  */
    7.68 +    trap_init();
    7.69      init_IRQ();  /* installs simple interrupt wrappers. Starts HZ clock. */
    7.70      time_init(); /* installs software handler for HZ clock. */
    7.71      softirq_init();
     8.1 --- a/xen-2.4.16/arch/i386/smpboot.c	Fri Jan 03 18:24:03 2003 +0000
     8.2 +++ b/xen-2.4.16/arch/i386/smpboot.c	Sun Jan 12 00:35:09 2003 +0000
     8.3 @@ -664,6 +664,7 @@ static void __init do_boot_cpu (int apic
     8.4      unsigned long boot_error = 0;
     8.5      int timeout, cpu;
     8.6      unsigned long start_eip;
     8.7 +    l2_pgentry_t *pagetable;
     8.8  
     8.9      cpu = ++cpucount;
    8.10      /*
    8.11 @@ -674,7 +675,10 @@ static void __init do_boot_cpu (int apic
    8.12   
    8.13      idle->processor    = cpu;
    8.14      idle->domain       = IDLE_DOMAIN_ID;
    8.15 -    idle->mm.pagetable = mk_pagetable((unsigned long)idle0_pg_table);
    8.16 +    pagetable = (void *)get_free_page(GFP_KERNEL);
    8.17 +    memcpy(pagetable, idle0_pg_table, PAGE_SIZE);
    8.18 +    idle_pg_table[cpu] = pagetable;
    8.19 +    idle->mm.pagetable = mk_pagetable(__pa(pagetable));
    8.20  
    8.21      map_cpu_to_boot_apicid(cpu, apicid);
    8.22  
     9.1 --- a/xen-2.4.16/arch/i386/traps.c	Fri Jan 03 18:24:03 2003 +0000
     9.2 +++ b/xen-2.4.16/arch/i386/traps.c	Sun Jan 12 00:35:09 2003 +0000
     9.3 @@ -210,12 +210,12 @@ static void inline do_trap(int trapnr, c
     9.4  
     9.5      __asm__ __volatile__ ("movl %%cr2,%0" : "=r" (addr) : );
     9.6  
     9.7 -    if ( trapnr == 14 )
     9.8 +    if ( (trapnr == 14) && (addr >= PAGE_OFFSET) )
     9.9      {
    9.10          unsigned long page;
    9.11 -        __asm__ __volatile__ ("movl %%cr3,%0" : "=r" (page) : );
    9.12 -        printk(" pde = %08lx\n", page);
    9.13 -        page = ((unsigned long *) __va(page))[addr >> 22];
    9.14 +        unsigned long *pde;
    9.15 +        pde = (unsigned long *)idle_pg_table[smp_processor_id()];
    9.16 +        page = pde[addr >> L2_PAGETABLE_SHIFT];
    9.17          printk("*pde = %08lx\n", page);
    9.18          if ( page & _PAGE_PRESENT )
    9.19          {
    10.1 --- a/xen-2.4.16/arch/i386/xeno.lds	Fri Jan 03 18:24:03 2003 +0000
    10.2 +++ b/xen-2.4.16/arch/i386/xeno.lds	Sun Jan 12 00:35:09 2003 +0000
    10.3 @@ -6,7 +6,7 @@ OUTPUT_ARCH(i386)
    10.4  ENTRY(start)
    10.5  SECTIONS
    10.6  {
    10.7 -  . = 0xE0000000 + 0x100000;
    10.8 +  . = 0xFC000000 + 0x100000;
    10.9    _text = .;			/* Text and read-only data */
   10.10    .text : {
   10.11  	*(.text)
    11.1 --- a/xen-2.4.16/common/domain.c	Fri Jan 03 18:24:03 2003 +0000
    11.2 +++ b/xen-2.4.16/common/domain.c	Sun Jan 12 00:35:09 2003 +0000
    11.3 @@ -10,6 +10,7 @@
    11.4  #include <xeno/event.h>
    11.5  #include <xeno/dom0_ops.h>
    11.6  #include <asm/io.h>
    11.7 +#include <asm/domain_page.h>
    11.8  
    11.9  rwlock_t tasklist_lock __cacheline_aligned = RW_LOCK_UNLOCKED;
   11.10  
   11.11 @@ -324,7 +325,6 @@ asmlinkage void schedule(void)
   11.12  
   11.13  static unsigned int alloc_new_dom_mem(struct task_struct *p, unsigned int kbytes)
   11.14  {
   11.15 -
   11.16      struct list_head *temp;
   11.17      struct pfn_info *pf, *pf_head;
   11.18      unsigned int alloc_pfns;
   11.19 @@ -394,11 +394,10 @@ int setup_guestos(struct task_struct *p,
   11.20  {
   11.21  #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED)
   11.22  #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED|_PAGE_DIRTY)
   11.23 -#define ALLOC_PAGE_FROM_DOMAIN() \
   11.24 -  ({ alloc_address -= PAGE_SIZE; __va(alloc_address); })
   11.25 +#define ALLOC_FRAME_FROM_DOMAIN() (alloc_address -= PAGE_SIZE)
   11.26      char *src, *dst;
   11.27      int i, dom = p->domain;
   11.28 -    unsigned long start_address = MAX_MONITOR_ADDRESS;
   11.29 +    unsigned long start_address, phys_l1tab, phys_l2tab;
   11.30      unsigned long cur_address, end_address, alloc_address, vaddr;
   11.31      unsigned long virt_load_address, virt_stack_address, virt_shinfo_address;
   11.32      unsigned long virt_ftable_start_addr = 0, virt_ftable_end_addr;
   11.33 @@ -410,7 +409,6 @@ int setup_guestos(struct task_struct *p,
   11.34      l1_pgentry_t *l1tab = NULL;
   11.35      struct pfn_info *page = NULL;
   11.36      net_ring_t *net_ring;
   11.37 -    blk_ring_t *blk_ring;
   11.38      net_vif_t *net_vif;
   11.39  
   11.40      if ( strncmp(__va(mod[0].mod_start), "XenoGues", 8) )
   11.41 @@ -447,7 +445,7 @@ int setup_guestos(struct task_struct *p,
   11.42                 dom, (mod[nr_mods-1].mod_end-mod[0].mod_start)>>20,
   11.43                 (end_address-start_address)>>21,
   11.44                 (end_address-start_address)>>20);
   11.45 -        /* XXX Should release memory from alloc_new_dom_mem here XXX */
   11.46 +        /* XXX should free domain memory here XXX */
   11.47          return -1;
   11.48      }
   11.49  
   11.50 @@ -457,10 +455,15 @@ int setup_guestos(struct task_struct *p,
   11.51      printk("DOM%d: Guest OS virtual load address is %08lx\n", dom,
   11.52             virt_load_address);
   11.53      
   11.54 -    l2tab = (l2_pgentry_t *)ALLOC_PAGE_FROM_DOMAIN();
   11.55 -    memcpy(l2tab, idle0_pg_table, sizeof(idle0_pg_table));
   11.56 +    /*
   11.57 +     * WARNING: The new domain must have its 'processor' field
   11.58 +     * filled in by now !!
   11.59 +     */
   11.60 +    phys_l2tab = ALLOC_FRAME_FROM_DOMAIN();
   11.61 +    l2tab = map_domain_mem(phys_l2tab);
   11.62 +    memcpy(l2tab, idle_pg_table[p->processor], PAGE_SIZE);
   11.63      memset(l2tab, 0, DOMAIN_ENTRIES_PER_L2_PAGETABLE*sizeof(l2_pgentry_t));
   11.64 -    p->mm.pagetable = mk_pagetable((unsigned long)l2tab);
   11.65 +    p->mm.pagetable = mk_pagetable(phys_l2tab);
   11.66  
   11.67      /*
   11.68       * NB. The upper limit on this loop does one extra page. This is to
   11.69 @@ -476,19 +479,21 @@ int setup_guestos(struct task_struct *p,
   11.70      if(dom == 0)
   11.71          ft_size = frame_table_size; 
   11.72  
   11.73 -    l2tab = pagetable_ptr(p->mm.pagetable) +
   11.74 -        l2_table_offset(virt_load_address);    
   11.75 +    phys_l2tab += l2_table_offset(virt_load_address)*sizeof(l2_pgentry_t);    
   11.76      for ( cur_address  = start_address;
   11.77            cur_address != (end_address + PAGE_SIZE + ft_size);
   11.78            cur_address += PAGE_SIZE )
   11.79      {
   11.80          if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) )
   11.81          {
   11.82 -            l1tab = (l1_pgentry_t *)ALLOC_PAGE_FROM_DOMAIN();
   11.83 +            phys_l1tab = ALLOC_FRAME_FROM_DOMAIN();
   11.84 +            l2tab = map_domain_mem(phys_l2tab);
   11.85 +            *l2tab = mk_l2_pgentry(phys_l1tab|L2_PROT);
   11.86 +            phys_l2tab += sizeof(l2_pgentry_t);
   11.87 +            l1tab = map_domain_mem(phys_l1tab);
   11.88              clear_page(l1tab);
   11.89              l1tab += l1_table_offset(
   11.90                  virt_load_address + cur_address - start_address);
   11.91 -            *l2tab++ = mk_l2_pgentry(__pa(l1tab)|L2_PROT);
   11.92          }
   11.93          *l1tab++ = mk_l1_pgentry(cur_address|L1_PROT);
   11.94          
   11.95 @@ -503,15 +508,25 @@ int setup_guestos(struct task_struct *p,
   11.96      
   11.97      /* Pages that are part of page tables must be read-only. */
   11.98      vaddr = virt_load_address + alloc_address - start_address;
   11.99 -    l2tab = pagetable_ptr(p->mm.pagetable) + l2_table_offset(vaddr);
  11.100 -    l1tab = l2_pgentry_to_l1(*l2tab++) + l1_table_offset(vaddr);
  11.101 +    phys_l2tab = pagetable_val(p->mm.pagetable) +
  11.102 +        (l2_table_offset(vaddr) * sizeof(l2_pgentry_t));
  11.103 +    l2tab = map_domain_mem(phys_l2tab);
  11.104 +    phys_l1tab = l2_pgentry_to_phys(*l2tab) +
  11.105 +        (l1_table_offset(vaddr) * sizeof(l1_pgentry_t));
  11.106 +    phys_l2tab += sizeof(l2_pgentry_t);
  11.107 +    l1tab = map_domain_mem(phys_l1tab);
  11.108      for ( cur_address  = alloc_address;
  11.109            cur_address != end_address;
  11.110            cur_address += PAGE_SIZE )
  11.111      {
  11.112          *l1tab++ = mk_l1_pgentry(l1_pgentry_val(*l1tab) & ~_PAGE_RW);
  11.113          if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) )
  11.114 -            l1tab = l2_pgentry_to_l1(*l2tab++);
  11.115 +        {
  11.116 +            l2tab = map_domain_mem(phys_l2tab);
  11.117 +            phys_l1tab = l2_pgentry_to_phys(*l2tab);
  11.118 +            phys_l2tab += sizeof(l2_pgentry_t);
  11.119 +            l1tab = map_domain_mem(phys_l1tab);
  11.120 +        }
  11.121          page = frame_table + (cur_address >> PAGE_SHIFT);
  11.122          page->flags = dom | PGT_l1_page_table;
  11.123          page->tot_count++;
  11.124 @@ -520,10 +535,12 @@ int setup_guestos(struct task_struct *p,
  11.125  
  11.126      /* Map in the the shared info structure. */
  11.127      virt_shinfo_address = end_address - start_address + virt_load_address;
  11.128 -    l2tab = pagetable_ptr(p->mm.pagetable) +
  11.129 -        l2_table_offset(virt_shinfo_address);
  11.130 -    l1tab = l2_pgentry_to_l1(*l2tab) +
  11.131 -        l1_table_offset(virt_shinfo_address);
  11.132 +    phys_l2tab = pagetable_val(p->mm.pagetable) +
  11.133 +        (l2_table_offset(virt_shinfo_address) * sizeof(l2_pgentry_t));
  11.134 +    l2tab = map_domain_mem(phys_l2tab);
  11.135 +    phys_l1tab = l2_pgentry_to_phys(*l2tab) +
  11.136 +        (l1_table_offset(virt_shinfo_address) * sizeof(l1_pgentry_t));
  11.137 +    l1tab = map_domain_mem(phys_l1tab);
  11.138      *l1tab = mk_l1_pgentry(__pa(p->shared_info)|L1_PROT);
  11.139  
  11.140      /* Set up shared info area. */
  11.141 @@ -541,8 +558,12 @@ int setup_guestos(struct task_struct *p,
  11.142              cur_address < virt_ftable_end_addr;
  11.143              cur_address += PAGE_SIZE)
  11.144          {
  11.145 -            l2tab = pagetable_ptr(p->mm.pagetable) + l2_table_offset(cur_address);
  11.146 -            l1tab = l2_pgentry_to_l1(*l2tab) + l1_table_offset(cur_address); 
  11.147 +            phys_l2tab = pagetable_val(p->mm.pagetable) +
  11.148 +                (l2_table_offset(cur_address) * sizeof(l2_pgentry_t));
  11.149 +            l2tab = map_domain_mem(phys_l2tab);
  11.150 +            phys_l1tab = l2_pgentry_to_phys(*l2tab) + 
  11.151 +                (l1_table_offset(cur_address) * sizeof(l1_pgentry_t)); 
  11.152 +            l1tab = map_domain_mem(phys_l1tab);
  11.153              *l1tab = mk_l1_pgentry(__pa(ft_mapping)|L1_PROT);
  11.154              ft_mapping += PAGE_SIZE;
  11.155          }
  11.156 @@ -555,8 +576,7 @@ int setup_guestos(struct task_struct *p,
  11.157      /* Install the new page tables. */
  11.158      __cli();
  11.159      __asm__ __volatile__ (
  11.160 -        "mov %%eax,%%cr3"
  11.161 -        : : "a" (__pa(pagetable_ptr(p->mm.pagetable))));
  11.162 +        "mov %%eax,%%cr3" : : "a" (pagetable_val(p->mm.pagetable)));
  11.163  
  11.164      /* Copy the guest OS image. */
  11.165      src = (char *)__va(mod[0].mod_start + 12);
  11.166 @@ -632,8 +652,7 @@ int setup_guestos(struct task_struct *p,
  11.167  
  11.168      /* Reinstate the caller's page tables. */
  11.169      __asm__ __volatile__ (
  11.170 -        "mov %%eax,%%cr3"
  11.171 -        : : "a" (__pa(pagetable_ptr(current->mm.pagetable))));    
  11.172 +        "mov %%eax,%%cr3" : : "a" (pagetable_val(current->mm.pagetable)));    
  11.173      __sti();
  11.174  
  11.175      new_thread(p, 
    12.1 --- a/xen-2.4.16/common/kernel.c	Fri Jan 03 18:24:03 2003 +0000
    12.2 +++ b/xen-2.4.16/common/kernel.c	Sun Jan 12 00:35:09 2003 +0000
    12.3 @@ -62,7 +62,7 @@ void cmain (unsigned long magic, multibo
    12.4  {
    12.5      struct task_struct *new_dom;
    12.6      dom0_newdomain_t dom0_params;
    12.7 -    unsigned long max_page, remaining_hypervisor_memory;
    12.8 +    unsigned long max_page;
    12.9      unsigned char *cmdline;
   12.10      int i;
   12.11  
   12.12 @@ -155,15 +155,11 @@ void cmain (unsigned long magic, multibo
   12.13      memcpy(&idle0_task_union, &first_task_struct, sizeof(first_task_struct));
   12.14  
   12.15      max_page = (mbi->mem_upper+1024) >> (PAGE_SHIFT - 10);
   12.16 -    if ( max_page > (MAX_USABLE_ADDRESS >> PAGE_SHIFT) )
   12.17 -        max_page = MAX_USABLE_ADDRESS >> PAGE_SHIFT;
   12.18 -    /* mem_upper is address of first memory hole in high memory, minus 1MB. */
   12.19 -    /* PS. mem_upper is in kB. */
   12.20 -    remaining_hypervisor_memory = init_frametable(max_page);
   12.21 -    printk("Initialised %luMB of memory on a %luMB machine\n",
   12.22 -           max_page >> (20-PAGE_SHIFT), (mbi->mem_upper>>10)+1);
   12.23 +    init_frametable(max_page);
   12.24 +    printk("Initialised all memory on a %luMB machine\n",
   12.25 +           max_page >> (20-PAGE_SHIFT));
   12.26  
   12.27 -    init_page_allocator(mod[nr_mods-1].mod_end, remaining_hypervisor_memory);
   12.28 +    init_page_allocator(mod[nr_mods-1].mod_end, MAX_MONITOR_ADDRESS);
   12.29   
   12.30      /* These things will get done by do_newdomain() for all other tasks. */
   12.31      current->shared_info = (void *)get_free_page(GFP_KERNEL);
    13.1 --- a/xen-2.4.16/common/memory.c	Fri Jan 03 18:24:03 2003 +0000
    13.2 +++ b/xen-2.4.16/common/memory.c	Sun Jan 12 00:35:09 2003 +0000
    13.3 @@ -173,6 +173,7 @@
    13.4  #include <asm/page.h>
    13.5  #include <asm/io.h>
    13.6  #include <asm/uaccess.h>
    13.7 +#include <asm/domain_page.h>
    13.8  
    13.9  #if 0
   13.10  #define MEM_LOG(_f, _a...) printk("DOM%d: (file=memory.c, line=%d) " _f "\n", current->domain, __LINE__, ## _a )
   13.11 @@ -191,8 +192,8 @@ static void put_l1_table(unsigned long p
   13.12  static void put_page(unsigned long page_nr, int writeable);
   13.13  static int dec_page_refcnt(unsigned long page_nr, unsigned int type);
   13.14  
   13.15 -static int mod_l2_entry(l2_pgentry_t *, l2_pgentry_t);
   13.16 -static int mod_l1_entry(l1_pgentry_t *, l1_pgentry_t);
   13.17 +static int mod_l2_entry(unsigned long, l2_pgentry_t);
   13.18 +static int mod_l1_entry(unsigned long, l1_pgentry_t);
   13.19  
   13.20  /* frame table size and its size in pages */
   13.21  frame_table_t * frame_table;
   13.22 @@ -206,13 +207,10 @@ static int tlb_flush[NR_CPUS];
   13.23  
   13.24  /*
   13.25   * init_frametable:
   13.26 - * Initialise per-frame memory information. The return value
   13.27 - * is the amount of memory available for use by the rest of Xen.
   13.28 - * The very highest frames are reserved for the per-frame info.
   13.29 - * This function should be called before initialising the
   13.30 - * page allocator!
   13.31 + * Initialise per-frame memory information. This goes directly after
   13.32 + * MAX_MONITOR_ADDRESS in physical memory.
   13.33   */
   13.34 -unsigned long __init init_frametable(unsigned long nr_pages)
   13.35 +void __init init_frametable(unsigned long nr_pages)
   13.36  {
   13.37      struct pfn_info *pf;
   13.38      unsigned long page_index;
   13.39 @@ -222,23 +220,21 @@ unsigned long __init init_frametable(uns
   13.40      max_page = nr_pages;
   13.41      frame_table_size = nr_pages * sizeof(struct pfn_info);
   13.42      frame_table_size = (frame_table_size + PAGE_SIZE - 1) & PAGE_MASK;
   13.43 -    free_pfns = nr_pages - (MAX_MONITOR_ADDRESS >> PAGE_SHIFT);
   13.44 +    free_pfns = nr_pages - 
   13.45 +        ((MAX_MONITOR_ADDRESS + frame_table_size) >> PAGE_SHIFT);
   13.46  
   13.47 -    frame_table = phys_to_virt(MAX_MONITOR_ADDRESS - frame_table_size);
   13.48 +    frame_table = phys_to_virt(MAX_MONITOR_ADDRESS);
   13.49      memset(frame_table, 0, frame_table_size);
   13.50  
   13.51      /* Put all domain-allocatable memory on a free list. */
   13.52      INIT_LIST_HEAD(&free_list);
   13.53 -    for( page_index = MAX_MONITOR_ADDRESS >> PAGE_SHIFT; 
   13.54 +    for( page_index = (MAX_MONITOR_ADDRESS + frame_table_size) >> PAGE_SHIFT; 
   13.55           page_index < nr_pages; 
   13.56           page_index++ )      
   13.57      {
   13.58          pf = list_entry(&frame_table[page_index].list, struct pfn_info, list);
   13.59          list_add_tail(&pf->list, &free_list);
   13.60      }
   13.61 -
   13.62 -    /* Return the remaing Xen-allocatable memory. */
   13.63 -    return(MAX_MONITOR_ADDRESS - frame_table_size);
   13.64  }
   13.65  
   13.66  
   13.67 @@ -312,7 +308,7 @@ static int get_l2_table(unsigned long pa
   13.68      if ( ret != 0 ) return((ret < 0) ? ret : 0);
   13.69      
   13.70      /* NEW level-2 page table! Deal with every PDE in the table. */
   13.71 -    p_l2_entry = (l2_pgentry_t *)__va(page_nr << PAGE_SHIFT);
   13.72 +    p_l2_entry = map_domain_mem(page_nr << PAGE_SHIFT);
   13.73      for ( i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ )
   13.74      {
   13.75          l2_entry = *p_l2_entry++;
   13.76 @@ -325,10 +321,13 @@ static int get_l2_table(unsigned long pa
   13.77          }
   13.78          ret = get_l1_table(l2_pgentry_to_pagenr(l2_entry));
   13.79          if ( ret ) return(ret);
   13.80 +        p_l2_entry = map_domain_mem((page_nr << PAGE_SHIFT) + 
   13.81 +                                    ((i+1) * sizeof(l2_pgentry_t)));
   13.82      }
   13.83  
   13.84      /* Now we simply slap in our high mapping. */
   13.85 -    memcpy(p_l2_entry, idle0_pg_table + DOMAIN_ENTRIES_PER_L2_PAGETABLE,
   13.86 +    memcpy(p_l2_entry, 
   13.87 +           idle_pg_table[smp_processor_id()] + DOMAIN_ENTRIES_PER_L2_PAGETABLE,
   13.88             HYPERVISOR_ENTRIES_PER_L2_PAGETABLE * sizeof(l2_pgentry_t));
   13.89  
   13.90      return(ret);
   13.91 @@ -344,7 +343,7 @@ static int get_l1_table(unsigned long pa
   13.92      if ( ret != 0 ) return((ret < 0) ? ret : 0);
   13.93  
   13.94      /* NEW level-1 page table! Deal with every PTE in the table. */
   13.95 -    p_l1_entry = (l1_pgentry_t *)__va(page_nr << PAGE_SHIFT);
   13.96 +    p_l1_entry = map_domain_mem(page_nr << PAGE_SHIFT);
   13.97      for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ )
   13.98      {
   13.99          l1_entry = *p_l1_entry++;
  13.100 @@ -414,12 +413,16 @@ static int put_l2_table(unsigned long pa
  13.101      if ( ret != 0 ) return((ret < 0) ? ret : 0);
  13.102  
  13.103      /* We had last reference to level-2 page table. Free the PDEs. */
  13.104 -    p_l2_entry = (l2_pgentry_t *)__va(page_nr << PAGE_SHIFT);
  13.105 +    p_l2_entry = map_domain_mem(page_nr << PAGE_SHIFT);
  13.106      for ( i = 0; i < HYPERVISOR_ENTRIES_PER_L2_PAGETABLE; i++ )
  13.107      {
  13.108          l2_entry = *p_l2_entry++;
  13.109 -        if ( (l2_pgentry_val(l2_entry) & _PAGE_PRESENT) ) 
  13.110 +        if ( (l2_pgentry_val(l2_entry) & _PAGE_PRESENT) )
  13.111 +        { 
  13.112              put_l1_table(l2_pgentry_to_pagenr(l2_entry));
  13.113 +            p_l2_entry = map_domain_mem((page_nr << PAGE_SHIFT) + 
  13.114 +                                        ((i+1) * sizeof(l2_pgentry_t)));
  13.115 +        }
  13.116      }
  13.117  
  13.118      return(0);
  13.119 @@ -433,7 +436,7 @@ static void put_l1_table(unsigned long p
  13.120      if ( dec_page_refcnt(page_nr, PGT_l1_page_table) != 0 ) return;
  13.121  
  13.122      /* We had last reference to level-1 page table. Free the PTEs. */
  13.123 -    p_l1_entry = (l1_pgentry_t *)__va(page_nr << PAGE_SHIFT);
  13.124 +    p_l1_entry = map_domain_mem(page_nr << PAGE_SHIFT);
  13.125      for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ )
  13.126      {
  13.127          l1_entry = *p_l1_entry++;
  13.128 @@ -463,9 +466,12 @@ static void put_page(unsigned long page_
  13.129  }
  13.130  
  13.131  
  13.132 -static int mod_l2_entry(l2_pgentry_t *p_l2_entry, l2_pgentry_t new_l2_entry)
  13.133 +static int mod_l2_entry(unsigned long pa, l2_pgentry_t new_l2_entry)
  13.134  {
  13.135 -    l2_pgentry_t old_l2_entry = *p_l2_entry;
  13.136 +    l2_pgentry_t *p_l2_entry, old_l2_entry;
  13.137 +
  13.138 +    p_l2_entry = map_domain_mem(pa);
  13.139 +    old_l2_entry = *p_l2_entry;
  13.140  
  13.141      if ( (((unsigned long)p_l2_entry & (PAGE_SIZE-1)) >> 2) >=
  13.142           DOMAIN_ENTRIES_PER_L2_PAGETABLE )
  13.143 @@ -475,6 +481,12 @@ static int mod_l2_entry(l2_pgentry_t *p_
  13.144          goto fail;
  13.145      }
  13.146  
  13.147 +    /*
  13.148 +     * Write the new value while pointer is still valid. The mapping cache 
  13.149 +     * entry for p_l2_entry may get clobbered by {put,get}_l1_table.
  13.150 +     */
  13.151 +    *p_l2_entry = new_l2_entry;
  13.152 +
  13.153      if ( (l2_pgentry_val(new_l2_entry) & _PAGE_PRESENT) )
  13.154      {
  13.155          if ( (l2_pgentry_val(new_l2_entry) & (_PAGE_GLOBAL|_PAGE_PSE)) )
  13.156 @@ -502,17 +514,25 @@ static int mod_l2_entry(l2_pgentry_t *p_
  13.157          put_l1_table(l2_pgentry_to_pagenr(old_l2_entry));
  13.158      }
  13.159      
  13.160 -    *p_l2_entry++ = new_l2_entry;
  13.161 -    
  13.162      return(0);
  13.163 +
  13.164   fail:
  13.165 +    /*
  13.166 +     * On failure we put the old value back. We need to regrab the
  13.167 +     * mapping of the physical page frame.
  13.168 +     */
  13.169 +    p_l2_entry = map_domain_mem(pa);
  13.170 +    *p_l2_entry = old_l2_entry;
  13.171      return(-1);
  13.172  }
  13.173  
  13.174  
  13.175 -static int mod_l1_entry(l1_pgentry_t *p_l1_entry, l1_pgentry_t new_l1_entry)
  13.176 +static int mod_l1_entry(unsigned long pa, l1_pgentry_t new_l1_entry)
  13.177  {
  13.178 -    l1_pgentry_t old_l1_entry = *p_l1_entry;
  13.179 +    l1_pgentry_t *p_l1_entry, old_l1_entry;
  13.180 +
  13.181 +    p_l1_entry = map_domain_mem(pa);
  13.182 +    old_l1_entry = *p_l1_entry;
  13.183  
  13.184      if ( (l1_pgentry_val(new_l1_entry) & _PAGE_PRESENT) )
  13.185      {
  13.186 @@ -548,7 +568,8 @@ static int mod_l1_entry(l1_pgentry_t *p_
  13.187                   l1_pgentry_val(old_l1_entry) & _PAGE_RW);
  13.188      }
  13.189  
  13.190 -    *p_l1_entry++ = new_l1_entry;
  13.191 +    /* p_l1_entry is still valid here */
  13.192 +    *p_l1_entry = new_l1_entry;
  13.193  
  13.194      return(0);
  13.195   fail:
  13.196 @@ -616,10 +637,8 @@ static int do_extended_command(unsigned 
  13.197          err = get_l2_table(pfn);
  13.198          if ( !err )
  13.199          {
  13.200 -            put_l2_table(__pa(pagetable_ptr(current->mm.pagetable)) 
  13.201 -                         >> PAGE_SHIFT);
  13.202 -            current->mm.pagetable = 
  13.203 -                mk_pagetable((unsigned long)__va(pfn<<PAGE_SHIFT));
  13.204 +            put_l2_table(pagetable_val(current->mm.pagetable) >> PAGE_SHIFT);
  13.205 +            current->mm.pagetable = mk_pagetable(pfn << PAGE_SHIFT);
  13.206          }
  13.207          else
  13.208          {
  13.209 @@ -632,8 +651,7 @@ static int do_extended_command(unsigned 
  13.210          break;
  13.211      
  13.212      case PGEXT_INVLPG:
  13.213 -        __asm__ __volatile__ ("invlpg %0" : : 
  13.214 -                              "m" (*(char*)(val & ~PGEXT_CMD_MASK)));
  13.215 +        __flush_tlb_one(val & ~PGEXT_CMD_MASK);
  13.216          break;
  13.217  
  13.218      default:
  13.219 @@ -684,12 +702,10 @@ int do_process_page_updates(page_update_
  13.220                  switch ( (flags & PG_type_mask) )
  13.221                  {
  13.222                  case PGT_l1_page_table: 
  13.223 -                    err = mod_l1_entry((l1_pgentry_t *)__va(cur.ptr), 
  13.224 -                                       mk_l1_pgentry(cur.val)); 
  13.225 +                    err = mod_l1_entry(cur.ptr, mk_l1_pgentry(cur.val)); 
  13.226                      break;
  13.227                  case PGT_l2_page_table: 
  13.228 -                    err = mod_l2_entry((l2_pgentry_t *)__va(cur.ptr),
  13.229 -                                       mk_l2_pgentry(cur.val)); 
  13.230 +                    err = mod_l2_entry(cur.ptr, mk_l2_pgentry(cur.val)); 
  13.231                      break;
  13.232                  default:
  13.233                      MEM_LOG("Update to non-pt page %08lx", cur.ptr);
  13.234 @@ -711,7 +727,8 @@ int do_process_page_updates(page_update_
  13.235              flags = page->flags;
  13.236              if ( (flags | current->domain) == PGT_l1_page_table )
  13.237              {
  13.238 -                *(unsigned long *)__va(cur.ptr) = cur.val;
  13.239 +                
  13.240 +                *(unsigned long *)map_domain_mem(cur.ptr) = cur.val;
  13.241                  err = 0;
  13.242              }
  13.243              else
  13.244 @@ -748,7 +765,7 @@ int do_process_page_updates(page_update_
  13.245          tlb_flush[smp_processor_id()] = 0;
  13.246          __asm__ __volatile__ (
  13.247              "movl %%eax,%%cr3" : : 
  13.248 -            "a" (__pa(pagetable_ptr(current->mm.pagetable))));
  13.249 +            "a" (pagetable_val(current->mm.pagetable)));
  13.250      }
  13.251  
  13.252      return(0);
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/xen-2.4.16/include/asm-i386/domain_page.h	Sun Jan 12 00:35:09 2003 +0000
    14.3 @@ -0,0 +1,27 @@
    14.4 +/******************************************************************************
    14.5 + * domain_page.h
    14.6 + * 
    14.7 + * Allow temporary mapping of domain page frames into Xen space.
    14.8 + */
    14.9 +
   14.10 +#include <xeno/config.h>
   14.11 +#include <xeno/sched.h>
   14.12 +
   14.13 +extern unsigned long *mapcache[NR_CPUS];
   14.14 +#define MAPCACHE_ENTRIES        1024
   14.15 +#define MAPCACHE_HASH(_pfn)     ((_pfn) & (MAPCACHE_ENTRIES-1))
   14.16 +static inline void *map_domain_mem(unsigned long pa)
   14.17 +{
   14.18 +    unsigned long pfn = pa >> PAGE_SHIFT;
   14.19 +    unsigned long hash = MAPCACHE_HASH(pfn);
   14.20 +    unsigned long *pent = mapcache[smp_processor_id()] + hash;
   14.21 +    void *va = (void *)(MAPCACHE_VIRT_START + 
   14.22 +                        (hash << PAGE_SHIFT) + 
   14.23 +                        (pa & ~PAGE_MASK));
   14.24 +    if ( (*pent & PAGE_MASK) != (pfn << PAGE_SHIFT) )
   14.25 +    {
   14.26 +        *pent = (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR;
   14.27 +        __flush_tlb_one(va);
   14.28 +    }
   14.29 +    return va;
   14.30 +}
    15.1 --- a/xen-2.4.16/include/asm-i386/page.h	Fri Jan 03 18:24:03 2003 +0000
    15.2 +++ b/xen-2.4.16/include/asm-i386/page.h	Sun Jan 12 00:35:09 2003 +0000
    15.3 @@ -41,23 +41,24 @@ typedef struct { unsigned long pt_lo; } 
    15.4  /* Strip type from a table entry. */
    15.5  #define l1_pgentry_val(_x) ((_x).l1_lo)
    15.6  #define l2_pgentry_val(_x) ((_x).l2_lo)
    15.7 +#define pagetable_val(_x)  ((_x).pt_lo)
    15.8  
    15.9  #define alloc_l1_pagetable()  ((l1_pgentry_t *)get_free_page(GFP_KERNEL))
   15.10  #define alloc_l2_pagetable()  ((l2_pgentry_t *)get_free_page(GFP_KERNEL))
   15.11  
   15.12 -#define pagetable_ptr(_x)  ((l2_pagetable_t)((_x).pt_lo))
   15.13 -#define pagetable_type(_x) (((_x).pt_lo) & ~PAGE_MASK)
   15.14 -#define mk_pagetable(_x)   ( (pagetable_t) { (_x) } )
   15.15 -#define pagetable_none(_x) ((_x).pt_lo == 0)
   15.16 -
   15.17  /* Add type to a table entry. */
   15.18  #define mk_l1_pgentry(_x)  ( (l1_pgentry_t) { (_x) } )
   15.19  #define mk_l2_pgentry(_x)  ( (l2_pgentry_t) { (_x) } )
   15.20 +#define mk_pagetable(_x)   ( (pagetable_t) { (_x) } )
   15.21  
   15.22  /* Turn a typed table entry into a page index. */
   15.23  #define l1_pgentry_to_pagenr(_x) (l1_pgentry_val(_x) >> PAGE_SHIFT) 
   15.24  #define l2_pgentry_to_pagenr(_x) (l2_pgentry_val(_x) >> PAGE_SHIFT)
   15.25  
   15.26 +/* Turn a typed table entry into a physical address. */
   15.27 +#define l1_pgentry_to_phys(_x) (l1_pgentry_val(_x) & PAGE_MASK)
   15.28 +#define l2_pgentry_to_phys(_x) (l2_pgentry_val(_x) & PAGE_MASK)
   15.29 +
   15.30  /* Dereference a typed level-2 entry to yield a typed level-1 table. */
   15.31  #define l2_pgentry_to_l1(_x)     \
   15.32    ((l1_pgentry_t *)__va(l2_pgentry_val(_x) & PAGE_MASK))
   15.33 @@ -72,7 +73,7 @@ typedef struct { unsigned long pt_lo; } 
   15.34  #define l1_pgentry_empty(_x) (!l1_pgentry_val(_x))
   15.35  #define l2_pgentry_empty(_x) (!l2_pgentry_val(_x))
   15.36  
   15.37 -#define __PAGE_OFFSET		(0xE0000000)
   15.38 +#define __PAGE_OFFSET		(0xFC000000)
   15.39  #define PAGE_OFFSET		((unsigned long)__PAGE_OFFSET)
   15.40  #define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
   15.41  #define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
   15.42 @@ -92,6 +93,7 @@ typedef struct { unsigned long pt_lo; } 
   15.43  #include <asm/bitops.h>
   15.44  
   15.45  extern l2_pgentry_t idle0_pg_table[ENTRIES_PER_L2_PAGETABLE];
   15.46 +extern l2_pgentry_t *idle_pg_table[NR_CPUS];
   15.47  extern void paging_init(void);
   15.48  
   15.49  #define __flush_tlb()							\
    16.1 --- a/xen-2.4.16/include/asm-i386/system.h	Fri Jan 03 18:24:03 2003 +0000
    16.2 +++ b/xen-2.4.16/include/asm-i386/system.h	Sun Jan 12 00:35:09 2003 +0000
    16.3 @@ -29,7 +29,7 @@ extern void FASTCALL(__switch_to(struct 
    16.4  		     :"=m" (prev->thread.esp),"=m" (prev->thread.eip)	\
    16.5  		     :"m" (next->thread.esp),"m" (next->thread.eip),	\
    16.6  		      "a" (prev), "d" (next),				\
    16.7 -                      "c" (__pa(pagetable_ptr(next->mm.pagetable)))     \
    16.8 +                      "c" (pagetable_val(next->mm.pagetable))		\
    16.9                       :"memory");                                        \
   16.10  } while (0)
   16.11  
    17.1 --- a/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h	Fri Jan 03 18:24:03 2003 +0000
    17.2 +++ b/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h	Sun Jan 12 00:35:09 2003 +0000
    17.3 @@ -10,6 +10,9 @@
    17.4  #ifndef __HYPERVISOR_IF_H__
    17.5  #define __HYPERVISOR_IF_H__
    17.6  
    17.7 +/* Virtual addresses beyond this are inaccessible by guest OSes. */
    17.8 +#define HYPERVISOR_VIRT_START (0xFC000000UL)
    17.9 +
   17.10  typedef struct trap_info_st
   17.11  {
   17.12      unsigned char  vector;  /* exception/interrupt vector */
    18.1 --- a/xen-2.4.16/include/xeno/bootmem.h	Fri Jan 03 18:24:03 2003 +0000
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,64 +0,0 @@
    18.4 -/*
    18.5 - * Discontiguous memory support, Kanoj Sarcar, SGI, Nov 1999
    18.6 - */
    18.7 -#ifndef _LINUX_BOOTMEM_H
    18.8 -#define _LINUX_BOOTMEM_H
    18.9 -
   18.10 -//#include <asm/pgtable.h>
   18.11 -
   18.12 -/*
   18.13 - *  simple boot-time physical memory area allocator.
   18.14 - */
   18.15 -
   18.16 -extern unsigned long max_low_pfn, max_page;
   18.17 -extern unsigned long min_low_pfn;
   18.18 -
   18.19 -#if 0
   18.20 -
   18.21 -/*
   18.22 - * node_bootmem_map is a map pointer - the bits represent all physical 
   18.23 - * memory pages (including holes) on the node.
   18.24 - */
   18.25 -typedef struct bootmem_data {
   18.26 -	unsigned long node_boot_start;
   18.27 -	unsigned long node_low_pfn;
   18.28 -	void *node_bootmem_map;
   18.29 -	unsigned long last_offset;
   18.30 -	unsigned long last_pos;
   18.31 -} bootmem_data_t;
   18.32 -
   18.33 -extern unsigned long __init bootmem_bootmap_pages (unsigned long);
   18.34 -extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend);
   18.35 -extern void __init reserve_bootmem (unsigned long addr, unsigned long size);
   18.36 -extern void __init free_bootmem (unsigned long addr, unsigned long size);
   18.37 -extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal);
   18.38 -#define alloc_bootmem(x) \
   18.39 -	__alloc_bootmem((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
   18.40 -#define alloc_bootmem_low(x) \
   18.41 -	__alloc_bootmem((x), SMP_CACHE_BYTES, 0)
   18.42 -#define alloc_bootmem_pages(x) \
   18.43 -	__alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
   18.44 -#define alloc_bootmem_low_pages(x) \
   18.45 -	__alloc_bootmem((x), PAGE_SIZE, 0)
   18.46 -extern unsigned long __init free_all_bootmem (void);
   18.47 -
   18.48 -extern unsigned long __init init_bootmem_node (pg_data_t *pgdat, unsigned long freepfn, unsigned long startpfn, unsigned long endpfn);
   18.49 -extern void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size);
   18.50 -extern void __init free_bootmem_node (pg_data_t *pgdat, unsigned long addr, unsigned long size);
   18.51 -extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat);
   18.52 -extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal);
   18.53 -#define alloc_bootmem_node(pgdat, x) \
   18.54 -	__alloc_bootmem_node((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
   18.55 -#define alloc_bootmem_pages_node(pgdat, x) \
   18.56 -	__alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
   18.57 -#define alloc_bootmem_low_pages_node(pgdat, x) \
   18.58 -	__alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0)
   18.59 -
   18.60 -#else
   18.61 -
   18.62 -extern void __init init_bootmem (unsigned long addr, unsigned long memend);
   18.63 -extern void * __init alloc_bootmem_low_pages(unsigned long size);
   18.64 -
   18.65 -#endif
   18.66 -
   18.67 -#endif /* _LINUX_BOOTMEM_H */
    19.1 --- a/xen-2.4.16/include/xeno/config.h	Fri Jan 03 18:24:03 2003 +0000
    19.2 +++ b/xen-2.4.16/include/xeno/config.h	Sun Jan 12 00:35:09 2003 +0000
    19.3 @@ -41,12 +41,16 @@
    19.4  #define __cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
    19.5  #define ____cacheline_aligned __cacheline_aligned
    19.6  
    19.7 -/* 0-8MB is fixed monitor space for now. */
    19.8 -#define MAX_MONITOR_ADDRESS ( 16*1024*1024)
    19.9 -#define MAX_DMA_ADDRESS     ( 16*1024*1024)
   19.10 -#define MAX_USABLE_ADDRESS  ((0xfc000000-__PAGE_OFFSET) & ~((1<<22)-1))
   19.11 -                             /*^^^^^^^^^*/
   19.12 -                             /*arbitrary*/
   19.13 +/* 0-16MB is fixed monitor space. 0-56MB is direct-mapped at top of memory.*/
   19.14 +#define MAX_MONITOR_ADDRESS   (16*1024*1024)
   19.15 +#define MAX_DMA_ADDRESS       (16*1024*1024)
   19.16 +#define MAX_DIRECTMAP_ADDRESS (56*1024*1024)
   19.17 +/* Penultimate 4MB of virtual address space used for domain page mappings. */
   19.18 +#define MAPCACHE_VIRT_START   (PAGE_OFFSET + MAX_DIRECTMAP_ADDRESS)
   19.19 +#define MAPCACHE_VIRT_END     (MAPCACHE_VIRT_START + (4*1024*1024))
   19.20 +/* Final 4MB of virtual address space used for ioremap(). */
   19.21 +#define IOREMAP_VIRT_START    (MAPCACHE_VIRT_END)
   19.22 +#define IOREMAP_VIRT_END      (IOREMAP_VIRT_START + (4*1024*1024))
   19.23  
   19.24  /* Linkage for x86 */
   19.25  #define FASTCALL(x)     x __attribute__((regparm(3)))
    20.1 --- a/xen-2.4.16/include/xeno/mm.h	Fri Jan 03 18:24:03 2003 +0000
    20.2 +++ b/xen-2.4.16/include/xeno/mm.h	Sun Jan 12 00:35:09 2003 +0000
    20.3 @@ -108,7 +108,8 @@ extern frame_table_t * frame_table;
    20.4  extern unsigned long frame_table_size;
    20.5  extern struct list_head free_list;
    20.6  extern unsigned int free_pfns;
    20.7 -unsigned long init_frametable(unsigned long nr_pages);
    20.8 +extern unsigned long max_page;
    20.9 +void init_frametable(unsigned long nr_pages);
   20.10  
   20.11  /* Part of the domain API. */
   20.12  int do_process_page_updates(page_update_request_t *updates, int count);
    21.1 --- a/xen-2.4.16/include/xeno/sched.h	Fri Jan 03 18:24:03 2003 +0000
    21.2 +++ b/xen-2.4.16/include/xeno/sched.h	Sun Jan 12 00:35:09 2003 +0000
    21.3 @@ -26,7 +26,7 @@ extern struct mm_struct init_mm;
    21.4  #define IDLE0_MM                                                    \
    21.5  {                                                                   \
    21.6      cpu_vm_mask: 0,                                                 \
    21.7 -    pagetable:   mk_pagetable((unsigned long)idle0_pg_table)        \
    21.8 +    pagetable:   mk_pagetable(__pa(idle0_pg_table))                 \
    21.9  }
   21.10  
   21.11  #define _HYP_EVENT_NEED_RESCHED 0
    22.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c	Fri Jan 03 18:24:03 2003 +0000
    22.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c	Sun Jan 12 00:35:09 2003 +0000
    22.3 @@ -143,7 +143,6 @@ void __init setup_arch(char **cmdline_p)
    22.4  {
    22.5      unsigned long start_pfn, max_pfn, max_low_pfn;
    22.6      unsigned long bootmap_size;
    22.7 -    char str[256]; int strcnt;
    22.8  
    22.9      extern void hypervisor_callback(void);
   22.10      extern void failsafe_callback(void);
   22.11 @@ -187,7 +186,7 @@ void __init setup_arch(char **cmdline_p)
   22.12   * 128MB for vmalloc and initrd
   22.13   */
   22.14  #define VMALLOC_RESERVE	(unsigned long)(128 << 20)
   22.15 -#define MAXMEM		(unsigned long)(-PAGE_OFFSET-VMALLOC_RESERVE)
   22.16 +#define MAXMEM		(unsigned long)(HYPERVISOR_VIRT_START-PAGE_OFFSET-VMALLOC_RESERVE)
   22.17  #define MAXMEM_PFN	PFN_DOWN(MAXMEM)
   22.18  #define MAX_NONPAE_PFN	(1 << 20)
   22.19  
   22.20 @@ -242,7 +241,7 @@ void __init setup_arch(char **cmdline_p)
   22.21       * Then reserve space for OS image, and the bootmem bitmap.
   22.22       */
   22.23      bootmap_size = init_bootmem(start_pfn, max_low_pfn);
   22.24 -    free_bootmem(0, PFN_PHYS(max_pfn));
   22.25 +    free_bootmem(0, PFN_PHYS(max_low_pfn));
   22.26      reserve_bootmem(0, PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE-1);
   22.27  
   22.28      /* Now reserve space for the hypervisor-provided page tables. */
   22.29 @@ -251,7 +250,7 @@ void __init setup_arch(char **cmdline_p)
   22.30          unsigned long  pte;
   22.31          int i;
   22.32          reserve_bootmem(__pa(pgd), PAGE_SIZE);
   22.33 -        for ( i = 0; i < (0xE0000000UL>>22); i++ )
   22.34 +        for ( i = 0; i < (HYPERVISOR_VIRT_START>>22); i++ )
   22.35          {
   22.36              unsigned long pgde = *pgd++;
   22.37              if ( !(pgde & 1) ) continue;
   22.38 @@ -260,6 +259,7 @@ void __init setup_arch(char **cmdline_p)
   22.39          }
   22.40      }
   22.41      cur_pgd = init_mm.pgd = (pgd_t *)start_info.pt_base;
   22.42 +    queue_pgd_pin(__pa(init_mm.pgd));
   22.43  
   22.44  #ifdef CONFIG_BLK_DEV_INITRD
   22.45      if (start_info.mod_start) {
   22.46 @@ -976,6 +976,7 @@ static void time_to_die(int irq, void *u
   22.47  static int __init setup_death_event(void)
   22.48  {
   22.49      (void)request_irq(_EVENT_DIE, time_to_die, 0, "die", NULL);
   22.50 +    return 0;
   22.51  }
   22.52  
   22.53  __initcall(setup_death_event);
    23.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/kernel/time.c	Fri Jan 03 18:24:03 2003 +0000
    23.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/kernel/time.c	Sun Jan 12 00:35:09 2003 +0000
    23.3 @@ -55,7 +55,6 @@
    23.4  #include <linux/timex.h>
    23.5  #include <linux/config.h>
    23.6  
    23.7 -#include <asm/fixmap.h>
    23.8  #include <asm/hypervisor.h>
    23.9  
   23.10  #include <linux/irq.h>
    24.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/mm/init.c	Fri Jan 03 18:24:03 2003 +0000
    24.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/mm/init.c	Sun Jan 12 00:35:09 2003 +0000
    24.3 @@ -32,7 +32,6 @@
    24.4  #include <asm/pgtable.h>
    24.5  #include <asm/pgalloc.h>
    24.6  #include <asm/dma.h>
    24.7 -#include <asm/fixmap.h>
    24.8  #include <asm/apic.h>
    24.9  #include <asm/tlb.h>
   24.10  
   24.11 @@ -59,31 +58,6 @@ int do_check_pgt_cache(int low, int high
   24.12      return freed;
   24.13  }
   24.14  
   24.15 -/*
   24.16 - * NOTE: pagetable_init alloc all the fixmap pagetables contiguous on the
   24.17 - * physical space so we can cache the place of the first one and move
   24.18 - * around without checking the pgd every time.
   24.19 - */
   24.20 -
   24.21 -#if CONFIG_HIGHMEM
   24.22 -pte_t *kmap_pte;
   24.23 -pgprot_t kmap_prot;
   24.24 -
   24.25 -#define kmap_get_fixmap_pte(vaddr)					\
   24.26 -	pte_offset(pmd_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr))
   24.27 -
   24.28 -void __init kmap_init(void)
   24.29 -{
   24.30 -    unsigned long kmap_vstart;
   24.31 -
   24.32 -    /* cache the first kmap pte */
   24.33 -    kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
   24.34 -    kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
   24.35 -
   24.36 -    kmap_prot = PAGE_KERNEL;
   24.37 -}
   24.38 -#endif /* CONFIG_HIGHMEM */
   24.39 -
   24.40  void show_mem(void)
   24.41  {
   24.42      int i, total = 0, reserved = 0;
   24.43 @@ -150,92 +124,8 @@ static inline void set_pte_phys (unsigne
   24.44      __flush_tlb_one(vaddr);
   24.45  }
   24.46  
   24.47 -void __set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
   24.48 -{
   24.49 -    unsigned long address = __fix_to_virt(idx);
   24.50 -
   24.51 -    if (idx >= __end_of_fixed_addresses) {
   24.52 -        printk("Invalid __set_fixmap\n");
   24.53 -        return;
   24.54 -    }
   24.55 -    set_pte_phys(address, phys, flags);
   24.56 -}
   24.57 -
   24.58 -#if 0
   24.59 -static void __init fixrange_init (unsigned long start, unsigned long end, pgd_t *pgd_base)
   24.60 -{
   24.61 -    pgd_t *pgd;
   24.62 -    pmd_t *pmd;
   24.63 -    pte_t *pte;
   24.64 -    int i, j;
   24.65 -    unsigned long vaddr;
   24.66 -
   24.67 -    vaddr = start;
   24.68 -    i = __pgd_offset(vaddr);
   24.69 -    j = __pmd_offset(vaddr);
   24.70 -    pgd = pgd_base + i;
   24.71 -
   24.72 -    for ( ; (i < PTRS_PER_PGD) && (vaddr != end); pgd++, i++) {
   24.73 -#if CONFIG_X86_PAE
   24.74 -        if (pgd_none(*pgd)) {
   24.75 -            pmd = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
   24.76 -            set_pgd(pgd, __pgd(__pa(pmd) + 0x1));
   24.77 -            if (pmd != pmd_offset(pgd, 0))
   24.78 -                printk("PAE BUG #02!\n");
   24.79 -        }
   24.80 -        pmd = pmd_offset(pgd, vaddr);
   24.81 -#else
   24.82 -        pmd = (pmd_t *)pgd;
   24.83 -#endif
   24.84 -        for (; (j < PTRS_PER_PMD) && (vaddr != end); pmd++, j++) {
   24.85 -            if (pmd_none(*pmd)) {
   24.86 -                pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
   24.87 -                set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte)));
   24.88 -                if (pte != pte_offset(pmd, 0))
   24.89 -                    BUG();
   24.90 -            }
   24.91 -            vaddr += PMD_SIZE;
   24.92 -        }
   24.93 -        j = 0;
   24.94 -    }
   24.95 -}
   24.96 -#endif
   24.97 -
   24.98 -static void __init pagetable_init (void)
   24.99 -{
  24.100 -#if 0
  24.101 -    vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
  24.102 -    fixrange_init(vaddr, 0, pgd_base);
  24.103 -#endif
  24.104 -
  24.105 -#if CONFIG_HIGHMEM
  24.106 -    /*
  24.107 -     * Permanent kmaps:
  24.108 -     */
  24.109 -    vaddr = PKMAP_BASE;
  24.110 -    fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
  24.111 -
  24.112 -    pgd = init_mm.pgd + __pgd_offset(vaddr);
  24.113 -    pmd = pmd_offset(pgd, vaddr);
  24.114 -    pte = pte_offset(pmd, vaddr);
  24.115 -    pkmap_page_table = pte;
  24.116 -#endif
  24.117 -}
  24.118 -
  24.119 -/*
  24.120 - * paging_init() sets up the page tables - note that the first 8MB are
  24.121 - * already mapped by head.S.
  24.122 - *
  24.123 - * This routines also unmaps the page at virtual kernel address 0, so
  24.124 - * that we can trap those pesky NULL-reference errors in the kernel.
  24.125 - */
  24.126  void __init paging_init(void)
  24.127  {
  24.128 -    pagetable_init();
  24.129 -
  24.130 -#ifdef CONFIG_HIGHMEM
  24.131 -    kmap_init();
  24.132 -#endif
  24.133      {
  24.134          unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
  24.135          unsigned int max_dma, high, low;
  24.136 @@ -249,9 +139,6 @@ void __init paging_init(void)
  24.137          else {
  24.138              zones_size[ZONE_DMA] = max_dma;
  24.139              zones_size[ZONE_NORMAL] = low - max_dma;
  24.140 -#ifdef CONFIG_HIGHMEM
  24.141 -            zones_size[ZONE_HIGHMEM] = high - low;
  24.142 -#endif
  24.143          }
  24.144          free_area_init(zones_size);
  24.145      }
  24.146 @@ -269,12 +156,7 @@ void __init mem_init(void)
  24.147      int codesize, reservedpages, datasize, initsize;
  24.148      int tmp;
  24.149  
  24.150 -#ifdef CONFIG_HIGHMEM
  24.151 -    highmem_start_page = mem_map + highstart_pfn;
  24.152 -    max_mapnr = num_physpages = highend_pfn;
  24.153 -#else
  24.154      max_mapnr = num_physpages = max_low_pfn;
  24.155 -#endif
  24.156      high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
  24.157  
  24.158      /* clear the zero-page */
  24.159 @@ -290,22 +172,6 @@ void __init mem_init(void)
  24.160           */
  24.161          if (page_is_ram(tmp) && PageReserved(mem_map+tmp))
  24.162              reservedpages++;
  24.163 -#ifdef CONFIG_HIGHMEM
  24.164 -    for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
  24.165 -        struct page *page = mem_map + tmp;
  24.166 -
  24.167 -        if (!page_is_ram(tmp)) {
  24.168 -            SetPageReserved(page);
  24.169 -            continue;
  24.170 -        }
  24.171 -        ClearPageReserved(page);
  24.172 -        set_bit(PG_highmem, &page->flags);
  24.173 -        atomic_set(&page->count, 1);
  24.174 -        __free_page(page);
  24.175 -        totalhigh_pages++;
  24.176 -    }
  24.177 -    totalram_pages += totalhigh_pages;
  24.178 -#endif
  24.179      codesize =  (unsigned long) &_etext - (unsigned long) &_text;
  24.180      datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
  24.181      initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
    25.1 --- a/xenolinux-2.4.16-sparse/include/asm-xeno/fixmap.h	Fri Jan 03 18:24:03 2003 +0000
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,118 +0,0 @@
    25.4 -/*
    25.5 - * fixmap.h: compile-time virtual memory allocation
    25.6 - *
    25.7 - * This file is subject to the terms and conditions of the GNU General Public
    25.8 - * License.  See the file "COPYING" in the main directory of this archive
    25.9 - * for more details.
   25.10 - *
   25.11 - * Copyright (C) 1998 Ingo Molnar
   25.12 - *
   25.13 - * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
   25.14 - */
   25.15 -
   25.16 -#ifndef _ASM_FIXMAP_H
   25.17 -#define _ASM_FIXMAP_H
   25.18 -
   25.19 -#include <linux/config.h>
   25.20 -#include <linux/kernel.h>
   25.21 -#include <asm/apicdef.h>
   25.22 -#include <asm/page.h>
   25.23 -#ifdef CONFIG_HIGHMEM
   25.24 -#include <linux/threads.h>
   25.25 -#include <asm/kmap_types.h>
   25.26 -#endif
   25.27 -
   25.28 -/*
   25.29 - * Here we define all the compile-time 'special' virtual
   25.30 - * addresses. The point is to have a constant address at
   25.31 - * compile time, but to set the physical address only
   25.32 - * in the boot process. We allocate these special  addresses
   25.33 - * from the end of virtual memory (0xfffff000) backwards.
   25.34 - * Also this lets us do fail-safe vmalloc(), we
   25.35 - * can guarantee that these special addresses and
   25.36 - * vmalloc()-ed addresses never overlap.
   25.37 - *
   25.38 - * these 'compile-time allocated' memory buffers are
   25.39 - * fixed-size 4k pages. (or larger if used with an increment
   25.40 - * highger than 1) use fixmap_set(idx,phys) to associate
   25.41 - * physical memory with fixmap indices.
   25.42 - *
   25.43 - * TLB entries of such buffers will not be flushed across
   25.44 - * task switches.
   25.45 - */
   25.46 -
   25.47 -/*
   25.48 - * on UP currently we will have no trace of the fixmap mechanizm,
   25.49 - * no page table allocations, etc. This might change in the
   25.50 - * future, say framebuffers for the console driver(s) could be
   25.51 - * fix-mapped?
   25.52 - */
   25.53 -enum fixed_addresses {
   25.54 -#ifdef CONFIG_X86_LOCAL_APIC
   25.55 -	FIX_APIC_BASE,	/* local (CPU) APIC) -- required for SMP or not */
   25.56 -#endif
   25.57 -#ifdef CONFIG_X86_IO_APIC
   25.58 -	FIX_IO_APIC_BASE_0,
   25.59 -	FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
   25.60 -#endif
   25.61 -#ifdef CONFIG_X86_VISWS_APIC
   25.62 -	FIX_CO_CPU,	/* Cobalt timer */
   25.63 -	FIX_CO_APIC,	/* Cobalt APIC Redirection Table */ 
   25.64 -	FIX_LI_PCIA,	/* Lithium PCI Bridge A */
   25.65 -	FIX_LI_PCIB,	/* Lithium PCI Bridge B */
   25.66 -#endif
   25.67 -#ifdef CONFIG_HIGHMEM
   25.68 -	FIX_KMAP_BEGIN,	/* reserved pte's for temporary kernel mappings */
   25.69 -	FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
   25.70 -#endif
   25.71 -	__end_of_fixed_addresses
   25.72 -};
   25.73 -
   25.74 -extern void __set_fixmap (enum fixed_addresses idx,
   25.75 -					unsigned long phys, pgprot_t flags);
   25.76 -
   25.77 -#define set_fixmap(idx, phys) \
   25.78 -		__set_fixmap(idx, phys, PAGE_KERNEL)
   25.79 -/*
   25.80 - * Some hardware wants to get fixmapped without caching.
   25.81 - */
   25.82 -#define set_fixmap_nocache(idx, phys) \
   25.83 -		__set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
   25.84 -/*
   25.85 - * used by vmalloc.c.
   25.86 - *
   25.87 - * Leave one empty page between vmalloc'ed areas and
   25.88 - * the start of the fixmap, and leave one page empty
   25.89 - * at the top of mem..
   25.90 - */
   25.91 -#define FIXADDR_TOP	(0xffffe000UL)
   25.92 -#define FIXADDR_SIZE	(__end_of_fixed_addresses << PAGE_SHIFT)
   25.93 -#define FIXADDR_START	(FIXADDR_TOP - FIXADDR_SIZE)
   25.94 -
   25.95 -#define __fix_to_virt(x)	(FIXADDR_TOP - ((x) << PAGE_SHIFT))
   25.96 -
   25.97 -extern void __this_fixmap_does_not_exist(void);
   25.98 -
   25.99 -/*
  25.100 - * 'index to address' translation. If anyone tries to use the idx
  25.101 - * directly without tranlation, we catch the bug with a NULL-deference
  25.102 - * kernel oops. Illegal ranges of incoming indices are caught too.
  25.103 - */
  25.104 -static inline unsigned long fix_to_virt(const unsigned int idx)
  25.105 -{
  25.106 -	/*
  25.107 -	 * this branch gets completely eliminated after inlining,
  25.108 -	 * except when someone tries to use fixaddr indices in an
  25.109 -	 * illegal way. (such as mixing up address types or using
  25.110 -	 * out-of-range indices).
  25.111 -	 *
  25.112 -	 * If it doesn't get removed, the linker will complain
  25.113 -	 * loudly with a reasonably clear error message..
  25.114 -	 */
  25.115 -	if (idx >= __end_of_fixed_addresses)
  25.116 -		__this_fixmap_does_not_exist();
  25.117 -
  25.118 -        return __fix_to_virt(idx);
  25.119 -}
  25.120 -
  25.121 -#endif
    26.1 --- a/xenolinux-2.4.16-sparse/include/asm-xeno/highmem.h	Fri Jan 03 18:24:03 2003 +0000
    26.2 +++ b/xenolinux-2.4.16-sparse/include/asm-xeno/highmem.h	Sun Jan 12 00:35:09 2003 +0000
    26.3 @@ -1,129 +1,2 @@
    26.4 -/*
    26.5 - * highmem.h: virtual kernel memory mappings for high memory
    26.6 - *
    26.7 - * Used in CONFIG_HIGHMEM systems for memory pages which
    26.8 - * are not addressable by direct kernel virtual addresses.
    26.9 - *
   26.10 - * Copyright (C) 1999 Gerhard Wichert, Siemens AG
   26.11 - *		      Gerhard.Wichert@pdb.siemens.de
   26.12 - *
   26.13 - *
   26.14 - * Redesigned the x86 32-bit VM architecture to deal with 
   26.15 - * up to 16 Terabyte physical memory. With current x86 CPUs
   26.16 - * we now support up to 64 Gigabytes physical RAM.
   26.17 - *
   26.18 - * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
   26.19 - */
   26.20  
   26.21 -#ifndef _ASM_HIGHMEM_H
   26.22 -#define _ASM_HIGHMEM_H
   26.23 -
   26.24 -#ifdef __KERNEL__
   26.25 -
   26.26 -#include <linux/config.h>
   26.27 -#include <linux/init.h>
   26.28 -#include <linux/interrupt.h>
   26.29 -#include <asm/kmap_types.h>
   26.30 -#include <asm/pgtable.h>
   26.31 -
   26.32 -#ifdef CONFIG_DEBUG_HIGHMEM
   26.33 -#define HIGHMEM_DEBUG 1
   26.34 -#else
   26.35 -#define HIGHMEM_DEBUG 0
   26.36 -#endif
   26.37 -
   26.38 -/* declarations for highmem.c */
   26.39 -extern unsigned long highstart_pfn, highend_pfn;
   26.40 -
   26.41 -extern pte_t *kmap_pte;
   26.42 -extern pgprot_t kmap_prot;
   26.43 -extern pte_t *pkmap_page_table;
   26.44 -
   26.45 -extern void kmap_init(void) __init;
   26.46 -
   26.47 -/*
   26.48 - * Right now we initialize only a single pte table. It can be extended
   26.49 - * easily, subsequent pte tables have to be allocated in one physical
   26.50 - * chunk of RAM.
   26.51 - */
   26.52 -#define PKMAP_BASE (0xfe000000UL)
   26.53 -#ifdef CONFIG_X86_PAE
   26.54 -#define LAST_PKMAP 512
   26.55 -#else
   26.56 -#define LAST_PKMAP 1024
   26.57 -#endif
   26.58 -#define LAST_PKMAP_MASK (LAST_PKMAP-1)
   26.59 -#define PKMAP_NR(virt)  ((virt-PKMAP_BASE) >> PAGE_SHIFT)
   26.60 -#define PKMAP_ADDR(nr)  (PKMAP_BASE + ((nr) << PAGE_SHIFT))
   26.61 -
   26.62 -extern void * FASTCALL(kmap_high(struct page *page));
   26.63 -extern void FASTCALL(kunmap_high(struct page *page));
   26.64 -
   26.65 -static inline void *kmap(struct page *page)
   26.66 -{
   26.67 -	if (in_interrupt())
   26.68 -		BUG();
   26.69 -	if (page < highmem_start_page)
   26.70 -		return page_address(page);
   26.71 -	return kmap_high(page);
   26.72 -}
   26.73 -
   26.74 -static inline void kunmap(struct page *page)
   26.75 -{
   26.76 -	if (in_interrupt())
   26.77 -		BUG();
   26.78 -	if (page < highmem_start_page)
   26.79 -		return;
   26.80 -	kunmap_high(page);
   26.81 -}
   26.82 -
   26.83 -/*
   26.84 - * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
   26.85 - * gives a more generic (and caching) interface. But kmap_atomic can
   26.86 - * be used in IRQ contexts, so in some (very limited) cases we need
   26.87 - * it.
   26.88 - */
   26.89 -static inline void *kmap_atomic(struct page *page, enum km_type type)
   26.90 -{
   26.91 -	enum fixed_addresses idx;
   26.92 -	unsigned long vaddr;
   26.93 -
   26.94 -	if (page < highmem_start_page)
   26.95 -		return page_address(page);
   26.96 -
   26.97 -	idx = type + KM_TYPE_NR*smp_processor_id();
   26.98 -	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
   26.99 -#if HIGHMEM_DEBUG
  26.100 -	if (!pte_none(*(kmap_pte-idx)))
  26.101 -		BUG();
  26.102 -#endif
  26.103 -	set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
  26.104 -	__flush_tlb_one(vaddr);
  26.105 -
  26.106 -	return (void*) vaddr;
  26.107 -}
  26.108 -
  26.109 -static inline void kunmap_atomic(void *kvaddr, enum km_type type)
  26.110 -{
  26.111 -#if HIGHMEM_DEBUG
  26.112 -	unsigned long vaddr = (unsigned long) kvaddr;
  26.113 -	enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
  26.114 -
  26.115 -	if (vaddr < FIXADDR_START) // FIXME
  26.116 -		return;
  26.117 -
  26.118 -	if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx))
  26.119 -		BUG();
  26.120 -
  26.121 -	/*
  26.122 -	 * force other mappings to Oops if they'll try to access
  26.123 -	 * this pte without first remap it
  26.124 -	 */
  26.125 -	pte_clear(kmap_pte-idx);
  26.126 -	__flush_tlb_one(vaddr);
  26.127 -#endif
  26.128 -}
  26.129 -
  26.130 -#endif /* __KERNEL__ */
  26.131 -
  26.132 -#endif /* _ASM_HIGHMEM_H */
  26.133 +#error "Highmem unsupported!"
    27.1 --- a/xenolinux-2.4.16-sparse/include/asm-xeno/pgalloc.h	Fri Jan 03 18:24:03 2003 +0000
    27.2 +++ b/xenolinux-2.4.16-sparse/include/asm-xeno/pgalloc.h	Sun Jan 12 00:35:09 2003 +0000
    27.3 @@ -4,7 +4,6 @@
    27.4  #include <linux/config.h>
    27.5  #include <asm/processor.h>
    27.6  #include <asm/hypervisor.h>
    27.7 -#include <asm/fixmap.h>
    27.8  #include <linux/threads.h>
    27.9  
   27.10  /*
    28.1 --- a/xenolinux-2.4.16-sparse/include/asm-xeno/pgtable.h	Fri Jan 03 18:24:03 2003 +0000
    28.2 +++ b/xenolinux-2.4.16-sparse/include/asm-xeno/pgtable.h	Sun Jan 12 00:35:09 2003 +0000
    28.3 @@ -15,7 +15,6 @@
    28.4  #ifndef __ASSEMBLY__
    28.5  #include <asm/processor.h>
    28.6  #include <asm/hypervisor.h>
    28.7 -#include <asm/fixmap.h>
    28.8  #include <linux/threads.h>
    28.9  
   28.10  #ifndef _I386_BITOPS_H
   28.11 @@ -93,22 +92,12 @@ extern void pgtable_cache_init(void);
   28.12  
   28.13  
   28.14  #ifndef __ASSEMBLY__
   28.15 -/* Just any arbitrary offset to the start of the vmalloc VM area: the
   28.16 - * current 8MB value just means that there will be a 8MB "hole" after the
   28.17 - * physical memory until the kernel virtual memory starts.  That means that
   28.18 - * any out-of-bounds memory accesses will hopefully be caught.
   28.19 - * The vmalloc() routines leaves a hole of 4kB between each vmalloced
   28.20 - * area for the same reason. ;)
   28.21 - */
   28.22 -#define VMALLOC_OFFSET	(8*1024*1024)
   28.23 +/* 4MB is just a nice "safety zone". Also, we align to a fresh pde. */
   28.24 +#define VMALLOC_OFFSET	(4*1024*1024)
   28.25  #define VMALLOC_START	(((unsigned long) high_memory + 2*VMALLOC_OFFSET-1) & \
   28.26  						~(VMALLOC_OFFSET-1))
   28.27  #define VMALLOC_VMADDR(x) ((unsigned long)(x))
   28.28 -#if CONFIG_HIGHMEM
   28.29 -# define VMALLOC_END	(PKMAP_BASE-2*PAGE_SIZE)
   28.30 -#else
   28.31 -# define VMALLOC_END	(FIXADDR_START-2*PAGE_SIZE)
   28.32 -#endif
   28.33 +#define VMALLOC_END	(HYPERVISOR_VIRT_START-PAGE_SIZE)
   28.34  
   28.35  #define _PAGE_BIT_PRESENT	0
   28.36  #define _PAGE_BIT_RW		1
    29.1 --- a/xenolinux-2.4.16-sparse/include/asm-xeno/smp.h	Fri Jan 03 18:24:03 2003 +0000
    29.2 +++ b/xenolinux-2.4.16-sparse/include/asm-xeno/smp.h	Sun Jan 12 00:35:09 2003 +0000
    29.3 @@ -12,7 +12,6 @@
    29.4  
    29.5  #ifdef CONFIG_X86_LOCAL_APIC
    29.6  #ifndef __ASSEMBLY__
    29.7 -#include <asm/fixmap.h>
    29.8  #include <asm/bitops.h>
    29.9  #include <asm/mpspec.h>
   29.10  #ifdef CONFIG_X86_IO_APIC