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-ia64-devel

[Xen-ia64-devel] [Patch]initrd support for DomainU

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [Patch]initrd support for DomainU
From: Akio Takebe <takebe_akio@xxxxxxxxxxxxxx>
Date: Mon, 19 Dec 2005 20:45:08 +0900
Delivery-date: Mon, 19 Dec 2005 11:48:36 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hi,

This is a patch to boot domU with initrd.
I confirmed domU could boot with initrd.

It is necessary for runninig xm-test that domU support initrd.

Please comment.

Best Regards,

Akio Takebe

Signed-off-by: Akio Takebe <takebe_akio@xxxxxxxxxxxxxx>

diff -r 7ef565a7cc86 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Thu Dec 15 23:17:06 2005
+++ b/tools/libxc/xc_linux_build.c      Mon Dec 19 19:28:12 2005
@@ -296,9 +296,13 @@
     unsigned long *page_array = NULL;
     struct load_funcs load_funcs;
     struct domain_setup_info dsi;
+    unsigned long vinitrd_start;
+    unsigned long vinitrd_end;
+    unsigned long v_end;
     unsigned long start_page, pgnr;
     start_info_t *start_info;
     int rc;
+    unsigned long i;
 
     rc = probeimageformat(image, image_size, &load_funcs);
     if ( rc != 0 )
@@ -310,11 +314,13 @@
     if ( rc != 0 )
         goto error_out;
 
-    dsi.v_start = round_pgdown(dsi.v_start);
-    dsi.v_end   = round_pgup(dsi.v_end);
+    dsi.v_start      = round_pgdown(dsi.v_start);
+    vinitrd_start    = round_pgup(dsi.v_end);
+    vinitrd_end      = vinitrd_start + initrd_len;
+    v_end            = round_pgup(vinitrd_end);
 
     start_page = dsi.v_start >> PAGE_SHIFT;
-    pgnr = (dsi.v_end - dsi.v_start) >> PAGE_SHIFT;
+    pgnr = (v_end - dsi.v_start) >> PAGE_SHIFT;
     if ( (page_array = malloc(pgnr * sizeof(unsigned long))) == NULL )
     {
         PERROR("Could not allocate memory");
@@ -326,9 +332,38 @@
         PERROR("Could not get the page frame list");
         goto error_out;
     }
+
+#define _p(a) ((void *) (a))
+
+    printf("VIRTUAL MEMORY ARRANGEMENT:\n"
+           " Loaded kernel: %p->%p\n"
+           " Init. ramdisk: %p->%p\n"
+           " TOTAL:         %p->%p\n",
+           _p(dsi.v_kernstart), _p(dsi.v_kernend), 
+           _p(vinitrd_start),   _p(vinitrd_end),
+           _p(dsi.v_start),     _p(v_end));
+    printf(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));
 
     (load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array,
                            &dsi);
+
+    /* Load the initial ramdisk image. */
+    if ( initrd_len != 0 )
+    {
+        for ( i = (vinitrd_start - dsi.v_start);
+              i < (vinitrd_end - dsi.v_start); i += PAGE_SIZE )
+        {
+            char page[PAGE_SIZE];
+            if ( gzread(initrd_gfd, page, PAGE_SIZE) == -1 )
+            {
+                PERROR("Error reading initrd image, could not");
+                goto error_out;
+            }
+            xc_copy_to_domain_page(xc_handle, dom,
+                                   page_array[i>>PAGE_SHIFT], page);
+        }
+    }
+
 
     *pvke = dsi.v_kernentry;
 
@@ -358,6 +393,11 @@
     start_info->store_evtchn = store_evtchn;
     start_info->console_mfn   = nr_pages - 1;
     start_info->console_evtchn = console_evtchn;
+    if ( initrd_len != 0 )
+    {
+        ctxt->initrd.start    = vinitrd_start;
+        ctxt->initrd.size     = initrd_len;
+    }
     munmap(start_info, PAGE_SIZE);
 
     free(page_array);
diff -r 7ef565a7cc86 xen/arch/ia64/xen/dom_fw.c
--- a/xen/arch/ia64/xen/dom_fw.c        Thu Dec 15 23:17:06 2005
+++ b/xen/arch/ia64/xen/dom_fw.c        Mon Dec 19 19:28:12 2005
@@ -842,9 +842,15 @@
        bp->console_info.orig_x = 0;
        bp->console_info.orig_y = 24;
        bp->fpswa = 0;
-        bp->initrd_start = (dom0_start+dom0_size) -
-                (PAGE_ALIGN(ia64_boot_param->initrd_size) + 4*1024*1024);
-        bp->initrd_size = ia64_boot_param->initrd_size;
+        if (d == dom0){
+                bp->initrd_start = (dom0_start+dom0_size) -
+                        (PAGE_ALIGN(ia64_boot_param->initrd_size) + 
4*1024*1024);
+                bp->initrd_size = ia64_boot_param->initrd_size;
+        }else{
+                bp->initrd_start = d->arch.initrd_start;
+                bp->initrd_size  = d->arch.initrd_len;
+
+       }
                 printf(" initrd start %0xlx", bp->initrd_start);
                 printf(" initrd size %0xlx", bp->initrd_size);
 
diff -r 7ef565a7cc86 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Thu Dec 15 23:17:06 2005
+++ b/xen/arch/ia64/xen/domain.c        Mon Dec 19 19:28:12 2005
@@ -297,6 +297,8 @@
 
        *regs = c->regs;
        d->arch.sys_pgnr = c->sys_pgnr;
+        d->arch.initrd_start = c->initrd.start;
+        d->arch.initrd_len   = c->initrd.size;
        new_thread(v, regs->cr_iip, 0, 0);
 
        v->vcpu_info->arch.evtchn_vector = c->vcpu.evtchn_vector;
diff -r 7ef565a7cc86 xen/include/asm-ia64/domain.h
--- a/xen/include/asm-ia64/domain.h     Thu Dec 15 23:17:06 2005
+++ b/xen/include/asm-ia64/domain.h     Mon Dec 19 19:28:12 2005
@@ -38,6 +38,8 @@
     u64 image_len;
     u64 entry;
 #endif
+    unsigned long initrd_start;
+    unsigned long initrd_len;
 };
 #define xen_vastart arch.xen_vastart
 #define xen_vaend arch.xen_vaend
diff -r 7ef565a7cc86 xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h    Thu Dec 15 23:17:06 2005
+++ b/xen/include/public/arch-ia64.h    Mon Dec 19 19:28:12 2005
@@ -276,6 +276,11 @@
     unsigned long start_info_pfn;
 } arch_shared_info_t;
 
+typedef struct {
+    unsigned long start;
+    unsigned long size; 
+} arch_initrd_info_t;
+
 typedef struct vcpu_guest_context {
 #define VGCF_FPU_VALID (1<<0)
 #define VGCF_VMX_GUEST (1<<1)
@@ -289,6 +294,7 @@
     cpu_user_regs_t regs;
     arch_vcpu_info_t vcpu;
     arch_shared_info_t shared;
+    arch_initrd_info_t initrd;
 } vcpu_guest_context_t;
 
 #endif /* !__ASSEMBLY__ */

Attachment: guest_initrd_support.patch
Description: Binary data

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>