ia64/xen-unstable

changeset 12976:a510c94ceaa3

[POWERPC] Merge in outstanding changes from xenppc-unstable.hg.
It's a long story, but basically a small divergence in xenppc-unstable meant a
large number of changesets couldn't be directly imported to xen-unstable, so
this changeset includes all of them.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Hollis Blanchard <hollisb@us.ibm.com>
date Tue Dec 12 09:56:06 2006 -0600 (2006-12-12)
parents 9d83185b4c37
children 749c399d73df
files config/powerpc64.mk extras/mini-os/arch/x86/setup.c tools/libaio/src/syscall-ppc.h tools/libxc/powerpc64/flatdevtree.c tools/libxc/powerpc64/flatdevtree.h tools/libxc/powerpc64/utils.c tools/libxc/powerpc64/xc_linux_build.c tools/libxc/powerpc64/xc_prose_build.c tools/libxc/xenctrl.h tools/libxc/xenguest.h tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/FlatDeviceTree.py tools/python/xen/xend/image.py xen/arch/powerpc/Makefile xen/arch/powerpc/domain.c xen/arch/powerpc/memory.c xen/arch/powerpc/mm.c xen/arch/powerpc/numa.c xen/arch/powerpc/ofd_fixup_memory.c xen/arch/powerpc/papr/xlate.c xen/arch/powerpc/powerpc64/ppc970.c xen/arch/powerpc/setup.c xen/arch/powerpc/shadow.c xen/arch/powerpc/smpboot.c xen/arch/powerpc/usercopy.c xen/common/Makefile xen/common/xencomm.c xen/include/asm-powerpc/acpi.h xen/include/asm-powerpc/config.h xen/include/asm-powerpc/domain.h xen/include/asm-powerpc/guest_access.h xen/include/asm-powerpc/mm.h xen/include/asm-powerpc/numa.h xen/include/asm-powerpc/page.h xen/include/asm-powerpc/smp.h xen/include/asm-powerpc/spinlock.h xen/include/xen/xencomm.h
line diff
     1.1 --- a/config/powerpc64.mk	Fri Dec 01 19:11:02 2006 -0500
     1.2 +++ b/config/powerpc64.mk	Tue Dec 12 09:56:06 2006 -0600
     1.3 @@ -1,5 +1,7 @@
     1.4  CONFIG_POWERPC := y
     1.5  CONFIG_POWERPC_$(XEN_OS) := y
     1.6  
     1.7 +CONFIG_XENCOMM := y
     1.8 +
     1.9  CFLAGS += -DELFSIZE=64
    1.10  LIBDIR := lib
     4.1 --- a/tools/libxc/powerpc64/flatdevtree.c	Fri Dec 01 19:11:02 2006 -0500
     4.2 +++ b/tools/libxc/powerpc64/flatdevtree.c	Tue Dec 12 09:56:06 2006 -0600
     4.3 @@ -220,6 +220,29 @@ void ft_add_rsvmap(struct ft_cxt *cxt, u
     4.4  	cxt->p_anchor = cxt->pres + 16;	/* over the terminator */
     4.5  }
     4.6  
     4.7 +int ft_set_rsvmap(void *bphp, int m, u64 physaddr, u64 size)
     4.8 +{
     4.9 +	const struct boot_param_header *bph = bphp;
    4.10 +	u64 *p_rsvmap = (u64 *)
    4.11 +		((char *)bph + be32_to_cpu(bph->off_mem_rsvmap));
    4.12 +	u32 i;
    4.13 +
    4.14 +	for (i = 0;; i++) {
    4.15 +		u64 addr, sz;
    4.16 +
    4.17 +		addr = be64_to_cpu(p_rsvmap[i * 2]);
    4.18 +		sz = be64_to_cpu(p_rsvmap[i * 2 + 1]);
    4.19 +		if (addr == 0 && size == 0)
    4.20 +			break;
    4.21 +		if (m == i) {
    4.22 +			p_rsvmap[i * 2] = cpu_to_be64(physaddr);
    4.23 +			p_rsvmap[i * 2 + 1] = cpu_to_be64(size);
    4.24 +			return 0;
    4.25 +		}
    4.26 +	}
    4.27 +	return -1;
    4.28 +}
    4.29 +
    4.30  void ft_begin_tree(struct ft_cxt *cxt)
    4.31  {
    4.32  	cxt->p_begin = cxt->p_anchor;
     5.1 --- a/tools/libxc/powerpc64/flatdevtree.h	Fri Dec 01 19:11:02 2006 -0500
     5.2 +++ b/tools/libxc/powerpc64/flatdevtree.h	Tue Dec 12 09:56:06 2006 -0600
     5.3 @@ -66,6 +66,7 @@ void ft_prop_str(struct ft_cxt *cxt, con
     5.4  void ft_prop_int(struct ft_cxt *cxt, const char *name, unsigned int val);
     5.5  void ft_begin(struct ft_cxt *cxt, void *blob, unsigned int max_size);
     5.6  void ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size);
     5.7 +int ft_set_rsvmap(void *bphp, int m, u64 physaddr, u64 size);
     5.8  
     5.9  void ft_dump_blob(const void *bphp);
    5.10  void ft_backtrack_node(struct ft_cxt *cxt);
     6.1 --- a/tools/libxc/powerpc64/utils.c	Fri Dec 01 19:11:02 2006 -0500
     6.2 +++ b/tools/libxc/powerpc64/utils.c	Tue Dec 12 09:56:06 2006 -0600
     6.3 @@ -77,7 +77,7 @@ int get_rma_page_array(int xc_handle, in
     6.4      /* We know that the RMA is machine contiguous so lets just get the
     6.5       * first MFN and fill the rest in ourselves */
     6.6      rc = xc_get_pfn_list(xc_handle, domid, *page_array, 1);
     6.7 -    if (rc != 1) {
     6.8 +    if (rc == -1) {
     6.9          perror("Could not get the page frame list");
    6.10          return -1;
    6.11      }
     7.1 --- a/tools/libxc/powerpc64/xc_linux_build.c	Fri Dec 01 19:11:02 2006 -0500
     7.2 +++ b/tools/libxc/powerpc64/xc_linux_build.c	Tue Dec 12 09:56:06 2006 -0600
     7.3 @@ -89,7 +89,7 @@ static int load_devtree(
     7.4      start_info_t *start_info __attribute__((unused)),
     7.5      unsigned long start_info_addr)
     7.6  {
     7.7 -    uint32_t start_info[4] = {0, start_info_addr, 0, 0x1000};
     7.8 +    uint32_t si[4] = {0, start_info_addr, 0, 0x1000};
     7.9      struct boot_param_header *header;
    7.10      void *chosen;
    7.11      void *xen;
    7.12 @@ -127,8 +127,14 @@ static int load_devtree(
    7.13          return rc;
    7.14      }
    7.15  
    7.16 +    rc = ft_set_rsvmap(devtree, 1, initrd_base, initrd_len);
    7.17 +    if (rc < 0) {
    7.18 +        DPRINTF("couldn't set initrd reservation\n");
    7.19 +        return ~0UL;
    7.20 +    }
    7.21 +
    7.22      /* start-info (XXX being removed soon) */
    7.23 -    rc = ft_set_prop(&devtree, xen, "start-info", start_info, sizeof(start_info));
    7.24 +    rc = ft_set_prop(&devtree, xen, "start-info", si, sizeof(si));
    7.25      if (rc < 0) {
    7.26          DPRINTF("couldn't set /xen/start-info\n");
    7.27          return rc;
    7.28 @@ -136,6 +142,15 @@ static int load_devtree(
    7.29  
    7.30      header = devtree;
    7.31      devtree_size = header->totalsize;
    7.32 +    {
    7.33 +        static const char dtb[] = "/tmp/xc_domU.dtb";
    7.34 +        int dfd = creat(dtb, 0666);
    7.35 +        if (dfd != -1) {
    7.36 +            write(dfd, devtree, devtree_size);
    7.37 +            close(dfd);
    7.38 +        } else
    7.39 +            DPRINTF("could not open(\"%s\")\n", dtb);
    7.40 +    }
    7.41  
    7.42      DPRINTF("copying device tree to 0x%lx[0x%x]\n", DEVTREE_ADDR, devtree_size);
    7.43      return install_image(xc_handle, domid, page_array, devtree, DEVTREE_ADDR,
    7.44 @@ -172,22 +187,35 @@ out:
    7.45  }
    7.46  
    7.47  static unsigned long create_start_info(
    7.48 -	start_info_t *start_info,
    7.49 +	void *devtree, start_info_t *start_info,
    7.50          unsigned int console_evtchn, unsigned int store_evtchn,
    7.51  	unsigned long nr_pages, unsigned long rma_pages)
    7.52  {
    7.53      unsigned long start_info_addr;
    7.54 +    uint64_t rma_top;
    7.55 +    int rc;
    7.56  
    7.57      memset(start_info, 0, sizeof(*start_info));
    7.58 -    snprintf(start_info->magic, sizeof(start_info->magic), "xen-%d.%d-powerpc64HV", 3, 0);
    7.59 +    snprintf(start_info->magic, sizeof(start_info->magic),
    7.60 +             "xen-%d.%d-powerpc64HV", 3, 0);
    7.61 +
    7.62 +    rma_top = rma_pages << PAGE_SHIFT;
    7.63 +    DPRINTF("RMA top = 0x%"PRIX64"\n", rma_top);
    7.64  
    7.65      start_info->nr_pages = nr_pages;
    7.66 -    start_info->shared_info = (nr_pages - 1) << PAGE_SHIFT;
    7.67 -    start_info->store_mfn = start_info->nr_pages - 2;
    7.68 +    start_info->shared_info = rma_top - PAGE_SIZE;
    7.69 +    start_info->store_mfn = (rma_top >> PAGE_SHIFT) - 2;
    7.70      start_info->store_evtchn = store_evtchn;
    7.71 -    start_info->console.domU.mfn = start_info->nr_pages - 3;
    7.72 +    start_info->console.domU.mfn = (rma_top >> PAGE_SHIFT) - 3;
    7.73      start_info->console.domU.evtchn = console_evtchn;
    7.74 -    start_info_addr = (start_info->nr_pages - 4) << PAGE_SHIFT;
    7.75 +    start_info_addr = rma_top - 4*PAGE_SIZE;
    7.76 +
    7.77 +    rc = ft_set_rsvmap(devtree, 0, start_info_addr, 4*PAGE_SIZE);
    7.78 +    if (rc < 0) {
    7.79 +        DPRINTF("couldn't set start_info reservation\n");
    7.80 +        return ~0UL;
    7.81 +    }
    7.82 +
    7.83  
    7.84      return start_info_addr;
    7.85  }
    7.86 @@ -201,6 +229,7 @@ static void free_page_array(xen_pfn_t *p
    7.87  
    7.88  int xc_linux_build(int xc_handle,
    7.89                     uint32_t domid,
    7.90 +                   unsigned int mem_mb,
    7.91                     const char *image_name,
    7.92                     const char *initrd_name,
    7.93                     const char *cmdline,
    7.94 @@ -226,8 +255,7 @@ int xc_linux_build(int xc_handle,
    7.95  
    7.96      DPRINTF("%s\n", __func__);
    7.97  
    7.98 -    DPRINTF("xc_get_tot_pages\n");
    7.99 -    nr_pages = xc_get_tot_pages(xc_handle, domid);
   7.100 +    nr_pages = mem_mb << (20 - PAGE_SHIFT);
   7.101      DPRINTF("nr_pages 0x%lx\n", nr_pages);
   7.102  
   7.103      rma_pages = get_rma_pages(devtree);
   7.104 @@ -258,7 +286,7 @@ int xc_linux_build(int xc_handle,
   7.105      }
   7.106  
   7.107      /* start_info stuff: about to be removed  */
   7.108 -    start_info_addr = create_start_info(&start_info, console_evtchn,
   7.109 +    start_info_addr = create_start_info(devtree, &start_info, console_evtchn,
   7.110                                          store_evtchn, nr_pages, rma_pages);
   7.111      *console_mfn = page_array[start_info.console.domU.mfn];
   7.112      *store_mfn = page_array[start_info.store_mfn];
     8.1 --- a/tools/libxc/powerpc64/xc_prose_build.c	Fri Dec 01 19:11:02 2006 -0500
     8.2 +++ b/tools/libxc/powerpc64/xc_prose_build.c	Tue Dec 12 09:56:06 2006 -0600
     8.3 @@ -230,6 +230,7 @@ static void free_page_array(xen_pfn_t *p
     8.4  
     8.5  int xc_prose_build(int xc_handle,
     8.6                     uint32_t domid,
     8.7 +                   unsigned int mem_mb,
     8.8                     const char *image_name,
     8.9                     const char *initrd_name,
    8.10                     const char *cmdline,
    8.11 @@ -257,8 +258,7 @@ int xc_prose_build(int xc_handle,
    8.12  
    8.13      DPRINTF("cmdline=%s\n", cmdline);
    8.14  
    8.15 -    DPRINTF("xc_get_tot_pages\n");
    8.16 -    nr_pages = xc_get_tot_pages(xc_handle, domid);
    8.17 +    nr_pages = mem_mb << (20 - PAGE_SHIFT);
    8.18      DPRINTF("nr_pages 0x%lx\n", nr_pages);
    8.19  
    8.20      rma_pages = get_rma_pages(devtree);
     9.1 --- a/tools/libxc/xenctrl.h	Fri Dec 01 19:11:02 2006 -0500
     9.2 +++ b/tools/libxc/xenctrl.h	Tue Dec 12 09:56:06 2006 -0600
     9.3 @@ -439,6 +439,10 @@ int xc_domain_memory_populate_physmap(in
     9.4                                        unsigned int address_bits,
     9.5                                        xen_pfn_t *extent_start);
     9.6  
     9.7 +int xc_alloc_real_mode_area(int xc_handle,
     9.8 +                            uint32_t domid,
     9.9 +                            unsigned int log);
    9.10 +
    9.11  int xc_domain_ioport_permission(int xc_handle,
    9.12                                  uint32_t domid,
    9.13                                  uint32_t first_port,
    10.1 --- a/tools/libxc/xenguest.h	Fri Dec 01 19:11:02 2006 -0500
    10.2 +++ b/tools/libxc/xenguest.h	Tue Dec 12 09:56:06 2006 -0600
    10.3 @@ -124,6 +124,7 @@ int xc_get_hvm_param(
    10.4  
    10.5  int xc_prose_build(int xc_handle,
    10.6                     uint32_t domid,
    10.7 +                   unsigned int mem_mb,
    10.8                     const char *image_name,
    10.9                     const char *ramdisk_name,
   10.10                     const char *cmdline,
    11.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Dec 01 19:11:02 2006 -0500
    11.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Tue Dec 12 09:56:06 2006 -0600
    11.3 @@ -809,6 +809,28 @@ static PyObject *pyxc_domain_memory_incr
    11.4      return zero;
    11.5  }
    11.6  
    11.7 +#ifdef __powerpc__
    11.8 +static PyObject *pyxc_alloc_real_mode_area(XcObject *self,
    11.9 +                                           PyObject *args,
   11.10 +                                           PyObject *kwds)
   11.11 +{
   11.12 +    uint32_t dom;
   11.13 +    unsigned int log;
   11.14 +
   11.15 +    static char *kwd_list[] = { "dom", "log", NULL };
   11.16 +
   11.17 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, 
   11.18 +                                      &dom, &log) )
   11.19 +        return NULL;
   11.20 +
   11.21 +    if ( xc_alloc_real_mode_area(self->xc_handle, dom, log) )
   11.22 +        return PyErr_SetFromErrno(xc_error);
   11.23 +
   11.24 +    Py_INCREF(zero);
   11.25 +    return zero;
   11.26 +}
   11.27 +#endif
   11.28 +
   11.29  static PyObject *pyxc_domain_ioport_permission(XcObject *self,
   11.30                                                 PyObject *args,
   11.31                                                 PyObject *kwds)
   11.32 @@ -1185,6 +1207,16 @@ static PyMethodDef pyxc_methods[] = {
   11.33        " mem_kb [long]: .\n"
   11.34        "Returns: [int] 0 on success; -1 on error.\n" },
   11.35  
   11.36 +#ifdef __powerpc__
   11.37 +    { "arch_alloc_real_mode_area", 
   11.38 +      (PyCFunction)pyxc_alloc_real_mode_area, 
   11.39 +      METH_VARARGS | METH_KEYWORDS, "\n"
   11.40 +      "Allocate a domain's real mode area.\n"
   11.41 +      " dom [int]: Identifier of domain.\n"
   11.42 +      " log [int]: Specifies the area's size.\n"
   11.43 +      "Returns: [int] 0 on success; -1 on error.\n" },
   11.44 +#endif
   11.45 +
   11.46      { "domain_ioport_permission",
   11.47        (PyCFunction)pyxc_domain_ioport_permission,
   11.48        METH_VARARGS | METH_KEYWORDS, "\n"
    12.1 --- a/tools/python/xen/xend/FlatDeviceTree.py	Fri Dec 01 19:11:02 2006 -0500
    12.2 +++ b/tools/python/xen/xend/FlatDeviceTree.py	Tue Dec 12 09:56:06 2006 -0600
    12.3 @@ -22,6 +22,10 @@ import sys
    12.4  import struct
    12.5  import stat
    12.6  import re
    12.7 +import glob
    12.8 +import math
    12.9 +
   12.10 +_host_devtree_root = '/proc/device-tree'
   12.11  
   12.12  _OF_DT_HEADER = int("d00dfeed", 16) # avoid signed/unsigned FutureWarning
   12.13  _OF_DT_BEGIN_NODE = 0x1
   12.14 @@ -33,8 +37,10 @@ def _bincat(seq, separator=''):
   12.15      '''Concatenate the contents of seq into a bytestream.'''
   12.16      strs = []
   12.17      for item in seq:
   12.18 -        if type(item) == type(0):
   12.19 +        if isinstance(item, int):
   12.20              strs.append(struct.pack(">I", item))
   12.21 +        elif isinstance(item, long):
   12.22 +            strs.append(struct.pack(">Q", item))
   12.23          else:
   12.24              try:
   12.25                  strs.append(item.to_bin())
   12.26 @@ -231,38 +237,51 @@ class Tree(_Node):
   12.27          header.totalsize = len(payload) + _alignup(len(header.to_bin()), 8)
   12.28          return _pad(header.to_bin(), 8) + payload
   12.29  
   12.30 -_host_devtree_root = '/proc/device-tree'
   12.31 -def _getprop(propname):
   12.32 -    '''Extract a property from the system's device tree.'''
   12.33 -    f = file(os.path.join(_host_devtree_root, propname), 'r')
   12.34 +def _readfile(fullpath):
   12.35 +    '''Return full contents of a file.'''
   12.36 +    f = file(fullpath, 'r')
   12.37      data = f.read()
   12.38      f.close()
   12.39      return data
   12.40  
   12.41 +def _find_first_cpu(dirpath):
   12.42 +    '''Find the first node of type 'cpu' in a directory tree.'''
   12.43 +    cpulist = glob.glob(os.path.join(dirpath, 'cpus', '*'))
   12.44 +    for node in cpulist:
   12.45 +        try:
   12.46 +            data = _readfile(os.path.join(node, 'device_type'))
   12.47 +        except IOError:
   12.48 +            continue
   12.49 +        if 'cpu' in data:
   12.50 +            return node
   12.51 +    raise IOError("couldn't find any CPU nodes under " + dirpath)
   12.52 +
   12.53  def _copynode(node, dirpath, propfilter):
   12.54 -    '''Extract all properties from a node in the system's device tree.'''
   12.55 +    '''Copy all properties and children nodes from a directory tree.'''
   12.56      dirents = os.listdir(dirpath)
   12.57      for dirent in dirents:
   12.58          fullpath = os.path.join(dirpath, dirent)
   12.59          st = os.lstat(fullpath)
   12.60          if stat.S_ISDIR(st.st_mode):
   12.61              child = node.addnode(dirent)
   12.62 -            _copytree(child, fullpath, propfilter)
   12.63 +            _copynode(child, fullpath, propfilter)
   12.64          elif stat.S_ISREG(st.st_mode) and propfilter(fullpath):
   12.65 -            node.addprop(dirent, _getprop(fullpath))
   12.66 -
   12.67 -def _copytree(node, dirpath, propfilter):
   12.68 -    path = os.path.join(_host_devtree_root, dirpath)
   12.69 -    _copynode(node, path, propfilter)
   12.70 +            node.addprop(dirent, _readfile(fullpath))
   12.71  
   12.72  def build(imghandler):
   12.73      '''Construct a device tree by combining the domain's configuration and
   12.74      the host's device tree.'''
   12.75      root = Tree()
   12.76  
   12.77 -    # 4 pages: start_info, console, store, shared_info
   12.78 +    # 1st reseravtion entry used for start_info, console, store, shared_info
   12.79      root.reserve(0x3ffc000, 0x4000)
   12.80  
   12.81 +    # 2nd reservation enrty used for initrd, later on when we load the
   12.82 +    # initrd we may fill this in with zeroes which signifies the end
   12.83 +    # of the reservation map.  So as to avoid adding a zero map now we
   12.84 +    # put some bogus yet sensible numbers here.
   12.85 +    root.reserve(0x1000000, 0x1000)
   12.86 +
   12.87      root.addprop('device_type', 'chrp-but-not-really\0')
   12.88      root.addprop('#size-cells', 2)
   12.89      root.addprop('#address-cells', 2)
   12.90 @@ -270,35 +289,52 @@ def build(imghandler):
   12.91      root.addprop('compatible', 'Momentum,Maple\0')
   12.92  
   12.93      xen = root.addnode('xen')
   12.94 -    xen.addprop('start-info', 0, 0x3ffc000, 0, 0x1000)
   12.95 +    xen.addprop('start-info', long(0x3ffc000), long(0x1000))
   12.96      xen.addprop('version', 'Xen-3.0-unstable\0')
   12.97 -    xen.addprop('reg', 0, imghandler.vm.domid, 0, 0)
   12.98 +    xen.addprop('reg', long(imghandler.vm.domid), long(0))
   12.99      xen.addprop('domain-name', imghandler.vm.getName() + '\0')
  12.100      xencons = xen.addnode('console')
  12.101      xencons.addprop('interrupts', 1, 0)
  12.102  
  12.103 -    # XXX split out RMA node
  12.104 -    mem = root.addnode('memory@0')
  12.105 +    # add memory nodes
  12.106      totalmem = imghandler.vm.getMemoryTarget() * 1024
  12.107 -    mem.addprop('reg', 0, 0, 0, totalmem)
  12.108 -    mem.addprop('device_type', 'memory\0')
  12.109 +    rma_log = 26 ### imghandler.vm.info.get('powerpc_rma_log')
  12.110 +    rma_bytes = 1 << rma_log
  12.111 +
  12.112 +    # RMA node
  12.113 +    rma = root.addnode('memory@0')
  12.114 +    rma.addprop('reg', long(0), long(rma_bytes))
  12.115 +    rma.addprop('device_type', 'memory\0')
  12.116  
  12.117 +    # all the rest in a single node
  12.118 +    remaining = totalmem - rma_bytes
  12.119 +    if remaining > 0:
  12.120 +        mem = root.addnode('memory@1')
  12.121 +        mem.addprop('reg', long(rma_bytes), long(remaining))
  12.122 +        mem.addprop('device_type', 'memory\0')
  12.123 +
  12.124 +    # add CPU nodes
  12.125      cpus = root.addnode('cpus')
  12.126      cpus.addprop('smp-enabled')
  12.127      cpus.addprop('#size-cells', 0)
  12.128      cpus.addprop('#address-cells', 1)
  12.129  
  12.130      # Copy all properties the system firmware gave us, except for 'linux,'
  12.131 -    # properties, from 'cpus/@0', once for every vcpu. Hopefully all cpus are
  12.132 -    # identical...
  12.133 +    # properties, from the first CPU node in the device tree. Do this once for
  12.134 +    # every vcpu. Hopefully all cpus are identical...
  12.135      cpu0 = None
  12.136 +    cpu0path = _find_first_cpu(_host_devtree_root)
  12.137      def _nolinuxprops(fullpath):
  12.138          return not os.path.basename(fullpath).startswith('linux,')
  12.139      for i in range(imghandler.vm.getVCpuCount()):
  12.140 -        cpu = cpus.addnode('PowerPC,970@0')
  12.141 -        _copytree(cpu, 'cpus/PowerPC,970@0', _nolinuxprops)
  12.142 -        # and then overwrite what we need to
  12.143 -        pft_size = imghandler.vm.info.get('pft-size', 0x14)
  12.144 +        # create new node and copy all properties
  12.145 +        cpu = cpus.addnode('PowerPC,970@%d' % i)
  12.146 +        _copynode(cpu, cpu0path, _nolinuxprops)
  12.147 +
  12.148 +        # overwrite what we need to
  12.149 +        shadow_mb = imghandler.vm.info.get('shadow_memory', 1)
  12.150 +        shadow_mb_log = int(math.log(shadow_mb, 2))
  12.151 +        pft_size = shadow_mb_log + 20
  12.152          cpu.setprop('ibm,pft-size', 0, pft_size)
  12.153  
  12.154          # set default CPU
  12.155 @@ -307,13 +343,13 @@ def build(imghandler):
  12.156  
  12.157      chosen = root.addnode('chosen')
  12.158      chosen.addprop('cpu', cpu0.get_phandle())
  12.159 -    chosen.addprop('memory', mem.get_phandle())
  12.160 +    chosen.addprop('memory', rma.get_phandle())
  12.161      chosen.addprop('linux,stdout-path', '/xen/console\0')
  12.162      chosen.addprop('interrupt-controller', xen.get_phandle())
  12.163      chosen.addprop('bootargs', imghandler.cmdline + '\0')
  12.164      # xc_linux_load.c will overwrite these 64-bit properties later
  12.165 -    chosen.addprop('linux,initrd-start', 0, 0)
  12.166 -    chosen.addprop('linux,initrd-end', 0, 0)
  12.167 +    chosen.addprop('linux,initrd-start', long(0))
  12.168 +    chosen.addprop('linux,initrd-end', long(0))
  12.169  
  12.170      if 1:
  12.171          f = file('/tmp/domU.dtb', 'w')
    13.1 --- a/tools/python/xen/xend/image.py	Fri Dec 01 19:11:02 2006 -0500
    13.2 +++ b/tools/python/xen/xend/image.py	Tue Dec 12 09:56:06 2006 -0600
    13.3 @@ -246,6 +246,15 @@ class PPC_LinuxImageHandler(LinuxImageHa
    13.4                                features       = self.vm.getFeatures(),
    13.5                                arch_args      = devtree.to_bin())
    13.6  
    13.7 +    def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb):
    13.8 +        """@param shadow_mem_kb The configured shadow memory, in KiB.
    13.9 +        @param maxmem_kb The configured maxmem, in KiB.
   13.10 +        @return The corresponding required amount of shadow memory, also in
   13.11 +        KiB.
   13.12 +        PowerPC currently uses "shadow memory" to refer to the hash table."""
   13.13 +        return max(maxmem_kb / 64, shadow_mem_kb)
   13.14 +
   13.15 +
   13.16  class PPC_ProseImageHandler(LinuxImageHandler):
   13.17  
   13.18      ostype = "prose"
   13.19 @@ -273,6 +282,7 @@ class PPC_ProseImageHandler(LinuxImageHa
   13.20          devtree = FlatDeviceTree.build(self)
   13.21  
   13.22          return xc.prose_build(dom            = self.vm.getDomid(),
   13.23 +                              memsize        = mem_mb,
   13.24                                image          = self.kernel,
   13.25                                store_evtchn   = store_evtchn,
   13.26                                console_evtchn = console_evtchn,
    14.1 --- a/xen/arch/powerpc/Makefile	Fri Dec 01 19:11:02 2006 -0500
    14.2 +++ b/xen/arch/powerpc/Makefile	Tue Dec 12 09:56:06 2006 -0600
    14.3 @@ -27,6 +27,7 @@ obj-y += memory.o
    14.4  obj-y += mm.o
    14.5  obj-y += mpic.o
    14.6  obj-y += mpic_init.o
    14.7 +obj-y += numa.o
    14.8  obj-y += of-devtree.o
    14.9  obj-y += of-devwalk.o
   14.10  obj-y += ofd_fixup.o
   14.11 @@ -36,6 +37,7 @@ obj-y += rtas.o
   14.12  obj-y += setup.o
   14.13  obj-y += shadow.o
   14.14  obj-y += smp.o
   14.15 +obj-y += smpboot.o
   14.16  obj-y += smp-tbsync.o
   14.17  obj-y += sysctl.o
   14.18  obj-y += time.o
   14.19 @@ -73,6 +75,7 @@ firmware_image.bin: firmware
   14.20  #
   14.21  irq.o: ../x86/irq.c
   14.22  physdev.o: ../x86/physdev.c
   14.23 +numa.o: ../x86/numa.c
   14.24  
   14.25  HDRS += $(wildcard *.h)
   14.26  
    15.1 --- a/xen/arch/powerpc/domain.c	Fri Dec 01 19:11:02 2006 -0500
    15.2 +++ b/xen/arch/powerpc/domain.c	Tue Dec 12 09:56:06 2006 -0600
    15.3 @@ -105,15 +105,15 @@ void arch_domain_destroy(struct domain *
    15.4  
    15.5  static void machine_fail(const char *s)
    15.6  {
    15.7 -    printf("%s failed, manual powercycle required!\n", s);
    15.8 +    printk("%s failed, manual powercycle required!\n", s);
    15.9      for (;;)
   15.10          sleep();
   15.11  }
   15.12 -
   15.13  void machine_halt(void)
   15.14  {
   15.15 +    printk("machine_halt called: spinning....\n");
   15.16      console_start_sync();
   15.17 -    printf("%s called\n", __func__);
   15.18 +    printk("%s called\n", __func__);
   15.19      rtas_halt();
   15.20  
   15.21      machine_fail(__func__);
   15.22 @@ -121,8 +121,9 @@ void machine_halt(void)
   15.23  
   15.24  void machine_restart(char * __unused)
   15.25  {
   15.26 +    printk("machine_restart called: spinning....\n");
   15.27      console_start_sync();
   15.28 -    printf("%s called\n", __func__);
   15.29 +    printk("%s called\n", __func__);
   15.30      rtas_reboot();
   15.31      machine_fail(__func__);
   15.32  }
    16.1 --- a/xen/arch/powerpc/memory.c	Fri Dec 01 19:11:02 2006 -0500
    16.2 +++ b/xen/arch/powerpc/memory.c	Tue Dec 12 09:56:06 2006 -0600
    16.3 @@ -20,6 +20,7 @@
    16.4   */
    16.5  #include <xen/sched.h>
    16.6  #include <xen/mm.h>
    16.7 +#include <xen/numa.h>
    16.8  #include "of-devtree.h"
    16.9  #include "oftree.h"
   16.10  #include "rtas.h"
   16.11 @@ -238,6 +239,9 @@ void memory_init(module_t *mod, int mcou
   16.12      DBG("total_pages: 0x%016lx\n", total_pages);
   16.13  
   16.14      init_frametable();
   16.15 +
   16.16 +    numa_initmem_init(0, max_page);
   16.17 +
   16.18      end_boot_allocator();
   16.19  
   16.20      /* Add memory between the beginning of the heap and the beginning
    17.1 --- a/xen/arch/powerpc/mm.c	Fri Dec 01 19:11:02 2006 -0500
    17.2 +++ b/xen/arch/powerpc/mm.c	Tue Dec 12 09:56:06 2006 -0600
    17.3 @@ -284,21 +284,21 @@ extern void copy_page(void *dp, void *sp
    17.4      }
    17.5  }
    17.6  
    17.7 +/* XXX should probably replace with faster data structure */
    17.8  static uint add_extent(struct domain *d, struct page_info *pg, uint order)
    17.9  {
   17.10      struct page_extents *pe;
   17.11  
   17.12      pe = xmalloc(struct page_extents);
   17.13      if (pe == NULL)
   17.14 -        return 0;
   17.15 +        return -ENOMEM;
   17.16  
   17.17      pe->pg = pg;
   17.18      pe->order = order;
   17.19 -    pe->pfn = page_to_mfn(pg);
   17.20  
   17.21      list_add_tail(&pe->pe_list, &d->arch.extent_list);
   17.22  
   17.23 -    return pe->pfn;
   17.24 +    return 0;
   17.25  }
   17.26  
   17.27  void free_extents(struct domain *d)
   17.28 @@ -337,7 +337,7 @@ uint allocate_extents(struct domain *d, 
   17.29          if (pg == NULL)
   17.30              return total_nrpages;
   17.31  
   17.32 -        if (add_extent(d, pg, ext_order) == 0) {
   17.33 +        if (add_extent(d, pg, ext_order) < 0) {
   17.34              free_domheap_pages(pg, ext_order);
   17.35              return total_nrpages;
   17.36          }
   17.37 @@ -390,6 +390,7 @@ int allocate_rma(struct domain *d, unsig
   17.38  
   17.39      return 0;
   17.40  }
   17.41 +
   17.42  void free_rma_check(struct page_info *page)
   17.43  {
   17.44      if (test_bit(_PGC_page_RMA, &page->count_info) &&
   17.45 @@ -397,7 +398,6 @@ void free_rma_check(struct page_info *pa
   17.46          panic("Attempt to free an RMA page: 0x%lx\n", page_to_mfn(page));
   17.47  }
   17.48  
   17.49 -
   17.50  ulong pfn2mfn(struct domain *d, ulong pfn, int *type)
   17.51  {
   17.52      ulong rma_base_mfn = page_to_mfn(d->arch.rma_page);
   17.53 @@ -415,8 +415,7 @@ ulong pfn2mfn(struct domain *d, ulong pf
   17.54          /* Its a grant table access */
   17.55          t = PFN_TYPE_GNTTAB;
   17.56          mfn = gnttab_shared_mfn(d, d->grant_table, (pfn - max_page));
   17.57 -    } else if (test_bit(_DOMF_privileged, &d->domain_flags) &&
   17.58 -               cpu_io_mfn(pfn)) {
   17.59 +    } else if (d->is_privileged && cpu_io_mfn(pfn)) {
   17.60          t = PFN_TYPE_IO;
   17.61          mfn = pfn;
   17.62      } else {
   17.63 @@ -424,14 +423,18 @@ ulong pfn2mfn(struct domain *d, ulong pf
   17.64              t = PFN_TYPE_RMA;
   17.65              mfn = pfn + rma_base_mfn;
   17.66          } else {
   17.67 -            list_for_each_entry (pe, &d->arch.extent_list, pe_list) {
   17.68 -                uint end_pfn = pe->pfn + (1 << pe->order);
   17.69 +            ulong cur_pfn = rma_size_mfn;
   17.70  
   17.71 -                if (pfn >= pe->pfn && pfn < end_pfn) {
   17.72 +            list_for_each_entry (pe, &d->arch.extent_list, pe_list) {
   17.73 +                uint pe_pages = 1UL << pe->order;
   17.74 +                uint end_pfn = cur_pfn + pe_pages;
   17.75 +
   17.76 +                if (pfn >= cur_pfn && pfn < end_pfn) {
   17.77                      t = PFN_TYPE_LOGICAL;
   17.78 -                    mfn = page_to_mfn(pe->pg) + (pfn - pe->pfn);
   17.79 +                    mfn = page_to_mfn(pe->pg) + (pfn - cur_pfn);
   17.80                      break;
   17.81                  }
   17.82 +                cur_pfn += pe_pages;
   17.83              }
   17.84          }
   17.85  #ifdef DEBUG
   17.86 @@ -492,8 +495,7 @@ unsigned long mfn_to_gmfn(struct domain 
   17.87          return max_page + (mfn - gnttab_mfn);
   17.88  
   17.89      /* IO? */
   17.90 -    if (test_bit(_DOMF_privileged, &d->domain_flags) &&
   17.91 -        cpu_io_mfn(mfn))
   17.92 +    if (d->is_privileged && cpu_io_mfn(mfn))
   17.93          return mfn;
   17.94  
   17.95      rma_mfn = page_to_mfn(d->arch.rma_page);
   17.96 @@ -530,3 +532,10 @@ void shadow_drop_references(
   17.97      struct domain *d, struct page_info *page)
   17.98  {
   17.99  }
  17.100 +
  17.101 +int arch_domain_add_extent(struct domain *d, struct page_info *page, int order)
  17.102 +{
  17.103 +    if (add_extent(d, page, order) < 0)
  17.104 +        return -ENOMEM;
  17.105 +    return 0;
  17.106 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/xen/arch/powerpc/numa.c	Tue Dec 12 09:56:06 2006 -0600
    18.3 @@ -0,0 +1,1 @@
    18.4 +#include "../x86/numa.c"
    19.1 --- a/xen/arch/powerpc/ofd_fixup_memory.c	Fri Dec 01 19:11:02 2006 -0500
    19.2 +++ b/xen/arch/powerpc/ofd_fixup_memory.c	Tue Dec 12 09:56:06 2006 -0600
    19.3 @@ -68,6 +68,8 @@ static ofdn_t ofd_memory_node_create(
    19.4      reg.sz = size;
    19.5      ofd_prop_add(m, n, "reg", &reg, sizeof (reg));
    19.6  
    19.7 +    printk("Dom0: %s: %016lx, %016lx\n", path, start, size);
    19.8 +
    19.9      return n;
   19.10  }
   19.11  
   19.12 @@ -86,17 +88,19 @@ static void ofd_memory_extent_nodes(void
   19.13      ulong size;
   19.14      ofdn_t n;
   19.15      struct page_extents *pe;
   19.16 +    ulong cur_pfn = 1UL << d->arch.rma_order;
   19.17  
   19.18 +    start = cur_pfn << PAGE_SHIFT;
   19.19 +    size = 0;
   19.20      list_for_each_entry (pe, &d->arch.extent_list, pe_list) {
   19.21  
   19.22 -        start = pe->pfn << PAGE_SHIFT;
   19.23 -        size = 1UL << (pe->order + PAGE_SHIFT);
   19.24 -
   19.25 -        n = ofd_memory_node_create(m, OFD_ROOT, "", memory, memory,
   19.26 -                                    start, size);
   19.27 -
   19.28 -        BUG_ON(n <= 0);
   19.29 +        size += 1UL << (pe->order + PAGE_SHIFT);
   19.30 +        if (pe->order != cpu_extent_order())
   19.31 +            panic("we don't handle this yet\n");
   19.32      }
   19.33 +    n = ofd_memory_node_create(m, OFD_ROOT, "", memory, memory,
   19.34 +                               start, size);
   19.35 +    BUG_ON(n <= 0);
   19.36  }
   19.37  
   19.38  void ofd_memory_props(void *m, struct domain *d)
    20.1 --- a/xen/arch/powerpc/papr/xlate.c	Fri Dec 01 19:11:02 2006 -0500
    20.2 +++ b/xen/arch/powerpc/papr/xlate.c	Tue Dec 12 09:56:06 2006 -0600
    20.3 @@ -178,7 +178,7 @@ long pte_enter(ulong flags, ulong ptex, 
    20.4          return H_Parameter;
    20.5      }
    20.6  
    20.7 -    if (mtype == PFN_TYPE_IO &&!test_bit(_DOMF_privileged, &d->domain_flags)) {
    20.8 +    if (mtype == PFN_TYPE_IO && !d->is_privileged) {
    20.9          /* only a privilaged dom can access outside IO space */
   20.10          DBG("%s: unprivileged access to physical page: 0x%lx\n",
   20.11              __func__, pfn);
    21.1 --- a/xen/arch/powerpc/powerpc64/ppc970.c	Fri Dec 01 19:11:02 2006 -0500
    21.2 +++ b/xen/arch/powerpc/powerpc64/ppc970.c	Tue Dec 12 09:56:06 2006 -0600
    21.3 @@ -193,8 +193,8 @@ void cpu_initialize(int cpuid)
    21.4      mtdec(timebase_freq);
    21.5      mthdec(timebase_freq);
    21.6  
    21.7 -    /* FIXME Do not set the NAP and DPM bits in HID0 until we have had a
    21.8 -     * chance to audit the safe halt and idle loop code. */
    21.9 +    /* FIXME Do not set the NAP bit in HID0 until we have had a chance
   21.10 +     * to audit the safe halt and idle loop code. */
   21.11      hid0.bits.nap = 0;      /* NAP */
   21.12      hid0.bits.dpm = 1;      /* Dynamic Power Management */
   21.13  
    22.1 --- a/xen/arch/powerpc/setup.c	Fri Dec 01 19:11:02 2006 -0500
    22.2 +++ b/xen/arch/powerpc/setup.c	Tue Dec 12 09:56:06 2006 -0600
    22.3 @@ -35,6 +35,7 @@
    22.4  #include <xen/gdbstub.h>
    22.5  #include <xen/symbols.h>
    22.6  #include <xen/keyhandler.h>
    22.7 +#include <xen/numa.h>
    22.8  #include <acm/acm_hooks.h>
    22.9  #include <public/version.h>
   22.10  #include <asm/mpic.h>
   22.11 @@ -77,10 +78,7 @@ ulong oftree_len;
   22.12  ulong oftree_end;
   22.13  
   22.14  uint cpu_hard_id[NR_CPUS] __initdata;
   22.15 -cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
   22.16 -cpumask_t cpu_online_map; /* missing ifdef in schedule.c */
   22.17  cpumask_t cpu_present_map;
   22.18 -cpumask_t cpu_possible_map;
   22.19  
   22.20  /* XXX get this from ISA node in device tree */
   22.21  char *vgabase;
   22.22 @@ -210,6 +208,15 @@ void startup_cpu_idle_loop(void)
   22.23      reset_stack_and_jump(idle_loop);
   22.24  }
   22.25  
   22.26 +/* The boot_pa is enough "parea" for the boot CPU to get thru
   22.27 + * initialization, it will ultimately get replaced later */
   22.28 +static __init void init_boot_cpu(void)
   22.29 +{
   22.30 +    static struct processor_area boot_pa;
   22.31 +    boot_pa.whoami = 0;
   22.32 +    parea = &boot_pa;
   22.33 +}    
   22.34 +
   22.35  static void init_parea(int cpuid)
   22.36  {
   22.37      /* Be careful not to shadow the global variable.  */
   22.38 @@ -250,6 +257,9 @@ static int kick_secondary_cpus(int maxcp
   22.39          /* wait for it */
   22.40          while (!cpu_online(cpuid))
   22.41              cpu_relax();
   22.42 +
   22.43 +        numa_set_node(cpuid, 0);
   22.44 +        numa_add_cpu(cpuid);
   22.45      }
   22.46  
   22.47      return 0;
   22.48 @@ -293,6 +303,9 @@ static void __init __start_xen(multiboot
   22.49      if ((mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0))
   22.50          cmdline_parse(__va((ulong)mbi->cmdline));
   22.51  
   22.52 +    /* we need to be able to identify this CPU early on */
   22.53 +    init_boot_cpu();
   22.54 +
   22.55      /* We initialise the serial devices very early so we can get debugging. */
   22.56      ns16550.io_base = 0x3f8;
   22.57      ns16550_init(0, &ns16550);
    23.1 --- a/xen/arch/powerpc/shadow.c	Fri Dec 01 19:11:02 2006 -0500
    23.2 +++ b/xen/arch/powerpc/shadow.c	Tue Dec 12 09:56:06 2006 -0600
    23.3 @@ -101,9 +101,6 @@ unsigned int shadow_set_allocation(struc
    23.4  
    23.5      addr = htab_alloc(d, order);
    23.6  
    23.7 -    printk("%s: ibm,fpt-size should be: 0x%x\n", __func__,
    23.8 -           d->arch.htab.log_num_ptes + LOG_PTE_SIZE);
    23.9 -
   23.10      if (addr == 0)
   23.11          return -ENOMEM;
   23.12  
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/xen/arch/powerpc/smpboot.c	Tue Dec 12 09:56:06 2006 -0600
    24.3 @@ -0,0 +1,29 @@
    24.4 +
    24.5 +#include <xen/config.h>
    24.6 +#include <xen/init.h>
    24.7 +#include <xen/types.h>
    24.8 +#include <xen/cpumask.h>
    24.9 +#include <asm/cache.h>
   24.10 +
   24.11 +/* representing HT siblings of each logical CPU */
   24.12 +cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
   24.13 +EXPORT_SYMBOL(cpu_sibling_map);
   24.14 +
   24.15 +/* representing HT and core siblings of each logical CPU */
   24.16 +cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
   24.17 +EXPORT_SYMBOL(cpu_core_map);
   24.18 +
   24.19 +/* bitmap of online cpus */
   24.20 +cpumask_t cpu_online_map __read_mostly;
   24.21 +EXPORT_SYMBOL(cpu_online_map);
   24.22 +
   24.23 +
   24.24 +#ifdef CONFIG_HOTPLUG_CPU
   24.25 +cpumask_t cpu_possible_map = CPU_MASK_ALL;
   24.26 +#else
   24.27 +cpumask_t cpu_possible_map;
   24.28 +#endif
   24.29 +EXPORT_SYMBOL(cpu_possible_map);
   24.30 +
   24.31 +u8 x86_cpu_to_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0xff };
   24.32 +EXPORT_SYMBOL(x86_cpu_to_apicid);
    25.1 --- a/xen/arch/powerpc/usercopy.c	Fri Dec 01 19:11:02 2006 -0500
    25.2 +++ b/xen/arch/powerpc/usercopy.c	Tue Dec 12 09:56:06 2006 -0600
    25.3 @@ -18,24 +18,14 @@
    25.4   * Authors: Hollis Blanchard <hollisb@us.ibm.com>
    25.5   */
    25.6  
    25.7 -#include <xen/config.h>
    25.8 -#include <xen/mm.h>
    25.9  #include <xen/sched.h>
   25.10 +#include <xen/lib.h>
   25.11  #include <asm/current.h>
   25.12 -#include <asm/uaccess.h>
   25.13 +#include <asm/page.h>
   25.14  #include <asm/debugger.h>
   25.15 -#include <public/xen.h>
   25.16 -#include <public/xencomm.h>
   25.17 -
   25.18 -#undef DEBUG
   25.19 -#ifdef DEBUG
   25.20 -static int xencomm_debug = 1; /* extremely verbose */
   25.21 -#else
   25.22 -#define xencomm_debug 0
   25.23 -#endif
   25.24  
   25.25  /* XXX need to return error, not panic, if domain passed a bad pointer */
   25.26 -static unsigned long paddr_to_maddr(unsigned long paddr)
   25.27 +unsigned long paddr_to_maddr(unsigned long paddr)
   25.28  {
   25.29      struct vcpu *v = get_current();
   25.30      struct domain *d = v->domain;
   25.31 @@ -58,208 +48,3 @@ static unsigned long paddr_to_maddr(unsi
   25.32  
   25.33      return pa;
   25.34  }
   25.35 -
   25.36 -/**
   25.37 - * xencomm_copy_from_guest: Copy a block of data from domain space.
   25.38 - * @to:   Machine address.
   25.39 - * @from: Physical address to a xencomm buffer descriptor.
   25.40 - * @n:    Number of bytes to copy.
   25.41 - * @skip: Number of bytes from the start to skip.
   25.42 - *
   25.43 - * Copy data from domain to hypervisor.
   25.44 - *
   25.45 - * Returns number of bytes that could not be copied.
   25.46 - * On success, this will be zero.
   25.47 - */
   25.48 -unsigned long
   25.49 -xencomm_copy_from_guest(void *to, const void *from, unsigned int n,
   25.50 -        unsigned int skip)
   25.51 -{
   25.52 -    struct xencomm_desc *desc;
   25.53 -    unsigned int from_pos = 0;
   25.54 -    unsigned int to_pos = 0;
   25.55 -    unsigned int i = 0;
   25.56 -
   25.57 -    /* first we need to access the descriptor */
   25.58 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)from);
   25.59 -    if (desc == NULL)
   25.60 -        return n;
   25.61 -
   25.62 -    if (desc->magic != XENCOMM_MAGIC) {
   25.63 -        printk("%s: error: %p magic was 0x%x\n",
   25.64 -               __func__, desc, desc->magic);
   25.65 -        return n;
   25.66 -    }
   25.67 -
   25.68 -    /* iterate through the descriptor, copying up to a page at a time */
   25.69 -    while ((to_pos < n) && (i < desc->nr_addrs)) {
   25.70 -        unsigned long src_paddr = desc->address[i];
   25.71 -        unsigned int pgoffset;
   25.72 -        unsigned int chunksz;
   25.73 -        unsigned int chunk_skip;
   25.74 -
   25.75 -        if (src_paddr == XENCOMM_INVALID) {
   25.76 -            i++;
   25.77 -            continue;
   25.78 -        }
   25.79 -
   25.80 -        pgoffset = src_paddr % PAGE_SIZE;
   25.81 -        chunksz = PAGE_SIZE - pgoffset;
   25.82 -
   25.83 -        chunk_skip = min(chunksz, skip);
   25.84 -        from_pos += chunk_skip;
   25.85 -        chunksz -= chunk_skip;
   25.86 -        skip -= chunk_skip;
   25.87 -
   25.88 -        if (skip == 0) {
   25.89 -            unsigned long src_maddr;
   25.90 -            unsigned long dest = (unsigned long)to + to_pos;
   25.91 -            unsigned int bytes = min(chunksz, n - to_pos);
   25.92 -
   25.93 -            src_maddr = paddr_to_maddr(src_paddr + chunk_skip);
   25.94 -            if (src_maddr == 0)
   25.95 -                return n - to_pos;
   25.96 -
   25.97 -            if (xencomm_debug)
   25.98 -                printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest);
   25.99 -            memcpy((void *)dest, (void *)src_maddr, bytes);
  25.100 -            from_pos += bytes;
  25.101 -            to_pos += bytes;
  25.102 -        }
  25.103 -
  25.104 -        i++;
  25.105 -    }
  25.106 -
  25.107 -    return n - to_pos;
  25.108 -}
  25.109 -
  25.110 -/**
  25.111 - * xencomm_copy_to_guest: Copy a block of data to domain space.
  25.112 - * @to:     Physical address to xencomm buffer descriptor.
  25.113 - * @from:   Machine address.
  25.114 - * @n:      Number of bytes to copy.
  25.115 - * @skip: Number of bytes from the start to skip.
  25.116 - *
  25.117 - * Copy data from hypervisor to domain.
  25.118 - *
  25.119 - * Returns number of bytes that could not be copied.
  25.120 - * On success, this will be zero.
  25.121 - */
  25.122 -unsigned long
  25.123 -xencomm_copy_to_guest(void *to, const void *from, unsigned int n,
  25.124 -        unsigned int skip)
  25.125 -{
  25.126 -    struct xencomm_desc *desc;
  25.127 -    unsigned int from_pos = 0;
  25.128 -    unsigned int to_pos = 0;
  25.129 -    unsigned int i = 0;
  25.130 -
  25.131 -    /* first we need to access the descriptor */
  25.132 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)to);
  25.133 -    if (desc == NULL)
  25.134 -        return n;
  25.135 -
  25.136 -    if (desc->magic != XENCOMM_MAGIC) {
  25.137 -        printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
  25.138 -        return n;
  25.139 -    }
  25.140 -
  25.141 -    /* iterate through the descriptor, copying up to a page at a time */
  25.142 -    while ((from_pos < n) && (i < desc->nr_addrs)) {
  25.143 -        unsigned long dest_paddr = desc->address[i];
  25.144 -        unsigned int pgoffset;
  25.145 -        unsigned int chunksz;
  25.146 -        unsigned int chunk_skip;
  25.147 -
  25.148 -        if (dest_paddr == XENCOMM_INVALID) {
  25.149 -            i++;
  25.150 -            continue;
  25.151 -        }
  25.152 -
  25.153 -        pgoffset = dest_paddr % PAGE_SIZE;
  25.154 -        chunksz = PAGE_SIZE - pgoffset;
  25.155 -
  25.156 -        chunk_skip = min(chunksz, skip);
  25.157 -        to_pos += chunk_skip;
  25.158 -        chunksz -= chunk_skip;
  25.159 -        skip -= chunk_skip;
  25.160 -
  25.161 -        if (skip == 0) {
  25.162 -            unsigned long dest_maddr;
  25.163 -            unsigned long source = (unsigned long)from + from_pos;
  25.164 -            unsigned int bytes = min(chunksz, n - from_pos);
  25.165 -
  25.166 -            dest_maddr = paddr_to_maddr(dest_paddr + chunk_skip);
  25.167 -            if (dest_maddr == 0)
  25.168 -                return -1;
  25.169 -
  25.170 -            if (xencomm_debug)
  25.171 -                printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr);
  25.172 -            memcpy((void *)dest_maddr, (void *)source, bytes);
  25.173 -            from_pos += bytes;
  25.174 -            to_pos += bytes;
  25.175 -        }
  25.176 -
  25.177 -        i++;
  25.178 -    }
  25.179 -
  25.180 -    return n - from_pos;
  25.181 -}
  25.182 -
  25.183 -/* Offset page addresses in 'handle' to skip 'bytes' bytes. Set completely
  25.184 - * exhausted pages to XENCOMM_INVALID. */
  25.185 -int xencomm_add_offset(void *handle, unsigned int bytes)
  25.186 -{
  25.187 -    struct xencomm_desc *desc;
  25.188 -    int i = 0;
  25.189 -
  25.190 -    /* first we need to access the descriptor */
  25.191 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)handle);
  25.192 -    if (desc == NULL)
  25.193 -        return -1;
  25.194 -
  25.195 -    if (desc->magic != XENCOMM_MAGIC) {
  25.196 -        printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
  25.197 -        return -1;
  25.198 -    }
  25.199 -
  25.200 -    /* iterate through the descriptor incrementing addresses */
  25.201 -    while ((bytes > 0) && (i < desc->nr_addrs)) {
  25.202 -        unsigned long dest_paddr = desc->address[i];
  25.203 -        unsigned int pgoffset;
  25.204 -        unsigned int chunksz;
  25.205 -        unsigned int chunk_skip;
  25.206 -
  25.207 -        if (dest_paddr == XENCOMM_INVALID) {
  25.208 -            i++;
  25.209 -            continue;
  25.210 -        }
  25.211 -
  25.212 -        pgoffset = dest_paddr % PAGE_SIZE;
  25.213 -        chunksz = PAGE_SIZE - pgoffset;
  25.214 -
  25.215 -        chunk_skip = min(chunksz, bytes);
  25.216 -        if (chunk_skip == chunksz) {
  25.217 -            /* exhausted this page */
  25.218 -            desc->address[i] = XENCOMM_INVALID;
  25.219 -        } else {
  25.220 -            desc->address[i] += chunk_skip;
  25.221 -        }
  25.222 -        bytes -= chunk_skip;
  25.223 -
  25.224 -	i++;
  25.225 -    }
  25.226 -    return 0;
  25.227 -}
  25.228 -
  25.229 -int xencomm_handle_is_null(void *ptr)
  25.230 -{
  25.231 -    struct xencomm_desc *desc;
  25.232 -
  25.233 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)ptr);
  25.234 -    if (desc == NULL)
  25.235 -        return 1;
  25.236 -
  25.237 -    return (desc->nr_addrs == 0);
  25.238 -}
  25.239 -
    26.1 --- a/xen/common/Makefile	Fri Dec 01 19:11:02 2006 -0500
    26.2 +++ b/xen/common/Makefile	Tue Dec 12 09:56:06 2006 -0600
    26.3 @@ -31,5 +31,7 @@ obj-$(perfc)       += perfc.o
    26.4  obj-$(crash_debug) += gdbstub.o
    26.5  obj-$(xenoprof)    += xenoprof.o
    26.6  
    26.7 +obj-$(CONFIG_XENCOMM) += xencomm.o
    26.8 +
    26.9  # Object file contains changeset and compiler information.
   26.10  version.o: $(BASEDIR)/include/xen/compile.h
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/xen/common/xencomm.c	Tue Dec 12 09:56:06 2006 -0600
    27.3 @@ -0,0 +1,316 @@
    27.4 +/*
    27.5 + * This program is free software; you can redistribute it and/or modify
    27.6 + * it under the terms of the GNU General Public License as published by
    27.7 + * the Free Software Foundation; either version 2 of the License, or
    27.8 + * (at your option) any later version.
    27.9 + *
   27.10 + * This program is distributed in the hope that it will be useful,
   27.11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   27.13 + * GNU General Public License for more details.
   27.14 + *
   27.15 + * You should have received a copy of the GNU General Public License
   27.16 + * along with this program; if not, write to the Free Software
   27.17 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   27.18 + *
   27.19 + * Copyright (C) IBM Corp. 2006
   27.20 + *
   27.21 + * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   27.22 + *          Tristan Gingold <tristan.gingold@bull.net>
   27.23 + */
   27.24 +
   27.25 +#include <xen/config.h>
   27.26 +#include <xen/mm.h>
   27.27 +#include <xen/sched.h>
   27.28 +#include <xen/xencomm.h>
   27.29 +#include <public/xen.h>
   27.30 +#include <public/xencomm.h>
   27.31 +
   27.32 +
   27.33 +#undef DEBUG
   27.34 +#ifdef DEBUG
   27.35 +static int xencomm_debug = 1; /* extremely verbose */
   27.36 +#else
   27.37 +#define xencomm_debug 0
   27.38 +#endif
   27.39 +
   27.40 +static unsigned long
   27.41 +xencomm_inline_from_guest(void *to, const void *from, unsigned int n,
   27.42 +        unsigned int skip)
   27.43 +{
   27.44 +    unsigned long src_paddr = xencomm_inline_addr(from);
   27.45 +
   27.46 +    src_paddr += skip;
   27.47 +
   27.48 +    while (n > 0) {
   27.49 +        unsigned int chunksz;
   27.50 +        unsigned long src_maddr;
   27.51 +        unsigned int bytes;
   27.52 +
   27.53 +        chunksz = PAGE_SIZE - (src_paddr % PAGE_SIZE);
   27.54 +
   27.55 +        bytes = min(chunksz, n);
   27.56 +
   27.57 +        src_maddr = paddr_to_maddr(src_paddr);
   27.58 +        if (xencomm_debug)
   27.59 +            printk("%lx[%d] -> %lx\n", src_maddr, bytes, (unsigned long)to);
   27.60 +        memcpy(to, (void *)src_maddr, bytes);
   27.61 +        src_paddr += bytes;
   27.62 +        to += bytes;
   27.63 +        n -= bytes;
   27.64 +    }
   27.65 +
   27.66 +    /* Always successful. */
   27.67 +    return 0;
   27.68 +}
   27.69 +
   27.70 +/**
   27.71 + * xencomm_copy_from_guest: Copy a block of data from domain space.
   27.72 + * @to:   Machine address.
   27.73 + * @from: Physical address to a xencomm buffer descriptor.
   27.74 + * @n:    Number of bytes to copy.
   27.75 + * @skip: Number of bytes from the start to skip.
   27.76 + *
   27.77 + * Copy data from domain to hypervisor.
   27.78 + *
   27.79 + * Returns number of bytes that could not be copied.
   27.80 + * On success, this will be zero.
   27.81 + */
   27.82 +unsigned long
   27.83 +xencomm_copy_from_guest(void *to, const void *from, unsigned int n,
   27.84 +        unsigned int skip)
   27.85 +{
   27.86 +    struct xencomm_desc *desc;
   27.87 +    unsigned int from_pos = 0;
   27.88 +    unsigned int to_pos = 0;
   27.89 +    unsigned int i = 0;
   27.90 +
   27.91 +    if (xencomm_is_inline(from))
   27.92 +        return xencomm_inline_from_guest(to, from, n, skip);
   27.93 +
   27.94 +    /* first we need to access the descriptor */
   27.95 +    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)from);
   27.96 +    if (desc == NULL)
   27.97 +        return n;
   27.98 +
   27.99 +    if (desc->magic != XENCOMM_MAGIC) {
  27.100 +        printk("%s: error: %p magic was 0x%x\n",
  27.101 +               __func__, desc, desc->magic);
  27.102 +        return n;
  27.103 +    }
  27.104 +
  27.105 +    /* iterate through the descriptor, copying up to a page at a time */
  27.106 +    while ((to_pos < n) && (i < desc->nr_addrs)) {
  27.107 +        unsigned long src_paddr = desc->address[i];
  27.108 +        unsigned int pgoffset;
  27.109 +        unsigned int chunksz;
  27.110 +        unsigned int chunk_skip;
  27.111 +
  27.112 +        if (src_paddr == XENCOMM_INVALID) {
  27.113 +            i++;
  27.114 +            continue;
  27.115 +        }
  27.116 +
  27.117 +        pgoffset = src_paddr % PAGE_SIZE;
  27.118 +        chunksz = PAGE_SIZE - pgoffset;
  27.119 +
  27.120 +        chunk_skip = min(chunksz, skip);
  27.121 +        from_pos += chunk_skip;
  27.122 +        chunksz -= chunk_skip;
  27.123 +        skip -= chunk_skip;
  27.124 +
  27.125 +        if (skip == 0) {
  27.126 +            unsigned long src_maddr;
  27.127 +            unsigned long dest = (unsigned long)to + to_pos;
  27.128 +            unsigned int bytes = min(chunksz, n - to_pos);
  27.129 +
  27.130 +            src_maddr = paddr_to_maddr(src_paddr + chunk_skip);
  27.131 +            if (src_maddr == 0)
  27.132 +                return n - to_pos;
  27.133 +
  27.134 +            if (xencomm_debug)
  27.135 +                printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest);
  27.136 +            memcpy((void *)dest, (void *)src_maddr, bytes);
  27.137 +            from_pos += bytes;
  27.138 +            to_pos += bytes;
  27.139 +        }
  27.140 +
  27.141 +        i++;
  27.142 +    }
  27.143 +
  27.144 +    return n - to_pos;
  27.145 +}
  27.146 +
  27.147 +static unsigned long
  27.148 +xencomm_inline_to_guest(void *to, const void *from, unsigned int n,
  27.149 +        unsigned int skip)
  27.150 +{
  27.151 +    unsigned long dest_paddr = xencomm_inline_addr(to);
  27.152 +
  27.153 +    dest_paddr += skip;
  27.154 +
  27.155 +    while (n > 0) {
  27.156 +        unsigned int chunksz;
  27.157 +        unsigned long dest_maddr;
  27.158 +        unsigned int bytes;
  27.159 +
  27.160 +        chunksz = PAGE_SIZE - (dest_paddr % PAGE_SIZE);
  27.161 +
  27.162 +        bytes = min(chunksz, n);
  27.163 +
  27.164 +        dest_maddr = paddr_to_maddr(dest_paddr);
  27.165 +        if (xencomm_debug)
  27.166 +            printk("%lx[%d] -> %lx\n", (unsigned long)from, bytes, dest_maddr);
  27.167 +        memcpy((void *)dest_maddr, (void *)from, bytes);
  27.168 +        dest_paddr += bytes;
  27.169 +        from += bytes;
  27.170 +        n -= bytes;
  27.171 +    }
  27.172 +
  27.173 +    /* Always successful.  */
  27.174 +    return 0;
  27.175 +}
  27.176 +
  27.177 +/**
  27.178 + * xencomm_copy_to_guest: Copy a block of data to domain space.
  27.179 + * @to:     Physical address to xencomm buffer descriptor.
  27.180 + * @from:   Machine address.
  27.181 + * @n:      Number of bytes to copy.
  27.182 + * @skip: Number of bytes from the start to skip.
  27.183 + *
  27.184 + * Copy data from hypervisor to domain.
  27.185 + *
  27.186 + * Returns number of bytes that could not be copied.
  27.187 + * On success, this will be zero.
  27.188 + */
  27.189 +unsigned long
  27.190 +xencomm_copy_to_guest(void *to, const void *from, unsigned int n,
  27.191 +        unsigned int skip)
  27.192 +{
  27.193 +    struct xencomm_desc *desc;
  27.194 +    unsigned int from_pos = 0;
  27.195 +    unsigned int to_pos = 0;
  27.196 +    unsigned int i = 0;
  27.197 +
  27.198 +    if (xencomm_is_inline(to))
  27.199 +        return xencomm_inline_to_guest(to, from, n, skip);
  27.200 +
  27.201 +    /* first we need to access the descriptor */
  27.202 +    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)to);
  27.203 +    if (desc == NULL)
  27.204 +        return n;
  27.205 +
  27.206 +    if (desc->magic != XENCOMM_MAGIC) {
  27.207 +        printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
  27.208 +        return n;
  27.209 +    }
  27.210 +
  27.211 +    /* iterate through the descriptor, copying up to a page at a time */
  27.212 +    while ((from_pos < n) && (i < desc->nr_addrs)) {
  27.213 +        unsigned long dest_paddr = desc->address[i];
  27.214 +        unsigned int pgoffset;
  27.215 +        unsigned int chunksz;
  27.216 +        unsigned int chunk_skip;
  27.217 +
  27.218 +        if (dest_paddr == XENCOMM_INVALID) {
  27.219 +            i++;
  27.220 +            continue;
  27.221 +        }
  27.222 +
  27.223 +        pgoffset = dest_paddr % PAGE_SIZE;
  27.224 +        chunksz = PAGE_SIZE - pgoffset;
  27.225 +
  27.226 +        chunk_skip = min(chunksz, skip);
  27.227 +        to_pos += chunk_skip;
  27.228 +        chunksz -= chunk_skip;
  27.229 +        skip -= chunk_skip;
  27.230 +
  27.231 +        if (skip == 0) {
  27.232 +            unsigned long dest_maddr;
  27.233 +            unsigned long source = (unsigned long)from + from_pos;
  27.234 +            unsigned int bytes = min(chunksz, n - from_pos);
  27.235 +
  27.236 +            dest_maddr = paddr_to_maddr(dest_paddr + chunk_skip);
  27.237 +            if (dest_maddr == 0)
  27.238 +                return -1;
  27.239 +
  27.240 +            if (xencomm_debug)
  27.241 +                printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr);
  27.242 +            memcpy((void *)dest_maddr, (void *)source, bytes);
  27.243 +            from_pos += bytes;
  27.244 +            to_pos += bytes;
  27.245 +        }
  27.246 +
  27.247 +        i++;
  27.248 +    }
  27.249 +
  27.250 +    return n - from_pos;
  27.251 +}
  27.252 +
  27.253 +static int xencomm_inline_add_offset(void **handle, unsigned int bytes)
  27.254 +{
  27.255 +    *handle += bytes;
  27.256 +    return 0;
  27.257 +}
  27.258 +
  27.259 +/* Offset page addresses in 'handle' to skip 'bytes' bytes. Set completely
  27.260 + * exhausted pages to XENCOMM_INVALID. */
  27.261 +int xencomm_add_offset(void **handle, unsigned int bytes)
  27.262 +{
  27.263 +    struct xencomm_desc *desc;
  27.264 +    int i = 0;
  27.265 +
  27.266 +    if (xencomm_is_inline(*handle))
  27.267 +        return xencomm_inline_add_offset(handle, bytes);
  27.268 +
  27.269 +    /* first we need to access the descriptor */
  27.270 +    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)*handle);
  27.271 +    if (desc == NULL)
  27.272 +        return -1;
  27.273 +
  27.274 +    if (desc->magic != XENCOMM_MAGIC) {
  27.275 +        printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
  27.276 +        return -1;
  27.277 +    }
  27.278 +
  27.279 +    /* iterate through the descriptor incrementing addresses */
  27.280 +    while ((bytes > 0) && (i < desc->nr_addrs)) {
  27.281 +        unsigned long dest_paddr = desc->address[i];
  27.282 +        unsigned int pgoffset;
  27.283 +        unsigned int chunksz;
  27.284 +        unsigned int chunk_skip;
  27.285 +
  27.286 +        pgoffset = dest_paddr % PAGE_SIZE;
  27.287 +        chunksz = PAGE_SIZE - pgoffset;
  27.288 +
  27.289 +        chunk_skip = min(chunksz, bytes);
  27.290 +        if (chunk_skip == chunksz) {
  27.291 +            /* exhausted this page */
  27.292 +            desc->address[i] = XENCOMM_INVALID;
  27.293 +        } else {
  27.294 +            desc->address[i] += chunk_skip;
  27.295 +        }
  27.296 +        bytes -= chunk_skip;
  27.297 +    }
  27.298 +    return 0;
  27.299 +}
  27.300 +
  27.301 +int xencomm_handle_is_null(void *handle)
  27.302 +{
  27.303 +    struct xencomm_desc *desc;
  27.304 +    int i;
  27.305 +
  27.306 +    if (xencomm_is_inline(handle))
  27.307 +        return xencomm_inline_addr(handle) == 0;
  27.308 +
  27.309 +    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)handle);
  27.310 +    if (desc == NULL)
  27.311 +        return 1;
  27.312 +
  27.313 +    for (i = 0; i < desc->nr_addrs; i++)
  27.314 +        if (desc->address[i] != XENCOMM_INVALID)
  27.315 +            return 0;
  27.316 +
  27.317 +    return 1;
  27.318 +}
  27.319 +
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/xen/include/asm-powerpc/acpi.h	Tue Dec 12 09:56:06 2006 -0600
    28.3 @@ -0,0 +1,2 @@
    28.4 +#define MAX_LOCAL_APIC 256
    28.5 +
    29.1 --- a/xen/include/asm-powerpc/config.h	Fri Dec 01 19:11:02 2006 -0500
    29.2 +++ b/xen/include/asm-powerpc/config.h	Tue Dec 12 09:56:06 2006 -0600
    29.3 @@ -50,6 +50,7 @@ extern char __bss_start[];
    29.4  #define CONFIG_GDB 1
    29.5  #define CONFIG_SMP 1
    29.6  #define CONFIG_PCI 1
    29.7 +#define CONFIG_NUMA 1
    29.8  #define CONFIG_CMDLINE_SIZE 512
    29.9  #define NR_CPUS 16
   29.10  
    30.1 --- a/xen/include/asm-powerpc/domain.h	Fri Dec 01 19:11:02 2006 -0500
    30.2 +++ b/xen/include/asm-powerpc/domain.h	Tue Dec 12 09:56:06 2006 -0600
    30.3 @@ -89,7 +89,7 @@ struct arch_vcpu {
    30.4      struct slb_entry slb_entries[NUM_SLB_ENTRIES];
    30.5  
    30.6      /* I/O-port access bitmap. */
    30.7 -    u8 *iobmp;        /* Guest kernel virtual address of the bitmap. */
    30.8 +    XEN_GUEST_HANDLE(uint8_t) iobmp; /* Guest kernel virtual address of the bitmap. */
    30.9      int iobmp_limit;  /* Number of ports represented in the bitmap.  */
   30.10      int iopl;         /* Current IOPL for this VCPU. */
   30.11  
    31.1 --- a/xen/include/asm-powerpc/guest_access.h	Fri Dec 01 19:11:02 2006 -0500
    31.2 +++ b/xen/include/asm-powerpc/guest_access.h	Tue Dec 12 09:56:06 2006 -0600
    31.3 @@ -21,82 +21,6 @@
    31.4  #ifndef __PPC_GUEST_ACCESS_H__
    31.5  #define __PPC_GUEST_ACCESS_H__
    31.6  
    31.7 -extern unsigned long xencomm_copy_to_guest(void *to, const void *from,
    31.8 -        unsigned int len, unsigned int skip); 
    31.9 -extern unsigned long xencomm_copy_from_guest(void *to, const void *from,
   31.10 -        unsigned int len, unsigned int skip); 
   31.11 -extern int xencomm_add_offset(void *handle, unsigned int bytes);
   31.12 -extern int xencomm_handle_is_null(void *ptr);
   31.13 -
   31.14 -
   31.15 -/* Is the guest handle a NULL reference? */
   31.16 -#define guest_handle_is_null(hnd) \
   31.17 -    ((hnd).p == NULL || xencomm_handle_is_null((hnd).p))
   31.18 -
   31.19 -/* Offset the given guest handle into the array it refers to. */
   31.20 -#define guest_handle_add_offset(hnd, nr) ({         \
   31.21 -    const typeof((hnd).p) _ptr = (hnd).p;           \
   31.22 -    xencomm_add_offset(_ptr, nr * sizeof(*_ptr));   \
   31.23 -})
   31.24 -
   31.25 -/* Cast a guest handle to the specified type of handle. */
   31.26 -#define guest_handle_cast(hnd, type) ({         \
   31.27 -    type *_x = (hnd).p;                         \
   31.28 -    XEN_GUEST_HANDLE(type) _y; \
   31.29 -    set_xen_guest_handle(_y, _x); \
   31.30 -    _y; \
   31.31 -})
   31.32 -
   31.33 -/* Since we run in real mode, we can safely access all addresses. That also
   31.34 - * means our __routines are identical to our "normal" routines. */
   31.35 -#define guest_handle_okay(hnd, nr) 1
   31.36 -
   31.37 -/*
   31.38 - * Copy an array of objects to guest context via a guest handle.
   31.39 - * Optionally specify an offset into the guest array.
   31.40 - */
   31.41 -#define copy_to_guest_offset(hnd, idx, ptr, nr) \
   31.42 -    __copy_to_guest_offset(hnd, idx, ptr, nr)
   31.43 -
   31.44 -/* Copy sub-field of a structure to guest context via a guest handle. */
   31.45 -#define copy_field_to_guest(hnd, ptr, field) \
   31.46 -    __copy_field_to_guest(hnd, ptr, field)
   31.47 -
   31.48 -/*
   31.49 - * Copy an array of objects from guest context via a guest handle.
   31.50 - * Optionally specify an offset into the guest array.
   31.51 - */
   31.52 -#define copy_from_guest_offset(ptr, hnd, idx, nr) \
   31.53 -    __copy_from_guest_offset(ptr, hnd, idx, nr)
   31.54 -
   31.55 -/* Copy sub-field of a structure from guest context via a guest handle. */
   31.56 -#define copy_field_from_guest(ptr, hnd, field) \
   31.57 -    __copy_field_from_guest(ptr, hnd, field)
   31.58 -
   31.59 -#define __copy_to_guest_offset(hnd, idx, ptr, nr) ({                \
   31.60 -    const typeof(ptr) _x = (hnd).p;                                 \
   31.61 -    const typeof(ptr) _y = (ptr);                                   \
   31.62 -    xencomm_copy_to_guest(_x, _y, sizeof(*_x)*(nr), sizeof(*_x)*(idx)); \
   31.63 -})
   31.64 -
   31.65 -#define __copy_field_to_guest(hnd, ptr, field) ({                   \
   31.66 -    const int _off = offsetof(typeof(*ptr), field);                  \
   31.67 -    const typeof(&(ptr)->field) _x = &(hnd).p->field;               \
   31.68 -    const typeof(&(ptr)->field) _y = &(ptr)->field;                 \
   31.69 -    xencomm_copy_to_guest(_x, _y, sizeof(*_x), sizeof(*_x)*(_off)); \
   31.70 -})
   31.71 -
   31.72 -#define __copy_from_guest_offset(ptr, hnd, idx, nr) ({              \
   31.73 -    const typeof(ptr) _x = (hnd).p;                                 \
   31.74 -    const typeof(ptr) _y = (ptr);                                   \
   31.75 -    xencomm_copy_from_guest(_y, _x, sizeof(*_x)*(nr), sizeof(*_x)*(idx));  \
   31.76 -})
   31.77 -
   31.78 -#define __copy_field_from_guest(ptr, hnd, field) ({                 \
   31.79 -    const int _off = offsetof(typeof(*ptr), field);                 \
   31.80 -    const typeof(&(ptr)->field) _x = &(hnd).p->field;               \
   31.81 -    const typeof(&(ptr)->field) _y = &(ptr)->field;                 \
   31.82 -    xencomm_copy_to_guest(_y, _x, sizeof(*_x), sizeof(*_x)*(_off)); \
   31.83 -})
   31.84 +#include <xen/xencomm.h>
   31.85  
   31.86  #endif /* __PPC_GUEST_ACCESS_H__ */
    32.1 --- a/xen/include/asm-powerpc/mm.h	Fri Dec 01 19:11:02 2006 -0500
    32.2 +++ b/xen/include/asm-powerpc/mm.h	Tue Dec 12 09:56:06 2006 -0600
    32.3 @@ -28,7 +28,7 @@
    32.4  #include <xen/mm.h>
    32.5  #include <asm/system.h>
    32.6  #include <asm/flushtlb.h>
    32.7 -#include <asm/uaccess.h>
    32.8 +#include <asm/page.h>
    32.9  #include <asm/debugger.h>
   32.10  
   32.11  #define memguard_guard_range(_p,_l)    ((void)0)
   32.12 @@ -87,7 +87,6 @@ struct page_extents {
   32.13      /* page extent */
   32.14      struct page_info *pg;
   32.15      uint order;
   32.16 -    ulong pfn;
   32.17  };
   32.18  
   32.19   /* The following page types are MUTUALLY EXCLUSIVE. */
   32.20 @@ -273,72 +272,20 @@ extern int update_grant_va_mapping(unsig
   32.21                                     struct domain *,
   32.22                                     struct vcpu *);
   32.23  
   32.24 -#define INVALID_MFN (~0UL)
   32.25 -#define PFN_TYPE_NONE 0
   32.26 -#define PFN_TYPE_RMA 1
   32.27 -#define PFN_TYPE_LOGICAL 2
   32.28 -#define PFN_TYPE_IO 3
   32.29 -#define PFN_TYPE_FOREIGN 4
   32.30 -
   32.31 -extern ulong pfn2mfn(struct domain *d, ulong pfn, int *type);
   32.32 -
   32.33  /* Arch-specific portion of memory_op hypercall. */
   32.34  long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg);
   32.35  
   32.36 -/* XXX implement me? */
   32.37 -#define set_gpfn_from_mfn(mfn, pfn) do { } while (0)
   32.38 -/* XXX only used for debug print right now... */
   32.39 -#define get_gpfn_from_mfn(mfn) (mfn)
   32.40 -
   32.41 -static inline unsigned long gmfn_to_mfn(struct domain *d, unsigned long gmfn)
   32.42 -{
   32.43 -    int mtype;
   32.44 -    ulong mfn;
   32.45 -    
   32.46 -    mfn = pfn2mfn(d, gmfn, &mtype);
   32.47 -    if (mfn != INVALID_MFN) {
   32.48 -        switch (mtype) {
   32.49 -        case PFN_TYPE_RMA:
   32.50 -        case PFN_TYPE_LOGICAL:
   32.51 -            break;
   32.52 -        default:
   32.53 -            WARN();
   32.54 -            mfn = INVALID_MFN;
   32.55 -            break;
   32.56 -        }
   32.57 -    }
   32.58 -    return mfn;
   32.59 -}
   32.60 -
   32.61 -#define mfn_to_gmfn(_d, mfn) (mfn)
   32.62 -
   32.63  extern int allocate_rma(struct domain *d, unsigned int order_pages);
   32.64  extern uint allocate_extents(struct domain *d, uint nrpages, uint rma_nrpages);
   32.65  extern void free_extents(struct domain *d);
   32.66  
   32.67 +extern int arch_domain_add_extent(struct domain *d, struct page_info *page,
   32.68 +        int order);
   32.69 +
   32.70  extern int steal_page(struct domain *d, struct page_info *page,
   32.71                          unsigned int memflags);
   32.72  
   32.73 -static inline unsigned long gmfn_to_mfn(struct domain *d, unsigned long gmfn)
   32.74 -{
   32.75 -    int mtype;
   32.76 -    ulong mfn;
   32.77 -    
   32.78 -    mfn = pfn2mfn(d, gmfn, &mtype);
   32.79 -    if (mfn != INVALID_MFN) {
   32.80 -        switch (mtype) {
   32.81 -        case PFN_TYPE_RMA:
   32.82 -        case PFN_TYPE_LOGICAL:
   32.83 -            break;
   32.84 -        default:
   32.85 -            WARN();
   32.86 -            mfn = INVALID_MFN;
   32.87 -            break;
   32.88 -        }
   32.89 -    }
   32.90 -    return mfn;
   32.91 -}
   32.92 -
   32.93 -#define mfn_to_gmfn(_d, mfn) (mfn)
   32.94 -
   32.95 +/* XXX these just exist until we can stop #including x86 code */
   32.96 +#define access_ok(addr,size) 1
   32.97 +#define array_access_ok(addr,count,size) 1
   32.98  #endif
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/xen/include/asm-powerpc/numa.h	Tue Dec 12 09:56:06 2006 -0600
    33.3 @@ -0,0 +1,2 @@
    33.4 +#include "../asm-x86/numa.h"
    33.5 +extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn);
    34.1 --- a/xen/include/asm-powerpc/page.h	Fri Dec 01 19:11:02 2006 -0500
    34.2 +++ b/xen/include/asm-powerpc/page.h	Tue Dec 12 09:56:06 2006 -0600
    34.3 @@ -13,7 +13,7 @@
    34.4   * along with this program; if not, write to the Free Software
    34.5   * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    34.6   *
    34.7 - * Copyright (C) IBM Corp. 2005
    34.8 + * Copyright (C) IBM Corp. 2005, 2006
    34.9   *
   34.10   * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   34.11   *          Jimi Xenidis <jimix@watson.ibm.com>
   34.12 @@ -129,5 +129,6 @@ static inline int get_order_from_pages(u
   34.13  #define _PAGE_PAT      0x080UL
   34.14  #define _PAGE_PSE      0x080UL
   34.15  #define _PAGE_GLOBAL   0x100UL
   34.16 +
   34.17  #endif  /* ! __ASSEMBLY__ */
   34.18  #endif
    35.1 --- a/xen/include/asm-powerpc/smp.h	Fri Dec 01 19:11:02 2006 -0500
    35.2 +++ b/xen/include/asm-powerpc/smp.h	Tue Dec 12 09:56:06 2006 -0600
    35.3 @@ -25,6 +25,12 @@
    35.4  #include <xen/cpumask.h>
    35.5  #include <xen/init.h>
    35.6  #include <asm/current.h>
    35.7 +
    35.8 +/* crap to make x86 "common code" happy */
    35.9 +#define BAD_APICID 0xFFu
   35.10 +extern u8 x86_cpu_to_apicid[];
   35.11 +
   35.12 +
   35.13  extern int smp_num_siblings;
   35.14  
   35.15  /* revisit when we support SMP */
    36.1 --- a/xen/include/asm-powerpc/spinlock.h	Fri Dec 01 19:11:02 2006 -0500
    36.2 +++ b/xen/include/asm-powerpc/spinlock.h	Tue Dec 12 09:56:06 2006 -0600
    36.3 @@ -72,13 +72,13 @@ cas_u32(volatile u32 *ptr, u32 oval, u32
    36.4  
    36.5  typedef struct {
    36.6      volatile u32 lock;
    36.7 -	u16 recurse_cpu;
    36.8 -	u16 recurse_cnt;
    36.9 +    s16 recurse_cpu;
   36.10 +    u16 recurse_cnt;
   36.11  } spinlock_t;
   36.12  
   36.13  #define __UNLOCKED (0U)
   36.14  #define __LOCKED (~__UNLOCKED)
   36.15 -#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { __UNLOCKED }
   36.16 +#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { __UNLOCKED, -1, 0 }
   36.17  static inline void spin_lock_init(spinlock_t *lock)
   36.18  {
   36.19      *lock = (spinlock_t) SPIN_LOCK_UNLOCKED;
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/xen/include/xen/xencomm.h	Tue Dec 12 09:56:06 2006 -0600
    37.3 @@ -0,0 +1,115 @@
    37.4 +/*
    37.5 + * This program is free software; you can redistribute it and/or modify
    37.6 + * it under the terms of the GNU General Public License as published by
    37.7 + * the Free Software Foundation; either version 2 of the License, or
    37.8 + * (at your option) any later version.
    37.9 + *
   37.10 + * This program is distributed in the hope that it will be useful,
   37.11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   37.12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   37.13 + * GNU General Public License for more details.
   37.14 + *
   37.15 + * You should have received a copy of the GNU General Public License
   37.16 + * along with this program; if not, write to the Free Software
   37.17 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   37.18 + *
   37.19 + * Copyright (C) IBM Corp. 2006
   37.20 + *
   37.21 + * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   37.22 + */
   37.23 +
   37.24 +#ifndef __XENCOMM_H__
   37.25 +#define __XENCOMM_H__
   37.26 +
   37.27 +#include <public/xen.h>
   37.28 +
   37.29 +extern unsigned long xencomm_copy_to_guest(void *to, const void *from,
   37.30 +        unsigned int len, unsigned int skip); 
   37.31 +extern unsigned long xencomm_copy_from_guest(void *to, const void *from,
   37.32 +        unsigned int len, unsigned int skip); 
   37.33 +extern int xencomm_add_offset(void **handle, unsigned int bytes);
   37.34 +extern int xencomm_handle_is_null(void *ptr);
   37.35 +
   37.36 +
   37.37 +static inline int xencomm_is_inline(const void *handle)
   37.38 +{
   37.39 +    unsigned long addr = (unsigned long)handle;
   37.40 +    return (addr & XENCOMM_INLINE_FLAG) == XENCOMM_INLINE_FLAG;
   37.41 +}
   37.42 +
   37.43 +static inline unsigned long xencomm_inline_addr(const void *handle)
   37.44 +{
   37.45 +	return (unsigned long)handle & ~XENCOMM_INLINE_FLAG;
   37.46 +}
   37.47 +
   37.48 +/* Is the guest handle a NULL reference? */
   37.49 +#define guest_handle_is_null(hnd) \
   37.50 +    ((hnd).p == NULL || xencomm_handle_is_null((hnd).p))
   37.51 +
   37.52 +/* Offset the given guest handle into the array it refers to. */
   37.53 +#define guest_handle_add_offset(hnd, nr) ({         \
   37.54 +    const typeof((hnd).p) _ptr;                     \
   37.55 +    xencomm_add_offset((void **)&((hnd).p), nr * sizeof(*_ptr));   \
   37.56 +})
   37.57 +
   37.58 +/* Cast a guest handle to the specified type of handle. */
   37.59 +#define guest_handle_cast(hnd, type) ({         \
   37.60 +    type *_x = (hnd).p;                         \
   37.61 +    XEN_GUEST_HANDLE(type) _y; \
   37.62 +    set_xen_guest_handle(_y, _x); \
   37.63 +    _y; \
   37.64 +})
   37.65 +
   37.66 +/* Since we run in real mode, we can safely access all addresses. That also
   37.67 + * means our __routines are identical to our "normal" routines. */
   37.68 +#define guest_handle_okay(hnd, nr) 1
   37.69 +
   37.70 +/*
   37.71 + * Copy an array of objects to guest context via a guest handle.
   37.72 + * Optionally specify an offset into the guest array.
   37.73 + */
   37.74 +#define copy_to_guest_offset(hnd, idx, ptr, nr) \
   37.75 +    __copy_to_guest_offset(hnd, idx, ptr, nr)
   37.76 +
   37.77 +/* Copy sub-field of a structure to guest context via a guest handle. */
   37.78 +#define copy_field_to_guest(hnd, ptr, field) \
   37.79 +    __copy_field_to_guest(hnd, ptr, field)
   37.80 +
   37.81 +/*
   37.82 + * Copy an array of objects from guest context via a guest handle.
   37.83 + * Optionally specify an offset into the guest array.
   37.84 + */
   37.85 +#define copy_from_guest_offset(ptr, hnd, idx, nr) \
   37.86 +    __copy_from_guest_offset(ptr, hnd, idx, nr)
   37.87 +
   37.88 +/* Copy sub-field of a structure from guest context via a guest handle. */
   37.89 +#define copy_field_from_guest(ptr, hnd, field) \
   37.90 +    __copy_field_from_guest(ptr, hnd, field)
   37.91 +
   37.92 +#define __copy_to_guest_offset(hnd, idx, ptr, nr) ({                \
   37.93 +    const typeof(ptr) _x = (hnd).p;                                 \
   37.94 +    const typeof(ptr) _y = (ptr);                                   \
   37.95 +    xencomm_copy_to_guest(_x, _y, sizeof(*_x)*(nr), sizeof(*_x)*(idx)); \
   37.96 +})
   37.97 +
   37.98 +#define __copy_field_to_guest(hnd, ptr, field) ({                   \
   37.99 +    const int _off = offsetof(typeof(*ptr), field);                  \
  37.100 +    const typeof(&(ptr)->field) _x = &(hnd).p->field;               \
  37.101 +    const typeof(&(ptr)->field) _y = &(ptr)->field;                 \
  37.102 +    xencomm_copy_to_guest(_x, _y, sizeof(*_x), sizeof(*_x)*(_off)); \
  37.103 +})
  37.104 +
  37.105 +#define __copy_from_guest_offset(ptr, hnd, idx, nr) ({              \
  37.106 +    const typeof(ptr) _x = (hnd).p;                                 \
  37.107 +    const typeof(ptr) _y = (ptr);                                   \
  37.108 +    xencomm_copy_from_guest(_y, _x, sizeof(*_x)*(nr), sizeof(*_x)*(idx));  \
  37.109 +})
  37.110 +
  37.111 +#define __copy_field_from_guest(ptr, hnd, field) ({                 \
  37.112 +    const int _off = offsetof(typeof(*ptr), field);                 \
  37.113 +    const typeof(&(ptr)->field) _x = &(hnd).p->field;               \
  37.114 +    const typeof(&(ptr)->field) _y = &(ptr)->field;                 \
  37.115 +    xencomm_copy_to_guest(_y, _x, sizeof(*_x), sizeof(*_x)*(_off)); \
  37.116 +})
  37.117 +
  37.118 +#endif /* __XENCOMM_H__ */