ia64/xen-unstable

changeset 115:11615a0ad0f1

bitkeeper revision 1.22.1.2 (3e3ea191XZbqn2wImmnYu75uh_kNuQ)

mm.h, hypervisor-if.h, memory.c, domain.c:
Added update interface for the MPT. DOM0 no longer has direct write privileges.
author kaf24@labyrinth.cl.cam.ac.uk
date Mon Feb 03 17:06:25 2003 +0000 (2003-02-03)
parents b46b05647a32
children c2ff58fce197
files 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/mm.h
line diff
     1.1 --- a/xen-2.4.16/common/domain.c	Mon Feb 03 16:33:53 2003 +0000
     1.2 +++ b/xen-2.4.16/common/domain.c	Mon Feb 03 17:06:25 2003 +0000
     1.3 @@ -625,9 +625,6 @@ int setup_guestos(struct task_struct *p,
     1.4      memset(l2tab, 0, DOMAIN_ENTRIES_PER_L2_PAGETABLE*sizeof(l2_pgentry_t));
     1.5      p->mm.pagetable = mk_pagetable(phys_l2tab);
     1.6  
     1.7 -    /* Domain 0 gets WRITE access to the read-only machine->physical table. */
     1.8 -    mk_l2_writeable(l2tab + (READONLY_MPT_VIRT_START >> L2_PAGETABLE_SHIFT));
     1.9 -
    1.10      /*
    1.11       * NB. The upper limit on this loop does one extra page + pages for frame
    1.12       * table. This is to make sure a pte exists when we want to map the
     2.1 --- a/xen-2.4.16/common/memory.c	Mon Feb 03 16:33:53 2003 +0000
     2.2 +++ b/xen-2.4.16/common/memory.c	Mon Feb 03 17:06:25 2003 +0000
     2.3 @@ -364,12 +364,6 @@ static int get_l2_table(unsigned long pa
     2.4                DOMAIN_ENTRIES_PER_L2_PAGETABLE] =
     2.5          mk_l2_pgentry(__pa(current->mm.perdomain_pt) | __PAGE_HYPERVISOR);
     2.6  
     2.7 -    /*
     2.8 -     * DOM0 has the MPT mapped as WRITABLE.
     2.9 -     * 'p_l2_entry' happens to be pointing at the right place at this point :-)
    2.10 -     */
    2.11 -    if ( current->domain == 0 ) mk_l2_writeable(p_l2_entry);
    2.12 -
    2.13   out:
    2.14      unmap_domain_mem(p_l2_entry);
    2.15      return ret;
    2.16 @@ -703,9 +697,11 @@ static int do_extended_command(unsigned 
    2.17      return err;
    2.18  }
    2.19  
    2.20 -/* functions to handle page table updates: upper half is invoked in case pt updates
    2.21 - * are requested by a domain and it invokes copy_from_user. bottom half is invoked
    2.22 - * both in case of domain downcall and domain building by hypervisor.
    2.23 +/*
    2.24 + * functions to handle page table updates: upper half is invoked in case pt
    2.25 + * updates are requested by a domain and it invokes copy_from_user. bottom half
    2.26 + * is invoked both in case of domain downcall and domain building by
    2.27 + * hypervisor.
    2.28   */
    2.29  page_update_request_t * do_process_page_updates_uh(page_update_request_t *updates,
    2.30      int count)
    2.31 @@ -742,7 +738,6 @@ int do_process_page_updates_bh(page_upda
    2.32          /* Least significant bits of 'ptr' demux the operation type. */
    2.33          switch ( cur->ptr & (sizeof(l1_pgentry_t)-1) )
    2.34          {
    2.35 -
    2.36              /*
    2.37               * PGREQ_NORMAL: Normal update to any level of page table.
    2.38               */
    2.39 @@ -765,7 +760,14 @@ int do_process_page_updates_bh(page_upda
    2.40                      break;
    2.41                  }
    2.42              }
    2.43 +            break;
    2.44  
    2.45 +        case PGREQ_MPT_UPDATE:
    2.46 +            page = frame_table + pfn;
    2.47 +            if ( DOMAIN_OKAY(page->flags) )
    2.48 +            {
    2.49 +                machine_to_phys_mapping[pfn] = cur->val;
    2.50 +            }
    2.51              break;
    2.52  
    2.53              /*
     3.1 --- a/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h	Mon Feb 03 16:33:53 2003 +0000
     3.2 +++ b/xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h	Mon Feb 03 17:06:25 2003 +0000
     3.3 @@ -36,8 +36,8 @@ typedef struct
     3.4   */
     3.5  /* A normal page-table update request. */
     3.6  #define PGREQ_NORMAL           0
     3.7 -/* Make an unchecked update to a base-level pte. */
     3.8 -#define PGREQ_UNCHECKED_UPDATE 1
     3.9 +/* Update an entry in the machine->physical mapping table. */
    3.10 +#define PGREQ_MPT_UPDATE       1
    3.11  /* An extended command. */
    3.12  #define PGREQ_EXTENDED_COMMAND 2
    3.13      unsigned long ptr, val; /* *ptr = val */
    3.14 @@ -50,6 +50,7 @@ typedef struct
    3.15  #define PGEXT_NEW_BASEPTR       5
    3.16  #define PGEXT_TLB_FLUSH         6
    3.17  #define PGEXT_INVLPG            7
    3.18 +#define PGEXT_
    3.19  #define PGEXT_CMD_MASK        255
    3.20  #define PGEXT_CMD_SHIFT         8
    3.21  } page_update_request_t;
     4.1 --- a/xen-2.4.16/include/xeno/mm.h	Mon Feb 03 16:33:53 2003 +0000
     4.2 +++ b/xen-2.4.16/include/xeno/mm.h	Mon Feb 03 17:06:25 2003 +0000
     4.3 @@ -114,6 +114,14 @@ extern unsigned int free_pfns;
     4.4  extern unsigned long max_page;
     4.5  void init_frametable(unsigned long nr_pages);
     4.6  
     4.7 +/*
     4.8 + * The MPT (machine->physical mapping table) is an array of word-sized
     4.9 + * values, indexed on machine frame number. It is expected that guest OSes
    4.10 + * will use it to store a "physical" frame number to give the appearance of
    4.11 + * contiguous (or near contiguous) physical memory.
    4.12 + */
    4.13 +#define machine_to_phys_mapping ((unsigned long *)RDWR_MPT_VIRT_START)
    4.14 +
    4.15  /* Part of the domain API. */
    4.16  int do_process_page_updates(page_update_request_t *updates, int count);
    4.17