Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753350AbdLUWCx (ORCPT ); Thu, 21 Dec 2017 17:02:53 -0500 Received: from mail-bl2nam02on0041.outbound.protection.outlook.com ([104.47.38.41]:39601 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751024AbdLUWCt (ORCPT ); Thu, 21 Dec 2017 17:02:49 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; From: Tom Lendacky Subject: [PATCH v2 0/5] 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, 21 Dec 2017 16:02:43 -0600 Message-ID: <20171221220242.30632.5031.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: SN4PR0501CA0123.namprd05.prod.outlook.com (10.167.128.40) To BN6PR12MB1137.namprd12.prod.outlook.com (10.168.226.139) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: aa0598da-773f-4412-c52c-08d548be9232 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060);SRVR:BN6PR12MB1137; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1137;3:FsSDJfiZrMnjg1PZSKTrKc58n/x1J639ID5nRn6uzYR4/1922LD7MeeV6YU5bgXkLhL1LCTzPXZl4dOA0QcAQN93sLTyMao5vysq11Z8QoLJHW+Pzh5L260zWQeuMbu4qQGWr/XRfANlDVtw9twvknoxPM5kV443ggdDqGYeVHdTSELM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5OTnUTNRbYRTYHOMugEHax15dc0utaNC7Xm+J0L+Wrp/YCyJCRryDr0ELwMW4OB+b8phSwHbDrkcqM6LeRAeibgo4LbKo4LEWiTicUlDPahR9SBcBSdtOHJTPmBDKxzKulnf/MRg6el4Bqxxr4JDFP7oim6+KfNEo7O3zgYR+0KUI;4:QtUs7NsMgcyZw01e1naCinv3/+/wBHB02uDV0elonYmnKg1rhq5Y/94B621ATMh5BngExrQcqqYLL3Hsj0BtP8DN2TUUxaq+57ocmtOFR52ZEJhO+lkbsTQZMndrnq76nuZmSktQaR1tDcjj5ePpMrc2NQ2bqPktqxOknSx0MJD95iHeCtRZF9ZhbcT9I5zCgnG5Admdkm9K6baGIgtK1+1YRN5P9/LISukyAJuhZcK0I4w1pdSXPogxxhsIhvoY5EsD3Ly1zN95AO7DyhupFQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(3231023)(10201501046)(93006095)(93001095)(6055026)(6041268)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011);SRVR:BN6PR12MB1137;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:BN6PR12MB1137; X-Forefront-PRVS: 0528942FD8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39380400002)(346002)(376002)(396003)(366004)(39860400002)(189003)(199004)(7696005)(6666003)(2351001)(83506002)(54906003)(6916009)(15650500001)(68736007)(305945005)(50466002)(2361001)(97736004)(58126008)(16526018)(86362001)(66066001)(316002)(105586002)(97746001)(72206003)(7736002)(478600001)(1076002)(47776003)(23676004)(55016002)(81156014)(106356001)(81166006)(230700001)(53416004)(53936002)(6506007)(8936002)(103116003)(3846002)(6116002)(2906002)(69596002)(5660300001)(9686003)(25786009)(8676002)(4326008)(2486003)(52116002)(386003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agnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1137;20:cnqhOafeP0EDod5vaNRgjGrUXK5YybBFXkSubMgir7ZXAbxL/6x5WnkuvFUK8yymEF4VI+jmkeR0lnH82ZsS20FS6f7jrwWtT0ISa+goeCl8Ln+36hgY9vGSMXiA7HguxLILL6AxXyaUVgYwz0BFcTm4fDoKv4hNPbUgPmHtU5Ka5XWAgzagJcDmwTGYd/hGc/WWsqBsGm6N4ac3jMnEoiepwCIRVhrRLvmkPEZ4NgAnkbgg88eB3/nDGiAQgX3k X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2017 22:02:47.1267 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa0598da-773f-4412-c52c-08d548be9232 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1137 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2279 Lines: 52 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: - Cleanup register saving in arch/x86/mm/mem_encrypt_boot.S - Reduce parameters and complexity for creating the SME PGD mappings - 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. --- Changes from v1: - Additional patch to cleanup the register saving performed in arch/x86/mm/mem_encrypt_boot.S in prep for changes made in the remainder of the patchset. - Additional patch to reduce parameters and complexity for creating the SME PGD mappings by introducing and using a structure for referencing the PGD to populate, the pagetable allocation area, the virtual/physical addresses being mapped and the pagetable flags to be used. - Consolidate PMD/PTE mapping code to reduce duplication. Tom Lendacky (5): x86/mm: Cleanup register saving in mem_encrypt_boot.S x86/mm: Use a struct to reduce parameters for SME PGD mapping 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 | 355 ++++++++++++++++++++++++++---------- arch/x86/mm/mem_encrypt_boot.S | 80 ++++---- 5 files changed, 309 insertions(+), 144 deletions(-) -- Tom Lendacky