ia64/xen-unstable

changeset 116:c2ff58fce197

bitkeeper revision 1.22.1.3 (3e3fc1b6-8OCS9mBQJHT5qOSCxbykw)

Many files:
Cleaned up domain-builder interface. MPT entries are now initialised at build time.
author kaf24@labyrinth.cl.cam.ac.uk
date Tue Feb 04 13:35:50 2003 +0000 (2003-02-04)
parents 11615a0ad0f1
children 659cfa9656db
files xen-2.4.16/common/dom0_ops.c xen-2.4.16/common/domain.c xen-2.4.16/common/memory.c xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h xen-2.4.16/include/xeno/dom0_ops.h xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_memory.c xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_ops.h xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/hypervisor_defs.h
line diff
     1.1 --- a/xen-2.4.16/common/dom0_ops.c	Mon Feb 03 17:06:25 2003 +0000
     1.2 +++ b/xen-2.4.16/common/dom0_ops.c	Tue Feb 04 13:35:50 2003 +0000
     1.3 @@ -1,4 +1,3 @@
     1.4 -
     1.5  /******************************************************************************
     1.6   * dom0_ops.c
     1.7   * 
     1.8 @@ -143,13 +142,18 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     1.9      }
    1.10      break;
    1.11  
    1.12 -    case DOM0_MAPTASK:
    1.13 +    case DOM0_GETMEMLIST:
    1.14      {
    1.15 -        unsigned int dom = op.u.mapdomts.domain;
    1.16 -        
    1.17 -        op.u.mapdomts.ts_phy_addr = __pa(find_domain_by_id(dom));
    1.18 -        copy_to_user(u_dom0_op, &op, sizeof(op));
    1.19 +        int i;
    1.20 +        unsigned long pfn = op.u.getmemlist.start_pfn;
    1.21 +        unsigned long *buffer = op.u.getmemlist.buffer;
    1.22  
    1.23 +        for ( i = 0; i < op.u.getmemlist.num_pfns; i++ )
    1.24 +        {
    1.25 +            /* XXX We trust DOM0 to give us a safe buffer. XXX */
    1.26 +            *buffer++ = pfn;
    1.27 +            pfn = (frame_table + pfn)->next;
    1.28 +        }
    1.29      }
    1.30      break;
    1.31  
     2.1 --- a/xen-2.4.16/common/domain.c	Mon Feb 03 17:06:25 2003 +0000
     2.2 +++ b/xen-2.4.16/common/domain.c	Tue Feb 04 13:35:50 2003 +0000
     2.3 @@ -564,12 +564,10 @@ int setup_guestos(struct task_struct *p,
     2.4      unsigned long phys_l1tab, phys_l2tab;
     2.5      unsigned long cur_address, alloc_address;
     2.6      unsigned long virt_load_address, virt_stack_address, virt_shinfo_address;
     2.7 -    unsigned long virt_ftable_start, virt_ftable_end, ft_mapping;
     2.8      start_info_t  *virt_startinfo_address;
     2.9      unsigned long long time;
    2.10      unsigned long count;
    2.11      unsigned long alloc_index;
    2.12 -    unsigned long ft_pages;
    2.13      l2_pgentry_t *l2tab, *l2start;
    2.14      l1_pgentry_t *l1tab = NULL, *l1start = NULL;
    2.15      struct pfn_info *page = NULL;
    2.16 @@ -626,17 +624,13 @@ int setup_guestos(struct task_struct *p,
    2.17      p->mm.pagetable = mk_pagetable(phys_l2tab);
    2.18  
    2.19      /*
    2.20 -     * NB. The upper limit on this loop does one extra page + pages for frame
    2.21 -     * table. This is to make sure a pte exists when we want to map the
    2.22 -     * shared_info struct and frame table struct.
    2.23 +     * NB. The upper limit on this loop does one extra page. This is to make 
    2.24 +     * sure a pte exists when we want to map the shared_info struct.
    2.25       */
    2.26  
    2.27 -    ft_pages = frame_table_size >> PAGE_SHIFT;
    2.28      l2tab += l2_table_offset(virt_load_address);
    2.29      cur_address = p->pg_head << PAGE_SHIFT;
    2.30 -    for ( count  = 0;
    2.31 -          count < p->tot_pages + 1 + ft_pages;
    2.32 -          count++)
    2.33 +    for ( count = 0; count < p->tot_pages + 1; count++ )
    2.34      {
    2.35          if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) )
    2.36          {
    2.37 @@ -650,11 +644,13 @@ int setup_guestos(struct task_struct *p,
    2.38          }
    2.39          *l1tab++ = mk_l1_pgentry(cur_address|L1_PROT);
    2.40          
    2.41 -        if(count < p->tot_pages)
    2.42 +        if ( count < p->tot_pages )
    2.43          {
    2.44              page = frame_table + (cur_address >> PAGE_SHIFT);
    2.45              page->flags = dom | PGT_writeable_page;
    2.46              page->type_count = page->tot_count = 1;
    2.47 +            /* Set up the MPT entry. */
    2.48 +            machine_to_phys_mapping[cur_address >> PAGE_SHIFT] = count;
    2.49          }
    2.50  
    2.51          cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT;
    2.52 @@ -663,9 +659,8 @@ int setup_guestos(struct task_struct *p,
    2.53  
    2.54      /* pages that are part of page tables must be read only */
    2.55      cur_address = p->pg_head << PAGE_SHIFT;
    2.56 -    for(count = 0;
    2.57 -        count < alloc_index;
    2.58 -        count++){
    2.59 +    for ( count = 0; count < alloc_index; count++ ) 
    2.60 +    {
    2.61          cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT;
    2.62      }
    2.63  
    2.64 @@ -674,11 +669,11 @@ int setup_guestos(struct task_struct *p,
    2.65      l1start = l1tab = map_domain_mem(l2_pgentry_to_phys(*l2tab));
    2.66      l1tab += l1_table_offset(virt_load_address + (alloc_index << PAGE_SHIFT));
    2.67      l2tab++;
    2.68 -    for(count = alloc_index;
    2.69 -        count < p->tot_pages;
    2.70 -        count++){
    2.71 +    for ( count = alloc_index; count < p->tot_pages; count++ ) 
    2.72 +    {
    2.73          *l1tab++ = mk_l1_pgentry(l1_pgentry_val(*l1tab) & ~_PAGE_RW);
    2.74 -        if(!((unsigned long)l1tab & (PAGE_SIZE - 1))){
    2.75 +        if( !((unsigned long)l1tab & (PAGE_SIZE - 1)) )
    2.76 +        {
    2.77              unmap_domain_mem(l1start);
    2.78              l1start = l1tab = map_domain_mem(l2_pgentry_to_phys(*l2tab));
    2.79              l2tab++;
    2.80 @@ -709,21 +704,6 @@ int setup_guestos(struct task_struct *p,
    2.81      virt_startinfo_address = (start_info_t *)
    2.82          (virt_load_address + ((alloc_index - 1) << PAGE_SHIFT));
    2.83      virt_stack_address  = (unsigned long)virt_startinfo_address;
    2.84 -
    2.85 -    /* set up frame_table mapping */
    2.86 -    ft_mapping = (unsigned long)frame_table;
    2.87 -    virt_ftable_start = virt_shinfo_address + PAGE_SIZE; 
    2.88 -    virt_ftable_end = virt_ftable_start + frame_table_size;
    2.89 -    for(cur_address = virt_ftable_start;
    2.90 -        cur_address < virt_ftable_end;
    2.91 -        cur_address += PAGE_SIZE){
    2.92 -        l2tab = l2start + l2_table_offset(cur_address);
    2.93 -        l1start = l1tab = map_domain_mem(l2_pgentry_to_phys(*l2tab));
    2.94 -        l1tab += l1_table_offset(cur_address);
    2.95 -        *l1tab = mk_l1_pgentry(__pa(ft_mapping)|L1_PROT);
    2.96 -        unmap_domain_mem(l1start);
    2.97 -        ft_mapping += PAGE_SIZE;
    2.98 -    }
    2.99      
   2.100      unmap_domain_mem(l2start);
   2.101  
   2.102 @@ -745,7 +725,6 @@ int setup_guestos(struct task_struct *p,
   2.103      virt_startinfo_address->pt_base = virt_load_address + 
   2.104          ((p->tot_pages - 1) << PAGE_SHIFT); 
   2.105      virt_startinfo_address->phys_base = p->pg_head << PAGE_SHIFT;
   2.106 -    virt_startinfo_address->frame_table = virt_ftable_start;
   2.107  
   2.108      /* Add virtual network interfaces and point to them in startinfo. */
   2.109      while (params->num_vifs-- > 0) {
     3.1 --- a/xen-2.4.16/common/memory.c	Mon Feb 03 17:06:25 2003 +0000
     3.2 +++ b/xen-2.4.16/common/memory.c	Tue Feb 04 13:35:50 2003 +0000
     3.3 @@ -175,7 +175,7 @@
     3.4  #include <asm/uaccess.h>
     3.5  #include <asm/domain_page.h>
     3.6  
     3.7 -#if 0
     3.8 +#if 1
     3.9  #define MEM_LOG(_f, _a...) printk("DOM%d: (file=memory.c, line=%d) " _f "\n", current->domain, __LINE__, ## _a )
    3.10  #else
    3.11  #define MEM_LOG(_f, _a...) ((void)0)
    3.12 @@ -760,6 +760,11 @@ int do_process_page_updates_bh(page_upda
    3.13                      break;
    3.14                  }
    3.15              }
    3.16 +            else
    3.17 +            {
    3.18 +                MEM_LOG("Bad domain normal update (dom %d, pfn %ld)",
    3.19 +                        current->domain, pfn);
    3.20 +            }
    3.21              break;
    3.22  
    3.23          case PGREQ_MPT_UPDATE:
    3.24 @@ -767,6 +772,12 @@ int do_process_page_updates_bh(page_upda
    3.25              if ( DOMAIN_OKAY(page->flags) )
    3.26              {
    3.27                  machine_to_phys_mapping[pfn] = cur->val;
    3.28 +                err = 0;
    3.29 +            }
    3.30 +            else
    3.31 +            {
    3.32 +                MEM_LOG("Bad domain MPT update (dom %d, pfn %ld)",
    3.33 +                        current->domain, pfn);
    3.34              }
    3.35              break;
    3.36  
     4.1 --- a/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h	Mon Feb 03 17:06:25 2003 +0000
     4.2 +++ b/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h	Tue Feb 04 13:35:50 2003 +0000
     4.3 @@ -205,7 +205,6 @@ typedef struct start_info_st {
     4.4      net_ring_t *net_rings;
     4.5      int num_net_rings;
     4.6      blk_ring_t *blk_ring;         /* block io communication rings */
     4.7 -    unsigned long frame_table;
     4.8      unsigned char cmd_line[1];    /* variable-length */
     4.9  } start_info_t;
    4.10  
     5.1 --- a/xen-2.4.16/include/xeno/dom0_ops.h	Mon Feb 03 17:06:25 2003 +0000
     5.2 +++ b/xen-2.4.16/include/xeno/dom0_ops.h	Tue Feb 04 13:35:50 2003 +0000
     5.3 @@ -1,4 +1,3 @@
     5.4 -
     5.5  /******************************************************************************
     5.6   * dom0_ops.h
     5.7   * 
     5.8 @@ -12,7 +11,7 @@
     5.9  
    5.10  #define DOM0_NEWDOMAIN   0
    5.11  #define DOM0_KILLDOMAIN  1
    5.12 -#define DOM0_MAPTASK     2
    5.13 +#define DOM0_GETMEMLIST  2
    5.14  #define DOM0_STARTDOM    4
    5.15  
    5.16  #define MAX_CMD_LEN    256
    5.17 @@ -30,11 +29,12 @@ typedef struct dom0_killdomain_st
    5.18      unsigned int domain;
    5.19  } dom0_killdomain_t;
    5.20  
    5.21 -typedef struct dom0_map_ts
    5.22 +typedef struct dom0_getmemlist_st
    5.23  {
    5.24 -    unsigned int domain;
    5.25 -    unsigned long ts_phy_addr;
    5.26 -} dom0_tsmap_t;
    5.27 +    unsigned long start_pfn;
    5.28 +    unsigned long num_pfns;
    5.29 +    void *buffer;
    5.30 +} dom0_getmemlist_t;
    5.31  
    5.32  typedef struct domain_launch
    5.33  {
    5.34 @@ -56,7 +56,7 @@ typedef struct dom0_op_st
    5.35      {
    5.36          dom0_newdomain_t newdomain;
    5.37          dom0_killdomain_t killdomain;
    5.38 -        dom0_tsmap_t mapdomts;
    5.39 +        dom0_getmemlist_t getmemlist;
    5.40          dom_meminfo_t meminfo;
    5.41      }
    5.42      u;
     6.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c	Mon Feb 03 17:06:25 2003 +0000
     6.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c	Tue Feb 04 13:35:50 2003 +0000
     6.3 @@ -43,8 +43,6 @@
     6.4  
     6.5  #define MAP_DISCONT     1
     6.6  
     6.7 -frame_table_t * frame_table;
     6.8 -
     6.9  static struct proc_dir_entry *xeno_base;
    6.10  static struct proc_dir_entry *dom0_cmd_intf;
    6.11  static struct proc_dir_entry *proc_ft;
    6.12 @@ -238,8 +236,6 @@ out:
    6.13  
    6.14  static int __init init_module(void)
    6.15  {
    6.16 -    frame_table = (frame_table_t *)start_info.frame_table;
    6.17 -    
    6.18      /* xeno proc root setup */
    6.19      xeno_base = proc_mkdir(XENO_BASE, &proc_root); 
    6.20  
     7.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_memory.c	Mon Feb 03 17:06:25 2003 +0000
     7.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_memory.c	Tue Feb 04 13:35:50 2003 +0000
     7.3 @@ -1,4 +1,3 @@
     7.4 -
     7.5  #include <linux/slab.h>
     7.6  #include <linux/mm.h>
     7.7  #include <linux/mman.h>
     7.8 @@ -16,6 +15,7 @@
     7.9  #include <asm/mmu.h>
    7.10  
    7.11  #include "hypervisor_defs.h"
    7.12 +#include "dom0_ops.h"
    7.13  
    7.14  #define MAP_CONT    0
    7.15  #define MAP_DISCONT 1
    7.16 @@ -126,26 +126,36 @@ int direct_remap_page_range(unsigned lon
    7.17  int direct_remap_disc_page_range(unsigned long from, 
    7.18                  unsigned long first_pg, int tot_pages, pgprot_t prot)
    7.19  {
    7.20 -    frame_table_t * current_ft;
    7.21 -    unsigned long current_pfn;
    7.22 +    dom0_op_t dom0_op;
    7.23 +    unsigned long *pfns = get_free_page(GFP_KERNEL);
    7.24      unsigned long start = from;
    7.25 -    int count = 0;
    7.26 +    int pages, i;
    7.27  
    7.28 -    current_ft = frame_table + first_pg;
    7.29 -    current_pfn = first_pg; 
    7.30 -    while(count < tot_pages){
    7.31 -            if(direct_remap_page_range(start, current_pfn << PAGE_SHIFT, 
    7.32 -                PAGE_SIZE, prot))
    7.33 +    while ( tot_pages != 0 )
    7.34 +    {
    7.35 +        dom0_op.cmd = DOM0_GETMEMLIST;
    7.36 +        dom0_op.u.getmemlist.start_pfn = first_pg;
    7.37 +        pages = 1023;
    7.38 +        dom0_op.u.getmemlist.num_pfns = 1024;
    7.39 +        if ( tot_pages < 1024 )
    7.40 +            dom0_op.u.getmemlist.num_pfns = pages = tot_pages;
    7.41 +        dom0_op.u.getmemlist.buffer = pfns;
    7.42 +        (void)HYPERVISOR_dom0_op(&dom0_op);
    7.43 +        first_pg = pfns[1023]; 
    7.44 +
    7.45 +        for ( i = 0; i < pages; i++ )
    7.46 +        {
    7.47 +            if(direct_remap_page_range(start, pfns[i] << PAGE_SHIFT, 
    7.48 +                                       PAGE_SIZE, prot))
    7.49                  goto out;
    7.50              start += PAGE_SIZE;
    7.51 -            current_pfn = current_ft->next;
    7.52 -            current_ft = (frame_table_t *)(frame_table + current_pfn);
    7.53 -            count++;
    7.54 +            tot_pages--;
    7.55 +        }
    7.56      }
    7.57  
    7.58  out:
    7.59 -
    7.60 -    return tot_pages - count;
    7.61 +    free_page(pfns);
    7.62 +    return tot_pages;
    7.63  } 
    7.64             
    7.65  /* below functions replace standard sys_mmap and sys_munmap which are absolutely useless
    7.66 @@ -175,8 +185,8 @@ unsigned long direct_mmap(unsigned long 
    7.67      }
    7.68  
    7.69      /* add node on the list of directly mapped areas, make sure the
    7.70 -	 * list remains sorted.
    7.71 -	 */ 
    7.72 +     * list remains sorted.
    7.73 +     */ 
    7.74      dmmap = (direct_mmap_node_t *)kmalloc(sizeof(direct_mmap_node_t), GFP_KERNEL);
    7.75      dmmap->vm_start = addr;
    7.76      dmmap->vm_end = addr + size;
     8.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_ops.h	Mon Feb 03 17:06:25 2003 +0000
     8.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_ops.h	Tue Feb 04 13:35:50 2003 +0000
     8.3 @@ -8,7 +8,7 @@
     8.4  
     8.5  #define DOM0_NEWDOMAIN   0
     8.6  #define DOM0_KILLDOMAIN  1
     8.7 -#define DOM0_MAPTASK     2
     8.8 +#define DOM0_GETMEMLIST  2
     8.9  #define MAP_DOM_MEM      3
    8.10  #define DOM0_STARTDOM    4
    8.11  #define MAX_CMD          4
    8.12 @@ -28,11 +28,12 @@ typedef struct dom0_killdomain_st
    8.13      unsigned int domain;
    8.14  } dom0_killdomain_t;
    8.15  
    8.16 -typedef struct dom0_map_ts
    8.17 +typedef struct dom0_getmemlist_st
    8.18  {
    8.19 -    unsigned int domain;
    8.20 -    unsigned long ts_phy_addr;
    8.21 -} dom0_tsmap_t;
    8.22 +    unsigned long start_pfn;
    8.23 +    unsigned long num_pfns;
    8.24 +    void *buffer;
    8.25 +} dom0_getmemlist_t;
    8.26  
    8.27  typedef struct dom_mem 
    8.28  {
    8.29 @@ -62,7 +63,7 @@ typedef struct dom0_op_st
    8.30      {
    8.31          dom0_newdomain_t newdomain;
    8.32          dom0_killdomain_t killdomain;
    8.33 -        dom0_tsmap_t mapdomts;
    8.34 +        dom0_getmemlist_t getmemlist;
    8.35          dom_mem_t dommem;
    8.36          dom_meminfo_t meminfo;
    8.37      }
     9.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/hypervisor_defs.h	Mon Feb 03 17:06:25 2003 +0000
     9.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/hypervisor_defs.h	Tue Feb 04 13:35:50 2003 +0000
     9.3 @@ -10,18 +10,6 @@
     9.4   */
     9.5  
     9.6  
     9.7 -/* original version: xen-2.4.16/include/xeno/mm.h */
     9.8 -typedef struct pfn_info {
     9.9 -    struct list_head list;      /* ->mapping has some page lists. */
    9.10 -    unsigned long next;         /* used for threading pages belonging */
    9.11 -    unsigned long prev;         /* to same domain */
    9.12 -    unsigned long flags;        /* atomic flags. */
    9.13 -    unsigned long tot_count;    /* Total domain usage count. */
    9.14 -    unsigned long type_count;   /* pagetable/dir, or domain-writeable refs. */
    9.15 -} frame_table_t;
    9.16 -
    9.17 -extern frame_table_t * frame_table;
    9.18 -
    9.19  typedef struct proc_data {
    9.20      unsigned int domain;
    9.21      unsigned long map_size;