Received: by 10.213.65.68 with SMTP id h4csp9541imn; Tue, 27 Mar 2018 15:08:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx49v6Ut8Ken39mbFe6re5poptslIi6eGN23nLxIcnPDFVDMcplSHkZe4copmrYSAY1v7iSMJ X-Received: by 10.99.156.17 with SMTP id f17mr713173pge.102.1522188522967; Tue, 27 Mar 2018 15:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522188522; cv=none; d=google.com; s=arc-20160816; b=L+/cBo2sIcLfCIYCMSs3PXTqcWHTSjYJhDunniBQ28ZUou+UfwkRU5YwkqhnuiJ7So e0GOiTQEDq8xAX6E1jEEnXgpVF2qLkhjtm2kvoaixtCuAQuSu6LgqsrQaKe0BJ8ctIs1 NyCkF/k2noQQ70oBRrCZy9buaPTN6e2R92yCgKsjdc/AUTvKXHnxtL9l3BFNtZnaEuFL 8K3G9ckdinkqZMMJP2agsF2SKnt80KH7+VaVX/4vbD5kFmAOB/eV+mXGCdqA6MLD7FPW b0LZCoX0BEHkRSS5f8mRlibgT0ufOfzCUrOSz5BNatCmj1ORZx4N4njfphE7IkELiz/o qs1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:subject:from:dkim-signature :arc-authentication-results; bh=1dNxI+qJ4Mkg6Sz7vCrbC5GI44Tljni98DvGZdMi8F8=; b=AtuAH/0okECm7JwvROcWjEioEz/pVP84wDUHv+sTXmZG7bhe8M9ywx6xfm2l0wsPTZ C9yNRSknQjxQNZUcR9/FkLYWA7BxaNQP8zRTxxEH4xg14LXyl24IJh/sragMB4szx7q9 DH/jtwv0MqPXO7EZvSwizwwJEZstqFIajeXDTPHsZ+uUqm6qdaV6alNPx6sDQQDUqYDP MqYAiGV9Gpq6FnZ6VOWbLtxhYjCTGi0ZMQGIPW//uioZzZgo9bXch1ZekDU3wvSfcwTJ OYsogB5L0Dik98OaKpFkuOKWGU9tcq6z7IcqwrTgWds/hM+RBOH/WOpnwx4o9RYE4Po9 u2qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=ZW3XHwOn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12-v6si487939plr.69.2018.03.27.15.08.28; Tue, 27 Mar 2018 15:08:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=ZW3XHwOn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752342AbeC0WHW (ORCPT + 99 others); Tue, 27 Mar 2018 18:07:22 -0400 Received: from mail-cys01nam02on0079.outbound.protection.outlook.com ([104.47.37.79]:19955 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752296AbeC0WHT (ORCPT ); Tue, 27 Mar 2018 18:07:19 -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=1dNxI+qJ4Mkg6Sz7vCrbC5GI44Tljni98DvGZdMi8F8=; b=ZW3XHwOn3A/qOWY4/8qlnsJQs/uPxzwqdIVkioVsrGBuPl0HP7e0cwwejOVrUxrKP1GchDhibLTCv/DGAVD2oGPNWu1L3/fE1Y50lebvgxtMeBJIFR2bnc3rqwyD7IXVjB53FlsuK79Era0NG9hYKoZVOAgLytuHA3JTZxfHs3w= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from tlendack-t1.amdoffice.net (165.204.77.1) by SN1PR12MB0173.namprd12.prod.outlook.com (2a01:111:e400:5144::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.609.10; Tue, 27 Mar 2018 22:07:15 +0000 From: Tom Lendacky Subject: [PATCH] x86/boot: Fix SEV boot failure from change to __PHYSICAL_MASK_SHIFT To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Brijesh Singh , Borislav Petkov , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "Kirill A. Shutemov" Date: Tue, 27 Mar 2018 17:07:11 -0500 Message-ID: <20180327220711.8702.55842.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: BN6PR05CA0031.namprd05.prod.outlook.com (2603:10b6:405:39::44) To SN1PR12MB0173.namprd12.prod.outlook.com (2a01:111:e400:5144::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7664aee4-fe6b-4f9e-1185-08d5942f19ef X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(2017052603328)(7153060)(7193020);SRVR:SN1PR12MB0173; X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0173;3:FbThS9fbEp4LDHhm7Nvxxa9BpUzQSfvc1VSrA1SlLHUbheYy/CvSuXw6MI1BWSXqapkzV4kS8HWIl3YY0SusKX1woLpP5N58atc+FbLdhxXPO/19gZElJQZ6lM+lt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L0e/eyiCU04sDq/N0vPZxnG+hZ0NIkqty1lpMP4EhnI/10kNm3cjo7zKWyeqV71Zf+wT7pu6JaEuT10U6GkNDXUvx4L5LjERHIY7Si4wzv5b6kLpl5+BuS5YN4tTlb2rY/82+9IWdfr30qOeZSum6RHwufpg+xEVbUBYtrW6esGkjcMakWyDVNbvaAJdeBZlJRixTfciEeY7xOfKrBP7A8CeZW/cuPNHd;4:RCWyZcH2mrQBznHEOaRsRtQxHhO+T+hBYbeWIz1/eUtkMdpFgUocWH0qbdQOdRxBPG42+wqJO+Ef4DnBhFIBoUSJ/d36zVW6ABbheTtoIBDxmjuTfvBcurIapjPEqkZaXG1S3/IBszM4GZKoEEgC95xSuNGDFSJo0F3ciRRbbqsbc2P41+b1uoeBzxdWzp8VFTRf0qaNHqMa/DTpGIFOeveaBdeF5GzNHJyHBlBOoaFyKGlff1iY/ldh/GYF6vglum7WKelw8ph2mRRSCM7zpBeIzdSbGdxYa45B2L0syslsGKTkD3XjN8EZEoCzMKam X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231221)(944501327)(52105095)(6055026)(6041310)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:SN1PR12MB0173;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0173; X-Forefront-PRVS: 0624A2429E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(39860400002)(366004)(39380400002)(189003)(199004)(86362001)(230700001)(2906002)(105586002)(25786009)(81156014)(53936002)(81166006)(50466002)(486005)(69596002)(486005)(476003)(7736002)(72206003)(16526019)(4326008)(53416004)(8936002)(2486003)(59450400001)(7696005)(956004)(26005)(58126008)(6506007)(386003)(103116003)(305945005)(478600001)(54906003)(9686003)(52116002)(55016002)(97746001)(66066001)(6116002)(23676004)(47776003)(8676002)(6666003)(106356001)(68736007)(97736004)(1857600001)(1076002)(3846002)(5660300001)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR12MB0173;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtTTjFQUjEyTUIwMTczOzIzOnVHN0t2cWorRE81NW9UdU9Ydms3U1Q5OVUz?= =?utf-8?B?RitmUVo4QW1iMnE0Z3pnVGdGcy9VQnllWmpjdUlpMUpZTlpOMHdaNS9sdWMr?= =?utf-8?B?Tmc2RW5RK0dYL0huUGtFeEUrUVhoWkxEQ2thVDMwS1B5c0pZdXYySVNLMWUr?= =?utf-8?B?dWE1U1lJeXp6Q1JRekdHKzhKQjhlS0xrMWllTGlsbHllaHJhb2xtS0NXMWRE?= =?utf-8?B?SGJLU0MyRnY1Zlk2QUVjd1g0amFkblJIb0MyOEFURERkS1MrMlVjVXN6STYx?= =?utf-8?B?Z1M4K2NuQ3IxZXlBbTN6TDR4YnZPZWxsa1pSYkpxUEhCT1dmVFM4MGRqMW56?= =?utf-8?B?WU5BWThibVVabjZuUml5ZnFoaFJnYzRjeW9zYjE0QTVvTTF4RWpicllDbXZH?= =?utf-8?B?ZnFKVkNJeTJOdDl6Z24zWnErSjg3Q08vWjU2UWVPaUJEUTNUU2x2WER5Ullr?= =?utf-8?B?MmEyT200dk5ETVdPeGhraHhMb1dleU9sNXFXRmlHUmdsQy94MEhaYUxBZFpl?= =?utf-8?B?S3hDcElIZ0h0cjYxMHFLOUpibmJQSXE2dDNZeEtKNEhQaHdKRjYxMUNwSkRL?= =?utf-8?B?NzcxWFVkazFzMEFHcUZHZFdtN1JidGYrWUk2YzRxdDFqNHU3WE1aNEpQNEdC?= =?utf-8?B?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0ob3zMgsfoLQgqPoZqS1pvliLzYti6r4vDPPfK387FXTwE2mp8ltVwQ4R3KqKPh4F4R4bC0=;24:P4A2Z9iveaMxp75kOkrNg9VOylO5wUM6tEh8S90XsDgGUeD2y/8s85M0WVS/gt86jnVYwvnALFLxhOwBRZwQJOwjSpWzv+herub49aWUazw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0173;7:dvwKbEx1ElE4D+520ukSGeoa4w6XjI/fjsEE3maHpBLU1wfV1fpqaNWEBAx6LGjCNZTzfHJF+Wrguzk0bESu8saUYWQUOF3NfiuGHfiMJHYRollekrIjWritMnYYcApM7jysPVOQSBJL6XwrGL7D8PCkBUwv8GarTrVtf/WdnS5mBiYr4t/ZM2QdfRnpiw0OSkBUn4AQ0bgI5WgP88eQgm6SEl/9Nv6CenEcoenPWCB1agl8xeElMQwXkCuFXaRO;20:vAWhUPrAsMwSPFELAb4Okpjp9mA677/cXXhSBCEs1sza/iwdqLwGxvFLebgz47QsNzt2sT8Ju/YI+sNJZuFebU1BXET0lAsVAtE9ILSnF5c50pLuW1v/NZJGf35FcUzperLp8KAXQcUhzfSnzR+WLg1+QWc7Hf+34CDviZLp+YhpC1l9+s3ncen8BsyUyhzzFnhRO0gPShFtJhVz3jUGUuU8MMvCK3O38ztXv5vlvM625h4rU3uFJL27M9odXzeg X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2018 22:07:15.1171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7664aee4-fe6b-4f9e-1185-08d5942f19ef X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0173 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In arch/x86/boot/compressed/kaslr_64.c, CONFIG_AMD_MEM_ENCRYPT support was initially #undef'd to support SME with minimal effort. When support for SEV was added, the #undef remained and some minimal support for setting the encryption bit was added for building identity mapped pagetable entries. Commit b83ce5ee9147 ("x86/mm/64: Make __PHYSICAL_MASK_SHIFT always 52") changed __PHYSICAL_MASK_SHIFT from 46 to 52 in support of 5-level paging. This change resulted in SEV guests failing to boot because the encryption bit was no longer being automatically masked out. The compressed boot path now requires sme_me_mask to be defined in order for the pagetable functions, such as pud_present(), to properly mask out the encryption bit (currently bit 47) when evaluating pagetable entries. Add an sme_me_mask variable in arch/x86/boot/compressed/mem_encrypt.S, which is set when SEV is active, delete the #undef CONFIG_AMD_MEM_ENCRYPT from arch/x86/boot/compressed/kaslr_64.c and use sme_me_mask when building the identify mapped pagetable entries. Signed-off-by: Tom Lendacky --- arch/x86/boot/compressed/kaslr_64.c | 14 ++++---------- arch/x86/boot/compressed/mem_encrypt.S | 17 ++++++++++------- arch/x86/boot/compressed/misc.h | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr_64.c b/arch/x86/boot/compressed/kaslr_64.c index b5e5e02..522d114 100644 --- a/arch/x86/boot/compressed/kaslr_64.c +++ b/arch/x86/boot/compressed/kaslr_64.c @@ -16,13 +16,6 @@ #define __pa(x) ((unsigned long)(x)) #define __va(x) ((void *)((unsigned long)(x))) -/* - * The pgtable.h and mm/ident_map.c includes make use of the SME related - * information which is not used in the compressed image support. Un-define - * the SME support to avoid any compile and link errors. - */ -#undef CONFIG_AMD_MEM_ENCRYPT - /* No PAGE_TABLE_ISOLATION support needed either: */ #undef CONFIG_PAGE_TABLE_ISOLATION @@ -85,13 +78,14 @@ static void *alloc_pgt_page(void *context) /* Locates and clears a region for a new top level page table. */ void initialize_identity_maps(void) { - unsigned long sev_me_mask = get_sev_encryption_mask(); + /* If running as an SEV guest, the encryption mask is required. */ + set_sev_encryption_mask(); /* Init mapping_info with run-time function/buffer pointers. */ mapping_info.alloc_pgt_page = alloc_pgt_page; mapping_info.context = &pgt_data; - mapping_info.page_flag = __PAGE_KERNEL_LARGE_EXEC | sev_me_mask; - mapping_info.kernpg_flag = _KERNPG_TABLE | sev_me_mask; + mapping_info.page_flag = __PAGE_KERNEL_LARGE_EXEC | sme_me_mask; + mapping_info.kernpg_flag = _KERNPG_TABLE; /* * It should be impossible for this not to already be true, diff --git a/arch/x86/boot/compressed/mem_encrypt.S b/arch/x86/boot/compressed/mem_encrypt.S index 54f5f66..eaa843a 100644 --- a/arch/x86/boot/compressed/mem_encrypt.S +++ b/arch/x86/boot/compressed/mem_encrypt.S @@ -88,9 +88,7 @@ ENTRY(get_sev_encryption_bit) ENDPROC(get_sev_encryption_bit) .code64 -ENTRY(get_sev_encryption_mask) - xor %rax, %rax - +ENTRY(set_sev_encryption_mask) #ifdef CONFIG_AMD_MEM_ENCRYPT push %rbp push %rdx @@ -101,9 +99,7 @@ ENTRY(get_sev_encryption_mask) testl %eax, %eax jz .Lno_sev_mask - xor %rdx, %rdx - bts %rax, %rdx /* Create the encryption mask */ - mov %rdx, %rax /* ... and return it */ + bts %rax, sme_me_mask(%rip) /* Create the encryption mask */ .Lno_sev_mask: movq %rbp, %rsp /* Restore original stack pointer */ @@ -112,9 +108,16 @@ ENTRY(get_sev_encryption_mask) pop %rbp #endif + xor %rax, %rax ret -ENDPROC(get_sev_encryption_mask) +ENDPROC(set_sev_encryption_mask) .data enc_bit: .int 0xffffffff + +#ifdef CONFIG_AMD_MEM_ENCRYPT + .balign 8 +GLOBAL(sme_me_mask) + .quad 0 +#endif diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h index 4d369c3..9e11be4 100644 --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -114,6 +114,6 @@ static inline void console_init(void) { } #endif -unsigned long get_sev_encryption_mask(void); +void set_sev_encryption_mask(void); #endif