lkml.org 
[lkml]   [2018]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.16 060/410] x86/speculation: Move firmware_restrict_branch_speculation_*() from C to CPP
    3.16.57-rc1 review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Ingo Molnar <mingo@kernel.org>

    commit d72f4e29e6d84b7ec02ae93088aa459ac70e733b upstream.

    firmware_restrict_branch_speculation_*() recently started using
    preempt_enable()/disable(), but those are relatively high level
    primitives and cause build failures on some 32-bit builds.

    Since we want to keep <asm/nospec-branch.h> low level, convert
    them to macros to avoid header hell...

    Cc: David Woodhouse <dwmw@amazon.co.uk>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: arjan.van.de.ven@intel.com
    Cc: bp@alien8.de
    Cc: dave.hansen@intel.com
    Cc: jmattson@google.com
    Cc: karahmed@amazon.de
    Cc: kvm@vger.kernel.org
    Cc: pbonzini@redhat.com
    Cc: rkrcmar@redhat.com
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    arch/x86/include/asm/nospec-branch.h | 28 +++++++++++++++-------------
    1 file changed, 15 insertions(+), 13 deletions(-)

    --- a/arch/x86/include/asm/nospec-branch.h
    +++ b/arch/x86/include/asm/nospec-branch.h
    @@ -213,20 +213,22 @@ static inline void indirect_branch_predi
    /*
    * With retpoline, we must use IBRS to restrict branch prediction
    * before calling into firmware.
    + *
    + * (Implemented as CPP macros due to header hell.)
    */
    -static inline void firmware_restrict_branch_speculation_start(void)
    -{
    - preempt_disable();
    - alternative_msr_write(MSR_IA32_SPEC_CTRL, SPEC_CTRL_IBRS,
    - X86_FEATURE_USE_IBRS_FW);
    -}
    +#define firmware_restrict_branch_speculation_start() \
    +do { \
    + preempt_disable(); \
    + alternative_msr_write(MSR_IA32_SPEC_CTRL, SPEC_CTRL_IBRS, \
    + X86_FEATURE_USE_IBRS_FW); \
    +} while (0)

    -static inline void firmware_restrict_branch_speculation_end(void)
    -{
    - alternative_msr_write(MSR_IA32_SPEC_CTRL, 0,
    - X86_FEATURE_USE_IBRS_FW);
    - preempt_enable();
    -}
    +#define firmware_restrict_branch_speculation_end() \
    +do { \
    + alternative_msr_write(MSR_IA32_SPEC_CTRL, 0, \
    + X86_FEATURE_USE_IBRS_FW); \
    + preempt_enable(); \
    +} while (0)

    #endif /* __ASSEMBLY__ */
    #endif /* _ASM_X86_NOSPEC_BRANCH_H_ */
    \
     
     \ /
      Last update: 2018-06-07 16:55    [W:4.172 / U:0.148 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site