From patchwork Thu Sep 22 14:54:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9345685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 570F560757 for ; Thu, 22 Sep 2016 15:41:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47EFD2AB3A for ; Thu, 22 Sep 2016 15:41:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C5AC2AB82; Thu, 22 Sep 2016 15:41:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E49A92AB3A for ; Thu, 22 Sep 2016 15:41:32 +0000 (UTC) Received: from localhost ([::1]:50932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn67w-0000jM-3m for patchwork-qemu-devel@patchwork.kernel.org; Thu, 22 Sep 2016 11:41:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5OM-0002Po-GE for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:54:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn5OH-0008OG-R9 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:54:26 -0400 Received: from mail-co1nam03on0064.outbound.protection.outlook.com ([104.47.40.64]:52096 helo=NAM03-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5OH-0008MY-Fb for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:54:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=5ZNXD16mc35dI4xl2olMkI+XAXl1/PQks6M+bUfL97g=; b=Qvj0pmfp7vPFrBCu3iTKUfXo/wahFBhX6f/vItzbxy+nZmvbkkAztzSK/7bGhFUOx8eMN7qMzcdlqqxg/zlQ3JsQckxzcwBAsva4IQjyoPY4NjENf6YYIgbo0f0g+UY4zyi1qPlRMAZXbFpurXACRwk9uPdvyaa2edeOxM90Frk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from [127.0.1.1] (165.204.77.1) by BLUPR12MB0657.namprd12.prod.outlook.com (10.163.217.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8; Thu, 22 Sep 2016 14:54:18 +0000 From: Brijesh Singh To: , , , , , , , , Date: Thu, 22 Sep 2016 10:54:15 -0400 Message-ID: <147455605536.8519.2560907331954648247.stgit@brijesh-build-machine> In-Reply-To: <147455590865.8519.11191009507297313736.stgit@brijesh-build-machine> References: <147455590865.8519.11191009507297313736.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN1PR17CA0033.namprd17.prod.outlook.com (10.169.33.171) To BLUPR12MB0657.namprd12.prod.outlook.com (10.163.217.27) X-MS-Office365-Filtering-Correlation-Id: 10f70c6b-248f-43c7-4fdf-08d3e2f854f6 X-Microsoft-Exchange-Di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Sl1igHef6FnTY7OVTDi9/6nHUSc=; 20:POF6JdBuv2IK6f3Pz4DZraok0CwNCTuxCxV0ZccFcuo9IYuJ0VjtQHY/DnAC2HEq4U96pG90LiarHF8InXwilwebyjX1LFZCEzwtJA0UfgflDhRM8M7ZIIzXAeipltKmf5ikYPEWQRec3+lqaYyBymG3zIeo6/MUr8toOkgOO3NZKrxivP5oez2P85NlaWhFBOOaagjH07uT2gCB9Kjz/pCfw1vrB1tWjL5zP3dNrncLwpaQNtqN0Jy0XCk1u8HOC0qCkg68w+w3EfFq8fYkFHS0Zf9AQ97BnjyTns8IsS19pN+F60HqNRuIiQeiqItZQF1vPOj/W1foIy6/3nJqUwbTFXL5LmecMWYR/Vr+GcIQHRMp/DqJ/7jwbCzxhMBy8Wvqqrjlb6C53txIq3FDrh0Wxg2wknUZdrfJBzTF/xYAbraR3GCancC9OewZW+NijeLMmN+U9sUFTfm0nrwnJfVs29a2QzbU+dd69K3YMwULSC/wOtzyh7sDdpe20NMr X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:BLUPR12MB0657; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0657; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0657; 4:aWrdKCYmP+XgOszGL31ZKzDxGyXPD/sV0HUaWyv4yX9bRnojasIvqyfuY6PDK/F3cv+vYlrHisp8eu5YV4mvUu2JQ6tAi6fAWMkTY2CJ3xxXreM6ZFyRilTHaU0NxTYxOlOSfICNTSwopvLt/QIG0PzgnMiZv5tZH8746APIVcdcPYGtOCvKZq7LdnVbNI+LNZBRRhFq5vJohYahSg+Xpf9mJa/96qdZgoFEuKn17LsGf5vA7jjE5cWcDM+Urgyak+8qN/xyKadMt7BbYCnXOXXT+xg5F3hOE+Y93eyXQ9870W+oJXJQ0lBtoUf+VbsMSl3rUN4DhQy+ZtDPxXqSYMaGEeQ6x30lZfwmtOSEQqKpiMnVCHvyP1L9MnsEuURLPEIY0G0wzIjX6WRTIoOQRYsbdJKyT88DtOqEWWFSU/T1IAIPQUMLS/sUY/SiPwEP X-Forefront-PRVS: 0073BFEF03 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(199003)(189002)(230700001)(33716001)(305945005)(81166006)(189998001)(2906002)(7736002)(101416001)(23676002)(7846002)(77096005)(5660300001)(81156014)(50986999)(50466002)(229853001)(8676002)(76176999)(54356999)(106356001)(9686002)(2950100001)(47776003)(86362001)(19580395003)(107886002)(5001770100001)(83506001)(68736007)(66066001)(2201001)(586003)(42186005)(33646002)(3846002)(6116002)(103116003)(4001350100001)(97736004)(105586002)(92566002)(19580405001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0657; H:[127.0.1.1]; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTFVQUjEyTUIwNjU3OzIzOkNJWkVRZFkzendhTU5IN0U0b1pCWDdFMHlI?= =?utf-8?B?TFJlejhkMHRuUjFCaXdzdVR1RXNKbUJMMktkRU9QcWt1RE1QSFVTNUltbXIw?= =?utf-8?B?WGgrUlVlZDMyWkhtd3BQOExYa2xtZmt5UStqN2l6SW12dHo0UDQ5V2l6NEFB?= =?utf-8?B?U2JkTFRYWDJ4N3hDamt0bjFvNXR4ZUIrZnlMZFl1Q0tvbGtaWXUwcUhVc041?= =?utf-8?B?cFQrMmZLMXdjUGo0dVZ1dm1JSW1FeHBWQlBvWjM2ZDZjNlMvSHJWcjV0QnpD?= =?utf-8?B?SG5vQXRCbHZ3S0pIN0ZGSjljWEtEU21nTVI4Zyt2c01qcXhNNURKT09PdGd6?= =?utf-8?B?WWVPUmhNYk5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q631kFraPsplzT5RWaK+KEnjOkaPbDwIsnB1JpAKejz88D7G3D148f02yDxKzZbumc=; 7:1tc6TEqHNfqEo12N/e9C6ScLu38oivk+yctFY7GWOmgImnaS2mBEDBT/83J90daEy8xT/Vg7UfraA2/fafEIfkG7NO1DlwAYosRZ06LKrw0LybwmI6WNFQq9Esqim5mtXlbEaoUPFuvcjP7mJF8hm0AJm8/9s2uaE43MeM7znaVJ/JYUbOidiv7CTJuDPolWQSqn5qecJJTynkAW6XrvpTSoewg2V8sV4c4xN0p+4sTMTV6+QpIwZubVj00go3o9d1DioicoLunuI3weVhgimiYmos10DtgIzfFBY14Ov4g1Zm6nd77ivcFJ628cABPe SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0657; 20:IBupqbkmqaE6l6CM0P4w78ErtAI+WTJ3z7mCdH1GqynhE7CAiiqvVwRzl6xuHJoslmvWu9OIWdd3hCwKv6XzLwUFuTYm3EKk9RoGXP+Mrn38t15YM598bxbJ2ya8N/HsPaPE1kMrvdRpttUANL7gdPRMzPQg2Os015dhZ5ttVyvEDXclLcqx7YOBqVyE3NFFnIBMG2qA35ujf7UH7OQTc6pJvaW40rrjE+BLLkpEPMW5YO9zuP6nxt43FiEzGeIo X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2016 14:54:18.9332 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0657 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.40.64 Subject: [Qemu-devel] [RFC PATCH v2 14/16] i386: set memory encryption ops for PC.BIOS and PC.RAM regions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If guest is launched with memory encryption enabled then register BIOS and PC.RAM memory regions with memory encryption handler. Registering PC.BIOS memory region will ensure that memory encryption routines will be used when rom_reset copies the BIOS image into guest memory. A typical sequence look like: qemy_system_reset rom_reset cpu_physical_memory_write_rom cpu_phyiscal_memory_rw_debug_internal memory_encryption->write Similarly registering PC.RAM region will ensure that any debug or dump accesses from qemu monitor will go through the memory encryption routines to decrypt/encrypt the contents. A sequence looks like: cpu_phyiscal_memory_rw_debug cpu_phyiscal_memory_rw_debug_internal memory_encryption->write Signed-off-by: Brijesh Singh --- hw/i386/pc.c | 7 +++++++ hw/i386/pc_sysfw.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 022dd1b..64bedd3 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1387,6 +1387,13 @@ void pc_memory_init(PCMachineState *pcms, e820_add_entry(0x100000000ULL, pcms->above_4g_mem_size, E820_RAM); } + /* if memory encryption is enabled then set the memory encryption + * ops so that any read and write to guest RAM from hypervisor will + * go through encryption routines. */ + if (kvm_memory_encryption_enabled()) { + kvm_memory_encryption_set_memory_region(ram); + } + 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..5fa40e8 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -208,6 +208,9 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw) } g_free(filename); + if (kvm_memory_encryption_enabled()) { + kvm_memory_encryption_set_memory_region(bios); + } /* map the last 128KB of the BIOS in ISA space */ isa_bios_size = bios_size; if (isa_bios_size > (128 * 1024)) { @@ -228,6 +231,7 @@ 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); + } void pc_system_firmware_init(MemoryRegion *rom_memory, bool isapc_ram_fw)