Subject: Re: new ldscript and Xen
To: Manuel Bouyer <bouyer@antioche.eu.org>
From: Pavel Cahyna <pavel.cahyna@st.mff.cuni.cz>
List: port-i386
Date: 05/28/2006 14:28:33
--IiVenqGWf+H9Y6IX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sun, May 28, 2006 at 01:55:33PM +0200, Manuel Bouyer wrote:
> On Sun, May 28, 2006 at 01:36:47PM +0200, Pavel Cahyna wrote:
> > On Sun, May 28, 2006 at 12:15:24PM +0200, Manuel Bouyer wrote:
> > > An Xen3 domU kernel also fails to load with the new script. Reverting to
> > > the old one makes things working again.
> > 
> > Please try the attached patch. Don't forget to rerun config before make.
> > 
> 
> It doesn't work either:
> (XEN) *** LOADING DOMAIN 0 ***
> (XEN) PHYSICAL MEMORY ARRANGEMENT:
> (XEN)  Dom0 alloc.:   0e000000->0f000000 (12288 pages to be allocated)
> (XEN) VIRTUAL MEMORY ARRANGEMENT:
> (XEN)  Loaded kernel: 00100000->0093d538
> (XEN)  Init. ramdisk: 009f1000->009f1000
> (XEN)  Phys-Mach map: 009f1000->00a01000
> (XEN)  Start info:    00a01000->00a02000
> (XEN)  Page tables:   00a02000->00a06000
> (XEN)  Boot stack:    00a06000->00a07000
> (XEN)  TOTAL:         00000000->00c00000
> (XEN)  ENTRY ADDRESS: 00100000
> (XEN) Initial loading isn't allowed to lowest 1GB of memory.
> 
> In Xen, the system is already in virtual mode when the kernel is loaded,
> so the entry address has to stay at c0100000, it's the physical addresses that
> have to be moved (Xen seems to use this as virtual addresses)

OK. It seems that Xen uses a different Makefile
(arch/xen/conf/Makefile.xen), so it should be easy to do it.

See the attached ldscript and patch.

Pavel

--IiVenqGWf+H9Y6IX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="xen.patch"

Index: xen/conf/Makefile.xen
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/conf/Makefile.xen,v
retrieving revision 1.17
diff -u -r1.17 Makefile.xen
--- xen/conf/Makefile.xen	14 May 2006 21:57:13 -0000	1.17
+++ xen/conf/Makefile.xen	28 May 2006 12:19:01 -0000
@@ -88,7 +88,7 @@
 TEXTADDR?=	c0100000
 LINKFLAGS_NORMAL=	-X
 .if (${OBJECT_FMT} == "ELF")
-KERN_LDSCRIPT?=	kern.ldscript
+KERN_LDSCRIPT?=	kern.ldscript.Xen
 LINKFORMAT=	-T $S/arch/${XEN_BUILD}/conf/${KERN_LDSCRIPT}
 .else
 LINKFORMAT=	-z

--IiVenqGWf+H9Y6IX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kern.ldscript.Xen"

/*	$NetBSD: kern.ldscript,v 1.5 2006/05/26 09:22:42 pavel Exp $	*/

OUTPUT_FORMAT("elf32-i386", "elf32-i386",
	      "elf32-i386")
OUTPUT_ARCH(i386)
SECTIONS
{
   /* Read-only sections, merged into text segment: */
   .text :
   {
     *(.text)
     *(.text.*)
     *(.stub)
     *(.rodata)
   } =0
   _etext = . ;
   PROVIDE (etext = .) ;

   /* Adjust the address for the data segment.  We want to adjust up to
      the same address within the page on the next page up.  */
   . = ALIGN(0x1000) + (. & (0x1000 - 1));
   .data :
   {
     *(.data)
     *(.data.*)
   }
   _edata = . ;
   PROVIDE (edata = .) ;
   __bss_start = . ;
   .bss :
   {
     *(.bss)
     *(.bss.*)
     *(COMMON)
     . = ALIGN(32 / 8);
   }
   . = ALIGN(32 / 8);
  _end = . ;
  PROVIDE (end = .) ;
}

--IiVenqGWf+H9Y6IX--