WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [LIBXC][POWERPC] Use new domain builder.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [LIBXC][POWERPC] Use new domain builder.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Mar 2007 08:00:45 -0700
Delivery-date: Thu, 22 Mar 2007 08:01:06 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Hollis Blanchard <hollisb@xxxxxxxxxx>
# Date 1174514580 18000
# Node ID 2c087916aaba101c3fbdc1c67c95f28065cf4709
# Parent  265e257388b52929e9e2bc62f9cf0818aac94e67
[LIBXC][POWERPC] Use new domain builder.
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
---
 tools/libxc/powerpc64/utils.c          |  188 ------------------
 tools/libxc/powerpc64/utils.h          |   37 ---
 tools/libxc/powerpc64/xc_linux_build.c |  336 ---------------------------------
 tools/libxc/Makefile                   |    6 
 tools/libxc/powerpc64/Makefile         |    2 
 tools/libxc/powerpc64/mk_flatdevtree.c |   58 ++---
 tools/libxc/powerpc64/mk_flatdevtree.h |   14 -
 tools/libxc/xc_dom.h                   |    2 
 tools/libxc/xc_dom_compat_linux.c      |   11 -
 tools/libxc/xc_dom_powerpc.c           |  236 +++++++++++++++++++++++
 10 files changed, 277 insertions(+), 613 deletions(-)

diff -r 265e257388b5 -r 2c087916aaba tools/libxc/Makefile
--- a/tools/libxc/Makefile      Wed Mar 21 17:03:00 2007 -0500
+++ b/tools/libxc/Makefile      Wed Mar 21 17:03:00 2007 -0500
@@ -48,9 +48,11 @@ GUEST_SRCS-y += xc_dom_core.c xc_dom_boo
 GUEST_SRCS-y += xc_dom_core.c xc_dom_boot.c
 GUEST_SRCS-y += xc_dom_elfloader.c
 GUEST_SRCS-y += xc_dom_binloader.c
+GUEST_SRCS-y += xc_dom_compat_linux.c
 
-GUEST_SRCS-$(CONFIG_X86)     += xc_dom_x86.c xc_dom_compat_linux.c
-GUEST_SRCS-$(CONFIG_IA64)    += xc_dom_ia64.c xc_dom_compat_linux.c
+GUEST_SRCS-$(CONFIG_X86)     += xc_dom_x86.c
+GUEST_SRCS-$(CONFIG_IA64)    += xc_dom_ia64.c
+GUEST_SRCS-$(CONFIG_POWERPC) += xc_dom_powerpc.c
 
 -include $(XEN_TARGET_ARCH)/Makefile
 
diff -r 265e257388b5 -r 2c087916aaba tools/libxc/powerpc64/Makefile
--- a/tools/libxc/powerpc64/Makefile    Wed Mar 21 17:03:00 2007 -0500
+++ b/tools/libxc/powerpc64/Makefile    Wed Mar 21 17:03:00 2007 -0500
@@ -1,6 +1,4 @@ GUEST_SRCS-y += powerpc64/flatdevtree.c
 GUEST_SRCS-y += powerpc64/flatdevtree.c
 GUEST_SRCS-y += powerpc64/mk_flatdevtree.c
-GUEST_SRCS-y += powerpc64/xc_linux_build.c
-GUEST_SRCS-y += powerpc64/utils.c
 
 CTRL_SRCS-y += powerpc64/xc_memory.c
diff -r 265e257388b5 -r 2c087916aaba tools/libxc/powerpc64/mk_flatdevtree.c
--- a/tools/libxc/powerpc64/mk_flatdevtree.c    Wed Mar 21 17:03:00 2007 -0500
+++ b/tools/libxc/powerpc64/mk_flatdevtree.c    Wed Mar 21 17:03:00 2007 -0500
@@ -34,6 +34,7 @@
 #include <sys/param.h>
 
 #include <xc_private.h> /* for PERROR() */
+#include <xc_dom.h>
 
 #include "mk_flatdevtree.h"
 
