ia64/xen-unstable

changeset 10151:2cab08ac143b

[IA64] support DOMID_XEN and DOMID_IO of foreign domain page mapping

support of foreign domain page mapping of DOMID_XEN and DOMID_IO.
This patch is needed for xentrace and xenmon.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Wed May 24 10:39:55 2006 -0600 (2006-05-24)
parents 35f2341bfac8
children 40959bc0a269
files xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/xensetup.c xen/include/asm-ia64/domain.h xen/include/asm-ia64/mm.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Wed May 24 09:59:04 2006 -0600
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Wed May 24 10:39:55 2006 -0600
     1.3 @@ -80,6 +80,41 @@ void build_physmap_table(struct domain *
     1.4  static void try_to_clear_PGC_allocate(struct domain* d,
     1.5                                        struct page_info* page);
     1.6  
     1.7 +#ifdef CONFIG_XEN_IA64_DOM0_VP
     1.8 +static struct domain *dom_xen, *dom_io;
     1.9 +
    1.10 +// followings are stolen from arch_init_memory() @ xen/arch/x86/mm.c
    1.11 +void
    1.12 +alloc_dom_xen_and_dom_io(void)
    1.13 +{
    1.14 +    /*
    1.15 +     * Initialise our DOMID_XEN domain.
    1.16 +     * Any Xen-heap pages that we will allow to be mapped will have
    1.17 +     * their domain field set to dom_xen.
    1.18 +     */
    1.19 +    dom_xen = alloc_domain();
    1.20 +    BUG_ON(dom_xen == NULL);
    1.21 +    spin_lock_init(&dom_xen->page_alloc_lock);
    1.22 +    INIT_LIST_HEAD(&dom_xen->page_list);
    1.23 +    INIT_LIST_HEAD(&dom_xen->xenpage_list);
    1.24 +    atomic_set(&dom_xen->refcnt, 1);
    1.25 +    dom_xen->domain_id = DOMID_XEN;
    1.26 +
    1.27 +    /*
    1.28 +     * Initialise our DOMID_IO domain.
    1.29 +     * This domain owns I/O pages that are within the range of the page_info
    1.30 +     * array. Mappings occur at the priv of the caller.
    1.31 +     */
    1.32 +    dom_io = alloc_domain();
    1.33 +    BUG_ON(dom_io == NULL);
    1.34 +    spin_lock_init(&dom_io->page_alloc_lock);
    1.35 +    INIT_LIST_HEAD(&dom_io->page_list);
    1.36 +    INIT_LIST_HEAD(&dom_io->xenpage_list);
    1.37 +    atomic_set(&dom_io->refcnt, 1);
    1.38 +    dom_io->domain_id = DOMID_IO;
    1.39 +}
    1.40 +#endif
    1.41 +
    1.42  /* this belongs in include/asm, but there doesn't seem to be a suitable place */
    1.43  void arch_domain_destroy(struct domain *d)
    1.44  {
    1.45 @@ -612,6 +647,12 @@ share_xen_page_with_guest(struct page_in
    1.46      spin_unlock(&d->page_alloc_lock);
    1.47  }
    1.48  
    1.49 +void
    1.50 +share_xen_page_with_privileged_guests(struct page_info *page, int readonly)
    1.51 +{
    1.52 +    share_xen_page_with_guest(page, dom_xen, readonly);
    1.53 +}
    1.54 +
    1.55  //XXX !xxx_present() should be used instread of !xxx_none()?
    1.56  static pte_t*
    1.57  lookup_alloc_domain_pte(struct domain* d, unsigned long mpaddr)
    1.58 @@ -1166,9 +1207,24 @@ dom0vp_add_physmap(struct domain* d, uns
    1.59      struct domain* rd;
    1.60      rd = find_domain_by_id(domid);
    1.61      if (unlikely(rd == NULL)) {
    1.62 -        error = -EINVAL;
    1.63 -        goto out0;
    1.64 +        switch (domid) {
    1.65 +        case DOMID_XEN:
    1.66 +            rd = dom_xen;
    1.67 +            break;
    1.68 +        case DOMID_IO:
    1.69 +            rd = dom_io;
    1.70 +            break;
    1.71 +        default:
    1.72 +            DPRINTK("d 0x%p domid %d "
    1.73 +                    "pgfn 0x%lx mfn 0x%lx flags 0x%lx domid %d\n",
    1.74 +                    d, d->domain_id, gpfn, mfn, flags, domid);
    1.75 +            error = -ESRCH;
    1.76 +            goto out0;
    1.77 +        }
    1.78 +        BUG_ON(rd == NULL);
    1.79 +        get_knownalive_domain(rd);
    1.80      }
    1.81 +
    1.82      if (unlikely(rd == d)) {
    1.83          error = -EINVAL;
    1.84          goto out1;
     2.1 --- a/xen/arch/ia64/xen/xensetup.c	Wed May 24 09:59:04 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/xensetup.c	Wed May 24 10:39:55 2006 -0600
     2.3 @@ -337,6 +337,7 @@ printk("About to call scheduler_init()\n
     2.4      BUG_ON(idle_domain == NULL);
     2.5  
     2.6      late_setup_arch((char **) &cmdline);
     2.7 +    alloc_dom_xen_and_dom_io();
     2.8      setup_per_cpu_areas();
     2.9      mem_init();
    2.10  
     3.1 --- a/xen/include/asm-ia64/domain.h	Wed May 24 09:59:04 2006 -0600
     3.2 +++ b/xen/include/asm-ia64/domain.h	Wed May 24 10:39:55 2006 -0600
     3.3 @@ -118,11 +118,14 @@ void __assign_domain_page(struct domain 
     3.4  void assign_domain_page(struct domain *d, unsigned long mpaddr, unsigned long physaddr);
     3.5  void assign_domain_io_page(struct domain *d, unsigned long mpaddr, unsigned long flags);
     3.6  #ifdef CONFIG_XEN_IA64_DOM0_VP
     3.7 +void alloc_dom_xen_and_dom_io(void);
     3.8  unsigned long assign_domain_mmio_page(struct domain *d, unsigned long mpaddr, unsigned long size);
     3.9  unsigned long assign_domain_mach_page(struct domain *d, unsigned long mpaddr, unsigned long size);
    3.10  unsigned long do_dom0vp_op(unsigned long cmd, unsigned long arg0, unsigned long arg1, unsigned long arg2, unsigned long arg3);
    3.11  unsigned long dom0vp_zap_physmap(struct domain *d, unsigned long gpfn, unsigned int extent_order);
    3.12  unsigned long dom0vp_add_physmap(struct domain* d, unsigned long gpfn, unsigned long mfn, unsigned int flags, domid_t domid);
    3.13 +#else
    3.14 +#define alloc_dom_xen_and_dom_io()      do { } while (0)
    3.15  #endif
    3.16  
    3.17  #include <asm/uaccess.h> /* for KERNEL_DS */
     4.1 --- a/xen/include/asm-ia64/mm.h	Wed May 24 09:59:04 2006 -0600
     4.2 +++ b/xen/include/asm-ia64/mm.h	Wed May 24 10:39:55 2006 -0600
     4.3 @@ -132,7 +132,8 @@ static inline u32 pickle_domptr(struct d
     4.4  #define XENSHARE_readonly 1
     4.5  void share_xen_page_with_guest(struct page_info *page,
     4.6                                 struct domain *d, int readonly);
     4.7 -#define share_xen_page_with_privileged_guests(p, r) do { } while (0)
     4.8 +void share_xen_page_with_privileged_guests(struct page_info *page,
     4.9 +                                           int readonly);
    4.10  
    4.11  extern struct page_info *frame_table;
    4.12  extern unsigned long frame_table_size;