Skip to contentSkip to conversation

Extboot support for Xen

PATCH In review Anthony Liguori 3 participants 4 messages Jan 15, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Extboot support for Xen

This patch adds extboot to Xen. It should be pretty harmless as the moment because it's never enabled. extboot allows arbitrary block devices to be used to boot guests including SCSI and PV disks. I've tested it with both Windows and Linux guests in QEMU.

The version of QEMU in Xen is a bit old so I couldn't complete the plumbing. The main problem is that Xen provides no way of exposing SCSI disks right now and PV disks aren't actually accessible within QEMU. I'm hoping someone else can pick that up though as I'm pretty overcommitted at the moment. The extboot infrastructure is there though so it's just a matter of initializing it with the appropriate BlockDriverState.

Another thing to look at is the choice of physical address. extboot occupies 1.5k of memory but option roms have to fall on a 2k boundary. I stole 2k from the space used by etherboot. That should be fine since etherboot and extboot should never be loaded at the same time. Of course, someone with more insight into hvmloader may know of a better place.

Subject: [PATCH] Extboot support for Xen
Cc: Keir Fraser <[email protected]>

This patch adds extboot to Xen. It should be pretty harmless as the moment because it's never enabled. extboot allows arbitrary block devices to be used to boot guests including SCSI and PV disks. I've tested it with both Windows and Linux guests in QEMU.

The version of QEMU in Xen is a bit old so I couldn't complete the plumbing. The main problem is that Xen provides no way of exposing SCSI disks right now and PV disks aren't actually accessible within QEMU. I'm hoping someone else can pick that up though as I'm pretty overcommitted at the moment. The extboot infrastructure is there though so it's just a matter of initializing it with the appropriate BlockDriverState.

Another thing to look at is the choice of physical address. extboot occupies 1.5k of memory but option roms have to fall on a 2k boundary. I stole 2k from the space used by etherboot. That should be fine since etherboot and extboot should never be loaded at the same time. Of course, someone with more insight into hvmloader may know of a better place.

tools/firmware/Makefile +1 -0
diff -r 533a8e6cebd0 tools/firmware/Makefile
@@ -10,6 +10,7 @@ SUBDIRS += rombios rombios/32bit
 SUBDIRS += rombios rombios/32bit
 SUBDIRS += vgabios
 SUBDIRS += vmxassist
+SUBDIRS += extboot
 SUBDIRS += hvmloader
 
 .PHONY: all
tools/firmware/extboot/Makefile new file +41 -0

41 lines not on this page · raw message

tools/firmware/extboot/STATUS new file +6 -0
diff -r 533a8e6cebd0 tools/firmware/extboot/STATUS
@@ -0,0 +1,6 @@
+Working
+-------
+
+Ubuntu Server 7.04 (i386)
+Windows 2000 Professional (i386)
+Windows XP SP2 (i386)
tools/firmware/extboot/extboot.S new file +742 -0

742 lines not on this page · raw message

tools/firmware/extboot/signrom.c new file +79 -0

79 lines not on this page · raw message

tools/firmware/hvmloader/Makefile +1 -0
diff -r 533a8e6cebd0 tools/firmware/hvmloader/Makefile
@@ -55,6 +55,7 @@ roms.h:	../rombios/BIOS-bochs-latest ../
 	sh ./mkhex vgabios_cirrusvga ../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h
 	sh ./mkhex vmxassist ../vmxassist/vmxassist.bin >> roms.h
 	cat ../etherboot/eb-rtl8139.zrom.h >> roms.h
+	sh ./mkhex extboot ../extboot/extboot.bin >> roms.h
 
 .PHONY: clean
 clean:
tools/firmware/hvmloader/config.h +3 -0
diff -r 533a8e6cebd0 tools/firmware/hvmloader/config.h
@@ -21,6 +21,9 @@
 #define HYPERCALL_PHYSICAL_ADDRESS    0x00080000
 #define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
 #define ETHERBOOT_PHYSICAL_ADDRESS    0x000C8000
+/* extboot only needs 1.5k but option roms must be on a 2k boundary */
+/* FIXME: I think etherboot takes up this full space */
+#define EXTBOOT_PHYSICAL_ADDRESS      0x000CF800
 #define VMXASSIST_PHYSICAL_ADDRESS    0x000D0000
 #define SMBIOS_PHYSICAL_ADDRESS       0x000E9000
 #define SMBIOS_MAXIMUM_SIZE           0x00001000
tools/firmware/hvmloader/hvmloader.c +18 -0
diff -r 533a8e6cebd0 tools/firmware/hvmloader/hvmloader.c
@@ -316,6 +316,11 @@ static int must_load_nic(void)
     return ((boot_order & 0xf0) == 0x40);
 }
 
