public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH for-11.0 v2 0/2] Build fixes for minimal microvm
@ 2026-03-19 12:21 Ani Sinha
  2026-03-19 12:21 ` [PATCH for-11.0 v2 1/2] i386/pc_sysfw: stub out x86_firmware_configure Ani Sinha
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ani Sinha @ 2026-03-19 12:21 UTC (permalink / raw)
  Cc: Ani Sinha, philmd, pbonzini, mjt, qemu-devel

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=n
CONFIG_MICROVM=y
CONFIG_VIRTIO_BLK=y
CONFIG_VIRTIO_SERIAL=y
CONFIG_VIRTIO_INPUT=y
CONFIG_VIRTIO_INPUT_HOST=y
CONFIG_VHOST_USER_INPUT=y
CONFIG_VIRTIO_NET=y
CONFIG_VIRTIO_SCSI=y
CONFIG_VIRTIO_RNG=y
CONFIG_VIRTIO_CRYPTO=y
CONFIG_VIRTIO_BALLOON=y
CONFIG_VIRTIO_GPU=y
CONFIG_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-seccomp

CI works: https://gitlab.com/anisinha/qemu/-/pipelines/2395426997

CC: mjt@tls.msk.ru
CC: qemu-devel@nongnu.org

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(-)

-- 
2.42.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH for-11.0 v2 1/2] i386/pc_sysfw: stub out x86_firmware_configure
  2026-03-19 12:21 [PATCH for-11.0 v2 0/2] Build fixes for minimal microvm Ani Sinha
@ 2026-03-19 12:21 ` Ani Sinha
  2026-03-19 12:40   ` Philippe Mathieu-Daudé
  2026-03-19 12:21 ` [PATCH for-11.0 v2 2/2] i386/hyperv: add stubs for synic enablement Ani Sinha
  2026-03-19 14:22 ` [PATCH for-11.0 v2 0/2] Build fixes for minimal microvm Michael Tokarev
  2 siblings, 1 reply; 5+ messages in thread
From: Ani Sinha @ 2026-03-19 12:21 UTC (permalink / raw)
  To: Michael S. Tsirkin, Marcel Apfelbaum, Paolo Bonzini,
	Richard Henderson, Philippe Mathieu-Daudé, Gerd Hoffmann
  Cc: Ani Sinha, Michael Tokarev, qemu-devel

x86_firmware_configure requires ovmf support. Add a stub for this function call
for cases where OVMF is not supported.

Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Ani Sinha <anisinha@redhat.com>
---
 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(-)

diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index d8a86756ca..0a073c4285 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -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);
-        }
-    }
-}
diff --git a/hw/i386/pc_sysfw_ovmf-stubs.c b/hw/i386/pc_sysfw_ovmf-stubs.c
index aabe78b271..b53906a052 100644
--- a/hw/i386/pc_sysfw_ovmf-stubs.c
+++ b/hw/i386/pc_sysfw_ovmf-stubs.c
@@ -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();
+}
diff --git a/hw/i386/pc_sysfw_ovmf.c b/hw/i386/pc_sysfw_ovmf.c
index da947c3ca4..2f7d15c9f3 100644
--- a/hw/i386/pc_sysfw_ovmf.c
+++ b/hw/i386/pc_sysfw_ovmf.c
@@ -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);
+        }
+    }
+}
-- 
2.42.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH for-11.0 v2 2/2] i386/hyperv: add stubs for synic enablement
  2026-03-19 12:21 [PATCH for-11.0 v2 0/2] Build fixes for minimal microvm Ani Sinha
  2026-03-19 12:21 ` [PATCH for-11.0 v2 1/2] i386/pc_sysfw: stub out x86_firmware_configure Ani Sinha
@ 2026-03-19 12:21 ` Ani Sinha
  2026-03-19 14:22 ` [PATCH for-11.0 v2 0/2] Build fixes for minimal microvm Michael Tokarev
  2 siblings, 0 replies; 5+ messages in thread
From: Ani Sinha @ 2026-03-19 12:21 UTC (permalink / raw)
  To: Paolo Bonzini, Marcelo Tosatti
  Cc: Ani Sinha, philmd, Michale Tokarev, kvm, qemu-devel

Add 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.

Reported-by: Michale Tokarev <mjt@tls.msk.ru>
Signed-off-by: Ani Sinha <anisinha@redhat.com>
---
 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(-)

diff --git a/target/i386/kvm/hyperv-stub.c b/target/i386/kvm/hyperv-stub.c
index 5836f53c23..767a4c7e1a 100644
--- a/target/i386/kvm/hyperv-stub.c
+++ b/target/i386/kvm/hyperv-stub.c
@@ -61,3 +61,8 @@ uint64_t hyperv_syndbg_query_options(void)
 {
     return 0;
 }
