From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbbKGLVo (ORCPT ); Sat, 7 Nov 2015 06:21:44 -0500 Received: from www.linutronix.de ([62.245.132.108]:35112 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751093AbbKGLVn (ORCPT ); Sat, 7 Nov 2015 06:21:43 -0500 Date: Sat, 7 Nov 2015 12:20:59 +0100 (CET) From: Thomas Gleixner To: Andy Lutomirski cc: x86@kernel.org, linux-kernel@vger.kernel.org, Brian Gerst , Linus Torvalds , Borislav Petkov , =?ISO-8859-15?Q?Fr=E9d=E9ric_Weisbecker?= , Peter Zijlstra Subject: Re: [PATCH 3/4] x86/asm: Add asm macros for static keys/jump labels In-Reply-To: <42b51cafe425b8d7d177c7c363235df0ace22692.1446849780.git.luto@kernel.org> Message-ID: References: <42b51cafe425b8d7d177c7c363235df0ace22692.1446849780.git.luto@kernel.org> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 Nov 2015, Andy Lutomirski wrote: > Unfortunately, these only work if HAVE_JUMP_LABEL. In principle, we > could do some serious surgery on the core jump label infrastructure > to keep the patch infrastructure available on x86 on all builds, but > that's probably not worth it. No, but we can be smarter about it. There is nothing which that asm entry code needs from linux/jump_label.h and asm/jump_label.h execpt STATIC_KEY_INIT_NOP. Something like the patch below should do the trick. Thanks, tglx Index: tip/arch/x86/entry/calling.h =================================================================== --- tip.orig/arch/x86/entry/calling.h +++ tip/arch/x86/entry/calling.h @@ -232,3 +232,22 @@ For 32-bit we have the following convent #endif /* CONFIG_X86_64 */ +/* ASM jump label support */ +#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL) +#include + + .macro STATIC_CALL_IF_ENABLED fun, key + 1: + jmp.d32 2f + call fun + .pushsection __jump_table, "aw" + _ASM_ALIGN + _ASM_PTR 1b, 2f, \key + .popsection + 2: + .endm +#else + .macro STATIC_CALL_IF_ENABLED fun, key + call fun + .endm +#endif Index: tip/arch/x86/entry/entry_64.S =================================================================== --- tip.orig/arch/x86/entry/entry_64.S +++ tip/arch/x86/entry/entry_64.S @@ -510,7 +510,7 @@ END(irq_entries_start) */ SWAPGS #ifdef CONFIG_CONTEXT_TRACKING - call enter_from_user_mode + STATIC_CALL_IF_ENABLED enter_from_user_mode, context_tracking_enabled #endif 1: @@ -1050,7 +1050,7 @@ ENTRY(error_entry) .Lerror_entry_from_usermode_after_swapgs: #ifdef CONFIG_CONTEXT_TRACKING - call enter_from_user_mode + STATIC_CALL_IF_ENABLED enter_from_user_mode, context_tracking_enabled #endif .Lerror_entry_done: Index: tip/arch/x86/include/asm/jump_label.h =================================================================== --- tip.orig/arch/x86/include/asm/jump_label.h +++ tip/arch/x86/include/asm/jump_label.h @@ -1,10 +1,6 @@ #ifndef _ASM_X86_JUMP_LABEL_H #define _ASM_X86_JUMP_LABEL_H -#ifndef __ASSEMBLY__ - -#include -#include #include #include @@ -16,6 +12,11 @@ # define STATIC_KEY_INIT_NOP GENERIC_NOP5_ATOMIC #endif +#ifndef __ASSEMBLY__ + +#include +#include + static __always_inline bool arch_static_branch(struct static_key *key, bool branch) { asm_volatile_goto("1:"