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 <[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(-)
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);
+ }
+ }
+}