+static int must_load_extboot(void)
+{
+    return (inb(0x404) == 1);
+}
+
 /* Replace possibly erroneous memory-size CMOS fields with correct values. */
 static void cmos_write_memory_size(void)
 {
@@ -354,6 +359,7 @@ int main(void)
 int main(void)
 {
     int acpi_sz = 0, vgabios_sz = 0, etherboot_sz = 0, rombios_sz, smbios_sz;
+    int extboot_sz = 0;
 
     printf("HVM Loader\n");
 
@@ -396,6 +402,14 @@ int main(void)
         memcpy((void *)ETHERBOOT_PHYSICAL_ADDRESS,
                etherboot, sizeof(etherboot));
         etherboot_sz = sizeof(etherboot);
+    }
+
+    if ( must_load_extboot() )
+    {
+        printf("Loading EXTBOOT ...\n");
+        memcpy((void *)EXTBOOT_PHYSICAL_ADDRESS,
+               extboot, sizeof(extboot));
+        extboot_sz = sizeof(extboot);
     }
 
     if ( get_acpi_enabled() )
@@ -416,6 +430,10 @@ int main(void)
         printf(" %05x-%05x: Etherboot ROM\n",
                ETHERBOOT_PHYSICAL_ADDRESS,
                ETHERBOOT_PHYSICAL_ADDRESS + etherboot_sz - 1);
+    if ( extboot_sz )
+        printf(" %05x-%05x: Extboot ROM\n",
+               EXTBOOT_PHYSICAL_ADDRESS,
+               EXTBOOT_PHYSICAL_ADDRESS + extboot_sz - 1);
     if ( use_vmxassist() )
         printf(" %05x-%05x: VMXAssist\n",
                VMXASSIST_PHYSICAL_ADDRESS,
tools/ioemu/Makefile.target +1 -1
diff -r 533a8e6cebd0 tools/ioemu/Makefile.target
@@ -403,7 +403,7 @@ VL_OBJS+= ne2000.o rtl8139.o pcnet.o e10
 
 ifeq ($(TARGET_BASE_ARCH), i386)
 # Hardware support
-VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
+VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) extboot.o
 ifeq ($(ARCH),ia64)
 VL_OBJS+= fdc.o mc146818rtc.o serial.o pc.o
 else
tools/ioemu/hw/extboot.c new file +125 -0

125 lines not on this page · raw message

tools/ioemu/vl.h +3 -0
diff -r 533a8e6cebd0 tools/ioemu/vl.h
@@ -971,6 +971,9 @@ int pmac_ide_init (BlockDriverState **hd
 int pmac_ide_init (BlockDriverState **hd_table,
                    SetIRQFunc *set_irq, void *irq_opaque, int irq);
 
+/* extboot.c */
+void extboot_init(BlockDriverState *bs, int cmd);
+
 /* cdrom.c */
 int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track);
 int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 9 lines · Anthony Liguori

The version of QEMU in Xen is a bit old so I couldn't complete the plumbing. The main problem is that Xen provides no way of exposing SCSI disks right now
and PV disks aren't actually accessible within QEMU. I'm hoping someone else
can pick that up though as I'm pretty overcommitted at the moment. The extboot infrastructure is there though so it's just a matter of initializing it
with the appropriate BlockDriverState.

Could you send the original complete version of your qemu changes, which applies to more recent qemu versions, to compare against?

Thanks,
Keir

#3 lore raw
In reply to Anthony Liguori
Quoted 7 lines · Anthony Liguori

This patch adds extboot to Xen. It should be pretty harmless as the moment because it's never enabled. extboot allows arbitrary block devices to be used
to boot guests including SCSI and PV disks. I've tested it with both Windows
and Linux guests in QEMU.

Quoted 9 lines

The version of QEMU in Xen is a bit old so I couldn't complete the plumbing. The main problem is that Xen provides no way of exposing SCSI disks right now
and PV disks aren't actually accessible within QEMU. I'm hoping someone else
can pick that up though as I'm pretty overcommitted at the moment. The extboot infrastructure is there though so it's just a matter of initializing it
with the appropriate BlockDriverState.

We really badly need the '-drive' patch from QEMU 0.9.1 in Xen. We currently hack this horribly by passing disks via xenstore, while all other args to QEMU are regular command line args. If we had the -drive patch another large chunk of Xen specific patches would go away which has to be a good thing.

If there aren't already plans to rebase to QEMU 0.9.1 in Xen 3.3.x series I'd recommend back-porting the '-drive' patch to Xen's QEMU 0.9.0

Dan.

Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
#2 lore raw
In reply to Keir Fraser
Quoted 14 lines · Keir Fraser
Quoted 10 lines · Anthony Liguori

The version of QEMU in Xen is a bit old so I couldn't complete the plumbing. The main problem is that Xen provides no way of exposing SCSI disks right now
and PV disks aren't actually accessible within QEMU. I'm hoping someone else
can pick that up though as I'm pretty overcommitted at the moment. The extboot infrastructure is there though so it's just a matter of initializing it
with the appropriate BlockDriverState.

Quoted 3 lines

Could you send the original complete version of your qemu changes, which applies to more recent qemu versions, to compare against?

Attached.

Regards,

Anthony Liguori

Quoted 5 lines

Thanks,
Keir

extboot/Makefile new file +21 -0
Index: qemu/extboot/Makefile
===================================================================
@@ -0,0 +1,21 @@
+OBJCOPY=objcopy
+
+CFLAGS=-Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin \
+       -fno-stack-protector
+
+all: extboot.bin
+
+%.o: %.S
+	$(CC) $(CFLAGS) -o $@ -c $<
+
+extboot.img: extboot.o
+	$(LD) --oformat binary -Ttext 0 -o $@ $<
+
+extboot.bin: extboot.img signrom
+	./signrom extboot.img extboot.bin
+
+signrom: signrom.c
+	$(CC) -o $@ -g -Wall $^
+
+clean:
+	$(RM) *.o *.img *.bin signrom *~
extboot/extboot.S new file +742 -0

742 lines not on this page · raw message

extboot/signrom.c new file +79 -0

79 lines not on this page · raw message

Makefile.target +1 -1
Index: qemu/Makefile.target
===================================================================
@@ -443,7 +443,7 @@
 VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
 VL_OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
-VL_OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o
+VL_OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o extboot.o
 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
 endif
 ifeq ($(TARGET_BASE_ARCH), ppc)
hw/extboot.c new file +128 -0

128 lines not on this page · raw message

hw/pc.h +4 -0
Index: qemu/hw/pc.h
===================================================================
@@ -151,4 +151,8 @@
 void *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_t device,
 		      BlockDriverState *bs);
 
