ia64/xen-unstable

changeset 11491:4fdf5151b187

[POWERPC] merge with xen-unstable.hg
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author hollisb@localhost
date Mon Sep 18 12:48:56 2006 -0500 (2006-09-18)
parents 50aea0ec406b
children f9cff9148068
files tools/libxc/powerpc64/Makefile tools/libxc/powerpc64/xc_linux_build.c xen/arch/powerpc/0opt.c xen/arch/powerpc/backtrace.c xen/arch/powerpc/boot_of.c xen/arch/powerpc/dom0_ops.c xen/arch/powerpc/domain.c xen/arch/powerpc/elf32.c xen/arch/powerpc/hcalls.c xen/arch/powerpc/iommu.c xen/arch/powerpc/mm.c xen/arch/powerpc/ofd_fixup.c xen/arch/powerpc/oftree.h 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/usercopy.c xen/include/asm-powerpc/current.h xen/include/asm-powerpc/flushtlb.h xen/include/asm-powerpc/guest_access.h xen/include/asm-powerpc/io.h xen/include/asm-powerpc/mm.h xen/include/asm-powerpc/powerpc64/ppc970-hid.h xen/include/asm-powerpc/powerpc64/processor.h xen/include/asm-powerpc/processor.h xen/include/asm-powerpc/reg_defs.h xen/include/asm-powerpc/shadow.h xen/include/asm-powerpc/smp.h xen/include/asm-powerpc/system.h
line diff
     1.1 --- a/tools/libxc/powerpc64/Makefile	Wed Aug 30 22:36:18 2006 +0100
     1.2 +++ b/tools/libxc/powerpc64/Makefile	Mon Sep 18 12:48:56 2006 -0500
     1.3 @@ -1,1 +1,4 @@
     1.4  GUEST_SRCS-y += powerpc64/xc_linux_build.c
     1.5 +GUEST_SRCS-y += powerpc64/ft_build.c
     1.6 +
     1.7 +CTRL_SRCS-y += powerpc64/xc_memory.c
     2.1 --- a/tools/libxc/powerpc64/xc_linux_build.c	Wed Aug 30 22:36:18 2006 +0100
     2.2 +++ b/tools/libxc/powerpc64/xc_linux_build.c	Mon Sep 18 12:48:56 2006 -0500
     2.3 @@ -27,14 +27,16 @@
     2.4  #include <sys/types.h>
     2.5  #include <inttypes.h>
     2.6  
     2.7 +#include <xen/xen.h>
     2.8  #include <xen/memory.h>
     2.9  #include <xc_private.h>
    2.10  #include <xg_private.h>
    2.11  #include <xenctrl.h>
    2.12  
    2.13 -/* XXX 64M hack */
    2.14 -#define MEMSIZE (64UL << 20)
    2.15 +#include "ft_build.h"
    2.16 +
    2.17  #define INITRD_ADDR (24UL << 20)
    2.18 +#define DEVTREE_ADDR (16UL << 20)
    2.19  
    2.20  #define ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1)))
    2.21  
    2.22 @@ -91,8 +93,8 @@ static int init_boot_vcpu(
    2.23      int xc_handle,
    2.24      int domid,
    2.25      struct domain_setup_info *dsi,
    2.26 -    unsigned long dtb,
    2.27 -    unsigned long kaddr)
    2.28 +    unsigned long devtree_addr,
    2.29 +    unsigned long kern_addr)
    2.30  {
    2.31      vcpu_guest_context_t ctxt;
    2.32      int rc;
    2.33 @@ -101,15 +103,15 @@ static int init_boot_vcpu(
    2.34      ctxt.user_regs.pc = dsi->v_kernentry;
    2.35      ctxt.user_regs.msr = 0;
    2.36      ctxt.user_regs.gprs[1] = 0; /* Linux uses its own stack */
    2.37 -    ctxt.user_regs.gprs[3] = dtb;
    2.38 -    ctxt.user_regs.gprs[4] = kaddr;
    2.39 +    ctxt.user_regs.gprs[3] = devtree_addr;
    2.40 +    ctxt.user_regs.gprs[4] = kern_addr;
    2.41      ctxt.user_regs.gprs[5] = 0;
    2.42      /* There is a buggy kernel that does not zero the "local_paca", so
    2.43       * we must make sure this register is 0 */
    2.44      ctxt.user_regs.gprs[13] = 0;
    2.45  
    2.46      DPRINTF("xc_vcpu_setvcpucontext:\n"
    2.47 -                 "  pc 0x%"PRIx64", msr 0x016%"PRIx64"\n"
    2.48 +                 "  pc 0x%016"PRIx64", msr 0x%016"PRIx64"\n"
    2.49                   "  r1-5 %016"PRIx64" %016"PRIx64" %016"PRIx64" %016"PRIx64
    2.50                   " %016"PRIx64"\n",
    2.51                   ctxt.user_regs.pc, ctxt.user_regs.msr,
    2.52 @@ -156,30 +158,69 @@ static int install_image(
    2.53      return rc;
    2.54  }
    2.55  
    2.56 -/* XXX be more flexible about placement in memory */
    2.57 -static int load_dtb(
    2.58 +static int load_devtree(
    2.59      int xc_handle,
    2.60      int domid,
    2.61 -    const char *dtb_path,
    2.62 -    unsigned long dtb_addr,
    2.63 -    struct domain_setup_info *dsi,
    2.64 -    xen_pfn_t *page_array)
    2.65 +    xen_pfn_t *page_array,
    2.66 +    void *devtree,
    2.67 +    unsigned long devtree_addr,
    2.68 +    unsigned long initrd_base,
    2.69 +    unsigned long initrd_len,
    2.70 +    start_info_t *si,
    2.71 +    unsigned long si_addr)
    2.72  {
    2.73 -    uint8_t *img;
    2.74 -    unsigned long dtb_size;
    2.75 +    uint32_t start_info[4] = {0, si_addr, 0, 0x1000};
    2.76 +    struct boot_param_header *header;
    2.77 +    uint64_t *prop;
    2.78 +    unsigned int devtree_size;
    2.79 +    unsigned int proplen;
    2.80      int rc = 0;
    2.81  
    2.82 -    img = load_file(dtb_path, &dtb_size);
    2.83 -    if (img == NULL) {
    2.84 -        rc = -1;
    2.85 -        goto out;
    2.86 +    header = devtree;
    2.87 +    devtree_size = header->totalsize;
    2.88 +
    2.89 +    DPRINTF("adding initrd props\n");
    2.90 +
    2.91 +	/* initrd-start */
    2.92 +    prop = ft_get_prop(devtree, "/chosen/linux,initrd-start", &proplen);
    2.93 +    if (prop == NULL) {
    2.94 +        DPRINTF("couldn't find linux,initrd-start\n");
    2.95 +        return -1;
    2.96      }
    2.97 +    if (proplen != sizeof(*prop)) {
    2.98 +        DPRINTF("couldn't set linux,initrd-start (size %d)\n", proplen);
    2.99 +        return -1;
   2.100 +    }
   2.101 +    *prop = initrd_base;
   2.102  
   2.103 -    DPRINTF("copying device tree to 0x%lx[0x%lx]\n", dtb_addr, dtb_size);
   2.104 -    rc = install_image(xc_handle, domid, page_array, img, dtb_addr, dtb_size);
   2.105 +	/* initrd-end */
   2.106 +    prop = ft_get_prop(devtree, "/chosen/linux,initrd-end", &proplen);
   2.107 +    if (prop == NULL) {
   2.108 +        DPRINTF("couldn't find linux,initrd-end\n");
   2.109 +        return -1;
   2.110 +    }
   2.111 +    if (proplen != sizeof(*prop)) {
   2.112 +        DPRINTF("couldn't set linux,initrd-end (size %d)\n", proplen);
   2.113 +        return -1;
   2.114 +    }
   2.115 +    *prop = initrd_base + initrd_len;
   2.116  
   2.117 -out:
   2.118 -    free(img);
   2.119 +	/* start-info (XXX being removed soon) */
   2.120 +    prop = ft_get_prop(devtree, "/xen/start-info", &proplen);
   2.121 +    if (prop == NULL) {
   2.122 +        DPRINTF("couldn't find /xen/start-info\n");
   2.123 +        return -1;
   2.124 +    }
   2.125 +    if (proplen != sizeof(start_info)) {
   2.126 +        DPRINTF("couldn't set /xen/start-info (size %d)\n", proplen);
   2.127 +        return -1;
   2.128 +    }
   2.129 +    memcpy(prop, start_info, proplen);
   2.130 +
   2.131 +    DPRINTF("copying device tree to 0x%lx[0x%x]\n", DEVTREE_ADDR, devtree_size);
   2.132 +    rc = install_image(xc_handle, domid, page_array, devtree, DEVTREE_ADDR,
   2.133 +                       devtree_size);
   2.134 +
   2.135      return rc;
   2.136  }
   2.137  
   2.138 @@ -294,17 +335,16 @@ out:
   2.139  }
   2.140  
   2.141  static unsigned long create_start_info(start_info_t *si,
   2.142 -        unsigned int console_evtchn, unsigned int store_evtchn)
   2.143 +        unsigned int console_evtchn, unsigned int store_evtchn,
   2.144 +        unsigned long nr_pages)
   2.145  {
   2.146 -    unsigned long eomem;
   2.147      unsigned long si_addr;
   2.148  
   2.149      memset(si, 0, sizeof(*si));
   2.150      snprintf(si->magic, sizeof(si->magic), "xen-%d.%d-powerpc64HV", 3, 0);
   2.151  
   2.152 -    eomem = MEMSIZE;
   2.153 -    si->nr_pages = eomem >> PAGE_SHIFT;
   2.154 -    si->shared_info = eomem - (PAGE_SIZE * 1);
   2.155 +    si->nr_pages = nr_pages;
   2.156 +    si->shared_info = (nr_pages - 1) << PAGE_SHIFT;
   2.157      si->store_mfn = si->nr_pages - 2;
   2.158      si->store_evtchn = store_evtchn;
   2.159      si->console.domU.mfn = si->nr_pages - 3;
   2.160 @@ -314,24 +354,24 @@ static unsigned long create_start_info(s
   2.161      return si_addr;
   2.162  }
   2.163  
   2.164 -static int get_page_array(int xc_handle, int domid, xen_pfn_t **page_array)
   2.165 +static int get_page_array(int xc_handle, int domid, xen_pfn_t **page_array,
   2.166 +                          unsigned long *nr_pages)
   2.167  {
   2.168 -    int nr_pages;
   2.169      int rc;
   2.170  
   2.171      DPRINTF("xc_get_tot_pages\n");
   2.172 -    nr_pages = xc_get_tot_pages(xc_handle, domid);
   2.173 -    DPRINTF("  0x%x\n", nr_pages);
   2.174 +    *nr_pages = xc_get_tot_pages(xc_handle, domid);
   2.175 +    DPRINTF("  0x%lx\n", *nr_pages);
   2.176  
   2.177 -    *page_array = malloc(nr_pages * sizeof(xen_pfn_t));
   2.178 +    *page_array = malloc(*nr_pages * sizeof(xen_pfn_t));
   2.179      if (*page_array == NULL) {
   2.180          perror("malloc");
   2.181          return -1;
   2.182      }
   2.183  
   2.184      DPRINTF("xc_get_pfn_list\n");
   2.185 -    rc = xc_get_pfn_list(xc_handle, domid, *page_array, nr_pages);
   2.186 -    if (rc != nr_pages) {
   2.187 +    rc = xc_get_pfn_list(xc_handle, domid, *page_array, *nr_pages);
   2.188 +    if (rc != *nr_pages) {
   2.189          perror("Could not get the page frame list");
   2.190          return -1;
   2.191      }
   2.192 @@ -339,6 +379,11 @@ static int get_page_array(int xc_handle,
   2.193      return 0;
   2.194  }
   2.195  
   2.196 +static void free_page_array(xen_pfn_t *page_array)
   2.197 +{
   2.198 +    free(page_array);
   2.199 +}
   2.200 +
   2.201  
   2.202  
   2.203  int xc_linux_build(int xc_handle,
   2.204 @@ -351,57 +396,70 @@ int xc_linux_build(int xc_handle,
   2.205                     unsigned int store_evtchn,
   2.206                     unsigned long *store_mfn,
   2.207                     unsigned int console_evtchn,
   2.208 -                   unsigned long *console_mfn)
   2.209 +                   unsigned long *console_mfn,
   2.210 +                   void *devtree)
   2.211  {
   2.212 +    start_info_t si;
   2.213      struct domain_setup_info dsi;
   2.214      xen_pfn_t *page_array = NULL;
   2.215 +    unsigned long nr_pages;
   2.216 +    unsigned long devtree_addr = 0;
   2.217      unsigned long kern_addr;
   2.218 -    unsigned long dtb_addr;
   2.219 -    unsigned long si_addr;
   2.220      unsigned long initrd_base = 0;
   2.221      unsigned long initrd_len = 0;
   2.222 -    start_info_t si;
   2.223 +    unsigned long si_addr;
   2.224      int rc = 0;
   2.225  
   2.226 -    if (get_page_array(xc_handle, domid, &page_array)) {
   2.227 +    DPRINTF("%s\n", __func__);
   2.228 +
   2.229 +    if (get_page_array(xc_handle, domid, &page_array, &nr_pages)) {
   2.230          rc = -1;
   2.231          goto out;
   2.232      }
   2.233  
   2.234 +    DPRINTF("loading image '%s'\n", image_name);
   2.235      if (load_kernel(xc_handle, domid, image_name, &dsi, page_array)) {
   2.236          rc = -1;
   2.237          goto out;
   2.238      }
   2.239      kern_addr = 0;
   2.240  
   2.241 -    if (initrd_name && initrd_name[0] != '\0' &&
   2.242 -        load_initrd(xc_handle, domid, page_array, initrd_name, &initrd_base,
   2.243 -                &initrd_len)) {
   2.244 -        rc = -1;
   2.245 -        goto out;
   2.246 -    }
   2.247 -    /* XXX install initrd addr/len into device tree */
   2.248 -
   2.249 -    dtb_addr = (16 << 20);
   2.250 -    if (load_dtb(xc_handle, domid, "/root/DomU.dtb", dtb_addr, &dsi, page_array)) {
   2.251 -        dtb_addr = 0;
   2.252 +    if (initrd_name && initrd_name[0] != '\0') {
   2.253 +        DPRINTF("loading initrd '%s'\n", initrd_name);
   2.254 +        if (load_initrd(xc_handle, domid, page_array, initrd_name,
   2.255 +                &initrd_base, &initrd_len)) {
   2.256 +            rc = -1;
   2.257 +            goto out;
   2.258 +        }
   2.259      }
   2.260  
   2.261 -    si_addr = create_start_info(&si, console_evtchn, store_evtchn);
   2.262 +    /* start_info stuff: about to be removed  */
   2.263 +    si_addr = create_start_info(&si, console_evtchn, store_evtchn, nr_pages);
   2.264      *console_mfn = page_array[si.console.domU.mfn];
   2.265      *store_mfn = page_array[si.store_mfn];
   2.266 -    
   2.267      if (install_image(xc_handle, domid, page_array, &si, si_addr,
   2.268                  sizeof(start_info_t))) {
   2.269          rc = -1;
   2.270          goto out;
   2.271      }
   2.272  
   2.273 -    if (init_boot_vcpu(xc_handle, domid, &dsi, dtb_addr, kern_addr)) {
   2.274 +    if (devtree) {
   2.275 +        DPRINTF("loading flattened device tree\n");
   2.276 +        devtree_addr = DEVTREE_ADDR;
   2.277 +        if (load_devtree(xc_handle, domid, page_array, devtree, devtree_addr,
   2.278 +                     initrd_base, initrd_len, &si, si_addr)) {
   2.279 +            DPRINTF("couldn't load flattened device tree.\n");
   2.280 +            rc = -1;
   2.281 +            goto out;
   2.282 +        }
   2.283 +    }
   2.284 +
   2.285 +    if (init_boot_vcpu(xc_handle, domid, &dsi, devtree_addr, kern_addr)) {
   2.286          rc = -1;
   2.287          goto out;
   2.288      }
   2.289  
   2.290  out:
   2.291 +    free_page_array(page_array);
   2.292      return rc;
   2.293  }
     3.1 --- a/xen/arch/powerpc/0opt.c	Wed Aug 30 22:36:18 2006 +0100
     3.2 +++ b/xen/arch/powerpc/0opt.c	Mon Sep 18 12:48:56 2006 -0500
     3.3 @@ -19,10 +19,10 @@
     3.4   */
     3.5  
     3.6  #include <xen/config.h>
     3.7 -#include <asm/misc.h>
     3.8 +#include <xen/lib.h>
     3.9  
    3.10  extern void __cmpxchg_called_with_bad_pointer(void);
    3.11  void __cmpxchg_called_with_bad_pointer(void)
    3.12  {
    3.13 -    trap();
    3.14 +    BUG();
    3.15  }
     4.1 --- a/xen/arch/powerpc/backtrace.c	Wed Aug 30 22:36:18 2006 +0100
     4.2 +++ b/xen/arch/powerpc/backtrace.c	Mon Sep 18 12:48:56 2006 -0500
     4.3 @@ -191,3 +191,20 @@ void show_backtrace(ulong sp, ulong lr, 
     4.4      backtrace(sp, lr, pc);
     4.5      console_end_sync();
     4.6  }
     4.7 +
     4.8 +void __warn(char *file, int line)
     4.9 +{
    4.10 +    ulong sp;
    4.11 +    ulong lr;
    4.12 +
    4.13 +    console_start_sync();
    4.14 +    printk("WARN at %s:%d\n", file, line);
    4.15 +
    4.16 +    sp = (ulong)__builtin_frame_address(0);
    4.17 +    lr = (ulong)__builtin_return_address(0);
    4.18 +
    4.19 +    backtrace(sp, lr, lr);
    4.20 +    console_end_sync();
    4.21 +}
    4.22 +
    4.23 +    
     5.1 --- a/xen/arch/powerpc/boot_of.c	Wed Aug 30 22:36:18 2006 +0100
     5.2 +++ b/xen/arch/powerpc/boot_of.c	Mon Sep 18 12:48:56 2006 -0500
     5.3 @@ -31,6 +31,7 @@
     5.4  #include <asm/io.h>
     5.5  #include "exceptions.h"
     5.6  #include "of-devtree.h"
     5.7 +#include "oftree.h"
     5.8  
     5.9  /* Secondary processors use this for handshaking with main processor.  */
    5.10  volatile unsigned int __spin_ack;
    5.11 @@ -38,7 +39,6 @@ volatile unsigned int __spin_ack;
    5.12  static ulong of_vec;
    5.13  static ulong of_msr;
    5.14  static int of_out;
    5.15 -static ofdn_t boot_cpu;
    5.16  static char bootargs[256];
    5.17  
    5.18  #define COMMAND_LINE_SIZE 512
    5.19 @@ -669,7 +669,7 @@ static int boot_of_fixup_chosen(void *me
    5.20              dn = ofd_node_find(mem, ofpath);
    5.21              if (dn <= 0) of_panic("no node for: %s\n", ofpath);
    5.22  
    5.23 -            boot_cpu = dn;
    5.24 +            ofd_boot_cpu = dn;
    5.25              val = dn;
    5.26  
    5.27              dn = ofd_node_find(mem, "/chosen");
    5.28 @@ -681,7 +681,7 @@ static int boot_of_fixup_chosen(void *me
    5.29          } else {
    5.30              of_printf("*** can't find path to booting cpu, "
    5.31                      "SMP is disabled\n");
    5.32 -            boot_cpu = -1;
    5.33 +            ofd_boot_cpu = -1;
    5.34          }
    5.35      }
    5.36      return rc;
    5.37 @@ -773,7 +773,7 @@ static void __init boot_of_fix_maple(voi
    5.38      }
    5.39  }
    5.40      
    5.41 -static int __init boot_of_serial(void *oftree)
    5.42 +static int __init boot_of_serial(void *oft)
    5.43  {
    5.44      int n;
    5.45      int p;
    5.46 @@ -805,7 +805,7 @@ static int __init boot_of_serial(void *o
    5.47              continue;
    5.48  
    5.49          of_printf("pruning `%s' from devtree\n", buf);
    5.50 -        rc = ofd_prune_path(oftree, buf);
    5.51 +        rc = ofd_prune_path(oft, buf);
    5.52          if (rc < 0)
    5.53              of_panic("prune of `%s' failed\n", buf);
    5.54      }
    5.55 @@ -858,8 +858,8 @@ static int __init boot_of_serial(void *o
    5.56  static void boot_of_module(ulong r3, ulong r4, multiboot_info_t *mbi)
    5.57  {
    5.58      static module_t mods[3];
    5.59 -    void *oftree;
    5.60 -    ulong oftree_sz = 48 * PAGE_SIZE;
    5.61 +    void *oft;
    5.62 +    ulong oft_sz = 48 * PAGE_SIZE;
    5.63      ulong mod0_start;
    5.64      ulong mod0_size;
    5.65      static const char sepr[] = " -- ";
    5.66 @@ -922,28 +922,28 @@ static void boot_of_module(ulong r3, ulo
    5.67      }
    5.68  
    5.69      /* snapshot the tree */
    5.70 -    oftree = (void*)find_space(oftree_sz, PAGE_SIZE, mbi);
    5.71 -    if (oftree == 0)
    5.72 +    oft = (void*)find_space(oft_sz, PAGE_SIZE, mbi);
    5.73 +    if (oft == 0)
    5.74          of_panic("Could not allocate OFD tree\n");
    5.75  
    5.76 -    of_printf("creating oftree\n");
    5.77 +    of_printf("creating oft\n");
    5.78      of_test("package-to-path");
    5.79 -    oftree = ofd_create(oftree, oftree_sz);
    5.80 -    pkg_save(oftree);
    5.81 +    oft = ofd_create(oft, oft_sz);
    5.82 +    pkg_save(oft);
    5.83  
    5.84 -    if (ofd_size(oftree) > oftree_sz)
    5.85 +    if (ofd_size(oft) > oft_sz)
    5.86           of_panic("Could not fit all of native devtree\n");
    5.87  
    5.88 -    boot_of_fixup_refs(oftree);
    5.89 -    boot_of_fixup_chosen(oftree);
    5.90 +    boot_of_fixup_refs(oft);
    5.91 +    boot_of_fixup_chosen(oft);
    5.92  
    5.93 -    if (ofd_size(oftree) > oftree_sz)
    5.94 +    if (ofd_size(oft) > oft_sz)
    5.95           of_panic("Could not fit all devtree fixups\n");
    5.96  
    5.97 -    ofd_walk(oftree, OFD_ROOT, /* add_hype_props */ NULL, 2);
    5.98 +    ofd_walk(oft, OFD_ROOT, /* add_hype_props */ NULL, 2);
    5.99  
   5.100 -    mods[1].mod_start = (ulong)oftree;
   5.101 -    mods[1].mod_end = mods[1].mod_start + oftree_sz;
   5.102 +    mods[1].mod_start = (ulong)oft;
   5.103 +    mods[1].mod_end = mods[1].mod_start + oft_sz;
   5.104      of_printf("%s: mod[1] @ 0x%016x[0x%x]\n", __func__,
   5.105                mods[1].mod_start, mods[1].mod_end);
   5.106  
   5.107 @@ -952,7 +952,7 @@ static void boot_of_module(ulong r3, ulo
   5.108      mbi->mods_count = 2;
   5.109      mbi->mods_addr = (u32)mods;
   5.110  
   5.111 -    boot_of_serial(oftree);
   5.112 +    boot_of_serial(oft);
   5.113  }
   5.114  
   5.115  static int __init boot_of_cpus(void)
     6.1 --- a/xen/arch/powerpc/dom0_ops.c	Wed Aug 30 22:36:18 2006 +0100
     6.2 +++ b/xen/arch/powerpc/dom0_ops.c	Mon Sep 18 12:48:56 2006 -0500
     6.3 @@ -27,6 +27,7 @@
     6.4  #include <public/xen.h>
     6.5  #include <public/domctl.h>
     6.6  #include <public/sysctl.h>
     6.7 +#include <asm/processor.h>
     6.8  
     6.9  void arch_getdomaininfo_ctxt(struct vcpu *, vcpu_guest_context_t *);
    6.10  void arch_getdomaininfo_ctxt(struct vcpu *v, vcpu_guest_context_t *c)
    6.11 @@ -92,6 +93,22 @@ long arch_do_domctl(struct xen_domctl *d
    6.12          } 
    6.13      }
    6.14      break;
    6.15 +    case XEN_DOMCTL_real_mode_area:
    6.16 +    {
    6.17 +        struct domain *d;
    6.18 +        unsigned int log = domctl->u.real_mode_area.log;
    6.19 +
    6.20 +        d = find_domain_by_id(domctl->domain);
    6.21 +        if (d == NULL)
    6.22 +            return -ESRCH;
    6.23 +
    6.24 +        if (!cpu_rma_valid(log))
    6.25 +            return -EINVAL;
    6.26 +
    6.27 +        ret = allocate_rma(d, log - PAGE_SHIFT);
    6.28 +        put_domain(d);
    6.29 +    }
    6.30 +    break;
    6.31  
    6.32      default:
    6.33          ret = -ENOSYS;
     7.1 --- a/xen/arch/powerpc/domain.c	Wed Aug 30 22:36:18 2006 +0100
     7.2 +++ b/xen/arch/powerpc/domain.c	Mon Sep 18 12:48:56 2006 -0500
     7.3 @@ -75,11 +75,6 @@ unsigned long hypercall_create_continuat
     7.4  
     7.5  int arch_domain_create(struct domain *d)
     7.6  {
     7.7 -    unsigned long rma_base;
     7.8 -    unsigned long rma_sz;
     7.9 -    uint rma_order_pages;
    7.10 -    int rc;
    7.11 -
    7.12      if (d->domain_id == IDLE_DOMAIN_ID) {
    7.13          d->shared_info = (void *)alloc_xenheap_page();
    7.14          clear_page(d->shared_info);
    7.15 @@ -87,20 +82,6 @@ int arch_domain_create(struct domain *d)
    7.16          return 0;
    7.17      }
    7.18  
    7.19 -    /* allocate the real mode area */
    7.20 -    rma_order_pages = cpu_default_rma_order_pages();
    7.21 -    d->max_pages = 1UL << rma_order_pages;
    7.22 -    d->tot_pages = 0;
    7.23 -
    7.24 -    rc = allocate_rma(d, rma_order_pages);
    7.25 -    if (rc)
    7.26 -        return rc;
    7.27 -    rma_base = page_to_maddr(d->arch.rma_page);
    7.28 -    rma_sz = rma_size(rma_order_pages);
    7.29 -
    7.30 -    d->shared_info = (shared_info_t *)
    7.31 -        (rma_addr(&d->arch, RMA_SHARED_INFO) + rma_base);
    7.32 -
    7.33      d->arch.large_page_sizes = cpu_large_page_orders(
    7.34          d->arch.large_page_order, ARRAY_SIZE(d->arch.large_page_order));
    7.35  
    7.36 @@ -264,7 +245,8 @@ void sync_vcpu_execstate(struct vcpu *v)
    7.37  
    7.38  void domain_relinquish_resources(struct domain *d)
    7.39  {
    7.40 -    free_domheap_pages(d->arch.rma_page, d->arch.rma_order);
    7.41 +    if (d->arch.rma_page)
    7.42 +        free_domheap_pages(d->arch.rma_page, d->arch.rma_order);
    7.43      free_extents(d);
    7.44  }
    7.45  
     8.1 --- a/xen/arch/powerpc/elf32.c	Wed Aug 30 22:36:18 2006 +0100
     8.2 +++ b/xen/arch/powerpc/elf32.c	Mon Sep 18 12:48:56 2006 -0500
     8.3 @@ -1,5 +1,7 @@
     8.4  #define parseelfimage parseelfimage_32
     8.5  #define loadelfimage loadelfimage_32
     8.6 +#define xen_elfnote_string xen_elfnote_string32
     8.7 +#define xen_elfnote_numeric xen_elfnote_numeric32
     8.8  #define ELFSIZE 32
     8.9  #include "../../common/elf.c"
    8.10  
     9.1 --- a/xen/arch/powerpc/hcalls.c	Wed Aug 30 22:36:18 2006 +0100
     9.2 +++ b/xen/arch/powerpc/hcalls.c	Mon Sep 18 12:48:56 2006 -0500
     9.3 @@ -112,9 +112,8 @@ static void do_ni_papr_hypercall(struct 
     9.4  {
     9.5      struct vcpu *v = get_current();
     9.6  
     9.7 -    printk("unsupported hcall 0x%lx was called by dom0x%x\n",
     9.8 +    printk("unsupported PAPR hcall 0x%lx was called by dom0x%x\n",
     9.9              regs->gprs[3], v->domain->domain_id);
    9.10 -    debugger_trap_immediate();
    9.11  
    9.12      regs->gprs[3] = H_Parameter;
    9.13  }
    10.1 --- a/xen/arch/powerpc/iommu.c	Wed Aug 30 22:36:18 2006 +0100
    10.2 +++ b/xen/arch/powerpc/iommu.c	Mon Sep 18 12:48:56 2006 -0500
    10.3 @@ -52,7 +52,7 @@ int iommu_put(u32 buid, ulong ioba, unio
    10.4  
    10.5          pfn = tce.tce_bits.tce_rpn;
    10.6          mfn = pfn2mfn(d, pfn, &mtype);
    10.7 -        if (mfn > 0) {
    10.8 +        if (mfn != INVALID_MFN) {
    10.9  #ifdef DEBUG
   10.10              printk("%s: ioba=0x%lx pfn=0x%lx mfn=0x%lx\n", __func__,
   10.11                     ioba, pfn, mfn);
    11.1 --- a/xen/arch/powerpc/mm.c	Wed Aug 30 22:36:18 2006 +0100
    11.2 +++ b/xen/arch/powerpc/mm.c	Mon Sep 18 12:48:56 2006 -0500
    11.3 @@ -301,27 +301,41 @@ uint allocate_extents(struct domain *d, 
    11.4  
    11.5      return total_nrpages;
    11.6  }
    11.7 -        
    11.8 -int allocate_rma(struct domain *d, unsigned int order_pages)
    11.9 +
   11.10 +int allocate_rma(struct domain *d, unsigned int order)
   11.11  {
   11.12 +    struct vcpu *v;
   11.13      ulong rma_base;
   11.14 -    ulong rma_sz = rma_size(order_pages);
   11.15 +    ulong rma_sz;
   11.16 +
   11.17 +    if (d->arch.rma_page)
   11.18 +        free_domheap_pages(d->arch.rma_page, d->arch.rma_order);
   11.19  
   11.20 -    d->arch.rma_page = alloc_domheap_pages(d, order_pages, 0);
   11.21 +    d->arch.rma_page = alloc_domheap_pages(d, order, 0);
   11.22      if (d->arch.rma_page == NULL) {
   11.23 -        DPRINTK("Could not allocate order_pages=%d RMA for domain %u\n",
   11.24 -                order_pages, d->domain_id);
   11.25 +        DPRINTK("Could not allocate order=%d RMA for domain %u\n",
   11.26 +                order, d->domain_id);
   11.27          return -ENOMEM;
   11.28      }
   11.29 -    d->arch.rma_order = order_pages;
   11.30 +    d->arch.rma_order = order;
   11.31  
   11.32      rma_base = page_to_maddr(d->arch.rma_page);
   11.33 +    rma_sz = rma_size(d->arch.rma_order);
   11.34      BUG_ON(rma_base & (rma_sz - 1)); /* check alignment */
   11.35  
   11.36 -    /* XXX */
   11.37 +    /* XXX shouldn't be needed */
   11.38      printk("clearing RMA: 0x%lx[0x%lx]\n", rma_base, rma_sz);
   11.39      memset((void *)rma_base, 0, rma_sz);
   11.40  
   11.41 +    d->shared_info = (shared_info_t *)
   11.42 +        (rma_addr(&d->arch, RMA_SHARED_INFO) + rma_base);
   11.43 +
   11.44 +    /* if there are already running vcpus, adjust v->vcpu_info */
   11.45 +    /* XXX untested */
   11.46 +    for_each_vcpu(d, v) {
   11.47 +        v->vcpu_info = &d->shared_info->vcpu_info[v->vcpu_id];
   11.48 +    }
   11.49 +
   11.50      return 0;
   11.51  }
   11.52  
   11.53 @@ -331,6 +345,10 @@ ulong pfn2mfn(struct domain *d, long pfn
   11.54      ulong rma_size_mfn = 1UL << d->arch.rma_order;
   11.55      struct page_extents *pe;
   11.56  
   11.57 +    if (type)
   11.58 +        *type = PFN_TYPE_NONE;
   11.59 +
   11.60 +    /* quick tests first */
   11.61      if (pfn < rma_size_mfn) {
   11.62          if (type)
   11.63              *type = PFN_TYPE_RMA;
   11.64 @@ -344,7 +362,6 @@ ulong pfn2mfn(struct domain *d, long pfn
   11.65          return pfn;
   11.66      }
   11.67  
   11.68 -    /* quick tests first */
   11.69      list_for_each_entry (pe, &d->arch.extent_list, pe_list) {
   11.70          uint end_pfn = pe->pfn + (1 << pe->order);
   11.71  
   11.72 @@ -364,7 +381,7 @@ ulong pfn2mfn(struct domain *d, long pfn
   11.73      }
   11.74  
   11.75      BUG();
   11.76 -    return 0;
   11.77 +    return INVALID_MFN;
   11.78  }
   11.79  
   11.80  void guest_physmap_add_page(
    12.1 --- a/xen/arch/powerpc/ofd_fixup.c	Wed Aug 30 22:36:18 2006 +0100
    12.2 +++ b/xen/arch/powerpc/ofd_fixup.c	Mon Sep 18 12:48:56 2006 -0500
    12.3 @@ -28,6 +28,8 @@
    12.4  
    12.5  #undef RTAS
    12.6  
    12.7 +ofdn_t ofd_boot_cpu;
    12.8 +
    12.9  #ifdef PAPR_VTERM
   12.10  static ofdn_t ofd_vdevice_vty(void *m, ofdn_t p, struct domain *d)
   12.11  {
   12.12 @@ -172,24 +174,21 @@ static ofdn_t ofd_cpus_props(void *m, st
   12.13  #endif
   12.14  
   12.15      c = ofd_node_find_by_prop(m, n, "device_type", cpu, sizeof (cpu));
   12.16 +    if (ofd_boot_cpu == -1)
   12.17 +        ofd_boot_cpu = c;
   12.18      while (c > 0) {
   12.19 -        ibm_pft_size[1] = d->arch.htab.log_num_ptes + LOG_PTE_SIZE;
   12.20 -        ofd_prop_add(m, c, "ibm,pft-size",
   12.21 -                     ibm_pft_size, sizeof (ibm_pft_size));
   12.22 +        /* Since we are not MP yet we prune all but the booting cpu */
   12.23 +        if (c == ofd_boot_cpu) {
   12.24 +            ibm_pft_size[1] = d->arch.htab.log_num_ptes + LOG_PTE_SIZE;
   12.25 +            ofd_prop_add(m, c, "ibm,pft-size",
   12.26 +                         ibm_pft_size, sizeof (ibm_pft_size));
   12.27  
   12.28 -        /* FIXME: Check the the "l2-cache" property who's
   12.29 -         * contents is an orphaned phandle? */
   12.30 -        c = ofd_node_find_next(m, c);
   12.31 -
   12.32 -        /* Since we are not MP yet we can prune the rest of the CPUs */
   12.33 -        while (c > 0) {
   12.34 -            ofdn_t nc;
   12.35 -
   12.36 -            nc = ofd_node_find_next(m, c);
   12.37 +            /* FIXME: Check the the "l2-cache" property who's
   12.38 +             * contents is an orphaned phandle? */
   12.39 +        } else
   12.40              ofd_node_prune(m, c);
   12.41  
   12.42 -            c = nc;
   12.43 -        }
   12.44 +        c = ofd_node_find_next(m, c);
   12.45      }
   12.46  
   12.47      return n;
    13.1 --- a/xen/arch/powerpc/oftree.h	Wed Aug 30 22:36:18 2006 +0100
    13.2 +++ b/xen/arch/powerpc/oftree.h	Mon Sep 18 12:48:56 2006 -0500
    13.3 @@ -21,10 +21,12 @@
    13.4  #ifndef _OFTREE_H
    13.5  #define _OFTREE_H
    13.6  #include <xen/multiboot.h>
    13.7 +#include "of-devtree.h"
    13.8  
    13.9  extern ulong oftree;
   13.10  extern ulong oftree_len;
   13.11  extern ulong oftree_end;
   13.12 +extern ofdn_t ofd_boot_cpu;
   13.13  
   13.14  extern int ofd_dom0_fixup(struct domain *d, ulong mem, start_info_t *si);
   13.15  extern void ofd_memory_props(void *m, struct domain *d);
    14.1 --- a/xen/arch/powerpc/papr/xlate.c	Wed Aug 30 22:36:18 2006 +0100
    14.2 +++ b/xen/arch/powerpc/papr/xlate.c	Mon Sep 18 12:48:56 2006 -0500
    14.3 @@ -164,6 +164,10 @@ static void h_enter(struct cpu_user_regs
    14.4      lpn = pte.bits.rpn & lpn;
    14.5  
    14.6      rpn = pfn2mfn(d, lpn, &mtype);
    14.7 +    if (rpn == INVALID_MFN) {
    14.8 +        regs->gprs[3] =  H_Parameter;
    14.9 +        return;
   14.10 +    }
   14.11  
   14.12      if (mtype == PFN_TYPE_IO) {
   14.13          /* only a privilaged dom can access outside IO space */
    15.1 --- a/xen/arch/powerpc/powerpc64/ppc970.c	Wed Aug 30 22:36:18 2006 +0100
    15.2 +++ b/xen/arch/powerpc/powerpc64/ppc970.c	Mon Sep 18 12:48:56 2006 -0500
    15.3 @@ -32,21 +32,19 @@
    15.4  
    15.5  #undef SERIALIZE
    15.6  
    15.7 -extern volatile struct processor_area * volatile global_cpu_table[];
    15.8 -
    15.9  struct rma_settings {
   15.10      int order;
   15.11 -    int rmlr0;
   15.12 -    int rmlr12;
   15.13 +    int rmlr_0;
   15.14 +    int rmlr_1_2;
   15.15  };
   15.16  
   15.17  static struct rma_settings rma_orders[] = {
   15.18 -    { .order = 26, .rmlr0 = 0, .rmlr12 = 3, }, /*  64 MB */
   15.19 -    { .order = 27, .rmlr0 = 1, .rmlr12 = 3, }, /* 128 MB */
   15.20 -    { .order = 28, .rmlr0 = 1, .rmlr12 = 0, }, /* 256 MB */
   15.21 -    { .order = 30, .rmlr0 = 0, .rmlr12 = 2, }, /*   1 GB */
   15.22 -    { .order = 34, .rmlr0 = 0, .rmlr12 = 1, }, /*  16 GB */
   15.23 -    { .order = 38, .rmlr0 = 0, .rmlr12 = 0, }, /* 256 GB */
   15.24 +    { .order = 26, .rmlr_0 = 0, .rmlr_1_2 = 3, }, /*  64 MB */
   15.25 +    { .order = 27, .rmlr_0 = 1, .rmlr_1_2 = 3, }, /* 128 MB */
   15.26 +    { .order = 28, .rmlr_0 = 1, .rmlr_1_2 = 0, }, /* 256 MB */
   15.27 +    { .order = 30, .rmlr_0 = 0, .rmlr_1_2 = 2, }, /*   1 GB */
   15.28 +    { .order = 34, .rmlr_0 = 0, .rmlr_1_2 = 1, }, /*  16 GB */
   15.29 +    { .order = 38, .rmlr_0 = 0, .rmlr_1_2 = 0, }, /* 256 GB */
   15.30  };
   15.31  
   15.32  static uint log_large_page_sizes[] = {
   15.33 @@ -68,6 +66,11 @@ unsigned int cpu_default_rma_order_pages
   15.34      return rma_orders[0].order - PAGE_SHIFT;
   15.35  }
   15.36  
   15.37 +int cpu_rma_valid(unsigned int log)
   15.38 +{
   15.39 +    return cpu_find_rma(log) != NULL;
   15.40 +}
   15.41 +
   15.42  unsigned int cpu_large_page_orders(uint *sizes, uint max)
   15.43  {
   15.44      uint i = 0;
   15.45 @@ -85,12 +88,36 @@ unsigned int cpu_extent_order(void)
   15.46      return log_large_page_sizes[0] - PAGE_SHIFT;
   15.47  }
   15.48  
   15.49 +static u64 cpu0_hids[6];
   15.50 +static u64 cpu0_hior;
   15.51 +
   15.52  void cpu_initialize(int cpuid)
   15.53  {
   15.54      ulong r1, r2;
   15.55 +    union hid0 hid0;
   15.56 +    union hid1 hid1;
   15.57 +    union hid4 hid4;
   15.58 +    union hid5 hid5;
   15.59 +
   15.60      __asm__ __volatile__ ("mr %0, 1" : "=r" (r1));
   15.61      __asm__ __volatile__ ("mr %0, 2" : "=r" (r2));
   15.62  
   15.63 +    if (cpuid == 0) {
   15.64 +        /* we can assume that these are sane to start with.  We
   15.65 +         * _do_not_ store the results in case we want to mess with them
   15.66 +         * on a per-cpu basis later. */
   15.67 +        cpu0_hids[0] = mfhid0();
   15.68 +        cpu0_hids[1] = mfhid1();
   15.69 +        cpu0_hids[4] = mfhid4();
   15.70 +        cpu0_hids[5] = mfhid5();
   15.71 +        cpu0_hior = 0;
   15.72 +    }
   15.73 +
   15.74 +    hid0.word = cpu0_hids[0];
   15.75 +    hid1.word = cpu0_hids[1];
   15.76 +    hid4.word = cpu0_hids[4];
   15.77 +    hid5.word = cpu0_hids[5];
   15.78 +
   15.79      /* This is SMP safe because the compiler must use r13 for it.  */
   15.80      parea = global_cpu_table[cpuid];
   15.81      ASSERT(parea != NULL);
   15.82 @@ -103,25 +130,21 @@ void cpu_initialize(int cpuid)
   15.83      mtdec(timebase_freq);
   15.84      mthdec(timebase_freq);
   15.85  
   15.86 -    union hid0 hid0;
   15.87 +    hid0.bits.nap = 1;      /* NAP */
   15.88 +    hid0.bits.dpm = 1;      /* Dynamic Power Management */
   15.89 +    hid0.bits.nhr = 0;      /* ! Not Hard Reset */
   15.90 +    hid0.bits.hdice_en = 1; /* enable HDEC */
   15.91 +    hid0.bits.en_therm = 0; /* ! Enable ext thermal ints */
   15.92 +    /* onlu debug Xen should do this */
   15.93 +    hid0.bits.en_attn = 1; /* Enable attn instruction */
   15.94  
   15.95 -    hid0.word = mfhid0();
   15.96 -    hid0.bits.nap = 1;
   15.97 -    hid0.bits.dpm = 1;
   15.98 -    hid0.bits.nhr = 1;
   15.99 -    hid0.bits.hdice = 1; /* enable HDEC */
  15.100 -    hid0.bits.eb_therm = 1;
  15.101 -    hid0.bits.en_attn = 1;
  15.102  #ifdef SERIALIZE
  15.103 -    ulong s = 0;
  15.104 -
  15.105 -    s |= 1UL << (63-0);     /* one_ppc */
  15.106 -    s |= 1UL << (63-2);     /* isync_sc */
  15.107 -    s |= 1UL << (63-16);     /* inorder */
  15.108 +    hid0.bits.one_ppc = 1;
  15.109 +    hid0.bits.isync_sc = 1;
  15.110 +    hid0.bits.inorder = 1;
  15.111      /* may not want these */
  15.112 -    s |= 1UL << (63-1);     /* do_single */
  15.113 -    s |= 1UL << (63-3);     /* ser-gp */
  15.114 -    hid0.word |= s;
  15.115 +    hid0.bits.do_single = 1;
  15.116 +    hid0.bits.ser-gp = 1;
  15.117  #endif
  15.118  
  15.119      printk("CPU #%d: Hello World! SP = %lx TOC = %lx HID0 = %lx\n", 
  15.120 @@ -129,32 +152,42 @@ void cpu_initialize(int cpuid)
  15.121  
  15.122      mthid0(hid0.word);
  15.123  
  15.124 -    union hid1 hid1;
  15.125 +    hid1.bits.bht_pm = 7; /* branch history table prediction mode */
  15.126 +    hid1.bits.en_ls = 1; /* enable link stack */
  15.127  
  15.128 -    hid1.word = mfhid1();
  15.129 -    hid1.bits.bht_pm = 7;
  15.130 -    hid1.bits.en_ls = 1;
  15.131 -
  15.132 -    hid1.bits.en_cc = 1;
  15.133 -    hid1.bits.en_ic = 1;
  15.134 +    hid1.bits.en_cc = 1; /* enable count cache */
  15.135 +    hid1.bits.en_ic = 1; /* enable inst cache */
  15.136  
  15.137 -    hid1.bits.pf_mode = 2;
  15.138 +    hid1.bits.pf_mode = 2; /* prefetch mode */
  15.139  
  15.140 -    hid1.bits.en_if_cach = 1;
  15.141 -    hid1.bits.en_ic_rec = 1;
  15.142 -    hid1.bits.en_id_rec = 1;
  15.143 -    hid1.bits.en_er_rec = 1;
  15.144 +    hid1.bits.en_if_cach = 1; /* i-fetch cacheability control */
  15.145 +    hid1.bits.en_ic_rec = 1; /* i-cache parity error recovery */
  15.146 +    hid1.bits.en_id_rec = 1; /* i-dir parity error recovery */
  15.147 +    hid1.bits.en_er_rec = 1; /* i-ERAT parity error recovery */
  15.148  
  15.149 -    hid1.bits.en_sp_itw = 1;
  15.150 +    hid1.bits.en_sp_itw = 1; /* En speculative tablewalks */
  15.151      mthid1(hid1.word);
  15.152  
  15.153 -    union hid5 hid5;
  15.154 +    /* no changes to hid4 but we want to make sure that secondaries
  15.155 +     * are sane */
  15.156 +    hid4.bits.lg_pg_dis = 0;    /* make sure we enable large pages */
  15.157 +    mthid4(hid4.word);
  15.158  
  15.159 -    hid5.word = mfhid5();
  15.160 -    hid5.bits.DCBZ_size = 0;
  15.161 -    hid5.bits.DCBZ32_ill = 0;
  15.162 +    hid5.bits.DCBZ_size = 0; /* make dcbz size 32 bytes */
  15.163 +    hid5.bits.DCBZ32_ill = 0; /* make dzbz 32byte illeagal */
  15.164      mthid5(hid5.word);
  15.165  
  15.166 +#ifdef DUMP_HIDS
  15.167 +    printk("hid0 0x%016lx\n"
  15.168 +           "hid1 0x%016lx\n"
  15.169 +           "hid4 0x%016lx\n"
  15.170 +           "hid5 0x%016lx\n",
  15.171 +           mfhid0(), mfhid1(), mfhid4(), mfhid5());
  15.172 +#endif
  15.173 +
  15.174 +    mthior(cpu0_hior);
  15.175 +
  15.176 +    /* for good luck */
  15.177      __asm__ __volatile__("isync; slbia; isync" : : : "memory");
  15.178  }
  15.179  
  15.180 @@ -166,18 +199,18 @@ void cpu_init_vcpu(struct vcpu *v)
  15.181  
  15.182      hid4.word = mfhid4();
  15.183  
  15.184 -    hid4.bits.lpes0 = 0; /* exceptions set MSR_HV=1 */
  15.185 -    hid4.bits.lpes1 = 1; /* RMA applies */
  15.186 +    hid4.bits.lpes_0 = 0; /* external exceptions set MSR_HV=1 */
  15.187 +    hid4.bits.lpes_1 = 1; /* RMA applies */
  15.188  
  15.189 -    hid4.bits.rmor = page_to_maddr(d->arch.rma_page) >> 26;
  15.190 +    hid4.bits.rmor_0_15 = page_to_maddr(d->arch.rma_page) >> 26;
  15.191  
  15.192 -    hid4.bits.lpid01 = d->domain_id & 3;
  15.193 -    hid4.bits.lpid25 = (d->domain_id >> 2) & 0xf;
  15.194 +    hid4.bits.lpid_0_1 = d->domain_id & 3;
  15.195 +    hid4.bits.lpid_2_5 = (d->domain_id >> 2) & 0xf;
  15.196  
  15.197      rma_settings = cpu_find_rma(d->arch.rma_order + PAGE_SHIFT);
  15.198      ASSERT(rma_settings != NULL);
  15.199 -    hid4.bits.rmlr0 = rma_settings->rmlr0;
  15.200 -    hid4.bits.rmlr12 = rma_settings->rmlr12;
  15.201 +    hid4.bits.rmlr_0 = rma_settings->rmlr_0;
  15.202 +    hid4.bits.rmlr_1_2 = rma_settings->rmlr_1_2;
  15.203  
  15.204      v->arch.cpu.hid4.word = hid4.word;
  15.205  }
    16.1 --- a/xen/arch/powerpc/setup.c	Wed Aug 30 22:36:18 2006 +0100
    16.2 +++ b/xen/arch/powerpc/setup.c	Mon Sep 18 12:48:56 2006 -0500
    16.3 @@ -77,6 +77,7 @@ cpumask_t cpu_present_map;
    16.4  cpumask_t cpu_possible_map;
    16.5  
    16.6  /* XXX get this from ISA node in device tree */
    16.7 +void *vgabase;
    16.8  ulong isa_io_base;
    16.9  struct ns16550_defaults ns16550;
   16.10  
   16.11 @@ -255,7 +256,6 @@ static int kick_secondary_cpus(int maxcp
   16.12              break;
   16.13          init_parea(cpuid);
   16.14          cpu_set(cpuid, cpu_online_map);
   16.15 -        cpu_set(cpuid, cpu_possible_map);
   16.16      }
   16.17  
   16.18      return 0;
   16.19 @@ -339,7 +339,7 @@ static void __init __start_xen(multiboot
   16.20  #endif
   16.21  
   16.22      /* Deal with secondary processors.  */
   16.23 -    if (opt_nosmp) {
   16.24 +    if (opt_nosmp || ofd_boot_cpu == -1) {
   16.25          printk("nosmp: leaving secondary processors spinning forever\n");
   16.26      } else {
   16.27          printk("spinning up at most %d total processors ...\n", max_cpus);
   16.28 @@ -350,8 +350,13 @@ static void __init __start_xen(multiboot
   16.29  
   16.30      /* Create initial domain 0. */
   16.31      dom0 = domain_create(0);
   16.32 -    if ((dom0 == NULL) || (alloc_vcpu(dom0, 0, 0) == NULL))
   16.33 +    if (dom0 == NULL)
   16.34          panic("Error creating domain 0\n");
   16.35 +    dom0->max_pages = ~0U;
   16.36 +    if (0 > allocate_rma(dom0, cpu_default_rma_order_pages()))
   16.37 +        panic("Error allocating domain 0 RMA\n");
   16.38 +    if (NULL == alloc_vcpu(dom0, 0, 0))
   16.39 +        panic("Error creating domain 0 vcpu 0\n");
   16.40  
   16.41      set_bit(_DOMF_privileged, &dom0->domain_flags);
   16.42      /* post-create hooks sets security label */
    17.1 --- a/xen/arch/powerpc/shadow.c	Wed Aug 30 22:36:18 2006 +0100
    17.2 +++ b/xen/arch/powerpc/shadow.c	Mon Sep 18 12:48:56 2006 -0500
    17.3 @@ -78,7 +78,6 @@ unsigned int shadow_set_allocation(struc
    17.4                                      unsigned int megabytes,
    17.5                                      int *preempted)
    17.6  {
    17.7 -    unsigned int rc;
    17.8      uint pages;
    17.9      uint p;
   17.10      uint order;
   17.11 @@ -91,7 +90,7 @@ unsigned int shadow_set_allocation(struc
   17.12      if (megabytes == 0) {
   17.13          /* old management tools */
   17.14          megabytes = 1;          /* 1/64th of 64M */
   17.15 -        printk("%s: Fix management tools to set and get shadow/htab values\n"
   17.16 +        printk("%s: WARNING!!: Update your managment tools\n"
   17.17                 "    using %d MiB htab\n",
   17.18                 __func__, megabytes);
   17.19      }
   17.20 @@ -112,7 +111,7 @@ unsigned int shadow_set_allocation(struc
   17.21      for (p = 0; p < (1 << order); p++)
   17.22          clear_page((void *)(addr + (p << PAGE_SHIFT)));
   17.23  
   17.24 -    return rc;
   17.25 +    return 0;
   17.26  }
   17.27  
   17.28  int shadow_domctl(struct domain *d, 
    18.1 --- a/xen/arch/powerpc/usercopy.c	Wed Aug 30 22:36:18 2006 +0100
    18.2 +++ b/xen/arch/powerpc/usercopy.c	Mon Sep 18 12:48:56 2006 -0500
    18.3 @@ -47,14 +47,24 @@ static unsigned long paddr_to_maddr(unsi
    18.4      pfn = pa >> PAGE_SHIFT;
    18.5  
    18.6      pa = pfn2mfn(d, pfn, &mtype);
    18.7 +    if (pa == INVALID_MFN) {
    18.8 +        printk("%s: Dom:%d bad paddr: 0x%lx\n",
    18.9 +               __func__, d->domain_id, paddr);
   18.10 +        return 0;
   18.11 +    }
   18.12      switch (mtype) {
   18.13 -        case PFN_TYPE_RMA:
   18.14 -        case PFN_TYPE_LOGICAL:
   18.15 -            break;
   18.16 -        default:
   18.17 -            panic("%s: called with bad memory address type: 0x%lx\n",
   18.18 -                    __func__, paddr);
   18.19 -            break;
   18.20 +    case PFN_TYPE_RMA:
   18.21 +    case PFN_TYPE_LOGICAL:
   18.22 +        break;
   18.23 +    case PFN_TYPE_REMOTE:
   18.24 +        printk("%s: Dom:%d paddr: 0x%lx type: REMOTE\n",
   18.25 +               __func__, d->domain_id, paddr);
   18.26 +        WARN();
   18.27 +        break;
   18.28 +    default:
   18.29 +        panic("%s: Dom:%d paddr: 0x%lx bad type:0x%x\n",
   18.30 +               __func__, d->domain_id, paddr, mtype);
   18.31 +        break;
   18.32      }
   18.33      pa <<= PAGE_SHIFT;
   18.34      pa |= offset;
   18.35 @@ -85,6 +95,9 @@ xencomm_copy_from_guest(void *to, const 
   18.36  
   18.37      /* first we need to access the descriptor */
   18.38      desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)from);
   18.39 +    if (desc == NULL)
   18.40 +        return n;
   18.41 +
   18.42      if (desc->magic != XENCOMM_MAGIC) {
   18.43          printk("%s: error: %p magic was 0x%x\n",
   18.44                 __func__, desc, desc->magic);
   18.45 @@ -117,6 +130,9 @@ xencomm_copy_from_guest(void *to, const 
   18.46              unsigned int bytes = min(chunksz, n - to_pos);
   18.47  
   18.48              src_maddr = paddr_to_maddr(src_paddr + chunk_skip);
   18.49 +            if (src_maddr == 0)
   18.50 +                return n - to_pos;
   18.51 +
   18.52              if (xencomm_debug)
   18.53                  printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest);
   18.54              memcpy((void *)dest, (void *)src_maddr, bytes);
   18.55 @@ -153,6 +169,9 @@ xencomm_copy_to_guest(void *to, const vo
   18.56  
   18.57      /* first we need to access the descriptor */
   18.58      desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)to);
   18.59 +    if (desc == NULL)
   18.60 +        return n;
   18.61 +
   18.62      if (desc->magic != XENCOMM_MAGIC) {
   18.63          printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
   18.64          return n;
   18.65 @@ -184,6 +203,9 @@ xencomm_copy_to_guest(void *to, const vo
   18.66              unsigned int bytes = min(chunksz, n - from_pos);
   18.67  
   18.68              dest_maddr = paddr_to_maddr(dest_paddr + chunk_skip);
   18.69 +            if (dest_maddr == 0)
   18.70 +                return -1;
   18.71 +
   18.72              if (xencomm_debug)
   18.73                  printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr);
   18.74              memcpy((void *)dest_maddr, (void *)source, bytes);
   18.75 @@ -199,16 +221,19 @@ xencomm_copy_to_guest(void *to, const vo
   18.76  
   18.77  /* Offset page addresses in 'handle' to skip 'bytes' bytes. Set completely
   18.78   * exhausted pages to XENCOMM_INVALID. */
   18.79 -void xencomm_add_offset(void *handle, unsigned int bytes)
   18.80 +int xencomm_add_offset(void *handle, unsigned int bytes)
   18.81  {
   18.82      struct xencomm_desc *desc;
   18.83      int i = 0;
   18.84  
   18.85      /* first we need to access the descriptor */
   18.86      desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)handle);
   18.87 +    if (desc == NULL)
   18.88 +        return -1;
   18.89 +
   18.90      if (desc->magic != XENCOMM_MAGIC) {
   18.91          printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
   18.92 -        return;
   18.93 +        return -1;
   18.94      }
   18.95  
   18.96      /* iterate through the descriptor incrementing addresses */
   18.97 @@ -230,6 +255,7 @@ void xencomm_add_offset(void *handle, un
   18.98          }
   18.99          bytes -= chunk_skip;
  18.100      }
  18.101 +    return 0;
  18.102  }
  18.103  
  18.104  int xencomm_handle_is_null(void *ptr)
  18.105 @@ -237,6 +263,9 @@ int xencomm_handle_is_null(void *ptr)
  18.106      struct xencomm_desc *desc;
  18.107  
  18.108      desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)ptr);
  18.109 +    if (desc == NULL)
  18.110 +        return 1;
  18.111  
  18.112      return (desc->nr_addrs == 0);
  18.113  }
  18.114 +
    19.1 --- a/xen/include/asm-powerpc/current.h	Wed Aug 30 22:36:18 2006 +0100
    19.2 +++ b/xen/include/asm-powerpc/current.h	Mon Sep 18 12:48:56 2006 -0500
    19.3 @@ -27,8 +27,8 @@
    19.4  
    19.5  struct vcpu;
    19.6  
    19.7 +extern volatile struct processor_area * volatile global_cpu_table[];
    19.8  register volatile struct processor_area *parea asm("r13");
    19.9 -
   19.10  static inline struct vcpu *get_current(void)
   19.11  {
   19.12      return parea->cur_vcpu;
    20.1 --- a/xen/include/asm-powerpc/flushtlb.h	Wed Aug 30 22:36:18 2006 +0100
    20.2 +++ b/xen/include/asm-powerpc/flushtlb.h	Mon Sep 18 12:48:56 2006 -0500
    20.3 @@ -35,9 +35,6 @@ DECLARE_PER_CPU(u32, tlbflush_time);
    20.4  
    20.5  static inline int NEED_FLUSH(u32 cpu_stamp, u32 lastuse_stamp)
    20.6  {
    20.7 -#if 0
    20.8 -    trap();
    20.9 -#endif
   20.10      return 0;
   20.11  }
   20.12  
    21.1 --- a/xen/include/asm-powerpc/guest_access.h	Wed Aug 30 22:36:18 2006 +0100
    21.2 +++ b/xen/include/asm-powerpc/guest_access.h	Mon Sep 18 12:48:56 2006 -0500
    21.3 @@ -25,7 +25,7 @@ extern unsigned long xencomm_copy_to_gue
    21.4          unsigned int len, unsigned int skip); 
    21.5  extern unsigned long xencomm_copy_from_guest(void *to, const void *from,
    21.6          unsigned int len, unsigned int skip); 
    21.7 -extern void xencomm_add_offset(void *handle, unsigned int bytes);
    21.8 +extern int xencomm_add_offset(void *handle, unsigned int bytes);
    21.9  extern int xencomm_handle_is_null(void *ptr);
   21.10  
   21.11  
    22.1 --- a/xen/include/asm-powerpc/io.h	Wed Aug 30 22:36:18 2006 +0100
    22.2 +++ b/xen/include/asm-powerpc/io.h	Mon Sep 18 12:48:56 2006 -0500
    22.3 @@ -40,6 +40,8 @@ extern ulong isa_io_base;
    22.4  #define readb(port) in_8((void *)(port))
    22.5  #define writeb(val, port) out_8((void *)(port), val)
    22.6  
    22.7 +extern char *vgabase;
    22.8 +#define vga_writeb(val, port) out_8((void *)((ulong)(port) + vgabase), val)
    22.9  
   22.10  extern u8 in_8(const volatile u8 *addr);
   22.11  extern void out_8(volatile u8 *addr, int val);
    23.1 --- a/xen/include/asm-powerpc/mm.h	Wed Aug 30 22:36:18 2006 +0100
    23.2 +++ b/xen/include/asm-powerpc/mm.h	Mon Sep 18 12:48:56 2006 -0500
    23.3 @@ -212,8 +212,6 @@ static inline int page_is_removable(stru
    23.4      return ((page->count_info & PGC_count_mask) == 1);
    23.5  }
    23.6  
    23.7 -#define set_machinetophys(_mfn, _pfn) (trap(), 0)
    23.8 -
    23.9  extern void synchronise_pagetables(unsigned long cpu_mask);
   23.10  
   23.11  /* XXX don't know what this is for */
   23.12 @@ -236,6 +234,8 @@ extern int update_grant_va_mapping(unsig
   23.13                                     struct domain *,
   23.14                                     struct vcpu *);
   23.15  
   23.16 +#define INVALID_MFN (~0UL)
   23.17 +#define PFN_TYPE_NONE 0
   23.18  #define PFN_TYPE_RMA 1
   23.19  #define PFN_TYPE_LOGICAL 2
   23.20  #define PFN_TYPE_IO 3
    24.1 --- a/xen/include/asm-powerpc/powerpc64/ppc970-hid.h	Wed Aug 30 22:36:18 2006 +0100
    24.2 +++ b/xen/include/asm-powerpc/powerpc64/ppc970-hid.h	Mon Sep 18 12:48:56 2006 -0500
    24.3 @@ -29,22 +29,30 @@
    24.4  
    24.5  union hid0 {
    24.6      struct hid0_bits {
    24.7 -        ulong   _unused_0_8:    9;
    24.8 -        ulong   nap:            1;
    24.9 -        ulong   _unused_10:     1;
   24.10 -        ulong   dpm:            1;  /* Dynamic Power Management */
   24.11 -        ulong   _unused_12_14:  3;
   24.12 -        ulong   nhr:            1;  /* Not Hard Reset */
   24.13 -        ulong   inorder:        1;
   24.14 +        ulong   one_ppc:        1; /* One PowerPC AS insn per dispatch group */
   24.15 +        ulong   do_single:      1; /* Single group completion */
   24.16 +        ulong   isync_sc:       1; /* Disable isync scoreboard optimization */
   24.17 +        ulong   ser_gp:         1; /* Serial Group Dispatch */
   24.18 +        ulong  _reserved_04_08: 5;
   24.19 +        ulong   nap:            1; /* Nap */
   24.20 +        ulong   _reserved_10:   1;
   24.21 +        ulong   dpm:            1; /* Dynamic Power Management */
   24.22 +        ulong   _reserved_12:   1;
   24.23 +        ulong   tg:             1; /* Perfmon threshold granualrity control */
   24.24 +        ulong   hang_dis:       1; /* Disable cpu hang detection mechanism */
   24.25 +        ulong   nhr:            1; /* Not Hard Reset */
   24.26 +        ulong   inorder:        1; /* Serial Group Issue */
   24.27          ulong   _reserved17:    1;
   24.28 -        ulong   tb_ctrl:        1;
   24.29 -        ulong   ext_tb_enb:     1;  /* timebase is linked to external clock */
   24.30 -        ulong   _unused_20_22:  3;
   24.31 -        ulong   hdice:          1;  /* HDEC enable */
   24.32 -        ulong   eb_therm:       1;  /* Enable ext thermal ints */
   24.33 +        ulong   tb_ctrl:        1; /* Enable time base couting while stopped */
   24.34 +        ulong   ext_tb_enb:     1; /* timebase is linked to external clock */
   24.35 +        ulong   _unused_20_21:  2;
   24.36 +        ulong   ciabr_en:       1;  /* CIABR enable */
   24.37 +        ulong   hdice_en:       1;  /* HDEC enable */
   24.38 +        ulong   en_therm:       1;  /* Enable ext thermal ints */
   24.39          ulong   _unused_25_30:  6;
   24.40          ulong   en_attn:        1;  /* Enable attn instruction */
   24.41 -        ulong   _unused_32_63:  32;
   24.42 +        ulong   en_mck:         1;  /* En external machine check interrupts */
   24.43 +        ulong   _unused_33_63:  31;
   24.44      } bits;
   24.45      ulong word;
   24.46  };
   24.47 @@ -62,11 +70,11 @@ union hid1 {
   24.48          ulong en_ic_rec:        1; /* i-cache parity error recovery */
   24.49          ulong en_id_rec:        1; /* i-dir parity error recovery */
   24.50          ulong en_er_rec:        1; /* i-ERAT parity error recovery */
   24.51 -        ulong ic_pe:            1;
   24.52 -        ulong icd0_pe:          1;
   24.53 +        ulong ic_pe:            1; /* Force instruction cache parity error */
   24.54 +        ulong icd0_pe:          1; /* Force insn cache dir 0 parity error */
   24.55          ulong _reserved_16:     1;
   24.56 -        ulong ier_pe:           1;
   24.57 -        ulong en_sp_itw:        1;
   24.58 +        ulong ier_pe:           1; /* force i-ERAT parity error (inject) */
   24.59 +        ulong en_sp_itw:        1; /* En speculative tablewalks */
   24.60          ulong _reserved_19_63:  45;
   24.61      } bits;
   24.62      ulong word;
   24.63 @@ -74,32 +82,61 @@ union hid1 {
   24.64  
   24.65  union hid4 {
   24.66      struct hid4_bits {
   24.67 -        ulong   lpes0:          1;  /* LPAR Environment Selector bit 0 */
   24.68 -        ulong   rmlr12:         2;  /* RMLR 1:2 */
   24.69 -        ulong   lpid25:         4;  /* LPAR ID bits 2:5 */
   24.70 -        ulong   rmor:           16; /* real mode offset region */
   24.71 -        ulong   rm_ci:          1;  /* real mode cache-inhibit */
   24.72 -        ulong   force_ai:       1;  /* Force alignment interrupt */
   24.73 -        ulong   _unused:        32;
   24.74 -        ulong   lpes1:          1;  /* LPAR Environment Selector bit 1 */
   24.75 -        ulong   rmlr0:          1;  /* RMLR 0 */
   24.76 +        ulong   lpes_0:         1; /* LPAR Environment Selector bit 0 */
   24.77 +        ulong   rmlr_1_2:       2; /* RMLR 1:2 */
   24.78 +        ulong   lpid_2_5:       4; /* LPAR ID bits 2:5 */
   24.79 +        ulong   rmor_0_15:     16; /* real mode offset region */
   24.80 +        ulong   rm_ci:          1; /* real mode cache-inhibit */
   24.81 +        ulong   force_ai:       1; /* Force alignment interrupt */
   24.82 +        ulong   dis_pref:       1; /* disable prefetching */
   24.83 +        ulong   res_pref:       1; /* reset data prefetching mechanism */
   24.84 +        ulong   en_sp_dtw:      1; /* enable speculative load tablewalk */
   24.85 +        ulong   l1dc_flsh:      1; /* L1 cache flash invalidate */
   24.86 +        ulong   dis_derpc:      2; /* Disable d-ERAT parity checking */
   24.87 +        ulong   dis_derpg:      1; /* Disable d-ERAT parity generation */
   24.88 +        ulong   dis_derat:      2; /* Disable d-ERAT */
   24.89 +        ulong   dis_dctpc:      2; /* Dis data cache tag paritiy checking */
   24.90 +        ulong   dis_dctpg:      1; /* Dis data cache tag paritiy generation */
   24.91 +        ulong   dis_dcset:      2; /* Disable data cache set */
   24.92 +        ulong   dis_dcpc:       2; /* Disable data cache paritiy checking */
   24.93 +        ulong   dis_dcpg:       1; /* Disable data cache paritiy generation */
   24.94 +        ulong   dis_dcrtpc:     2; /* Disable data cache real add tag parity */
   24.95 +        ulong   dis_tlbpc:      4; /* Disable TLB paritiy checking */
   24.96 +        ulong   dis_tlbpg:      1; /* Disable TLB paritiy generation */
   24.97 +        ulong   dis_tlbset:     4; /* Disable TLB set */
   24.98 +        ulong   dis_slbpc:      1; /* Disable SLB paritiy checking */
   24.99 +        ulong   dis_slbpg:      1; /* Disable SLB paritiy generation */
  24.100 +        ulong   mck_inj:        1; /* Machine check inject enable */
  24.101 +        ulong   dis_stfwd:      1; /* Disbale store forwarding */
  24.102 +        ulong   lpes_1:         1;  /* LPAR Environment Selector bit 1 */
  24.103 +        ulong   rmlr_0:         1;  /* RMLR 0 */
  24.104          ulong   _reserved:      1;
  24.105          ulong   dis_splarx:     1;  /* Disable spec. lwarx/ldarx */
  24.106          ulong   lg_pg_dis:      1;  /* Disable large page support */
  24.107 -        ulong   lpid01:         2;  /* LPAR ID bits 0:1 */
  24.108 +        ulong   lpid_0_1:       2;  /* LPAR ID bits 0:1 */
  24.109      } bits;
  24.110      ulong word;
  24.111  };
  24.112  
  24.113  union hid5 {
  24.114      struct hid5_bits {
  24.115 -        ulong  _reserved_0_31:  32;
  24.116 -        ulong   hrmor:          16;
  24.117 -        ulong   _reserver_48_49:2;
  24.118 -        ulong   _unused_50_55:  6;
  24.119 -        ulong   DCBZ_size:      1;
  24.120 -        ulong   DCBZ32_ill:     1;
  24.121 -        ulong  _unused_58_63:   6;
  24.122 +        ulong _reserved_0_31: 32;
  24.123 +        ulong hrmor_0_15:     16;
  24.124 +        ulong _reserved_48_49: 2;
  24.125 +        ulong DC_mck:          1; /* Machine check enabled for dcache errors */
  24.126 +        ulong dis_pwrsave:     1; /* Dis pwrsave on on L1 and d-ERAT */
  24.127 +        ulong force_G:         1; /* Force gaurded load */
  24.128 +        ulong DC_repl:         1; /* D-Cache replacement algo */
  24.129 +        ulong hwr_stms:        1; /* Number of available HW prefetch streams */
  24.130 +        ulong dst_noop:        1; /* D-stream Touch no-op */
  24.131 +        ulong DCBZ_size:       1; /* make dcbz size 32 bytes */
  24.132 +        ulong DCBZ32_ill:      1; /* make dzbz 32byte illeagal */
  24.133 +        ulong tlb_map:         1; /* TLB mapping */
  24.134 +        ulong lmq_port:        1; /* Demand miss (LMQ to STS) */
  24.135 +        ulong lmq_size_0:      1; /* number of outstanding req. to STS */
  24.136 +        ulong  _reserved_61:   1;
  24.137 +        ulong  tch_nop:        1; /* make dcbtand dcbtst ack like no-ops */
  24.138 +        ulong  lmq_size_1:     1; /* second bit to lmq_size_0 */
  24.139      } bits;
  24.140      ulong word;
  24.141  };
    25.1 --- a/xen/include/asm-powerpc/powerpc64/processor.h	Wed Aug 30 22:36:18 2006 +0100
    25.2 +++ b/xen/include/asm-powerpc/powerpc64/processor.h	Mon Sep 18 12:48:56 2006 -0500
    25.3 @@ -138,6 +138,11 @@ static inline void mthid0(ulong val)
    25.4      __asm__ __volatile__ (
    25.5              "sync\n"
    25.6              "mtspr %0, %1\n"
    25.7 +            "mfspr %1, %0\n"
    25.8 +            "mfspr %1, %0\n"
    25.9 +            "mfspr %1, %0\n"
   25.10 +            "mfspr %1, %0\n"
   25.11 +            "mfspr %1, %0\n"
   25.12              "isync\n"
   25.13              : : "i"(SPRN_HID0), "r"(val));
   25.14  }
   25.15 @@ -153,6 +158,7 @@ static inline void mthid1(ulong val)
   25.16      __asm__ __volatile__ (
   25.17              "sync\n"
   25.18              "mtspr %0, %1\n"
   25.19 +            "mtspr %0, %1\n"
   25.20              "isync\n"
   25.21              : : "i"(SPRN_HID1), "r"(val));
   25.22  }
   25.23 @@ -189,5 +195,23 @@ static inline void mthid5(ulong val)
   25.24              : : "i"(SPRN_HID5), "r"(val));
   25.25  }
   25.26  
   25.27 +static inline void mthrmor(ulong val)
   25.28 +{
   25.29 +    __asm__ __volatile__ (
   25.30 +            "sync\n"
   25.31 +            "mtspr %0, %1\n"
   25.32 +            "isync\n"
   25.33 +            : : "i"(SPRN_HRMOR), "r"(val));
   25.34 +}
   25.35 +
   25.36 +static inline void mthior(ulong val)
   25.37 +{
   25.38 +    __asm__ __volatile__ (
   25.39 +            "sync\n"
   25.40 +            "mtspr %0, %1\n"
   25.41 +            "isync\n"
   25.42 +            : : "i"(SPRN_HIOR), "r"(val));
   25.43 +}
   25.44 +
   25.45  #endif /* __ASSEMBLY__ */
   25.46  #endif
    26.1 --- a/xen/include/asm-powerpc/processor.h	Wed Aug 30 22:36:18 2006 +0100
    26.2 +++ b/xen/include/asm-powerpc/processor.h	Mon Sep 18 12:48:56 2006 -0500
    26.3 @@ -42,6 +42,7 @@ extern void show_execution_state(struct 
    26.4  extern void show_backtrace(ulong sp, ulong lr, ulong pc);
    26.5  extern unsigned int cpu_extent_order(void);
    26.6  extern unsigned int cpu_default_rma_order_pages(void);
    26.7 +extern int cpu_rma_valid(unsigned int log);
    26.8  extern uint cpu_large_page_orders(uint *sizes, uint max);
    26.9  extern void cpu_initialize(int cpuid);
   26.10  extern void cpu_init_vcpu(struct vcpu *);
   26.11 @@ -49,7 +50,11 @@ extern void save_cpu_sprs(struct vcpu *)
   26.12  extern void load_cpu_sprs(struct vcpu *);
   26.13  
   26.14  /* XXX this could also land us in GDB */
   26.15 -#define dump_execution_state() trap()
   26.16 +#define dump_execution_state() BUG()
   26.17 +
   26.18 +extern void __warn(char *file, int line);
   26.19 +#define WARN() __warn(__FILE__, __LINE__)
   26.20 +#define WARN_ON(_p) do { if (_p) WARN(); } while ( 0 )
   26.21  
   26.22  #define ARCH_HAS_PREFETCH
   26.23  static inline void prefetch(const void *x) {;}
    27.1 --- a/xen/include/asm-powerpc/reg_defs.h	Wed Aug 30 22:36:18 2006 +0100
    27.2 +++ b/xen/include/asm-powerpc/reg_defs.h	Mon Sep 18 12:48:56 2006 -0500
    27.3 @@ -154,6 +154,7 @@
    27.4  #define SPRN_HSPRG0 304
    27.5  #define SPRN_HSPRG1 305
    27.6  #define SPRN_HDEC   310
    27.7 +#define SPRN_HIOR   311
    27.8  #define SPRN_RMOR   312
    27.9  #define SPRN_HRMOR  313
   27.10  #define SPRN_HSRR0  314
    28.1 --- a/xen/include/asm-powerpc/shadow.h	Wed Aug 30 22:36:18 2006 +0100
    28.2 +++ b/xen/include/asm-powerpc/shadow.h	Mon Sep 18 12:48:56 2006 -0500
    28.3 @@ -26,22 +26,11 @@
    28.4  #define shadow_mode_translate(_d) (1)
    28.5  #define shadow_mode_refcounts(_d) (1)
    28.6  
    28.7 -#define __translate_gpfn_to_mfn(_d, gpfn)              \
    28.8 -    ( (shadow_mode_translate(_d))                      \
    28.9 -      ? translate_gpfn_to_mfn(_d, gpfn)                \
   28.10 -      : (gpfn) )
   28.11 -
   28.12  #define __mfn_to_gpfn(_d, mfn)                         \
   28.13      ( (shadow_mode_translate(_d))                      \
   28.14        ? machine_to_phys_mapping[(mfn)]                 \
   28.15        : (mfn) )
   28.16  
   28.17 -static inline unsigned long
   28.18 -translate_gpfn_to_mfn(struct domain *rd, unsigned long gpfn)
   28.19 -{
   28.20 -    trap();
   28.21 -    return 0;
   28.22 -}
   28.23  extern void guest_physmap_add_page(
   28.24      struct domain *d, unsigned long gpfn, unsigned long mfn);
   28.25  
   28.26 @@ -64,7 +53,7 @@ extern unsigned int shadow_teardown(stru
   28.27  extern unsigned int shadow_set_allocation(
   28.28      struct domain *d, unsigned int megabytes, int *preempted);
   28.29  
   28.30 -/* Return the size of the shadow pool, rounded up to the nearest MB */
   28.31 +/* Return the size of the shadow2 pool, rounded up to the nearest MB */
   28.32  static inline unsigned int shadow_get_allocation(struct domain *d)
   28.33  {
   28.34      return (1ULL << (d->arch.htab.order + PAGE_SHIFT)) >> 20;
    29.1 --- a/xen/include/asm-powerpc/smp.h	Wed Aug 30 22:36:18 2006 +0100
    29.2 +++ b/xen/include/asm-powerpc/smp.h	Mon Sep 18 12:48:56 2006 -0500
    29.3 @@ -27,7 +27,7 @@
    29.4  extern int smp_num_siblings;
    29.5  
    29.6  /* revisit when we support SMP */
    29.7 -#define get_hard_smp_processor_id(i) i
    29.8 +#define get_hard_smp_processor_id(i) (global_cpu_table[i]->whoami)
    29.9  #define raw_smp_processor_id() (parea->whoami)
   29.10  #define hard_smp_processor_id() raw_smp_processor_id()
   29.11  extern cpumask_t cpu_sibling_map[];
    30.1 --- a/xen/include/asm-powerpc/system.h	Wed Aug 30 22:36:18 2006 +0100
    30.2 +++ b/xen/include/asm-powerpc/system.h	Mon Sep 18 12:48:56 2006 -0500
    30.3 @@ -22,10 +22,10 @@
    30.4  #define _ASM_SYSTEM_H_
    30.5  
    30.6  #include <xen/config.h>
    30.7 +#include <xen/lib.h>
    30.8  #include <asm/memory.h>
    30.9  #include <asm/time.h>
   30.10  #include <asm/processor.h>
   30.11 -#include <asm/misc.h>
   30.12  #include <asm/msr.h>
   30.13  
   30.14  #define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
   30.15 @@ -139,7 +139,7 @@ static always_inline unsigned long
   30.16  {
   30.17      switch (size) {
   30.18      case 2:
   30.19 -        trap(); return 0; /* XXX implement __cmpxchg_u16 ? */
   30.20 +        BUG(); return 0; /* XXX implement __cmpxchg_u16 ? */
   30.21      case 4:
   30.22          return __cmpxchg_u32(ptr, old, new);
   30.23      case 8: