Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757480AbeAIWhi (ORCPT + 1 other); Tue, 9 Jan 2018 17:37:38 -0500 Received: from mail-cys01nam02on0064.outbound.protection.outlook.com ([104.47.37.64]:45088 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752557AbeAIWhg (ORCPT ); Tue, 9 Jan 2018 17:37:36 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; From: Tom Lendacky Subject: [PATCH v1 0/2] x86/retpoline: 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:24 -0600 Message-ID: <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: CO1PR15CA0045.namprd15.prod.outlook.com (10.175.176.13) To BN6PR12MB1138.namprd12.prod.outlook.com (10.168.226.140) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15914793-be77-4090-0e1b-08d557b191f1 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7153060)(7193020);SRVR:BN6PR12MB1138; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1138;3:DeMdgI2enziLp3WwbjJUDQc7ALfOU7iJAPttfvfCP1MSsYee2C8s9IQiHHqcXmj5chX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ijA5njYSYJHP1lVSSgS+90ElJVlkWSI0/fSKyIU6QU97IYEbKYZAi8PZoV4xw/lwzdGXafeS4F7MVNCCQNSsvhqLeDVHntc6YJnBWe0aTcjoDkrClQpUR8GO5CaR1LJHDbV7C1Y7KoVpEb7LCW6HXAFuHV26juJvV8FdZN3Ay7LhbVE3ym8QOfddYNMfFMg6LF60tGgofS8WWtTWEiq8960gXB4Nja4ERsAADo859j4+qQB5Yfmcvw5BS3ueoN5vsdX0ay5m7Ue6JGhyMwp;4:h0cRBaPlU6AuzMRmTuZWWwqF/+C7igVPF1dMbQGRJUfNY9Y7OuvQc8VXFhCwQDJxGqy+m3Mg43bXAeHoPtu+CA+ceE8irm1Ei/rdK33KxjCDVJLp5IfaH5Kh+LCanBv6XrWf/8+zSFtMXHljmrmqhbrvWeb7RaBhkbbJFxideiDiBnSACZGruDEbhZAKTPoQgOap6LNJrMEjeE7ynWRBkg/2wPUoSFXF7xC0NkMRpj1eZ+MATL9CCXDr/BKygkdIDFCxSGd01XIeM1kKG+6Y8w== 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)(3231023)(944501075)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041268)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011);SRVR:BN6PR12MB1138;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:BN6PR12MB1138; X-Forefront-PRVS: 0547116B72 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39860400002)(39380400002)(346002)(396003)(366004)(376002)(199004)(189003)(6506007)(52116002)(7696005)(59450400001)(386003)(2486003)(23676004)(53936002)(4326008)(105586002)(305945005)(97736004)(47776003)(106356001)(66066001)(3846002)(68736007)(1076002)(230700001)(9686003)(6116002)(69596002)(55016002)(83506002)(58126008)(50466002)(97746001)(16526018)(54906003)(478600001)(6666003)(25786009)(103116003)(53416004)(72206003)(5660300001)(86362001)(7416002)(81166006)(2906002)(81156014)(8676002)(8936002)(316002)(7736002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1138;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMTM4OzIzOkhBS1ZkbGZETXlHTENBK25LUVgrQU0rY08w?= =?utf-8?B?a2VPc3I1TnlhU0NSUFNqZFlWNVpuVmY4L3hObHNna3lsWEpkd2h2cE5YMm9p?= =?utf-8?B?RlRMU1FPa3JOV29NNDNiNkpJNVRtUW5idEdUdG5qR2RrODhvUk84bXFQdWhy?= =?utf-8?B?UjlYOTAyR2dmcm5ES09jSGtnbmFadmdrMVVXYXFkaDhNNjlQY0NHcGswYUgw?= =?utf-8?B?V2dlem1VNHZRSlNSQ2ZlaTNyaWNzUjllNnYyOGQxMGZPQ1dBNS9IVXk5dUFn?= =?utf-8?B?WE8yMHp5aFJJSDY3eDl0NXhPK09NaE1YVGJFMnFvdC9tcjBHczh5L3NpWUc2?= =?utf-8?B?bUJ3YW5SbHFweGROSzBGaHBjRk9qN3c5UnVOWkNtTm5YcFYvZE43ODJBL2ZP?= =?utf-8?B?empxN3hrSmtUTDhoM0FwekpZNnZuekFTS2NFMXF6TE9wNjAwQXErUEgwczBl?= =?utf-8?B?U1pVQkoxV0JPZW4yK3ZEU1A0N01sdmJodlo2RFdUaStaQnhDY3NvcFJtL1hq?= =?utf-8?B?Mm84WWtHMmFDM2JsTmtMK21sQTJqN3AvRnpZbWNTY1pCdTlEcURVRUJxL1Vk?= =?utf-8?B?R0wvS0I1M0xBNGh0d3k4SEs5QURIZ1RMMlp4MnVxVzRNNkRWREZjY0hmcHlO?= =?utf-8?B?Snh4d241TTNnWWdETndLcEU5N2NNVVpFa1R3WStYSk1W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ticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1138;20:b6tk/q7C8pXwY9IhvMHbh0lZ8B5d+zll/06BNHFmtwiyo8eqvb4Hp/cfUxFV8FwdH1T2LNCXz6xgwGbXf5dmiPsyFlwwskWdau8W0sSPIKQmuuCWvsU7iT3n9TlKYW1nZe+u/XKbs1yi+AF7Ub+7MFyRjuiXZE4BOuf8iNLG5LlcNgmp3ZAYoZb26/RNFrd2oaZvHdff5LbtvFbdO4uYnOcQARGES/avjz7bkEwJZ9p8Ve3eAHq65XK9UtdE5k49 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2018 22:37:28.5552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15914793-be77-4090-0e1b-08d557b191f1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1138 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: The RETPOLINE_AMD feature is set by default for AMD hardware. This feature expects LFENCE to be serializing in order to perform the proper speculation control. If LFENCE cannot be determined to be serializing (for example, when running under a hypervisor that does not allow writing to the MSR that makes LFENCE serializing) the feature needs to be disabled. The kernel will then fall back to using the generic retpoline support. The following patches are included in this series: - Add a function to clear the RETPOLINE_AMD feature and update the variable used for sysfs output. - If LFENCE can not be determined to be serializing call the new function to clear the RETPOLINE_AMD feature. This patch series is based on tip:x86/pti. --- Tom Lendacky (2): x86/retpoline: Add a function to clear the RETPOLINE_AMD feature x86/cpu/AMD: Clear RETPOLINE_AMD if LFENCE is not serializing arch/x86/include/asm/nospec-branch.h | 1 + arch/x86/kernel/cpu/amd.c | 4 ++++ arch/x86/kernel/cpu/bugs.c | 10 ++++++++++ 3 files changed, 15 insertions(+) -- Tom Lendacky