direct-io.hg

changeset 12973: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
     2.1 --- a/tools/libxc/powerpc64/flatdevtree.c	Fri Dec 01 19:11:02 2006 -0500
     2.2 +++ b/tools/libxc/powerpc64/flatdevtree.c	Tue Dec 12 09:56:06 2006 -0600
     2.3 @@ -220,6 +220,29 @@ void ft_add_rsvmap(struct ft_cxt *cxt, u
     2.4  	cxt->p_anchor = cxt->pres + 16;	/* over the terminator */
     2.5  }
     2.6  
     2.7 +int ft_set_rsvmap(void *bphp, int m, u64 physaddr, u64 size)
     2.8 +{
     2.9 +	const struct boot_param_header *bph = bphp;
    2.10 +	u64 *p_rsvmap = (u64 *)
    2.11 +		((char *)bph + be32_to_cpu(bph->off_mem_rsvmap));
    2.12 +	u32 i;
    2.13 +
    2.14 +	for (i = 0;; i++) {
    2.15 +		u64 addr, sz;
    2.16 +
    2.17 +		addr = be64_to_cpu(p_rsvmap[i * 2]);
    2.18 +		sz = be64_to_cpu(p_rsvmap[i * 2 + 1]);
    2.19 +		if (addr == 0 && size == 0)
    2.20 +			break;
    2.21 +		if (m == i) {
    2.22 +			p_rsvmap[i * 2] = cpu_to_be64(physaddr);
    2.23 +			p_rsvmap[i * 2 + 1] = cpu_to_be64(size);
    2.24 +			return 0;
    2.25 +		}
    2.26 +	}
    2.27 +	return -1;
    2.28 +}
    2.29 +
    2.30  void ft_begin_tree(struct ft_cxt *cxt)
    2.31  {
    2.32  	cxt->p_begin = cxt->p_anchor;
     3.1 --- a/tools/libxc/powerpc64/flatdevtree.h	Fri Dec 01 19:11:02 2006 -0500
     3.2 +++ b/tools/libxc/powerpc64/flatdevtree.h	Tue Dec 12 09:56:06 2006 -0600
     3.3 @@ -66,6 +66,7 @@ void ft_prop_str(struct ft_cxt *cxt, con
     3.4  void ft_prop_int(struct ft_cxt *cxt, const char *name, unsigned int val);
     3.5  void ft_begin(struct ft_cxt *cxt, void *blob, unsigned int max_size);
     3.6  void ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size);
     3.7 +int ft_set_rsvmap(void *bphp, int m, u64 physaddr, u64 size);
     3.8  
     3.9  void ft_dump_blob(const void *bphp);
    3.10  void ft_backtrack_node(struct ft_cxt *cxt);
     4.1 --- a/tools/libxc/powerpc64/utils.c	Fri Dec 01 19:11:02 2006 -0500
     4.2 +++ b/tools/libxc/powerpc64/utils.c	Tue Dec 12 09:56:06 2006 -0600
     4.3 @@ -77,7 +77,7 @@ int get_rma_page_array(int xc_handle, in
     4.4      /* We know that the RMA is machine contiguous so lets just get the
     4.5       * first MFN and fill the rest in ourselves */
     4.6      rc = xc_get_pfn_list(xc_handle, domid, *page_array, 1);
     4.7 -    if (rc != 1) {
     4.8 +    if (rc == -1) {
     4.9          perror("Could not get the page frame list");
    4.10          return -1;
    4.11      }
     5.1 --- a/tools/libxc/powerpc64/xc_linux_build.c	Fri Dec 01 19:11:02 2006 -0500
     5.2 +++ b/tools/libxc/powerpc64/xc_linux_build.c	Tue Dec 12 09:56:06 2006 -0600
     5.3 @@ -89,7 +89,7 @@ static int load_devtree(
     5.4      start_info_t *start_info __attribute__((unused)),
     5.5      unsigned long start_info_addr)
     5.6  {
     5.7 -    uint32_t start_info[4] = {0, start_info_addr, 0, 0x1000};
     5.8 +    uint32_t si[4] = {0, start_info_addr, 0, 0x1000};
     5.9      struct boot_param_header *header;
    5.10      void *chosen;
    5.11      void *xen;
    5.12 @@ -127,8 +127,14 @@ static int load_devtree(
    5.13          return rc;
    5.14      }
    5.15  
    5.16 +    rc = ft_set_rsvmap(devtree, 1, initrd_base, initrd_len);
    5.17 +    if (rc < 0) {
    5.18 +        DPRINTF("couldn't set initrd reservation\n");
    5.19 +        return ~0UL;
    5.20 +    }
    5.21 +
    5.22      /* start-info (XXX being removed soon) */
    5.23 -    rc = ft_set_prop(&devtree, xen, "start-info", start_info, sizeof(start_info));
    5.24 +    rc = ft_set_prop(&devtree, xen, "start-info", si, sizeof(si));
    5.25      if (rc < 0) {
    5.26          DPRINTF("couldn't set /xen/start-info\n");
    5.27          return rc;
    5.28 @@ -136,6 +142,15 @@ static int load_devtree(
    5.29  
    5.30      header = devtree;
    5.31      devtree_size = header->totalsize;
    5.32 +    {
    5.33 +        static const char dtb[] = "/tmp/xc_domU.dtb";
    5.34 +        int dfd = creat(dtb, 0666);
    5.35 +        if (dfd != -1) {
    5.36 +            write(dfd, devtree, devtree_size);
    5.37 +            close(dfd);
    5.38 +        } else
    5.39 +            DPRINTF("could not open(\"%s\")\n", dtb);
    5.40 +    }
    5.41  
    5.42      DPRINTF("copying device tree to 0x%lx[0x%x]\n", DEVTREE_ADDR, devtree_size);
    5.43      return install_image(xc_handle, domid, page_array, devtree, DEVTREE_ADDR,
    5.44 @@ -172,22 +187,35 @@ out:
    5.45  }
    5.46  
    5.47  static unsigned long create_start_info(
    5.48 -	start_info_t *start_info,
    5.49 +	void *devtree, start_info_t *start_info,
    5.50          unsigned int console_evtchn, unsigned int store_evtchn,
    5.51  	unsigned long nr_pages, unsigned long rma_pages)
    5.52  {
    5.53      unsigned long start_info_addr;
    5.54 +    uint64_t rma_top;
    5.55 +    int rc;
    5.56  
    5.57      memset(start_info, 0, sizeof(*start_info));
    5.58 -    snprintf(start_info->magic, sizeof(start_info->magic), "xen-%d.%d-powerpc64HV", 3, 0);
    5.59 +    snprintf(start_info->magic, sizeof(start_info->magic),
    5.60 +             "xen-%d.%d-powerpc64HV", 3, 0);
    5.61 +
    5.62 +    rma_top = rma_pages << PAGE_SHIFT;
    5.63 +    DPRINTF("RMA top = 0x%"PRIX64"\n", rma_top);
    5.64  
    5.65      start_info->nr_pages = nr_pages;
    5.66 -    start_info->shared_info = (nr_pages - 1) << PAGE_SHIFT;
    5.67 -    start_info->store_mfn = start_info->nr_pages - 2;
    5.68 +    start_info->shared_info = rma_top - PAGE_SIZE;
    5.69 +    start_info->store_mfn = (rma_top >> PAGE_SHIFT) - 2;
    5.70      start_info->store_evtchn = store_evtchn;
    5.71 -    start_info->console.domU.mfn = start_info->nr_pages - 3;
    5.72 +    start_info->console.domU.mfn = (rma_top >> PAGE_SHIFT) - 3;
    5.73      start_info->console.domU.evtchn = console_evtchn;
    5.74 -    start_info_addr = (start_info->nr_pages - 4) << PAGE_SHIFT;
    5.75 +    start_info_addr = rma_top - 4*PAGE_SIZE;
    5.76 +
    5.77 +    rc = ft_set_rsvmap(devtree, 0, start_info_addr, 4*PAGE_SIZE);
    5.78 +    if (rc < 0) {
    5.79 +        DPRINTF("couldn't set start_info reservation\n");
    5.80 +        return ~0UL;
    5.81 +    }
    5.82 +
    5.83  
    5.84      return start_info_addr;
    5.85  }
    5.86 @@ -201,6 +229,7 @@ static void free_page_array(xen_pfn_t *p
    5.87  
    5.88  int xc_linux_build(int xc_handle,
    5.89                     uint32_t domid,
    5.90 +                   unsigned int mem_mb,
    5.91                     const char *image_name,
    5.92                     const char *initrd_name,
    5.93                     const char *cmdline,
    5.94 @@ -226,8 +255,7 @@ int xc_linux_build(int xc_handle,
    5.95  
    5.96      DPRINTF("%s\n", __func__);
    5.97  
    5.98 -    DPRINTF("xc_get_tot_pages\n");
    5.99 -    nr_pages = xc_get_tot_pages(xc_handle, domid);
   5.100 +    nr_pages = mem_mb << (20 - PAGE_SHIFT);
   5.101      DPRINTF("nr_pages 0x%lx\n", nr_pages);
   5.102  
   5.103      rma_pages = get_rma_pages(devtree);
   5.104 @@ -258,7 +286,7 @@ int xc_linux_build(int xc_handle,
   5.105      }
   5.106  
   5.107      /* start_info stuff: about to be removed  */
   5.108 -    start_info_addr = create_start_info(&start_info, console_evtchn,
   5.109 +    start_info_addr = create_start_info(devtree, &start_info, console_evtchn,
   5.110                                          store_evtchn, nr_pages, rma_pages);
   5.111      *console_mfn = page_array[start_info.console.domU.mfn];
   5.112      *store_mfn = page_array[start_info.store_mfn];
     6.1 --- a/tools/libxc/powerpc64/xc_prose_build.c	Fri Dec 01 19:11:02 2006 -0500
     6.2 +++ b/tools/libxc/powerpc64/xc_prose_build.c	Tue Dec 12 09:56:06 2006 -0600
     6.3 @@ -230,6 +230,7 @@ static void free_page_array(xen_pfn_t *p
     6.4  
     6.5  int xc_prose_build(int xc_handle,
     6.6                     uint32_t domid,
     6.7 +                   unsigned int mem_mb,
     6.8                     const char *image_name,
     6.9                     const char *initrd_name,
    6.10                     const char *cmdline,
    6.11 @@ -257,8 +258,7 @@ int xc_prose_build(int xc_handle,
    6.12  
    6.13      DPRINTF("cmdline=%s\n", cmdline);
    6.14  
    6.15 -    DPRINTF("xc_get_tot_pages\n");
    6.16 -    nr_pages = xc_get_tot_pages(xc_handle, domid);
    6.17 +    nr_pages = mem_mb << (20 - PAGE_SHIFT);
    6.18      DPRINTF("nr_pages 0x%lx\n", nr_pages);
    6.19  
    6.20      rma_pages = get_rma_pages(devtree);
     7.1 --- a/tools/libxc/xenctrl.h	Fri Dec 01 19:11:02 2006 -0500
     7.2 +++ b/tools/libxc/xenctrl.h	Tue Dec 12 09:56:06 2006 -0600
     7.3 @@ -439,6 +439,10 @@ int xc_domain_memory_populate_physmap(in
     7.4                                        unsigned int address_bits,
     7.5                                        xen_pfn_t *extent_start);
     7.6  
     7.7 +int xc_alloc_real_mode_area(int xc_handle,
     7.8 +                            uint32_t domid,
     7.9 +                            unsigned int log);
    7.10 +
    7.11  int xc_domain_ioport_permission(int xc_handle,
    7.12                                  uint32_t domid,
    7.13                                  uint32_t first_port,
     8.1 --- a/tools/libxc/xenguest.h	Fri Dec 01 19:11:02 2006 -0500
     8.2 +++ b/tools/libxc/xenguest.h	Tue Dec 12 09:56:06 2006 -0600
     8.3 @@ -124,6 +124,7 @@ int xc_get_hvm_param(
     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 *ramdisk_name,
    8.10                     const char *cmdline,
     9.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Dec 01 19:11:02 2006 -0500
     9.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Tue Dec 12 09:56:06 2006 -0600
     9.3 @@ -809,6 +809,28 @@ static PyObject *pyxc_domain_memory_incr
     9.4      return zero;
     9.5  }
     9.6  
     9.7 +#ifdef __powerpc__
     9.8 +static PyObject *pyxc_alloc_real_mode_area(XcObject *self,
     9.9 +                                           PyObject *args,
    9.10 +                                           PyObject *kwds)
    9.11 +{
    9.12 +    uint32_t dom;
    9.13 +    unsigned int log;
    9.14 +
    9.15 +    static char *kwd_list[] = { "dom", "log", NULL };
    9.16 +
    9.17 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, 
    9.18 +                                      &dom, &log) )
    9.19 +        return NULL;
    9.20 +
    9.21 +    if ( xc_alloc_real_mode_area(self->xc_handle, dom, log) )
    9.22 +        return PyErr_SetFromErrno(xc_error);
    9.23 +
    9.24 +    Py_INCREF(zero);
    9.25 +    return zero;
    9.26 +}
    9.27 +#endif
    9.28 +
    9.29  static PyObject *pyxc_domain_ioport_permission(XcObject *self,
    9.30                                                 PyObject *args,
    9.31                                                 PyObject *kwds)
    9.32 @@ -1185,6 +1207,16 @@ static PyMethodDef pyxc_methods[] = {
    9.33        " mem_kb [long]: .\n"
    9.34        "Returns: [int] 0 on success; -1 on error.\n" },
    9.35  
    9.36 +#ifdef __powerpc__
    9.37 +    { "arch_alloc_real_mode_area", 
    9.38 +      (PyCFunction)pyxc_alloc_real_mode_area, 
    9.39 +      METH_VARARGS | METH_KEYWORDS, "\n"
    9.40 +      "Allocate a domain's real mode area.\n"
    9.41 +      " dom [int]: Identifier of domain.\n"
    9.42 +      " log [int]: Specifies the area's size.\n"
    9.43 +      "Returns: [int] 0 on success; -1 on error.\n" },
    9.44 +#endif
    9.45 +
    9.46      { "domain_ioport_permission",
    9.47        (PyCFunction)pyxc_domain_ioport_permission,
    9.48        METH_VARARGS | METH_KEYWORDS, "\n"
    10.1 --- a/tools/python/xen/xend/FlatDeviceTree.py	Fri Dec 01 19:11:02 2006 -0500
    10.2 +++ b/tools/python/xen/xend/FlatDeviceTree.py	Tue Dec 12 09:56:06 2006 -0600
    10.3 @@ -22,6 +22,10 @@ import sys
    10.4  import struct
    10.5  import stat
    10.6  import re
    10.7 +import glob
    10.8 +import math
    10.9 +
   10.10 +_host_devtree_root = '/proc/device-tree'
   10.11  
   10.12  _OF_DT_HEADER = int("d00dfeed", 16) # avoid signed/unsigned FutureWarning
   10.13  _OF_DT_BEGIN_NODE = 0x1
   10.14 @@ -33,8 +37,10 @@ def _bincat(seq, separator=''):
   10.15      '''Concatenate the contents of seq into a bytestream.'''
   10.16      strs = []
   10.17      for item in seq:
   10.18 -        if type(item) == type(0):
   10.19 +        if isinstance(item, int):
   10.20              strs.append(struct.pack(">I", item))
   10.21 +        elif isinstance(item, long):
   10.22 +            strs.append(struct.pack(">Q", item))
   10.23          else:
   10.24              try:
   10.25                  strs.append(item.to_bin())
   10.26 @@ -231,38 +237,51 @@ class Tree(_Node):
   10.27          header.totalsize = len(payload) + _alignup(len(header.to_bin()), 8)
   10.28          return _pad(header.to_bin(), 8) + payload
   10.29  
   10.30 -_host_devtree_root = '/proc/device-tree'
   10.31 -def _getprop(propname):
   10.32 -    '''Extract a property from the system's device tree.'''
   10.33 -    f = file(os.path.join(_host_devtree_root, propname), 'r')
   10.34 +def _readfile(fullpath):
   10.35 +    '''Return full contents of a file.'''
   10.36 +    f = file(fullpath, 'r')
   10.37      data = f.read()
   10.38      f.close()
   10.39      return data
   10.40  
   10.41 +def _find_first_cpu(dirpath):
   10.42 +    '''Find the first node of type 'cpu' in a directory tree.'''
   10.43 +    cpulist = glob.glob(os.path.join(dirpath, 'cpus', '*'))
   10.44 +    for node in cpulist:
   10.45 +        try:
   10.46 +            data = _readfile(os.path.join(node, 'device_type'))
   10.47 +        except IOError:
   10.48 +            continue
   10.49 +        if 'cpu' in data:
   10.50 +            return node
   10.51 +    raise IOError("couldn't find any CPU nodes under " + dirpath)
   10.52 +
   10.53  def _copynode(node, dirpath, propfilter):
   10.54 -    '''Extract all properties from a node in the system's device tree.'''
   10.55 +    '''Copy all properties and children nodes from a directory tree.'''
   10.56      dirents = os.listdir(dirpath)
   10.57      for dirent in dirents:
   10.58          fullpath = os.path.join(dirpath, dirent)
   10.59          st = os.lstat(fullpath)
   10.60          if stat.S_ISDIR(st.st_mode):
   10.61              child = node.addnode(dirent)
   10.62 -            _copytree(child, fullpath, propfilter)
   10.63 +            _copynode(child, fullpath, propfilter)
   10.64          elif stat.S_ISREG(st.st_mode) and propfilter(fullpath):
   10.65 -            node.addprop(dirent, _getprop(fullpath))
   10.66 -
   10.67 -def _copytree(node, dirpath, propfilter):
   10.68 -    path = os.path.join(_host_devtree_root, dirpath)
   10.69 -    _copynode(node, path, propfilter)
   10.70 +            node.addprop(dirent, _readfile(fullpath))
   10.71  
   10.72  def build(imghandler):
   10.73      '''Construct a device tree by combining the domain's configuration and
   10.74      the host's device tree.'''
   10.75      root = Tree()
   10.76  
   10.77 -    # 4 pages: start_info, console, store, shared_info
   10.78 +    # 1st reseravtion entry used for start_info, console, store, shared_info
   10.79      root.reserve(0x3ffc000, 0x4000)
   10.80  
   10.81 +    # 2nd reservation enrty used for initrd, later on when we load the
   10.82 +    # initrd we may fill this in with zeroes which signifies the end
   10.83 +    # of the reservation map.  So as to avoid adding a zero map now we
   10.84 +    # put some bogus yet sensible numbers here.
   10.85 +    root.reserve(0x1000000, 0x1000)
   10.86 +
   10.87      root.addprop('device_type', 'chrp-but-not-really\0')
   10.88      root.addprop('#size-cells', 2)
   10.89      root.addprop('#address-cells', 2)
   10.90 @@ -270,35 +289,52 @@ def build(imghandler):
   10.91      root.addprop('compatible', 'Momentum,Maple\0')
   10.92  
   10.93      xen = root.addnode('xen')
   10.94 -    xen.addprop('start-info', 0, 0x3ffc000, 0, 0x1000)
   10.95 +    xen.addprop('start-info', long(0x3ffc000), long(0x1000))
   10.96      xen.addprop('version', 'Xen-3.0-unstable\0')
   10.97 -    xen.addprop('reg', 0, imghandler.vm.domid, 0, 0)
   10.98 +    xen.addprop('reg', long(imghandler.vm.domid), long(0))
   10.99      xen.addprop('domain-name', imghandler.vm.getName() + '\0')
  10.100      xencons = xen.addnode('console')
  10.101      xencons.addprop('interrupts', 1, 0)
  10.102  
  10.103 -    # XXX split out RMA node
  10.104 -    mem = root.addnode('memory@0')
  10.105 +    # add memory nodes
  10.106      totalmem = imghandler.vm.getMemoryTarget() * 1024
  10.107 -    mem.addprop('reg', 0, 0, 0, totalmem)
  10.108 -    mem.addprop('device_type', 'memory\0')
  10.109 +    rma_log = 26 ### imghandler.vm.info.get('powerpc_rma_log')
  10.110 +    rma_bytes = 1 << rma_log
  10.111  
  10.112 +    # RMA node
  10.113 +    rma = root.addnode('memory@0')
  10.114 +    rma.addprop('reg', long(0), long(rma_bytes))
  10.115 +    rma.addprop('device_type', 'memory\0')
  10.116 +
  10.117 +    # all the rest in a single node
  10.118 +    remaining = totalmem - rma_bytes
  10.119 +    if remaining > 0:
  10.120 +        mem = root.addnode('memory@1')
  10.121 +        mem.addprop('reg', long(rma_bytes), long(remaining))
  10.122 +        mem.addprop('device_type', 'memory\0')
  10.123 +
  10.124 +    # add CPU nodes
  10.125      cpus = root.addnode('cpus')
  10.126      cpus.addprop('smp-enabled')
  10.127      cpus.addprop('#size-cells', 0)
  10.128      cpus.addprop('#address-cells', 1)
  10.129  
  10.130      # Copy all properties the system firmware gave us, except for 'linux,'
  10.131 -    # properties, from 'cpus/@0', once for every vcpu. Hopefully all cpus are
  10.132 -    # identical...
  10.133 +    # properties, from the first CPU node in the device tree. Do this once for
  10.134 +    # every vcpu. Hopefully all cpus are identical...
  10.135      cpu0 = None
  10.136 +    cpu0path = _find_first_cpu(_host_devtree_root)
  10.137      def _nolinuxprops(fullpath):
  10.138          return not os.path.basename(fullpath).startswith('linux,')
  10.139      for i in range(imghandler.vm.getVCpuCount()):
  10.140 -        cpu = cpus.addnode('PowerPC,970@0')
  10.141 -        _copytree(cpu, 'cpus/PowerPC,970@0', _nolinuxprops)
  10.142 -        # and then overwrite what we need to
  10.143 -        pft_size = imghandler.vm.info.get('pft-size', 0x14)
  10.144 +        # create new node and copy all properties
  10.145 +        cpu = cpus.addnode('PowerPC,970@%d' % i)
  10.146 +        _copynode(cpu, cpu0path, _nolinuxprops)
  10.147 +
  10.148 +        # overwrite what we need to
  10.149 +        shadow_mb = imghandler.vm.info.get('shadow_memory', 1)
  10.150 +        shadow_mb_log = int(math.log(shadow_mb, 2))
  10.151 +        pft_size = shadow_mb_log + 20
  10.152          cpu.setprop('ibm,pft-size', 0, pft_size)
  10.153  
  10.154          # set default CPU
  10.155 @@ -307,13 +343,13 @@ def build(imghandler):
  10.156  
  10.157      chosen = root.addnode('chosen')
  10.158      chosen.addprop('cpu', cpu0.get_phandle())
  10.159 -    chosen.addprop('memory', mem.get_phandle())
  10.160 +    chosen.addprop('memory', rma.get_phandle())
  10.161      chosen.addprop('linux,stdout-path', '/xen/console\0')
  10.162      chosen.addprop('interrupt-controller', xen.get_phandle())
  10.163      chosen.addprop('bootargs', imghandler.cmdline + '\0')
  10.164      # xc_linux_load.c will overwrite these 64-bit properties later
  10.165 -    chosen.addprop('linux,initrd-start', 0, 0)
  10.166 -    chosen.addprop('linux,initrd-end', 0, 0)
  10.167 +    chosen.addprop('linux,initrd-start', long(0))
  10.168 +    chosen.addprop('linux,initrd-end', long(0))
  10.169  
  10.170      if 1:
  10.171          f = file('/tmp/domU.dtb', 'w')
    11.1 --- a/tools/python/xen/xend/image.py	Fri Dec 01 19:11:02 2006 -0500
    11.2 +++ b/tools/python/xen/xend/image.py	Tue Dec 12 09:56:06 2006 -0600
    11.3 @@ -246,6 +246,15 @@ class PPC_LinuxImageHandler(LinuxImageHa
    11.4                                features       = self.vm.getFeatures(),
    11.5                                arch_args      = devtree.to_bin())
    11.6  
    11.7 +    def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb):
    11.8 +        """@param shadow_mem_kb The configured shadow memory, in KiB.
    11.9 +        @param maxmem_kb The configured maxmem, in KiB.
   11.10 +        @return The corresponding required amount of shadow memory, also in
   11.11 +        KiB.
   11.12 +        PowerPC currently uses "shadow memory" to refer to the hash table."""
   11.13 +        return max(maxmem_kb / 64, shadow_mem_kb)
   11.14 +
   11.15 +
   11.16  class PPC_ProseImageHandler(LinuxImageHandler):
   11.17  
   11.18      ostype = "prose"
   11.19 @@ -273,6 +282,7 @@ class PPC_ProseImageHandler(LinuxImageHa
   11.20          devtree = FlatDeviceTree.build(self)
   11.21  
   11.22          return xc.prose_build(dom            = self.vm.getDomid(),
   11.23 +                              memsize        = mem_mb,
   11.24                                image          = self.kernel,
   11.25                                store_evtchn   = store_evtchn,
   11.26                                console_evtchn = console_evtchn,
    12.1 --- a/xen/arch/powerpc/Makefile	Fri Dec 01 19:11:02 2006 -0500
    12.2 +++ b/xen/arch/powerpc/Makefile	Tue Dec 12 09:56:06 2006 -0600
    12.3 @@ -27,6 +27,7 @@ obj-y += memory.o
    12.4  obj-y += mm.o
    12.5  obj-y += mpic.o
    12.6  obj-y += mpic_init.o
    12.7 +obj-y += numa.o
    12.8  obj-y += of-devtree.o
    12.9  obj-y += of-devwalk.o
   12.10  obj-y += ofd_fixup.o
   12.11 @@ -36,6 +37,7 @@ obj-y += rtas.o
   12.12  obj-y += setup.o
   12.13  obj-y += shadow.o
   12.14  obj-y += smp.o
   12.15 +obj-y += smpboot.o
   12.16  obj-y += smp-tbsync.o
   12.17  obj-y += sysctl.o
   12.18  obj-y += time.o
   12.19 @@ -73,6 +75,7 @@ firmware_image.bin: firmware
   12.20  #
   12.21  irq.o: ../x86/irq.c
   12.22  physdev.o: ../x86/physdev.c
   12.23 +numa.o: ../x86/numa.c
   12.24  
   12.25  HDRS += $(wildcard *.h)
   12.26  
    13.1 --- a/xen/arch/powerpc/domain.c	Fri Dec 01 19:11:02 2006 -0500
    13.2 +++ b/xen/arch/powerpc/domain.c	Tue Dec 12 09:56:06 2006 -0600
    13.3 @@ -105,15 +105,15 @@ void arch_domain_destroy(struct domain *
    13.4  
    13.5  static void machine_fail(const char *s)
    13.6  {
    13.7 -    printf("%s failed, manual powercycle required!\n", s);
    13.8 +    printk("%s failed, manual powercycle required!\n", s);
    13.9      for (;;)
   13.10          sleep();
   13.11  }
   13.12 -
   13.13  void machine_halt(void)
   13.14  {
   13.15 +    printk("machine_halt called: spinning....\n");
   13.16      console_start_sync();
   13.17 -    printf("%s called\n", __func__);
   13.18 +    printk("%s called\n", __func__);
   13.19      rtas_halt();
   13.20  
   13.21      machine_fail(__func__);
   13.22 @@ -121,8 +121,9 @@ void machine_halt(void)
   13.23  
   13.24  void machine_restart(char * __unused)
   13.25  {
   13.26 +    printk("machine_restart called: spinning....\n");
   13.27      console_start_sync();
   13.28 -    printf("%s called\n", __func__);
   13.29 +    printk("%s called\n", __func__);
   13.30      rtas_reboot();
   13.31      machine_fail(__func__);
   13.32  }
    14.1 --- a/xen/arch/powerpc/memory.c	Fri Dec 01 19:11:02 2006 -0500
    14.2 +++ b/xen/arch/powerpc/memory.c	Tue Dec 12 09:56:06 2006 -0600
    14.3 @@ -20,6 +20,7 @@
    14.4   */
    14.5  #include <xen/sched.h>
    14.6  #include <xen/mm.h>
    14.7 +#include <xen/numa.h>
    14.8  #include "of-devtree.h"
    14.9  #include "oftree.h"
   14.10  #include "rtas.h"
   14.11 @@ -238,6 +239,9 @@ void memory_init(module_t *mod, int mcou
   14.12      DBG("total_pages: 0x%016lx\n", total_pages);
   14.13  
   14.14      init_frametable();
   14.15 +
   14.16 +    numa_initmem_init(0, max_page);
   14.17 +
   14.18      end_boot_allocator();
   14.19  
   14.20      /* Add memory between the beginning of the heap and the beginning
    15.1 --- a/xen/arch/powerpc/mm.c	Fri Dec 01 19:11:02 2006 -0500
    15.2 +++ b/xen/arch/powerpc/mm.c	Tue Dec 12 09:56:06 2006 -0600
    15.3 @@ -284,21 +284,21 @@ extern void copy_page(void *dp, void *sp
    15.4      }
    15.5  }
    15.6  
    15.7 +/* XXX should probably replace with faster data structure */
    15.8  static uint add_extent(struct domain *d, struct page_info *pg, uint order)
    15.9  {
   15.10      struct page_extents *pe;
   15.11  
   15.12      pe = xmalloc(struct page_extents);
   15.13      if (pe == NULL)
   15.14 -        return 0;
   15.15 +        return -ENOMEM;
   15.16  
   15.17      pe->pg = pg;
   15.18      pe->order = order;
   15.19 -    pe->pfn = page_to_mfn(pg);
   15.20  
   15.21      list_add_tail(&pe->pe_list, &d->arch.extent_list);
   15.22  
   15.23 -    return pe->pfn;
   15.24 +    return 0;
   15.25  }
   15.26  
   15.27  void free_extents(struct domain *d)
   15.28 @@ -337,7 +337,7 @@ uint allocate_extents(struct domain *d, 
   15.29          if (pg == NULL)
   15.30              return total_nrpages;
   15.31  
   15.32 -        if (add_extent(d, pg, ext_order) == 0) {
   15.33 +        if (add_extent(d, pg, ext_order) < 0) {
   15.34              free_domheap_pages(pg, ext_order);
   15.35              return total_nrpages;
   15.36          }
   15.37 @@ -390,6 +390,7 @@ int allocate_rma(struct domain *d, unsig
   15.38  
   15.39      return 0;
   15.40  }
   15.41 +
   15.42  void free_rma_check(struct page_info *page)
   15.43  {
   15.44      if (test_bit(_PGC_page_RMA, &page->count_info) &&
   15.45 @@ -397,7 +398,6 @@ void free_rma_check(struct page_info *pa
   15.46          panic("Attempt to free an RMA page: 0x%lx\n", page_to_mfn(page));
   15.47  }
   15.48  
   15.49 -
   15.50  ulong pfn2mfn(struct domain *d, ulong pfn, int *type)
   15.51  {
   15.52      ulong rma_base_mfn = page_to_mfn(d->arch.rma_page);
   15.53 @@ -415,8 +415,7 @@ ulong pfn2mfn(struct domain *d, ulong pf
   15.54          /* Its a grant table access */
   15.55          t = PFN_TYPE_GNTTAB;
   15.56          mfn = gnttab_shared_mfn(d, d->grant_table, (pfn - max_page));
   15.57 -    } else if (test_bit(_DOMF_privileged, &d->domain_flags) &&
   15.58 -               cpu_io_mfn(pfn)) {
   15.59 +    } else if (d->is_privileged && cpu_io_mfn(pfn)) {
   15.60          t = PFN_TYPE_IO;
   15.61          mfn = pfn;
   15.62      } else {
   15.63 @@ -424,14 +423,18 @@ ulong pfn2mfn(struct domain *d, ulong pf
   15.64              t = PFN_TYPE_RMA;
   15.65              mfn = pfn + rma_base_mfn;
   15.66          } else {
   15.67 -            list_for_each_entry (pe, &d->arch.extent_list, pe_list) {
   15.68 -                uint end_pfn = pe->pfn + (1 << pe->order);
   15.69 +            ulong cur_pfn = rma_size_mfn;
   15.70  
   15.71 -                if (pfn >= pe->pfn && pfn < end_pfn) {
   15.72 +            list_for_each_entry (pe, &d->arch.extent_list, pe_list) {
   15.73 +                uint pe_pages = 1UL << pe->order;
   15.74 +                uint end_pfn = cur_pfn + pe_pages;
   15.75 +
   15.76 +                if (pfn >= cur_pfn && pfn < end_pfn) {
   15.77                      t = PFN_TYPE_LOGICAL;
   15.78 -                    mfn = page_to_mfn(pe->pg) + (pfn - pe->pfn);
   15.79 +                    mfn = page_to_mfn(pe->pg) + (pfn - cur_pfn);
   15.80                      break;
   15.81                  }
   15.82 +                cur_pfn += pe_pages;
   15.83              }
   15.84          }
   15.85  #ifdef DEBUG
   15.86 @@ -492,8 +495,7 @@ unsigned long mfn_to_gmfn(struct domain 
   15.87          return max_page + (mfn - gnttab_mfn);
   15.88  
   15.89      /* IO? */
   15.90 -    if (test_bit(_DOMF_privileged, &d->domain_flags) &&
   15.91 -        cpu_io_mfn(mfn))
   15.92 +    if (d->is_privileged && cpu_io_mfn(mfn))
   15.93          return mfn;
   15.94  
   15.95      rma_mfn = page_to_mfn(d->arch.rma_page);
   15.96 @@ -530,3 +532,10 @@ void shadow_drop_references(
   15.97      struct domain *d, struct page_info *page)
   15.98  {
   15.99  }
  15.100 +
  15.101 +int arch_domain_add_extent(struct domain *d, struct page_info *page, int order)
  15.102 +{
  15.103 +    if (add_extent(d, page, order) < 0)
  15.104 +        return -ENOMEM;
  15.105 +    return 0;
  15.106 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/xen/arch/powerpc/numa.c	Tue Dec 12 09:56:06 2006 -0600
    16.3 @@ -0,0 +1,1 @@
    16.4 +#include "../x86/numa.c"
    17.1 --- a/xen/arch/powerpc/ofd_fixup_memory.c	Fri Dec 01 19:11:02 2006 -0500
    17.2 +++ b/xen/arch/powerpc/ofd_fixup_memory.c	Tue Dec 12 09:56:06 2006 -0600
    17.3 @@ -68,6 +68,8 @@ static ofdn_t ofd_memory_node_create(
    17.4      reg.sz = size;
    17.5      ofd_prop_add(m, n, "reg", &reg, sizeof (reg));
    17.6  
    17.7 +    printk("Dom0: %s: %016lx, %016lx\n", path, start, size);
    17.8 +
    17.9      return n;
   17.10  }
   17.11  
   17.12 @@ -86,17 +88,19 @@ static void ofd_memory_extent_nodes(void
   17.13      ulong size;
   17.14      ofdn_t n;
   17.15      struct page_extents *pe;
   17.16 +    ulong cur_pfn = 1UL << d->arch.rma_order;
   17.17  
   17.18 +    start = cur_pfn << PAGE_SHIFT;
   17.19 +    size = 0;
   17.20      list_for_each_entry (pe, &d->arch.extent_list, pe_list) {
   17.21  
   17.22 -        start = pe->pfn << PAGE_SHIFT;
   17.23 -        size = 1UL << (pe->order + PAGE_SHIFT);
   17.24 -
   17.25 -        n = ofd_memory_node_create(m, OFD_ROOT, "", memory, memory,
   17.26 -                                    start, size);
   17.27 -
   17.28 -        BUG_ON(n <= 0);
   17.29 +        size += 1UL << (pe->order + PAGE_SHIFT);
   17.30 +        if (pe->order != cpu_extent_order())
   17.31 +            panic("we don't handle this yet\n");
   17.32      }
   17.33 +    n = ofd_memory_node_create(m, OFD_ROOT, "", memory, memory,
   17.34 +                               start, size);
   17.35 +    BUG_ON(n <= 0);
   17.36  }
   17.37  
   17.38  void ofd_memory_props(void *m, struct domain *d)
    18.1 --- a/xen/arch/powerpc/papr/xlate.c	Fri Dec 01 19:11:02 2006 -0500
    18.2 +++ b/xen/arch/powerpc/papr/xlate.c	Tue Dec 12 09:56:06 2006 -0600
    18.3 @@ -178,7 +178,7 @@ long pte_enter(ulong flags, ulong ptex, 
    18.4          return H_Parameter;
    18.5      }
    18.6  
    18.7 -    if (mtype == PFN_TYPE_IO &&!test_bit(_DOMF_privileged, &d->domain_flags)) {
    18.8 +    if (mtype == PFN_TYPE_IO && !d->is_privileged) {
    18.9          /* only a privilaged dom can access outside IO space */
   18.10          DBG("%s: unprivileged access to physical page: 0x%lx\n",
   18.11              __func__, pfn);
    19.1 --- a/xen/arch/powerpc/powerpc64/ppc970.c	Fri Dec 01 19:11:02 2006 -0500
    19.2 +++ b/xen/arch/powerpc/powerpc64/ppc970.c	Tue Dec 12 09:56:06 2006 -0600
    19.3 @@ -193,8 +193,8 @@ void cpu_initialize(int cpuid)
    19.4      mtdec(timebase_freq);
    19.5      mthdec(timebase_freq);
    19.6  
    19.7 -    /* FIXME Do not set the NAP and DPM bits in HID0 until we have had a
    19.8 -     * chance to audit the safe halt and idle loop code. */
    19.9 +    /* FIXME Do not set the NAP bit in HID0 until we have had a chance
   19.10 +     * to audit the safe halt and idle loop code. */
   19.11      hid0.bits.nap = 0;      /* NAP */
   19.12      hid0.bits.dpm = 1;      /* Dynamic Power Management */
   19.13  
    20.1 --- a/xen/arch/powerpc/setup.c	Fri Dec 01 19:11:02 2006 -0500
    20.2 +++ b/xen/arch/powerpc/setup.c	Tue Dec 12 09:56:06 2006 -0600
    20.3 @@ -35,6 +35,7 @@
    20.4  #include <xen/gdbstub.h>
    20.5  #include <xen/symbols.h>
    20.6  #include <xen/keyhandler.h>
    20.7 +#include <xen/numa.h>
    20.8  #include <acm/acm_hooks.h>
    20.9  #include <public/version.h>
   20.10  #include <asm/mpic.h>
   20.11 @@ -77,10 +78,7 @@ ulong oftree_len;
   20.12  ulong oftree_end;
   20.13  
   20.14  uint cpu_hard_id[NR_CPUS] __initdata;
   20.15 -cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
   20.16 -cpumask_t cpu_online_map; /* missing ifdef in schedule.c */
   20.17  cpumask_t cpu_present_map;
   20.18 -cpumask_t cpu_possible_map;
   20.19  
   20.20  /* XXX get this from ISA node in device tree */
   20.21  char *vgabase;
   20.22 @@ -210,6 +208,15 @@ void startup_cpu_idle_loop(void)
   20.23      reset_stack_and_jump(idle_loop);
   20.24  }
   20.25  
   20.26 +/* The boot_pa is enough "parea" for the boot CPU to get thru
   20.27 + * initialization, it will ultimately get replaced later */
   20.28 +static __init void init_boot_cpu(void)
   20.29 +{
   20.30 +    static struct processor_area boot_pa;
   20.31 +    boot_pa.whoami = 0;
   20.32 +    parea = &boot_pa;
   20.33 +}    
   20.34 +
   20.35  static void init_parea(int cpuid)
   20.36  {
   20.37      /* Be careful not to shadow the global variable.  */
   20.38 @@ -250,6 +257,9 @@ static int kick_secondary_cpus(int maxcp
   20.39          /* wait for it */
   20.40          while (!cpu_online(cpuid))
   20.41              cpu_relax();
   20.42 +
   20.43 +        numa_set_node(cpuid, 0);
   20.44 +        numa_add_cpu(cpuid);
   20.45      }
   20.46  
   20.47      return 0;
   20.48 @@ -293,6 +303,9 @@ static void __init __start_xen(multiboot
   20.49      if ((mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0))
   20.50          cmdline_parse(__va((ulong)mbi->cmdline));
   20.51  
   20.52 +    /* we need to be able to identify this CPU early on */
   20.53 +    init_boot_cpu();
   20.54 +
   20.55      /* We initialise the serial devices very early so we can get debugging. */
   20.56      ns16550.io_base = 0x3f8;
   20.57      ns16550_init(0, &ns16550);
    21.1 --- a/xen/arch/powerpc/shadow.c	Fri Dec 01 19:11:02 2006 -0500
    21.2 +++ b/xen/arch/powerpc/shadow.c	Tue Dec 12 09:56:06 2006 -0600
    21.3 @@ -101,9 +101,6 @@ unsigned int shadow_set_allocation(struc
    21.4  
    21.5      addr = htab_alloc(d, order);
    21.6  
    21.7 -    printk("%s: ibm,fpt-size should be: 0x%x\n", __func__,
    21.8 -           d->arch.htab.log_num_ptes + LOG_PTE_SIZE);
    21.9 -
   21.10      if (addr == 0)
   21.11          return -ENOMEM;
   21.12  
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/xen/arch/powerpc/smpboot.c	Tue Dec 12 09:56:06 2006 -0600
    22.3 @@ -0,0 +1,29 @@
    22.4 +
    22.5 +#include <xen/config.h>
    22.6 +#include <xen/init.h>
    22.7 +#include <xen/types.h>
    22.8 +#include <xen/cpumask.h>
    22.9 +#include <asm/cache.h>
   22.10 +
   22.11 +/* representing HT siblings of each logical CPU */
   22.12 +cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
   22.13 +EXPORT_SYMBOL(cpu_sibling_map);
   22.14 +
   22.15 +/* representing HT and core siblings of each logical CPU */
   22.16 +cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
   22.17 +EXPORT_SYMBOL(cpu_core_map);
   22.18 +
   22.19 +/* bitmap of online cpus */
   22.20 +cpumask_t cpu_online_map __read_mostly;
   22.21 +EXPORT_SYMBOL(cpu_online_map);
   22.22 +
   22.23 +
   22.24 +#ifdef CONFIG_HOTPLUG_CPU
   22.25 +cpumask_t cpu_possible_map = CPU_MASK_ALL;
   22.26 +#else
   22.27 +cpumask_t cpu_possible_map;
   22.28 +#endif
   22.29 +EXPORT_SYMBOL(cpu_possible_map);
   22.30 +
   22.31 +u8 x86_cpu_to_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0xff };
   22.32 +EXPORT_SYMBOL(x86_cpu_to_apicid);
    23.1 --- a/xen/arch/powerpc/usercopy.c	Fri Dec 01 19:11:02 2006 -0500
    23.2 +++ b/xen/arch/powerpc/usercopy.c	Tue Dec 12 09:56:06 2006 -0600
    23.3 @@ -18,24 +18,14 @@
    23.4   * Authors: Hollis Blanchard <hollisb@us.ibm.com>
    23.5   */
    23.6  
    23.7 -#include <xen/config.h>
    23.8 -#include <xen/mm.h>
    23.9  #include <xen/sched.h>
   23.10 +#include <xen/lib.h>
   23.11  #include <asm/current.h>
   23.12 -#include <asm/uaccess.h>
   23.13 +#include <asm/page.h>
   23.14  #include <asm/debugger.h>
   23.15 -#include <public/xen.h>
   23.16 -#include <public/xencomm.h>
   23.17 -
   23.18 -#undef DEBUG
   23.19 -#ifdef DEBUG
   23.20 -static int xencomm_debug = 1; /* extremely verbose */
   23.21 -#else
   23.22 -#define xencomm_debug 0
   23.23 -#endif
   23.24  
   23.25  /* XXX need to return error, not panic, if domain passed a bad pointer */
   23.26 -static unsigned long paddr_to_maddr(unsigned long paddr)
   23.27 +unsigned long paddr_to_maddr(unsigned long paddr)
   23.28  {
   23.29      struct vcpu *v = get_current();
   23.30      struct domain *d = v->domain;
   23.31 @@ -58,208 +48,3 @@ static unsigned long paddr_to_maddr(unsi
   23.32  
   23.33      return pa;
   23.34  }
   23.35 -
   23.36 -/**
   23.37 - * xencomm_copy_from_guest: Copy a block of data from domain space.
   23.38 - * @to:   Machine address.
   23.39 - * @from: Physical address to a xencomm buffer descriptor.
   23.40 - * @n:    Number of bytes to copy.
   23.41 - * @skip: Number of bytes from the start to skip.
   23.42 - *
   23.43 - * Copy data from domain to hypervisor.
   23.44 - *
   23.45 - * Returns number of bytes that could not be copied.
   23.46 - * On success, this will be zero.
   23.47 - */
   23.48 -unsigned long
   23.49 -xencomm_copy_from_guest(void *to, const void *from, unsigned int n,
   23.50 -        unsigned int skip)
   23.51 -{
   23.52 -    struct xencomm_desc *desc;
   23.53 -    unsigned int from_pos = 0;
   23.54 -    unsigned int to_pos = 0;
   23.55 -    unsigned int i = 0;
   23.56 -
   23.57 -    /* first we need to access the descriptor */
   23.58 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)from);
   23.59 -    if (desc == NULL)
   23.60 -        return n;
   23.61 -
   23.62 -    if (desc->magic != XENCOMM_MAGIC) {
   23.63 -        printk("%s: error: %p magic was 0x%x\n",
   23.64 -               __func__, desc, desc->magic);
   23.65 -        return n;
   23.66 -    }
   23.67 -
   23.68 -    /* iterate through the descriptor, copying up to a page at a time */
   23.69 -    while ((to_pos < n) && (i < desc->nr_addrs)) {
   23.70 -        unsigned long src_paddr = desc->address[i];
   23.71 -        unsigned int pgoffset;
   23.72 -        unsigned int chunksz;
   23.73 -        unsigned int chunk_skip;
   23.74 -
   23.75 -        if (src_paddr == XENCOMM_INVALID) {
   23.76 -            i++;
   23.77 -            continue;
   23.78 -        }
   23.79 -
   23.80 -        pgoffset = src_paddr % PAGE_SIZE;
   23.81 -        chunksz = PAGE_SIZE - pgoffset;
   23.82 -
   23.83 -        chunk_skip = min(chunksz, skip);
   23.84 -        from_pos += chunk_skip;
   23.85 -        chunksz -= chunk_skip;
   23.86 -        skip -= chunk_skip;
   23.87 -
   23.88 -        if (skip == 0) {
   23.89 -            unsigned long src_maddr;
   23.90 -            unsigned long dest = (unsigned long)to + to_pos;
   23.91 -            unsigned int bytes = min(chunksz, n - to_pos);
   23.92 -
   23.93 -            src_maddr = paddr_to_maddr(src_paddr + chunk_skip);
   23.94 -            if (src_maddr == 0)
   23.95 -                return n - to_pos;
   23.96 -
   23.97 -            if (xencomm_debug)
   23.98 -                printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest);
   23.99 -            memcpy((void *)dest, (void *)src_maddr, bytes);
  23.100 -            from_pos += bytes;
  23.101 -            to_pos += bytes;
  23.102 -        }
  23.103 -
  23.104 -        i++;
  23.105 -    }
  23.106 -
  23.107 -    return n - to_pos;
  23.108 -}
  23.109 -
  23.110 -/**
  23.111 - * xencomm_copy_to_guest: Copy a block of data to domain space.
  23.112 - * @to:     Physical address to xencomm buffer descriptor.
  23.113 - * @from:   Machine address.
  23.114 - * @n:      Number of bytes to copy.
  23.115 - * @skip: Number of bytes from the start to skip.
  23.116 - *
  23.117 - * Copy data from hypervisor to domain.
  23.118 - *
  23.119 - * Returns number of bytes that could not be copied.
  23.120 - * On success, this will be zero.
  23.121 - */
  23.122 -unsigned long
  23.123 -xencomm_copy_to_guest(void *to, const void *from, unsigned int n,
  23.124 -        unsigned int skip)
  23.125 -{
  23.126 -    struct xencomm_desc *desc;
  23.127 -    unsigned int from_pos = 0;
  23.128 -    unsigned int to_pos = 0;
  23.129 -    unsigned int i = 0;
  23.130 -
  23.131 -    /* first we need to access the descriptor */
  23.132 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)to);
  23.133 -    if (desc == NULL)
  23.134 -        return n;
  23.135 -
  23.136 -    if (desc->magic != XENCOMM_MAGIC) {
  23.137 -        printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
  23.138 -        return n;
  23.139 -    }
  23.140 -
  23.141 -    /* iterate through the descriptor, copying up to a page at a time */
  23.142 -    while ((from_pos < n) && (i < desc->nr_addrs)) {
  23.143 -        unsigned long dest_paddr = desc->address[i];
  23.144 -        unsigned int pgoffset;
  23.145 -        unsigned int chunksz;
  23.146 -        unsigned int chunk_skip;
  23.147 -
  23.148 -        if (dest_paddr == XENCOMM_INVALID) {
  23.149 -            i++;
  23.150 -            continue;
  23.151 -        }
  23.152 -
  23.153 -        pgoffset = dest_paddr % PAGE_SIZE;
  23.154 -        chunksz = PAGE_SIZE - pgoffset;
  23.155 -
  23.156 -        chunk_skip = min(chunksz, skip);
  23.157 -        to_pos += chunk_skip;
  23.158 -        chunksz -= chunk_skip;
  23.159 -        skip -= chunk_skip;
  23.160 -
  23.161 -        if (skip == 0) {
  23.162 -            unsigned long dest_maddr;
  23.163 -            unsigned long source = (unsigned long)from + from_pos;
  23.164 -            unsigned int bytes = min(chunksz, n - from_pos);
  23.165 -
  23.166 -            dest_maddr = paddr_to_maddr(dest_paddr + chunk_skip);
  23.167 -            if (dest_maddr == 0)
  23.168 -                return -1;
  23.169 -
  23.170 -            if (xencomm_debug)
  23.171 -                printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr);
  23.172 -            memcpy((void *)dest_maddr, (void *)source, bytes);
  23.173 -            from_pos += bytes;
  23.174 -            to_pos += bytes;
  23.175 -        }
  23.176 -
  23.177 -        i++;
  23.178 -    }
  23.179 -
  23.180 -    return n - from_pos;
  23.181 -}
  23.182 -
  23.183 -/* Offset page addresses in 'handle' to skip 'bytes' bytes. Set completely
  23.184 - * exhausted pages to XENCOMM_INVALID. */
  23.185 -int xencomm_add_offset(void *handle, unsigned int bytes)
  23.186 -{
  23.187 -    struct xencomm_desc *desc;
  23.188 -    int i = 0;
  23.189 -
  23.190 -    /* first we need to access the descriptor */
  23.191 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)handle);
  23.192 -    if (desc == NULL)
  23.193 -        return -1;
  23.194 -
  23.195 -    if (desc->magic != XENCOMM_MAGIC) {
  23.196 -        printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
  23.197 -        return -1;
  23.198 -    }
  23.199 -
  23.200 -    /* iterate through the descriptor incrementing addresses */
  23.201 -    while ((bytes > 0) && (i < desc->nr_addrs)) {
  23.202 -        unsigned long dest_paddr = desc->address[i];
  23.203 -        unsigned int pgoffset;
  23.204 -        unsigned int chunksz;
  23.205 -        unsigned int chunk_skip;
  23.206 -
  23.207 -        if (dest_paddr == XENCOMM_INVALID) {
  23.208 -            i++;
  23.209 -            continue;
  23.210 -        }
  23.211 -
  23.212 -        pgoffset = dest_paddr % PAGE_SIZE;
  23.213 -        chunksz = PAGE_SIZE - pgoffset;
  23.214 -
  23.215 -        chunk_skip = min(chunksz, bytes);
  23.216 -        if (chunk_skip == chunksz) {
  23.217 -            /* exhausted this page */
  23.218 -            desc->address[i] = XENCOMM_INVALID;
  23.219 -        } else {
  23.220 -            desc->address[i] += chunk_skip;
  23.221 -        }
  23.222 -        bytes -= chunk_skip;
  23.223 -
  23.224 -	i++;
  23.225 -    }
  23.226 -    return 0;
  23.227 -}
  23.228 -
  23.229 -int xencomm_handle_is_null(void *ptr)
  23.230 -{
  23.231 -    struct xencomm_desc *desc;
  23.232 -
  23.233 -    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)ptr);
  23.234 -    if (desc == NULL)
  23.235 -        return 1;
  23.236 -
  23.237 -    return (desc->nr_addrs == 0);
  23.238 -}
  23.239 -
    24.1 --- a/xen/common/Makefile	Fri Dec 01 19:11:02 2006 -0500
    24.2 +++ b/xen/common/Makefile	Tue Dec 12 09:56:06 2006 -0600
    24.3 @@ -31,5 +31,7 @@ obj-$(perfc)       += perfc.o
    24.4  obj-$(crash_debug) += gdbstub.o
    24.5  obj-$(xenoprof)    += xenoprof.o
    24.6  
    24.7 +obj-$(CONFIG_XENCOMM) += xencomm.o
    24.8 +
    24.9  # Object file contains changeset and compiler information.
   24.10  version.o: $(BASEDIR)/include/xen/compile.h
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/xen/common/xencomm.c	Tue Dec 12 09:56:06 2006 -0600
    25.3 @@ -0,0 +1,316 @@
    25.4 +/*
    25.5 + * This program is free software; you can redistribute it and/or modify
    25.6 + * it under the terms of the GNU General Public License as published by
    25.7 + * the Free Software Foundation; either version 2 of the License, or
    25.8 + * (at your option) any later version.
    25.9 + *
   25.10 + * This program is distributed in the hope that it will be useful,
   25.11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   25.13 + * GNU General Public License for more details.
   25.14 + *
   25.15 + * You should have received a copy of the GNU General Public License
   25.16 + * along with this program; if not, write to the Free Software
   25.17 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   25.18 + *
   25.19 + * Copyright (C) IBM Corp. 2006
   25.20 + *
   25.21 + * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   25.22 + *          Tristan Gingold <tristan.gingold@bull.net>
   25.23 + */
   25.24 +
   25.25 +#include <xen/config.h>
   25.26 +#include <xen/mm.h>
   25.27 +#include <xen/sched.h>
   25.28 +#include <xen/xencomm.h>
   25.29 +#include <public/xen.h>
   25.30 +#include <public/xencomm.h>
   25.31 +
   25.32 +
   25.33 +#undef DEBUG
   25.34 +#ifdef DEBUG
   25.35 +static int xencomm_debug = 1; /* extremely verbose */
   25.36 +#else
   25.37 +#define xencomm_debug 0
   25.38 +#endif
   25.39 +
   25.40 +static unsigned long
   25.41 +xencomm_inline_from_guest(void *to, const void *from, unsigned int n,
   25.42 +        unsigned int skip)
   25.43 +{
   25.44 +    unsigned long src_paddr = xencomm_inline_addr(from);
   25.45 +
   25.46 +    src_paddr += skip;
   25.47 +
   25.48 +    while (n > 0) {
   25.49 +        unsigned int chunksz;
   25.50 +        unsigned long src_maddr;
   25.51 +        unsigned int bytes;
   25.52 +
   25.53 +        chunksz = PAGE_SIZE - (src_paddr % PAGE_SIZE);
   25.54 +
   25.55 +        bytes = min(chunksz, n);
   25.56 +
   25.57 +        src_maddr = paddr_to_maddr(src_paddr);
   25.58 +        if (xencomm_debug)
   25.59 +            printk("%lx[%d] -> %lx\n", src_maddr, bytes, (unsigned long)to);
   25.60 +        memcpy(to, (void *)src_maddr, bytes);
   25.61 +        src_paddr += bytes;
   25.62 +        to += bytes;
   25.63 +        n -= bytes;
   25.64 +    }
   25.65 +
   25.66 +    /* Always successful. */
   25.67 +    return 0;
   25.68 +}
   25.69 +
   25.70 +/**
   25.71 + * xencomm_copy_from_guest: Copy a block of data from domain space.
   25.72 + * @to:   Machine address.
   25.73 + * @from: Physical address to a xencomm buffer descriptor.
   25.74 + * @n:    Number of bytes to copy.
   25.75 + * @skip: Number of bytes from the start to skip.
   25.76 + *
   25.77 + * Copy data from domain to hypervisor.
   25.78 + *
   25.79 + * Returns number of bytes that could not be copied.
   25.80 + * On success, this will be zero.
   25.81 + */
   25.82 +unsigned long
   25.83 +xencomm_copy_from_guest(void *to, const void *from, unsigned int n,
   25.84 +        unsigned int skip)
   25.85 +{
   25.86 +    struct xencomm_desc *desc;
   25.87 +    unsigned int from_pos = 0;
   25.88 +    unsigned int to_pos = 0;
   25.89 +    unsigned int i = 0;
   25.90 +
   25.91 +    if (xencomm_is_inline(from))
   25.92 +        return xencomm_inline_from_guest(to, from, n, skip);
   25.93 +
   25.94 +    /* first we need to access the descriptor */
   25.95 +    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)from);
   25.96 +    if (desc == NULL)
   25.97 +        return n;
   25.98 +
   25.99 +    if (desc->magic != XENCOMM_MAGIC) {
  25.100 +        printk("%s: error: %p magic was 0x%x\n",
  25.101 +               __func__, desc, desc->magic);
  25.102 +        return n;
  25.103 +    }
  25.104 +
  25.105 +    /* iterate through the descriptor, copying up to a page at a time */
  25.106 +    while ((to_pos < n) && (i < desc->nr_addrs)) {
  25.107 +        unsigned long src_paddr = desc->address[i];
  25.108 +        unsigned int pgoffset;
  25.109 +        unsigned int chunksz;
  25.110 +        unsigned int chunk_skip;
  25.111 +
  25.112 +        if (src_paddr == XENCOMM_INVALID) {
  25.113 +            i++;
  25.114 +            continue;
  25.115 +        }
  25.116 +
  25.117 +        pgoffset = src_paddr % PAGE_SIZE;
  25.118 +        chunksz = PAGE_SIZE - pgoffset;
  25.119 +
  25.120 +        chunk_skip = min(chunksz, skip);
  25.121 +        from_pos += chunk_skip;
  25.122 +        chunksz -= chunk_skip;
  25.123 +        skip -= chunk_skip;
  25.124 +
  25.125 +        if (skip == 0) {
  25.126 +            unsigned long src_maddr;
  25.127 +            unsigned long dest = (unsigned long)to + to_pos;
  25.128 +            unsigned int bytes = min(chunksz, n - to_pos);
  25.129 +
  25.130 +            src_maddr = paddr_to_maddr(src_paddr + chunk_skip);
  25.131 +            if (src_maddr == 0)
  25.132 +                return n - to_pos;
  25.133 +
  25.134 +            if (xencomm_debug)
  25.135 +                printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest);
  25.136 +            memcpy((void *)dest, (void *)src_maddr, bytes);
  25.137 +            from_pos += bytes;
  25.138 +            to_pos += bytes;
  25.139 +        }
  25.140 +
  25.141 +        i++;
  25.142 +    }
  25.143 +
  25.144 +    return n - to_pos;
  25.145 +}
  25.146 +
  25.147 +static unsigned long
  25.148 +xencomm_inline_to_guest(void *to, const void *from, unsigned int n,
  25.149 +        unsigned int skip)
  25.150 +{
  25.151 +    unsigned long dest_paddr = xencomm_inline_addr(to);
  25.152 +
  25.153 +    dest_paddr += skip;
  25.154 +
  25.155 +    while (n > 0) {
  25.156 +        unsigned int chunksz;
  25.157 +        unsigned long dest_maddr;
  25.158 +        unsigned int bytes;
  25.159 +
  25.160 +        chunksz = PAGE_SIZE - (dest_paddr % PAGE_SIZE);
  25.161 +
  25.162 +        bytes = min(chunksz, n);
  25.163 +
  25.164 +        dest_maddr = paddr_to_maddr(dest_paddr);
  25.165 +        if (xencomm_debug)
  25.166 +            printk("%lx[%d] -> %lx\n", (unsigned long)from, bytes, dest_maddr);
  25.167 +        memcpy((void *)dest_maddr, (void *)from, bytes);
  25.168 +        dest_paddr += bytes;
  25.169 +        from += bytes;
  25.170 +        n -= bytes;
  25.171 +    }
  25.172 +
  25.173 +    /* Always successful.  */
  25.174 +    return 0;
  25.175 +}
  25.176 +
  25.177 +/**
  25.178 + * xencomm_copy_to_guest: Copy a block of data to domain space.
  25.179 + * @to:     Physical address to xencomm buffer descriptor.
  25.180 + * @from:   Machine address.
  25.181 + * @n:      Number of bytes to copy.
  25.182 + * @skip: Number of bytes from the start to skip.
  25.183 + *
  25.184 + * Copy data from hypervisor to domain.
  25.185 + *
  25.186 + * Returns number of bytes that could not be copied.
  25.187 + * On success, this will be zero.
  25.188 + */
  25.189 +unsigned long
  25.190 +xencomm_copy_to_guest(void *to, const void *from, unsigned int n,
  25.191 +        unsigned int skip)
  25.192 +{
  25.193 +    struct xencomm_desc *desc;
  25.194 +    unsigned int from_pos = 0;
  25.195 +    unsigned int to_pos = 0;
  25.196 +    unsigned int i = 0;
  25.197 +
  25.198 +    if (xencomm_is_inline(to))
  25.199 +        return xencomm_inline_to_guest(to, from, n, skip);
  25.200 +
  25.201 +    /* first we need to access the descriptor */
  25.202 +    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)to);
  25.203 +    if (desc == NULL)
  25.204 +        return n;
  25.205 +
  25.206 +    if (desc->magic != XENCOMM_MAGIC) {
  25.207 +        printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
  25.208 +        return n;
  25.209 +    }
  25.210 +
  25.211 +    /* iterate through the descriptor, copying up to a page at a time */
  25.212 +    while ((from_pos < n) && (i < desc->nr_addrs)) {
  25.213 +        unsigned long dest_paddr = desc->address[i];
  25.214 +        unsigned int pgoffset;
  25.215 +        unsigned int chunksz;
  25.216 +        unsigned int chunk_skip;
  25.217 +
  25.218 +        if (dest_paddr == XENCOMM_INVALID) {
  25.219 +            i++;
  25.220 +            continue;
  25.221 +        }
  25.222 +
  25.223 +        pgoffset = dest_paddr % PAGE_SIZE;
  25.224 +        chunksz = PAGE_SIZE - pgoffset;
  25.225 +
  25.226 +        chunk_skip = min(chunksz, skip);
  25.227 +        to_pos += chunk_skip;
  25.228 +        chunksz -= chunk_skip;
  25.229 +        skip -= chunk_skip;
  25.230 +
  25.231 +        if (skip == 0) {
  25.232 +            unsigned long dest_maddr;
  25.233 +            unsigned long source = (unsigned long)from + from_pos;
  25.234 +            unsigned int bytes = min(chunksz, n - from_pos);
  25.235 +
  25.236 +            dest_maddr = paddr_to_maddr(dest_paddr + chunk_skip);
  25.237 +            if (dest_maddr == 0)
  25.238 +                return -1;
  25.239 +
  25.240 +            if (xencomm_debug)
  25.241 +                printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr);
  25.242 +            memcpy((void *)dest_maddr, (void *)source, bytes);
  25.243 +            from_pos += bytes;
  25.244 +            to_pos += bytes;
  25.245 +        }
  25.246 +
  25.247 +        i++;
  25.248 +    }
  25.249 +
  25.250 +    return n - from_pos;
  25.251 +}
  25.252 +
  25.253 +static int xencomm_inline_add_offset(void **handle, unsigned int bytes)
  25.254 +{
  25.255 +    *handle += bytes;
  25.256 +    return 0;
  25.257 +}
  25.258 +
  25.259 +/* Offset page addresses in 'handle' to skip 'bytes' bytes. Set completely
  25.260 + * exhausted pages to XENCOMM_INVALID. */
  25.261 +int xencomm_add_offset(void **handle, unsigned int bytes)
  25.262 +{
  25.263 +    struct xencomm_desc *desc;
  25.264 +    int i = 0;
  25.265 +
  25.266 +    if (xencomm_is_inline(*handle))
  25.267 +        return xencomm_inline_add_offset(handle, bytes);
  25.268 +
  25.269 +    /* first we need to access the descriptor */
  25.270 +    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)*handle);
  25.271 +    if (desc == NULL)
  25.272 +        return -1;
  25.273 +
  25.274 +    if (desc->magic != XENCOMM_MAGIC) {
  25.275 +        printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
  25.276 +        return -1;
  25.277 +    }
  25.278 +
  25.279 +    /* iterate through the descriptor incrementing addresses */
  25.280 +    while ((bytes > 0) && (i < desc->nr_addrs)) {
  25.281 +        unsigned long dest_paddr = desc->address[i];
  25.282 +        unsigned int pgoffset;
  25.283 +        unsigned int chunksz;
  25.284 +        unsigned int chunk_skip;
  25.285 +
  25.286 +        pgoffset = dest_paddr % PAGE_SIZE;
  25.287 +        chunksz = PAGE_SIZE - pgoffset;
  25.288 +
  25.289 +        chunk_skip = min(chunksz, bytes);
  25.290 +        if (chunk_skip == chunksz) {
  25.291 +            /* exhausted this page */
  25.292 +            desc->address[i] = XENCOMM_INVALID;
  25.293 +        } else {
  25.294 +            desc->address[i] += chunk_skip;
  25.295 +        }
  25.296 +        bytes -= chunk_skip;
  25.297 +    }
  25.298 +    return 0;
  25.299 +}
  25.300 +
  25.301 +int xencomm_handle_is_null(void *handle)
  25.302 +{
  25.303 +    struct xencomm_desc *desc;
  25.304 +    int i;
  25.305 +
  25.306 +    if (xencomm_is_inline(handle))
  25.307 +        return xencomm_inline_addr(handle) == 0;
  25.308 +
  25.309 +    desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)handle);
  25.310 +    if (desc == NULL)
  25.311 +        return 1;
  25.312 +
  25.313 +    for (i = 0; i < desc->nr_addrs; i++)
  25.314 +        if (desc->address[i] != XENCOMM_INVALID)
  25.315 +            return 0;
  25.316 +
  25.317 +    return 1;
  25.318 +}
  25.319 +
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/xen/include/asm-powerpc/acpi.h	Tue Dec 12 09:56:06 2006 -0600
    26.3 @@ -0,0 +1,2 @@
    26.4 +#define MAX_LOCAL_APIC 256
    26.5 +
    27.1 --- a/xen/include/asm-powerpc/config.h	Fri Dec 01 19:11:02 2006 -0500
    27.2 +++ b/xen/include/asm-powerpc/config.h	Tue Dec 12 09:56:06 2006 -0600
    27.3 @@ -50,6 +50,7 @@ extern char __bss_start[];
    27.4  #define CONFIG_GDB 1
    27.5  #define CONFIG_SMP 1
    27.6  #define CONFIG_PCI 1
    27.7 +#define CONFIG_NUMA 1
    27.8  #define CONFIG_CMDLINE_SIZE 512
    27.9  #define NR_CPUS 16
   27.10  
    28.1 --- a/xen/include/asm-powerpc/domain.h	Fri Dec 01 19:11:02 2006 -0500
    28.2 +++ b/xen/include/asm-powerpc/domain.h	Tue Dec 12 09:56:06 2006 -0600
    28.3 @@ -89,7 +89,7 @@ struct arch_vcpu {
    28.4      struct slb_entry slb_entries[NUM_SLB_ENTRIES];
    28.5  
    28.6      /* I/O-port access bitmap. */
    28.7 -    u8 *iobmp;        /* Guest kernel virtual address of the bitmap. */
    28.8 +    XEN_GUEST_HANDLE(uint8_t) iobmp; /* Guest kernel virtual address of the bitmap. */
    28.9      int iobmp_limit;  /* Number of ports represented in the bitmap.  */
   28.10      int iopl;         /* Current IOPL for this VCPU. */
   28.11  
    29.1 --- a/xen/include/asm-powerpc/guest_access.h	Fri Dec 01 19:11:02 2006 -0500
    29.2 +++ b/xen/include/asm-powerpc/guest_access.h	Tue Dec 12 09:56:06 2006 -0600
    29.3 @@ -21,82 +21,6 @@
    29.4  #ifndef __PPC_GUEST_ACCESS_H__
    29.5  #define __PPC_GUEST_ACCESS_H__
    29.6  
    29.7 -extern unsigned long xencomm_copy_to_guest(void *to, const void *from,
    29.8 -        unsigned int len, unsigned int skip); 
    29.9 -extern unsigned long xencomm_copy_from_guest(void *to, const void *from,
   29.10 -        unsigned int len, unsigned int skip); 
   29.11 -extern int xencomm_add_offset(void *handle, unsigned int bytes);
   29.12 -extern int xencomm_handle_is_null(void *ptr);
   29.13 -
   29.14 -
   29.15 -/* Is the guest handle a NULL reference? */
   29.16 -#define guest_handle_is_null(hnd) \
   29.17 -    ((hnd).p == NULL || xencomm_handle_is_null((hnd).p))
   29.18 -
   29.19 -/* Offset the given guest handle into the array it refers to. */
   29.20 -#define guest_handle_add_offset(hnd, nr) ({         \
   29.21 -    const typeof((hnd).p) _ptr = (hnd).p;           \
   29.22 -    xencomm_add_offset(_ptr, nr * sizeof(*_ptr));   \
   29.23 -})
   29.24 -
   29.25 -/* Cast a guest handle to the specified type of handle. */
   29.26 -#define guest_handle_cast(hnd, type) ({         \
   29.27 -    type *_x = (hnd).p;                         \
   29.28 -    XEN_GUEST_HANDLE(type) _y; \
   29.29 -    set_xen_guest_handle(_y, _x); \
   29.30 -    _y; \
   29.31 -})
   29.32 -
   29.33 -/* Since we run in real mode, we can safely access all addresses. That also
   29.34 - * means our __routines are identical to our "normal" routines. */
   29.35 -#define guest_handle_okay(hnd, nr) 1
   29.36 -
   29.37 -/*
   29.38 - * Copy an array of objects to guest context via a guest handle.
   29.39 - * Optionally specify an offset into the guest array.
   29.40 - */
   29.41 -#define copy_to_guest_offset(hnd, idx, ptr, nr) \
   29.42 -    __copy_to_guest_offset(hnd, idx, ptr, nr)
   29.43 -
   29.44 -/* Copy sub-field of a structure to guest context via a guest handle. */
   29.45 -#define copy_field_to_guest(hnd, ptr, field) \
   29.46 -    __copy_field_to_guest(hnd, ptr, field)
   29.47 -
   29.48 -/*
   29.49 - * Copy an array of objects from guest context via a guest handle.
   29.50 - * Optionally specify an offset into the guest array.
   29.51 - */
   29.52 -#define copy_from_guest_offset(ptr, hnd, idx, nr) \
   29.53 -    __copy_from_guest_offset(ptr, hnd, idx, nr)
   29.54 -
   29.55 -/* Copy sub-field of a structure from guest context via a guest handle. */
   29.56 -#define copy_field_from_guest(ptr, hnd, field) \
   29.57 -    __copy_field_from_guest(ptr, hnd, field)
   29.58 -
   29.59 -#define __copy_to_guest_offset(hnd, idx, ptr, nr) ({                \
   29.60 -    const typeof(ptr) _x = (hnd).p;                                 \
   29.61 -    const typeof(ptr) _y = (ptr);                                   \
   29.62 -    xencomm_copy_to_guest(_x, _y, sizeof(*_x)*(nr), sizeof(*_x)*(idx)); \
   29.63 -})
   29.64 -
   29.65 -#define __copy_field_to_guest(hnd, ptr, field) ({                   \
   29.66 -    const int _off = offsetof(typeof(*ptr), field);                  \
   29.67 -    const typeof(&(ptr)->field) _x = &(hnd).p->field;               \
   29.68 -    const typeof(&(ptr)->field) _y = &(ptr)->field;                 \
   29.69 -    xencomm_copy_to_guest(_x, _y, sizeof(*_x), sizeof(*_x)*(_off)); \
   29.70 -})
   29.71 -
   29.72 -#define __copy_from_guest_offset(ptr, hnd, idx, nr) ({              \
   29.73 -    const typeof(ptr) _x = (hnd).p;                                 \
   29.74 -    const typeof(ptr) _y = (ptr);                                   \
   29.75 -    xencomm_copy_from_guest(_y, _x, sizeof(*_x)*(nr), sizeof(*_x)*(idx));  \
   29.76 -})
   29.77 -
   29.78 -#define __copy_field_from_guest(ptr, hnd, field) ({                 \
   29.79 -    const int _off = offsetof(typeof(*ptr), field);                 \
   29.80 -    const typeof(&(ptr)->field) _x = &(hnd).p->field;               \
   29.81 -    const typeof(&(ptr)->field) _y = &(ptr)->field;                 \
   29.82 -    xencomm_copy_to_guest(_y, _x, sizeof(*_x), sizeof(*_x)*(_off)); \
   29.83 -})
   29.84 +#include <xen/xencomm.h>
   29.85  
   29.86  #endif /* __PPC_GUEST_ACCESS_H__ */
    30.1 --- a/xen/include/asm-powerpc/mm.h	Fri Dec 01 19:11:02 2006 -0500
    30.2 +++ b/xen/include/asm-powerpc/mm.h	Tue Dec 12 09:56:06 2006 -0600
    30.3 @@ -28,7 +28,7 @@
    30.4  #include <xen/mm.h>
    30.5  #include <asm/system.h>
    30.6  #include <asm/flushtlb.h>
    30.7 -#include <asm/uaccess.h>
    30.8 +#include <asm/page.h>
    30.9  #include <asm/debugger.h>
   30.10  
   30.11  #define memguard_guard_range(_p,_l)    ((void)0)
   30.12 @@ -87,7 +87,6 @@ struct page_extents {
   30.13      /* page extent */
   30.14      struct page_info *pg;
   30.15      uint order;
   30.16 -    ulong pfn;
   30.17  };
   30.18  
   30.19   /* The following page types are MUTUALLY EXCLUSIVE. */
   30.20 @@ -273,72 +272,20 @@ extern int update_grant_va_mapping(unsig
   30.21                                     struct domain *,
   30.22                                     struct vcpu *);
   30.23  
   30.24 -#define INVALID_MFN (~0UL)
   30.25 -#define PFN_TYPE_NONE 0
   30.26 -#define PFN_TYPE_RMA 1
   30.27 -#define PFN_TYPE_LOGICAL 2
   30.28 -#define PFN_TYPE_IO 3
   30.29 -#define PFN_TYPE_FOREIGN 4
   30.30 -
   30.31 -extern ulong pfn2mfn(struct domain *d, ulong pfn, int *type);
   30.32 -
   30.33  /* Arch-specific portion of memory_op hypercall. */
   30.34  long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg);
   30.35  
   30.36 -/* XXX implement me? */
   30.37 -#define set_gpfn_from_mfn(mfn, pfn) do { } while (0)
   30.38 -/* XXX only used for debug print right now... */
   30.39 -#define get_gpfn_from_mfn(mfn) (mfn)
   30.40 -
   30.41 -static inline unsigned long gmfn_to_mfn(struct domain *d, unsigned long gmfn)
   30.42 -{
   30.43 -    int mtype;
   30.44 -    ulong mfn;
   30.45 -    
   30.46 -    mfn = pfn2mfn(d, gmfn, &mtype);
   30.47 -    if (mfn != INVALID_MFN) {
   30.48 -        switch (mtype) {
   30.49 -        case PFN_TYPE_RMA:
   30.50 -        case PFN_TYPE_LOGICAL:
   30.51 -            break;
   30.52 -        default:
   30.53 -            WARN();
   30.54 -            mfn = INVALID_MFN;
   30.55 -            break;
   30.56 -        }
   30.57 -    }
   30.58 -    return mfn;
   30.59 -}
   30.60 -
   30.61 -#define mfn_to_gmfn(_d, mfn) (mfn)
   30.62 -
   30.63  extern int allocate_rma(struct domain *d, unsigned int order_pages);
   30.64  extern uint allocate_extents(struct domain *d, uint nrpages, uint rma_nrpages);
   30.65  extern void free_extents(struct domain *d);
   30.66  
   30.67 +extern int arch_domain_add_extent(struct domain *d, struct page_info *page,
   30.68 +        int order);
   30.69 +
   30.70  extern int steal_page(struct domain *d, struct page_info *page,
   30.71                          unsigned int memflags);
   30.72  
   30.73 -static inline unsigned long gmfn_to_mfn(struct domain *d, unsigned long gmfn)
   30.74 -{
   30.75 -    int mtype;
   30.76 -    ulong mfn;
   30.77 -    
   30.78 -    mfn = pfn2mfn(d, gmfn, &mtype);
   30.79 -    if (mfn != INVALID_MFN) {
   30.80 -        switch (mtype) {
   30.81 -        case PFN_TYPE_RMA:
   30.82 -        case PFN_TYPE_LOGICAL:
   30.83 -            break;
   30.84 -        default:
   30.85 -            WARN();
   30.86 -            mfn = INVALID_MFN;
   30.87 -            break;
   30.88 -        }
   30.89 -    }
   30.90 -    return mfn;
   30.91 -}
   30.92 -
   30.93 -#define mfn_to_gmfn(_d, mfn) (mfn)
   30.94 -
   30.95 +/* XXX these just exist until we can stop #including x86 code */
   30.96 +#define access_ok(addr,size) 1
   30.97 +#define array_access_ok(addr,count,size) 1
   30.98  #endif
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/xen/include/asm-powerpc/numa.h	Tue Dec 12 09:56:06 2006 -0600
    31.3 @@ -0,0 +1,2 @@
    31.4 +#include "../asm-x86/numa.h"
    31.5 +extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn);
    32.1 --- a/xen/include/asm-powerpc/page.h	Fri Dec 01 19:11:02 2006 -0500
    32.2 +++ b/xen/include/asm-powerpc/page.h	Tue Dec 12 09:56:06 2006 -0600
    32.3 @@ -13,7 +13,7 @@
    32.4   * along with this program; if not, write to the Free Software
    32.5   * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    32.6   *
    32.7 - * Copyright (C) IBM Corp. 2005
    32.8 + * Copyright (C) IBM Corp. 2005, 2006
    32.9   *
   32.10   * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   32.11   *          Jimi Xenidis <jimix@watson.ibm.com>
   32.12 @@ -129,5 +129,6 @@ static inline int get_order_from_pages(u
   32.13  #define _PAGE_PAT      0x080UL
   32.14  #define _PAGE_PSE      0x080UL
   32.15  #define _PAGE_GLOBAL   0x100UL
   32.16 +
   32.17  #endif  /* ! __ASSEMBLY__ */
   32.18  #endif
    33.1 --- a/xen/include/asm-powerpc/smp.h	Fri Dec 01 19:11:02 2006 -0500
    33.2 +++ b/xen/include/asm-powerpc/smp.h	Tue Dec 12 09:56:06 2006 -0600
    33.3 @@ -25,6 +25,12 @@
    33.4  #include <xen/cpumask.h>
    33.5  #include <xen/init.h>
    33.6  #include <asm/current.h>
    33.7 +
    33.8 +/* crap to make x86 "common code" happy */
    33.9 +#define BAD_APICID 0xFFu
   33.10 +extern u8 x86_cpu_to_apicid[];
   33.11 +
   33.12 +
   33.13  extern int smp_num_siblings;
   33.14  
   33.15  /* revisit when we support SMP */
    34.1 --- a/xen/include/asm-powerpc/spinlock.h	Fri Dec 01 19:11:02 2006 -0500
    34.2 +++ b/xen/include/asm-powerpc/spinlock.h	Tue Dec 12 09:56:06 2006 -0600
    34.3 @@ -72,13 +72,13 @@ cas_u32(volatile u32 *ptr, u32 oval, u32
    34.4  
    34.5  typedef struct {
    34.6      volatile u32 lock;
    34.7 -	u16 recurse_cpu;
    34.8 -	u16 recurse_cnt;
    34.9 +    s16 recurse_cpu;
   34.10 +    u16 recurse_cnt;
   34.11  } spinlock_t;
   34.12  
   34.13  #define __UNLOCKED (0U)
   34.14  #define __LOCKED (~__UNLOCKED)
   34.15 -#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { __UNLOCKED }
   34.16 +#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { __UNLOCKED, -1, 0 }
   34.17  static inline void spin_lock_init(spinlock_t *lock)
   34.18  {
   34.19      *lock = (spinlock_t) SPIN_LOCK_UNLOCKED;
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/xen/include/xen/xencomm.h	Tue Dec 12 09:56:06 2006 -0600
    35.3 @@ -0,0 +1,115 @@
    35.4 +/*
    35.5 + * This program is free software; you can redistribute it and/or modify
    35.6 + * it under the terms of the GNU General Public License as published by
    35.7 + * the Free Software Foundation; either version 2 of the License, or
    35.8 + * (at your option) any later version.
    35.9 + *
   35.10 + * This program is distributed in the hope that it will be useful,
   35.11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   35.12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   35.13 + * GNU General Public License for more details.
   35.14 + *
   35.15 + * You should have received a copy of the GNU General Public License
   35.16 + * along with this program; if not, write to the Free Software
   35.17 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   35.18 + *
   35.19 + * Copyright (C) IBM Corp. 2006
   35.20 + *
   35.21 + * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   35.22 + */
   35.23 +
   35.24 +#ifndef __XENCOMM_H__
   35.25 +#define __XENCOMM_H__
   35.26 +
   35.27 +#include <public/xen.h>
   35.28 +
   35.29 +extern unsigned long xencomm_copy_to_guest(void *to, const void *from,
   35.30 +        unsigned int len, unsigned int skip); 
   35.31 +extern unsigned long xencomm_copy_from_guest(void *to, const void *from,
   35.32 +        unsigned int len, unsigned int skip); 
   35.33 +extern int xencomm_add_offset(void **handle, unsigned int bytes);
   35.34 +extern int xencomm_handle_is_null(void *ptr);
   35.35 +
   35.36 +
   35.37 +static inline int xencomm_is_inline(const void *handle)
   35.38 +{
   35.39 +    unsigned long addr = (unsigned long)handle;
   35.40 +    return (addr & XENCOMM_INLINE_FLAG) == XENCOMM_INLINE_FLAG;
   35.41 +}
   35.42 +
   35.43 +static inline unsigned long xencomm_inline_addr(const void *handle)
   35.44 +{
   35.45 +	return (unsigned long)handle & ~XENCOMM_INLINE_FLAG;
   35.46 +}
   35.47 +
   35.48 +/* Is the guest handle a NULL reference? */
   35.49 +#define guest_handle_is_null(hnd) \
   35.50 +    ((hnd).p == NULL || xencomm_handle_is_null((hnd).p))
   35.51 +
   35.52 +/* Offset the given guest handle into the array it refers to. */
   35.53 +#define guest_handle_add_offset(hnd, nr) ({         \
   35.54 +    const typeof((hnd).p) _ptr;                     \
   35.55 +    xencomm_add_offset((void **)&((hnd).p), nr * sizeof(*_ptr));   \
   35.56 +})
   35.57 +
   35.58 +/* Cast a guest handle to the specified type of handle. */
   35.59 +#define guest_handle_cast(hnd, type) ({         \
   35.60 +    type *_x = (hnd).p;                         \
   35.61 +    XEN_GUEST_HANDLE(type) _y; \
   35.62 +    set_xen_guest_handle(_y, _x); \
   35.63 +    _y; \
   35.64 +})
   35.65 +
   35.66 +/* Since we run in real mode, we can safely access all addresses. That also
   35.67 + * means our __routines are identical to our "normal" routines. */
   35.68 +#define guest_handle_okay(hnd, nr) 1
   35.69 +
   35.70 +/*
   35.71 + * Copy an array of objects to guest context via a guest handle.
   35.72 + * Optionally specify an offset into the guest array.
   35.73 + */
   35.74 +#define copy_to_guest_offset(hnd, idx, ptr, nr) \
   35.75 +    __copy_to_guest_offset(hnd, idx, ptr, nr)
   35.76 +
   35.77 +/* Copy sub-field of a structure to guest context via a guest handle. */
   35.78 +#define copy_field_to_guest(hnd, ptr, field) \
   35.79 +    __copy_field_to_guest(hnd, ptr, field)
   35.80 +
   35.81 +/*
   35.82 + * Copy an array of objects from guest context via a guest handle.
   35.83 + * Optionally specify an offset into the guest array.
   35.84 + */
   35.85 +#define copy_from_guest_offset(ptr, hnd, idx, nr) \
   35.86 +    __copy_from_guest_offset(ptr, hnd, idx, nr)
   35.87 +
   35.88 +/* Copy sub-field of a structure from guest context via a guest handle. */
   35.89 +#define copy_field_from_guest(ptr, hnd, field) \
   35.90 +    __copy_field_from_guest(ptr, hnd, field)
   35.91 +
   35.92 +#define __copy_to_guest_offset(hnd, idx, ptr, nr) ({                \
   35.93 +    const typeof(ptr) _x = (hnd).p;                                 \
   35.94 +    const typeof(ptr) _y = (ptr);                                   \
   35.95 +    xencomm_copy_to_guest(_x, _y, sizeof(*_x)*(nr), sizeof(*_x)*(idx)); \
   35.96 +})
   35.97 +
   35.98 +#define __copy_field_to_guest(hnd, ptr, field) ({                   \
   35.99 +    const int _off = offsetof(typeof(*ptr), field);                  \
  35.100 +    const typeof(&(ptr)->field) _x = &(hnd).p->field;               \
  35.101 +    const typeof(&(ptr)->field) _y = &(ptr)->field;                 \
  35.102 +    xencomm_copy_to_guest(_x, _y, sizeof(*_x), sizeof(*_x)*(_off)); \
  35.103 +})
  35.104 +
  35.105 +#define __copy_from_guest_offset(ptr, hnd, idx, nr) ({              \
  35.106 +    const typeof(ptr) _x = (hnd).p;                                 \
  35.107 +    const typeof(ptr) _y = (ptr);                                   \
  35.108 +    xencomm_copy_from_guest(_y, _x, sizeof(*_x)*(nr), sizeof(*_x)*(idx));  \
  35.109 +})
  35.110 +
  35.111 +#define __copy_field_from_guest(ptr, hnd, field) ({                 \
  35.112 +    const int _off = offsetof(typeof(*ptr), field);                 \
  35.113 +    const typeof(&(ptr)->field) _x = &(hnd).p->field;               \
  35.114 +    const typeof(&(ptr)->field) _y = &(ptr)->field;                 \
  35.115 +    xencomm_copy_to_guest(_y, _x, sizeof(*_x), sizeof(*_x)*(_off)); \
  35.116 +})
  35.117 +
  35.118 +#endif /* __XENCOMM_H__ */