ia64/xen-unstable

changeset 10048:d0c7cc0afd15

Add support to domain builders for loading kernels with physical addresses in the elf paddr and entry fields.
Add a new __xen_guest header field to distinguish between kernels with
the previous use of the paddr field and the new use.
Add a new __xen_guest header field to control the kernel entry point,
since the elf header entry field now points to a physical address.
This header field is also useful for supporting alternative entry
points in kernel images which run both on xen and native.
Also add a kernel config option to control whether the resulting kernel
should include compatibility code to run on Xen 3.0.2 or whether such
code such be left out, resulting in a kernel which will only run on
newer Xen versions. Default to having compatibility enabled.
Kernels built with the new use of the elf header fields would otherwise
not work on Xen versions prior to this changeset.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Thu May 11 17:30:50 2006 +0100 (2006-05-11)
parents 891e0d1cf4ab
children 062d109ce872
files buildconfigs/linux-defconfig_xen0_x86_32 buildconfigs/linux-defconfig_xen0_x86_64 buildconfigs/linux-defconfig_xenU_x86_32 buildconfigs/linux-defconfig_xenU_x86_64 buildconfigs/linux-defconfig_xen_x86_32 buildconfigs/linux-defconfig_xen_x86_64 linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S linux-2.6-xen-sparse/drivers/xen/Kconfig linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h tools/libxc/xc_load_elf.c tools/libxc/xg_private.h xen/common/elf.c xen/include/xen/sched.h
line diff
     1.1 --- a/buildconfigs/linux-defconfig_xen0_x86_32	Thu May 11 15:51:56 2006 +0100
     1.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_32	Thu May 11 17:30:50 2006 +0100
     1.3 @@ -1,7 +1,7 @@
     1.4  #
     1.5  # Automatically generated make config: don't edit
     1.6 -# Linux kernel version: 2.6.16-xen0
     1.7 -# Sat Apr  8 11:34:07 2006
     1.8 +# Linux kernel version: 2.6.16.13-xen0
     1.9 +# Thu May 11 17:06:31 2006
    1.10  #
    1.11  CONFIG_X86_32=y
    1.12  CONFIG_SEMAPHORE_SLEEPERS=y
    1.13 @@ -1309,7 +1309,7 @@ CONFIG_CRYPTO_CRC32C=m
    1.14  #
    1.15  # CONFIG_CRYPTO_DEV_PADLOCK is not set
    1.16  CONFIG_XEN=y
    1.17 -CONFIG_XEN_INTERFACE_VERSION=0x00030101
    1.18 +CONFIG_XEN_INTERFACE_VERSION=0x00030202
    1.19  
    1.20  #
    1.21  # XEN
    1.22 @@ -1330,10 +1330,12 @@ CONFIG_XEN_NETDEV_LOOPBACK=y
    1.23  CONFIG_XEN_BLKDEV_FRONTEND=y
    1.24  CONFIG_XEN_NETDEV_FRONTEND=y
    1.25  # CONFIG_XEN_BLKDEV_TAP is not set
    1.26 -# CONFIG_XEN_TPMDEV_FRONTEND is not set
    1.27  CONFIG_XEN_SCRUB_PAGES=y
    1.28  CONFIG_XEN_DISABLE_SERIAL=y
    1.29  CONFIG_XEN_SYSFS=y
    1.30 +CONFIG_XEN_COMPAT_030002_AND_LATER=y
    1.31 +# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
    1.32 +CONFIG_XEN_COMPAT_030002=y
    1.33  CONFIG_HAVE_ARCH_ALLOC_SKB=y
    1.34  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    1.35  CONFIG_NO_IDLE_HZ=y
     2.1 --- a/buildconfigs/linux-defconfig_xen0_x86_64	Thu May 11 15:51:56 2006 +0100
     2.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_64	Thu May 11 17:30:50 2006 +0100
     2.3 @@ -1,7 +1,7 @@
     2.4  #
     2.5  # Automatically generated make config: don't edit
     2.6 -# Linux kernel version: 2.6.16-xen0
     2.7 -# Thu Apr 13 14:58:29 2006
     2.8 +# Linux kernel version: 2.6.16.13-xen0
     2.9 +# Thu May 11 17:17:19 2006
    2.10  #
    2.11  CONFIG_X86_64=y
    2.12  CONFIG_64BIT=y
    2.13 @@ -1250,7 +1250,7 @@ CONFIG_CRYPTO_CRC32C=m
    2.14  # Hardware crypto devices
    2.15  #
    2.16  CONFIG_XEN=y
    2.17 -CONFIG_XEN_INTERFACE_VERSION=0x00030101
    2.18 +CONFIG_XEN_INTERFACE_VERSION=0x00030202
    2.19  
    2.20  #
    2.21  # XEN
    2.22 @@ -1271,10 +1271,12 @@ CONFIG_XEN_NETDEV_LOOPBACK=y
    2.23  CONFIG_XEN_BLKDEV_FRONTEND=y
    2.24  CONFIG_XEN_NETDEV_FRONTEND=y
    2.25  # CONFIG_XEN_BLKDEV_TAP is not set
    2.26 -# CONFIG_XEN_TPMDEV_FRONTEND is not set
    2.27  CONFIG_XEN_SCRUB_PAGES=y
    2.28  CONFIG_XEN_DISABLE_SERIAL=y
    2.29  CONFIG_XEN_SYSFS=y
    2.30 +CONFIG_XEN_COMPAT_030002_AND_LATER=y
    2.31 +# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
    2.32 +CONFIG_XEN_COMPAT_030002=y
    2.33  CONFIG_HAVE_ARCH_ALLOC_SKB=y
    2.34  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    2.35  CONFIG_NO_IDLE_HZ=y
     3.1 --- a/buildconfigs/linux-defconfig_xenU_x86_32	Thu May 11 15:51:56 2006 +0100
     3.2 +++ b/buildconfigs/linux-defconfig_xenU_x86_32	Thu May 11 17:30:50 2006 +0100
     3.3 @@ -1,7 +1,7 @@
     3.4  #
     3.5  # Automatically generated make config: don't edit
     3.6 -# Linux kernel version: 2.6.16-rc3-xen0
     3.7 -# Thu Feb 16 22:53:43 2006
     3.8 +# Linux kernel version: 2.6.16.13-xenU
     3.9 +# Thu May 11 17:08:12 2006
    3.10  #
    3.11  CONFIG_X86_32=y
    3.12  CONFIG_SEMAPHORE_SLEEPERS=y
    3.13 @@ -617,11 +617,7 @@ CONFIG_DUMMY_CONSOLE=y
    3.14  #
    3.15  
    3.16  #
    3.17 -# SN Devices
    3.18 -#
    3.19 -
    3.20 -#
    3.21 -# EDAC - error detection and reporting (RAS)
    3.22 +# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
    3.23  #
    3.24  # CONFIG_EDAC is not set
    3.25  
    3.26 @@ -852,7 +848,7 @@ CONFIG_CRYPTO_CRC32C=m
    3.27  #
    3.28  # CONFIG_CRYPTO_DEV_PADLOCK is not set
    3.29  CONFIG_XEN=y
    3.30 -CONFIG_NO_IDLE_HZ=y
    3.31 +CONFIG_XEN_INTERFACE_VERSION=0x00030202
    3.32  
    3.33  #
    3.34  # XEN
    3.35 @@ -862,12 +858,15 @@ CONFIG_XEN_UNPRIVILEGED_GUEST=y
    3.36  # CONFIG_XEN_BACKEND is not set
    3.37  CONFIG_XEN_BLKDEV_FRONTEND=y
    3.38  CONFIG_XEN_NETDEV_FRONTEND=y
    3.39 -# CONFIG_XEN_TPMDEV_FRONTEND is not set
    3.40  CONFIG_XEN_SCRUB_PAGES=y
    3.41  CONFIG_XEN_DISABLE_SERIAL=y
    3.42  CONFIG_XEN_SYSFS=y
    3.43 +CONFIG_XEN_COMPAT_030002_AND_LATER=y
    3.44 +# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
    3.45 +CONFIG_XEN_COMPAT_030002=y
    3.46  CONFIG_HAVE_ARCH_ALLOC_SKB=y
    3.47  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    3.48 +CONFIG_NO_IDLE_HZ=y
    3.49  
    3.50  #
    3.51  # Library routines
    3.52 @@ -883,4 +882,6 @@ CONFIG_GENERIC_PENDING_IRQ=y
    3.53  CONFIG_X86_SMP=y
    3.54  CONFIG_X86_BIOS_REBOOT=y
    3.55  CONFIG_X86_TRAMPOLINE=y
    3.56 +CONFIG_X86_NO_TSS=y
    3.57 +CONFIG_X86_NO_IDT=y
    3.58  CONFIG_KTIME_SCALAR=y
     4.1 --- a/buildconfigs/linux-defconfig_xenU_x86_64	Thu May 11 15:51:56 2006 +0100
     4.2 +++ b/buildconfigs/linux-defconfig_xenU_x86_64	Thu May 11 17:30:50 2006 +0100
     4.3 @@ -1,7 +1,7 @@
     4.4  #
     4.5  # Automatically generated make config: don't edit
     4.6 -# Linux kernel version: 2.6.16-xenU
     4.7 -# Thu Apr 13 14:59:16 2006
     4.8 +# Linux kernel version: 2.6.16.13-xenU
     4.9 +# Thu May 11 17:17:57 2006
    4.10  #
    4.11  CONFIG_X86_64=y
    4.12  CONFIG_64BIT=y
    4.13 @@ -1135,7 +1135,7 @@ CONFIG_CRYPTO_CRC32C=m
    4.14  # Hardware crypto devices
    4.15  #
    4.16  CONFIG_XEN=y
    4.17 -CONFIG_XEN_INTERFACE_VERSION=0x00030101
    4.18 +CONFIG_XEN_INTERFACE_VERSION=0x00030202
    4.19  
    4.20  #
    4.21  # XEN
    4.22 @@ -1145,10 +1145,12 @@ CONFIG_XEN_UNPRIVILEGED_GUEST=y
    4.23  # CONFIG_XEN_BACKEND is not set
    4.24  CONFIG_XEN_BLKDEV_FRONTEND=y
    4.25  CONFIG_XEN_NETDEV_FRONTEND=y
    4.26 -# CONFIG_XEN_TPMDEV_FRONTEND is not set
    4.27  CONFIG_XEN_SCRUB_PAGES=y
    4.28  CONFIG_XEN_DISABLE_SERIAL=y
    4.29  CONFIG_XEN_SYSFS=y
    4.30 +CONFIG_XEN_COMPAT_030002_AND_LATER=y
    4.31 +# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
    4.32 +CONFIG_XEN_COMPAT_030002=y
    4.33  CONFIG_HAVE_ARCH_ALLOC_SKB=y
    4.34  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    4.35  CONFIG_NO_IDLE_HZ=y
     5.1 --- a/buildconfigs/linux-defconfig_xen_x86_32	Thu May 11 15:51:56 2006 +0100
     5.2 +++ b/buildconfigs/linux-defconfig_xen_x86_32	Thu May 11 17:30:50 2006 +0100
     5.3 @@ -1,7 +1,7 @@
     5.4  #
     5.5  # Automatically generated make config: don't edit
     5.6 -# Linux kernel version: 2.6.16-xen
     5.7 -# Thu Apr 20 17:07:18 2006
     5.8 +# Linux kernel version: 2.6.16.13-xen
     5.9 +# Thu May 11 17:11:00 2006
    5.10  #
    5.11  CONFIG_X86_32=y
    5.12  CONFIG_SEMAPHORE_SLEEPERS=y
    5.13 @@ -888,7 +888,7 @@ CONFIG_MTD_NAND_DISKONCHIP=m
    5.14  # CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
    5.15  CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
    5.16  CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y
    5.17 -CONFIG_MTD_NAND_NANDSIM=y
    5.18 +CONFIG_MTD_NAND_NANDSIM=m
    5.19  
    5.20  #
    5.21  # OneNAND Flash Device Drivers
    5.22 @@ -3009,7 +3009,7 @@ CONFIG_CRYPTO_TEST=m
    5.23  #
    5.24  # CONFIG_CRYPTO_DEV_PADLOCK is not set
    5.25  CONFIG_XEN=y
    5.26 -CONFIG_XEN_INTERFACE_VERSION=0x00030101
    5.27 +CONFIG_XEN_INTERFACE_VERSION=0x00030202
    5.28  
    5.29  #
    5.30  # XEN
    5.31 @@ -3030,10 +3030,12 @@ CONFIG_XEN_NETDEV_LOOPBACK=y
    5.32  CONFIG_XEN_BLKDEV_FRONTEND=y
    5.33  CONFIG_XEN_NETDEV_FRONTEND=y
    5.34  # CONFIG_XEN_BLKDEV_TAP is not set
    5.35 -CONFIG_XEN_TPMDEV_FRONTEND=m
    5.36  CONFIG_XEN_SCRUB_PAGES=y
    5.37  CONFIG_XEN_DISABLE_SERIAL=y
    5.38  CONFIG_XEN_SYSFS=y
    5.39 +CONFIG_XEN_COMPAT_030002_AND_LATER=y
    5.40 +# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
    5.41 +CONFIG_XEN_COMPAT_030002=y
    5.42  CONFIG_HAVE_ARCH_ALLOC_SKB=y
    5.43  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    5.44  CONFIG_NO_IDLE_HZ=y
     6.1 --- a/buildconfigs/linux-defconfig_xen_x86_64	Thu May 11 15:51:56 2006 +0100
     6.2 +++ b/buildconfigs/linux-defconfig_xen_x86_64	Thu May 11 17:30:50 2006 +0100
     6.3 @@ -1,7 +1,7 @@
     6.4  #
     6.5  # Automatically generated make config: don't edit
     6.6 -# Linux kernel version: 2.6.16-xen
     6.7 -# Thu Apr 20 17:05:48 2006
     6.8 +# Linux kernel version: 2.6.16.13-xen
     6.9 +# Thu May 11 17:18:58 2006
    6.10  #
    6.11  CONFIG_X86_64=y
    6.12  CONFIG_64BIT=y
    6.13 @@ -840,7 +840,7 @@ CONFIG_MTD_NAND_DISKONCHIP=m
    6.14  # CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
    6.15  CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
    6.16  CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y
    6.17 -CONFIG_MTD_NAND_NANDSIM=y
    6.18 +CONFIG_MTD_NAND_NANDSIM=m
    6.19  
    6.20  #
    6.21  # OneNAND Flash Device Drivers
    6.22 @@ -2841,7 +2841,7 @@ CONFIG_CRYPTO_TEST=m
    6.23  # Hardware crypto devices
    6.24  #
    6.25  CONFIG_XEN=y
    6.26 -CONFIG_XEN_INTERFACE_VERSION=0x00030101
    6.27 +CONFIG_XEN_INTERFACE_VERSION=0x00030202
    6.28  
    6.29  #
    6.30  # XEN
    6.31 @@ -2863,10 +2863,12 @@ CONFIG_XEN_TPMDEV_BACKEND=m
    6.32  CONFIG_XEN_BLKDEV_FRONTEND=y
    6.33  CONFIG_XEN_NETDEV_FRONTEND=y
    6.34  # CONFIG_XEN_BLKDEV_TAP is not set
    6.35 -CONFIG_XEN_TPMDEV_FRONTEND=m
    6.36  CONFIG_XEN_SCRUB_PAGES=y
    6.37  CONFIG_XEN_DISABLE_SERIAL=y
    6.38  CONFIG_XEN_SYSFS=y
    6.39 +CONFIG_XEN_COMPAT_030002_AND_LATER=y
    6.40 +# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
    6.41 +CONFIG_XEN_COMPAT_030002=y
    6.42  CONFIG_HAVE_ARCH_ALLOC_SKB=y
    6.43  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    6.44  CONFIG_NO_IDLE_HZ=y
     7.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S	Thu May 11 15:51:56 2006 +0100
     7.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S	Thu May 11 17:30:50 2006 +0100
     7.3 @@ -23,6 +23,8 @@
     7.4  #define X86_CAPABILITY	new_cpu_data+CPUINFO_x86_capability
     7.5  #define X86_VENDOR_ID	new_cpu_data+CPUINFO_x86_vendor_id
     7.6  
     7.7 +#define VIRT_ENTRY_OFFSET 0x0
     7.8 +.org VIRT_ENTRY_OFFSET
     7.9  ENTRY(startup_32)
    7.10  	movl %esi,xen_start_info
    7.11  	cld
    7.12 @@ -155,6 +157,14 @@ ENTRY(cpu_gdt_table)
    7.13  	.ascii	",XEN_VER=xen-3.0"
    7.14  	.ascii	",VIRT_BASE=0x"
    7.15  		utoa __PAGE_OFFSET
    7.16 +#ifdef CONFIG_XEN_COMPAT_030002
    7.17 +	.ascii	",ELF_PADDR_OFFSET=0x"
    7.18 +		utoa __PAGE_OFFSET
    7.19 +#else
    7.20 +	.ascii	",ELF_PADDR_OFFSET=0x0"
    7.21 +#endif /* !CONFIG_XEN_COMPAT_030002 */
    7.22 +	.ascii	",VIRT_ENTRY=0x"
    7.23 +		utoa (__PAGE_OFFSET + __PHYSICAL_START + VIRT_ENTRY_OFFSET)
    7.24  	.ascii	",HYPERCALL_PAGE=0x"
    7.25  		utoa ((__PHYSICAL_START+HYPERCALL_PAGE_OFFSET)>>PAGE_SHIFT)
    7.26  	.ascii  ",FEATURES=writable_page_tables"
     8.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S	Thu May 11 15:51:56 2006 +0100
     8.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S	Thu May 11 17:30:50 2006 +0100
     8.3 @@ -24,6 +24,8 @@
     8.4  
     8.5  	.text
     8.6  	.code64
     8.7 +#define VIRT_ENTRY_OFFSET 0x0
     8.8 +.org VIRT_ENTRY_OFFSET
     8.9  	.globl startup_64
    8.10  startup_64:
    8.11  ENTRY(_start)
    8.12 @@ -146,8 +148,18 @@ gdt_end:
    8.13  .section __xen_guest
    8.14  	.ascii	"GUEST_OS=linux,GUEST_VER=2.6"
    8.15  	.ascii	",XEN_VER=xen-3.0"
    8.16 -	.ascii	",VIRT_BASE=0x"; utoh __START_KERNEL_map
    8.17 -	.ascii	",HYPERCALL_PAGE=0x"; utoh (phys_hypercall_page >> PAGE_SHIFT)
    8.18 +	.ascii	",VIRT_BASE=0x"
    8.19 +		utoh __START_KERNEL_map
    8.20 +#ifdef CONFIG_XEN_COMPAT_030002
    8.21 +	.ascii	",ELF_PADDR_OFFSET=0x"
    8.22 +		utoh __START_KERNEL_map
    8.23 +#else
    8.24 +	.ascii	",ELF_PADDR_OFFSET=0x0"
    8.25 +#endif /* !CONFIG_XEN_COMPAT_030002 */
    8.26 +	.ascii	",VIRT_ENTRY=0x"
    8.27 +		utoh (__START_KERNEL_map + __PHYSICAL_START + VIRT_ENTRY_OFFSET)
    8.28 +	.ascii	",HYPERCALL_PAGE=0x"
    8.29 +		utoh (phys_hypercall_page >> PAGE_SHIFT)
    8.30  	.ascii  ",FEATURES=writable_page_tables"
    8.31  	.ascii		 "|writable_descriptor_tables"
    8.32  	.ascii		 "|auto_translated_physmap"
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/Kconfig	Thu May 11 15:51:56 2006 +0100
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig	Thu May 11 17:30:50 2006 +0100
     9.3 @@ -198,6 +198,22 @@ config XEN_SYSFS
     9.4  	help
     9.5  		Xen hypervisor attributes will show up under /sys/hypervisor/.
     9.6  
     9.7 +choice
     9.8 +	prompt "Xen version compatibility"
     9.9 +	default XEN_COMPAT_030002_AND_LATER
    9.10 +
    9.11 +	config XEN_COMPAT_030002_AND_LATER
    9.12 +		bool "3.0.2 and later"
    9.13 +
    9.14 +	config XEN_COMPAT_LATEST_ONLY
    9.15 +		bool "no compatibility code"
    9.16 +
    9.17 +endchoice
    9.18 +
    9.19 +config XEN_COMPAT_030002
    9.20 +	bool
    9.21 +	default XEN_COMPAT_030002_AND_LATER
    9.22 +
    9.23  endmenu
    9.24  
    9.25  config HAVE_ARCH_ALLOC_SKB
    10.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h	Thu May 11 15:51:56 2006 +0100
    10.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h	Thu May 11 17:30:50 2006 +0100
    10.3 @@ -289,9 +289,10 @@ extern int page_is_ram(unsigned long pag
    10.4  #endif
    10.5  #define __KERNEL_START		(__PAGE_OFFSET + __PHYSICAL_START)
    10.6  
    10.7 +#ifdef CONFIG_XEN_COMPAT_030002
    10.8  #undef LOAD_OFFSET
    10.9  #define LOAD_OFFSET		0
   10.10 -
   10.11 +#endif /* CONFIG_XEN_COMPAT_030002 */
   10.12  
   10.13  #define PAGE_OFFSET		((unsigned long)__PAGE_OFFSET)
   10.14  #define VMALLOC_RESERVE		((unsigned long)__VMALLOC_RESERVE)
    11.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h	Thu May 11 15:51:56 2006 +0100
    11.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h	Thu May 11 17:30:50 2006 +0100
    11.3 @@ -260,8 +260,10 @@ static inline pgd_t __pgd(unsigned long 
    11.4  #define __PAGE_OFFSET           0xffff880000000000
    11.5  #endif /* !__ASSEMBLY__ */
    11.6  
    11.7 +#ifdef CONFIG_XEN_COMPAT_030002
    11.8  #undef LOAD_OFFSET
    11.9  #define LOAD_OFFSET		0
   11.10 +#endif /* CONFIG_XEN_COMPAT_030002 */
   11.11  
   11.12  /* to align the pointer to the (next) page boundary */
   11.13  #define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
    12.1 --- a/tools/libxc/xc_load_elf.c	Thu May 11 15:51:56 2006 +0100
    12.2 +++ b/tools/libxc/xc_load_elf.c	Thu May 11 17:30:50 2006 +0100
    12.3 @@ -58,7 +58,7 @@ static int parseelfimage(const char *ima
    12.4      Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
    12.5      Elf_Phdr *phdr;
    12.6      Elf_Shdr *shdr;
    12.7 -    unsigned long kernstart = ~0UL, kernend=0UL;
    12.8 +    unsigned long kernstart = ~0UL, kernend=0UL, vaddr, virt_base;
    12.9      const char *shstrtab;
   12.10      char *guestinfo=NULL, *p;
   12.11      int h;
   12.12 @@ -148,35 +148,47 @@ static int parseelfimage(const char *ima
   12.13  
   12.14      dsi->xen_guest_string = guestinfo;
   12.15  
   12.16 +    virt_base = 0;
   12.17 +    if ( (p = strstr(guestinfo, "VIRT_BASE=")) != NULL )
   12.18 +        virt_base = strtoul(p+10, &p, 0);
   12.19 +    dsi->elf_paddr_offset = virt_base;
   12.20 +    if ( (p = strstr(guestinfo, "ELF_PADDR_OFFSET=")) != NULL )
   12.21 +        dsi->elf_paddr_offset = strtoul(p+17, &p, 0);
   12.22 +
   12.23      for ( h = 0; h < ehdr->e_phnum; h++ )
   12.24      {
   12.25          phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
   12.26          if ( !is_loadable_phdr(phdr) )
   12.27              continue;
   12.28 -        if ( phdr->p_paddr < kernstart )
   12.29 -            kernstart = phdr->p_paddr;
   12.30 -        if ( (phdr->p_paddr + phdr->p_memsz) > kernend )
   12.31 -            kernend = phdr->p_paddr + phdr->p_memsz;
   12.32 +        vaddr = phdr->p_paddr - dsi->elf_paddr_offset + virt_base;
   12.33 +        if ( vaddr < kernstart )
   12.34 +            kernstart = vaddr;
   12.35 +        if ( (vaddr + phdr->p_memsz) > kernend )
   12.36 +            kernend = vaddr + phdr->p_memsz;
   12.37      }
   12.38  
   12.39 +    if ( virt_base )
   12.40 +        dsi->v_start = virt_base;
   12.41 +    else
   12.42 +        dsi->v_start = kernstart;
   12.43 +
   12.44 +    dsi->v_kernentry = ehdr->e_entry;
   12.45 +    if ( (p = strstr(guestinfo, "VIRT_ENTRY=")) != NULL )
   12.46 +        dsi->v_kernentry = strtoul(p+11, &p, 0);
   12.47 +
   12.48      if ( (kernstart > kernend) ||
   12.49 -         (ehdr->e_entry < kernstart) ||
   12.50 -         (ehdr->e_entry > kernend) )
   12.51 +         (dsi->v_kernentry < kernstart) ||
   12.52 +         (dsi->v_kernentry > kernend) )
   12.53      {
   12.54          ERROR("Malformed ELF image.");
   12.55          return -EINVAL;
   12.56      }
   12.57  
   12.58 -    dsi->v_start = kernstart;
   12.59 -    if ( (p = strstr(guestinfo, "VIRT_BASE=")) != NULL )
   12.60 -        dsi->v_start = strtoul(p+10, &p, 0);
   12.61 -
   12.62      if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
   12.63          dsi->load_symtab = 1;
   12.64  
   12.65      dsi->v_kernstart = kernstart;
   12.66      dsi->v_kernend   = kernend;
   12.67 -    dsi->v_kernentry = ehdr->e_entry;
   12.68      dsi->v_end       = dsi->v_kernend;
   12.69  
   12.70      loadelfsymtab(image, 0, 0, NULL, dsi);
   12.71 @@ -204,7 +216,7 @@ loadelfimage(
   12.72  
   12.73          for ( done = 0; done < phdr->p_filesz; done += chunksz )
   12.74          {
   12.75 -            pa = (phdr->p_paddr + done) - dsi->v_start;
   12.76 +            pa = (phdr->p_paddr + done) - dsi->elf_paddr_offset;
   12.77              va = xc_map_foreign_range(
   12.78                  xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]);
   12.79              chunksz = phdr->p_filesz - done;
   12.80 @@ -217,7 +229,7 @@ loadelfimage(
   12.81  
   12.82          for ( ; done < phdr->p_memsz; done += chunksz )
   12.83          {
   12.84 -            pa = (phdr->p_paddr + done) - dsi->v_start;
   12.85 +            pa = (phdr->p_paddr + done) - dsi->elf_paddr_offset;
   12.86              va = xc_map_foreign_range(
   12.87                  xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]);
   12.88              chunksz = phdr->p_memsz - done;
    13.1 --- a/tools/libxc/xg_private.h	Thu May 11 15:51:56 2006 +0100
    13.2 +++ b/tools/libxc/xg_private.h	Thu May 11 17:30:50 2006 +0100
    13.3 @@ -136,8 +136,11 @@ struct domain_setup_info
    13.4      unsigned long v_kernend;
    13.5      unsigned long v_kernentry;
    13.6  
    13.7 +    unsigned long elf_paddr_offset;
    13.8 +
    13.9 +    unsigned int  pae_kernel;
   13.10 +
   13.11      unsigned int  load_symtab;
   13.12 -    unsigned int  pae_kernel;
   13.13      unsigned long symtab_addr;
   13.14      unsigned long symtab_len;
   13.15  
    14.1 --- a/xen/common/elf.c	Thu May 11 15:51:56 2006 +0100
    14.2 +++ b/xen/common/elf.c	Thu May 11 17:30:50 2006 +0100
    14.3 @@ -23,7 +23,7 @@ int parseelfimage(struct domain_setup_in
    14.4      Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr;
    14.5      Elf_Phdr *phdr;
    14.6      Elf_Shdr *shdr;
    14.7 -    unsigned long kernstart = ~0UL, kernend=0UL;
    14.8 +    unsigned long kernstart = ~0UL, kernend=0UL, vaddr, virt_base;
    14.9      char *shstrtab, *guestinfo=NULL, *p;
   14.10      char *elfbase = (char *)dsi->image_addr;
   14.11      int h;
   14.12 @@ -81,39 +81,50 @@ int parseelfimage(struct domain_setup_in
   14.13  
   14.14      dsi->xen_section_string = guestinfo;
   14.15  
   14.16 -    for ( h = 0; h < ehdr->e_phnum; h++ ) 
   14.17 +    if ( guestinfo == NULL )
   14.18 +        guestinfo = "";
   14.19 +
   14.20 +    virt_base = 0;
   14.21 +    if ( (p = strstr(guestinfo, "VIRT_BASE=")) != NULL )
   14.22 +        virt_base = simple_strtoul(p+10, &p, 0);
   14.23 +    dsi->elf_paddr_offset = virt_base;
   14.24 +    if ( (p = strstr(guestinfo, "ELF_PADDR_OFFSET=")) != NULL )
   14.25 +        dsi->elf_paddr_offset = simple_strtoul(p+17, &p, 0);
   14.26 +
   14.27 +    for ( h = 0; h < ehdr->e_phnum; h++ )
   14.28      {
   14.29          phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
   14.30          if ( !is_loadable_phdr(phdr) )
   14.31              continue;
   14.32 -        if ( phdr->p_paddr < kernstart )
   14.33 -            kernstart = phdr->p_paddr;
   14.34 -        if ( (phdr->p_paddr + phdr->p_memsz) > kernend )
   14.35 -            kernend = phdr->p_paddr + phdr->p_memsz;
   14.36 +        vaddr = phdr->p_paddr - dsi->elf_paddr_offset + virt_base;
   14.37 +        if ( vaddr < kernstart )
   14.38 +            kernstart = vaddr;
   14.39 +        if ( (vaddr + phdr->p_memsz) > kernend )
   14.40 +            kernend = vaddr + phdr->p_memsz;
   14.41      }
   14.42  
   14.43 +    if ( virt_base )
   14.44 +        dsi->v_start = virt_base;
   14.45 +    else
   14.46 +        dsi->v_start = kernstart;
   14.47 +
   14.48 +    dsi->v_kernentry = ehdr->e_entry;
   14.49 +    if ( (p = strstr(guestinfo, "VIRT_ENTRY=")) != NULL )
   14.50 +        dsi->v_kernentry = simple_strtoul(p+11, &p, 0);
   14.51 +
   14.52      if ( (kernstart > kernend) || 
   14.53 -         (ehdr->e_entry < kernstart) || 
   14.54 -         (ehdr->e_entry > kernend) )
   14.55 +         (dsi->v_kernentry < kernstart) ||
   14.56 +         (dsi->v_kernentry > kernend) )
   14.57      {
   14.58          printk("Malformed ELF image.\n");
   14.59          return -EINVAL;
   14.60      }
   14.61  
   14.62 -    dsi->v_start = kernstart;
   14.63 -
   14.64 -    if ( guestinfo != NULL )
   14.65 -    {
   14.66 -        if ( (p = strstr(guestinfo, "VIRT_BASE=")) != NULL )
   14.67 -            dsi->v_start = simple_strtoul(p+10, &p, 0);
   14.68 -
   14.69 -        if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
   14.70 +    if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
   14.71              dsi->load_symtab = 1;
   14.72 -    }
   14.73  
   14.74      dsi->v_kernstart = kernstart;
   14.75      dsi->v_kernend   = kernend;
   14.76 -    dsi->v_kernentry = ehdr->e_entry;
   14.77      dsi->v_end       = dsi->v_kernend;
   14.78  
   14.79      loadelfsymtab(dsi, 0);
   14.80 @@ -126,18 +137,19 @@ int loadelfimage(struct domain_setup_inf
   14.81      char *elfbase = (char *)dsi->image_addr;
   14.82      Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr;
   14.83      Elf_Phdr *phdr;
   14.84 +    unsigned long vaddr;
   14.85      int h;
   14.86    
   14.87 -    for ( h = 0; h < ehdr->e_phnum; h++ ) 
   14.88 +    for ( h = 0; h < ehdr->e_phnum; h++ )
   14.89      {
   14.90          phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
   14.91          if ( !is_loadable_phdr(phdr) )
   14.92              continue;
   14.93 +        vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start;
   14.94          if ( phdr->p_filesz != 0 )
   14.95 -            memcpy((char *)phdr->p_paddr, elfbase + phdr->p_offset, 
   14.96 -                   phdr->p_filesz);
   14.97 +            memcpy((char *)vaddr, elfbase + phdr->p_offset, phdr->p_filesz);
   14.98          if ( phdr->p_memsz > phdr->p_filesz )
   14.99 -            memset((char *)phdr->p_paddr + phdr->p_filesz, 0, 
  14.100 +            memset((char *)vaddr + phdr->p_filesz, 0,
  14.101                     phdr->p_memsz - phdr->p_filesz);
  14.102      }
  14.103  
    15.1 --- a/xen/include/xen/sched.h	Thu May 11 15:51:56 2006 +0100
    15.2 +++ b/xen/include/xen/sched.h	Thu May 11 17:30:50 2006 +0100
    15.3 @@ -173,6 +173,7 @@ struct domain_setup_info
    15.4      unsigned long v_kernend;
    15.5      unsigned long v_kernentry;
    15.6      /* Initialised by loader: Private. */
    15.7 +    unsigned long elf_paddr_offset;
    15.8      unsigned int  load_symtab;
    15.9      unsigned long symtab_addr;
   15.10      unsigned long symtab_len;