Re: [RFC/PATCH 1/2] kvm tools, seabios: Add "--bios" option to "vm run"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here are some small changes I made to get SeaBIOS to work on lkvm.
Some may not be entirely needed.

Oh, and I've also attached the .config I used.

John

On Fri, Feb 24, 2012 at 11:29 AM, John Floren <john@xxxxxxxxxxx> wrote:
> On Fri, Feb 24, 2012 at 11:18 AM, Pekka Enberg <penberg@xxxxxxxxxx> wrote:
>> On Fri, Feb 24, 2012 at 9:01 PM, Pekka Enberg <penberg@xxxxxxxxxx> wrote:
>>> Aah, I guess we need to implement proper support for QEMU BIOS config
>>> port ("0x510") because the dummy port is accidentally asking for a
>>> boot menu.
>>>
>>> If I disable boot menu support from SeaBIOS, I'm now seeing this PCI
>>> "out of address space" error which I suppose is what Ron and John were
>>> talking about earlier:
>>
>> [snip, snip]
>>
>> So looking at SeaBIOS code, it seems to me we could simply make LKVM
>> lie to it by claiming to be coreboot and get away with it, no? We'd
>> basically avoid all the PCI allocation passes and such.
>>
>> How difficult is it to initialize a struct cb_header data structure?
>> src/coreboot.c::find_cb_header() seems to be rather strict but
>> certainly nothing that we fundamentally can't do.
>>
>> Another option is to extend the Xen codepaths to support LKVM too.
>>
>>                                Pekka
>
> Just tell SeaBIOS to compile for Coreboot. That seemed to get me going.
>
> John
From 3f304bb583627d000be0c8ea8039c0c7c8a4c781 Mon Sep 17 00:00:00 2001
From: John Floren <john@xxxxxxxxxxx>
Date: Fri, 24 Feb 2012 17:11:44 -0800
Subject: [PATCH] Tweaks to allow SeaBIOS to boot on lkvm. Remember to build
 for Coreboot when you do make menuconfig.

---
 src/Kconfig      |    8 ++++----
 src/clock.c      |    3 +++
 src/coreboot.c   |    4 ++--
 src/paravirt.c   |    4 ++--
 src/pirtable.c   |    2 +-
 src/post.c       |    8 ++++----
 src/virtio-blk.c |   25 +++++++++++++++----------
 7 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/src/Kconfig b/src/Kconfig
index 250663a..21e13aa 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -108,7 +108,7 @@ menu "Hardware support"
         help
             Support for AHCI disk code.
     config VIRTIO_BLK
-        depends on DRIVES && !COREBOOT
+        depends on DRIVES
         bool "virtio-blk controllers"
         default y
         help
@@ -298,13 +298,13 @@ endmenu
 
 menu "BIOS Tables"
     config PIRTABLE
-        depends on !COREBOOT
+#        depends on !COREBOOT
         bool "PIR table"
         default y
         help
             Support generation of a PIR table in 0xf000 segment.
     config MPTABLE
-        depends on !COREBOOT
+#        depends on !COREBOOT
         bool "MPTable"
         default y
         help
@@ -316,7 +316,7 @@ menu "BIOS Tables"
             Support generation of SM BIOS tables.  This is also
             sometimes called DMI.
     config ACPI
-        depends on !COREBOOT
+#        depends on !COREBOOT
         bool "ACPI"
         default y
         help
diff --git a/src/clock.c b/src/clock.c
index e8a48a1..ee6c15b 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -68,6 +68,7 @@ u8 no_tsc VAR16VISIBLE;
 static void
 calibrate_tsc(void)
 {
+if (0) {
     u32 eax, ebx, ecx, edx, cpuid_features = 0;
     cpuid(0, &eax, &ebx, &ecx, &edx);
     if (eax > 0)
@@ -107,6 +108,8 @@ calibrate_tsc(void)
 
     dprintf(1, "CPU Mhz=%u\n", hz / 1000000);
 }
+SET_GLOBAL(cpu_khz, 2128000);
+}
 
 static u64
 emulate_tsc(void)
diff --git a/src/coreboot.c b/src/coreboot.c
index e328c15..976f20d 100644
--- a/src/coreboot.c
+++ b/src/coreboot.c
@@ -179,9 +179,9 @@ coreboot_fill_map(void)
 fail:
     // No table found..  Use 16Megs as a dummy value.
     dprintf(1, "Unable to find coreboot table!\n");
-    RamSize = 16*1024*1024;
+    RamSize = 512*1024*1024;
     RamSizeOver4G = 0;
-    add_e820(0, 16*1024*1024, E820_RAM);
+    add_e820(0, RamSize, E820_RAM);
     return;
 }
 
