[SeaBIOS] [PATCH v2] qemu: fast boot when linuxboot optionrom is used
Stefano Garzarella
sgarzare at redhat.com
Fri Nov 30 15:27:21 CET 2018
On Fri, Nov 30, 2018 at 2:06 PM Gerd Hoffmann <kraxel at redhat.com> wrote:
>
> Hi,
>
> > > Note: All these tests are done with CONFIG_DEBUG_LEVEL=0, using
> > > CONFIG_DEBUG_LEVEL=1 the boot time grows up to 24 ms, maybe we should
> > > put CONFIG_DEBUG_LEVEL=0 in the SeaBIOS configuration used in QEMU.
> >
> > I think the main seabios binary should have CONFIG_DEBUG_LEVEL=1 as it
> > helps with debug reports. I suppose an additional binary could be
> > made for those looking for the fastest possible speed. (The sole cost
> > of the debugging is the additional hardware accesses that results from
> > those debug messages.)
>
> The qemu debugcon (CONFIG_DEBUG_IO) is detecable at runtime, it returns
> 0xe9 on port reads. So we should be able to skip that too. IIRC it
> isn't *that* straightforward as seabios is initially mapped read/only so
> a simple probe-on-first-putchar, then cache the result in a variable
> doesn't work. We could probe after make_bios_writable though which
> should still avoid printing most of the messages.
Great! I just tried the patch below and it works as you said. If I
don't have debugcon in QEMU the outs are avoided and the speed is not
bad (11.4 ms).
If I have debugcon (iobase=0x402), I can see the output.
Do you think can be an acceptable trade-off?
Thanks.
Stefano
diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c
index 0770c47..31c080e 100644
--- a/src/fw/paravirt.c
+++ b/src/fw/paravirt.c
@@ -121,6 +121,10 @@ qemu_preinit(void)
kvm_detect();
}
+ // Detect qemu debugcon
+ if (inb(GET_GLOBAL(DebugOutputPort)) != QEMU_DEBUGCON_READBACK)
+ DebugOutputPort = 0;
+
// On emulators, get memory size from nvram.
u32 rs = ((rtc_read(CMOS_MEM_EXTMEM2_LOW) << 16)
| (rtc_read(CMOS_MEM_EXTMEM2_HIGH) << 24));
diff --git a/src/fw/paravirt.h b/src/fw/paravirt.h
index a14d83e..f7e1d4c 100644
--- a/src/fw/paravirt.h
+++ b/src/fw/paravirt.h
@@ -49,6 +49,9 @@ static inline int runningOnKVM(void) {
// QEMU_CFG_DMA ID bit
#define QEMU_CFG_VERSION_DMA 2
+// QEMU debugcon read value
+#define QEMU_DEBUGCON_READBACK 0xe9
+
int qemu_cfg_enabled(void);
int qemu_cfg_dma_enabled(void);
void qemu_preinit(void);
diff --git a/src/hw/serialio.c b/src/hw/serialio.c
index 319a85c..4e0f2ac 100644
--- a/src/hw/serialio.c
+++ b/src/hw/serialio.c
@@ -107,7 +107,7 @@ u16 DebugOutputPort VARFSEG = 0x402;
void
qemu_debug_putc(char c)
{
- if (CONFIG_DEBUG_IO && runningOnQEMU())
+ if (CONFIG_DEBUG_IO && runningOnQEMU() && GET_GLOBAL(DebugOutputPort))
// Send character to debug port.
outb(c, GET_GLOBAL(DebugOutputPort));
}
>
> cheers,
> Gerd
>
--
Stefano Garzarella
Red Hat
More information about the SeaBIOS
mailing list