Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757539AbeAIWhr (ORCPT + 1 other); Tue, 9 Jan 2018 17:37:47 -0500 Received: from mail-cys01nam02on0060.outbound.protection.outlook.com ([104.47.37.60]:8346 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752557AbeAIWhn (ORCPT ); Tue, 9 Jan 2018 17:37:43 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; From: Tom Lendacky Subject: [PATCH v1 1/2] x86/retpoline: Add a function to clear the RETPOLINE_AMD feature 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:36 -0600 Message-ID: <20180109223736.29322.5436.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: BN6PR1101CA0018.namprd11.prod.outlook.com (10.174.237.28) To BN6PR12MB1138.namprd12.prod.outlook.com (10.168.226.140) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b96a814-2397-4b43-f834-08d557b1974b 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;BN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bSJ0IxAX7UHYRqdO34Z85RZs3mnwAJIftYVKR/OdEPm/OIhvgLi4TJq7iZ+wbu5JpiKaIJzlQTtfFDsF0hDIyCpYt2NvgAUZ+Dx9ifGwzwf/cAPz2AdJHQUb3f+X0htJeNgG8F3Jz44p+ItE0L8TYgJGeMwt2DVX/LGC/riTK1hC+BpvkHL2Dy81zc0j1mxI2nOTTrd2gI7hMyARE56QoiF484oc/GaTCkjyxO2LcWy39LsAJ4wgiMbbHZFRrwXLESF5C8fBWpXZBqLdC/cjq3gh4NSAW6eESAjQ3B4nJg7Z4wPT4ueZWU3Ctpc5pCGrBaPhNUyfZKyPQdgpKjy6n9Ni;4:SaoTIJ6IPjvLwLkuH8/P3SsIC37fUZpwHjPkVz1T9uUf/SikA8m+4/SMXf3z32VXTzMlxTzJTSgOiCsJWrzWAjzXnlJ5QewCL6SxAgpX363jHSqIEs/c760CgyVGu9YedgdwvA24tQ5vnznmSg61iD/K9G3bQg599zsAozTA5jVrC7D1JBcywNKERyoFIkrvIfo7lH+9N0NMc6hDgB0lkdsyYQFKa0lgK2ZwjHS50XlJxwfW3YY2CpqBm090po+TaUtontgIJaWNoQQydlDN2ez9dbYQOH8opfVMosV8KKeyatSZTRkSkRl4qAldnqBI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); 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)(76176011)(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)(2950100002)(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?MTtCTjZQUjEyTUIxMTM4OzIzOmc2ODZMNUFaR2l3UWNENnRFaklaL3Rsd0lZ?= =?utf-8?B?c2IzdGlpOE5pbUxRZ3huWlVxUEtZdUlLWEM2OTNZQmN4dk1vVWI3bGpyS0FC?= =?utf-8?B?bWhpZVRIZ3hOR3NGLzhxTGcxSmFHSE9veUR0MXJUZzZEaEp6QVJobVYvTlB0?= =?utf-8?B?NkY4T2V1bnZlRjQ4TWdMT2Zidnh6Wjl4aFkvc2kzK1gxaVFQUkhlbXRwcG8w?= =?utf-8?B?RUU5NkY2Z1VsbEs0bUpyUXJNbzBWV1A2dEVlVFh6cFlWTURySGYzZWhSQk02?= =?utf-8?B?VUFmcy8xR2cyVys2V0VydXQxSm56SDJJNWF6OFFuUWFPRFJ2Nzc0NXlLTXgx?= =?utf-8?B?NjBkTGFWdlU3MVl0ZDJzNUkyZHZqNkpEQnd0K0NrR1c3aEhFbm9rUnlRQ0pN?= =?utf-8?B?aE1HVWRXQ2FCOXhOSGdiSHdmMURTVjlaTjFSVXZ5eHZFazZyZk5WRkZScnFj?= =?utf-8?B?NnpVekVaa0JKcGYyR0FsSEJOeHBpNWFTOWc3K3ZzSngxTGNlRXRKR2o3TGlU?= =?utf-8?B?M1c0cFZ0ZHBDWjBuMUZWSjF1TWNhUHU3eDhkT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0AhGTMw0sgAjvFMpGnJike65P/M5PSDc0im5nNZqyyKGlkmz2ah7Hzzulls+BsYvDrSf+wFGHbVWgM+0zlJA4nkgFVLbeGSSz6pVy5hFM6QL4nIqpnK5+kW1chGqaazgwWpxUCqlRHvGaYdgUQ46GLQiF7Ce5uCVG7BdaNnQ6OXer270KpJV4tYhK6hK4cg SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1138;20:TRuSiDXELh9wvyxz2FT2s76AoK0ygnXBs8e3e+MdMvh9989Bu/Ut5mZXuNhTXXpljxyjaDDdy7aB7Xe5ZM+Ce0ksZ2xE81Z/rAkgGOipfcrSzUYl95ettGraWkhgO5BUFfnFA1GvOWR674TBExOIngVs1O5iZ+8yslZPwIbxVpPmXu7LI/JQvT884uCLJr1MTjzqODXLc32wJvK8MkSRuPJhoGZdajdONxuA84TT22QCmhTOV2ZdzjJ7+TYf3vpA X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2018 22:37:39.3521 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b96a814-2397-4b43-f834-08d557b1974b 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: For AMD hardware, the RETPOLINE_AMD feature is dependent on LFENCE being a serializing instruction. Create a function to allow RETPOLINE_AMD to be cleared if it cannot be determined that LFENCE is serializing. In addition, update the spectre_v2_enabled variable so that sysfs output is correct. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/nospec-branch.h | 1 + arch/x86/kernel/cpu/bugs.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 8ddf851..5785684 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -153,6 +153,7 @@ #endif void spectre_v2_check_boottime_disable(void); +void retpoline_amd_disable(void); #endif /* __ASSEMBLY__ */ #endif /* __NOSPEC_BRANCH_H__ */ diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index b957f77..a4c594c 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -170,6 +170,16 @@ void __init spectre_v2_check_boottime_disable(void) return; } +void retpoline_amd_disable(void) +{ + if (!boot_cpu_has(X86_FEATURE_RETPOLINE_AMD)) + return; + + setup_clear_cpu_cap(X86_FEATURE_RETPOLINE_AMD); + spectre_v2_enabled = retp_compiler() ? + SPECTRE_V2_RETPOLINE_GENERIC : SPECTRE_V2_RETPOLINE_MINIMAL; +} + #ifdef CONFIG_SYSFS ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, char *buf)