Subject: Re: NetBSD kernel in dom0
To: Andreas Wrede <andreas@planix.com>
From: Christian Limpach <chris@pin.lu>
List: port-xen
Date: 05/21/2004 03:27:16
Hi,

On Thu, May 20, 2004 at 07:56:30PM -0400, Andreas Wrede wrote:
> I managed to install Xen+NetBSD on a spare machine. I can boot the kernel 
> (xen12netbsd.gz) from the LiveCD in dom0 and from there I can create 
> additional domains and boot them with a locally compiled NetBSD/xen kernel.
> 
> If I try to boot domain0 with a locally build kernel (one that works fine 
> in domain 1), xen produces the message "DOM0: Invalid guest OS image" and 
> reboots. The kernel config file is the one on sys/arch/xen/config/XEN, 
>   the only change is 'netbsd  root on wd0a type ffs' as grub does not pass 
> boot parameters to the kernel.
> 
> Have I missed a step somewhere?

There's a bug in Xen, it can't load images with a size which is not a
multiple of 4.  You can either pad the image to make its size a
multiple of 4 or you can rebuild Xen with the following path applied:

diff -ru xeno-1.2.bk/xen/arch/i386/boot/boot.S xeno-1.2/xen/arch/i386/boot/boot.S
--- xeno-1.2.bk/xen/arch/i386/boot/boot.S	2004-03-11 23:16:13.000000000 +0100
+++ xeno-1.2/xen/arch/i386/boot/boot.S	2004-04-21 00:08:16.000000000 +0200
@@ -103,6 +103,7 @@
         sub     %ebx,%ecx                    /* %ecx = byte len of all mods */
         mov     $(MAX_DIRECTMAP_ADDRESS), %edi
         add     %ecx, %edi                   /* %edi = src + length */        
+        add    	$3,%ecx
         shr     $2,%ecx                      /* %ecx = length/4 */
 1:      sub     $4,%eax                      /* %eax = src, %edi = dst */
         sub     $4,%edi

Or you can download a Xen image with the patch applied from:
ftp://ftp.netbsd.org/pub/NetBSD/arch/xen/misc/xen-1.2-fixed.gz
(there's also xen-1.2-fixed-ide.gz which includes support for a few
additional ide chipsets)

    christian