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

Re: [Xen-devel] [PATCH 1 of 8] tools: libxc: allow HVM firmware to be lo

To: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 1 of 8] tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment
From: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Date: Fri, 13 May 2011 15:29:06 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 13 May 2011 07:29:44 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20110513140305.GD6042@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <patchbomb.1305294149@xxxxxxxxxxxxxxxxxxxxxxxxx> <c5c7ae5f33b16ee03535.1305294150@xxxxxxxxxxxxxxxxxxxxxxxxx> <20110513140305.GD6042@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Fri, 2011-05-13 at 15:03 +0100, Konrad Rzeszutek Wilk wrote:
> On Fri, May 13, 2011 at 02:42:30PM +0100, Ian Campbell wrote:
> > # HG changeset patch
> > # User Ian Campbell <ian.campbell@xxxxxxxxxx>
> > # Date 1305294079 -3600
> > # Node ID c5c7ae5f33b16ee03535e9c688ad9bee2510b2b6
> > # Parent  9476bc07db2c654b266ab1f1c9ff0c65f401d74d
> > tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment
> > 
> > Enables direct loading of e.g. seabios.elf.
> > 
> > Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
> > 
> > diff -r 9476bc07db2c -r c5c7ae5f33b1 tools/libxc/xc_hvm_build.c
> > --- a/tools/libxc/xc_hvm_build.c    Fri May 13 14:41:19 2011 +0100
> > +++ b/tools/libxc/xc_hvm_build.c    Fri May 13 14:41:19 2011 +0100
> > @@ -88,7 +88,9 @@ static int loadelfimage(
> >      struct elf_binary *elf, uint32_t dom, unsigned long *parray)
> >  {
> >      privcmd_mmap_entry_t *entries = NULL;
> > -    size_t pages = (elf->pend - elf->pstart + PAGE_SIZE - 1) >> PAGE_SHIFT;
> > +    unsigned long pfn_start = elf->pstart >> PAGE_SHIFT;
> > +    unsigned long pfn_end = (elf->pend + PAGE_SIZE - 1) >> PAGE_SHIFT;
> > +    size_t pages = pfn_end - pfn_start;
> >      int i, rc = -1;
> >  
> >      /* Map address space for initial elf image. */
> > @@ -105,6 +107,8 @@ static int loadelfimage(
> >      if ( elf->dest == NULL )
> >          goto err;
> >  
> > +    elf->dest += elf->pstart & 4095;
> 
> Whoa. Decimal numbers! Threw me off when I saw this - so used to 0xfff. :-)

Oops, I switch to the symbolic names for everything else but missed that
one. Should be (PAGE_SIZE - 1).

Updated version below.

8<---------------------------------------------------------------

# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1305296917 -3600
# Node ID 07b02c79fc9c71ff3c8a966ad78cd8aa94210df5
# Parent  9476bc07db2c654b266ab1f1c9ff0c65f401d74d
tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment

Enables direct loading of e.g. seabios.elf.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 9476bc07db2c -r 07b02c79fc9c tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c        Fri May 13 14:41:19 2011 +0100
+++ b/tools/libxc/xc_hvm_build.c        Fri May 13 15:28:37 2011 +0100
@@ -88,7 +88,9 @@ static int loadelfimage(
     struct elf_binary *elf, uint32_t dom, unsigned long *parray)
 {
     privcmd_mmap_entry_t *entries = NULL;
-    size_t pages = (elf->pend - elf->pstart + PAGE_SIZE - 1) >> PAGE_SHIFT;
+    unsigned long pfn_start = elf->pstart >> PAGE_SHIFT;
+    unsigned long pfn_end = (elf->pend + PAGE_SIZE - 1) >> PAGE_SHIFT;
+    size_t pages = pfn_end - pfn_start;
     int i, rc = -1;
 
     /* Map address space for initial elf image. */
@@ -105,6 +107,8 @@ static int loadelfimage(
     if ( elf->dest == NULL )
         goto err;
 
+    elf->dest += elf->pstart & (PAGE_SIZE - 1);
+
     /* Load the initial elf image. */
     elf_load_binary(elf);
     rc = 0;
@@ -169,12 +173,6 @@ static int setup_guest(xc_interface *xch
         goto error_out;
     }
 
-    if ( (elf.pstart & (PAGE_SIZE - 1)) != 0 )
-    {
-        PERROR("Guest OS must load to a page boundary.");
-        goto error_out;
-    }
-
     IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n"
             "  Loader:        %016"PRIx64"->%016"PRIx64"\n"
             "  TOTAL:         %016"PRIx64"->%016"PRIx64"\n"



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