If guest is launched into SEV-enabled mode then read/write to the BIOS and RAM memory regions should be performed using the SEV commands.
Signed-off-by: Brijesh Singh <[email protected]> --- hw/i386/pc.c | 5 +++++ hw/i386/pc_sysfw.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 022dd1b..1471df4 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -46,6 +46,7 @@ #include "sysemu/sysemu.h" #include "sysemu/numa.h" #include "sysemu/kvm.h" +#include "sysemu/sev.h" #include "sysemu/qtest.h" #include "kvm_i386.h" #include "hw/xen/xen.h" @@ -1387,6 +1388,10 @@ void pc_memory_init(PCMachineState *pcms, e820_add_entry(0x100000000ULL, pcms->above_4g_mem_size, E820_RAM); } + /* Register SEV read/write ops for the guest RAM */ + if (kvm_sev_enabled()) + memory_region_set_ram_ops(ram, kvm_sev_get_ram_ops()); + if (!pcmc->has_reserved_memory && (machine->ram_slots || (machine->maxram_size > machine->ram_size))) { diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index f915ad0..95b1006 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -35,6 +35,7 @@ #include "sysemu/sysemu.h" #include "hw/block/flash.h" #include "sysemu/kvm.h" +#include "sysemu/sev.h" #define BIOS_FILENAME "bios.bin" @@ -228,6 +229,11 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw) memory_region_add_subregion(rom_memory, (uint32_t)(-bios_size), bios); + + /* Register SEV read/write callback */ + if (kvm_sev_enabled()) { + memory_region_set_ram_ops(bios, kvm_sev_get_ram_ops()); + } } void pc_system_firmware_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
