ia64/xen-unstable

changeset 12794:9787cb7262e8

[IA64] changed foreign domain page mapping semantic.

x86 foreign HVM domain page mapping semantic was changed to use gmfn
instead mfn. It applies to domains with auto_translated_mode enabled,
and all ia64 domains enable auto_translated_mode. This patch changes
ia64 foreign domain page mapping to use gmfn and fixes ia64 domU buidler.
However this patch breaks domain save/restore/dump-core.
They should also be fixed-up

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Tue Dec 05 10:59:32 2006 -0700 (2006-12-05)
parents 918ea03857b9
children 85b9711cb895
files linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c linux-2.6-xen-sparse/include/asm-ia64/hypercall.h tools/libxc/xc_linux_build.c xen/arch/ia64/xen/dom0_ops.c xen/arch/ia64/xen/mm.c xen/include/asm-ia64/mm.h xen/include/public/arch-ia64.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c	Tue Dec 05 10:01:15 2006 -0700
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c	Tue Dec 05 10:59:32 2006 -0700
     1.3 @@ -497,7 +497,7 @@ xen_ia64_privcmd_entry_mmap(struct vm_ar
     1.4  			    unsigned long addr,
     1.5  			    struct xen_ia64_privcmd_range* privcmd_range,
     1.6  			    int i,
     1.7 -			    unsigned long mfn,
     1.8 +			    unsigned long gmfn,
     1.9  			    pgprot_t prot,
    1.10  			    domid_t domid)
    1.11  {
    1.12 @@ -506,7 +506,7 @@ xen_ia64_privcmd_entry_mmap(struct vm_ar
    1.13  	unsigned long gpfn;
    1.14  	unsigned long flags;
    1.15  
    1.16 -	if ((addr & ~PAGE_MASK) != 0 || mfn == INVALID_MFN) {
    1.17 +	if ((addr & ~PAGE_MASK) != 0 || gmfn == INVALID_MFN) {
    1.18  		error = -EINVAL;
    1.19  		goto out;
    1.20  	}
    1.21 @@ -521,7 +521,7 @@ xen_ia64_privcmd_entry_mmap(struct vm_ar
    1.22  	if (pgprot_val(prot) == PROT_READ) {
    1.23  		flags = ASSIGN_readonly;
    1.24  	}
    1.25 -	error = HYPERVISOR_add_physmap(gpfn, mfn, flags, domid);
    1.26 +	error = HYPERVISOR_add_physmap_with_gmfn(gpfn, gmfn, flags, domid);
    1.27  	if (error != 0) {
    1.28  		goto out;
    1.29  	}
    1.30 @@ -732,7 +732,7 @@ out_enomem0:
    1.31  int
    1.32  direct_remap_pfn_range(struct vm_area_struct *vma,
    1.33  		       unsigned long address,	// process virtual address
    1.34 -		       unsigned long mfn,	// mfn, mfn + 1, ... mfn + size/PAGE_SIZE
    1.35 +		       unsigned long gmfn,	// gmfn, gmfn + 1, ... gmfn + size/PAGE_SIZE
    1.36  		       unsigned long size,
    1.37  		       pgprot_t prot,
    1.38  		       domid_t  domid)		// target domain
    1.39 @@ -755,13 +755,13 @@ direct_remap_pfn_range(struct vm_area_st
    1.40  
    1.41  	i = (address - vma->vm_start) >> PAGE_SHIFT;
    1.42  	for (offset = 0; offset < size; offset += PAGE_SIZE) {
    1.43 -		error = xen_ia64_privcmd_entry_mmap(vma, (address + offset) & PAGE_MASK, privcmd_range, entry_offset + i, mfn, prot, domid);
    1.44 +		error = xen_ia64_privcmd_entry_mmap(vma, (address + offset) & PAGE_MASK, privcmd_range, entry_offset + i, gmfn, prot, domid);
    1.45  		if (error != 0) {
    1.46  			break;
    1.47  		}
    1.48  
    1.49  		i++;
    1.50 -		mfn++;
    1.51 +		gmfn++;
    1.52          }
    1.53  
    1.54  	return error;
     2.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Tue Dec 05 10:01:15 2006 -0700
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Tue Dec 05 10:59:32 2006 -0700
     2.3 @@ -387,6 +387,28 @@ HYPERVISOR_add_physmap(unsigned long gpf
     2.4  	return ret;
     2.5  }
     2.6  
     2.7 +static inline unsigned long
     2.8 +__HYPERVISOR_add_physmap_with_gmfn(unsigned long gpfn, unsigned long gmfn,
     2.9 +                                   unsigned long flags, domid_t domid)
    2.10 +{
    2.11 +	return _hypercall5(unsigned long, ia64_dom0vp_op,
    2.12 +	                   IA64_DOM0VP_add_physmap_with_gmfn,
    2.13 +	                   gpfn, gmfn, flags, domid);
    2.14 +}
    2.15 +
    2.16 +static inline unsigned long
    2.17 +HYPERVISOR_add_physmap_with_gmfn(unsigned long gpfn, unsigned long gmfn,
    2.18 +				 unsigned long flags, domid_t domid)
    2.19 +{
    2.20 +	unsigned long ret = 0;
    2.21 +	BUG_ON(!is_running_on_xen());//XXX
    2.22 +	if (is_running_on_xen()) {
    2.23 +		ret = __HYPERVISOR_add_physmap_with_gmfn(gpfn, gmfn,
    2.24 +		                                         flags, domid);
    2.25 +	}
    2.26 +	return ret;
    2.27 +}
    2.28 +
    2.29  #ifdef CONFIG_XEN_IA64_EXPOSE_P2M
    2.30  static inline unsigned long
    2.31  HYPERVISOR_expose_p2m(unsigned long conv_start_gpfn,
     3.1 --- a/tools/libxc/xc_linux_build.c	Tue Dec 05 10:01:15 2006 -0700
     3.2 +++ b/tools/libxc/xc_linux_build.c	Tue Dec 05 10:59:32 2006 -0700
     3.3 @@ -481,7 +481,9 @@ static int setup_guest(int xc_handle,
     3.4      start_info_t *start_info;
     3.5      unsigned long start_info_mpa;
     3.6      struct xen_ia64_boot_param *bp;
     3.7 +#if 0 // see comment below
     3.8      shared_info_t *shared_info;
     3.9 +#endif
    3.10      int i;
    3.11      DECLARE_DOMCTL;
    3.12      int rc;
    3.13 @@ -553,8 +555,8 @@ static int setup_guest(int xc_handle,
    3.14      (load_funcs.loadimage)(image, image_size, xc_handle, dom,
    3.15                             page_array + start_page, &dsi);
    3.16  
    3.17 -    *store_mfn = page_array[nr_pages - 2];
    3.18 -    *console_mfn = page_array[nr_pages - 1];
    3.19 +    *store_mfn = page_array[nr_pages - 2]; //XXX
    3.20 +    *console_mfn = page_array[nr_pages - 1]; //XXX
    3.21      IPRINTF("start_info: 0x%lx at 0x%lx, "
    3.22             "store_mfn: 0x%lx at 0x%lx, "
    3.23             "console_mfn: 0x%lx at 0x%lx\n",
    3.24 @@ -593,6 +595,14 @@ static int setup_guest(int xc_handle,
    3.25      ctxt->user_regs.r28 = start_info_mpa + sizeof (start_info_t);
    3.26      munmap(start_info, PAGE_SIZE);
    3.27  
    3.28 +#if 0
    3.29 +    /*
    3.30 +     * XXX FIXME:
    3.31 +     * The follwoing initialization is done by XEN_DOMCTL_arch_setup as
    3.32 +     * work around.
    3.33 +     * Should XENMEM_add_to_physmap with XENMAPSPACE_shared_info be used?
    3.34 +     */
    3.35 +
    3.36      /* shared_info page starts its life empty. */
    3.37      shared_info = xc_map_foreign_range(
    3.38          xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
    3.39 @@ -605,7 +615,7 @@ static int setup_guest(int xc_handle,
    3.40      shared_info->arch.start_info_pfn = nr_pages - 3;
    3.41  
    3.42      munmap(shared_info, PAGE_SIZE);
    3.43 -
    3.44 +#endif
    3.45      free(page_array);
    3.46      return 0;
    3.47  
     4.1 --- a/xen/arch/ia64/xen/dom0_ops.c	Tue Dec 05 10:01:15 2006 -0700
     4.2 +++ b/xen/arch/ia64/xen/dom0_ops.c	Tue Dec 05 10:59:32 2006 -0700
     4.3 @@ -125,6 +125,19 @@ long arch_do_domctl(xen_domctl_t *op, XE
     4.4                      for_each_vcpu (d, v)
     4.5                          v->arch.breakimm = d->arch.breakimm;
     4.6                  }
     4.7 +#if 1
     4.8 +                /*
     4.9 +                 * XXX FIXME 
    4.10 +                 * see comment around shared_info in setup_guest() in 
    4.11 +                 * libxc/xc_linux_build.c
    4.12 +                 */
    4.13 +                {
    4.14 +                    int i;
    4.15 +                    d->shared_info->arch.start_info_pfn = ds->maxmem >> PAGE_SHIFT;
    4.16 +                    for_each_cpu(i)
    4.17 +                        d->shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
    4.18 +                }
    4.19 +#endif
    4.20              }
    4.21          }
    4.22  
    4.23 @@ -340,6 +353,10 @@ do_dom0vp_op(unsigned long cmd,
    4.24          ret = dom0vp_add_physmap(d, arg0, arg1, (unsigned int)arg2,
    4.25                                   (domid_t)arg3);
    4.26          break;
    4.27 +    case IA64_DOM0VP_add_physmap_with_gmfn:
    4.28 +        ret = dom0vp_add_physmap_with_gmfn(d, arg0, arg1, (unsigned int)arg2,
    4.29 +                                           (domid_t)arg3);
    4.30 +        break;
    4.31      case IA64_DOM0VP_expose_p2m:
    4.32          ret = dom0vp_expose_p2m(d, arg0, arg1, arg2, arg3);
    4.33          break;
     5.1 --- a/xen/arch/ia64/xen/mm.c	Tue Dec 05 10:01:15 2006 -0700
     5.2 +++ b/xen/arch/ia64/xen/mm.c	Tue Dec 05 10:59:32 2006 -0700
     5.3 @@ -1261,12 +1261,14 @@ dom0vp_zap_physmap(struct domain *d, uns
     5.4      return 0;
     5.5  }
     5.6  
     5.7 -unsigned long
     5.8 -dom0vp_add_physmap(struct domain* d, unsigned long gpfn, unsigned long mfn,
     5.9 -                   unsigned long flags, domid_t domid)
    5.10 +static unsigned long
    5.11 +__dom0vp_add_physmap(struct domain* d, unsigned long gpfn,
    5.12 +                     unsigned long mfn_or_gmfn,
    5.13 +                     unsigned long flags, domid_t domid, int is_gmfn)
    5.14  {
    5.15 -    int error = 0;
    5.16 +    int error = -EINVAL;
    5.17      struct domain* rd;
    5.18 +    unsigned long mfn;
    5.19  
    5.20      /* Not allowed by a domain.  */
    5.21      if (flags & (ASSIGN_nocache | ASSIGN_pgc_allocated))
    5.22 @@ -1283,22 +1285,26 @@ dom0vp_add_physmap(struct domain* d, uns
    5.23              break;
    5.24          default:
    5.25              gdprintk(XENLOG_INFO, "d 0x%p domid %d "
    5.26 -                    "pgfn 0x%lx mfn 0x%lx flags 0x%lx domid %d\n",
    5.27 -                    d, d->domain_id, gpfn, mfn, flags, domid);
    5.28 +                    "pgfn 0x%lx mfn_or_gmfn 0x%lx flags 0x%lx domid %d\n",
    5.29 +                    d, d->domain_id, gpfn, mfn_or_gmfn, flags, domid);
    5.30              return -ESRCH;
    5.31          }
    5.32          BUG_ON(rd == NULL);
    5.33          get_knownalive_domain(rd);
    5.34      }
    5.35  
    5.36 -    if (unlikely(rd == d || !mfn_valid(mfn))) {
    5.37 -        error = -EINVAL;
    5.38 +    if (unlikely(rd == d))
    5.39          goto out1;
    5.40 -    }
    5.41 -    if (unlikely(get_page(mfn_to_page(mfn), rd) == 0)) {
    5.42 -        error = -EINVAL;
    5.43 +    if (is_gmfn) {
    5.44 +        if (domid == DOMID_XEN || domid == DOMID_IO)
    5.45 +            goto out1;
    5.46 +        mfn = gmfn_to_mfn(rd, mfn_or_gmfn);
    5.47 +    } else 
    5.48 +        mfn = mfn_or_gmfn;
    5.49 +    if (unlikely(!mfn_valid(mfn) || get_page(mfn_to_page(mfn), rd) == 0))
    5.50          goto out1;
    5.51 -    }
    5.52 +
    5.53 +    error = 0;
    5.54      BUG_ON(page_get_owner(mfn_to_page(mfn)) == d &&
    5.55             get_gpfn_from_mfn(mfn) != INVALID_M2P_ENTRY);
    5.56      assign_domain_page_replace(d, gpfn << PAGE_SHIFT, mfn, flags);
    5.57 @@ -1309,6 +1315,21 @@ out1:
    5.58      return error;
    5.59  }
    5.60  
    5.61 +unsigned long
    5.62 +dom0vp_add_physmap(struct domain* d, unsigned long gpfn, unsigned long mfn,
    5.63 +                   unsigned long flags, domid_t domid)
    5.64 +{
    5.65 +    return __dom0vp_add_physmap(d, gpfn, mfn, flags, domid, 0);
    5.66 +}
    5.67 +
    5.68 +unsigned long
    5.69 +dom0vp_add_physmap_with_gmfn(struct domain* d, unsigned long gpfn,
    5.70 +                             unsigned long gmfn, unsigned long flags,
    5.71 +                             domid_t domid)
    5.72 +{
    5.73 +    return __dom0vp_add_physmap(d, gpfn, gmfn, flags, domid, 1);
    5.74 +}
    5.75 +
    5.76  #ifdef CONFIG_XEN_IA64_EXPOSE_P2M
    5.77  static struct page_info* p2m_pte_zero_page = NULL;
    5.78  
     6.1 --- a/xen/include/asm-ia64/mm.h	Tue Dec 05 10:01:15 2006 -0700
     6.2 +++ b/xen/include/asm-ia64/mm.h	Tue Dec 05 10:59:32 2006 -0700
     6.3 @@ -441,6 +441,7 @@ extern unsigned long ____lookup_domain_m
     6.4  extern unsigned long do_dom0vp_op(unsigned long cmd, unsigned long arg0, unsigned long arg1, unsigned long arg2, unsigned long arg3);
     6.5  extern unsigned long dom0vp_zap_physmap(struct domain *d, unsigned long gpfn, unsigned int extent_order);
     6.6  extern unsigned long dom0vp_add_physmap(struct domain* d, unsigned long gpfn, unsigned long mfn, unsigned long flags, domid_t domid);
     6.7 +extern unsigned long dom0vp_add_physmap_with_gmfn(struct domain* d, unsigned long gpfn, unsigned long gmfn, unsigned long flags, domid_t domid);
     6.8  #ifdef CONFIG_XEN_IA64_EXPOSE_P2M
     6.9  extern void expose_p2m_init(void);
    6.10  extern unsigned long dom0vp_expose_p2m(struct domain* d, unsigned long conv_start_gpfn, unsigned long assign_start_gpfn, unsigned long expose_size, unsigned long granule_pfn);
     7.1 --- a/xen/include/public/arch-ia64.h	Tue Dec 05 10:01:15 2006 -0700
     7.2 +++ b/xen/include/public/arch-ia64.h	Tue Dec 05 10:59:32 2006 -0700
     7.3 @@ -386,6 +386,9 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_conte
     7.4  /* xen perfmon */
     7.5  #define IA64_DOM0VP_perfmon             8
     7.6  
     7.7 +/* gmfn version of IA64_DOM0VP_add_physmap */
     7.8 +#define IA64_DOM0VP_add_physmap_with_gmfn       9
     7.9 +
    7.10  // flags for page assignement to pseudo physical address space
    7.11  #define _ASSIGN_readonly                0
    7.12  #define ASSIGN_readonly                 (1UL << _ASSIGN_readonly)