+
+int hyperv_enable_synic(X86CPU *cpu)
+{
+    return 0;
+}
diff --git a/target/i386/kvm/hyperv.c b/target/i386/kvm/hyperv.c
index f7a81bd270..bd3c26d02b 100644
--- a/target/i386/kvm/hyperv.c
+++ b/target/i386/kvm/hyperv.c
@@ -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.
diff --git a/target/i386/kvm/hyperv.h b/target/i386/kvm/hyperv.h
index e45a4512fe..a393a5d428 100644
--- a/target/i386/kvm/hyperv.h
+++ b/target/i386/kvm/hyperv.h
@@ -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);
 
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index a29f757c16..9e352882c8 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -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;
         }
     }
 
-- 
2.42.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH for-11.0 v2 1/2] i386/pc_sysfw: stub out x86_firmware_configure
  2026-03-19 12:21 ` [PATCH for-11.0 v2 1/2] i386/pc_sysfw: stub out x86_firmware_configure Ani Sinha
@ 2026-03-19 12:40   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-19 12:40 UTC (permalink / raw)
  To: Ani Sinha, Michael S. Tsirkin, Marcel Apfelbaum, Paolo Bonzini,
	Richard Henderson, Gerd Hoffmann
  Cc: Michael Tokarev, qemu-devel

On 19/3/26 13:21, Ani Sinha wrote:
> x86_firmware_configure requires ovmf support. Add a stub for this function call
> for cases where OVMF is not supported.
> 
> Reported-by: Michael Tokarev <mjt@tls.msk.ru>
> Signed-off-by: Ani Sinha <anisinha@redhat.com>
> ---
>   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(-)
> 
> diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
> index d8a86756ca..0a073c4285 100644
> --- a/hw/i386/pc_sysfw.c
> +++ b/hw/i386/pc_sysfw.c

We can now remove this include line:

  - #include "kvm/tdx.h"

> @@ -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);
> -        }
> -    }
> -}
> diff --git a/hw/i386/pc_sysfw_ovmf-stubs.c b/hw/i386/pc_sysfw_ovmf-stubs.c
> index aabe78b271..b53906a052 100644
> --- a/hw/i386/pc_sysfw_ovmf-stubs.c
> +++ b/hw/i386/pc_sysfw_ovmf-stubs.c
> @@ -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();
> +}
> diff --git a/hw/i386/pc_sysfw_ovmf.c b/hw/i386/pc_sysfw_ovmf.c
> index da947c3ca4..2f7d15c9f3 100644
> --- a/hw/i386/pc_sysfw_ovmf.c
> +++ b/hw/i386/pc_sysfw_ovmf.c
> @@ -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);
> +        }
> +    }
> +}



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH for-11.0 v2 0/2] Build fixes for minimal microvm
  2026-03-19 12:21 [PATCH for-11.0 v2 0/2] Build fixes for minimal microvm Ani Sinha
  2026-03-19 12:21 ` [PATCH for-11.0 v2 1/2] i386/pc_sysfw: stub out x86_firmware_configure Ani Sinha
  2026-03-19 12:21 ` [PATCH for-11.0 v2 2/2] i386/hyperv: add stubs for synic enablement Ani Sinha
@ 2026-03-19 14:22 ` Michael Tokarev
  2 siblings, 0 replies; 5+ messages in thread
From: Michael Tokarev @ 2026-03-19 14:22 UTC (permalink / raw)
  To: Ani Sinha; +Cc: philmd, pbonzini, qemu-devel

On 19.03.2026 15:21, Ani Sinha wrote:
> Some build fixes for building a minmal qemu for microvm
...
> CI works: https://gitlab.com/anisinha/qemu/-/pipelines/2395426997
> 
> CC: mjt@tls.msk.ru
> CC: qemu-devel@nongnu.org
> 
> Ani Sinha (2):
>    i386/pc_sysfw: stub out x86_firmware_configure
>    i386/hyperv: add stubs for synic enablement

Series:

Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Tested-by: Michael Tokarev <mjt@tls.msk.ru>

and yes, you can fold the change suggested by Philippe.

Thanks,

/mjt


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-19 14:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 12:21 [PATCH for-11.0 v2 0/2] Build fixes for minimal microvm Ani Sinha
2026-03-19 12:21 ` [PATCH for-11.0 v2 1/2] i386/pc_sysfw: stub out x86_firmware_configure Ani Sinha
2026-03-19 12:40   ` Philippe Mathieu-Daudé
2026-03-19 12:21 ` [PATCH for-11.0 v2 2/2] i386/hyperv: add stubs for synic enablement Ani Sinha
2026-03-19 14:22 ` [PATCH for-11.0 v2 0/2] Build fixes for minimal microvm Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox