Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757670AbeAIWiA (ORCPT + 1 other); Tue, 9 Jan 2018 17:38:00 -0500 Received: from mail-bn3nam01on0077.outbound.protection.outlook.com ([104.47.33.77]:38113 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752557AbeAIWhz (ORCPT ); Tue, 9 Jan 2018 17:37:55 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; From: Tom Lendacky Subject: [PATCH v1 2/2] x86/cpu/AMD: Clear RETPOLINE_AMD if LFENCE is not serializing To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Rik van Riel , Andi Kleen , Peter Zijlstra , Linus Torvalds , Jiri Kosina , Dan Williams , Dave Hansen , Borislav Petkov , Andy Lutomirski , Kees Cook , Thomas Gleixner , Tim Chen , Greg Kroah-Hartman , David Woodhouse , Paul Turner Date: Tue, 09 Jan 2018 16:37:45 -0600 Message-ID: <20180109223745.29322.30862.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20180109223723.29322.59126.stgit@tlendack-t1.amdoffice.net> References: <20180109223723.29322.59126.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: DM5PR21CA0032.namprd21.prod.outlook.com (10.172.92.146) To MWHPR12MB1150.namprd12.prod.outlook.com (10.169.204.14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 921a006e-ccfc-41e7-19ae-08d557b19d4e X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:MWHPR12MB1150; X-Microsoft-Exchange-Diag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UF76OaeMPHIiMvhmP0rIGKM4CS4iip5RZ77T9KejhoVHQBOLMlRMc8ppCr6Tx7+tC+qQoFr5RqZDkf1c7Y+mQIhsrulcNnrEw3x6DqIqWQfsQ07lbSr0q2yQ37VVJpnJwDtHxtg1Wh1mm45MZ/RgINXkWQQUlTIQZVcFOXTguywD10uxJf36C4r4TzAoHpqjp1aC/EAIIZgC6vQ5YdUlSkWtUa2qHiv7nWhhdeVBDh3Pn2VZfis2c1EP6iDCYafPCQTBFWOE34KUcrcKyPeWl3Wme1HiQcQYrXl5GxVps/37JZHlxCx9MFSEnlOLkliGoUTTN16U0p8y9owycNNLP0/IN3MB2DWA1b/Y9AbPqRvP;4:/QeTe0Phd+yrJkn+3UXQgKATnnotyexfkQO+uEi/tnIOw9JJP2ALv2MwKPXzBz8l75VOQQfaxOLf7K3aWy89GjFwVXicnq48/jQqPh6kpfRy9GEhCrOe5QHljOr+zkfM8QvQWgasudAE6/pI+8r302/2uj10+XymNUOvTMlCqPTNYrYXJDV7f+RAVxBcxgnTJkIfsYYR5FTz4Df1ISUdCRZDD9BSB9YKJTBz9UZblzJ+1dWlS0GS+39FY3L8MzU9ki3yx+7qAAWMa10KWQCqM0g6Dy0G/GHqoJHmrgnPOAy12HVB8Iw+Unkp6B69jst/ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(944501075)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041268)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(6072148)(201708071742011);SRVR:MWHPR12MB1150;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:MWHPR12MB1150; X-Forefront-PRVS: 0547116B72 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(376002)(366004)(39380400002)(346002)(396003)(39860400002)(199004)(189003)(55016002)(9686003)(7736002)(86362001)(68736007)(478600001)(16526018)(386003)(58126008)(72206003)(316002)(7416002)(54906003)(6506007)(305945005)(69596002)(97746001)(83506002)(52116002)(3846002)(66066001)(1076002)(97736004)(76176011)(47776003)(53416004)(8936002)(6666003)(25786009)(81166006)(81156014)(230700001)(6116002)(2950100002)(2486003)(50466002)(4326008)(105586002)(5660300001)(106356001)(7696005)(2906002)(23676004)(103116003)(53936002)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR12MB1150;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTUwOzIzOlN2WXZIUVpsL1dMbUVWR0hQYytFZEYxMWF1?= =?utf-8?B?TXEySHU0bkhtcUNMR3M4Q1JpWjFDQnhLWG5tRVVmY3dHT0NBYUI0bTFnT1Bx?= =?utf-8?B?azdTc0t5RnpnenhlTzhZT3FQbFJONXRjcEVsQVZKTUNvNXRCR0xPZzUvdWt3?= =?utf-8?B?S3p3WGlVRVArSS95TUhyZk1TSW1acmw4bm5ibVlBSis3U3orVDRkRWxJaTh2?= =?utf-8?B?NVNEd1BwdTB0WVNSbWlZbEhUeDFtdnVCcE93ZWRkUUNMM2g0UWk1WEhtYUZY?= =?utf-8?B?eGJ4eVNkVVZEV0tSNFNYby9QZjVlTnlmb3NkVlVva3ZCM05IUmI2ZlJIV3E4?= =?utf-8?B?SlVPSis3R1lDYWZ1enNMSVd1dFMxRThKWGZBVENoWEhMMnRUdGNqY1NybG5J?= =?utf-8?B?cWgrQUtHZVN5SVd1bmVGM0M4WXV4ZUFBSEJYeHRFVHQrK2swYmFPdWNIeFNp?= =?utf-8?B?TlFUclU2Q05uaDYrbTQxck1rVWdVYWk5Smp6bE41SjBVTzRXOXF1UG9zOEJq?= =?utf-8?B?NVg0a3BpcldmMGFwSUF3TVVIU2gvY0VLNjgyRXpzZ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iBu+rEDXpHFEpdVcJVAtpbv0lANyBrlUV6HRVzhMRJivjiE+1JbTFzeZBnH2MMrt0WnWaN6tJAhAXalHskrEa8/eLClPE+36htu6OffYiBxrnJkFKDXnMA4toADQEtb+ElmUNKZk0j+bj6NClntedYo4T5m+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1150;20:pGMyY9/RK3M4y+8PxBFhO/MDKI9nWWsCOcZbr14Tt9Et1Xhl3Oh2knKNNeLmwaSU0JYPJpEHnMQJ4Q22V/wGJiksdwY0afiUdOIDtcKPxfRRHRWnVtNbkkQsH1HK6B0iXk52NEghIHR+OmkXUHVIlc9BnV+QGR62xo8C65ZoEqWuUTb/IVgIkdxmocg8sOhU7wSsLGLFCGwfd8K910IR47Juy3o+84UaRhJElkFxAGYngR+cUyIMBxIE1pbyaMnP X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2018 22:37:48.8387 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 921a006e-ccfc-41e7-19ae-08d557b19d4e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1150 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: During early boot, spectre_v2_check_boottime_disable() sets the RETPOLINE_AMD feature for AMD hardware (before init_amd() is called). Since the RETPOLINE_AMD feature uses LFENCE to perform speculation control, it can only be used if LFENCE is serializing. Clear the RETPOLINE_AMD feature if the MSR write to make LFENCE serializing is not successful. Signed-off-by: Tom Lendacky --- arch/x86/kernel/cpu/amd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index ea831c8..8a0076b 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -13,6 +13,7 @@ #include #include #include +#include #ifdef CONFIG_X86_64 # include @@ -854,6 +855,9 @@ static void init_amd(struct cpuinfo_x86 *c) } else { /* MFENCE stops RDTSC speculation */ set_cpu_cap(c, X86_FEATURE_MFENCE_RDTSC); + + /* Don't use the LFENCE-based retpoline support */ + retpoline_amd_disable(); } }