From patchwork Thu Sep 22 14:53:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9345471 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 36F3860757 for ; Thu, 22 Sep 2016 14:58:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27F512AAF3 for ; Thu, 22 Sep 2016 14:58:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C7ED2AB45; Thu, 22 Sep 2016 14:58:21 +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 F00F52AAF3 for ; Thu, 22 Sep 2016 14:58:19 +0000 (UTC) Received: from localhost ([::1]:49256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5S6-0005mB-Kr for patchwork-qemu-devel@patchwork.kernel.org; Thu, 22 Sep 2016 10:58:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5NJ-000176-FC for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:53:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn5NE-0007vj-9B for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:53:20 -0400 Received: from mail-sn1nam01on0048.outbound.protection.outlook.com ([104.47.32.48]:32564 helo=NAM01-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5NE-0007vR-1a for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:53:16 -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=uTl1p7DkawonJsB1ZULEdhztaDUfppJegWZ/Dw6vyF8=; b=OwQVodzi8dPA6wH/+h/PMw8xGlueK13PhOR61bA0Fyg4HZ4q3F16+tRLZrhOqLVb+P1ce4hENzKmPpcKzBQAxuyLRTfXYm8tzKvXzscgL6cgJRkf9hTC68VXIZfGoGrXmiooDjpFB0FQxyGrJov57KERAfEIgXY6Bfsl4Y+niOA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from [127.0.1.1] (165.204.77.1) by SN1PR12MB0672.namprd12.prod.outlook.com (10.163.208.30) 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:53:13 +0000 From: Brijesh Singh To: , , , , , , , , Date: Thu, 22 Sep 2016 10:53:10 -0400 Message-ID: <147455599045.8519.7374631726432800452.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: SN1PR0501CA0018.namprd05.prod.outlook.com (10.163.126.156) To SN1PR12MB0672.namprd12.prod.outlook.com (10.163.208.30) X-MS-Office365-Filtering-Correlation-Id: 1254e450-e02b-4984-5bd9-08d3e2f82de8 X-Microsoft-Exchange-Di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d21TY6mnaqsn3UE5/Udoewy44TdBaidrq/Kk=; 20:rl5YDOP8z7lNYYkV4Qc8vTPgZaudFva5P5a+iX7k6Ho+aooltci/kUtGImz66HwMlP+ImYjrsV8HWSuI4iWQeGuQRM6gPFk1YaLdyTlV2+HwkMUjByG2HDWsHaeNyqpKQ7jSddPB0V1uNBigkOzJhzZvpQLuN/SVv6C8Dl7aBMdTdnhogmqM0SHh6Sfvv+8yeIBtR2nIl3abPf5ARWsiTrCbv1Mi+Bd72qaDtPYfODl0Yw3q3sMCYAQ33oJEJe8Ag49EOEgQljAjzWg370DMzLTdO2D8XYegRNeepa52cQjgt2zNbbDtPtr70I3Fimy0jPu+TDu4FCnzH2iwoY4aD5XfdLc8k1UVBS8nnN5mSy5K1LchcRDYmqXxg9Waxcvu30uBIP6f6sFFpPBAIj/lJijpdK4FEPC7C37XBdrqkhMojqcRrLKTqQGv3D2Wgtf5WKt6EXuDlvAhzoHN8zxekOzfT47pN7CrdDVVEcpFaDuCt8JJucFQCK2sQg9qtG3J 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)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:SN1PR12MB0672; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0672; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0672; 4:/R3BLMleXeupcPv9Qd9lxfUEieCXQc2pngx0n/ZqWyoLwb6hScXmaEM2Gwvm6gNNUCRtcTfs7AJC1ycVHPM2+jmhSnqPYE4zxYqqRZRZX5DVFIDgwP9veINCT7spKjdKYGSlJSKW4ZDfgtb/uH3TpJc+Nf2WL/96ipeT95XQcuxML7fUfYJs6yS5MWVLAm8MgP42HrQoANHFqyu/hAycpm5MQ4oJ53lgCqktLPJbRAksPNEPhW9kPIL/+XHl1dYgOUPJ3ruETa0ye2cOqoPUpUDxWAQrLZ0xJnuLB8Fr59q70AL1p4ZJvTniD9pib6WULSCVdrrU4ii3d75IwrO5a4gWPJwQ03reX/bL4chiWaesC4/T33OEV4htcjS6fGpTaJRqjrlvOp0kpcuVoPIFHvlTETh7/UDo83Rt8Iog1+GuoPj7nzDYhytduEZvN0xA X-Forefront-PRVS: 0073BFEF03 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(199003)(189002)(3846002)(8676002)(50466002)(81166006)(97736004)(23676002)(50986999)(189998001)(2906002)(575784001)(92566002)(86362001)(68736007)(305945005)(33646002)(7736002)(76176999)(101416001)(2201001)(81156014)(66066001)(5001770100001)(54356999)(6116002)(42186005)(7846002)(77096005)(2950100001)(47776003)(103116003)(4001350100001)(106356001)(586003)(230700001)(19580405001)(229853001)(9686002)(83506001)(107886002)(33716001)(19580395003)(105586002)(5660300001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0672; 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?MTtTTjFQUjEyTUIwNjcyOzIzOmN0TnF2eEQxSTdNNVVhNStIaXdaUlRObHJE?= =?utf-8?B?MDJkU3BoQjVxNlhHTkJmU1Z1dG0rZjU3amdvajBWYngxV3JESkR3UFJrVFc1?= =?utf-8?B?T3RxdFd3ZUlqWnRYamZTaXlPRVoxakRsKzBNKzRmZTl3MWVyaEhoNVduR3J4?= =?utf-8?B?aFQwSjg2enVsbGFHbm1GYzNWdm5JbWliYXhlOVZUaHJuRlFVSitRZDBKQ1NR?= =?utf-8?B?QzFLUVRyZXA5aU9TR1hRS204RkpsOFJwdThVYjRaVmVHNmprQmtxeGg5SmtT?= =?utf-8?B?dnRNaXVuYUc1MDl2bnhYSWVQVGUxaFM0Vy9VMGo1T2txYXpHUmZPSjUreVRj?= =?utf-8?B?bEF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dQ==; 24:jFyRJtvuVDU6yAvwFgbjK/KWHTWyocn1+73EnV6GQuoJKRPeWa/Bv1+4icwVDqkybrLIaLeLPO1lxsLmBrQ39/sL08Fwlz680RS5UGrd6cE=; 7:5HBmx4PRl6iq9GbWjyRWjyjQcs3rrO0LJKqbwaU/PRHPj8HW1/GVe4u5eyh9C+HOZcoiHVToAH+wztE0qZrhfIDSY2vBPeH/ssG/TdVK+5RCVyXMev8ZKOetRkg7uk2IBHrRE8MQae6exEbMx2PzgkyBh9PS4PGflB5YlYp9DoVLcf3g3bhtlwhHlVfVl8fjG4ETEgRLkVnb5uB2WChjNa4hAt7roRyizBUtElhKfU8KLpOhwAa8Rvv1dGTFZpwsuqCc6RaRY06l4pP1m5pnNt4JzZog6FgDAv8b1CleiEqV+TLQfdWXe4f/4SXutoYk SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0672; 20:X2mVdAWq32KB7mfr6Ss1G6tx7wr9zwtLQKpoLyOn2ZQYoVB29OnxCzQfKBq5zZW4BJ19LC2N3NQ0wQ8ZQfLLoBFJEa915xMb6gA6DNjBlynR1RXbU9t5NCU5fh9jPVYIu9Nz+yiklVGA3Q/b/6NEsKKNf0wWN7dnrpTVal98IxmdITMFDZbNjMInmnJBRstckWHrBJ1kVylOxKnwItyUR0KneSpq7a/PsOrAYwdWLrrN/e0af58CvE551EI1rEYx X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2016 14:53:13.7379 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0672 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.32.48 Subject: [Qemu-devel] [RFC PATCH v2 08/16] core: loader: create memory encryption context before copying data 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 During system boot, rom_reset copies bios binary from internal PC.BIOS ROM to guest RAM (PC.RAM). If memory encryption is enabled then we need to ensure that encryption context is created before we start the copy process. When encryption is enabled any data copy from PC.BIOS ROM to guest RAM will go through the encryption routines which will encrypt the data as it copies into guest memory. Similarly after we are done with copying destory the encryption context. Signed-off-by: Brijesh Singh --- hw/core/loader.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/core/loader.c b/hw/core/loader.c index 53e0e41..6e0be34 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -55,6 +55,7 @@ #include "exec/address-spaces.h" #include "hw/boards.h" #include "qemu/cutils.h" +#include "sysemu/kvm.h" #include @@ -997,6 +998,13 @@ static void rom_reset(void *unused) { Rom *rom; + /* create the memory encryption context before we copy any data + * from internal ROM to guest RAM. + */ + if (kvm_memory_encryption_enabled()) { + kvm_memory_encryption_start(); + } + QTAILQ_FOREACH(rom, &roms, next) { if (rom->fw_file) { continue; @@ -1024,6 +1032,11 @@ static void rom_reset(void *unused) */ cpu_flush_icache_range(rom->addr, rom->datasize); } + + /* delete the memory encryption context after we are done with copying */ + if (kvm_memory_encryption_enabled()) { + kvm_memory_encryption_finish(); + } } int rom_check_and_register_reset(void)