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] calculate dom0 metaphysical load address correc

To: Alex Williamson <alex.williamson@xxxxxx>
Subject: [Xen-ia64-devel] [patch] calculate dom0 metaphysical load address correctly
From: Jes Sorensen <jes@xxxxxxx>
Date: Tue, 22 May 2007 14:55:41 +0200
Cc: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 22 May 2007 05:53:55 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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
User-agent: Thunderbird 1.5.0.4 (X11/20060527)
Hi,

This one is needed to handle system where metaphysical doesn't start
at 0x4000000.

Cheers,
Jes
# HG changeset patch
# User jes@xxxxxxxxxxxxxxxx
# Date 1179838406 -7200
# Node ID ce09d8e7f7334cda03f26e2493398f3cface8060
# Parent  44a59dc866263af3c33ade323d9fb5fb0451c8cd
Calculate load address of dom0 image based on xen_pstart rather than
address from ELF image as dom0 meta-physical memory must match real
physical window.

Signed-off-by: Jes Sorensen <jes@xxxxxxx>

diff -r 44a59dc86626 -r ce09d8e7f733 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Fri May 11 14:27:18 2007 +0200
+++ b/xen/arch/ia64/xen/domain.c        Tue May 22 14:53:26 2007 +0200
@@ -1109,7 +1109,8 @@ int shadow_mode_control(struct domain *d
 #define        privify_memory(x,y) do {} while(0)
 #endif
 
-static void loaddomainelfimage(struct domain *d, struct elf_binary *elf)
+static void loaddomainelfimage(struct domain *d, struct elf_binary *elf,
+                              unsigned long phys_load_offset)
 {
        const elf_phdr *phdr;
        int phnum, h, filesz, memsz;
@@ -1126,6 +1127,7 @@ static void loaddomainelfimage(struct do
                memsz = elf_uval(elf, phdr, p_memsz);
                elfaddr = (unsigned long) elf->image + elf_uval(elf, phdr, 
p_offset);
                dom_mpaddr = elf_uval(elf, phdr, p_paddr);
+               dom_mpaddr += phys_load_offset;
 
                while (memsz > 0) {
                        p = assign_new_domain_page(d,dom_mpaddr);
@@ -1216,6 +1218,7 @@ int construct_dom0(struct domain *d,
        unsigned long pkern_end;
        unsigned long pinitrd_start = 0;
        unsigned long pstart_info;
+       unsigned long phys_load_offset;
        struct page_info *start_info_page;
        unsigned long bp_mpa;
        struct ia64_boot_param *bp;
@@ -1243,6 +1246,20 @@ int construct_dom0(struct domain *d,
        if (0 != (elf_xen_parse(&elf, &parms)))
                return rc;
 
+       /*
+        * We cannot rely on the load address in the ELF headers to
+        * determine the meta physical address the image is loaded
+        * at since meta physical memory needs to match physical
+        * memory of the system for NUMA awareness. Patch the address
+        * to match the real one, based on xen_pstart
+        */
+       phys_load_offset = xen_pstart - elf.pstart;
+       elf.pstart += phys_load_offset;
+       elf.pend += phys_load_offset;
+       parms.virt_kstart += phys_load_offset;
+       parms.virt_kend += phys_load_offset;
+       parms.virt_entry += phys_load_offset;
+
        printk(" Dom0 kernel: %s, %s, paddr 0x%" PRIx64 " -> 0x%" PRIx64 "\n",
               elf_64bit(&elf) ? "64-bit" : "32-bit",
               elf_msb(&elf)   ? "msb"    : "lsb",
@@ -1273,8 +1290,10 @@ int construct_dom0(struct domain *d,
            /* The next page aligned boundary after the start info.
               Note: EFI_PAGE_SHIFT = 12 <= PAGE_SHIFT */
            pinitrd_start = pstart_info + PAGE_SIZE;
-           if (pinitrd_start + initrd_len >= dom0_size)
+
+           if ((pinitrd_start + initrd_len - phys_load_offset) >= dom0_size)
                    panic("%s: not enough memory assigned to dom0", __func__);
+
            for (offset = 0; offset < initrd_len; offset += PAGE_SIZE) {
                struct page_info *p;
                p = assign_new_domain_page(d, pinitrd_start + offset);
@@ -1327,7 +1346,7 @@ int construct_dom0(struct domain *d,
                panic("Cannot allocate dom0 vcpu %d\n", i);
 
        /* Copy the OS image. */
-       loaddomainelfimage(d,&elf);
+       loaddomainelfimage(d, &elf, phys_load_offset);
 
        BUILD_BUG_ON(sizeof(start_info_t) + sizeof(dom0_vga_console_info_t) +
                     sizeof(struct ia64_boot_param) > PAGE_SIZE);
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel