pvh: add new PVH option rom
cover pvh: add new PVH option rom
This patch series is based on "[RFC v2 0/4] QEMU changes to do PVH boot" and provides a PVH option rom that can be used with SeaBIOS to boot uncompressed kernel using the x86/HVM direct boot ABI.
Patches 1 and 2 are to prepare the PVH option rom, moving common functions in a new header. Patch 3 adds the new PVH option rom and patch 4 uses it when we are booting an uncompressed kernel using the x86/HVM direct boot ABI.
Stefano Garzarella (4):
linuxboot_dma: remove duplicate definitions of FW_CFG
linuxboot_dma: move common functions in a new header
optionrom: add new PVH option rom hw/i386/pc: use PVH option rom
hw/i386/pc.c | 4 + pc-bios/optionrom/Makefile | 5 +- pc-bios/optionrom/linuxboot_dma.c | 110 +++------------- pc-bios/optionrom/optrom.h | 109 ++++++++++++++++ pc-bios/optionrom/optrom_fw_cfg.h | 92 ++++++++++++++ pc-bios/optionrom/pvh.S | 200 ++++++++++++++++++++++++++++++ pc-bios/optionrom/pvh_main.c | 117 +++++++++++++++++ 7 files changed, 541 insertions(+), 96 deletions(-) create mode 100644 pc-bios/optionrom/optrom.h create mode 100644 pc-bios/optionrom/optrom_fw_cfg.h create mode 100644 pc-bios/optionrom/pvh.S create mode 100644 pc-bios/optionrom/pvh_main.c
Signature · 1 line
2.20.1
PATCH 1/4 linuxboot_dma: remove duplicate definitions of FW_CFG
FW_CFG_DMA_CTL_* bits and struct fw_cfg_dma_access are defined in the qemu_fw_cfg.h header file already included in linuxboot_dma.c, so we can remove the definition of BIOS_CFG_DMA_CTL_* and struct FWCfgDmaAccess.
--- pc-bios/optionrom/linuxboot_dma.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
pc-bios/optionrom/linuxboot_dma.c +4 -16
@@ -58,12 +58,6 @@ asm(" jmp load_kernel\n" ); -/* QEMU_CFG_DMA_CONTROL bits */ -#define BIOS_CFG_DMA_CTL_ERROR 0x01 -#define BIOS_CFG_DMA_CTL_READ 0x02 -#define BIOS_CFG_DMA_CTL_SKIP 0x04 -#define BIOS_CFG_DMA_CTL_SELECT 0x08 -#define BIOS_CFG_DMA_ADDR_HIGH 0x514#define BIOS_CFG_DMA_ADDR_LOW 0x518
@@ -75,12 +69,6 @@ asm(#define barrier () asm("" : : : "memory") -typedef struct FWCfgDmaAccess { -uint32_t control; -uint32_t length; -uint64_t address; -} __attribute__((packed))FWCfgDmaAccess ; -static inline void outl (uint32_t value,uint16_t port) { asm("outl %0, %w1" : :"a" (value),"Nd" (port));
@@ -153,9 +141,9 @@ static inline uint32_t be32_to_cpu(uint32_t x)static __attribute__((__noinline__))void bios_cfg_read_entry (void *buf,uint16_t entry,uint32_t len) { -FWCfgDmaAccess access; -uint32_t control = (entry <<16 ) |BIOS_CFG_DMA_CTL_SELECT - |BIOS_CFG_DMA_CTL_READ ; +struct fw_cfg_dma_access access; +uint32_t control = (entry <<16 ) |FW_CFG_DMA_CTL_SELECT + |FW_CFG_DMA_CTL_READ ; access.address =cpu_to_be64 ((uint64_t )(uint32_t )buf); access.length =cpu_to_be32 (len);
@@ -165,7 +153,7 @@ void bios_cfg_read_entry(void *buf, uint16_t entry, uint32_t len)outl (cpu_to_be32 ((uint32_t )&access),BIOS_CFG_DMA_ADDR_LOW ); -while (be32_to_cpu (access.control) & ~BIOS_CFG_DMA_CTL_ERROR ) { +while (be32_to_cpu (access.control) & ~FW_CFG_DMA_CTL_ERROR ) {barrier (); } }
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH 1/4] linuxboot_dma: remove duplicate definitions of FW_CFG
Quoted 9 lines · Stefano Garzarella
FW_CFG_DMA_CTL_* bits and struct
fw_cfg_dma_accessare defined in theqemu_fw_cfg.hheader file already included inlinuxboot_dma.c, so we can remove the definition of BIOS_CFG_DMA_CTL_* and struct FWCfgDmaAccess.Signed-off-by Stefano Garzarella <[email protected]>--- pc-bios/optionrom/linuxboot_dma.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
PATCH 2/4 linuxboot_dma: move common functions in a new header
In reply to Stefano GarzarellaIn order to allow other option roms to use these common useful functions and definitions, this patch put them in a new C header file called optrom.h, and also add useful out*() in*() functions for different size.
--- pc-bios/optionrom/linuxboot_dma.c | 98 ++++----------------------- pc-bios/optionrom/optrom.h | 109 ++++++++++++++++++++++++++++++ pc-bios/optionrom/optrom_fw_cfg.h | 92 +++++++++++++++++++++++++ 3 files changed, 216 insertions(+), 83 deletions(-) create mode 100644 pc-bios/optionrom/optrom.h create mode 100644 pc-bios/optionrom/optrom_fw_cfg.h
pc-bios/optionrom/linuxboot_dma.c +15 -83
@@ -58,21 +58,9 @@ asm(" jmp load_kernel\n" ); -#define BIOS_CFG_DMA_ADDR_HIGH 0x514 -#define BIOS_CFG_DMA_ADDR_LOW 0x518 - -#define uint64_t unsigned long long -#define uint32_t unsigned int -#define uint16_t unsigned short - -#include "../../include/standard-headers/linux/qemu_fw_cfg.h" - -#define barrier () asm("" : : : "memory") - -static inline void outl (uint32_t value,uint16_t port) -{ - asm("outl %0, %w1" : :"a" (value),"Nd" (port)); -} +#include <stdint.h> +#include "optrom.h" +#include "optrom_fw_cfg.h" static inline void set_es (void *addr) {
@@ -80,12 +68,6 @@ static inline void set_es(void *addr) asm("movl %0, %%es" : :"r" (seg)); } -#ifdef __clang__ -#define ADDR32 -#else -#define ADDR32 "addr32 " -#endif -static inline uint16_t readw_es (uint16_t offset) {uint16_t val;
@@ -108,56 +90,6 @@ static inline void writel_es(uint16_t offset, uint32_t val) asm(ADDR32 "movl %0, %%es:(%1)" : :"r" (val),"r" ((uint32_t )offset)); } -static inline uint32_t bswap32 (uint32_t x) -{ - asm("bswapl %0" :"=r" (x) :"0" (x)); -return x; -} - -static inline uint64_t bswap64 (uint64_t x) -{ - asm("bswapl %%eax; bswapl %%edx; xchg %%eax, %%edx" :"=A" (x) :"0" (x)); -return x; -} - -static inline uint64_t cpu_to_be64 (uint64_t x) -{ -return bswap64 (x); -} - -static inline uint32_t cpu_to_be32 (uint32_t x) -{ -return bswap32 (x); -} - -static inline uint32_t be32_to_cpu (uint32_t x) -{ -return bswap32 (x); -} - -/* clang is happy to inline this function, and bloats the -* ROM. -*/ -static __attribute__((__noinline__)) -void bios_cfg_read_entry (void *buf,uint16_t entry,uint32_t len) -{ -struct fw_cfg_dma_access access; -uint32_t control = (entry <<16 ) |FW_CFG_DMA_CTL_SELECT - |FW_CFG_DMA_CTL_READ ; - - access.address =cpu_to_be64 ((uint64_t )(uint32_t )buf); - access.length =cpu_to_be32 (len); - access.control =cpu_to_be32 (control); - -barrier (); - -outl (cpu_to_be32 ((uint32_t )&access),BIOS_CFG_DMA_ADDR_LOW ); - -while (be32_to_cpu (access.control) & ~FW_CFG_DMA_CTL_ERROR ) { -barrier (); - } -} -/* Return top of memory using BIOS function E801. */ static uint32_t get_e801_addr (void ) {
@@ -211,9 +143,9 @@ void load_kernel(void)uint32_t initrd_end_page, max_allowed_page;uint32_t segment_addr, stack_addr; -bios_cfg_read_entry (&setup_addr,FW_CFG_SETUP_ADDR ,4 ); -bios_cfg_read_entry (&setup_size,FW_CFG_SETUP_SIZE ,4 ); -bios_cfg_read_entry (setup_addr,FW_CFG_SETUP_DATA , setup_size); +bios_cfg_read_entry_dma (&setup_addr,FW_CFG_SETUP_ADDR ,4 ); +bios_cfg_read_entry_dma (&setup_size,FW_CFG_SETUP_SIZE ,4 ); +bios_cfg_read_entry_dma (setup_addr,FW_CFG_SETUP_DATA , setup_size);set_es (setup_addr);
@@ -223,8 +155,8 @@ void load_kernel(void)writel_es (0x22c ,0x37ffffff ); } -bios_cfg_read_entry (&initrd_addr,FW_CFG_INITRD_ADDR ,4 ); -bios_cfg_read_entry (&initrd_size,FW_CFG_INITRD_SIZE ,4 ); +bios_cfg_read_entry_dma (&initrd_addr,FW_CFG_INITRD_ADDR ,4 ); +bios_cfg_read_entry_dma (&initrd_size,FW_CFG_INITRD_SIZE ,4 ); initrd_end_page = ((uint32_t )(initrd_addr + initrd_size) &-4096 ); max_allowed_page = (readl_es (0x22c ) &-4096 );
@@ -239,15 +171,15 @@ void load_kernel(void) } -bios_cfg_read_entry (initrd_addr,FW_CFG_INITRD_DATA , initrd_size); +bios_cfg_read_entry_dma (initrd_addr,FW_CFG_INITRD_DATA , initrd_size); -bios_cfg_read_entry (&kernel_addr,FW_CFG_KERNEL_ADDR ,4 ); -bios_cfg_read_entry (&kernel_size,FW_CFG_KERNEL_SIZE ,4 ); -bios_cfg_read_entry (kernel_addr,FW_CFG_KERNEL_DATA , kernel_size); +bios_cfg_read_entry_dma (&kernel_addr,FW_CFG_KERNEL_ADDR ,4 ); +bios_cfg_read_entry_dma (&kernel_size,FW_CFG_KERNEL_SIZE ,4 ); +bios_cfg_read_entry_dma (kernel_addr,FW_CFG_KERNEL_DATA , kernel_size); -bios_cfg_read_entry (&cmdline_addr,FW_CFG_CMDLINE_ADDR ,4 ); -bios_cfg_read_entry (&cmdline_size,FW_CFG_CMDLINE_SIZE ,4 ); -bios_cfg_read_entry (cmdline_addr,FW_CFG_CMDLINE_DATA , cmdline_size); +bios_cfg_read_entry_dma (&cmdline_addr,FW_CFG_CMDLINE_ADDR ,4 ); +bios_cfg_read_entry_dma (&cmdline_size,FW_CFG_CMDLINE_SIZE ,4 ); +bios_cfg_read_entry_dma (cmdline_addr,FW_CFG_CMDLINE_DATA , cmdline_size);/* Boot linux */ segment_addr = ((uint32_t )setup_addr >>4 );
pc-bios/optionrom/optrom.h new file +109 -0
109 lines not on this page · raw message
pc-bios/optionrom/optrom_fw_cfg.h new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH 2/4] linuxboot_dma: move common functions in a new header
Quoted 4 lines · Stefano Garzarella
In order to allow other option roms to use these common useful functions and definitions, this patch put them in a new C header file called
optrom.h, and also add useful out*() in*() functions for different size.
It's usually helpful to modify code in a one patch and move it in a separate patch. This patch does both, so it's a harder to review. Don't worry about changing it now, but something to try in the future.
pc-bios/optionrom/linuxboot_dma.c asm( · line 63
Quoted 3 lines
pc-bios/optionrom/linuxboot_dma.c +3
-0+#include <stdint.h> +#include "optrom.h" +#include "optrom_fw_cfg.h"
Can these be moved to the top of the file like a regular C source file?
Quoted 23 lines
pc-bios/optionrom/optrom.h new file +17
-0@@ -0,0 +1,109 @@ +/* +* Common Option ROM Functions for C code +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +* +* Copyright (c) 2015-2019 Red Hat Inc.
pc-bios/optionrom/optrom.h line 27
Quoted 10 lines
pc-bios/optionrom/optrom.h new file +10
-0+* Authors: +* Marc Marí <[email protected]> +* Richard W.M. Jones <[email protected]> +* Stefano Garzarella <[email protected]> +*/ + +#ifndef OPTROM_H +#define OPTROM_H + +#include "../../include/standard-headers/linux/qemu_fw_cfg.h"
This depends on <stdint.h>, please include it first.
Re: [Qemu-devel] [PATCH 2/4] linuxboot_dma: move common functions in a new header
Quoted 10 lines · Stefan Hajnoczi
Quoted 4 lines · Stefano Garzarella
In order to allow other option roms to use these common useful functions and definitions, this patch put them in a new C header file called
optrom.h, and also add useful out*() in*() functions for different size.It's usually helpful to modify code in a one patch and move it in a separate patch. This patch does both, so it's a harder to review. Don't worry about changing it now, but something to try in the future.
Thanks for the tip!
Quoted 6 lines
pc-bios/optionrom/linuxboot_dma.c asm( · line 63
Quoted 4 lines
pc-bios/optionrom/linuxboot_dma.c +3
-0+#include <stdint.h> +#include "optrom.h" +#include "optrom_fw_cfg.h" Can these be moved to the top of the file like a regular C source file?
Yes, I'll move them to the top.
Quoted 28 lines
Quoted 28 lines
pc-bios/optionrom/optrom.h new file +21
-0@@ -0,0 +1,109 @@ +/* +* Common Option ROM Functions for C code +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +* +* Copyright (c) 2015-2019 Red Hat Inc. +* Authors: +* Marc Marí <[email protected]> +* Richard W.M. Jones <[email protected]> +* Stefano Garzarella <[email protected]>
Quoted 8 lines
pc-bios/optionrom/optrom.h line 27
Quoted 6 lines
pc-bios/optionrom/optrom.h new file +6
-0+*/ + +#ifndef OPTROM_H +#define OPTROM_H + +#include "../../include/standard-headers/linux/qemu_fw_cfg.h" This depends on <
stdint.h>, please include it first.
Sure.
Thanks,
Stefano
Signature · 2 lines
Stefano Garzarella Red Hat
Re: [Qemu-devel] [PATCH 2/4] linuxboot_dma: move common functions in a new header
Quoted 60 lines · Stefano Garzarella
Quoted 10 lines · Stefan Hajnoczi
Quoted 4 lines · Stefano Garzarella
In order to allow other option roms to use these common useful functions and definitions, this patch put them in a new C header file called
optrom.h, and also add useful out*() in*() functions for different size.It's usually helpful to modify code in a one patch and move it in a separate patch. This patch does both, so it's a harder to review. Don't worry about changing it now, but something to try in the future.
Thanks for the tip!
Quoted 6 lines
pc-bios/optionrom/linuxboot_dma.c asm( · line 63
Quoted 4 lines
pc-bios/optionrom/linuxboot_dma.c +3
-0+#include <stdint.h> +#include "optrom.h" +#include "optrom_fw_cfg.h" Can these be moved to the top of the file like a regular C source file?
Yes, I'll move them to the top.
Quoted 28 lines
Quoted 28 lines
pc-bios/optionrom/optrom.h new file +21
-0@@ -0,0 +1,109 @@ +/* +* Common Option ROM Functions for C code +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +* +* Copyright (c) 2015-2019 Red Hat Inc. +* Authors: +* Marc Marí <[email protected]> +* Richard W.M. Jones <[email protected]> +* Stefano Garzarella <[email protected]> Quoted 8 lines
pc-bios/optionrom/optrom.h line 27
Quoted 6 lines
pc-bios/optionrom/optrom.h new file +6
-0+*/ + +#ifndef OPTROM_H +#define OPTROM_H + +#include "../../include/standard-headers/linux/qemu_fw_cfg.h" This depends on <
stdint.h>, please include it first.
Quoted 5 lines
Sure.
Thanks,
Stefano
Better to just pull in qemu/osdep.h
Quoted 4 lines
Signature · 3 lines
-- Stefano Garzarella Red Hat
Re: [Qemu-devel] [PATCH 2/4] linuxboot_dma: move common functions in a new header
Quoted 11 lines · Michael S. Tsirkin
Quoted 11 lines
Quoted 10 lines
pc-bios/optionrom/optrom.h
Quoted 8 lines
pc-bios/optionrom/optrom.h new file +1
-0+#include "../../include/standard-headers/linux/qemu_fw_cfg.h" This depends on <
stdint.h>, please include it first.
Quoted 7 lines
Quoted 5 lines
Sure.
Thanks,
StefanoBetter to just pull in
qemu/osdep.h
Except that qemu/osdep.h should already have been pulled in by whatever .c file is including this header. We specifically document that .h files shouldn't need to include osdep.h (and in turn, anything that osdep.h already pulls in, like <stdint.h>).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 2/4] linuxboot_dma: move common functions in a new header
Quoted 20 lines · Eric Blake
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines
Quoted 10 lines
pc-bios/optionrom/optrom.h
Quoted 8 lines
pc-bios/optionrom/optrom.h new file +1
-0+#include "../../include/standard-headers/linux/qemu_fw_cfg.h" This depends on <
stdint.h>, please include it first.Sure.
Thanks,
Stefano
Quoted 6 lines
Quoted 1 line
Better to just pull in
qemu/osdep.hExcept that
qemu/osdep.hshould already have been pulled in by whatever .c file is including this header. We specifically document that .h files shouldn't need to includeosdep.h(and in turn, anything thatosdep.halready pulls in, like <stdint.h>).
Since I can't include qemu/osdep.h because this header file is used by the option roms (bare metal), do you think is better to include stdint.h in optrom.h or in the .c files that use it?
As Stefan pointed out, I'm including qemu_fw_cfg.h in optrom.h and it depends on stdint.h. In this case, what is the best approach?
Thanks,
Stefano
Re: [Qemu-devel] [PATCH 2/4] linuxboot_dma: move common functions in a new header
Quoted 7 lines · Stefano Garzarella
Quoted 6 lines
Quoted 1 line
Better to just pull in
qemu/osdep.hExcept that
qemu/osdep.hshould already have been pulled in by whatever .c file is including this header. We specifically document that .h files shouldn't need to includeosdep.h(and in turn, anything thatosdep.halready pulls in, like <stdint.h>).
Quoted 5 lines
Since I can't include
qemu/osdep.hbecause this header file is used by the option roms (bare metal), do you think is better to includestdint.hinoptrom.hor in the .c files that use it?
As Stefan pointed out, I'm includingqemu_fw_cfg.hinoptrom.hand it depends onstdint.h. In this case, what is the best approach?
If this is one of the exception files that is used to build files outside of qemu, then its should probably be mentioned as an exception in scripts/clean-includes (okay, I see that pc-bios/ is already exempted) - and thus using osdep.h is not an option, but using <stdint.h> is, because it is the exception to the rule, in relation to files used only for qemu.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 2/4] linuxboot_dma: move common functions in a new header
In reply to Michael S. TsirkinQuoted 5 lines · Michael S. Tsirkin
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
+#include "
../../include/standard-headers/linux/qemu_fw_cfg.h"This depends on <
stdint.h>, please include it first.Better to just pull in
qemu/osdep.h
This header is used in the option roms that are bare-metal, so IMHO I can't include qemu/osdep.h here or in the option roms.
Thanks,
Stefano
PATCH 3/4 optionrom: add new PVH option rom
In reply to Stefano GarzarellaThe new pvh.bin option rom can be used with SeaBIOS to boot uncompressed kernel using the x86/HVM direct boot ABI.
pvh.S contains the entry point of the option rom. It runs in real mode, loads the e820 table querying the BIOS, and then it switches to 32bit protect mode and jump to the pvh_load_kernel() written in pvh_main.c. pvh_load_kernel() loads the cmdline and kernel entry_point using fw_cfg, then it looks for RSDP, fills the hvm_start_info required by x86/HVM ABI, and finally jumps to the kernel entry_point.
--- pc-bios/optionrom/Makefile | 5 +- pc-bios/optionrom/pvh.S | 200 +++++++++++++++++++++++++++++++++++ pc-bios/optionrom/pvh_main.c | 117 ++++++++++++++++++++ 3 files changed, 321 insertions(+), 1 deletion(-) create mode 100644 pc-bios/optionrom/pvh.S create mode 100644 pc-bios/optionrom/pvh_main.c
pc-bios/optionrom/Makefile +4 -1
@@ -37,7 +37,7 @@ Wa = -Wa, ASFLAGS += -32 QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), $(Wa)-32) -build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin +build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin # suppress auto-removal of intermediate files .SECONDARY:
@@ -46,6 +46,9 @@ build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin %.o: %.S $(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) -c -o - $< | $(AS) $(ASFLAGS) -o $@,"AS","$(TARGET_DIR)$@") +%.img: %.o %_main.o + $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_I386_EMULATION) -T $(SRC_PATH)/pc-bios/optionrom/flat.lds -s -o $@ $?,"BUILD","$(TARGET_DIR)$@") + %.img: %.o $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_I386_EMULATION) -T $(SRC_PATH)/pc-bios/optionrom/flat.lds -s -o $@ $<,"BUILD","$(TARGET_DIR)$@")
pc-bios/optionrom/pvh.S new file +200 -0
200 lines not on this page · raw message
pc-bios/optionrom/pvh_main.c new file +117 -0
117 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH 3/4] optionrom: add new PVH option rom
Quoted 12 lines · Stefano Garzarella
The new pvh.bin option rom can be used with SeaBIOS to boot uncompressed kernel using the x86/HVM direct boot ABI.
pvh.Scontains the entry point of the option rom. It runs in real mode, loads the e820 table querying the BIOS, and then it switches to 32bit protect mode and jump to thepvh_load_kernel()written inpvh_main.c.pvh_load_kernel()loads the cmdline and kernelentry_pointusingfw_cfg, then it looks for RSDP, fills thehvm_start_inforequired by x86/HVM ABI, and finally jumps to the kernelentry_point.
Quoted 8 lines
Signed-off-by Stefano Garzarella <[email protected]>--- pc-bios/optionrom/Makefile | 5 +- pc-bios/optionrom/pvh.S | 200 +++++++++++++++++++++++++++++++++++ pc-bios/optionrom/pvh_main.c | 117 ++++++++++++++++++++ 3 files changed, 321 insertions(+), 1 deletion(-) create mode 100644 pc-bios/optionrom/pvh.S create mode 100644 pc-bios/optionrom/pvh_main.c
PATCH 4/4 hw/i386/pc: use PVH option rom
In reply to Stefano GarzarellaUse pvh.bin option rom when we are booting an uncompressed kernel using the x86/HVM direct boot ABI.
Based-on: <[email protected]>
--- hw/i386/pc.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/pc.c +4 -0
@@ -1005,6 +1005,10 @@ static void load_linux(PCMachineState *pcms,fw_cfg_add_bytes (fw_cfg,FW_CFG_SETUP_DATA , header,sizeof (header)); + option_rom[nb_option_roms].bootindex =0 ; + option_rom[nb_option_roms].name ="pvh.bin" ; + nb_option_roms++; +return ; }/* This looks like a multiboot kernel. If it is, let's stop
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH 4/4] hw/i386/pc: use PVH option rom
Quoted 14 lines · Stefano Garzarella
Use pvh.bin option rom when we are booting an uncompressed kernel using the x86/HVM direct boot ABI.
Signed-off-by Stefano Garzarella <[email protected]>Based-on: <[email protected]>
--- hw/i386/pc.c | 4 ++++ 1 file changed, 4 insertions(+)hw/i386/pc.c +0
-0
hw/i386/pc.c static void load_linux(PCMachineState *pcms, · line 1011
Quoted 7 lines
hw/i386/pc.c +4
-0@@ -1005,6 +1005,10 @@ static void load_linux(PCMachineState *pcms,fw_cfg_add_bytes (fw_cfg,FW_CFG_SETUP_DATA , header,sizeof (header)); + option_rom[nb_option_roms].bootindex =0 ; + option_rom[nb_option_roms].name ="pvh.bin" ; + nb_option_roms++; +
xen_load_linux() has the following:
assert(!strcmp(option_rom[i].name, "linuxboot.bin") ||
!strcmp(option_rom[i].name, "linuxboot_dma.bin") ||
!strcmp(option_rom[i].name, "multiboot.bin"));I wonder if it needs to be updated for pvh.bin?
Re: [Qemu-devel] [PATCH 4/4] hw/i386/pc: use PVH option rom
Quoted 26 lines · Stefan Hajnoczi
Quoted 14 lines · Stefano Garzarella
Use pvh.bin option rom when we are booting an uncompressed kernel using the x86/HVM direct boot ABI.
Signed-off-by Stefano Garzarella <[email protected]>Based-on: <[email protected]>
--- hw/i386/pc.c | 4 ++++ 1 file changed, 4 insertions(+)hw/i386/pc.c +0
-0hw/i386/pc.c static void load_linux(PCMachineState *pcms, · line 1011
Quoted 7 lines
hw/i386/pc.c +4
-0@@ -1005,6 +1005,10 @@ static void load_linux(PCMachineState *pcms,fw_cfg_add_bytes (fw_cfg,FW_CFG_SETUP_DATA , header,sizeof (header)); + option_rom[nb_option_roms].bootindex =0 ; + option_rom[nb_option_roms].name ="pvh.bin" ; + nb_option_roms++; +
xen_load_linux()has the following:
Quoted 5 lines
assert(!strcmp(option_rom[i].name, "linuxboot.bin") || !strcmp(option_rom[i].name, "linuxboot_dma.bin") || !strcmp(option_rom[i].name, "multiboot.bin"));I wonder if it needs to be updated for pvh.bin?
Yeah! I think we need to add pvh.bin on the assert in xen_load_linux().
Thanks for catching this,
Stefano