Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1318394 > unrolled thread
| Started by | Borislav Petkov <bp@alien8.de> |
|---|---|
| First post | 2016-01-26 22:20 +0100 |
| Last post | 2016-01-27 09:50 +0100 |
| Articles | 10 — 2 participants |
Back to article view | Back to linux.kernel
[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
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-26 22:20 +0100 |
| Subject | [PATCH 00/10] tip-queue 2016-01-26, rest |
| Message-ID | <qVjbQ-1GJ-5@gated-at.bofh.it> |
From: Borislav Petkov <bp@suse.de> Hi, this is the rest of the series today. Main one is the cpufeature cleanup. I merged the AVIC patch from tip:x86/cpu so that the rest applies cleanly. The rest is simplifications/cleanups. Please apply, thanks. Alexander Kuleshov (1): x86/head_64: Simplify kernel load address alignment check Borislav Petkov (5): x86/cpufeature: Carve out X86_FEATURE_* x86/cpufeature: Replace the old static_cpu_has() with safe variant x86/cpufeature: Get rid of the non-asm goto variant x86/alternatives: Add an auxilary section x86/vdso: Use static_cpu_has() Brian Gerst (1): x86/alternatives: Discard dynamic check after init Michael S. Tsirkin (3): x86/asm: Add condition codes clobber to memory barrier macros x86/asm: Drop a comment left over from X86_OOSTORE x86/asm: Tweak the comment about wmb() use for IO
[toc] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-26 22:20 +0100 |
| Subject | [PATCH 09/10] x86/vdso: Use static_cpu_has() |
| Message-ID | <qVjbQ-1GJ-21@gated-at.bofh.it> |
| In reply to | #1318394 |
From: Borislav Petkov <bp@suse.de> ... and simplify and speed up a tad. Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Andy Lutomirski <luto@amacapital.net> --- arch/x86/entry/vdso/vma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 5471ac362147..6b46648588d8 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -255,7 +255,7 @@ static void vgetcpu_cpu_init(void *arg) #ifdef CONFIG_NUMA node = cpu_to_node(cpu); #endif - if (cpu_has(&cpu_data(cpu), X86_FEATURE_RDTSCP)) + if (static_cpu_has(X86_FEATURE_RDTSCP)) write_rdtscp_aux((node << 12) | cpu); /* -- 2.3.5
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-26 22:20 +0100 |
| Subject | [PATCH 03/10] x86/asm: Tweak the comment about wmb() use for IO |
| Message-ID | <qVjbQ-1GJ-23@gated-at.bofh.it> |
| In reply to | #1318394 |
From: "Michael S. Tsirkin" <mst@redhat.com> On x86, we *do* still use the non-nop rmb()/wmb() for IO barriers, but even that is generally questionable. Leave them around for historical reasons, unless somebody can point to a case where they care about the performance. Tweak the comment so people don't think they are strictly required in all cases. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Cc: Andrey Konovalov <andreyknvl@google.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: virtualization <virtualization@lists.linux-foundation.org> Link: http://lkml.kernel.org/r/1452715911-12067-4-git-send-email-mst@redhat.com Signed-off-by: Borislav Petkov <bp@suse.de> --- arch/x86/include/asm/barrier.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h index d2aa66a3a4b5..4f95b2affd88 100644 --- a/arch/x86/include/asm/barrier.h +++ b/arch/x86/include/asm/barrier.h @@ -6,8 +6,8 @@ /* * Force strict CPU ordering. - * And yes, this is required on UP too when we're talking - * to devices. + * + * And yes, this might be required on UP too when we're talking to devices. */ #ifdef CONFIG_X86_32 -- 2.3.5
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-26 22:20 +0100 |
| Subject | [PATCH 07/10] x86/alternatives: Add an auxilary section |
| Message-ID | <qVjbR-1GJ-27@gated-at.bofh.it> |
| In reply to | #1318394 |
From: Borislav Petkov <bp@suse.de>
Add .altinstr_aux for additional instructions which will be used before
and/or during patching. All stuff which needs more sophisticated
patching should go there. See next patch.
Signed-off-by: Borislav Petkov <bp@suse.de>
---
arch/x86/kernel/vmlinux.lds.S | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 74e4bf11f562..92dc211c11db 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -195,6 +195,17 @@ SECTIONS
:init
#endif
+ /*
+ * Section for code used exclusively before alternatives are run. All
+ * references to such code must be patched out by alternatives, normally
+ * by using X86_FEATURE_ALWAYS CPU feature bit.
+ *
+ * See static_cpu_has() for an example.
+ */
+ .altinstr_aux : AT(ADDR(.altinstr_aux) - LOAD_OFFSET) {
+ *(.altinstr_aux)
+ }
+
INIT_DATA_SECTION(16)
.x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
--
2.3.5
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-26 22:20 +0100 |
| Subject | [PATCH 01/10] x86/asm: Add condition codes clobber to memory barrier macros |
| Message-ID | <qVjbR-1GJ-31@gated-at.bofh.it> |
| In reply to | #1318394 |
From: "Michael S. Tsirkin" <mst@redhat.com>
ADDL clobbers flags (such as CF) but barrier.h didn't tell this to gcc.
Historically, gcc doesn't need them on x86, and always considers flags
clobbered. We are probably missing the cc clobber in a *lot* of places
for this reason.
But even if not necessary, it's probably a good thing to add for
documentation, and in case gcc semantics ever change.
Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: virtualization <virtualization@lists.linux-foundation.org>
Link: http://lkml.kernel.org/r/1452715911-12067-2-git-send-email-mst@redhat.com
Signed-off-by: Borislav Petkov <bp@suse.de>
---
arch/x86/include/asm/barrier.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
index 0681d2532527..5bce7865b623 100644
--- a/arch/x86/include/asm/barrier.h
+++ b/arch/x86/include/asm/barrier.h
@@ -15,9 +15,12 @@
* Some non-Intel clones support out of order store. wmb() ceases to be a
* nop for these.
*/
-#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
-#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
-#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
+#define mb() asm volatile(ALTERNATIVE("lock; addl $0,0(%%esp)", "mfence", \
+ X86_FEATURE_XMM2) ::: "memory", "cc")
+#define rmb() asm volatile(ALTERNATIVE("lock; addl $0,0(%%esp)", "lfence", \
+ X86_FEATURE_XMM2) ::: "memory", "cc")
+#define wmb() asm volatile(ALTERNATIVE("lock; addl $0,0(%%esp)", "sfence", \
+ X86_FEATURE_XMM2) ::: "memory", "cc")
#else
#define mb() asm volatile("mfence":::"memory")
#define rmb() asm volatile("lfence":::"memory")
--
2.3.5
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-26 22:20 +0100 |
| Subject | [PATCH 06/10] x86/cpufeature: Get rid of the non-asm goto variant |
| Message-ID | <qVjbR-1GJ-43@gated-at.bofh.it> |
| In reply to | #1318394 |
From: Borislav Petkov <bp@suse.de>
I can simply quote hpa from the mail:
"Get rid of the non-asm goto variant and just fall back to dynamic if
asm goto is unavailable. It doesn't make any sense, really, if it is
supposed to be safe, and by now the asm goto-capable gcc is in more wide
use. (Originally the gcc 3.x fallback to pure dynamic didn't exist,
either.)"
Booy, am I lazy.
Cleanup the whole CC_HAVE_ASM_GOTO ifdeffery too, while at it.
Signed-off-by: Borislav Petkov <bp@suse.de>
Suggested-by: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/include/asm/cpufeature.h | 49 ++++-----------------------------------
1 file changed, 5 insertions(+), 44 deletions(-)
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index a261cf2e7907..d48bf024f335 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -129,17 +129,16 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
* fast paths and boot_cpu_has() otherwise!
*/
-#if __GNUC__ >= 4 && defined(CONFIG_X86_FAST_FEATURE_TESTS)
+#if 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 are only valid after alternatives have run, but will statically
- * patch the target code for additional performance.
+ * These will statically patch the target code for additional
+ * performance.
*/
static __always_inline __pure bool _static_cpu_has(u16 bit)
{
-#ifdef CC_HAVE_ASM_GOTO
asm_volatile_goto("1: jmp %l[t_dynamic]\n"
"2:\n"
".skip -(((5f-4f) - (2b-1b)) > 0) * "
@@ -172,45 +171,6 @@ static __always_inline __pure bool _static_cpu_has(u16 bit)
return false;
t_dynamic:
return __static_cpu_has(bit);
-#else
- u8 flag;
- /* Open-coded due to __stringify() in ALTERNATIVE() */
- asm volatile("1: movb $2,%0\n"
- "2:\n"
- ".section .altinstructions,\"a\"\n"
- " .long 1b - .\n" /* src offset */
- " .long 3f - .\n" /* repl offset */
- " .word %P2\n" /* always replace */
- " .byte 2b - 1b\n" /* source len */
- " .byte 4f - 3f\n" /* replacement len */
- " .byte 0\n" /* pad len */
- ".previous\n"
- ".section .discard,\"aw\",@progbits\n"
- " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
- ".previous\n"
- ".section .altinstr_replacement,\"ax\"\n"
- "3: movb $0,%0\n"
- "4:\n"
- ".previous\n"
- ".section .altinstructions,\"a\"\n"
- " .long 1b - .\n" /* src offset */
- " .long 5f - .\n" /* repl offset */
- " .word %P1\n" /* feature bit */
- " .byte 4b - 3b\n" /* src len */
- " .byte 6f - 5f\n" /* repl len */
- " .byte 0\n" /* pad len */
- ".previous\n"
- ".section .discard,\"aw\",@progbits\n"
- " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
- ".previous\n"
- ".section .altinstr_replacement,\"ax\"\n"
- "5: movb $1,%0\n"
- "6:\n"
- ".previous\n"
- : "=qm" (flag)
- : "i" (bit), "i" (X86_FEATURE_ALWAYS));
- return (flag == 2 ? __static_cpu_has(bit) : flag);
-#endif /* CC_HAVE_ASM_GOTO */
}
#define static_cpu_has(bit) \
@@ -221,7 +181,8 @@ static __always_inline __pure bool _static_cpu_has(u16 bit)
)
#else
/*
- * gcc 3.x is too stupid to do the static test; fall back to dynamic.
+ * Fall back to dynamic for gcc versions which don't support asm goto. Should be
+ * a minority now anyway.
*/
#define static_cpu_has(bit) boot_cpu_has(bit)
#endif
--
2.3.5
[toc] | [prev] | [next] | [standalone]
| From | Brian Gerst <brgerst@gmail.com> |
|---|---|
| Date | 2016-01-27 04:40 +0100 |
| Subject | Re: [PATCH 06/10] x86/cpufeature: Get rid of the non-asm goto variant |
| Message-ID | <qVp7A-5OH-21@gated-at.bofh.it> |
| In reply to | #1318403 |
On Tue, Jan 26, 2016 at 4:12 PM, Borislav Petkov <bp@alien8.de> wrote: > From: Borislav Petkov <bp@suse.de> > > I can simply quote hpa from the mail: > > "Get rid of the non-asm goto variant and just fall back to dynamic if > asm goto is unavailable. It doesn't make any sense, really, if it is > supposed to be safe, and by now the asm goto-capable gcc is in more wide > use. (Originally the gcc 3.x fallback to pure dynamic didn't exist, > either.)" > > Booy, am I lazy. > > Cleanup the whole CC_HAVE_ASM_GOTO ifdeffery too, while at it. > > Signed-off-by: Borislav Petkov <bp@suse.de> > Suggested-by: "H. Peter Anvin" <hpa@zytor.com> > --- > arch/x86/include/asm/cpufeature.h | 49 ++++----------------------------------- > 1 file changed, 5 insertions(+), 44 deletions(-) > > diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h > index a261cf2e7907..d48bf024f335 100644 > --- a/arch/x86/include/asm/cpufeature.h > +++ b/arch/x86/include/asm/cpufeature.h > @@ -129,17 +129,16 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; > * fast paths and boot_cpu_has() otherwise! > */ > > -#if __GNUC__ >= 4 && defined(CONFIG_X86_FAST_FEATURE_TESTS) > +#if CC_HAVE_ASM_GOTO && defined(CONFIG_X86_FAST_FEATURE_TESTS) This should be: #if defined(CC_HAVE_ASM_GOTO) && ... -- Brian Gerst
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-27 09:50 +0100 |
| Subject | [PATCH -v1.1 8/10] x86/alternatives: Discard dynamic check after init |
| Message-ID | <qVtXz-Pn-1@gated-at.bofh.it> |
| In reply to | #1318592 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-27 09:50 +0100 |
| Subject | Re: [PATCH 06/10] x86/cpufeature: Get rid of the non-asm goto variant |
| Message-ID | <qVtXz-Pn-3@gated-at.bofh.it> |
| In reply to | #1318592 |
On Tue, Jan 26, 2016 at 10:36:21PM -0500, Brian Gerst wrote:
> This should be:
> #if defined(CC_HAVE_ASM_GOTO) && ...
Good catch, thanks!
I thought about it while typing and then gcc didn't complain so I forgot
again. :-\
Ingo, I'm sending the patches which changed as a reply to this message.
Thanks.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-01-27 09:50 +0100 |
| Subject | [PATCH -v1.1 06/10] x86/cpufeature: Get rid of the non-asm goto variant |
| Message-ID | <qVtXA-Pn-19@gated-at.bofh.it> |
| In reply to | #1318754 |
From: Borislav Petkov <bp@suse.de>
Date: Wed, 20 Jan 2016 19:14:03 +0100
Subject: [PATCH 1/4] x86/cpufeature: Get rid of the non-asm goto variant
I can simply quote hpa from the mail:
"Get rid of the non-asm goto variant and just fall back to dynamic if
asm goto is unavailable. It doesn't make any sense, really, if it is
supposed to be safe, and by now the asm goto-capable gcc is in more wide
use. (Originally the gcc 3.x fallback to pure dynamic didn't exist,
either.)"
Booy, am I lazy.
Cleanup the whole CC_HAVE_ASM_GOTO ifdeffery too, while at it.
Signed-off-by: Borislav Petkov <bp@suse.de>
Suggested-by: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/include/asm/cpufeature.h | 49 ++++-----------------------------------
1 file changed, 5 insertions(+), 44 deletions(-)
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index a261cf2e7907..9048c1bbc519 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -129,17 +129,16 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
* fast paths and boot_cpu_has() otherwise!
*/
-#if __GNUC__ >= 4 && defined(CONFIG_X86_FAST_FEATURE_TESTS)
+#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 are only valid after alternatives have run, but will statically
- * patch the target code for additional performance.
+ * These will statically patch the target code for additional
+ * performance.
*/
static __always_inline __pure bool _static_cpu_has(u16 bit)
{
-#ifdef CC_HAVE_ASM_GOTO
asm_volatile_goto("1: jmp %l[t_dynamic]\n"
"2:\n"
".skip -(((5f-4f) - (2b-1b)) > 0) * "
@@ -172,45 +171,6 @@ static __always_inline __pure bool _static_cpu_has(u16 bit)
return false;
t_dynamic:
return __static_cpu_has(bit);
-#else
- u8 flag;
- /* Open-coded due to __stringify() in ALTERNATIVE() */
- asm volatile("1: movb $2,%0\n"
- "2:\n"
- ".section .altinstructions,\"a\"\n"
- " .long 1b - .\n" /* src offset */
- " .long 3f - .\n" /* repl offset */
- " .word %P2\n" /* always replace */
- " .byte 2b - 1b\n" /* source len */
- " .byte 4f - 3f\n" /* replacement len */
- " .byte 0\n" /* pad len */
- ".previous\n"
- ".section .discard,\"aw\",@progbits\n"
- " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
- ".previous\n"
- ".section .altinstr_replacement,\"ax\"\n"
- "3: movb $0,%0\n"
- "4:\n"
- ".previous\n"
- ".section .altinstructions,\"a\"\n"
- " .long 1b - .\n" /* src offset */
- " .long 5f - .\n" /* repl offset */
- " .word %P1\n" /* feature bit */
- " .byte 4b - 3b\n" /* src len */
- " .byte 6f - 5f\n" /* repl len */
- " .byte 0\n" /* pad len */
- ".previous\n"
- ".section .discard,\"aw\",@progbits\n"
- " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
- ".previous\n"
- ".section .altinstr_replacement,\"ax\"\n"
- "5: movb $1,%0\n"
- "6:\n"
- ".previous\n"
- : "=qm" (flag)
- : "i" (bit), "i" (X86_FEATURE_ALWAYS));
- return (flag == 2 ? __static_cpu_has(bit) : flag);
-#endif /* CC_HAVE_ASM_GOTO */
}
#define static_cpu_has(bit) \
@@ -221,7 +181,8 @@ static __always_inline __pure bool _static_cpu_has(u16 bit)
)
#else
/*
- * gcc 3.x is too stupid to do the static test; fall back to dynamic.
+ * Fall back to dynamic for gcc versions which don't support asm goto. Should be
+ * a minority now anyway.
*/
#define static_cpu_has(bit) boot_cpu_has(bit)
#endif
--
2.3.5
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web