diff --git a/src/paravirt.c b/src/paravirt.c
index 9cf77de..c38a84d 100644
--- a/src/paravirt.c
+++ b/src/paravirt.c
@@ -46,8 +46,8 @@ void qemu_cfg_port_probe(void)
     char *sig = "QEMU";
     int i;
 
-    if (CONFIG_COREBOOT)
-        return;
+//    if (CONFIG_COREBOOT)
+//        return;
 
     qemu_cfg_present = 1;
 
diff --git a/src/pirtable.c b/src/pirtable.c
index 4c3f1ff..7cb358e 100644
--- a/src/pirtable.c
+++ b/src/pirtable.c
@@ -17,7 +17,7 @@ struct pir_table {
 } PACKED;
 
 extern struct pir_table PIR_TABLE;
-#if CONFIG_PIRTABLE && !CONFIG_COREBOOT
+#if CONFIG_PIRTABLE //&& !CONFIG_COREBOOT
 struct pir_table PIR_TABLE __aligned(16) VAR16EXPORT = {
     .pir = {
         .version = 0x0100,
diff --git a/src/post.c b/src/post.c
index b4ad1fa..880a238 100644
--- a/src/post.c
+++ b/src/post.c
@@ -157,10 +157,10 @@ ram_probe(void)
 static void
 init_bios_tables(void)
 {
-    if (CONFIG_COREBOOT) {
-        coreboot_copy_biostable();
-        return;
-    }
+//    if (CONFIG_COREBOOT) {
+//        coreboot_copy_biostable();
+//        return;
+//    }
     if (usingXen()) {
 	xen_copy_biostables();
 	return;
diff --git a/src/virtio-blk.c b/src/virtio-blk.c
index b869189..9022601 100644
--- a/src/virtio-blk.c
+++ b/src/virtio-blk.c
@@ -28,6 +28,7 @@ struct virtiodrive_s {
 static int
 virtio_blk_op(struct disk_op_s *op, int write)
 {
+    int i = 0;
     struct virtiodrive_s *vdrive_g =
         container_of(op->drive_g, struct virtiodrive_s, drive);
     struct vring_virtqueue *vq = GET_GLOBAL(vdrive_g->vq);
@@ -51,7 +52,7 @@ virtio_blk_op(struct disk_op_s *op, int write)
             .length	= sizeof(status),
         },
     };
-
+dprintf(3, "in virtio_blk_op\n");
     /* Add to virtqueue and kick host */
     if (write)
         vring_add_buf(vq, sg, 2, 1, 0, 0);
@@ -60,9 +61,15 @@ virtio_blk_op(struct disk_op_s *op, int write)
     vring_kick(GET_GLOBAL(vdrive_g->ioaddr), vq, 1);
 
     /* Wait for reply */
-    while (!vring_more_used(vq))
+    while (!vring_more_used(vq)) {
         usleep(5);
-
+	if (++i > 1000) {
+		vring_kick(GET_GLOBAL(vdrive_g->ioaddr), vq, 1);
+		i = 0;
+		dprintf(1, "THIS SHOULD NEVER HAPPEN! Re-kicking virtio queue!\n");
+	}
+    }
+dprintf(3, "got reply\n");
     /* Reclaim virtqueue element */
     vring_get_buf(vq, NULL);
 
@@ -77,8 +84,8 @@ virtio_blk_op(struct disk_op_s *op, int write)
 int
 process_virtio_blk_op(struct disk_op_s *op)
 {
-    if (! CONFIG_VIRTIO_BLK || CONFIG_COREBOOT)
-        return 0;
+//    if (! CONFIG_VIRTIO_BLK || CONFIG_COREBOOT)
+//        return 0;
     switch (op->command) {
     case CMD_READ:
         return virtio_blk_op(op, 0);
@@ -100,7 +107,7 @@ static void
 init_virtio_blk(struct pci_device *pci)
 {
     u16 bdf = pci->bdf;
-    dprintf(1, "found virtio-blk at %x:%x\n", pci_bdf_to_bus(bdf),
+    dprintf(3, "found virtio-blk at %x:%x\n", pci_bdf_to_bus(bdf),
             pci_bdf_to_dev(bdf));
     struct virtiodrive_s *vdrive_g = malloc_fseg(sizeof(*vdrive_g));
     if (!vdrive_g) {
@@ -159,10 +166,8 @@ void
 virtio_blk_setup(void)
 {
     ASSERT32FLAT();
-    if (! CONFIG_VIRTIO_BLK || CONFIG_COREBOOT)
-        return;
-
-    dprintf(3, "init virtio-blk\n");
+//    if (! CONFIG_VIRTIO_BLK || CONFIG_COREBOOT)
+//        return;
 
     struct pci_device *pci;
     foreachpci(pci) {
-- 
1.7.9

Attachment: .config
Description: Binary data


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux