ia64/xen-unstable

changeset 118:73643659824d

bitkeeper revision 1.22.1.5 (3e3fdd804HE3wN54H1WWZNmL4_hwmg)

Many files:
XenoLinux now does proper physical-machine address conversion. phys_base has been removed from start_info.
author kaf24@labyrinth.cl.cam.ac.uk
date Tue Feb 04 15:34:24 2003 +0000 (2003-02-04)
parents 659cfa9656db
children 134b05519a54
files xen-2.4.16/common/domain.c xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h xenolinux-2.4.16-sparse/arch/xeno/kernel/head.S xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c xenolinux-2.4.16-sparse/arch/xeno/mm/fault.c xenolinux-2.4.16-sparse/arch/xeno/mm/hypervisor.c xenolinux-2.4.16-sparse/arch/xeno/mm/init.c xenolinux-2.4.16-sparse/include/asm-xeno/hypervisor.h xenolinux-2.4.16-sparse/include/asm-xeno/page.h
line diff
     1.1 --- a/xen-2.4.16/common/domain.c	Tue Feb 04 14:15:38 2003 +0000
     1.2 +++ b/xen-2.4.16/common/domain.c	Tue Feb 04 15:34:24 2003 +0000
     1.3 @@ -484,11 +484,6 @@ int final_setup_guestos(struct task_stru
     1.4      virt_startinfo_addr->shared_info = (shared_info_t *)meminfo->virt_shinfo_addr;
     1.5      virt_startinfo_addr->pt_base = meminfo->virt_load_addr + 
     1.6                      ((p->tot_pages - 1) << PAGE_SHIFT);
     1.7 -
     1.8 -    /* now, this is just temprorary before we switch to pseudo phys
     1.9 -     * addressing. this works only for contiguous chunks of memory!!!
    1.10 -     */
    1.11 -    virt_startinfo_addr->phys_base = p->pg_head << PAGE_SHIFT;
    1.12      
    1.13      /* Add virtual network interfaces and point to them in startinfo. */
    1.14      while (meminfo->num_vifs-- > 0) {
    1.15 @@ -737,7 +732,6 @@ int setup_guestos(struct task_struct *p,
    1.16          (shared_info_t *)virt_shinfo_address;
    1.17      virt_startinfo_address->pt_base = virt_load_address + 
    1.18          ((p->tot_pages - 1) << PAGE_SHIFT); 
    1.19 -    virt_startinfo_address->phys_base = p->pg_head << PAGE_SHIFT;
    1.20  
    1.21      /* Add virtual network interfaces and point to them in startinfo. */
    1.22      while (params->num_vifs-- > 0) {
     2.1 --- a/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h	Tue Feb 04 14:15:38 2003 +0000
     2.2 +++ b/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h	Tue Feb 04 15:34:24 2003 +0000
     2.3 @@ -16,6 +16,9 @@
     2.4   * to all domains except DOM0.
     2.5   */
     2.6  #define HYPERVISOR_VIRT_START (0xFC000000UL)
     2.7 +#ifndef machine_to_phys_mapping
     2.8 +#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
     2.9 +#endif
    2.10  
    2.11  typedef struct trap_info_st
    2.12  {
    2.13 @@ -198,8 +201,7 @@ typedef struct shared_info_st {
    2.14  typedef struct start_info_st {
    2.15      unsigned long nr_pages;       /* total pages allocated to this domain */
    2.16      shared_info_t *shared_info;   /* start address of shared info struct */
    2.17 -    unsigned long  pt_base;       /* address of page directory */
    2.18 -    unsigned long phys_base;
    2.19 +    unsigned long  pt_base;       /* VIRTUAL address of page directory */
    2.20      unsigned long mod_start;      /* start address of pre-loaded module */
    2.21      unsigned long mod_len;        /* size (bytes) of pre-loaded module */
    2.22      net_ring_t *net_rings;
     3.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/kernel/head.S	Tue Feb 04 14:15:38 2003 +0000
     3.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/kernel/head.S	Tue Feb 04 15:34:24 2003 +0000
     3.3 @@ -10,8 +10,8 @@
     3.4  
     3.5  /* Offsets in start_info structure */
     3.6  #define SHARED_INFO  4
     3.7 -#define MOD_START   16
     3.8 -#define MOD_LEN     20
     3.9 +#define MOD_START   12
    3.10 +#define MOD_LEN     16
    3.11                  
    3.12  startup_32:
    3.13          cld
     4.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c	Tue Feb 04 14:15:38 2003 +0000
     4.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c	Tue Feb 04 15:34:24 2003 +0000
     4.3 @@ -46,6 +46,8 @@
     4.4  
     4.5  shared_info_t *HYPERVISOR_shared_info;
     4.6  
     4.7 +unsigned long *phys_to_machine_mapping;
     4.8 +
     4.9  /*
    4.10   * Machine setup..
    4.11   */
    4.12 @@ -143,6 +145,7 @@ void __init setup_arch(char **cmdline_p)
    4.13  {
    4.14      unsigned long start_pfn, max_pfn, max_low_pfn;
    4.15      unsigned long bootmap_size;
    4.16 +    unsigned long i;
    4.17  
    4.18      extern void hypervisor_callback(void);
    4.19      extern void failsafe_callback(void);
    4.20 @@ -254,12 +257,24 @@ void __init setup_arch(char **cmdline_p)
    4.21          {
    4.22              unsigned long pgde = *pgd++;
    4.23              if ( !(pgde & 1) ) continue;
    4.24 -            pte = (pgde & PAGE_MASK) - start_info.phys_base;
    4.25 +            pte = machine_to_phys(pgde & PAGE_MASK);
    4.26              reserve_bootmem(pte, PAGE_SIZE);
    4.27          }
    4.28      }
    4.29      cur_pgd = init_mm.pgd = (pgd_t *)start_info.pt_base;
    4.30  
    4.31 +    /* Now initialise the physical->machine mapping table. */
    4.32 +    phys_to_machine_mapping = alloc_bootmem(max_pfn * sizeof(unsigned long));
    4.33 +    for ( i = 0; i < max_pfn; i++ )
    4.34 +    {
    4.35 +        unsigned long pgde, *ppte;
    4.36 +        unsigned long pfn = i + (PAGE_OFFSET >> PAGE_SHIFT);
    4.37 +        pgde = *((unsigned long *)start_info.pt_base + (pfn >> 10));
    4.38 +        ppte = (unsigned long *)machine_to_phys(pgde & PAGE_MASK) + (pfn&1023);
    4.39 +        phys_to_machine_mapping[i] = 
    4.40 +            (*(unsigned long *)__va(ppte)) >> PAGE_SHIFT;
    4.41 +    }
    4.42 +
    4.43  #ifdef CONFIG_BLK_DEV_INITRD
    4.44      if (start_info.mod_start) {
    4.45          if ((__pa(start_info.mod_start) + start_info.mod_len) <= 
     5.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/mm/fault.c	Tue Feb 04 14:15:38 2003 +0000
     5.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/mm/fault.c	Tue Feb 04 15:34:24 2003 +0000
     5.3 @@ -314,14 +314,14 @@ no_context:
     5.4  	printk(" printing eip:\n");
     5.5  	printk("%08lx\n", regs->eip);
     5.6          page = ((unsigned long *) cur_pgd)[address >> 22];
     5.7 -        printk(KERN_ALERT "*pde = %08lx(%08lx)\n", page, page - start_info.phys_base);
     5.8 +        printk(KERN_ALERT "*pde=%08lx(%08lx)\n", page, machine_to_phys(page));
     5.9          if (page & 1) {
    5.10                  page &= PAGE_MASK;
    5.11                  address &= 0x003ff000;
    5.12 -                page -= start_info.phys_base;
    5.13 +                page = machine_to_phys(page);
    5.14                  page = ((unsigned long *) __va(page))[address >> PAGE_SHIFT];
    5.15 -                printk(KERN_ALERT "*pte = %08lx(%08lx)\n", page, 
    5.16 -                       page - start_info.phys_base);
    5.17 +                printk(KERN_ALERT "*pte=%08lx(%08lx)\n", page, 
    5.18 +                       machine_to_phys(page));
    5.19          }
    5.20   	die("Oops", regs, error_code);
    5.21  	bust_spinlocks(0);
     6.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/mm/hypervisor.c	Tue Feb 04 14:15:38 2003 +0000
     6.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/mm/hypervisor.c	Tue Feb 04 15:34:24 2003 +0000
     6.3 @@ -31,7 +31,7 @@ static void DEBUG_allow_pt_reads(void)
     6.4          pte = update_debug_queue[i].ptep;
     6.5          if ( pte == NULL ) continue;
     6.6          update_debug_queue[i].ptep = NULL;
     6.7 -        update.ptr = __pa(pte) + start_info.phys_base;
     6.8 +        update.ptr = phys_to_machine(__pa(pte));
     6.9          update.val = update_debug_queue[i].pteval;
    6.10          HYPERVISOR_pt_update(&update, 1);
    6.11      }
    6.12 @@ -51,7 +51,7 @@ static void DEBUG_disallow_pt_read(unsig
    6.13      pgd = pgd_offset_k(va);
    6.14      pmd = pmd_offset(pgd, va);
    6.15      pte = pte_offset(pmd, va);
    6.16 -    update.ptr = __pa(pte) + start_info.phys_base;
    6.17 +    update.ptr = phys_to_machine(__pa(pte));
    6.18      pteval = *(unsigned long *)pte;
    6.19      update.val = pteval & ~_PAGE_PRESENT;
    6.20      HYPERVISOR_pt_update(&update, 1);
    6.21 @@ -100,21 +100,21 @@ void queue_l1_entry_update(unsigned long
    6.22  #if PT_UPDATE_DEBUG > 0
    6.23      DEBUG_disallow_pt_read(ptr);
    6.24  #endif
    6.25 -    update_queue[idx].ptr = ptr + start_info.phys_base;
    6.26 +    update_queue[idx].ptr = phys_to_machine(ptr);
    6.27      update_queue[idx].val = val;
    6.28      increment_index();
    6.29  }
    6.30  
    6.31  void queue_l2_entry_update(unsigned long ptr, unsigned long val)
    6.32  {
    6.33 -    update_queue[idx].ptr = ptr + start_info.phys_base;
    6.34 +    update_queue[idx].ptr = phys_to_machine(ptr);
    6.35      update_queue[idx].val = val;
    6.36      increment_index();
    6.37  }
    6.38  
    6.39  void queue_pt_switch(unsigned long ptr)
    6.40  {
    6.41 -    update_queue[idx].ptr  = ptr + start_info.phys_base;
    6.42 +    update_queue[idx].ptr  = phys_to_machine(ptr);
    6.43      update_queue[idx].ptr |= PGREQ_EXTENDED_COMMAND;
    6.44      update_queue[idx].val  = PGEXT_NEW_BASEPTR;
    6.45      increment_index();
    6.46 @@ -137,7 +137,7 @@ void queue_invlpg(unsigned long ptr)
    6.47  
    6.48  void queue_pgd_pin(unsigned long ptr)
    6.49  {
    6.50 -    update_queue[idx].ptr  = ptr + start_info.phys_base;
    6.51 +    update_queue[idx].ptr  = phys_to_machine(ptr);
    6.52      update_queue[idx].ptr |= PGREQ_EXTENDED_COMMAND;
    6.53      update_queue[idx].val  = PGEXT_PIN_L2_TABLE;
    6.54      increment_index();
    6.55 @@ -145,7 +145,7 @@ void queue_pgd_pin(unsigned long ptr)
    6.56  
    6.57  void queue_pgd_unpin(unsigned long ptr)
    6.58  {
    6.59 -    update_queue[idx].ptr  = ptr + start_info.phys_base;
    6.60 +    update_queue[idx].ptr  = phys_to_machine(ptr);
    6.61      update_queue[idx].ptr |= PGREQ_EXTENDED_COMMAND;
    6.62      update_queue[idx].val  = PGEXT_UNPIN_TABLE;
    6.63      increment_index();
    6.64 @@ -153,7 +153,7 @@ void queue_pgd_unpin(unsigned long ptr)
    6.65  
    6.66  void queue_pte_pin(unsigned long ptr)
    6.67  {
    6.68 -    update_queue[idx].ptr  = ptr + start_info.phys_base;
    6.69 +    update_queue[idx].ptr  = phys_to_machine(ptr);
    6.70      update_queue[idx].ptr |= PGREQ_EXTENDED_COMMAND;
    6.71      update_queue[idx].val  = PGEXT_PIN_L1_TABLE;
    6.72      increment_index();
    6.73 @@ -161,7 +161,7 @@ void queue_pte_pin(unsigned long ptr)
    6.74  
    6.75  void queue_pte_unpin(unsigned long ptr)
    6.76  {
    6.77 -    update_queue[idx].ptr  = ptr + start_info.phys_base;
    6.78 +    update_queue[idx].ptr  = phys_to_machine(ptr);
    6.79      update_queue[idx].ptr |= PGREQ_EXTENDED_COMMAND;
    6.80      update_queue[idx].val  = PGEXT_UNPIN_TABLE;
    6.81      increment_index();
     7.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/mm/init.c	Tue Feb 04 14:15:38 2003 +0000
     7.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/mm/init.c	Tue Feb 04 15:34:24 2003 +0000
     7.3 @@ -126,23 +126,23 @@ static inline void set_pte_phys (unsigne
     7.4  
     7.5  void __init paging_init(void)
     7.6  {
     7.7 +    unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
     7.8 +    unsigned int max_dma, high, low;
     7.9 +    
    7.10 +    max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
    7.11 +    low = max_low_pfn;
    7.12 +    high = highend_pfn;
    7.13 +    
    7.14 +    if (low < max_dma)
    7.15      {
    7.16 -        unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
    7.17 -        unsigned int max_dma, high, low;
    7.18 -
    7.19 -        max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
    7.20 -        low = max_low_pfn;
    7.21 -        high = highend_pfn;
    7.22 -
    7.23 -        if (low < max_dma)
    7.24 -            zones_size[ZONE_DMA] = low;
    7.25 -        else {
    7.26 -            zones_size[ZONE_DMA] = max_dma;
    7.27 -            zones_size[ZONE_NORMAL] = low - max_dma;
    7.28 -        }
    7.29 -        free_area_init(zones_size);
    7.30 +        zones_size[ZONE_DMA] = low;
    7.31      }
    7.32 -    return;
    7.33 +    else 
    7.34 +    {
    7.35 +        zones_size[ZONE_DMA] = max_dma;
    7.36 +        zones_size[ZONE_NORMAL] = low - max_dma;
    7.37 +    }
    7.38 +    free_area_init(zones_size);
    7.39  }
    7.40  
    7.41  
     8.1 --- a/xenolinux-2.4.16-sparse/include/asm-xeno/hypervisor.h	Tue Feb 04 14:15:38 2003 +0000
     8.2 +++ b/xenolinux-2.4.16-sparse/include/asm-xeno/hypervisor.h	Tue Feb 04 15:34:24 2003 +0000
     8.3 @@ -27,8 +27,8 @@ void do_hypervisor_callback(struct pt_re
     8.4  
     8.5  /* arch/xeno/mm/hypervisor.c */
     8.6  /*
     8.7 - * NB. ptr values should be fake-physical. 'vals' should be already
     8.8 - * fully adjusted (ie. for start_info.phys_base).
     8.9 + * NB. ptr values should be PHYSICAL, not MACHINE. 'vals' should be already
    8.10 + * be MACHINE addresses.
    8.11   */
    8.12  
    8.13  extern unsigned int pt_update_queue_idx;
    8.14 @@ -77,7 +77,7 @@ extern page_update_debug_t update_debug_
    8.15   update_debug_queue[pt_update_queue_idx].line = __LINE__;         \
    8.16   update_debug_queue[pt_update_queue_idx].file = __FILE__;         \
    8.17   printk("L1 %s %d: %08lx (%08lx -> %08lx)\n", __FILE__, __LINE__, \
    8.18 -        (_p)+start_info.phys_base, *(unsigned long *)__va(_p),    \
    8.19 +        phys_to_machine(_p), *(unsigned long *)__va(_p),          \
    8.20          (unsigned long)(_v));                                     \
    8.21   queue_l1_entry_update((_p),(_v));                                \
    8.22  })
    8.23 @@ -87,7 +87,7 @@ extern page_update_debug_t update_debug_
    8.24   update_debug_queue[pt_update_queue_idx].line = __LINE__;         \
    8.25   update_debug_queue[pt_update_queue_idx].file = __FILE__;         \
    8.26   printk("L2 %s %d: %08lx (%08lx -> %08lx)\n", __FILE__, __LINE__, \
    8.27 -        (_p)+start_info.phys_base, *(unsigned long *)__va(_p),    \
    8.28 +        phys_to_machine(_p), *(unsigned long *)__va(_p),          \
    8.29          (unsigned long)(_v));                                     \
    8.30   queue_l2_entry_update((_p),(_v));                                \
    8.31  })
     9.1 --- a/xenolinux-2.4.16-sparse/include/asm-xeno/page.h	Tue Feb 04 14:15:38 2003 +0000
     9.2 +++ b/xenolinux-2.4.16-sparse/include/asm-xeno/page.h	Tue Feb 04 15:34:24 2003 +0000
     9.3 @@ -34,6 +34,23 @@
     9.4  #define clear_user_page(page, vaddr)	clear_page(page)
     9.5  #define copy_user_page(to, from, vaddr)	copy_page(to, from)
     9.6  
     9.7 +/**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
     9.8 +extern unsigned long *phys_to_machine_mapping;
     9.9 +#define pfn_to_mfn(_pfn) (phys_to_machine_mapping[(_pfn)])
    9.10 +#define mfn_to_pfn(_mfn) (machine_to_phys_mapping[(_mfn)])
    9.11 +static inline unsigned long phys_to_machine(unsigned long phys)
    9.12 +{
    9.13 +    unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
    9.14 +    machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
    9.15 +    return machine;
    9.16 +}
    9.17 +static inline unsigned long machine_to_phys(unsigned long machine)
    9.18 +{
    9.19 +    unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT);
    9.20 +    phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
    9.21 +    return phys;
    9.22 +}
    9.23 +
    9.24  /*
    9.25   * These are used to make use of C type-checking..
    9.26   */
    9.27 @@ -49,7 +66,7 @@ typedef struct { unsigned long pgd; } pg
    9.28  static inline unsigned long pte_val(pte_t x)
    9.29  {
    9.30      unsigned long ret = x.pte_low;
    9.31 -    if ( (ret & 1) ) ret -= start_info.phys_base;
    9.32 +    if ( (ret & 1) ) ret = machine_to_phys(ret);
    9.33      return ret;
    9.34  }
    9.35  #endif
    9.36 @@ -60,7 +77,7 @@ typedef struct { unsigned long pgprot; }
    9.37  static inline unsigned long pmd_val(pmd_t x)
    9.38  {
    9.39      unsigned long ret = x.pmd;
    9.40 -    if ( (ret & 1) ) ret -= start_info.phys_base;
    9.41 +    if ( (ret & 1) ) ret = machine_to_phys(ret);
    9.42      return ret;
    9.43  }
    9.44  #define pgd_val(x)	({ BUG(); (unsigned long)0; })
    9.45 @@ -68,12 +85,12 @@ static inline unsigned long pmd_val(pmd_
    9.46  
    9.47  static inline pte_t __pte(unsigned long x)
    9.48  {
    9.49 -    if ( (x & 1) ) x += start_info.phys_base;
    9.50 +    if ( (x & 1) ) x = phys_to_machine(x);
    9.51      return ((pte_t) { (x) });
    9.52  }
    9.53  static inline pmd_t __pmd(unsigned long x)
    9.54  {
    9.55 -    if ( (x & 1) ) x += start_info.phys_base;
    9.56 +    if ( (x & 1) ) x = phys_to_machine(x);
    9.57      return ((pmd_t) { (x) });
    9.58  }
    9.59  #define __pgd(x) ({ BUG(); (pgprot_t) { 0 }; })