summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-06 18:32:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-06 18:32:35 -0400
commitf725492dd16f516c2b67d7cee90b8619d09fd534 (patch)
treed99530011c025f88fa6e34d84b3d95a612a42469
parent80e77644efcc1ec1064edd4c66a989cdf2e7ec7e (diff)
parent3855f11d54a07256cc4a6fb85c692000208a73a7 (diff)
Merge branch 'x86-asm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 asm updates from Ingo Molnar: "This includes the following changes: - cpu_has() cleanups - sync_bitops.h modernization to the rmwcc.h facility, similarly to bitops.h - continued LTO annotations/fixes - misc cleanups and smaller cleanups" * 'x86-asm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/um/vdso: Drop unnecessary cc-ldoption x86/vdso: Rename variable to fix -Wshadow warning x86/cpu/amd: Exclude 32bit only assembler from 64bit build x86/asm: Mark all top level asm statements as .text x86/build/vdso: Add FORCE to the build rule of %.so x86/asm: Modernize sync_bitops.h x86/mm: Convert some slow-path static_cpu_has() callers to boot_cpu_has() x86: Convert some slow-path static_cpu_has() callers to boot_cpu_has() x86/asm: Clarify static_cpu_has()'s intended use x86/uaccess: Fix implicit cast of __user pointer x86/cpufeature: Remove __pure attribute to _static_cpu_has()
-rw-r--r--arch/x86/entry/vdso/Makefile2
-rw-r--r--arch/x86/entry/vdso/vdso2c.h13
-rw-r--r--arch/x86/include/asm/cpufeature.h11
-rw-r--r--arch/x86/include/asm/fpu/internal.h7
-rw-r--r--arch/x86/include/asm/sync_bitops.h31
-rw-r--r--arch/x86/include/asm/uaccess.h3
-rw-r--r--arch/x86/kernel/apic/apic_numachip.c2
-rw-r--r--arch/x86/kernel/cpu/amd.c5
-rw-r--r--arch/x86/kernel/cpu/aperfmperf.c6
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/cpu/mce/inject.c2
-rw-r--r--arch/x86/kernel/cpu/proc.c10
-rw-r--r--arch/x86/kernel/kprobes/core.c1
-rw-r--r--arch/x86/kernel/ldt.c14
-rw-r--r--arch/x86/kernel/paravirt.c2
-rw-r--r--arch/x86/kernel/process.c4
-rw-r--r--arch/x86/kernel/reboot.c2
-rw-r--r--arch/x86/kernel/vm86_32.c2
-rw-r--r--arch/x86/lib/error-inject.c1
-rw-r--r--arch/x86/mm/dump_pagetables.c4
-rw-r--r--arch/x86/mm/pgtable.c4
-rw-r--r--arch/x86/mm/pti.c2
-rw-r--r--arch/x86/um/vdso/Makefile2
23 files changed, 63 insertions, 69 deletions
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 5bfe2243a08f..42fe42e82baf 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -116,7 +116,7 @@ $(obj)/%-x32.o: $(obj)/%.o FORCE
116targets += vdsox32.lds $(vobjx32s-y) 116targets += vdsox32.lds $(vobjx32s-y)
117 117
118$(obj)/%.so: OBJCOPYFLAGS := -S 118$(obj)/%.so: OBJCOPYFLAGS := -S
119$(obj)/%.so: $(obj)/%.so.dbg 119$(obj)/%.so: $(obj)/%.so.dbg FORCE
120 $(call if_changed,objcopy) 120 $(call if_changed,objcopy)
121 121
122$(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE 122$(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h
index fa847a620f40..a20b134de2a8 100644
--- a/arch/x86/entry/vdso/vdso2c.h
+++ b/arch/x86/entry/vdso/vdso2c.h
@@ -7,7 +7,7 @@
7 7
8static void BITSFUNC(go)(void *raw_addr, size_t raw_len, 8static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
9 void *stripped_addr, size_t stripped_len, 9 void *stripped_addr, size_t stripped_len,
10 FILE *outfile, const char *name) 10 FILE *outfile, const char *image_name)
11{ 11{
12 int found_load = 0; 12 int found_load = 0;
13 unsigned long load_size = -1; /* Work around bogus warning */ 13 unsigned long load_size = -1; /* Work around bogus warning */
@@ -93,11 +93,12 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
93 int k; 93 int k;
94 ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) + 94 ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
95 GET_LE(&symtab_hdr->sh_entsize) * i; 95 GET_LE(&symtab_hdr->sh_entsize) * i;
96 const char *name = raw_addr + GET_LE(&strtab_hdr->sh_offset) + 96 const char *sym_name = raw_addr +
97 GET_LE(&sym->st_name); 97 GET_LE(&strtab_hdr->sh_offset) +
98 GET_LE(&sym->st_name);
98 99
99 for (k = 0; k < NSYMS; k++) { 100 for (k = 0; k < NSYMS; k++) {
100 if (!strcmp(name, required_syms[k].name)) { 101 if (!strcmp(sym_name, required_syms[k].name)) {
101 if (syms[k]) { 102 if (syms[k]) {
102 fail("duplicate symbol %s\n", 103 fail("duplicate symbol %s\n",
103 required_syms[k].name); 104 required_syms[k].name);
@@ -134,7 +135,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
134 if (syms[sym_vvar_start] % 4096) 135 if (syms[sym_vvar_start] % 4096)
135 fail("vvar_begin must be a multiple of 4096\n"); 136 fail("vvar_begin must be a multiple of 4096\n");
136 137
137 if (!name) { 138 if (!image_name) {
138 fwrite(stripped_addr, stripped_len, 1, outfile); 139 fwrite(stripped_addr, stripped_len, 1, outfile);
139 return; 140 return;
140 } 141 }
@@ -157,7 +158,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
157 } 158 }
158 fprintf(outfile, "\n};\n\n"); 159 fprintf(outfile, "\n};\n\n");
159 160
160 fprintf(outfile, "const struct vdso_image %s = {\n", name); 161 fprintf(outfile, "const struct vdso_image %s = {\n", image_name);
161 fprintf(outfile, "\t.data = raw_data,\n"); 162 fprintf(outfile, "\t.data = raw_data,\n");
162 fprintf(outfile, "\t.size = %lu,\n", mapping_size); 163 fprintf(outfile, "\t.size = %lu,\n", mapping_size);
163 if (alt_sec) { 164 if (alt_sec) {
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 0e56ff7e4848..1d337c51f7e6 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -156,11 +156,14 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit);
156#else 156#else
157 157
158/* 158/*
159 * Static testing of CPU features. Used the same as boot_cpu_has(). 159 * Static testing of CPU features. Used the same as boot_cpu_has(). It
160 * These will statically patch the target code for additional 160 * statically patches the target code for additional performance. Use
161 * performance. 161 * static_cpu_has() only in fast paths, where every cycle counts. Which
162 * means that the boot_cpu_has() variant is already fast enough for the
163 * majority of cases and you should stick to using it as it is generally
164 * only two instructions: a RIP-relative MOV and a TEST.
162 */ 165 */
163static __always_inline __pure bool _static_cpu_has(u16 bit) 166static __always_inline bool _static_cpu_has(u16 bit)
164{ 167{
165 asm_volatile_goto("1: jmp 6f\n" 168 asm_volatile_goto("1: jmp 6f\n"
166 "2:\n" 169 "2:\n"
diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
index fb04a3ded7dd..745a19d34f23 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -253,7 +253,7 @@ static inline void copy_xregs_to_kernel_booting(struct xregs_state *xstate)
253 253
254 WARN_ON(system_state != SYSTEM_BOOTING); 254 WARN_ON(system_state != SYSTEM_BOOTING);
255 255
256 if (static_cpu_has(X86_FEATURE_XSAVES)) 256 if (boot_cpu_has(X86_FEATURE_XSAVES))
257 XSTATE_OP(XSAVES, xstate, lmask, hmask, err); 257 XSTATE_OP(XSAVES, xstate, lmask, hmask, err);
258 else 258 else
259 XSTATE_OP(XSAVE, xstate, lmask, hmask, err); 259 XSTATE_OP(XSAVE, xstate, lmask, hmask, err);
@@ -275,7 +275,7 @@ static inline void copy_kernel_to_xregs_booting(struct xregs_state *xstate)
275 275
276 WARN_ON(system_state != SYSTEM_BOOTING); 276 WARN_ON(system_state != SYSTEM_BOOTING);
277 277
278 if (static_cpu_has(X86_FEATURE_XSAVES)) 278 if (boot_cpu_has(X86_FEATURE_XSAVES))
279 XSTATE_OP(XRSTORS, xstate, lmask, hmask, err); 279 XSTATE_OP(XRSTORS, xstate, lmask, hmask, err);
280 else 280 else
281 XSTATE_OP(XRSTOR, xstate, lmask, hmask, err); 281 XSTATE_OP(XRSTOR, xstate, lmask, hmask, err);
@@ -497,8 +497,7 @@ static inline void fpregs_activate(struct fpu *fpu)
497 * - switch_fpu_finish() restores the new state as 497 * - switch_fpu_finish() restores the new state as
498 * necessary. 498 * necessary.
499 */ 499 */
500static inline void 500static inline void switch_fpu_prepare(struct fpu *old_fpu, int cpu)
501switch_fpu_prepare(struct fpu *old_fpu, int cpu)
502{ 501{
503 if (static_cpu_has(X86_FEATURE_FPU) && old_fpu->initialized) { 502 if (static_cpu_has(X86_FEATURE_FPU) && old_fpu->initialized) {
504 if (!copy_fpregs_to_fpstate(old_fpu)) 503 if (!copy_fpregs_to_fpstate(old_fpu))
diff --git a/arch/x86/include/asm/sync_bitops.h b/arch/x86/include/asm/sync_bitops.h
index 2fe745356fb1..6d8d6bc183b7 100644
--- a/arch/x86/include/asm/sync_bitops.h
+++ b/arch/x86/include/asm/sync_bitops.h
@@ -14,6 +14,8 @@
14 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). 14 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
15 */ 15 */
16 16
17#include <asm/rmwcc.h>
18
17#define ADDR (*(volatile long *)addr) 19#define ADDR (*(volatile long *)addr)
18 20
19/** 21/**
@@ -29,7 +31,7 @@
29 */ 31 */
30static inline void sync_set_bit(long nr, volatile unsigned long *addr) 32static inline void sync_set_bit(long nr, volatile unsigned long *addr)
31{ 33{
32 asm volatile("lock; bts %1,%0" 34 asm volatile("lock; " __ASM_SIZE(bts) " %1,%0"
33 : "+m" (ADDR) 35 : "+m" (ADDR)
34 : "Ir" (nr) 36 : "Ir" (nr)
35 : "memory"); 37 : "memory");
@@ -47,7 +49,7 @@ static inline void sync_set_bit(long nr, volatile unsigned long *addr)
47 */ 49 */
48static inline void sync_clear_bit(long nr, volatile unsigned long *addr) 50static inline void sync_clear_bit(long nr, volatile unsigned long *addr)
49{ 51{
50 asm volatile("lock; btr %1,%0" 52 asm volatile("lock; " __ASM_SIZE(btr) " %1,%0"
51 : "+m" (ADDR) 53 : "+m" (ADDR)
52 : "Ir" (nr) 54 : "Ir" (nr)
53 : "memory"); 55 : "memory");
@@ -64,7 +66,7 @@ static inline void sync_clear_bit(long nr, volatile unsigned long *addr)
64 */ 66 */
65static inline void sync_change_bit(long nr, volatile unsigned long *addr) 67static inline void sync_change_bit(long nr, volatile unsigned long *addr)
66{ 68{
67 asm volatile("lock; btc %1,%0" 69 asm volatile("lock; " __ASM_SIZE(btc) " %1,%0"
68 : "+m" (ADDR) 70 : "+m" (ADDR)
69 : "Ir" (nr) 71 : "Ir" (nr)
70 : "memory"); 72 : "memory");
@@ -78,14 +80,9 @@ static inline void sync_change_bit(long nr, volatile unsigned long *addr)
78 * This operation is atomic and cannot be reordered. 80 * This operation is atomic and cannot be reordered.
79 * It also implies a memory barrier. 81 * It also implies a memory barrier.
80 */ 82 */
81static inline int sync_test_and_set_bit(long nr, volatile unsigned long *addr) 83static inline bool sync_test_and_set_bit(long nr, volatile unsigned long *addr)
82{ 84{
83 unsigned char oldbit; 85 return GEN_BINARY_RMWcc("lock; " __ASM_SIZE(bts), *addr, c, "Ir", nr);
84
85 asm volatile("lock; bts %2,%1\n\tsetc %0"
86 : "=qm" (oldbit), "+m" (ADDR)
87 : "Ir" (nr) : "memory");
88 return oldbit;
89} 86}
90 87
91/** 88/**
@@ -98,12 +95,7 @@ static inline int sync_test_and_set_bit(long nr, volatile unsigned long *addr)
98 */ 95 */
99static inline int sync_test_and_clear_bit(long nr, volatile unsigned long *addr) 96static inline int sync_test_and_clear_bit(long nr, volatile unsigned long *addr)
100{ 97{
101 unsigned char oldbit; 98 return GEN_BINARY_RMWcc("lock; " __ASM_SIZE(btr), *addr, c, "Ir", nr);
102
103 asm volatile("lock; btr %2,%1\n\tsetc %0"
104 : "=qm" (oldbit), "+m" (ADDR)
105 : "Ir" (nr) : "memory");
106 return oldbit;
107} 99}
108 100
109/** 101/**
@@ -116,12 +108,7 @@ static inline int sync_test_and_clear_bit(long nr, volatile unsigned long *addr)
116 */ 108 */
117static inline int sync_test_and_change_bit(long nr, volatile unsigned long *addr) 109static inline int sync_test_and_change_bit(long nr, volatile unsigned long *addr)
118{ 110{
119 unsigned char oldbit; 111 return GEN_BINARY_RMWcc("lock; " __ASM_SIZE(btc), *addr, c, "Ir", nr);
120
121 asm volatile("lock; btc %2,%1\n\tsetc %0"
122 : "=qm" (oldbit), "+m" (ADDR)
123 : "Ir" (nr) : "memory");
124 return oldbit;
125} 112}
126 113
127#define sync_test_bit(nr, addr) test_bit(nr, addr) 114#define sync_test_bit(nr, addr) test_bit(nr, addr)
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index bb21913885a3..c82abd6e4ca3 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -586,7 +586,6 @@ extern void __cmpxchg_wrong_size(void)
586#define __user_atomic_cmpxchg_inatomic(uval, ptr, old, new, size) \ 586#define __user_atomic_cmpxchg_inatomic(uval, ptr, old, new, size) \
587({ \ 587({ \
588 int __ret = 0; \ 588 int __ret = 0; \
589 __typeof__(ptr) __uval = (uval); \
590 __typeof__(*(ptr)) __old = (old); \ 589 __typeof__(*(ptr)) __old = (old); \
591 __typeof__(*(ptr)) __new = (new); \ 590 __typeof__(*(ptr)) __new = (new); \
592 __uaccess_begin_nospec(); \ 591 __uaccess_begin_nospec(); \
@@ -662,7 +661,7 @@ extern void __cmpxchg_wrong_size(void)
662 __cmpxchg_wrong_size(); \ 661 __cmpxchg_wrong_size(); \
663 } \ 662 } \
664 __uaccess_end(); \ 663 __uaccess_end(); \
665 *__uval = __old; \ 664 *(uval) = __old; \
666 __ret; \ 665 __ret; \
667}) 666})
668 667
diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c
index 78778b54f904..a5464b8b6c46 100644
--- a/arch/x86/kernel/apic/apic_numachip.c
+++ b/arch/x86/kernel/apic/apic_numachip.c
@@ -175,7 +175,7 @@ static void fixup_cpu_id(struct cpuinfo_x86 *c, int node)
175 this_cpu_write(cpu_llc_id, node); 175 this_cpu_write(cpu_llc_id, node);
176 176
177 /* Account for nodes per socket in multi-core-module processors */ 177 /* Account for nodes per socket in multi-core-module processors */
178 if (static_cpu_has(X86_FEATURE_NODEID_MSR)) { 178 if (boot_cpu_has(X86_FEATURE_NODEID_MSR)) {
179 rdmsrl(MSR_FAM10H_NODE_ID, val); 179 rdmsrl(MSR_FAM10H_NODE_ID, val);
180 nodes = ((val >> 3) & 7) + 1; 180 nodes = ((val >> 3) & 7) + 1;
181 } 181 }
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 01004bfb1a1b..fb6a64bd765f 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -82,11 +82,14 @@ static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
82 * performance at the same time.. 82 * performance at the same time..
83 */ 83 */
84 84
85#ifdef CONFIG_X86_32
85extern __visible void vide(void); 86extern __visible void vide(void);
86__asm__(".globl vide\n" 87__asm__(".text\n"
88 ".globl vide\n"
87 ".type vide, @function\n" 89 ".type vide, @function\n"
88 ".align 4\n" 90 ".align 4\n"
89 "vide: ret\n"); 91 "vide: ret\n");
92#endif
90 93
91static void init_amd_k5(struct cpuinfo_x86 *c) 94static void init_amd_k5(struct cpuinfo_x86 *c)
92{ 95{
diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index 804c49493938..64d5aec24203 100644
--- a/arch/x86/kernel/cpu/aperfmperf.c
+++ b/arch/x86/kernel/cpu/aperfmperf.c
@@ -83,7 +83,7 @@ unsigned int aperfmperf_get_khz(int cpu)
83 if (!cpu_khz) 83 if (!cpu_khz)
84 return 0; 84 return 0;
85 85
86 if (!static_cpu_has(X86_FEATURE_APERFMPERF)) 86 if (!boot_cpu_has(X86_FEATURE_APERFMPERF))
87 return 0; 87 return 0;
88 88
89 aperfmperf_snapshot_cpu(cpu, ktime_get(), true); 89 aperfmperf_snapshot_cpu(cpu, ktime_get(), true);
@@ -99,7 +99,7 @@ void arch_freq_prepare_all(void)
99 if (!cpu_khz) 99 if (!cpu_khz)
100 return; 100 return;
101 101
102 if (!static_cpu_has(X86_FEATURE_APERFMPERF)) 102 if (!boot_cpu_has(X86_FEATURE_APERFMPERF))
103 return; 103 return;
104 104
105 for_each_online_cpu(cpu) 105 for_each_online_cpu(cpu)
@@ -115,7 +115,7 @@ unsigned int arch_freq_get_on_cpu(int cpu)
115 if (!cpu_khz) 115 if (!cpu_khz)
116 return 0; 116 return 0;
117 117
118 if (!static_cpu_has(X86_FEATURE_APERFMPERF)) 118 if (!boot_cpu_has(X86_FEATURE_APERFMPERF))
119 return 0; 119 return 0;
120 120
121 if (aperfmperf_snapshot_cpu(cpu, ktime_get(), true)) 121 if (aperfmperf_snapshot_cpu(cpu, ktime_get(), true))
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index cb28e98a0659..95a5faf3a6a0 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1668,7 +1668,7 @@ static void setup_getcpu(int cpu)
1668 unsigned long cpudata = vdso_encode_cpunode(cpu, early_cpu_to_node(cpu)); 1668 unsigned long cpudata = vdso_encode_cpunode(cpu, early_cpu_to_node(cpu));
1669 struct desc_struct d = { }; 1669 struct desc_struct d = { };
1670 1670
1671 if (static_cpu_has(X86_FEATURE_RDTSCP)) 1671 if (boot_cpu_has(X86_FEATURE_RDTSCP))
1672 write_rdtscp_aux(cpudata); 1672 write_rdtscp_aux(cpudata);
1673 1673
1674 /* Store CPU and node number in limit. */ 1674 /* Store CPU and node number in limit. */
diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
index 8492ef7d9015..3da9a8823e47 100644
--- a/arch/x86/kernel/cpu/mce/inject.c
+++ b/arch/x86/kernel/cpu/mce/inject.c
@@ -528,7 +528,7 @@ static void do_inject(void)
528 * only on the node base core. Refer to D18F3x44[NbMcaToMstCpuEn] for 528 * only on the node base core. Refer to D18F3x44[NbMcaToMstCpuEn] for
529 * Fam10h and later BKDGs. 529 * Fam10h and later BKDGs.
530 */ 530 */
531 if (static_cpu_has(X86_FEATURE_AMD_DCM) && 531 if (boot_cpu_has(X86_FEATURE_AMD_DCM) &&
532 b == 4 && 532 b == 4 &&
533 boot_cpu_data.x86 < 0x17) { 533 boot_cpu_data.x86 < 0x17) {
534 toggle_nb_mca_mst_cpu(amd_get_nb_id(cpu)); 534 toggle_nb_mca_mst_cpu(amd_get_nb_id(cpu));
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index 2c8522a39ed5..cb2e49810d68 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -35,11 +35,11 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)
35 "fpu_exception\t: %s\n" 35 "fpu_exception\t: %s\n"
36 "cpuid level\t: %d\n" 36 "cpuid level\t: %d\n"
37 "wp\t\t: yes\n", 37 "wp\t\t: yes\n",
38 static_cpu_has_bug(X86_BUG_FDIV) ? "yes" : "no", 38 boot_cpu_has_bug(X86_BUG_FDIV) ? "yes" : "no",
39 static_cpu_has_bug(X86_BUG_F00F) ? "yes" : "no", 39 boot_cpu_has_bug(X86_BUG_F00F) ? "yes" : "no",
40 static_cpu_has_bug(X86_BUG_COMA) ? "yes" : "no", 40 boot_cpu_has_bug(X86_BUG_COMA) ? "yes" : "no",
41 static_cpu_has(X86_FEATURE_FPU) ? "yes" : "no", 41 boot_cpu_has(X86_FEATURE_FPU) ? "yes" : "no",
42 static_cpu_has(X86_FEATURE_FPU) ? "yes" : "no", 42 boot_cpu_has(X86_FEATURE_FPU) ? "yes" : "no",
43 c->cpuid_level); 43 c->cpuid_level);
44} 44}
45#else 45#else
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index fed46ddb1eef..122548ad5c2e 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -716,6 +716,7 @@ NOKPROBE_SYMBOL(kprobe_int3_handler);
716 * calls trampoline_handler() runs, which calls the kretprobe's handler. 716 * calls trampoline_handler() runs, which calls the kretprobe's handler.
717 */ 717 */
718asm( 718asm(
719 ".text\n"
719 ".global kretprobe_trampoline\n" 720 ".global kretprobe_trampoline\n"
720 ".type kretprobe_trampoline, @function\n" 721 ".type kretprobe_trampoline, @function\n"
721 "kretprobe_trampoline:\n" 722 "kretprobe_trampoline:\n"
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 6135ae8ce036..b2463fcb20a8 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -113,7 +113,7 @@ static void do_sanity_check(struct mm_struct *mm,
113 * tables. 113 * tables.
114 */ 114 */
115 WARN_ON(!had_kernel_mapping); 115 WARN_ON(!had_kernel_mapping);
116 if (static_cpu_has(X86_FEATURE_PTI)) 116 if (boot_cpu_has(X86_FEATURE_PTI))
117 WARN_ON(!had_user_mapping); 117 WARN_ON(!had_user_mapping);
118 } else { 118 } else {
119 /* 119 /*
@@ -121,7 +121,7 @@ static void do_sanity_check(struct mm_struct *mm,
121 * Sync the pgd to the usermode tables. 121 * Sync the pgd to the usermode tables.
122 */ 122 */
123 WARN_ON(had_kernel_mapping); 123 WARN_ON(had_kernel_mapping);
124 if (static_cpu_has(X86_FEATURE_PTI)) 124 if (boot_cpu_has(X86_FEATURE_PTI))
125 WARN_ON(had_user_mapping); 125 WARN_ON(had_user_mapping);
126 } 126 }
127} 127}
@@ -156,7 +156,7 @@ static void map_ldt_struct_to_user(struct mm_struct *mm)
156 k_pmd = pgd_to_pmd_walk(k_pgd, LDT_BASE_ADDR); 156 k_pmd = pgd_to_pmd_walk(k_pgd, LDT_BASE_ADDR);
157 u_pmd = pgd_to_pmd_walk(u_pgd, LDT_BASE_ADDR); 157 u_pmd = pgd_to_pmd_walk(u_pgd, LDT_BASE_ADDR);
158 158
159 if (static_cpu_has(X86_FEATURE_PTI) && !mm->context.ldt) 159 if (boot_cpu_has(X86_FEATURE_PTI) && !mm->context.ldt)
160 set_pmd(u_pmd, *k_pmd); 160 set_pmd(u_pmd, *k_pmd);
161} 161}
162 162
@@ -181,7 +181,7 @@ static void map_ldt_struct_to_user(struct mm_struct *mm)
181{ 181{
182 pgd_t *pgd = pgd_offset(mm, LDT_BASE_ADDR); 182 pgd_t *pgd = pgd_offset(mm, LDT_BASE_ADDR);
183 183
184 if (static_cpu_has(X86_FEATURE_PTI) && !mm->context.ldt) 184 if (boot_cpu_has(X86_FEATURE_PTI) && !mm->context.ldt)
185 set_pgd(kernel_to_user_pgdp(pgd), *pgd); 185 set_pgd(kernel_to_user_pgdp(pgd), *pgd);
186} 186}
187 187
@@ -208,7 +208,7 @@ map_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt, int slot)
208 spinlock_t *ptl; 208 spinlock_t *ptl;
209 int i, nr_pages; 209 int i, nr_pages;
210 210
211 if (!static_cpu_has(X86_FEATURE_PTI)) 211 if (!boot_cpu_has(X86_FEATURE_PTI))
212 return 0; 212 return 0;
213 213
214 /* 214 /*
@@ -271,7 +271,7 @@ static void unmap_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt)
271 return; 271 return;
272 272
273 /* LDT map/unmap is only required for PTI */ 273 /* LDT map/unmap is only required for PTI */
274 if (!static_cpu_has(X86_FEATURE_PTI)) 274 if (!boot_cpu_has(X86_FEATURE_PTI))
275 return; 275 return;
276 276
277 nr_pages = DIV_ROUND_UP(ldt->nr_entries * LDT_ENTRY_SIZE, PAGE_SIZE); 277 nr_pages = DIV_ROUND_UP(ldt->nr_entries * LDT_ENTRY_SIZE, PAGE_SIZE);
@@ -311,7 +311,7 @@ static void free_ldt_pgtables(struct mm_struct *mm)
311 unsigned long start = LDT_BASE_ADDR; 311 unsigned long start = LDT_BASE_ADDR;
312 unsigned long end = LDT_END_ADDR; 312 unsigned long end = LDT_END_ADDR;
313 313
314 if (!static_cpu_has(X86_FEATURE_PTI)) 314 if (!boot_cpu_has(X86_FEATURE_PTI))
315 return; 315 return;
316 316
317 tlb_gather_mmu(&tlb, mm, start, end); 317 tlb_gather_mmu(&tlb, mm, start, end);
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index c0e0101133f3..7bbaa6baf37f 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -121,7 +121,7 @@ DEFINE_STATIC_KEY_TRUE(virt_spin_lock_key);
121 121
122void __init native_pv_lock_init(void) 122void __init native_pv_lock_init(void)
123{ 123{
124 if (!static_cpu_has(X86_FEATURE_HYPERVISOR)) 124 if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
125 static_branch_disable(&virt_spin_lock_key); 125 static_branch_disable(&virt_spin_lock_key);
126} 126}
127 127
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 957eae13b370..d1d312d012a6 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -236,7 +236,7 @@ static int get_cpuid_mode(void)
236 236
237static int set_cpuid_mode(struct task_struct *task, unsigned long cpuid_enabled) 237static int set_cpuid_mode(struct task_struct *task, unsigned long cpuid_enabled)
238{ 238{
239 if (!static_cpu_has(X86_FEATURE_CPUID_FAULT)) 239 if (!boot_cpu_has(X86_FEATURE_CPUID_FAULT))
240 return -ENODEV; 240 return -ENODEV;
241 241
242 if (cpuid_enabled) 242 if (cpuid_enabled)
@@ -670,7 +670,7 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
670 if (c->x86_vendor != X86_VENDOR_INTEL) 670 if (c->x86_vendor != X86_VENDOR_INTEL)
671 return 0; 671 return 0;
672 672
673 if (!cpu_has(c, X86_FEATURE_MWAIT) || static_cpu_has_bug(X86_BUG_MONITOR)) 673 if (!cpu_has(c, X86_FEATURE_MWAIT) || boot_cpu_has_bug(X86_BUG_MONITOR))
674 return 0; 674 return 0;
675 675
676 return 1; 676 return 1;
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 8fd3cedd9acc..09d6bded3c1e 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -121,7 +121,7 @@ void __noreturn machine_real_restart(unsigned int type)
121 write_cr3(real_mode_header->trampoline_pgd); 121 write_cr3(real_mode_header->trampoline_pgd);
122 122
123 /* Exiting long mode will fail if CR4.PCIDE is set. */ 123 /* Exiting long mode will fail if CR4.PCIDE is set. */
124 if (static_cpu_has(X86_FEATURE_PCID)) 124 if (boot_cpu_has(X86_FEATURE_PCID))
125 cr4_clear_bits(X86_CR4_PCIDE); 125 cr4_clear_bits(X86_CR4_PCIDE);
126#endif 126#endif
127 127
diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
index a092b6b40c6b..6a38717d179c 100644
--- a/arch/x86/kernel/vm86_32.c
+++ b/arch/x86/kernel/vm86_32.c
@@ -369,7 +369,7 @@ static long do_sys_vm86(struct vm86plus_struct __user *user_vm86, bool plus)
369 preempt_disable(); 369 preempt_disable();
370 tsk->thread.sp0 += 16; 370 tsk->thread.sp0 += 16;
371 371
372 if (static_cpu_has(X86_FEATURE_SEP)) { 372 if (boot_cpu_has(X86_FEATURE_SEP)) {
373 tsk->thread.sysenter_cs = 0; 373 tsk->thread.sysenter_cs = 0;
374 refresh_sysenter_cs(&tsk->thread); 374 refresh_sysenter_cs(&tsk->thread);
375 } 375 }
diff --git a/arch/x86/lib/error-inject.c b/arch/x86/lib/error-inject.c
index 3cdf06128d13..be5b5fb1598b 100644
--- a/arch/x86/lib/error-inject.c
+++ b/arch/x86/lib/error-inject.c
@@ -6,6 +6,7 @@
6asmlinkage void just_return_func(void); 6asmlinkage void just_return_func(void);
7 7
8asm( 8asm(
9 ".text\n"
9 ".type just_return_func, @function\n" 10 ".type just_return_func, @function\n"
10 ".globl just_return_func\n" 11 ".globl just_return_func\n"
11 "just_return_func:\n" 12 "just_return_func:\n"
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index c0309ea9abee..6a7302d1161f 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -578,7 +578,7 @@ void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd)
578void ptdump_walk_pgd_level_debugfs(struct seq_file *m, pgd_t *pgd, bool user) 578void ptdump_walk_pgd_level_debugfs(struct seq_file *m, pgd_t *pgd, bool user)
579{ 579{
580#ifdef CONFIG_PAGE_TABLE_ISOLATION 580#ifdef CONFIG_PAGE_TABLE_ISOLATION
581 if (user && static_cpu_has(X86_FEATURE_PTI)) 581 if (user && boot_cpu_has(X86_FEATURE_PTI))
582 pgd = kernel_to_user_pgdp(pgd); 582 pgd = kernel_to_user_pgdp(pgd);
583#endif 583#endif
584 ptdump_walk_pgd_level_core(m, pgd, false, false); 584 ptdump_walk_pgd_level_core(m, pgd, false, false);
@@ -591,7 +591,7 @@ void ptdump_walk_user_pgd_level_checkwx(void)
591 pgd_t *pgd = INIT_PGD; 591 pgd_t *pgd = INIT_PGD;
592 592
593 if (!(__supported_pte_mask & _PAGE_NX) || 593 if (!(__supported_pte_mask & _PAGE_NX) ||
594 !static_cpu_has(X86_FEATURE_PTI)) 594 !boot_cpu_has(X86_FEATURE_PTI))
595 return; 595 return;
596 596
597 pr_info("x86/mm: Checking user space page tables\n"); 597 pr_info("x86/mm: Checking user space page tables\n");
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 7bd01709a091..3dbf440d4114 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -190,7 +190,7 @@ static void pgd_dtor(pgd_t *pgd)
190 * when PTI is enabled. We need them to map the per-process LDT into the 190 * when PTI is enabled. We need them to map the per-process LDT into the
191 * user-space page-table. 191 * user-space page-table.
192 */ 192 */
193#define PREALLOCATED_USER_PMDS (static_cpu_has(X86_FEATURE_PTI) ? \ 193#define PREALLOCATED_USER_PMDS (boot_cpu_has(X86_FEATURE_PTI) ? \
194 KERNEL_PGD_PTRS : 0) 194 KERNEL_PGD_PTRS : 0)
195#define MAX_PREALLOCATED_USER_PMDS KERNEL_PGD_PTRS 195#define MAX_PREALLOCATED_USER_PMDS KERNEL_PGD_PTRS
196 196
@@ -292,7 +292,7 @@ static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
292 292
293#ifdef CONFIG_PAGE_TABLE_ISOLATION 293#ifdef CONFIG_PAGE_TABLE_ISOLATION
294 294
295 if (!static_cpu_has(X86_FEATURE_PTI)) 295 if (!boot_cpu_has(X86_FEATURE_PTI))
296 return; 296 return;
297 297
298 pgdp = kernel_to_user_pgdp(pgdp); 298 pgdp = kernel_to_user_pgdp(pgdp);
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index d0255d64edce..9c2463bc158f 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -628,7 +628,7 @@ static void pti_set_kernel_image_nonglobal(void)
628 */ 628 */
629void __init pti_init(void) 629void __init pti_init(void)
630{ 630{
631 if (!static_cpu_has(X86_FEATURE_PTI)) 631 if (!boot_cpu_has(X86_FEATURE_PTI))
632 return; 632 return;
633 633
634 pr_info("enabled\n"); 634 pr_info("enabled\n");
diff --git a/arch/x86/um/vdso/Makefile b/arch/x86/um/vdso/Makefile
index bf94060fc06f..0caddd6acb22 100644
--- a/arch/x86/um/vdso/Makefile
+++ b/arch/x86/um/vdso/Makefile
@@ -62,7 +62,7 @@ quiet_cmd_vdso = VDSO $@
62 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \ 62 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
63 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' 63 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
64 64
65VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) 65VDSO_LDFLAGS = -fPIC -shared -Wl,--hash-style=sysv
66GCOV_PROFILE := n 66GCOV_PROFILE := n
67 67
68# 68#