ia64/xen-unstable

changeset 99:2ca9cc27dbec

bitkeeper revision 1.17 (3e33c6c930lVm278ebyafgyZR0Wnvg)

domain building code
author bd240@boulderdash.cl.cam.ac.uk
date Sun Jan 26 11:30:17 2003 +0000 (2003-01-26)
parents 336647fd8f40
children d59292c8dcab
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/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
line diff
     1.1 --- a/xen-2.4.16/common/dom0_ops.c	Wed Jan 15 14:21:52 2003 +0000
     1.2 +++ b/xen-2.4.16/common/dom0_ops.c	Sun Jan 26 11:30:17 2003 +0000
     1.3 @@ -13,6 +13,7 @@
     1.4  #include <xeno/dom0_ops.h>
     1.5  #include <xeno/sched.h>
     1.6  #include <xeno/event.h>
     1.7 +#include <asm/domain_page.h>
     1.8  
     1.9  extern unsigned int alloc_new_dom_mem(struct task_struct *, unsigned int);
    1.10  
    1.11 @@ -30,6 +31,28 @@ static unsigned int get_domnr(void)
    1.12      return (dom_mask == ~0UL) ? 0 : ffz(dom_mask);
    1.13  }
    1.14  
    1.15 +static void build_page_list(struct task_struct *p)
    1.16 +{
    1.17 +    unsigned long * list;
    1.18 +    unsigned long curr;
    1.19 +    unsigned long page;
    1.20 +
    1.21 +    list = (unsigned long *)map_domain_mem(p->pg_head << PAGE_SHIFT);
    1.22 +    curr = p->pg_head;
    1.23 +    *list++ = p->pg_head;
    1.24 +    page = (frame_table + p->pg_head)->next;
    1.25 +    printk(KERN_ALERT "bd240 debug: list %lx, page num %lx\n", list, page);
    1.26 +    while(page != p->pg_head){
    1.27 +        if(!((unsigned long)list & (PAGE_SIZE-1))){
    1.28 +            printk(KERN_ALERT "bd240 debug: list %lx, page num %lx\n", list, page);
    1.29 +            curr = (frame_table + curr)->next;
    1.30 +            list = (unsigned long *)map_domain_mem(curr << PAGE_SHIFT);
    1.31 +        }
    1.32 +        *list++ = page;
    1.33 +        page = (frame_table + page)->next;
    1.34 +    }
    1.35 +}
    1.36 +    
    1.37  long do_dom0_op(dom0_op_t *u_dom0_op)
    1.38  {
    1.39      long ret = 0;
    1.40 @@ -80,7 +103,14 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.41                  ret = -1;
    1.42                  break;
    1.43              }
    1.44 +            build_page_list(p);
    1.45              ret = p->domain;
    1.46 +
    1.47 +            op.u.newdomain.domain = ret;
    1.48 +            op.u.newdomain.pg_head = p->pg_head;
    1.49 +            copy_to_user(u_dom0_op, &op, sizeof(op));
    1.50 +            printk(KERN_ALERT "bd240 debug: hyp dom0_ops: %lx, %d\n", op.u.newdomain.pg_head, op.u.newdomain.memory_kb);
    1.51 +
    1.52              break;
    1.53          }
    1.54  
     2.1 --- a/xen-2.4.16/common/domain.c	Wed Jan 15 14:21:52 2003 +0000
     2.2 +++ b/xen-2.4.16/common/domain.c	Sun Jan 26 11:30:17 2003 +0000
     2.3 @@ -17,6 +17,8 @@
     2.4  #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED)
     2.5  #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED|_PAGE_DIRTY)
     2.6  
     2.7 +extern int new_do_process_page_updates(page_update_request_t *, int);
     2.8 +
     2.9  extern int nr_mods;
    2.10  extern module_t *mod;
    2.11  extern unsigned char *cmdline;
    2.12 @@ -336,7 +338,7 @@ asmlinkage void schedule(void)
    2.13  }
    2.14  
    2.15  
    2.16 -static unsigned int alloc_new_dom_mem(struct task_struct *p, unsigned int kbytes)
    2.17 +unsigned int alloc_new_dom_mem(struct task_struct *p, unsigned int kbytes)
    2.18  {
    2.19      struct list_head *temp;
    2.20      struct pfn_info *pf, *pf_head;
    2.21 @@ -352,7 +354,6 @@ static unsigned int alloc_new_dom_mem(st
    2.22      
    2.23      /* allocate pages and build a thread through frame_table */
    2.24      temp = free_list.next;
    2.25 -    printk("bd240 debug: DOM%d requesting %d pages\n", p->domain, req_pages);
    2.26  
    2.27      /* allocate first page */
    2.28      pf = list_entry(temp, struct pfn_info, list);
    2.29 @@ -390,22 +391,51 @@ int final_setup_guestos(struct task_stru
    2.30      start_info_t * virt_startinfo_addr;
    2.31      unsigned long virt_stack_addr;
    2.32      unsigned long long time;
    2.33 +    unsigned long phys_l1tab, phys_l2tab;
    2.34 +    page_update_request_t * pgt_updates;
    2.35 +    unsigned long count;
    2.36      net_ring_t *net_ring;
    2.37 +    net_vif_t *net_vif;
    2.38      char *dst;    // temporary
    2.39      int i;        // temporary
    2.40  
    2.41 +    /* first of all, set up domain pagetables */
    2.42 +    pgt_updates = (page_update_request_t *)
    2.43 +        map_domain_mem(meminfo->pgt_update_arr);
    2.44 +    printk(KERN_ALERT "bd240 debug: update request starting virt %lx, phys %lx\n", pgt_updates, meminfo->pgt_update_arr);
    2.45 +    for(count = 0; count < meminfo->num_pgt_updates; count++){
    2.46 +        printk(KERN_ALERT "bd240 debug: update pair %lx, %lx\n", pgt_updates->ptr, pgt_updates->val); 
    2.47 +        new_do_process_page_updates(pgt_updates, 1);
    2.48 +        pgt_updates++;
    2.49 +        if(!((unsigned long)pgt_updates & (PAGE_SIZE-1))){
    2.50 +            pgt_updates--;
    2.51 +            pgt_updates = (page_update_request_t *)map_domain_mem(
    2.52 +                ((frame_table + ((unsigned long)pgt_updates >> 
    2.53 +                PAGE_SHIFT))->next) << PAGE_SHIFT);   
    2.54 +        }
    2.55 +    }
    2.56 +
    2.57      /* entries 0xe0000000 onwards in page table must contain hypervisor
    2.58       * mem mappings - set them up.
    2.59       */
    2.60 -    l2tab = (l2_pgentry_t *)__va(meminfo->l2_pgt_addr);
    2.61 +    phys_l2tab = meminfo->l2_pgt_addr;
    2.62 +    l2tab = map_domain_mem(phys_l2tab); 
    2.63      memcpy(l2tab + DOMAIN_ENTRIES_PER_L2_PAGETABLE, 
    2.64 -        ((l2_pgentry_t *)idle0_pg_table) + DOMAIN_ENTRIES_PER_L2_PAGETABLE, 
    2.65 -        (ENTRIES_PER_L2_PAGETABLE - DOMAIN_ENTRIES_PER_L2_PAGETABLE) * sizeof(l2_pgentry_t));
    2.66 -    p->mm.pagetable = mk_pagetable((unsigned long)l2tab);
    2.67 +        ((l2_pgentry_t *)idle_pg_table[p->processor]) + 
    2.68 +        DOMAIN_ENTRIES_PER_L2_PAGETABLE, 
    2.69 +        (ENTRIES_PER_L2_PAGETABLE - DOMAIN_ENTRIES_PER_L2_PAGETABLE) 
    2.70 +        * sizeof(l2_pgentry_t));
    2.71 +    l2tab[PERDOMAIN_VIRT_START >> L2_PAGETABLE_SHIFT] = 
    2.72 +        mk_l2_pgentry(__pa(p->mm.perdomain_pt) | PAGE_HYPERVISOR);
    2.73 +    p->mm.pagetable = mk_pagetable(phys_l2tab);
    2.74  
    2.75      /* map in the shared info structure */
    2.76 -    l2tab = pagetable_ptr(p->mm.pagetable) + l2_table_offset(meminfo->virt_shinfo_addr);
    2.77 -    l1tab = l2_pgentry_to_l1(*l2tab) + l1_table_offset(meminfo->virt_shinfo_addr);
    2.78 +    phys_l2tab = pagetable_val(p->mm.pagetable) + 
    2.79 +        (l2_table_offset(meminfo->virt_shinfo_addr) * sizeof(l2_pgentry_t));
    2.80 +    l2tab = map_domain_mem(phys_l2tab);
    2.81 +    phys_l1tab = l2_pgentry_to_phys(*l2tab) + 
    2.82 +        (l1_table_offset(meminfo->virt_shinfo_addr) * sizeof(l1_pgentry_t));
    2.83 +    l1tab = map_domain_mem(phys_l1tab);
    2.84      *l1tab = mk_l1_pgentry(__pa(p->shared_info) | L1_PROT);
    2.85  
    2.86      /* set up the shared info structure */
    2.87 @@ -422,9 +452,8 @@ int final_setup_guestos(struct task_stru
    2.88       * new domain. thus, temporarely install its pagetables.
    2.89       */
    2.90      __cli();
    2.91 -    __asm__ __volatile__ (
    2.92 -        "mov %%eax, %%cr3"
    2.93 -        : : "a" (__pa(pagetable_ptr(p->mm.pagetable))));
    2.94 +    __asm__ __volatile__ ( 
    2.95 +        "mov %%eax,%%cr3" : : "a" (pagetable_val(p->mm.pagetable)));
    2.96  
    2.97      memset(virt_startinfo_addr, 0, sizeof(virt_startinfo_addr));
    2.98      virt_startinfo_addr->nr_pages = p->tot_pages;
    2.99 @@ -439,26 +468,20 @@ int final_setup_guestos(struct task_stru
   2.100      
   2.101      /* Add virtual network interfaces and point to them in startinfo. */
   2.102      while (meminfo->num_vifs-- > 0) {
   2.103 -        net_ring = create_net_vif(p->domain);
   2.104 +        net_vif = create_net_vif(p->domain);
   2.105 +        net_ring = net_vif->net_ring;
   2.106          if (!net_ring) panic("no network ring!\n");
   2.107      }
   2.108 -    virt_startinfo_addr->net_rings = p->net_ring_base;
   2.109 +
   2.110 +/* XXX SMH: horrible hack to convert hypervisor VAs in SHIP to guest VAs  */
   2.111 +#define SH2G(_x) (meminfo->virt_shinfo_addr | (((unsigned long)(_x)) & 0xFFF))
   2.112 +
   2.113 +    virt_startinfo_addr->net_rings = (net_ring_t *)SH2G(p->net_ring_base); 
   2.114      virt_startinfo_addr->num_net_rings = p->num_net_vifs;
   2.115  
   2.116      /* Add block io interface */
   2.117 -    virt_startinfo_addr->blk_ring = p->blk_ring_base;
   2.118 +    virt_startinfo_addr->blk_ring = (blk_ring_t *)SH2G(p->blk_ring_base);
   2.119  
   2.120 -    /* i do not think this has to be done any more, temporary */
   2.121 -    /* We tell OS about any modules we were given. */
   2.122 -    if ( nr_mods > 1 )
   2.123 -    {
   2.124 -        virt_startinfo_addr->mod_start = 
   2.125 -            (mod[1].mod_start-mod[0].mod_start-12) + meminfo->virt_load_addr;
   2.126 -        virt_startinfo_addr->mod_len = 
   2.127 -            mod[nr_mods-1].mod_end - mod[1].mod_start;
   2.128 -    }
   2.129 -
   2.130 -    /* temporary, meminfo->cmd_line just needs to be copied info start info */
   2.131      dst = virt_startinfo_addr->cmd_line;
   2.132      if ( mod[0].string )
   2.133      {
   2.134 @@ -489,10 +512,10 @@ int final_setup_guestos(struct task_stru
   2.135  
   2.136      /* Reinstate the caller's page tables. */
   2.137      __asm__ __volatile__ (
   2.138 -        "mov %%eax,%%cr3"
   2.139 -        : : "a" (__pa(pagetable_ptr(current->mm.pagetable))));    
   2.140 +        "mov %%eax,%%cr3" : : "a" (pagetable_val(current->mm.pagetable)));    
   2.141      __sti();
   2.142  
   2.143 +
   2.144      new_thread(p, 
   2.145                 (unsigned long)meminfo->virt_load_addr, 
   2.146                 (unsigned long)virt_stack_addr, 
     3.1 --- a/xen-2.4.16/common/memory.c	Wed Jan 15 14:21:52 2003 +0000
     3.2 +++ b/xen-2.4.16/common/memory.c	Sun Jan 26 11:30:17 2003 +0000
     3.3 @@ -757,6 +757,11 @@ int do_process_page_updates(page_update_
     3.4  
     3.5          if ( err )
     3.6          {
     3.7 +            page = frame_table + (cur.ptr >> PAGE_SHIFT);
     3.8 +            printk(KERN_ALERT "bd240 debug: Update request %d\n", cur.ptr & (sizeof(l1_pgentry_t) - 1)); 
     3.9 +            printk(KERN_ALERT "bd240 debug: Update request %lx, %lx\n", cur.ptr, cur.val);
    3.10 +            printk(KERN_ALERT "bd240 debug: Page flags %lx\n", page->flags);
    3.11 +
    3.12              kill_domain_with_errmsg("Illegal page update request");
    3.13          }
    3.14  
    3.15 @@ -774,3 +779,116 @@ int do_process_page_updates(page_update_
    3.16      return(0);
    3.17  }
    3.18  
    3.19 +/* Apply updates to page table @pagetable_id within the current domain. */
    3.20 +int new_do_process_page_updates(page_update_request_t * cur, int count)
    3.21 +{
    3.22 +    unsigned long flags, pfn;
    3.23 +    struct pfn_info *page;
    3.24 +    int err = 0, i;
    3.25 +
    3.26 +    for ( i = 0; i < count; i++ )
    3.27 +    {
    3.28 +        pfn = cur->ptr >> PAGE_SHIFT;
    3.29 +        if ( pfn >= max_page )
    3.30 +        {
    3.31 +            MEM_LOG("Page out of range (%08lx > %08lx)", pfn, max_page);
    3.32 +            kill_domain_with_errmsg("Page update request out of range");
    3.33 +        }
    3.34 +
    3.35 +        err = 1;
    3.36 +
    3.37 +        /* Least significant bits of 'ptr' demux the operation type. */
    3.38 +        switch ( cur->ptr & (sizeof(l1_pgentry_t)-1) )
    3.39 +        {
    3.40 +
    3.41 +            /*
    3.42 +             * PGREQ_NORMAL: Normal update to any level of page table.
    3.43 +             */
    3.44 +        case PGREQ_NORMAL:
    3.45 +            page = frame_table + pfn;
    3.46 +            flags = page->flags;
    3.47 +            
    3.48 +            printk(KERN_ALERT "bd240 debug: normal update\n");
    3.49 +            
    3.50 +            if ( (flags & PG_domain_mask) == current->domain )
    3.51 +            {
    3.52 +                printk(KERN_ALERT "bd240 debug: normal update inside\n");
    3.53 +                switch ( (flags & PG_type_mask) )
    3.54 +                {
    3.55 +                case PGT_l1_page_table: 
    3.56 +                    err = mod_l1_entry(cur->ptr, mk_l1_pgentry(cur->val)); 
    3.57 +                    break;
    3.58 +                case PGT_l2_page_table: 
    3.59 +                    err = mod_l2_entry(cur->ptr, mk_l2_pgentry(cur->val)); 
    3.60 +                    break;
    3.61 +                default:
    3.62 +                    MEM_LOG("Update to non-pt page %08lx", cur->ptr);
    3.63 +                    break;
    3.64 +                }
    3.65 +            }
    3.66 +
    3.67 +            printk(KERN_ALERT "bd240 debug: normal update finish\n");
    3.68 +
    3.69 +            break;
    3.70 +
    3.71 +            /*
    3.72 +             * PGREQ_UNCHECKED_UPDATE: Make an unchecked update to a
    3.73 +             * bottom-level page-table entry.
    3.74 +             * Restrictions apply:
    3.75 +             *  1. Update only allowed by domain 0.
    3.76 +             *  2. Update must be to a level-1 pte belonging to dom0.
    3.77 +             */
    3.78 +        case PGREQ_UNCHECKED_UPDATE:
    3.79 +            cur->ptr &= ~(sizeof(l1_pgentry_t) - 1);
    3.80 +            page = frame_table + pfn;
    3.81 +            flags = page->flags;
    3.82 +            if ( (flags | current->domain) == PGT_l1_page_table )
    3.83 +            {
    3.84 +                
    3.85 +                *(unsigned long *)map_domain_mem(cur->ptr) = cur->val;
    3.86 +                err = 0;
    3.87 +            }
    3.88 +            else
    3.89 +            {
    3.90 +                MEM_LOG("UNCHECKED_UPDATE: Bad domain %d, or"
    3.91 +                        " bad pte type %08lx", current->domain, flags);
    3.92 +            }
    3.93 +            break;
    3.94 +
    3.95 +            /*
    3.96 +             * PGREQ_EXTENDED_COMMAND: Extended command is specified
    3.97 +             * in the least-siginificant bits of the 'value' field.
    3.98 +             */
    3.99 +        case PGREQ_EXTENDED_COMMAND:
   3.100 +            cur->ptr &= ~(sizeof(l1_pgentry_t) - 1);
   3.101 +            err = do_extended_command(cur->ptr, cur->val);
   3.102 +            break;
   3.103 +
   3.104 +        default:
   3.105 +            MEM_LOG("Invalid page update command %08lx", cur->ptr);
   3.106 +            break;
   3.107 +        }
   3.108 +
   3.109 +        if ( err )
   3.110 +        {
   3.111 +            page = frame_table + (cur->ptr >> PAGE_SHIFT);
   3.112 +            printk(KERN_ALERT "bd240 debug: Update request %lx\n", cur->ptr & (sizeof(l1_pgentry_t) - 1)); 
   3.113 +            printk(KERN_ALERT "bd240 debug: Update request %lx, %lx\n", cur->ptr, cur->val);
   3.114 +            printk(KERN_ALERT "bd240 debug: Page flags %lx\n", page->flags);
   3.115 +
   3.116 +            kill_domain_with_errmsg("Illegal page update request");
   3.117 +        }
   3.118 +
   3.119 +        cur++;
   3.120 +    }
   3.121 +
   3.122 +    if ( tlb_flush[smp_processor_id()] )
   3.123 +    {
   3.124 +        tlb_flush[smp_processor_id()] = 0;
   3.125 +        __asm__ __volatile__ (
   3.126 +            "movl %%eax,%%cr3" : : 
   3.127 +            "a" (pagetable_val(current->mm.pagetable)));
   3.128 +    }
   3.129 +
   3.130 +    return(0);
   3.131 +}
     4.1 --- a/xen-2.4.16/include/xeno/dom0_ops.h	Wed Jan 15 14:21:52 2003 +0000
     4.2 +++ b/xen-2.4.16/include/xeno/dom0_ops.h	Sun Jan 26 11:30:17 2003 +0000
     4.3 @@ -19,9 +19,10 @@
     4.4  
     4.5  typedef struct dom0_newdomain_st 
     4.6  {
     4.7 -    unsigned int memory_kb;
     4.8 +    unsigned int domain;    // return parameter
     4.9 +    unsigned int memory_kb; 
    4.10      unsigned int num_vifs;  // temporary
    4.11 -    unsigned int domain; 
    4.12 +    unsigned long pg_head;  // return parameter
    4.13  } dom0_newdomain_t;
    4.14  
    4.15  typedef struct dom0_killdomain_st
    4.16 @@ -37,11 +38,13 @@ typedef struct dom0_map_ts
    4.17  
    4.18  typedef struct domain_launch
    4.19  {
    4.20 -    unsigned long domain;
    4.21 +    unsigned int domain;
    4.22      unsigned long l2_pgt_addr;
    4.23      unsigned long virt_load_addr;
    4.24      unsigned long virt_shinfo_addr;
    4.25      unsigned long virt_startinfo_addr;
    4.26 +    unsigned long pgt_update_arr;
    4.27 +    unsigned long num_pgt_updates;
    4.28      unsigned int num_vifs;
    4.29      char cmd_line[MAX_CMD_LEN];
    4.30  } dom_meminfo_t;
     5.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c	Wed Jan 15 14:21:52 2003 +0000
     5.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c	Sun Jan 26 11:30:17 2003 +0000
     5.3 @@ -35,7 +35,7 @@
     5.4  #define XENO_BASE       "xeno"          // proc file name defs should be in separate .h
     5.5  #define DOM0_CMD_INTF   "dom0_cmd"
     5.6  #define DOM0_FT         "frame_table"
     5.7 -#define DOM0_NEWDOM     "new_dom_id"
     5.8 +#define DOM0_NEWDOM     "new_dom_data"
     5.9  
    5.10  #define MAX_LEN         16
    5.11  #define DOM_DIR         "dom"
    5.12 @@ -148,13 +148,13 @@ static void create_proc_dom_entries(int 
    5.13  static ssize_t dom_mem_write(struct file * file, const char * buff, 
    5.14  	size_t size , loff_t * off)
    5.15  {
    5.16 -    unsigned long addr;
    5.17 -    proc_memdata_t * mem_data = (proc_memdata_t *)((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
    5.18 +    dom_mem_t mem_data;
    5.19 +    
    5.20 +    copy_from_user(&mem_data, (dom_mem_t *)buff, sizeof(dom_mem_t));
    5.21      
    5.22 -    copy_from_user(&addr, (unsigned long *)buff, sizeof(addr));
    5.23 -    
    5.24 -    if(direct_disc_unmap(addr, mem_data->pfn, mem_data->tot_pages) == 0){
    5.25 -        return sizeof(addr);
    5.26 +    if(direct_disc_unmap(mem_data.vaddr, mem_data.start_pfn, 
    5.27 +        mem_data.tot_pages) == 0){
    5.28 +        return sizeof(sizeof(dom_mem_t));
    5.29      } else {
    5.30          return -1;
    5.31      }
    5.32 @@ -172,14 +172,10 @@ static ssize_t dom_mem_read(struct file 
    5.33      /* remap the range using xen specific routines */
    5.34  
    5.35      addr = direct_mmap(mem_data->pfn << PAGE_SHIFT, mem_data->tot_pages << PAGE_SHIFT, prot, 0, 0);
    5.36 -	printk(KERN_ALERT "bd240 debug: dom_mem_read: %lx, %lx @ %lx\n", mem_data->pfn << PAGE_SHIFT, mem_data->tot_pages << PAGE_SHIFT, addr);
    5.37  
    5.38      copy_to_user((unsigned long *)buff, &addr, sizeof(addr));
    5.39  
    5.40 -	printk(KERN_ALERT "bd240 debug: exiting dom_mem_read\n");
    5.41 -
    5.42      return sizeof(addr);
    5.43 -     
    5.44  }
    5.45  
    5.46  struct file_operations dom_mem_ops = {
    5.47 @@ -218,8 +214,6 @@ static int dom_map_mem(unsigned int dom,
    5.48                  memdata->tot_pages = tot_pages;
    5.49                  file->data = memdata;
    5.50  
    5.51 -				printk(KERN_ALERT "bd240 debug: cmd setup dom mem: %lx, %d\n", memdata->pfn, memdata->tot_pages);
    5.52 -
    5.53                  ret = 0;
    5.54                  break;
    5.55              }
    5.56 @@ -232,23 +226,33 @@ static int dom_map_mem(unsigned int dom,
    5.57      return ret;
    5.58  }
    5.59  
    5.60 -/* return dom id stored as data pointer to userspace */
    5.61 -static int dom_id_read_proc(char *page, char **start, off_t off,
    5.62 -                          int count, int *eof, void *data)
    5.63 +/* function used to retrieve data associated with new domain */
    5.64 +static ssize_t dom_data_read(struct file * file, char * buff, size_t size, loff_t * off)
    5.65  {
    5.66 -    char arg[16];
    5.67 -    sprintf(arg, "%d", (int)data);
    5.68 -    strcpy(page, arg);
    5.69 +    dom0_newdomain_t * dom_data = (dom0_newdomain_t *)
    5.70 +        ((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
    5.71 +
    5.72 +    copy_to_user((dom0_newdomain_t *)buff, dom_data, sizeof(dom0_newdomain_t));
    5.73 +
    5.74      remove_proc_entry(DOM0_NEWDOM, xeno_base);
    5.75 -    return sizeof(unsigned int);
    5.76 +
    5.77 +    kfree(dom_data);
    5.78 +
    5.79 +    return sizeof(dom0_newdomain_t);
    5.80  }
    5.81  
    5.82 +struct file_operations newdom_data_fops = {
    5.83 +    read:    dom_data_read,
    5.84 +};
    5.85 +
    5.86  static int cmd_write_proc(struct file *file, const char *buffer, 
    5.87                             u_long count, void *data)
    5.88  {
    5.89      dom0_op_t op;
    5.90      int ret = 0;
    5.91      struct proc_dir_entry * new_dom_id;
    5.92 +    dom0_newdomain_t * params;
    5.93 +
    5.94      
    5.95      copy_from_user(&op, buffer, sizeof(dom0_op_t));
    5.96  
    5.97 @@ -260,28 +264,38 @@ static int cmd_write_proc(struct file *f
    5.98  
    5.99      /* is the request intended for hypervisor? */
   5.100      if(op.cmd != MAP_DOM_MEM){
   5.101 +
   5.102          ret = HYPERVISOR_dom0_op(&op);
   5.103  
   5.104          /* if new domain created, create proc entries */
   5.105          if(op.cmd == DOM0_NEWDOMAIN){
   5.106              create_proc_dom_entries(ret);
   5.107  
   5.108 +            params = (dom0_newdomain_t *)kmalloc(sizeof(dom0_newdomain_t),
   5.109 +                GFP_KERNEL);
   5.110 +            params->memory_kb = op.u.newdomain.memory_kb;
   5.111 +            params->pg_head = op.u.newdomain.pg_head;
   5.112 +            params->num_vifs = op.u.newdomain.num_vifs;
   5.113 +            params->domain = op.u.newdomain.domain;
   5.114 +
   5.115 +            printk(KERN_ALERT "bd240 debug: cmd_write: %lx, %d, %d\n", params->pg_head, params->memory_kb, params->domain); 
   5.116 +
   5.117              /* now notify user space of the new domain's id */
   5.118              new_dom_id = create_proc_entry(DOM0_NEWDOM, 0600, xeno_base);
   5.119              if ( new_dom_id != NULL )
   5.120              {
   5.121                  new_dom_id->owner      = THIS_MODULE;
   5.122                  new_dom_id->nlink      = 1;
   5.123 -                new_dom_id->read_proc  = dom_id_read_proc; 
   5.124 -                new_dom_id->data       = (void *)ret; 
   5.125 +                new_dom_id->proc_fops  = &newdom_data_fops; 
   5.126 +                new_dom_id->data       = (void *)params; 
   5.127              }
   5.128  
   5.129          }
   5.130  
   5.131      } else {
   5.132  
   5.133 -        ret = dom_map_mem(op.u.reqdommem.domain, op.u.reqdommem.start_pfn, 
   5.134 -                        op.u.reqdommem.tot_pages); 
   5.135 +        ret = dom_map_mem(op.u.dommem.domain, op.u.dommem.start_pfn, 
   5.136 +                        op.u.dommem.tot_pages); 
   5.137      }
   5.138      
   5.139  out:
   5.140 @@ -324,7 +338,6 @@ struct file_operations ft_ops = {
   5.141  
   5.142  static int __init init_module(void)
   5.143  {
   5.144 -    
   5.145      frame_table = (frame_table_t *)start_info.frame_table;
   5.146      frame_table_len = start_info.frame_table_len;
   5.147      frame_table_pa = start_info.frame_table_pa;
     6.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_memory.c	Wed Jan 15 14:21:52 2003 +0000
     6.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_memory.c	Sun Jan 26 11:30:17 2003 +0000
     6.3 @@ -55,9 +55,6 @@ static inline void direct_remappte_range
     6.4  	do {
     6.5  		pte_t oldpage;
     6.6  		oldpage = ptep_get_and_clear(pte);
     6.7 -    /*    
     6.8 -		printk(KERN_ALERT "bd240 debug: %lx - %lx\n", pte, phys_addr);
     6.9 -	*/
    6.10   		direct_set_pte(pte, direct_mk_pte_phys(phys_addr, prot));
    6.11  
    6.12  		forget_pte(oldpage);
    6.13 @@ -184,10 +181,8 @@ unsigned long direct_mmap(unsigned long 
    6.14  	entry = find_direct(&current->mm->context.direct_list, addr);
    6.15  	if(entry != &current->mm->context.direct_list){
    6.16  		list_add_tail(&dmmap->list, entry);
    6.17 -		printk(KERN_ALERT "bd240 debug: added node %lx, size %lx in the middle\n", dmmap->vm_start, size);
    6.18  	} else {
    6.19      	list_add_tail(&dmmap->list, &current->mm->context.direct_list);
    6.20 -		printk(KERN_ALERT "bd240 debug: added node %lx, size %lx at tail\n", dmmap->vm_start, size);
    6.21  	}
    6.22  
    6.23      /* and perform the mapping */
    6.24 @@ -321,7 +316,6 @@ int direct_unmap(unsigned long addr, uns
    6.25          return -1;
    6.26  
    6.27      list_del(&node->list);
    6.28 -	printk(KERN_ALERT "bd240 debug: delisted %lx from dlist\n", node->vm_start);
    6.29      kfree(node);
    6.30  
    6.31      direct_zap_page_range(current->mm, addr, size);
    6.32 @@ -336,8 +330,6 @@ int direct_disc_unmap(unsigned long from
    6.33      struct list_head * curr;
    6.34      struct list_head * direct_list = &current->mm->context.direct_list;    
    6.35  
    6.36 -	printk(KERN_ALERT "bd240 debug: direct_disc_unmap\n");
    6.37 -
    6.38      curr = direct_list->next;
    6.39      while(curr != direct_list){
    6.40          node = list_entry(curr, direct_mmap_node_t, list);
    6.41 @@ -350,13 +342,9 @@ int direct_disc_unmap(unsigned long from
    6.42      if(curr == direct_list)
    6.43          return -1;
    6.44  
    6.45 -	printk(KERN_ALERT "bd240 debug: direct_disc_unmap, deleted from direct_list\n");
    6.46 -
    6.47      list_del(&node->list);
    6.48      kfree(node);
    6.49  
    6.50 -	printk(KERN_ALERT "bd240 debug: direct_disc_unmap, from %lx, tot_pages %lx\n", from, tot_pages);
    6.51 -
    6.52      while(count < tot_pages){
    6.53              direct_zap_page_range(current->mm, from, PAGE_SIZE);
    6.54              from += PAGE_SIZE;
     7.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_ops.h	Wed Jan 15 14:21:52 2003 +0000
     7.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_ops.h	Sun Jan 26 11:30:17 2003 +0000
     7.3 @@ -1,4 +1,3 @@
     7.4 -
     7.5  /******************************************************************************
     7.6   * dom0_ops.h
     7.7   * 
     7.8 @@ -18,9 +17,10 @@
     7.9  
    7.10  typedef struct dom0_newdomain_st
    7.11  {
    7.12 +    unsigned int domain;
    7.13      unsigned int memory_kb;
    7.14      unsigned int num_vifs;  // temporary
    7.15 -    unsigned int domain;    // return parameter
    7.16 +    unsigned long pg_head;  // return parameter
    7.17  } dom0_newdomain_t;
    7.18  
    7.19  typedef struct dom0_killdomain_st
    7.20 @@ -34,12 +34,13 @@ typedef struct dom0_map_ts
    7.21      unsigned long ts_phy_addr;
    7.22  } dom0_tsmap_t;
    7.23  
    7.24 -typedef struct dom_mem_req 
    7.25 +typedef struct dom_mem 
    7.26  {
    7.27      unsigned int domain;
    7.28 +    unsigned long vaddr;
    7.29      unsigned long start_pfn;
    7.30      int tot_pages;
    7.31 -} dom_mem_req_t;
    7.32 +} dom_mem_t;
    7.33  
    7.34  typedef struct domain_launch
    7.35  {
    7.36 @@ -48,6 +49,9 @@ typedef struct domain_launch
    7.37      unsigned long virt_load_addr;
    7.38      unsigned long virt_shinfo_addr;
    7.39      unsigned long virt_startinfo_addr;
    7.40 +    unsigned long pgt_update_arr;
    7.41 +    unsigned long num_pgt_updates;
    7.42 +    unsigned int num_vifs;
    7.43      char cmd_line[MAX_CMD_LEN];
    7.44  } dom_meminfo_t;
    7.45  
    7.46 @@ -59,7 +63,8 @@ typedef struct dom0_op_st
    7.47          dom0_newdomain_t newdomain;
    7.48          dom0_killdomain_t killdomain;
    7.49          dom0_tsmap_t mapdomts;
    7.50 -        dom_mem_req_t reqdommem;
    7.51 +        dom_mem_t dommem;
    7.52 +        dom_meminfo_t meminfo;
    7.53      }
    7.54      u;
    7.55  } dom0_op_t;