summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2019-03-29 14:52:59 -0400
committerBorislav Petkov <bp@suse.de>2019-04-08 06:13:34 -0400
commit67e87d43b794a8886b5d075b3e0fdd0c615a595f (patch)
tree29d253d071132e7703a88f2c944d2b3096414864
parentbfdd5a67c8cb02c147c6b012543e84cb1f5759ba (diff)
x86: Convert some slow-path static_cpu_has() callers to boot_cpu_has()
Using static_cpu_has() is pointless on those paths, convert them to the boot_cpu_has() variant. No functional changes. Reported-by: Nadav Amit <nadav.amit@gmail.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Rik van Riel <riel@surriel.com> Reviewed-by: Juergen Gross <jgross@suse.com> # for paravirt Cc: Aubrey Li <aubrey.li@intel.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Dominik Brodowski <linux@dominikbrodowski.net> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jann Horn <jannh@google.com> Cc: Joerg Roedel <jroedel@suse.de> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Thomas Lendacky <Thomas.Lendacky@amd.com> Cc: linux-edac@vger.kernel.org Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: virtualization@lists.linux-foundation.org Cc: x86@kernel.org Link: https://lkml.kernel.org/r/20190330112022.28888-3-bp@alien8.de
-rw-r--r--arch/x86/include/asm/fpu/internal.h7
-rw-r--r--arch/x86/kernel/apic/apic_numachip.c2
-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/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
11 files changed, 26 insertions, 27 deletions
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/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/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/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 58ac7be52c7a..16a7113e91c5 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)
@@ -666,7 +666,7 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
666 if (c->x86_vendor != X86_VENDOR_INTEL) 666 if (c->x86_vendor != X86_VENDOR_INTEL)
667 return 0; 667 return 0;
668 668
669 if (!cpu_has(c, X86_FEATURE_MWAIT) || static_cpu_has_bug(X86_BUG_MONITOR)) 669 if (!cpu_has(c, X86_FEATURE_MWAIT) || boot_cpu_has_bug(X86_BUG_MONITOR))
670 return 0; 670 return 0;
671 671
672 return 1; 672 return 1;
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 725624b6c0c0..d62ebbc5ec78 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -108,7 +108,7 @@ void __noreturn machine_real_restart(unsigned int type)
108 write_cr3(real_mode_header->trampoline_pgd); 108 write_cr3(real_mode_header->trampoline_pgd);
109 109
110 /* Exiting long mode will fail if CR4.PCIDE is set. */ 110 /* Exiting long mode will fail if CR4.PCIDE is set. */
111 if (static_cpu_has(X86_FEATURE_PCID)) 111 if (boot_cpu_has(X86_FEATURE_PCID))
112 cr4_clear_bits(X86_CR4_PCIDE); 112 cr4_clear_bits(X86_CR4_PCIDE);
113#endif 113#endif
114 114
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 }