Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1318751
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH -v1.1 8/10] x86/alternatives: Discard dynamic check after init |
| Date | 2016-01-27 09:50 +0100 |
| Message-ID | <qVtXz-Pn-1@gated-at.bofh.it> (permalink) |
| References | <qVjbQ-1GJ-5@gated-at.bofh.it> <qVjbR-1GJ-43@gated-at.bofh.it> <qVp7A-5OH-21@gated-at.bofh.it> <qVtXz-Pn-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Brian Gerst <brgerst@gmail.com>
Date: Sat, 16 Jan 2016 14:22:04 -0500
Subject: [PATCH -v1.1 8/10] x86/alternatives: Discard dynamic check after init
Move the code to do the dynamic check to the altinstr_aux section so
that it is discarded after alternatives have run and a static branch has
been chosen.
This way we're changing the dynamic branch from C code to assembly,
which makes it *substantially* smaller while avoiding a completely
unnecessary call to an out of line function.
Boris: change it to do TESTB, as hpa suggests.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Kristen Carlson Accardi <kristen@linux.intel.com>
Cc: Laura Abbott <labbott@fedoraproject.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Link: http://lkml.kernel.org/r/1452972124-7380-1-git-send-email-brgerst@gmail.com
Signed-off-by: Borislav Petkov <bp@suse.de>
---
arch/x86/include/asm/cpufeature.h | 19 ++++++++++++-------
arch/x86/kernel/cpu/common.c | 6 ------
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 9048c1bbc519..9fba7a5dd24a 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -130,8 +130,6 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
*/
#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_X86_FAST_FEATURE_TESTS)
-extern bool __static_cpu_has(u16 bit);
-
/*
* Static testing of CPU features. Used the same as boot_cpu_has().
* These will statically patch the target code for additional
@@ -139,7 +137,7 @@ extern bool __static_cpu_has(u16 bit);
*/
static __always_inline __pure bool _static_cpu_has(u16 bit)
{
- asm_volatile_goto("1: jmp %l[t_dynamic]\n"
+ asm_volatile_goto("1: jmp 6f\n"
"2:\n"
".skip -(((5f-4f) - (2b-1b)) > 0) * "
"((5f-4f) - (2b-1b)),0x90\n"
@@ -164,13 +162,20 @@ static __always_inline __pure bool _static_cpu_has(u16 bit)
" .byte 0\n" /* repl len */
" .byte 0\n" /* pad len */
".previous\n"
- : : "i" (bit), "i" (X86_FEATURE_ALWAYS)
- : : t_dynamic, t_no);
+ ".section .altinstr_aux,\"ax\"\n"
+ "6:\n"
+ " testb %[bitnum],%[cap_byte]\n"
+ " jnz %l[t_yes]\n"
+ " jmp %l[t_no]\n"
+ ".previous\n"
+ : : "i" (bit), "i" (X86_FEATURE_ALWAYS),
+ [bitnum] "i" (1 << (bit & 7)),
+ [cap_byte] "m" (((const char *)boot_cpu_data.x86_capability)[bit >> 3])
+ : : t_yes, t_no);
+ t_yes:
return true;
t_no:
return false;
- t_dynamic:
- return __static_cpu_has(bit);
}
#define static_cpu_has(bit) \
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index ee499817f3f5..079d83fc6488 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1475,12 +1475,6 @@ void cpu_init(void)
}
#endif
-inline bool __static_cpu_has(u16 bit)
-{
- return boot_cpu_has(bit);
-}
-EXPORT_SYMBOL_GPL(__static_cpu_has);
-
static void bsp_resume(void)
{
if (this_cpu->c_bsp_resume)
--
2.3.5
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/10] tip-queue 2016-01-26, rest Borislav Petkov <bp@alien8.de> - 2016-01-26 22:20 +0100
[PATCH 09/10] x86/vdso: Use static_cpu_has() Borislav Petkov <bp@alien8.de> - 2016-01-26 22:20 +0100
[PATCH 03/10] x86/asm: Tweak the comment about wmb() use for IO Borislav Petkov <bp@alien8.de> - 2016-01-26 22:20 +0100
[PATCH 07/10] x86/alternatives: Add an auxilary section Borislav Petkov <bp@alien8.de> - 2016-01-26 22:20 +0100
[PATCH 01/10] x86/asm: Add condition codes clobber to memory barrier macros Borislav Petkov <bp@alien8.de> - 2016-01-26 22:20 +0100
[PATCH 06/10] x86/cpufeature: Get rid of the non-asm goto variant Borislav Petkov <bp@alien8.de> - 2016-01-26 22:20 +0100
Re: [PATCH 06/10] x86/cpufeature: Get rid of the non-asm goto variant Brian Gerst <brgerst@gmail.com> - 2016-01-27 04:40 +0100
[PATCH -v1.1 8/10] x86/alternatives: Discard dynamic check after init Borislav Petkov <bp@alien8.de> - 2016-01-27 09:50 +0100
Re: [PATCH 06/10] x86/cpufeature: Get rid of the non-asm goto variant Borislav Petkov <bp@alien8.de> - 2016-01-27 09:50 +0100
[PATCH -v1.1 06/10] x86/cpufeature: Get rid of the non-asm goto variant Borislav Petkov <bp@alien8.de> - 2016-01-27 09:50 +0100
csiph-web