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

Pekka Enberg
2012-02-24T18:54:55Z

Hi,

I played around with the "--debug-ioport" command line option and was able
to cheat my way past SeaBIOS POST phase. Should SeaBIOS automatically pick
up virtio devices and attempt to boot them?

And no, I'm not going to commit this, at least not for now.

Pekka

>From 8070dd3cfd3a371f4d968fd2446514f03df1f149 Mon Sep 17 00:00:00 2001
From: Pekka Enberg <penberg@kernel.org>
Date: Fri, 24 Feb 2012 20:20:16 +0200
Subject: [PATCH] kvmtool, seabios: Ignore BIOS POST legacy registers

This makes SeaBIOS limp along all the way to boot menu:

[penberg@tux kvm]$ ./vm run --firmware /usr/share/seabios/bios.bin
# lkvm run -k ../../arch/x86/boot/bzImage -m 448 -c 4 --name guest-11658
Start bios (version 0.6.0)
Unable to unlock ram - bridge not found
Ram Size=0x00100000 (0x0000000000000000 high)
CPU Mhz=13
Found 1 cpu(s) max supported 1 cpu(s)
PCI: bus=0 devfn=0x08: vendor_id=0x1af4 device_id=0x1009
PCI: bus=0 devfn=0x10: vendor_id=0x1af4 device_id=0x1009
PCI: bus=0 devfn=0x18: vendor_id=0x1af4 device_id=0x1000
region 0: 0x00000000
region 1: 0x00000000
WARNING - Unable to allocate resource at mptable_init:26!
WARNING - Unable to allocate resource at smbios_init:381!
Scan for VGA option rom
WARNING - Timeout at i8042_wait_read:35!
Found 2 lpt ports
Found 4 serial ports
Scan for option roms
Press F12 for boot menu.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
tools/kvm/hw/i8042.c | 8 ++++++++
tools/kvm/x86/ioport.c | 18 ++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/tools/kvm/hw/i8042.c b/tools/kvm/hw/i8042.c
index 3a36425..542fffd 100644
--- a/tools/kvm/hw/i8042.c
+++ b/tools/kvm/hw/i8042.c
@@ -19,6 +19,7 @@
* Registers
*/
#define I8042_DATA_REG 0x60
+#define I8042_PORT_B_REG 0x61
#define I8042_COMMAND_REG 0x64

/*
@@ -307,6 +308,10 @@ static bool kbd_in(struct ioport *ioport, struct kvm *kvm, u16 port, void *data,
ioport__write32(data, value);
break;
}
+ case I8042_PORT_B_REG: {
+ ioport__write8(data, 0x20);
+ break;
+ }
default:
return false;
}
@@ -327,6 +332,9 @@ static bool kbd_out(struct ioport *ioport, struct kvm *kvm, u16 port, void *data
kbd_write_data(value);
break;
}
+ case I8042_PORT_B_REG: {
+ break;
+ }
default:
return false;
}
diff --git a/tools/kvm/x86/ioport.c b/tools/kvm/x86/ioport.c
index 86302e6..7b3f4e3 100644
--- a/tools/kvm/x86/ioport.c
+++ b/tools/kvm/x86/ioport.c
@@ -50,15 +50,24 @@ void ioport__setup_arch(void)
{
/* Legacy ioport setup */

+ /* 0000 - 001F - DMA1 controller */
+ ioport__register(0x0000, &dummy_read_write_ioport_ops, 32, NULL);
+
/* 0x0020 - 0x003F - 8259A PIC 1 */
ioport__register(0x0020, &dummy_read_write_ioport_ops, 2, NULL);

/* PORT 0040-005F - PIT - PROGRAMMABLE INTERVAL TIMER (8253, 8254) */
ioport__register(0x0040, &dummy_read_write_ioport_ops, 4, NULL);

+ /* 0092 - PS/2 system control port A */
+ ioport__register(0x0092, &dummy_read_write_ioport_ops, 1, NULL);
+
/* 0x00A0 - 0x00AF - 8259A PIC 2 */
ioport__register(0x00A0, &dummy_read_write_ioport_ops, 2, NULL);

+ /* 00C0 - 001F - DMA2 controller */
+ ioport__register(0x00C0, &dummy_read_write_ioport_ops, 32, NULL);
+
/* PORT 00E0-00EF are 'motherboard specific' so we use them for our
internal debugging purposes. */
ioport__register(IOPORT_DBG, &debug_ops, 1, NULL);
@@ -69,9 +78,18 @@ void ioport__setup_arch(void)
/* 0x00F0 - 0x00FF - Math co-processor */
ioport__register(0x00F0, &dummy_write_only_ioport_ops, 2, NULL);

+ /* PORT 0278-027A - PARALLEL PRINTER PORT (usually LPT1, sometimes LPT2) */
+ ioport__register(0x0278, &dummy_read_write_ioport_ops, 3, NULL);
+
+ /* PORT 0378-037A - PARALLEL PRINTER PORT (usually LPT2, sometimes LPT3) */
+ ioport__register(0x0378, &dummy_read_write_ioport_ops, 3, NULL);
+
/* PORT 03D4-03D5 - COLOR VIDEO - CRT CONTROL REGISTERS */
ioport__register(0x03D4, &dummy_read_write_ioport_ops, 1, NULL);
ioport__register(0x03D5, &dummy_write_only_ioport_ops, 1, NULL);

ioport__register(0x402, &seabios_debug_ops, 1, NULL);
+
+ /* 0510 - QEMU BIOS configuration register */
+ ioport__register(0x510, &dummy_read_write_ioport_ops, 2, NULL);
}
--
1.7.6.5