Message ID | 20170418211959.10190.3481.stgit@tlendack-t1.amdoffice.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <kvm-owner@kernel.org> 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 B1C27602C2 for <patchwork-kvm@patchwork.kernel.org>; Tue, 18 Apr 2017 21:24:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A240F2094F for <patchwork-kvm@patchwork.kernel.org>; Tue, 18 Apr 2017 21:24:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96C18269DA; Tue, 18 Apr 2017 21:24:41 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46A262094F for <patchwork-kvm@patchwork.kernel.org>; Tue, 18 Apr 2017 21:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758059AbdDRVUX (ORCPT <rfc822;patchwork-kvm@patchwork.kernel.org>); Tue, 18 Apr 2017 17:20:23 -0400 Received: from mail-bl2nam02on0061.outbound.protection.outlook.com ([104.47.38.61]:22878 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758055AbdDRVUO (ORCPT <rfc822;kvm@vger.kernel.org>); Tue, 18 Apr 2017 17:20:14 -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=M6xVlxngATxdpp66Jl8udDKNhnRIbVRw/AR5xLtlL0E=; b=4rTbMRDADNThScsZWJvsfJ5rHtktmTiruaSSoTSAPCnJK8Ln8CuSjGjQVanbTmJWx92xBchyvRBl6ZGtFr/gCHzqAMwFtFGUh8b3C2y60NDwhIrXcmgH9hcuFuLbdIDHCFr2OSUSMAXYfSsxET9PUamKRyDtdBjPtM/PDzWK7ls= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from tlendack-t1.amdoffice.net (165.204.77.1) by CY4PR12MB1142.namprd12.prod.outlook.com (10.168.163.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Tue, 18 Apr 2017 21:20:02 +0000 From: Tom Lendacky <thomas.lendacky@amd.com> Subject: [PATCH v5 21/32] x86, realmode: Decrypt trampoline area if memory encryption is active To: <linux-arch@vger.kernel.org>, <linux-efi@vger.kernel.org>, <kvm@vger.kernel.org>, <linux-doc@vger.kernel.org>, <x86@kernel.org>, <kexec@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <kasan-dev@googlegroups.com>, <linux-mm@kvack.org>, <iommu@lists.linux-foundation.org> CC: Rik van Riel <riel@redhat.com>, Radim =?utf-8?b?S3LEjW3DocWZ?= <rkrcmar@redhat.com>, Toshimitsu Kani <toshi.kani@hpe.com>, Arnd Bergmann <arnd@arndb.de>, Jonathan Corbet <corbet@lwn.net>, Matt Fleming <matt@codeblueprint.co.uk>, "Michael S. Tsirkin" <mst@redhat.com>, Joerg Roedel <joro@8bytes.org>, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>, Paolo Bonzini <pbonzini@redhat.com>, Larry Woodman <lwoodman@redhat.com>, Brijesh Singh <brijesh.singh@amd.com>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>, Andrey Ryabinin <aryabinin@virtuozzo.com>, Alexander Potapenko <glider@google.com>, Dave Young <dyoung@redhat.com>, Thomas Gleixner <tglx@linutronix.de>, Dmitry Vyukov <dvyukov@google.com> Date: Tue, 18 Apr 2017 16:19:59 -0500 Message-ID: <20170418211959.10190.3481.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> References: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR1701CA0008.namprd17.prod.outlook.com (10.172.58.18) To CY4PR12MB1142.namprd12.prod.outlook.com (10.168.163.150) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8b42d8ac-0a0e-4683-841d-08d486a0aec5 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:CY4PR12MB1142; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1142; 3:OdlDrdUt0w+Us59x4YpwWQO/KqO0rhFElQ1YyYYjXbMIb5bSShKxNbPGuxQaRYWblUfhJt5nEjMtKsHIdSBE1DO3ElcPBd+m6FDTwsvkeYkvJ9gJmzOE8CRktVSwU5A8kfdGjnk4eNTbGq7cGIEqqGWjqKpXO9LPgeRe+5HXl8jVAPwkv+0BXB2Nlzz8FWAn+iqSIgyLAaxb1yK5mDmV+3Cw89rRdq9bP0jW0w62uRzWc9dpVK9lFrHMDs8ThQeFJLNmcgQhIBdar2mRsMMCQQKqriMkb76aKmd0kp4l+ZsmgmvoGkYSFYFTfnBolZghLZBvxCI/sq20/XVg8l1OCUo3U9Z3vEj8tD+/Nm7/VTk=; 25:JBHyn/V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fsnr1G+SrH2bNWIc/hkntYNlxYw+CoVo+pLwli/6y4a1wQVs3veoUFdJZyHQW93bwXgGqDneoE4jhsFPdZH7lU3Fu03+2+56CMfk1PPLIyzyLVX6Vn2d+alU5VsKnYuyYRj6hiKpSw/fHgNFGTO43AIG4Q3ZNxrUzSDfBJpi2FK2W+zUYLpJJ X-Microsoft-Antispam-PRVS: <CY4PR12MB11424543202D987C642D417EEC190@CY4PR12MB1142.namprd12.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123555025)(6072148); SRVR:CY4PR12MB1142; BCL:0; PCL:0; RULEID:; SRVR:CY4PR12MB1142; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1142; 4:89AG3aaDmUoLsT17LQtDYtHh/CTgPfneLNMUrWU5k4BnitJGKqLiO244I7wwLWxQvKMerpE9EtvlILienyRCQvNgGN7PriDQSO9qLxGrRKzCD9vvEAV8XXxzow84dTRVjlUVbaGiKeTiIVp4Tk92f6gmEeVXne1lrqHltiuAUPwnA2i8fQ6C5TMrLYB4Orze9+dsO3qCQmmkMWvH1lopOsGD2SsJhc0ePV62is0N099tUtx1SBMX0n0YJIFPvyL5Ye5Tneoe6olersBa4ILJSBDpxMzmLokrPBNT4N0undZa3aldIsAPbhVIVMZDA+H/81lvHbHntJsOOYRlEhTDQg5Ky6lUYtyRMEbQrQMzq81XGf7cNQeuZIZxeFlcCj1Bx9BdPzAfJMxqEmKbm3IUoborjUn+SNOZXNxaGxPsvadcH1w1QQa45cIYK15E+K6aXAJCsOKoSSHeMy/jJo15/0Iz1S2K+3cYTeng0NLPUPfdBg2dVv7jI+qLeFZ6+w19ZBcgzFntluvM7Q0vKspar14died/P5qMNY75KjJKGRb9n2wxQQDGgTUtMAw/1SZ/FwCGgL+FqXr1NgGI92ZDbxH6O/LwlwoRPliffLss3vLBWO5tlqm7eVDb3wL5vnf/OcMCLRS0Rawqo0/IRJAm5O8wHy+jguGKYG4Ui9EI6VZKrTtlQTpzkrdBtvy0G1p6BvkZC+ctM5ROjVfQppxvBIl/mSaK4pIHaUZ+JIiZP8N0pNQeeZqLtlZNfYmKYVikjz1IlISKoCikNViamUOL3g== X-Forefront-PRVS: 028166BF91 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39410400002)(39400400002)(39850400002)(39860400002)(39840400002)(39450400003)(33646002)(81166006)(7416002)(5660300001)(8676002)(7406005)(189998001)(50466002)(103116003)(3846002)(2906002)(25786009)(4326008)(23676002)(66066001)(53416004)(6116002)(6506006)(54356999)(9686003)(230700001)(1076002)(50986999)(54906002)(2201001)(53936002)(76176999)(7736002)(305945005)(4001350100001)(83506001)(38730400002)(86362001)(42186005)(2950100002)(6666003)(55016002)(97746001)(47776003)(921003)(71626007)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1142; H:tlendack-t1.amdoffice.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQyOzIzOkJjc3pTcUt0UHdxZkZUTDdHV2RTR29ycmVX?= =?utf-8?B?VTgxWnYzUC9Wd3IyRS9VVk9rL2dvYUpXbWNrOCtXandvY1JOa2gyOVd5WU1a?= =?utf-8?B?RW9rQjc2em0xMEErUWlPbXR4QjA0ckZyQWF2amxBSVhQd0ZodFhYVVNpWkF6?= =?utf-8?B?NDdUUHZRNFZ6OU1TWWxLTnhjeVZ6WVpXQ2VnMW1lM1MwK1BUemlQNmc2djIy?= =?utf-8?B?WkI1bXZwU285VjJrWVNSYWplNzdiSXNpSmNaTDJSN0lpdndFZ3FWdGNXcU1i?= =?utf-8?B?Y2tiTUMwaDNCbVBLdG5pM2Z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Vvaf2s1+1g9F679A/1btrkL/E=; 5:xmJTM3jNKQape5hQPEFZ+WYFGEwAFrEakMTqQ/GAlj8V0uAcVCb4q6B1ryvxqHtKNQMAf0W8tvKP6sY3ascwaf2jdW8T6I4+LErdmD/LE9pbsHg9a9VycIC5SSXgZsjv9g3SyRkvrPP8WmqvWelmyQ==; 24:m5UcPqRJ+jtdOVF736ruS4iv+9guyAr+pVoY8wExscx54Z0qHBoBL+cxAXS/iEMyvvHxGqXplySS2LsRDhCNo9sNhiES7o7jxrHJp3xXwJc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1142; 7:BQlmMwGCm9dkYrFihCreIfhRz511DrvBEYft05IcA9FJqQ0TZY9Q5iqD3aleve8BftaZMEy7mO+QFkdWLmMj/6b+QGe3mbEBRE4GRzWg6s42PuUPLe1iVh2I0mmLFnYAfRAMRPtXZIuI1KsR2Hsx9J7uCfgk3AbioQoPw6uBPI51zSdgIXiDaD4ir7+mRdJJiZdIAEtiwAnNwsMVKZiuIEDsf+cPlSn3DMtCQ4rbTbXMqCVPwKHlxx+AyYuJp+B9wCgNBEnzm5mb0Zh3ZobXmOQ4uqotA5BKCVPdeY2wCcKqe8mvxIFQksnan7+BnFI+TXK4uUVvyrt+OnafC8TI0w==; 20:d5dsSwzawgLxW9q/jI8t6Q9Od5ZHq7nLHUAl0SKlwLjPZu81R/GjRG8SOzISZz5YJLbGdYSJiCZZoiUMQJvz3FHQxkMqQPyVmZaixdSMmcPRKHL2YbEteDzef9GSLw2rQQxi+/dEynH7wd6GW/G/++HyXBOKsXeZxiDQJKgNlc5ljJ2kqTeKO2zvRV1Xys7f4dDkGfcjSV4ND9jkDrmATJTxPKkVS0uKGWYKZQdCwYKnYHfRl1jFjsTJxOE79CQI X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2017 21:20:02.5610 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1142 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: <kvm.vger.kernel.org> X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c index 5db706f1..21d7506 100644 --- a/arch/x86/realmode/init.c +++ b/arch/x86/realmode/init.c @@ -6,6 +6,8 @@ #include <asm/pgtable.h> #include <asm/realmode.h> #include <asm/tlbflush.h> +#include <asm/mem_encrypt.h> +#include <asm/cacheflush.h> struct real_mode_header *real_mode_header; u32 *trampoline_cr4_features; @@ -130,6 +132,16 @@ static void __init set_real_mode_permissions(void) unsigned long text_start = (unsigned long) __va(real_mode_header->text_start); + /* + * If SME is active, the trampoline area will need to be in + * decrypted memory in order to bring up other processors + * successfully. + */ + if (sme_active()) { + sme_early_decrypt(__pa(base), size); + set_memory_decrypted((unsigned long)base, size >> PAGE_SHIFT); + } + set_memory_nx((unsigned long) base, size >> PAGE_SHIFT); set_memory_ro((unsigned long) base, ro_size >> PAGE_SHIFT); set_memory_x((unsigned long) text_start, text_size >> PAGE_SHIFT);
When Secure Memory Encryption is enabled, the trampoline area must not be encrypted. A CPU running in real mode will not be able to decrypt memory that has been encrypted because it will not be able to use addresses with the memory encryption mask. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> --- arch/x86/realmode/init.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)