Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752248AbdLGXdu (ORCPT ); Thu, 7 Dec 2017 18:33:50 -0500 Received: from mail-co1nam03on0078.outbound.protection.outlook.com ([104.47.40.78]:48480 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751010AbdLGXdt (ORCPT ); Thu, 7 Dec 2017 18:33:49 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; From: Tom Lendacky Subject: [PATCH v1 0/3] x86: SME: BSP/SME microcode update fix To: x86@kernel.org Cc: Brijesh Singh , linux-kernel@vger.kernel.org, Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Thomas Gleixner Date: Thu, 07 Dec 2017 17:33:42 -0600 Message-ID: <20171207233342.29646.12858.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: MWHPR2201CA0074.namprd22.prod.outlook.com (10.174.103.27) To MWHPR12MB1151.namprd12.prod.outlook.com (10.169.204.15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc7bd0bd-482f-4d21-6b70-08d53dcaf676 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(48565401081)(2017052603307);SRVR:MWHPR12MB1151; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1151;3:q5mwrByTr/uqGghbADbm/Bj1vTM2C5tFXocvKcyQL2UJjLoa/mSXPaZt3GRaIyd5e9XkqkhE72YiaXLSwbBIJPeh0DiH/Jg5TQ8vGlfi16l3h/FtH+Cy/RFWWHsTvZ5tpPQrauA1MJITr3Gg34z9fY2SIMCHCUErAEbbp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Tb7GQFFnrQBdlnsQF1w4tUmBsQTCKO42O5uvISsaCJWAUwlnMAzVnUeaR8JGflXLR1eGVBZSYhCb3o3wlxAnroTPtz21N82f7UGOXULu9ssImBZE9KiR1lFDxft3sWjTzUNsQE0XTasU3Aduyu07ZEdOg9q+3V0HkfUTu1CO7SnS0i2SDbPHGyCtnE;4:q2nPpKmv7DOtPLCiUGbBTKMD1C30OKTz4imLFe9Efuqs9xdhD/3/LFp2UM8ysGN7g6yPqsVdiW9eu3TOuVknibwbV/dMvNq/zXi8Wq9cTww2CErewjp0EYQt/XsMF0rNWhYMy+dkPREZJS4DoGGCEqAjT5QWEyjaYgf5dNDQxJBqcvF5UF1P4E/7J1EYcAInFmDpFE00hwY1CRZcbhWyNHb/unAIhMT4CGTa26Zi10wm/d4clxtiFUGJzEuMERuq09nsOmv3hAlFowUgYlMwpw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(3002001)(3231022)(93006095)(93001095)(10201501046)(6055026)(6041248)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011);SRVR:MWHPR12MB1151;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:MWHPR12MB1151; X-Forefront-PRVS: 05143A8241 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(346002)(376002)(39860400002)(366004)(189003)(199004)(4326008)(105586002)(2351001)(305945005)(97746001)(8936002)(68736007)(2906002)(7736002)(106356001)(50466002)(33646002)(1076002)(83506002)(69596002)(6506006)(25786009)(9686003)(66066001)(2361001)(55016002)(103116003)(47776003)(3846002)(230700001)(16526018)(6116002)(8676002)(5660300001)(81166006)(81156014)(54906003)(316002)(6916009)(58126008)(53936002)(478600001)(97736004)(86362001)(15650500001)(2486003)(7696005)(53416004)(52116002)(23676004)(6666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STDJnPT0=?= X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1151;6:9phyZ/9DETaGfEMdKKnSibRHsjIkdkPcJEjgdL1HIyHGvzJ4pe93DKw+dPz+zY3TSh+cCR6aj3ngiN6hbOuWKpEWKnEOAGYvhCQxqf9uKu4MgYYDpPDRV/4SFmYLwcEUg+c2y9NJQOLGyLhkC0dxxdkVo1ZX/0aBa6bOd0v18/T7wVgtNS88Wu8B56brRuANS2nY9vAAaOL7qlZS8pCPPKWnrruFW5GPT5Mom82aiRbDZmDwcZFRUNAanCu1k7azani94B2KklTVCpaaR1YdI3QERPBigP3F6ZSYg8Cu3gTnVkNdSpx/fWvxBCf4GZPa2mxaohg/g1sBfopR/RYD9DYDDTcOfUB90VYt+JCfkkg=;5:Jb79kJioCr4H7W7WppH28BqUssmK88voE6kmCn/xpKtAGgfQAvPA+pWE9CGbbme5LiAS1RlT+YrJICjCgT2vpdDanaS+DtQr9NCRlDz5TenWrKkWQkeT8W1A8Ox6h+msa9llsBrh2HcSdNYJqdL7WSBxWw1S1h4zNMLF9mWkKvE=;24:gx1xQGXe7KRUM3lTvm2U1xUDYJXJx4mEHGNSJU2ao5RvuMVZ94mdvKVp1iysTO/o1Sj7YE+X3jHohWZRnhVUPwbFUta12AH+gJCgyVfHCIM=;7:rY6h5LwiDevwv0VhWYw6kY42EFCXr5Xk2zatm+HHpT4NkZvcwfCsH4gA5VauYZdAALHKMpz5FMvbGT78lJcBcfdeHwN47MpdYFPOYrsJCExs2A8nNRAuM6Y6tPfqwYHkklw6PLrBh4PNrvJ4rTwnquiO36hjzT47T3atZYTD+P7U+hpKirlZ+kns5vGGq0/x/Y5Ev2REFpSMlX1D1WBJV+o3b9cgrtiU3kzC/t7MSEeA5N5vtSNQefloykwMF8s6 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1151;20:bWiHwFA4U04fIAq/P7keTK6cXcQ4le14Lno132NfoE5UdMeLr4R/QubJs8X9HvPhsXywd6aX3lASlzWWkjdIiaUNY8Lh6Pdg6qVDf65aSeOhC0nbaLIxIYbVbB+rxDiTvKsw8rS0RSm0N1HBTSovd95GDjyhoQqIgN2vNJzGe42UCGf3cT8Hfn3WcfEHgOmn+pT8osGdh7Z1il7w1GfCqY692ycVgoI/rhvOtQllGDGh+1NxWbH73axniansPpVz X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2017 23:33:46.5124 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc7bd0bd-482f-4d21-6b70-08d53dcaf676 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1151 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1512 Lines: 38 This patch series addresses an issue when SME is active and the BSP is attempting to check for and load microcode during load_ucode_bsp(). Since the initrd has not been decrypted (yet) and the virtual address of the initrd treats the memory as encrypted, the CPIO archive parsing fails to locate the microcode. This series moves the encryption of the initrd into the early boot code and encrypts it at the same time that the kernel is encrypted. Since the initrd is now encrypted, the CPIO archive parsing succeeds in properly locating the microcode. The following patches are included in this fix: - Centralize the use of the PMD flags used in sme_encrypt_kernel() in preparation for using PTE flags also. - Prepare sme_encrypt_kernel() to handle PAGE aligned encryption, not just 2MB large page aligned encryption. - Encrypt the initrd in sme_encrypt_kernel() when the kernel is being encrypted. This patch series is based on tip/master. --- Tom Lendacky (3): x86/mm: Centralize PMD flags in sme_encrypt_kernel() x86/mm: Prepare sme_encrypt_kernel() for PAGE aligned encryption x86/mm: Encrypt the initrd earlier for BSP microcode update arch/x86/include/asm/mem_encrypt.h | 4 - arch/x86/kernel/head64.c | 4 - arch/x86/kernel/setup.c | 10 - arch/x86/mm/mem_encrypt.c | 264 +++++++++++++++++++++++++++--------- arch/x86/mm/mem_encrypt_boot.S | 66 +++++---- 5 files changed, 243 insertions(+), 105 deletions(-) -- Tom Lendacky