[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 8/9] i386: factor out x86_firmware_configure()
From: |
Gerd Hoffmann |
Subject: |
[PULL 8/9] i386: factor out x86_firmware_configure() |
Date: |
Wed, 27 Apr 2022 19:29:51 +0200 |
move sev firmware setup to separate function so it can be used from
other code paths. No functional change.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20220425135051.551037-3-kraxel@redhat.com>
---
include/hw/i386/x86.h | 3 +++
hw/i386/pc_sysfw.c | 36 ++++++++++++++++++++++--------------
2 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index 916cc325eeb1..4841a49f86c0 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -140,4 +140,7 @@ void gsi_handler(void *opaque, int n, int level);
void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
DeviceState *ioapic_init_secondary(GSIState *gsi_state);
+/* pc_sysfw.c */
+void x86_firmware_configure(void *ptr, int size);
+
#endif
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index 0540047bad22..c8d9e71b889b 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -147,7 +147,6 @@ static void pc_system_flash_map(PCMachineState *pcms,
MemoryRegion *flash_mem;
void *flash_ptr;
int flash_size;
- int ret;
assert(PC_MACHINE_GET_CLASS(pcms)->pci_enabled);
@@ -195,19 +194,7 @@ static void pc_system_flash_map(PCMachineState *pcms,
if (sev_enabled()) {
flash_ptr = memory_region_get_ram_ptr(flash_mem);
flash_size = memory_region_size(flash_mem);
- /*
- * OVMF places a GUIDed structures in the flash, so
- * search for them
- */
- pc_system_parse_ovmf_flash(flash_ptr, flash_size);
-
- ret = sev_es_save_reset_vector(flash_ptr, flash_size);
- if (ret) {
- error_report("failed to locate and/or save reset vector");
- exit(1);
- }
-
- sev_encrypt_flash(flash_ptr, flash_size, &error_fatal);
+ x86_firmware_configure(flash_ptr, flash_size);
}
}
}
@@ -259,3 +246,24 @@ void pc_system_firmware_init(PCMachineState *pcms,
pc_system_flash_cleanup_unused(pcms);
}
+
+void x86_firmware_configure(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()) {
+ 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(ptr, size, &error_fatal);
+ }
+}
--
2.35.1
- [PULL 0/9] Kraxel 20220427 patches, Gerd Hoffmann, 2022/04/27
- [PULL 2/9] Replacing CONFIG_VNC_PNG with CONFIG_PNG, Gerd Hoffmann, 2022/04/27
- [PULL 1/9] hw/display/vmware_vga: do not discard screen updates, Gerd Hoffmann, 2022/04/27
- [PULL 4/9] ui/vnc: refactor arrays of addresses to SocketAddressList, Gerd Hoffmann, 2022/04/27
- [PULL 3/9] Added parameter to take screenshot with screendump as PNG, Gerd Hoffmann, 2022/04/27
- [PULL 5/9] qapi/ui: add 'display-update' command for changing listen address, Gerd Hoffmann, 2022/04/27
- [PULL 6/9] avocado/vnc: add test_change_listen, Gerd Hoffmann, 2022/04/27
- [PULL 7/9] i386: move bios load error message, Gerd Hoffmann, 2022/04/27
- [PULL 8/9] i386: factor out x86_firmware_configure(),
Gerd Hoffmann <=
- [PULL 9/9] i386: firmware parsing and sev setup for -bios loaded firmware, Gerd Hoffmann, 2022/04/27
- Re: [PULL 0/9] Kraxel 20220427 patches, Richard Henderson, 2022/04/27