From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpZI-0005ou-Lr for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:24:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjpZC-0005GJ-L3 for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:24:15 -0400 Received: from mail-sn1nam02on0079.outbound.protection.outlook.com ([104.47.36.79]:49689 helo=NAM02-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpZC-0005Dy-Cw for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:24:10 -0400 From: Brijesh Singh Date: Tue, 13 Sep 2016 10:49:21 -0400 Message-ID: <147377816100.11859.1924921034992764815.stgit@brijesh-build-machine> In-Reply-To: <147377800565.11859.4411044563640180545.stgit@brijesh-build-machine> References: <147377800565.11859.4411044563640180545.stgit@brijesh-build-machine> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [RFC PATCH v1 15/22] i386: sev: register RAM read/write ops for BIOS and PC.RAM region List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: ehabkost@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mst@redhat.com, p.fedin@samsung.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com, rth@twiddle.net 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 --- 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)