From patchwork Wed Mar 8 20:52:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9611983 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 92F7E6016C for ; Wed, 8 Mar 2017 21:28:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 857D028611 for ; Wed, 8 Mar 2017 21:28:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A0F528634; Wed, 8 Mar 2017 21:28:17 +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 D7DEB28611 for ; Wed, 8 Mar 2017 21:28:16 +0000 (UTC) Received: from localhost ([::1]:58526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clj83-0007cT-Px for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Mar 2017 16:28:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clj5r-0005wM-RX for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:26:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clj5o-0005ZR-JZ for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:25:59 -0500 Received: from mail-co1nam03on0060.outbound.protection.outlook.com ([104.47.40.60]:55296 helo=NAM03-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1clj5o-0005YQ-8c for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:25:56 -0500 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=3EvQEJbUdcnHPaVnrQ0Ssg2BSdcDfQbXAVShsMlXztw=; b=3+OY46Hq2ikdhxlwB8KRTSw6/XcOwXiYzrT/GrKfEK1QURO8Yw94cmcwTFIDuYxjzrNauI5VHIqZWZ/ME8XN2AOi2GDHTVoENDvfJB/FPAhq0MyXlZ1sFFTtaK61UBUId77i85ufjskRPsanvfK4DFNWP1bGZVLkgTDJKvwZeVE= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from [127.0.1.1] (165.204.77.1) by CY4PR12MB1608.namprd12.prod.outlook.com (10.172.72.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Wed, 8 Mar 2017 20:52:57 +0000 From: Brijesh Singh To: , , , , , , , , Date: Wed, 8 Mar 2017 15:52:55 -0500 Message-ID: <148900637563.27090.8781580144264908372.stgit@brijesh-build-machine> In-Reply-To: <148900626714.27090.1616990932333159904.stgit@brijesh-build-machine> References: <148900626714.27090.1616990932333159904.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR21CA0008.namprd21.prod.outlook.com (10.172.122.146) To CY4PR12MB1608.namprd12.prod.outlook.com (10.172.72.17) X-MS-Office365-Filtering-Correlation-Id: 0cd530b9-ab97-4df6-965d-08d466651a2d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:CY4PR12MB1608; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1608; 3:8Fzm6EYx9yWMkSHmpZwjp9IQkrTicfjO6irsX5K6u3r5AngPLgx6bhM1EazeTF/pFuJv3ZM+BaQdyh/01tCxoWSXcJdVCey3HcgiJpiBV7ffoNoUCaoIAWWwi173jUoD5x8R56zYFmeaViNSQ+RBYjUSaUYOlJPjIRKygfoS2ZvV1h+Fospg7nue209TZZI8lsqpIb1rHCSaRtSiYHby8bz8tn7IiCQghvL/fKXb7Hxpo66FZsSnpm425WtmYuux63IZ34qEwgLe830LMJb5Urp9c74I1fQEZW+loucHOD0=; 25:gkPV+3TnMdWQ6GKpIoH8+iU4x3dACckRnfhM/ymcn650na33xRsKtJB2PSQkZOP1D+GnbkiOMlLWTvasQZdWZLDryy21zrsKr4pJWR+55YNXWBpd6Tg2FVTMWB8iYN48wH9K39zRjVoUd7zEO42E5pqmIiZN6EIKG4NI2VHD96Rh3d8gosLktdm+rbgRLiHrjN7Ul3bl9oUriX5Hk87jwNG5tgxxfh4AlyqYbsvOlN1lkJ5wa5XwdC6VTGxvaIslQZMS5ZwtT43xCb3U2C7fNd2DWk8MzoaZ/xDB/F/pIrvx8A6DIZ8I1HVBKzJYS9xhsQUxo22oIA1h1a1hCt8Op09B4V2e9XNQo4MwDdMmq2k0q3wq9nN+0zG/eyT0ABHlHkAuyzn1uKieeH53INl91EpP452J/b05EwtJVyE4OaY/cKu4GSh36A6TCuCvbkxf X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1608; 31:EFikmQnMysmeiOWjbSZR9YXLPmRTAwjxsYMDbi45liBy4S+00FMgVdGVxXdgtCW7x63NvcRjt0LpsT3wECFMcqMZSH0EUo78qCQXZRjBxN0DIuJOroQa2jJYpnvY15yU33AxmpJ8MTrf03/qf0oQqVOf1tQkX+mFJEE9Dg1P/F+3JTO+yts/SP0U+gALQ/ojUoNh0zFw1Bemofy/c1Vd0LgFbM/NziYA7cr337aX4hwrl26DNzWNH/ucw9c9WxM4; 20:9xCJe+VDw3xy/0KuMF+ulmrvX9NXEG9RIQ4DgyuqUueBt3Acq3anLF1jpKW7BuC+KGI0K1abwAvcwlrCijo88iRYybPpNxfhhPL4SrPzsZ2eJGEBFArnd4bHClXV1JG01bgVrYmfIfdSUAnDnmVD4h8Ox6kpTKREuFbKYSlQzDylm1liG0D6j2u1Qn7cXXwwt+o5IJTOG8YUFX8nS9rkN05J2YjpL0gZOags2rDjqBHH2drV4RdoGSQvZYTpYjD9E0xi64/MZ8eky5b6lZOT1/VTJLHFuyGTOACNZcdviq6QBxjtYhBz32sg3NE601IJyikmBBETAU6YcoZerMrBNXzaCzOBal5wmzmS5QtsfenfmDe0kPkjSKnjdj9b//Bv2PtGQNTPiur9cO6AKEYIYDeP+TjZK8V1tBUDZEmtds0ty0aSy/pPAHOPZV6kyJPl7HVy1hRUMxx7uezsC6CU7HWr4bvMxH/kYVDXm/ROZzs5EfIQ82fAlmvngEemVEv8 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123560025)(20161123558025)(20161123555025)(20161123564025)(6072148); SRVR:CY4PR12MB1608; BCL:0; PCL:0; RULEID:; SRVR:CY4PR12MB1608; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1608; 4:62qpC8BZYnXXQyCDJrHSLP5NHqhYefQku3B1Dw14HlYQTZ9O2jzRQLAJtAmkim9uTMvTC3RChZZSQQXqHxrDaq1drkJBljuv2lzz3lQP5opYdW+jmX9Nl0BAXe1wenSBrGRsFB7Ufwbc2MKK0VrtgmgfjaXYyL4yGAvG9WDroXYONX/jfKLrwXaC6r0szrOsXcJDicYIoskHDEIAfzA836kfMF0N37mGWtdASNvWTWOcDXpg/5MBrsbVy454vVBgBoztaFcU66V7ABcMwBlxSXVZwoQoA/gW1IbJT59A12itjVcnm+M4mp8MpQ3ipKXSyFB4/YF5j2Msu7yt7+pPSo5OBRwmEX057MeOapU3/kwou7Y40ggslU2cZv69RVyng+sgEZuc6KGThOIWv9jxbRr/prM1zRbOFjRe7MbhvglPL607b0FGNiM8/vxbGAZla3/kWfzY4y78H02ct5dJJy0dNlElb62pGfBKOzpEaZc83vJHG7lD8mxai2YVYsL+oIeVjh/+tEqKArqbE4lfGP9XI84RthJoEyGwCBZlnoH3e38AwgTlRNSKxvkxssUiOJN66iKu5Luxm+JaUzB7Bd6/TtS6nEsKTpZP5K8fru1effY1fUdcMUO3s70e2tzAmxlb+rHs39IcmVLDIg2SkJzAYZ0S0KfjbSEADtDcDS4= X-Forefront-PRVS: 02408926C4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6049001)(6009001)(39410400002)(39860400002)(39450400003)(39840400002)(39850400002)(8676002)(3846002)(230700001)(53936002)(77096006)(6486002)(9686003)(7736002)(81166006)(54906002)(90366009)(25786008)(305945005)(86362001)(103116003)(5660300001)(2201001)(6116002)(33646002)(189998001)(47776003)(83506001)(2906002)(66066001)(2950100002)(33716001)(23676002)(54356999)(76176999)(50986999)(38730400002)(42186005)(4326008)(50466002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1608; H:[127.0.1.1]; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxNjA4OzIzOlhtNTI3YlRUMnVkVG5nRXpLcU0rUHJTdFRu?= =?utf-8?B?RWpBZ2x0elRjZ1l6Q2xyOEw3U2FaQ1U5eml6bWpEbU5HSjhGRE9jeTAwMHl5?= =?utf-8?B?aWtGYlhQNWtiemF0a2hkcHlCTk13RG5RUm1BZjFkWjZnZH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F/804DDsgEANcIK4OIcdfqTuTG6z3gSNcnCL2lpy5U7Yrle5cgkQCDdNw77iKqBU0MR9WM=; 24:toEPMtta8J8fAHC2GIzdXGwnnmGmes6rynpSYTuc5nX4E0cxfDdTKFXLWHopZ4cYb1Baphaf0iQRjzfGmNcPuh5fJRjdCVQQSaf2KWS/sfo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1608; 7:kzYbgSxC1xm471N4sUs9IqYaqswwwEqSrN9WJPPqEbkZ8lzsBotEchmYEhEsoRbrXr7A1NCYaBAf4ck4t6ghSBwhz80Z7FtgWhdWVLuoj7O6W8goc8vcY85nZ7pJ/TFpoZn4kzAiiCaUF/tYMauZC4HouqLIzq1QCgy5i0ey2+cvN94FZGBrTKhNaa6KnpBlVGV8fd8c1S6qvAyAo0YenyLv0mBgob0PXAENy2NDi7pu33N9KCVjjjtVzgJ5T5E2GVGz3+ZfIhIonhdPbqn69yOZwXCmIqDbr/2ld4IqNLWRvw8fO3/HmhHoCCnpFO/3awuhn3bopIWEZTwKHKimWA==; 20:l+kkleFADoMp88Z8JXUg/l6wbCsc6Oje1ykU/Q1YzdHgL7Wpz7cvacP0N4Ujp58VkUXrKnh4Mlck62qV7vDKkFKDgcoD+U60pdkt6pVip36j/VAuzr2+bziBlHqY20SFN+n16loL1QXd09uodbIC7OZYtiIFQ+g9n8U8whtKNOtDV16E5ZPkcyk7VGzgNHIEi/Mjo71GXOW9wSS8oItBX9g6qVUyjzUkucuTHQTydgeKA1VMvpdbjPzEO88pUNC5 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2017 20:52:57.7382 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1608 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.40.60 Subject: [Qemu-devel] [RFC PATCH v4 10/20] vl: add memory encryption support 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: , Cc: Thomas.Lendacky@amd.com, brijesh.singh@amd.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If memory encryption is enabled then create memory encryption launch context to ensure that bootstrap data (bios images) get encrypted. Also release the encryption context after machine is succesfully created. Signed-off-by: Brijesh Singh --- vl.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vl.c b/vl.c index 71b75ef..c6e7846 100644 --- a/vl.c +++ b/vl.c @@ -4521,6 +4521,14 @@ int main(int argc, char **argv, char **envp) current_machine->boot_order = boot_order; current_machine->cpu_model = cpu_model; + /* If memory encryption is enabled then create encryption context. */ + if (kvm_memcrypt_enabled()) { + if (kvm_memcrypt_create_launch_context()) { + error_report("failed to create memory encryption context"); + exit(1); + } + } + machine_class->init(current_machine); realtime_init(); @@ -4671,6 +4679,13 @@ int main(int argc, char **argv, char **envp) vm_start(); } + if (kvm_memcrypt_enabled()) { + if (kvm_memcrypt_release_launch_context()) { + error_report("failed to stop encryption context"); + exit(1); + } + } + os_setup_post(); main_loop();