Build fixes for minimal microvm
v2 cover Build fixes for minimal microvm
Some build fixes for building a minmal qemu for microvm
cc -m64 @qemu-system-x86_64.rsp
ld: libqemu-x86_64-softmmu.a.p/target_i386_kvm_kvm.c.o: in function `hyperv_init_vcpu':
target/i386/kvm/kvm.c:1757:(.text+0x5d83): undefined reference to `hyperv_is_synic_enabled'
ld: libqemu-x86_64-softmmu.a.p/hw_i386_x86-common.c.o: in function `x86_bios_rom_reload':
hw/i386/x86-common.c:1104:(.text+0x240d): undefined reference to `x86_firmware_configure'
collect2: error: ld returned 1 exit status
The build is done with the devices file:
CONFIG_PCI_DEVICES=nCONFIG_MICROVM=yCONFIG_VIRTIO_BLK=yCONFIG_VIRTIO_SERIAL=yCONFIG_VIRTIO_INPUT=yCONFIG_VIRTIO_INPUT_HOST=yCONFIG_VHOST_USER_INPUT=yCONFIG_VIRTIO_NET=yCONFIG_VIRTIO_SCSI=yCONFIG_VIRTIO_RNG=yCONFIG_VIRTIO_CRYPTO=yCONFIG_VIRTIO_BALLOON=yCONFIG_VIRTIO_GPU=yCONFIG_VHOST_USER_GPU=y
and with these confiure options:
../../configure ${common_configure_opts} \
--without-default-features \
--target-list=x86_64-softmmu --enable-kvm --disable-tcg \
--enable-pixman --enable-vnc \
--enable-virtfs \
--enable-linux-aio --enable-linux-io-uring \
--enable-numa \
--enable-attr \
--enable-coroutine-pool \
--audio-drv-list="" \
--without-default-devices \
--with-devices-x86_64=microvm \
--enable-vhost-kernel --enable-vhost-net \
--enable-vhost-vdpa \
--enable-vhost-user --enable-vhost-user-blk-server \
--enable-vhost-crypto \
--enable-seccompCI works: https://gitlab.com/anisinha/qemu/-/pipelines/2395426997
Ani Sinha (2):
i386/pc_sysfw: stub out x86_firmware_configure
i386/hyperv: add stubs for synic enablement
hw/i386/pc_sysfw.c | 31 ------------------------------- hw/i386/pc_sysfw_ovmf-stubs.c | 5 +++++ hw/i386/pc_sysfw_ovmf.c | 33 +++++++++++++++++++++++++++++++++ target/i386/kvm/hyperv-stub.c | 5 +++++ target/i386/kvm/hyperv.c | 9 +++++++++ target/i386/kvm/hyperv.h | 1 + target/i386/kvm/kvm.c | 12 +++++------- 7 files changed, 58 insertions(+), 38 deletions(-)
Signature · 1 line
2.42.0
PATCH v2 1/2 i386/pc_sysfw: stub out x86_firmware_configure
x86_firmware_configure requires ovmf support. Add a stub for this function call for cases where OVMF is not supported.
--- hw/i386/pc_sysfw.c | 31 ------------------------------- hw/i386/pc_sysfw_ovmf-stubs.c | 5 +++++ hw/i386/pc_sysfw_ovmf.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 31 deletions(-)
hw/i386/pc_sysfw.c +0 -31
@@ -283,34 +283,3 @@ void pc_system_firmware_init(PCMachineState *pcms, } } } - -void x86_firmware_configure (hwaddr gpa,void *ptr,int size) -{ -int ret; - -/* -* OVMF places a GUIDed structures in the flash, so -* search for them -*/ -pc_system_parse_ovmf_flash (ptr, size); - -if (sev_enabled ()) { - -/* Copy the SEV metadata table (if it exists) */ -pc_system_parse_sev_metadata (ptr, size); - - ret =sev_es_save_reset_vector (ptr, size); -if (ret) { -error_report ("failed to locate and/or save reset vector" ); -exit (1 ); - } - -sev_encrypt_flash (gpa, ptr, size, &error_fatal); - }else if (is_tdx_vm ()) { - ret =tdx_parse_tdvf (ptr, size); -if (ret) { -error_report ("failed to parse TDVF for TDX VM" ); -exit (1 ); - } - } -}
hw/i386/pc_sysfw_ovmf-stubs.c +5 -0
@@ -24,3 +24,8 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size) {g_assert_not_reached (); } + +void x86_firmware_configure (hwaddr gpa,void *ptr,int size) +{ +g_assert_not_reached (); +}
hw/i386/pc_sysfw_ovmf.c +33 -0
@@ -28,6 +28,8 @@#include "hw/i386/pc.h" #include "exec/target_page.h" #include "cpu.h" +#include "target/i386/sev.h" +#include "kvm/tdx.h" #define OVMF_TABLE_FOOTER_GUID "96b582de-1fb2-45f7-baea-a366c55a082d"
@@ -160,3 +162,34 @@ bool pc_system_ovmf_table_find(const char *entry, uint8_t **data, }return false; } + +void x86_firmware_configure (hwaddr gpa,void *ptr,int size) +{ +int ret; + +/* +* OVMF places a GUIDed structures in the flash, so +* search for them +*/ +pc_system_parse_ovmf_flash (ptr, size); + +if (sev_enabled ()) { + +/* Copy the SEV metadata table (if it exists) */ +pc_system_parse_sev_metadata (ptr, size); + + ret =sev_es_save_reset_vector (ptr, size); +if (ret) { +error_report ("failed to locate and/or save reset vector" ); +exit (1 ); + } + +sev_encrypt_flash (gpa, ptr, size, &error_fatal); + }else if (is_tdx_vm ()) { + ret =tdx_parse_tdvf (ptr, size); +if (ret) { +error_report ("failed to parse TDVF for TDX VM" ); +exit (1 ); + } + } +}
Signature · 1 line
2.42.0
Re: [PATCH for-11.0 v2 1/2] i386/pc_sysfw: stub out x86_firmware_configure
hw/i386/pc_sysfw.c
Quoted 15 lines · Ani Sinha
x86_firmware_configurerequires ovmf support. Add a stub for this function call for cases where OVMF is not supported.Reported-by Michael Tokarev <[email protected]>Signed-off-by Ani Sinha <[email protected]>--- hw/i386/pc_sysfw.c | 31 ------------------------------- hw/i386/pc_sysfw_ovmf-stubs.c | 5 +++++ hw/i386/pc_sysfw_ovmf.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 31 deletions(-)hw/i386/pc_sysfw.c +0
-0
We can now remove this include line:
- #include "kvm/tdx.h"
Quoted 96 lines
hw/i386/pc_sysfw.c +0
-31@@ -283,34 +283,3 @@ void pc_system_firmware_init(PCMachineState *pcms, } } } - -void x86_firmware_configure (hwaddr gpa,void *ptr,int size) -{ -int ret; - -/* -* OVMF places a GUIDed structures in the flash, so -* search for them -*/ -pc_system_parse_ovmf_flash (ptr, size); - -if (sev_enabled ()) { - -/* Copy the SEV metadata table (if it exists) */ -pc_system_parse_sev_metadata (ptr, size); - - ret =sev_es_save_reset_vector (ptr, size); -if (ret) { -error_report ("failed to locate and/or save reset vector" ); -exit (1 ); - } - -sev_encrypt_flash (gpa, ptr, size, &error_fatal); - }else if (is_tdx_vm ()) { - ret =tdx_parse_tdvf (ptr, size); -if (ret) { -error_report ("failed to parse TDVF for TDX VM" ); -exit (1 ); - } - } -}hw/i386/pc_sysfw_ovmf-stubs.c +5
-0@@ -24,3 +24,8 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size) {g_assert_not_reached (); } + +void x86_firmware_configure (hwaddr gpa,void *ptr,int size) +{ +g_assert_not_reached (); +}hw/i386/pc_sysfw_ovmf.c +33
-0@@ -28,6 +28,8 @@#include "hw/i386/pc.h" #include "exec/target_page.h" #include "cpu.h" +#include "target/i386/sev.h" +#include "kvm/tdx.h" #define OVMF_TABLE_FOOTER_GUID "96b582de-1fb2-45f7-baea-a366c55a082d"@@ -160,3 +162,34 @@ bool pc_system_ovmf_table_find(const char *entry, uint8_t **data, }return false; } + +void x86_firmware_configure (hwaddr gpa,void *ptr,int size) +{ +int ret; + +/* +* OVMF places a GUIDed structures in the flash, so +* search for them +*/ +pc_system_parse_ovmf_flash (ptr, size); + +if (sev_enabled ()) { + +/* Copy the SEV metadata table (if it exists) */ +pc_system_parse_sev_metadata (ptr, size); + + ret =sev_es_save_reset_vector (ptr, size); +if (ret) { +error_report ("failed to locate and/or save reset vector" ); +exit (1 ); + } + +sev_encrypt_flash (gpa, ptr, size, &error_fatal); + }else if (is_tdx_vm ()) { + ret =tdx_parse_tdvf (ptr, size); +if (ret) { +error_report ("failed to parse TDVF for TDX VM" ); +exit (1 ); + } + } +}
PATCH v2 2/2 i386/hyperv: add stubs for synic enablement
In reply to Ani SinhaAdd a new call hyperv_enable_synic() that can be called whether or not CONFIG_HYPERV is enabled. This way genetic code in i396/kvm.c can call this function to enable synic for hyperv. For non-hyperv cases, the stub will be a noop.
--- target/i386/kvm/hyperv-stub.c | 5 +++++ target/i386/kvm/hyperv.c | 9 +++++++++ target/i386/kvm/hyperv.h | 1 + target/i386/kvm/kvm.c | 12 +++++------- 4 files changed, 20 insertions(+), 7 deletions(-)
target/i386/kvm/hyperv-stub.c +5 -0
@@ -61,3 +61,8 @@ uint64_t hyperv_syndbg_query_options(void) {return 0 ; } + +int hyperv_enable_synic (X86CPU *cpu) +{ +return 0 ; +}
target/i386/kvm/hyperv.c +9 -0
@@ -24,6 +24,15 @@ int hyperv_x86_synic_add(X86CPU *cpu)return 0 ; } +int hyperv_enable_synic (X86CPU *cpu) +{ +int ret =0 ; +if (!hyperv_is_synic_enabled ()) { + ret =hyperv_x86_synic_add (cpu); + } +return ret; +} +/* * All devices possibly using SynIC have to be reset before calling this to let * them remove their SINT routes first.
target/i386/kvm/hyperv.h +1 -0
@@ -23,6 +23,7 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit);#endif int hyperv_x86_synic_add (X86CPU *cpu); +int hyperv_enable_synic (X86CPU *cpu);void hyperv_x86_synic_reset (X86CPU *cpu);void hyperv_x86_synic_update (X86CPU *cpu);
target/i386/kvm/kvm.c +5 -7
@@ -1754,13 +1754,11 @@ static int hyperv_init_vcpu(X86CPU *cpu)return ret; } -if (!hyperv_is_synic_enabled ()) { - ret =hyperv_x86_synic_add (cpu); -if (ret <0 ) { -error_report ("failed to create HyperV SynIC: %s" , -strerror (-ret)); -return ret; - } + ret =hyperv_enable_synic (cpu); +if (ret <0 ) { +error_report ("failed to create HyperV SynIC: %s" , +strerror (-ret)); +return ret; } }
Signature · 1 line
2.42.0
Quoted 1 line · Ani Sinha
Some build fixes for building a minmal qemu for microvm
...
Quoted 8 lines
CI works: https://gitlab.com/anisinha/qemu/-/pipelines/2395426997
Ani Sinha (2):
i386/pc_sysfw: stub outx86_firmware_configure
i386/hyperv: add stubs for synic enablement
Series:
and yes, you can fold the change suggested by Philippe.
Thanks,
/mjt