summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorGerd Hoffmann2022-04-25 15:50:50 +0200
committerGerd Hoffmann2022-04-27 07:51:01 +0200
commit966f1ca56ffe6e2c4d1333df59bcec233587aabc (patch)
tree26d74437b73252dd06ae1b3df2a15dacc2c0b9f4 /hw
parenti386: move bios load error message (diff)
downloadqemu-966f1ca56ffe6e2c4d1333df59bcec233587aabc.tar.gz
qemu-966f1ca56ffe6e2c4d1333df59bcec233587aabc.tar.xz
qemu-966f1ca56ffe6e2c4d1333df59bcec233587aabc.zip
i386: factor out x86_firmware_configure()
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>
Diffstat (limited to 'hw')
-rw-r--r--hw/i386/pc_sysfw.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index 0540047bad..c8d9e71b88 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);
+ }
+}