Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753515AbeADWWA (ORCPT + 1 other); Thu, 4 Jan 2018 17:22:00 -0500 Received: from mga06.intel.com ([134.134.136.31]:22344 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751952AbeADWV7 (ORCPT ); Thu, 4 Jan 2018 17:21:59 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,315,1511856000"; d="scan'208";a="18300747" Subject: Re: [PATCH 2/7] x86/enter: MACROS to set/clear IBRS To: Peter Zijlstra Cc: Thomas Gleixner , Andy Lutomirski , Linus Torvalds , Greg KH , Dave Hansen , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , linux-kernel@vger.kernel.org References: <032e71e3826ed92523e9070fffa7108392848dc6.1515086770.git.tim.c.chen@linux.intel.com> <20180104221645.GC32035@hirez.programming.kicks-ass.net> From: Tim Chen Message-ID: <7fe03060-3904-dcf7-3cdf-a98ade5f5148@linux.intel.com> Date: Thu, 4 Jan 2018 14:21:57 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20180104221645.GC32035@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 01/04/2018 02:16 PM, Peter Zijlstra wrote: > On Thu, Jan 04, 2018 at 09:56:43AM -0800, Tim Chen wrote: >> diff --git a/arch/x86/include/asm/spec_ctrl.h b/arch/x86/include/asm/spec_ctrl.h >> new file mode 100644 >> index 0000000..16fc4f58 >> --- /dev/null >> +++ b/arch/x86/include/asm/spec_ctrl.h > > Does this really have to live outside of arch/x86/entry/ ? > There are some inline C routines later in this file that will be needed by other functions. Want to consolidate them in the same file. > >> +.macro ENABLE_IBRS >> + ALTERNATIVE "jmp 10f", "", X86_FEATURE_SPEC_CTRL >> + PUSH_MSR_REGS >> + WRMSR_ASM $MSR_IA32_SPEC_CTRL, $SPEC_CTRL_FEATURE_ENABLE_IBRS >> + POP_MSR_REGS >> +10: >> +.endm >> + >> +.macro DISABLE_IBRS >> + ALTERNATIVE "jmp 10f", "", X86_FEATURE_SPEC_CTRL >> + PUSH_MSR_REGS >> + WRMSR_ASM $MSR_IA32_SPEC_CTRL, $SPEC_CTRL_FEATURE_DISABLE_IBRS >> + POP_MSR_REGS >> +10: >> +.endm >> + >> +.macro ENABLE_IBRS_CLOBBER >> + ALTERNATIVE "jmp 10f", "", X86_FEATURE_SPEC_CTRL >> + WRMSR_ASM $MSR_IA32_SPEC_CTRL, $SPEC_CTRL_FEATURE_ENABLE_IBRS >> +10: >> +.endm >> + >> +.macro DISABLE_IBRS_CLOBBER >> + ALTERNATIVE "jmp 10f", "", X86_FEATURE_SPEC_CTRL >> + WRMSR_ASM $MSR_IA32_SPEC_CTRL, $SPEC_CTRL_FEATURE_DISABLE_IBRS >> +10: >> +.endm >> + >> +.macro ENABLE_IBRS_SAVE_AND_CLOBBER save_reg:req >> + ALTERNATIVE "jmp 10f", "", X86_FEATURE_SPEC_CTRL >> + movl $MSR_IA32_SPEC_CTRL, %ecx >> + rdmsr >> + movl %eax, \save_reg >> + >> + movl $0, %edx >> + movl $SPEC_CTRL_FEATURE_ENABLE_IBRS, %eax >> + wrmsr >> +10: >> +.endm >> + >> +.macro RESTORE_IBRS_CLOBBER save_reg:req >> + ALTERNATIVE "jmp 10f", "", X86_FEATURE_SPEC_CTRL >> + /* Set IBRS to the value saved in the save_reg */ >> + movl $MSR_IA32_SPEC_CTRL, %ecx >> + movl $0, %edx > > whitespace damage Will fix > >> + movl \save_reg, %eax >> + wrmsr >> +10: >> +.endm > > Should not all those 10 things look like .Ldone_\@ or something ? > They are removed in patch 6 with .Ldone_\@ Tim