@@ -310,24 +311,19 @@ void free_devtree(struct ft_cxt *root)
 }
 
 int make_devtree(struct ft_cxt *root,
-                 uint32_t domid, 
-                 uint32_t mem_mb,
-                 unsigned long rma_bytes,
-                 unsigned long shadow_mb,
-                 unsigned long initrd_base,
-                 unsigned long initrd_len,
-                 const char *bootargs,
-                 uint64_t shared_info_paddr,
-                 unsigned long console_evtchn,
-                 uint64_t console_paddr,
-                 unsigned long store_evtchn,
-                 uint64_t store_paddr)
+                 struct xc_dom_image *dom,
+                 unsigned long shadow_mb)
 {
     struct boot_param_header *bph = NULL;
     uint64_t val[2];
     uint32_t val32[2];
-    unsigned long remaining;
-    unsigned long initrd_end = initrd_base + initrd_len;
+    uint64_t shared_info_paddr = dom->shared_info_pfn << PAGE_SHIFT;
+    uint64_t xenstore_paddr = dom->xenstore_pfn << PAGE_SHIFT;
+    uint64_t console_paddr = dom->console_pfn << PAGE_SHIFT;
+    long remaining;
+    unsigned long ramdisk_start;
+    unsigned long ramdisk_size;
+    unsigned long rma_bytes = 1 << dom->realmodearea_log;
     int64_t shadow_mb_log;
     uint64_t pft_size;
     char cpupath[MAX_PATH];
@@ -370,16 +366,18 @@ int make_devtree(struct ft_cxt *root,
     }
 
     /* reserve xen store page for domU */
-    if (store_paddr) {
-        val[0] = cpu_to_be64((u64) store_paddr);
+    if (xenstore_paddr) {
+        val[0] = cpu_to_be64((u64) xenstore_paddr);
         val[1] = cpu_to_be64((u64) PAGE_SIZE);
         ft_add_rsvmap(root, val[0], val[1]);
     }
 
     /* reserve space for initrd if needed */
-    if ( initrd_len > 0 )  {
-        val[0] = cpu_to_be64((u64) initrd_base);
-        val[1] = cpu_to_be64((u64) initrd_len);
+    ramdisk_start = dom->ramdisk_seg.pfn << PAGE_SHIFT;
+    ramdisk_size = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart;
+    if (ramdisk_size > 0) {
+        val[0] = cpu_to_be64((u64) ramdisk_start);
+        val[1] = cpu_to_be64((u64) ramdisk_size);
         ft_add_rsvmap(root, val[0], val[1]);
     }
 
@@ -422,13 +420,13 @@ int make_devtree(struct ft_cxt *root,
     ft_prop_int(root, "interrupt-controller", xen_phandle);
 
     /* chosen.addprop('bootargs', imghandler.cmdline + '\0') */
-    if ( bootargs != NULL )
-        ft_prop_str(root, "bootargs", bootargs);
+    if (dom->cmdline != NULL)
+        ft_prop_str(root, "bootargs", dom->cmdline);
 
     /* mark where the initrd is, if present */
-    if ( initrd_len > 0 ) {
-        val[0] = cpu_to_be64((u64) initrd_base);
-        val[1] = cpu_to_be64((u64) initrd_end);
+    if (ramdisk_size > 0) {
+        val[0] = cpu_to_be64((u64) ramdisk_start);
+        val[1] = cpu_to_be64((u64) ramdisk_start + ramdisk_size);
         ft_prop(root, "linux,initrd-start", &(val[0]), sizeof(val[0]));
         ft_prop(root, "linux,initrd-end", &(val[1]), sizeof(val[1]));
     }
@@ -443,7 +441,7 @@ int make_devtree(struct ft_cxt *root,
     ft_prop_str(root, "compatible", "Xen-3.0-unstable");
 
     /* xen.addprop('reg', long(imghandler.vm.domid), long(0)) */
-    val[0] = cpu_to_be64((u64) domid);
+    val[0] = cpu_to_be64((u64) dom->guest_domid);
     val[1] = cpu_to_be64((u64) 0);
     ft_prop(root, "reg", val, sizeof(val));
 
@@ -469,7 +467,7 @@ int make_devtree(struct ft_cxt *root,
         ft_prop(root, "reg", val, sizeof(val));
 
         /* xencons.addprop('interrupts', console_evtchn, 0) */
-        val32[0] = cpu_to_be32((u32) console_evtchn);
+        val32[0] = cpu_to_be32((u32) dom->console_evtchn);
         val32[1] = cpu_to_be32((u32) 0);
         ft_prop(root, "interrupts", val32, sizeof(val32));
 
@@ -477,17 +475,17 @@ int make_devtree(struct ft_cxt *root,
         ft_end_node(root);
     }
 
-    if (store_paddr != 0) {
+    if (xenstore_paddr != 0) {
         /* start store node */
         ft_begin_node(root, "store");
 
         /* store paddr */
-        val[0] = cpu_to_be64((u64) store_paddr);
+        val[0] = cpu_to_be64((u64) xenstore_paddr);
         val[1] = cpu_to_be64((u64) PAGE_SIZE);
         ft_prop(root, "reg", val, sizeof(val));
 
         /* store event channel */
-        val32[0] = cpu_to_be32((u32) store_evtchn);
+        val32[0] = cpu_to_be32((u32) dom->xenstore_evtchn);
         val32[1] = cpu_to_be32((u32) 0);
         ft_prop(root, "interrupts", val32, sizeof(val32));
 
@@ -516,7 +514,7 @@ int make_devtree(struct ft_cxt *root,
     ft_end_node(root);
 
     /* calculate remaining bytes from total - rma size */
-    remaining = (mem_mb * 1024 * 1024) - rma_bytes;
+    remaining = (dom->total_pages << PAGE_SHIFT) - rma_bytes;
 
     /* memory@<rma_bytes> is all remaining memory after RMA */
     if (remaining > 0)
diff -r 265e257388b5 -r 2c087916aaba tools/libxc/powerpc64/mk_flatdevtree.h
--- a/tools/libxc/powerpc64/mk_flatdevtree.h    Wed Mar 21 17:03:00 2007 -0500
+++ b/tools/libxc/powerpc64/mk_flatdevtree.h    Wed Mar 21 17:03:00 2007 -0500
@@ -26,18 +26,8 @@
 
 extern void free_devtree(struct ft_cxt *root);
 extern int make_devtree(struct ft_cxt *root,
-                        uint32_t domid, 
-                        uint32_t mem_mb,
-                        unsigned long rma_bytes,
-                        unsigned long shadow_mb,
-                        unsigned long initrd_base,
-                        unsigned long initrd_len,
-                        const char *bootargs,
-                        uint64_t shared_info_paddr,
-                        unsigned long console_evtchn,
-                        uint64_t console_paddr,
-                        unsigned long store_evtchn,
-                        uint64_t store_paddr);
+                        struct xc_dom_image *dom,
+                        unsigned long shadow_mb);
 
 #define MAX_PATH 200
 #define BUFSIZE 1024
diff -r 265e257388b5 -r 2c087916aaba tools/libxc/powerpc64/utils.c
--- a/tools/libxc/powerpc64/utils.c     Wed Mar 21 17:03:00 2007 -0500
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright IBM Corporation 2006, 2007
- *
- * Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
- *          Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
- */
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <inttypes.h>
-
-#include <xen/xen.h>
-#include <xen/memory.h>
-#include <xc_private.h>
-#include <xg_private.h>
-#include <xenctrl.h>
-
-#include "flatdevtree_env.h"
-#include "flatdevtree.h"
-#include "utils.h"
-
-int get_rma_page_array(int xc_handle, int domid, xen_pfn_t **page_array,
-                      unsigned long nr_pages)
-{
-    int rc;
-    int i;
-    xen_pfn_t *p;
-
-    *page_array = malloc(nr_pages * sizeof(xen_pfn_t));
-    if (*page_array == NULL) {
-        perror("malloc");
-        return -1;
-    }
-
-    DPRINTF("xc_get_pfn_list\n");
-    /* We know that the RMA is machine contiguous so lets just get the
-     * first MFN and fill the rest in ourselves */
-    rc = xc_get_pfn_list(xc_handle, domid, (uint64_t *)*page_array, 1);
-    if (rc == -1) {
-        perror("Could not get the page frame list");
-        return -1;
-    }
-    p = *page_array;
-    for (i = 1; i < nr_pages; i++)
-        p[i] = p[i - 1] + 1;
-    return 0;
-}
-
-int install_image(
-        int xc_handle,
-        int domid,
-        xen_pfn_t *page_array,
-        void *image,
-        unsigned long paddr,
-        unsigned long size)
-{
-    uint8_t *img = image;
-    int i;
-    int rc = 0;
-
-    if (paddr & ~PAGE_MASK) {
-        printf("*** unaligned address\n");
-        return -1;
-    }
-
-    for (i = 0; i < size; i += PAGE_SIZE) {
-        void *page = img + i;
-        xen_pfn_t pfn = (paddr + i) >> PAGE_SHIFT;
-        xen_pfn_t mfn = page_array[pfn];
-
-        rc = xc_copy_to_domain_page(xc_handle, domid, mfn, page);
-        if (rc < 0) {
-            perror("xc_copy_to_domain_page");
-            break;
-        }
-    }
-    return rc;
-}
-
-void *load_file(const char *path, unsigned long *filesize)
-{
-    void *img;
-    ssize_t size;
-    int fd;
-
-    DPRINTF("load_file(%s)\n", path);
-
-    fd = open(path, O_RDONLY);
-    if (fd < 0) {
-        perror(path);
-        return NULL;
-    }
-
-    size = lseek(fd, 0, SEEK_END);
-    if (size < 0) {
-        perror(path);
-        close(fd);
-        return NULL;
-    }
-    lseek(fd, 0, SEEK_SET);
-
-    img = malloc(size);
-    if (img == NULL) {
-        perror(path);
-        close(fd);
-        return NULL;
-    }
-
-    size = read(fd, img, size);
-    if (size <= 0) {
-        perror(path);
-        close(fd);
-        free(img);
-        return NULL;
-    }
-
-    if (filesize)
-        *filesize = size;
-    close(fd);
-    return img;
-}
-
-int load_elf_kernel(
-    int xc_handle,
-    int domid,
-    const char *kernel_path,
-    struct domain_setup_info *dsi,
-    xen_pfn_t *page_array)
-{
-    struct load_funcs load_funcs;
-    char *kernel_img;
-    unsigned long kernel_size;
-    int rc;
-
-    /* load the kernel ELF file */
-    kernel_img = load_file(kernel_path, &kernel_size);
-    if (kernel_img == NULL) {
-        rc = -1;
-        goto out;
-    }
-
-    DPRINTF("probe_elf\n");
-    rc = probe_elf(kernel_img, kernel_size, &load_funcs);
-    if (rc < 0) {
-        rc = -1;
-        printf("%s is not an ELF file\n", kernel_path);
-        goto out;
-    }
-
-    DPRINTF("parseimage\n");
-    rc = (load_funcs.parseimage)(kernel_img, kernel_size, dsi);
-    if (rc < 0) {
-        rc = -1;
-        goto out;
-    }
-
-    DPRINTF("loadimage\n");
-    (load_funcs.loadimage)(kernel_img, kernel_size, xc_handle, domid,
-            page_array, dsi);
-
-    DPRINTF("  v_start     %016"PRIx64"\n", dsi->v_start);
-    DPRINTF("  v_end       %016"PRIx64"\n", dsi->v_end);
-    DPRINTF("  v_kernstart %016"PRIx64"\n", dsi->v_kernstart);
-    DPRINTF("  v_kernend   %016"PRIx64"\n", dsi->v_kernend);
-    DPRINTF("  v_kernentry %016"PRIx64"\n", dsi->v_kernentry);
-
-out:
-    free(kernel_img);
-    return rc;
-}
diff -r 265e257388b5 -r 2c087916aaba tools/libxc/powerpc64/utils.h
--- a/tools/libxc/powerpc64/utils.h     Wed Mar 21 17:03:00 2007 -0500
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright IBM Corporation 2006, 2007
- *
- * Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
- *          Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
- */
-
-extern int get_rma_page_array(int xc_handle, int domid, xen_pfn_t **page_array,
-                             unsigned long nr_pages);
-extern int install_image(int xc_handle, int domid, xen_pfn_t *page_array,
-                        void *image, unsigned long paddr, unsigned long size);
-extern void *load_file(const char *path, unsigned long *filesize);
-extern int load_elf_kernel(int xc_handle, int domid,  const char *kernel_path,
-                          struct domain_setup_info *dsi,
-                          xen_pfn_t *page_array);
-
-#define ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1)))
-
-#define max(x,y) ({ \
-        const typeof(x) _x = (x);       \
-        const typeof(y) _y = (y);       \
-        (void) (&_x == &_y);            \
-        _x > _y ? _x : _y; })
diff -r 265e257388b5 -r 2c087916aaba tools/libxc/powerpc64/xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.c    Wed Mar 21 17:03:00 2007 -0500
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,336 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright IBM Corporation 2006, 2007
- *
- * Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
- *          Ryan Harper <ryanh@xxxxxxxxxx>
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <inttypes.h>
-
-#include <xen/xen.h>
-#include <xen/memory.h>
-#include <xc_private.h>
-#include <xg_private.h>
-#include <xenctrl.h>
-
-#include "flatdevtree_env.h"
-#include "flatdevtree.h"
-#include "utils.h"
-#include "mk_flatdevtree.h"
-
-/* Use 16MB extents to match PowerPC's large page size. */
-#define EXTENT_SHIFT 24
-#define EXTENT_ORDER (EXTENT_SHIFT - PAGE_SHIFT)
-
-#define INITRD_ADDR (24UL << 20)
-#define DEVTREE_ADDR (16UL << 20)
-
-static int init_boot_vcpu(
-    int xc_handle,
-    int domid,
-    struct domain_setup_info *dsi,
-    unsigned long devtree_addr,
-    unsigned long kern_addr)
-{
-    vcpu_guest_context_t ctxt;
-    int rc;
-
-    memset(&ctxt.user_regs, 0x55, sizeof(ctxt.user_regs));
-    ctxt.user_regs.pc = dsi->v_kernentry;
-    ctxt.user_regs.msr = 0;
-    ctxt.user_regs.gprs[1] = 0; /* Linux uses its own stack */
-    ctxt.user_regs.gprs[3] = devtree_addr;
-    ctxt.user_regs.gprs[4] = kern_addr;
-    ctxt.user_regs.gprs[5] = 0;
-    /* There is a buggy kernel that does not zero the "local_paca", so
-     * we must make sure this register is 0 */
-    ctxt.user_regs.gprs[13] = 0;
-
-    DPRINTF("xc_vcpu_setvcpucontext:\n"
-                 "  pc 0x%016"PRIx64", msr 0x%016"PRIx64"\n"
-                 "  r1-5 %016"PRIx64" %016"PRIx64" %016"PRIx64" %016"PRIx64
-                 " %016"PRIx64"\n",
-                 ctxt.user_regs.pc, ctxt.user_regs.msr,
-                 ctxt.user_regs.gprs[1],
-                 ctxt.user_regs.gprs[2],
-                 ctxt.user_regs.gprs[3],
-                 ctxt.user_regs.gprs[4],
-                 ctxt.user_regs.gprs[5]);
-    rc = xc_vcpu_setcontext(xc_handle, domid, 0, &ctxt);
-    if (rc < 0)
-        perror("setdomaininfo");
-
-    return rc;
-}
-
-static int load_initrd(
-    int xc_handle,
-    int domid,
-    xen_pfn_t *page_array,
-    const char *initrd_path,
-    unsigned long *base,
-    unsigned long *len)
-{
-    uint8_t *initrd_img;
-    int rc = -1;
-
-    /* load the initrd file */
-    initrd_img = load_file(initrd_path, len);
-    if (initrd_img == NULL)
-        return -1;
-
-    DPRINTF("copying initrd to 0x%lx[0x%lx]\n", INITRD_ADDR, *len);
-    if (install_image(xc_handle, domid, page_array, initrd_img, INITRD_ADDR,
-                *len))
-        goto out;
-
-    *base = INITRD_ADDR;
-    rc = 0;
-
-out:
-    free(initrd_img);
-    return rc;
-}
-
-static void free_page_array(xen_pfn_t *page_array)
-{
-    free(page_array);
-}
-
-static int check_memory_config(int rma_log, unsigned int mem_mb)
-{
-    u64 mem_kb = (mem_mb << 10);
-    u64 rma_kb = (1 << rma_log) >> 10;
-
-    switch(rma_log)
-    {
-        case 26:
-        case 27:
-        case 28:
-        case 30:
-        case 34:
-        case 38:
-            if (mem_kb < rma_kb) {
-                DPRINTF("Domain memory must be at least %dMB\n", 
-                        (1 << rma_log)>>20);
-                break;
-            }
-
-            if (mem_kb % (16 << 10)) {
-                DPRINTF("Domain memory %dMB must be a multiple of 16MB\n",
-                        mem_mb);
-                       
-                break;
-            }
-
-            /* rma_log and mem_mb OK */
-            return 0;
-
-        default:
-            DPRINTF("Invalid rma_log (%d)\n", rma_log);
-    }
-
-    return 1;
-}
-
-static int alloc_memory(int xc_handle, domid_t domid, ulong nr_pages,
-                        ulong rma_pages)
-{
-    xen_pfn_t *extent_pfn_arry;
-    ulong nr_extents;
-    ulong start_pfn = rma_pages;
-    int i;
-    int j;
-    int rc = 0;
-
-    nr_extents = (nr_pages - rma_pages) >> EXTENT_ORDER;
-    DPRINTF("allocating memory in %lu chunks of %luMB\n", nr_extents,
-            1UL >> (20 - EXTENT_ORDER));
-
-    /* populate_physmap requires an array of PFNs that determine where the
-     * guest mapping of the new MFNs. */
-    extent_pfn_arry = malloc((1<<EXTENT_ORDER) * sizeof(xen_pfn_t));
-    if (extent_pfn_arry == NULL) {
-        PERROR("Couldn't allocate extent PFN array.\n");
-        return -ENOMEM;
-    }
-
-    /* Now allocate the remaining memory as large-order extents. */
-    for (i = 0; i < nr_extents; i++) {
-        /* Initialize the extent PFN array. */
-        for (j = 0; j < (1 << EXTENT_ORDER); j++)
-            extent_pfn_arry[j] = start_pfn++;
-
-        DPRINTF("populate_physmap(Dom%u, order %u, starting_pfn %llx)\n",
-                domid, EXTENT_ORDER, extent_pfn_arry[0]);
-
-        if (xc_domain_memory_populate_physmap(xc_handle, domid, 1, 
EXTENT_ORDER,
-                                               0, extent_pfn_arry))
-        {
-            PERROR("Could not allocate extents\n");
-            rc = -1;
-            break;
-        }
-    }
-
-    free(extent_pfn_arry);
-    return rc;
-}
-
-int xc_linux_build(int xc_handle,
-                   uint32_t domid,
-                   unsigned int mem_mb,
-                   const char *image_name,
-                   const char *initrd_name,
-                   const char *cmdline,
-                   const char *features,
-                   unsigned long flags,
-                   unsigned int store_evtchn,
-                   unsigned long *store_mfn,
-                   unsigned int console_evtchn,
-                   unsigned long *console_mfn)
-{
-    struct domain_setup_info dsi;
-    xen_pfn_t *page_array = NULL;
-    unsigned long nr_pages;
-    unsigned long devtree_addr = 0;
-    unsigned long kern_addr;
-    unsigned long initrd_base = 0;
-    unsigned long initrd_len = 0;
-    unsigned long rma_pages;
-    unsigned long shadow_mb;
-    u64 shared_info_paddr;
-    u64 store_paddr;
-    u64 console_paddr;
-    int rma_log = 26;  /* 64MB RMA */
-    int rc = 0;
-    int op;
-    struct ft_cxt devtree;
-
-    DPRINTF("%s\n", __func__);
-
-    nr_pages = mem_mb << (20 - PAGE_SHIFT);
-    DPRINTF("nr_pages 0x%lx\n", nr_pages);
-
-    rma_pages = (1 << rma_log) >> PAGE_SHIFT;
-    if (rma_pages == 0) {
-        rc = -1;
-        goto out;
-    }
-
-    /* validate rma_log and domain memory config */
-    if (check_memory_config(rma_log, mem_mb)) {
-        rc = -1;
-        goto out;
-    }
-    
-    /* Allocate the RMA. */
-    DPRINTF("RMA: 0x%lx pages\n", rma_pages);
-    if (xc_alloc_real_mode_area(xc_handle, domid, rma_log)) {
-        rc = -1;
-        goto out;
-    }
-
-    /* Get the MFN mapping (for RMA only -- we only load data into the RMA). */
-    if (get_rma_page_array(xc_handle, domid, &page_array, rma_pages)) {
-        rc = -1;
-        goto out;
-    }
-
-    /* Allocate the non-RMA memory. */
-    rc = alloc_memory(xc_handle, domid, nr_pages, rma_pages);
-    if (rc) {
-        goto out;
-    }
-
-    /* Load kernel. */
-    DPRINTF("loading image '%s'\n", image_name);
-    if (load_elf_kernel(xc_handle, domid, image_name, &dsi, page_array)) {
-        rc = -1;
-        goto out;
-    }
-    kern_addr = 0;
-
-    /* Load initrd. */
-    if (initrd_name && initrd_name[0] != '\0') {
-        DPRINTF("loading initrd '%s'\n", initrd_name);
-        if (load_initrd(xc_handle, domid, page_array, initrd_name,
-                &initrd_base, &initrd_len)) {
-            rc = -1;
-            goto out;
-        }
-    }
-
-    /* fetch the current shadow_memory value for this domain */
-    op = XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION;
-    if (xc_shadow_control(xc_handle, domid, op, NULL, 0, 
-                          &shadow_mb, 0, NULL) < 0) {
-        rc = -1;
-        goto out;
-    }
-
-    /* determine shared_info, console, and store paddr */
-    shared_info_paddr = (rma_pages << PAGE_SHIFT) - PAGE_SIZE;
-    console_paddr = shared_info_paddr - PAGE_SIZE;
-    store_paddr = console_paddr - PAGE_SIZE;
-
-    /* map paddrs to mfns */
-    *store_mfn = page_array[(xen_pfn_t)(store_paddr >> PAGE_SHIFT)];
-    *console_mfn = page_array[(xen_pfn_t)(console_paddr >> PAGE_SHIFT)];
-    DPRINTF("console_mfn->%08lx store_mfn->%08lx\n", *console_mfn,
-            *store_mfn);
-
-    /* build the devtree here */
-    DPRINTF("constructing devtree\n");
-    if (make_devtree(&devtree, domid, mem_mb, (rma_pages << PAGE_SHIFT),
-                     shadow_mb, initrd_base, initrd_len, cmdline, 
-                     shared_info_paddr, console_evtchn, console_paddr,
-                     store_evtchn, store_paddr) < 0) {
-        DPRINTF("failed to create flattened device tree\n");
-        rc = -1;
-        goto out;
-    }
-
-    devtree_addr = DEVTREE_ADDR;
-    DPRINTF("loading flattened device tree to 0x%lx[0x%x]\n",
-            devtree_addr, devtree.bph->totalsize);
-
-    if (install_image(xc_handle, domid, page_array, (void *)devtree.bph,
-                      devtree_addr, devtree.bph->totalsize)) {
-        DPRINTF("couldn't load flattened device tree.\n");
-        rc = -1;
-        goto out2;
-    }
-
-    if (init_boot_vcpu(xc_handle, domid, &dsi, devtree_addr, kern_addr)) {
-        rc = -1;
-        goto out2;
-    }
-
-out2:
-    free_devtree(&devtree);
-out:
-    free_page_array(page_array);
-    return rc;
-}
diff -r 265e257388b5 -r 2c087916aaba tools/libxc/xc_dom.h
--- a/tools/libxc/xc_dom.h      Wed Mar 21 17:03:00 2007 -0500
+++ b/tools/libxc/xc_dom.h      Wed Mar 21 17:03:00 2007 -0500
@@ -49,6 +49,7 @@ struct xc_dom_image {
     struct xc_dom_seg ramdisk_seg;
     struct xc_dom_seg p2m_seg;
     struct xc_dom_seg pgtables_seg;
+    struct xc_dom_seg devicetree_seg;
     xen_pfn_t start_info_pfn;
     xen_pfn_t console_pfn;
     xen_pfn_t xenstore_pfn;
@@ -75,6 +76,7 @@ struct xc_dom_image {
     /* physical memory */
     xen_pfn_t total_pages;
     struct xc_dom_phys *phys_pages;
+    int realmodearea_log;
 
     /* malloc memory pool */
     struct xc_dom_mem *memblocks;
diff -r 265e257388b5 -r 2c087916aaba tools/libxc/xc_dom_compat_linux.c
--- a/tools/libxc/xc_dom_compat_linux.c Wed Mar 21 17:03:00 2007 -0500
+++ b/tools/libxc/xc_dom_compat_linux.c Wed Mar 21 17:03:00 2007 -0500
@@ -32,6 +32,10 @@ static int xc_linux_build_internal(struc
 {
     int rc;
 
+    dom->flags = flags;
+    dom->console_evtchn = console_evtchn;
+    dom->xenstore_evtchn = store_evtchn;
+
     if ( (rc = xc_dom_boot_xen_init(dom, xc_handle, domid)) != 0 )
         goto out;
     if ( (rc = xc_dom_parse_image(dom)) != 0 )
@@ -42,12 +46,7 @@ static int xc_linux_build_internal(struc
         goto out;
     if ( (rc = xc_dom_build_image(dom)) != 0 )
         goto out;
-
-    dom->flags = flags;
-    dom->console_evtchn = console_evtchn;
-    dom->xenstore_evtchn = store_evtchn;
-    rc = xc_dom_boot_image(dom);
-    if ( rc != 0 )
+    if ( (rc = xc_dom_boot_image(dom)) != 0 )
         goto out;
 
     *console_mfn = xc_dom_p2m_host(dom, dom->console_pfn);
diff -r 265e257388b5 -r 2c087916aaba tools/libxc/xc_dom_powerpc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxc/xc_dom_powerpc.c      Wed Mar 21 17:03:00 2007 -0500
@@ -0,0 +1,236 @@
+/*
+ * Xen domain builder -- powerpc bits.
+ *
+ * Most architecture-specific code for powerpc goes here.
+ *
+ * This code is licenced under the GPL.
+ * written 2006 by Gerd Hoffmann <kraxel@xxxxxxx>.
+ *
+ * Copyright IBM Corp. 2007
+ *
+ * Authors: Gerd Hoffmann <kraxel@xxxxxxx>
+ *          Hollis Blanchard <hollisb@xxxxxxxxxx>
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include <xen/xen.h>
+
+#include "xg_private.h"
+#include "xc_dom.h"
+#include "powerpc64/flatdevtree.h"
+#include "powerpc64/mk_flatdevtree.h"
+
+#define RMA_LOG 26 /* 64 MB */
+#define EXTENT_LOG 24 /* 16 MB */
+#define EXTENT_ORDER (EXTENT_LOG - PAGE_SHIFT)
+
+/* ------------------------------------------------------------------------ */
+
+static int alloc_magic_pages(struct xc_dom_image *dom)
+{
+    struct ft_cxt devtree;
+    void *guest_devtree;
+    unsigned long shadow_mb;
+    int rma_pages;
+    int rc;
+
+    /* Allocate special pages from the end of the RMA. */
+    rma_pages = 1 << (dom->realmodearea_log - PAGE_SHIFT);
+    dom->shared_info_pfn = --rma_pages;
+    dom->console_pfn = --rma_pages;
+    dom->xenstore_pfn = --rma_pages;
+
+    /* Gather shadow allocation info for the device tree. */
+    rc = xc_shadow_control(dom->guest_xc, dom->guest_domid,
+                           XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION, NULL, 0, 
+                           &shadow_mb, 0, NULL);
+    if (rc < 0 || shadow_mb == 0) {
+        xc_dom_printf("Couldn't get shadow allocation size or it was 0.\n");
+        return rc;
+    }
+
+    /* Build device tree. */
+    rc = make_devtree(&devtree, dom, shadow_mb);
+    if (rc < 0) {
+        xc_dom_printf("Failed to create flattened device tree.\n");
+        return rc;
+    }
+
+    /* Find a spot for it. */
+    rc = xc_dom_alloc_segment(dom, &dom->devicetree_seg, "devtree", 0,
+                              devtree.bph->totalsize);
+    if (rc)
+        goto out;
+
+    /* Copy the device tree into place. */
+    guest_devtree = xc_dom_seg_to_ptr(dom, &dom->devicetree_seg);
+    if (!guest_devtree) {
+        xc_dom_printf("Couldn't map guest memory for device tree.\n");
+        rc = -1;
+        goto out;
+    }
+    memcpy(guest_devtree, devtree.bph, devtree.bph->totalsize);
+
+out:
+    free_devtree(&devtree);
+    return rc;
+}
+
+static int shared_info(struct xc_dom_image *dom, void *ptr)
+{
+    shared_info_t *shared_info = ptr;
+
+    xc_dom_printf("%s: called\n", __FUNCTION__);
+
+    memset(shared_info, 0, sizeof(*shared_info));
+    return 0;
+}
+
+static int vcpu(struct xc_dom_image *dom, void *ptr)
+{
+    vcpu_guest_context_t *ctxt = ptr;
+
+    memset(ctxt, 0x55, sizeof(*ctxt));
+    ctxt->user_regs.pc = dom->parms.virt_entry;
+    ctxt->user_regs.msr = 0;
+    ctxt->user_regs.gprs[1] = 0; /* Linux uses its own stack */
+    ctxt->user_regs.gprs[3] = dom->devicetree_seg.pfn << PAGE_SHIFT;
+    ctxt->user_regs.gprs[4] = dom->kernel_seg.pfn << PAGE_SHIFT;
+    ctxt->user_regs.gprs[5] = 0;
+
+    /* There is a buggy kernel that does not zero the "local_paca", so
+     * we must make sure this register is 0 */
+    ctxt->user_regs.gprs[13] = 0;
+
+    xc_dom_printf("%s: initial vcpu:\n", __FUNCTION__);
+    xc_dom_printf("  pc 0x%016"PRIx64", msr 0x%016"PRIx64"\n"
+                  "  r1-5 %016"PRIx64" %016"PRIx64" %016"PRIx64" %016"PRIx64
+                  " %016"PRIx64"\n",
+                  ctxt->user_regs.pc, ctxt->user_regs.msr,
+                  ctxt->user_regs.gprs[1],
+                  ctxt->user_regs.gprs[2],
+                  ctxt->user_regs.gprs[3],
+                  ctxt->user_regs.gprs[4],
+                  ctxt->user_regs.gprs[5]);
+
+    return 0;
+}
+
+/* ------------------------------------------------------------------------ */
+
+static struct xc_dom_arch xc_dom_arch = {
+    .guest_type = "xen-3.0-powerpc64",
+    .page_shift = PAGE_SHIFT,
+    .alloc_magic_pages = alloc_magic_pages,
+    .shared_info = shared_info,
+    .vcpu = vcpu,
+};
+
+static void __init register_arch_hooks(void)
+{
+    xc_dom_register_arch_hooks(&xc_dom_arch);
+}
+
+int arch_setup_meminit(struct xc_dom_image *dom)
+{
+    xen_pfn_t *extent_list;
+    unsigned long total_mem = dom->total_pages << PAGE_SHIFT;
+    unsigned long rma_bytes;
+    unsigned long rma_nr_pages;
+    unsigned long nr_extents;
+    int rc = 0;
+    int i;
+
+    /* XXX RMA size is processor-dependent. */
+    dom->realmodearea_log = RMA_LOG;
+    rma_bytes = 1 << dom->realmodearea_log;
+    rma_nr_pages = rma_bytes >> PAGE_SHIFT;
+
+    xc_dom_printf("dom%u memory: %lu MB RMA, %lu MB additional.\n",
+            dom->guest_domid, rma_bytes >> 20, (total_mem - rma_bytes) >> 20);
+
+    if (total_mem < rma_bytes) {
+        xc_dom_printf("Domain must have at least %lu MB\n", rma_bytes >> 20);
+        return -EINVAL;
+    }
+
+    /* Allocate the first chunk of memory. */
+    rc = xc_alloc_real_mode_area(dom->guest_xc, dom->guest_domid,
+                                 dom->realmodearea_log);
+    if (rc) {
+        xc_dom_printf("Failed to allocate real mode area.\n");
+        return rc;
+    }
+
+    /* Allocate p2m map. */
+    dom->p2m_host = xc_dom_malloc(dom, sizeof(xen_pfn_t) * dom->total_pages);
+    if (dom->p2m_host == NULL) {
+        xc_dom_printf("Couldn't allocate p2m map.\n");
+        return -ENOMEM;
+    }
+
+    nr_extents = (dom->total_pages - rma_nr_pages) >> EXTENT_ORDER;
+    if (nr_extents) {
+        /* Allocate extent list for populate_physmap() call. */
+        extent_list = xc_dom_malloc(dom, sizeof(xen_pfn_t) * nr_extents);
+        if (extent_list == NULL) {
+            xc_dom_printf("Couldn't allocate extent list.\n");
+            return -ENOMEM;
+        }
+
+        /* Allocate the remaining (non-RMA) memory. */
+        for (i = 0; i < nr_extents; i++) {
+            /* Use PFNs above the RMA memory we already allocated. */
+            extent_list[i] = rma_nr_pages + i * (1<<EXTENT_ORDER);
+        }
+        rc = xc_domain_memory_populate_physmap(dom->guest_xc, dom->guest_domid,
+                                               nr_extents, EXTENT_ORDER, 0,
+                                               extent_list);
+        if (rc < 0) {
+            xc_dom_printf("populate_physmap(0x%lx extents order %u) -> 0x%x\n",
+                          nr_extents, EXTENT_ORDER, rc);
+            return rc;
+        }
+    }
+
+    /* Populate the p2m map. */
+    rc = xc_get_pfn_list(dom->guest_xc, dom->guest_domid, dom->p2m_host,
+                         dom->total_pages);
+    if (rc < 0) {
+        xc_dom_printf("Couldn't get p2m translation.\n");
+        return rc;
+    }
+
+    xc_dom_printf("%s: success\n", __func__);
+
+    return 0;
+}
+
+int arch_setup_bootearly(struct xc_dom_image *dom)
+{
+    xc_dom_printf("%s: doing nothing\n", __FUNCTION__);
+    return 0;
+}
+
+int arch_setup_bootlate(struct xc_dom_image *dom)
+{
+    unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
+    shared_info_t *shared_info;
+
+    /* setup shared_info page */
+    xc_dom_printf("%s: shared_info: mfn 0x%" PRIpfn "\n",
+                  __FUNCTION__, dom->shared_info_mfn);
+    shared_info = xc_map_foreign_range(dom->guest_xc, dom->guest_domid,
+                                       page_size,
+                                       PROT_READ | PROT_WRITE,
+                                       dom->shared_info_mfn);
+    if ( shared_info == NULL )
+        return -1;
+    dom->arch_hooks->shared_info(dom, shared_info);
+    munmap(shared_info, page_size);
+    return 0;
+}

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [LIBXC][POWERPC] Use new domain builder., Xen patchbot-unstable <=