Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756947AbeAHWJX (ORCPT + 1 other); Mon, 8 Jan 2018 17:09:23 -0500 Received: from mail-sn1nam02on0069.outbound.protection.outlook.com ([104.47.36.69]:41952 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753022AbeAHWJV (ORCPT ); Mon, 8 Jan 2018 17:09:21 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; From: Tom Lendacky Subject: [PATCH v2 0/2] x86/cpu/AMD: Make LFENCE a serializing instruction on AMD To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Linus Torvalds , Dan Williams , Dave Hansen , Borislav Petkov , Thomas Gleixner , Tim Chen , Greg Kroah-Hartman , David Woodhouse , Paul Turner Date: Mon, 08 Jan 2018 16:09:12 -0600 Message-ID: <20180108220912.12580.82330.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: DM5PR1101CA0019.namprd11.prod.outlook.com (10.174.246.29) To MWHPR12MB1151.namprd12.prod.outlook.com (10.169.204.15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fa304e24-867b-4d93-9883-08d556e47569 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:MWHPR12MB1151; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1151;3:dNgY3sXuGo5AVtesbTHP40NBxVDC0gXpYsGoj/Y/mJC5ivP2n7D5FIIbM/N78/6oq3eTtuCVoPOEsOxaggpLIa0vycTEzZxOMzbNfuL0P2nrg0uP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t0ySlRZTN43VPH9QKS/cgAwFa15tD6yap9oOlUrPEemEmGOatpwNVvK3uUnRPxGxsqYyuEjnlv5X32bOo4KnGEDNY2W8lI1piDjGJjJTwdXiHhssCi6tmcP8sJNyljQV84uYpCnWFs3CBlxz5iu7saq/uAnJUpNTwRDbI+y1HoFSGTrHYcDxS23Kg5H4yM4cq+DH9g6PDThoHnC3wPX6KUxb5T/FxyrYhIoUqe5zTv+OX;4:ffMAM3Sf9M6qxbdu9zlwVGfvPCWX+01OXwROI9QkNNt2wRU3g0l9HNA9hNcFcREY1nxtmzMneuBBUYkXHHJ6EEewb/wn3tNLwL87tRh6LlNDCsUePwFKBL1j4WewVSPGuFZZMhvWWtXjUKqOfKcx2x9jFgtg2AqDzYTyXONZijyPu4CGtVWvULU4zxJpNLDzZ583a1g+A94NipYIajI+unXp9iDiGjFZejddpAzr0IcOrCWzsX+ibtv4j/+lfcpslca6e+hF9UJQ4pzmoexC1w== 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)(93006095)(93001095)(10201501046)(3002001)(3231023)(944501075)(6055026)(6041268)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011);SRVR:MWHPR12MB1151;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:MWHPR12MB1151; X-Forefront-PRVS: 054642504A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(346002)(376002)(39860400002)(366004)(39380400002)(396003)(199004)(189003)(81156014)(97736004)(16526018)(52116002)(7696005)(2486003)(23676004)(6116002)(7416002)(66066001)(47776003)(1076002)(6506007)(386003)(3846002)(50466002)(305945005)(7736002)(2906002)(86362001)(8676002)(106356001)(8936002)(81166006)(6666003)(72206003)(9686003)(69596002)(97746001)(68736007)(478600001)(103116003)(25786009)(58126008)(54906003)(230700001)(53936002)(55016002)(5660300001)(316002)(53416004)(105586002)(4326008)(83506002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR12MB1151;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTUxOzIzOmpiZlE4ZVNaWjRnUmRpdWw5NFNCa0Nka1Bi?= =?utf-8?B?UlgweFNCL3hNSGhjV09SK09VNnl0aHZSa0RhSlIwSU1UUWNFSFZIU1N6ZHFQ?= =?utf-8?B?eFpIL1M4UHgzNjU1d3JpZmRqOWlrcis0dER2bStGSlpjOEtmVDZuSkxUN2JP?= =?utf-8?B?eVJ1QnJDM1daQ095REtIUSs4NCt5bXA1ZnJIWEt6bTR6S1pNcnM0MFhMeHdK?= =?utf-8?B?RGV3NnJxaEtUNVpYbE5xTFo4SmtZM1FaMForTUFSMzViUTRoZ0RJVjFDZVRR?= =?utf-8?B?dEw2V3Fnd0h6czdzR2x0NTdmYmRvWEtzVUVMQytyYzJYdXZtM1I5bjJjYit1?= =?utf-8?B?bVpZUVlYeHZudWx4TmxFRWhMZHhGT2w1NE43L1dIaTBHZFhsSElQVm84bWlN?= =?utf-8?B?L2t0SE5oTFhoa2xPc2lOdWw1UzUzV2ljVm4zVnA3QnA3aTR5aEJZdWhjdmZl?= =?utf-8?B?MXc0S3R2bkoydVN1OE5QVUhuWW9aK0tOb0thclVRalZTdGczS2xOemM4Rjhz?= =?utf-8?B?eEwzMUd4amVJR3RGS2tUc25KWGxqMnAvNlhxMXhXR1VhUTVQRWZ4N0lVNnBI?= =?utf-8?B?aUUyL2hSOGQzT0NRNm5sVXV0VjBCNjBEWU40V2ZWTEJPUHVrRlhKS3VoMDQ3?= =?utf-8?B?dWlmemQwZTVFUi9YTi8wZ3lzR1dwZmVPazNqbWRaNWQxYkJLVUVLdVB1YW8x?= =?utf-8?B?YndBM25FN1psWkk1WGtR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dF2smvDJ5jnZehQE5c7SWq3cIvHIHg5jGKz9KSJ7pX1D1WnZ8qTyRMon8Igo5NIA1D5bTUaXQmEczjkhyCWiBM6gXfylfl6BtJUsxUEvKO34q+EcZH2e5v3dl8JF8U7Mi6nANWRUONLTvuWIGQbobTA9sqE2DNYSRK/hZklfENmvqK X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2018 22:09:15.6742 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa304e24-867b-4d93-9883-08d556e47569 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1151 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: To aid in speculation control, the LFENCE instruction will be turned into a serializing instruction. There is less performance impact using LFENCE in this way compared to MFENCE. With LFENCE now being a serializing instruction, it can be also used in rdtsc_ordered() in preference to MFENCE_RDTSC. Since the kernel could be running under a hypervisor that does not allow writing to that MSR, it must be first verified that the write was successful before setting the LFENCE_RDTSC feature. The following patches are included in this series: - Make LFENCE a serializing instruction on AMD - Use LFENCE_RDTSC in preference to MFENCE_RDTSC on AMD This patch series is based on tip:x86/pti. --- Changes from v1: - Add a check verifying the MSR was actually updated - Remove the third patch that eliminates the MFENCE_RDTSC feature (since the feature is still needed) - Adding Dan Williams to the cc since this will impact nospec_barrier(), which will require an alternative_2 to add an MFENCE instruction with an MFENCE_RDTSC check Tom Lendacky (2): x86/cpu/AMD: Make LFENCE a serializing instruction x86/cpu/AMD: Use LFENCE_RDTSC in preference to MFENCE_RDTSC arch/x86/include/asm/msr-index.h | 3 +++ arch/x86/kernel/cpu/amd.c | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) -- Tom Lendacky