+/* extboot.c */
+
+void extboot_init(BlockDriverState *bs, int cmd);
+
 #endif
hw/pc.c +46 -27

103 lines not on this page · raw message

sysemu.h +1 -0
Index: qemu/sysemu.h
===================================================================
@@ -133,6 +133,7 @@
 
 int nb_drives;
 DriveInfo drives_table[MAX_DRIVES+1];
+int extboot_drive;
 
 extern int drive_get_index(BlockInterfaceType interface, int bus, int unit);
 extern int drive_get_max_bus(BlockInterfaceType interface);
vl.c +18 -2
Index: qemu/vl.c
===================================================================
@@ -167,6 +167,7 @@
    to store the VM snapshots */
 DriveInfo drives_table[MAX_DRIVES+1];
 int nb_drives;
+int extboot_drive = -1;
 /* point to the block driver where the snapshots are managed */
 BlockDriverState *bs_snapshots;
 int vga_ram_size;
@@ -4852,7 +4853,8 @@
     int max_devs;
     int index;
     char *params[] = { "bus", "unit", "if", "index", "cyls", "heads",
-                       "secs", "trans", "media", "snapshot", "file", NULL };
+                       "secs", "trans", "media", "snapshot", "file", "boot",
+		       NULL };
 
     if (check_params(buf, sizeof(buf), params, str) < 0) {
          fprintf(stderr, "qemu: unknowm parameter '%s' in '%s'\n",
@@ -5008,6 +5010,19 @@
 	}
     }
 
+    if (get_param_value(buf, sizeof(buf), "boot", str)) {
+	if (!strcmp(buf, "on")) {
+	    if (extboot_drive != -1) {
+		fprintf(stderr, "qemu: two bootable drives specified\n");
+		return -1;
+	    }
+	    extboot_drive = nb_drives;
+	} else if (strcmp(buf, "off")) {
+	    fprintf(stderr, "qemu: '%s' invalid boot option\n", str);
+	    return -1;
+	}
+    }
+
     get_param_value(file, sizeof(file), "file", str);
 
     /* compute bus and unit according index */
@@ -7443,7 +7458,8 @@
            "-hdc/-hdd file  use 'file' as IDE hard disk 2/3 image\n"
            "-cdrom file     use 'file' as IDE cdrom image (cdrom is ide1 master)\n"
 	   "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]\n"
-           "       [,cyls=c,heads=h,secs=s[,trans=t]][snapshot=on|off]\n"
+           "       [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
+	   "       [,boot=on|off]\n"
 	   "                use 'file' as a drive image\n"
            "-mtdblock file  use 'file' as on-board Flash memory image\n"
            "-sd file        use 'file' as SecureDigital card image\n"
Makefile +2 -1
Index: qemu/Makefile
===================================================================
@@ -171,7 +171,7 @@
 	mkdir -p "$(DESTDIR)$(datadir)"
 	for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
 		video.x openbios-sparc32 pxe-ne2k_pci.bin \
-		pxe-rtl8139.bin pxe-pcnet.bin; do \
+		pxe-rtl8139.bin pxe-pcnet.bin extboot.bin; do \
 		$(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
 	done
 ifndef CONFIG_WIN32
@@ -271,6 +271,7 @@
         $(datadir)/pxe-ne2k_pci.bin \
 	$(datadir)/pxe-rtl8139.bin \
         $(datadir)/pxe-pcnet.bin \
+	$(datadir)/extboot.bin \
 	$(docdir)/qemu-doc.html \
 	$(docdir)/qemu-tech.html \
 	$(mandir)/man1/qemu.1 $(mandir)/man1/qemu-img.1 )

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel