ia64/xen-unstable

changeset 114:b46b05647a32

bitkeeper revision 1.22.1.1 (3e3e99f1o3TNE3GpOg3lVm9IdI7Z7Q)

Many files:
We now have a shared read-only machine->physical mapping table at start of hypervisor virtual address region.
author kaf24@labyrinth.cl.cam.ac.uk
date Mon Feb 03 16:33:53 2003 +0000 (2003-02-03)
parents 033b5b739c6f
children 11615a0ad0f1
files xen-2.4.16/arch/i386/Rules.mk xen-2.4.16/arch/i386/boot/boot.S xen-2.4.16/arch/i386/mm.c xen-2.4.16/arch/i386/xeno.lds xen-2.4.16/common/domain.c xen-2.4.16/common/memory.c xen-2.4.16/include/asm-i386/page.h xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h xen-2.4.16/include/xeno/config.h
line diff
     1.1 --- a/xen-2.4.16/arch/i386/Rules.mk	Fri Jan 31 15:03:37 2003 +0000
     1.2 +++ b/xen-2.4.16/arch/i386/Rules.mk	Mon Feb 03 16:33:53 2003 +0000
     1.3 @@ -4,7 +4,7 @@
     1.4  CC := gcc
     1.5  LD := ld
     1.6  # Linker should relocate monitor to this address
     1.7 -MONITOR_BASE := 0xFC100000
     1.8 +MONITOR_BASE := 0xFC500000
     1.9  # Bootloader should load monitor to this real address
    1.10  LOAD_BASE    := 0x00100000
    1.11  CFLAGS  := -fno-builtin -O3 -Wall -DMONITOR_BASE=$(MONITOR_BASE) 
     2.1 --- a/xen-2.4.16/arch/i386/boot/boot.S	Fri Jan 31 15:03:37 2003 +0000
     2.2 +++ b/xen-2.4.16/arch/i386/boot/boot.S	Mon Feb 03 16:33:53 2003 +0000
     2.3 @@ -216,13 +216,15 @@ nopaging_gdt_descr:
     2.4          .long   SYMBOL_NAME(gdt_table)-__PAGE_OFFSET
     2.5          
     2.6          ALIGN
     2.7 +/* NB. Rings != 0 get access up to 0xFC400000. This allows access to the */
     2.8 +/*     machine->physical mapping table. Ring 0 can access all memory.    */
     2.9  ENTRY(gdt_table)
    2.10          .quad 0x0000000000000000     /* NULL descriptor */
    2.11          .quad 0x0000000000000000     /* not used */
    2.12 -        .quad 0x00cfba000000bfff     /* 0x11 ring 1 3.95GB code at 0x0 */
    2.13 -        .quad 0x00cfb2000000bfff     /* 0x19 ring 1 3.95GB data at 0x0 */
    2.14 -        .quad 0x00cffa000000bfff     /* 0x23 ring 3 3.95GB code at 0x0 */
    2.15 -        .quad 0x00cff2000000bfff     /* 0x2b ring 3 3.95GB data at 0x0 */
    2.16 +        .quad 0x00cfba000000c3ff     /* 0x11 ring 1 3.95GB code at 0x0 */
    2.17 +        .quad 0x00cfb2000000c3ff     /* 0x19 ring 1 3.95GB data at 0x0 */
    2.18 +        .quad 0x00cffa000000c3ff     /* 0x23 ring 3 3.95GB code at 0x0 */
    2.19 +        .quad 0x00cff2000000c3ff     /* 0x2b ring 3 3.95GB data at 0x0 */
    2.20          .quad 0x00cf9a000000ffff     /* 0x30 ring 0 4.00GB code at 0x0 */
    2.21          .quad 0x00cf92000000ffff     /* 0x38 ring 0 4.00GB data at 0x0 */
    2.22          .fill NR_CPUS,8,0             /* space for TSS's */
     3.1 --- a/xen-2.4.16/arch/i386/mm.c	Fri Jan 31 15:03:37 2003 +0000
     3.2 +++ b/xen-2.4.16/arch/i386/mm.c	Mon Feb 03 16:33:53 2003 +0000
     3.3 @@ -73,8 +73,14 @@ void __init paging_init(void)
     3.4      /* Create page table for ioremap(). */
     3.5      ioremap_pt = (void *)get_free_page(GFP_KERNEL);
     3.6      clear_page(ioremap_pt);
     3.7 -    idle0_pg_table[MAPCACHE_VIRT_START >> L2_PAGETABLE_SHIFT] = 
     3.8 +    idle0_pg_table[IOREMAP_VIRT_START >> L2_PAGETABLE_SHIFT] = 
     3.9          mk_l2_pgentry(__pa(ioremap_pt) | PAGE_HYPERVISOR);
    3.10 +
    3.11 +    /* Create read-only mapping of MPT for guest-OS use. */
    3.12 +    idle0_pg_table[READONLY_MPT_VIRT_START >> L2_PAGETABLE_SHIFT] =
    3.13 +        idle0_pg_table[RDWR_MPT_VIRT_START >> L2_PAGETABLE_SHIFT];
    3.14 +    mk_l2_readonly(idle0_pg_table + 
    3.15 +                   (READONLY_MPT_VIRT_START >> L2_PAGETABLE_SHIFT));
    3.16  }
    3.17  
    3.18  void __init zap_low_mappings (void)
     4.1 --- a/xen-2.4.16/arch/i386/xeno.lds	Fri Jan 31 15:03:37 2003 +0000
     4.2 +++ b/xen-2.4.16/arch/i386/xeno.lds	Mon Feb 03 16:33:53 2003 +0000
     4.3 @@ -6,7 +6,7 @@ OUTPUT_ARCH(i386)
     4.4  ENTRY(start)
     4.5  SECTIONS
     4.6  {
     4.7 -  . = 0xFC000000 + 0x100000;
     4.8 +  . = 0xFC400000 + 0x100000;
     4.9    _text = .;			/* Text and read-only data */
    4.10    .text : {
    4.11  	*(.text)
     5.1 --- a/xen-2.4.16/common/domain.c	Fri Jan 31 15:03:37 2003 +0000
     5.2 +++ b/xen-2.4.16/common/domain.c	Mon Feb 03 16:33:53 2003 +0000
     5.3 @@ -576,6 +576,9 @@ int setup_guestos(struct task_struct *p,
     5.4      net_ring_t *net_ring;
     5.5      net_vif_t *net_vif;
     5.6  
     5.7 +    /* Sanity! */
     5.8 +    if ( p->domain != 0 ) BUG();
     5.9 +
    5.10      if ( strncmp(__va(mod[0].mod_start), "XenoGues", 8) )
    5.11      {
    5.12          printk("DOM%d: Invalid guest OS image\n", dom);
    5.13 @@ -622,10 +625,13 @@ int setup_guestos(struct task_struct *p,
    5.14      memset(l2tab, 0, DOMAIN_ENTRIES_PER_L2_PAGETABLE*sizeof(l2_pgentry_t));
    5.15      p->mm.pagetable = mk_pagetable(phys_l2tab);
    5.16  
    5.17 +    /* Domain 0 gets WRITE access to the read-only machine->physical table. */
    5.18 +    mk_l2_writeable(l2tab + (READONLY_MPT_VIRT_START >> L2_PAGETABLE_SHIFT));
    5.19 +
    5.20      /*
    5.21 -     * NB. The upper limit on this loop does one extra page + pages for frame table. 
    5.22 -     * This is to make sure a pte exists when we want to map the shared_info struct
    5.23 -     * and frame table struct.
    5.24 +     * NB. The upper limit on this loop does one extra page + pages for frame
    5.25 +     * table. This is to make sure a pte exists when we want to map the
    5.26 +     * shared_info struct and frame table struct.
    5.27       */
    5.28  
    5.29      ft_pages = frame_table_size >> PAGE_SHIFT;
     6.1 --- a/xen-2.4.16/common/memory.c	Fri Jan 31 15:03:37 2003 +0000
     6.2 +++ b/xen-2.4.16/common/memory.c	Mon Feb 03 16:33:53 2003 +0000
     6.3 @@ -224,15 +224,15 @@ void __init init_frametable(unsigned lon
     6.4      max_page = nr_pages;
     6.5      frame_table_size = nr_pages * sizeof(struct pfn_info);
     6.6      frame_table_size = (frame_table_size + PAGE_SIZE - 1) & PAGE_MASK;
     6.7 -    free_pfns = nr_pages - 
     6.8 -        ((MAX_MONITOR_ADDRESS + frame_table_size) >> PAGE_SHIFT);
     6.9 +    frame_table = (frame_table_t *)FRAMETABLE_VIRT_START;
    6.10 +    memset(frame_table, 0, frame_table_size);
    6.11  
    6.12 -    frame_table = phys_to_virt(MAX_MONITOR_ADDRESS);
    6.13 -    memset(frame_table, 0, frame_table_size);
    6.14 +    free_pfns = nr_pages - 
    6.15 +        ((__pa(frame_table) + frame_table_size) >> PAGE_SHIFT);
    6.16  
    6.17      /* Put all domain-allocatable memory on a free list. */
    6.18      INIT_LIST_HEAD(&free_list);
    6.19 -    for( page_index = (MAX_MONITOR_ADDRESS + frame_table_size) >> PAGE_SHIFT; 
    6.20 +    for( page_index = (__pa(frame_table) + frame_table_size) >> PAGE_SHIFT; 
    6.21           page_index < nr_pages; 
    6.22           page_index++ )      
    6.23      {
    6.24 @@ -364,6 +364,12 @@ static int get_l2_table(unsigned long pa
    6.25                DOMAIN_ENTRIES_PER_L2_PAGETABLE] =
    6.26          mk_l2_pgentry(__pa(current->mm.perdomain_pt) | __PAGE_HYPERVISOR);
    6.27  
    6.28 +    /*
    6.29 +     * DOM0 has the MPT mapped as WRITABLE.
    6.30 +     * 'p_l2_entry' happens to be pointing at the right place at this point :-)
    6.31 +     */
    6.32 +    if ( current->domain == 0 ) mk_l2_writeable(p_l2_entry);
    6.33 +
    6.34   out:
    6.35      unmap_domain_mem(p_l2_entry);
    6.36      return ret;
     7.1 --- a/xen-2.4.16/include/asm-i386/page.h	Fri Jan 31 15:03:37 2003 +0000
     7.2 +++ b/xen-2.4.16/include/asm-i386/page.h	Mon Feb 03 16:33:53 2003 +0000
     7.3 @@ -73,7 +73,7 @@ typedef struct { unsigned long pt_lo; } 
     7.4  #define l1_pgentry_empty(_x) (!l1_pgentry_val(_x))
     7.5  #define l2_pgentry_empty(_x) (!l2_pgentry_val(_x))
     7.6  
     7.7 -#define __PAGE_OFFSET		(0xFC000000)
     7.8 +#define __PAGE_OFFSET		(0xFC400000)
     7.9  #define PAGE_OFFSET		((unsigned long)__PAGE_OFFSET)
    7.10  #define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
    7.11  #define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
    7.12 @@ -83,7 +83,7 @@ typedef struct { unsigned long pt_lo; } 
    7.13  
    7.14  /* High table entries are reserved by the hypervisor. */
    7.15  #define DOMAIN_ENTRIES_PER_L2_PAGETABLE	    \
    7.16 -  (PAGE_OFFSET >> L2_PAGETABLE_SHIFT)
    7.17 +  (HYPERVISOR_VIRT_START >> L2_PAGETABLE_SHIFT)
    7.18  #define HYPERVISOR_ENTRIES_PER_L2_PAGETABLE \
    7.19    (ENTRIES_PER_L2_PAGETABLE - DOMAIN_ENTRIES_PER_L2_PAGETABLE)
    7.20  
    7.21 @@ -153,6 +153,16 @@ extern void paging_init(void);
    7.22  #define PAGE_HYPERVISOR_RO MAKE_GLOBAL(__PAGE_HYPERVISOR_RO)
    7.23  #define PAGE_HYPERVISOR_NOCACHE MAKE_GLOBAL(__PAGE_HYPERVISOR_NOCACHE)
    7.24  
    7.25 +#define mk_l2_writeable(_p) \
    7.26 +    (*(_p) = mk_l2_pgentry(l2_pgentry_val(*(_p)) |  _PAGE_RW))
    7.27 +#define mk_l2_readonly(_p) \
    7.28 +    (*(_p) = mk_l2_pgentry(l2_pgentry_val(*(_p)) & ~_PAGE_RW))
    7.29 +#define mk_l1_writeable(_p) \
    7.30 +    (*(_p) = mk_l1_pgentry(l1_pgentry_val(*(_p)) |  _PAGE_RW))
    7.31 +#define mk_l1_readonly(_p) \
    7.32 +    (*(_p) = mk_l1_pgentry(l1_pgentry_val(*(_p)) & ~_PAGE_RW))
    7.33 +
    7.34 +
    7.35  #ifndef __ASSEMBLY__
    7.36  static __inline__ int get_order(unsigned long size)
    7.37  {
     8.1 --- a/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h	Fri Jan 31 15:03:37 2003 +0000
     8.2 +++ b/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h	Mon Feb 03 16:33:53 2003 +0000
     8.3 @@ -10,7 +10,11 @@
     8.4  #ifndef __HYPERVISOR_IF_H__
     8.5  #define __HYPERVISOR_IF_H__
     8.6  
     8.7 -/* Virtual addresses beyond this are inaccessible by guest OSes. */
     8.8 +/*
     8.9 + * Virtual addresses beyond this are not modifiable by guest OSes.
    8.10 + * The machine->physical mapping table starts at this address, read-only
    8.11 + * to all domains except DOM0.
    8.12 + */
    8.13  #define HYPERVISOR_VIRT_START (0xFC000000UL)
    8.14  
    8.15  typedef struct trap_info_st
     9.1 --- a/xen-2.4.16/include/xeno/config.h	Fri Jan 31 15:03:37 2003 +0000
     9.2 +++ b/xen-2.4.16/include/xeno/config.h	Mon Feb 03 16:33:53 2003 +0000
     9.3 @@ -41,12 +41,33 @@
     9.4  #define __cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
     9.5  #define ____cacheline_aligned __cacheline_aligned
     9.6  
     9.7 -/* 0-16MB is fixed monitor space. 0-52MB is direct-mapped at top of memory.*/
     9.8 +/*** Hypervisor owns top 64MB of virtual address space. ***/
     9.9 +#define HYPERVISOR_VIRT_START (0xFC000000UL)
    9.10 +
    9.11 +/*
    9.12 + * First 4MB are mapped read-only for all. It's for the machine->physical
    9.13 + * mapping table (MPT table). The following are virtual addresses.
    9.14 + */
    9.15 +#define READONLY_MPT_VIRT_START (HYPERVISOR_VIRT_START)
    9.16 +#define READONLY_MPT_VIRT_END   (READONLY_MPT_VIRT_START + (4*1024*1024))
    9.17 +/*
    9.18 + * Next 16MB is fixed monitor space, which is part of a 48MB direct-mapped
    9.19 + * memory region. The following are machine addresses.
    9.20 + */
    9.21  #define MAX_MONITOR_ADDRESS   (16*1024*1024)
    9.22  #define MAX_DMA_ADDRESS       (16*1024*1024)
    9.23 -#define MAX_DIRECTMAP_ADDRESS (52*1024*1024)
    9.24 +#define MAX_DIRECTMAP_ADDRESS (48*1024*1024)
    9.25 +/* And the virtual addresses for the direct-map region... */
    9.26 +#define DIRECTMAP_VIRT_START  (READONLY_MPT_VIRT_END)
    9.27 +#define DIRECTMAP_VIRT_END    (DIRECTMAP_VIRT_START + MAX_DIRECTMAP_ADDRESS)
    9.28 +#define MONITOR_VIRT_START    (DIRECTMAP_VIRT_START)
    9.29 +#define MONITOR_VIRT_END      (MONITOR_VIRT_START + MAX_MONITOR_ADDRESS)
    9.30 +#define RDWR_MPT_VIRT_START   (MONITOR_VIRT_END)
    9.31 +#define RDWR_MPT_VIRT_END     (RDWR_MPT_VIRT_START + (4*1024*1024))
    9.32 +#define FRAMETABLE_VIRT_START (RDWR_MPT_VIRT_END)
    9.33 +#define FRAMETABLE_VIRT_END   (DIRECTMAP_VIRT_END)
    9.34  /* Next 4MB of virtual address space used for per-domain mappings (eg. GDT). */
    9.35 -#define PERDOMAIN_VIRT_START  (PAGE_OFFSET + MAX_DIRECTMAP_ADDRESS)
    9.36 +#define PERDOMAIN_VIRT_START  (DIRECTMAP_VIRT_END)
    9.37  #define PERDOMAIN_VIRT_END    (PERDOMAIN_VIRT_START + (4*1024*1024))
    9.38  /* Penultimate 4MB of virtual address space used for domain page mappings. */
    9.39  #define MAPCACHE_VIRT_START   (PERDOMAIN_VIRT_END)