Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/bear: Convert cpu_has_bear() to cpu feature function

Get rid of the cpu_has_bear jump label and convert cpu_has_bear() to a cpu
feature function using test_facility() and with that use a static branch.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by

Heiko Carstens and committed by
Vasily Gorbik
841f35a0 db14f78e

+11 -13
+1
arch/s390/include/asm/cpufeature.h
··· 22 22 23 23 int cpu_have_feature(unsigned int nr); 24 24 25 + #define cpu_has_bear() test_facility(193) 25 26 #define cpu_has_edat1() test_facility(8) 26 27 #define cpu_has_edat2() test_facility(78) 27 28 #define cpu_has_gs() test_facility(133)
+3 -2
arch/s390/kernel/irq.c
··· 9 9 */ 10 10 11 11 #include <linux/kernel_stat.h> 12 + #include <linux/cpufeature.h> 12 13 #include <linux/interrupt.h> 13 14 #include <linux/seq_file.h> 14 15 #include <linux/proc_fs.h> ··· 151 150 152 151 if (user_mode(regs)) { 153 152 update_timer_sys(); 154 - if (static_branch_likely(&cpu_has_bear)) 153 + if (cpu_has_bear()) 155 154 current->thread.last_break = regs->last_break; 156 155 } 157 156 ··· 187 186 188 187 if (user_mode(regs)) { 189 188 update_timer_sys(); 190 - if (static_branch_likely(&cpu_has_bear)) 189 + if (cpu_has_bear()) 191 190 current->thread.last_break = regs->last_break; 192 191 } 193 192
-6
arch/s390/kernel/setup.c
··· 181 181 struct lowcore *lowcore_ptr[NR_CPUS]; 182 182 EXPORT_SYMBOL(lowcore_ptr); 183 183 184 - DEFINE_STATIC_KEY_FALSE(cpu_has_bear); 185 - 186 184 /* 187 185 * The Write Back bit position in the physaddr is given by the SLPC PCI. 188 186 * Leaving the mask zero always uses write through which is safe ··· 980 982 numa_setup(); 981 983 smp_detect_cpus(); 982 984 topology_init_early(); 983 - 984 - if (test_facility(193)) 985 - static_branch_enable(&cpu_has_bear); 986 - 987 985 setup_protection_map(); 988 986 /* 989 987 * Create kernel page tables.
+2 -1
arch/s390/kernel/syscall.c
··· 12 12 * platform. 13 13 */ 14 14 15 + #include <linux/cpufeature.h> 15 16 #include <linux/errno.h> 16 17 #include <linux/sched.h> 17 18 #include <linux/mm.h> ··· 128 127 regs->psw = get_lowcore()->svc_old_psw; 129 128 regs->int_code = get_lowcore()->svc_int_code; 130 129 update_timer_sys(); 131 - if (static_branch_likely(&cpu_has_bear)) 130 + if (cpu_has_bear()) 132 131 current->thread.last_break = regs->last_break; 133 132 134 133 local_irq_enable();
+2 -1
arch/s390/kernel/traps.c
··· 15 15 */ 16 16 #include "asm/irqflags.h" 17 17 #include "asm/ptrace.h" 18 + #include <linux/cpufeature.h> 18 19 #include <linux/kprobes.h> 19 20 #include <linux/kdebug.h> 20 21 #include <linux/randomize_kstack.h> ··· 342 341 343 342 if (user_mode(regs)) { 344 343 update_timer_sys(); 345 - if (!static_branch_likely(&cpu_has_bear)) { 344 + if (!cpu_has_bear()) { 346 345 if (regs->last_break < 4096) 347 346 regs->last_break = 1; 348 347 }
+2 -2
arch/s390/mm/dump_pagetables.c
··· 84 84 * in which case we have two lpswe instructions in lowcore that need 85 85 * to be executable. 86 86 */ 87 - if (addr == PAGE_SIZE && (nospec_uses_trampoline() || !static_key_enabled(&cpu_has_bear))) 87 + if (addr == PAGE_SIZE && (nospec_uses_trampoline() || !cpu_has_bear())) 88 88 return; 89 89 WARN_ONCE(IS_ENABLED(CONFIG_DEBUG_WX), 90 90 "s390/mm: Found insecure W+X mapping at address %pS\n", ··· 178 178 return false; 179 179 } else { 180 180 pr_info("Checked W+X mappings: passed, no %sW+X pages found\n", 181 - (nospec_uses_trampoline() || !static_key_enabled(&cpu_has_bear)) ? 181 + (nospec_uses_trampoline() || !cpu_has_bear()) ? 182 182 "unexpected " : ""); 183 183 184 184 return true;
+1 -1
arch/s390/mm/vmem.c
··· 660 660 * prefix page is used to return to the previous context with 661 661 * an LPSWE instruction and therefore must be executable. 662 662 */ 663 - if (!static_key_enabled(&cpu_has_bear)) 663 + if (!cpu_has_bear()) 664 664 set_memory_x(0, 1); 665 665 if (debug_pagealloc_enabled()) 666 666 __set_memory_4k(__va(0), absolute_pointer(__va(0)) + ident_map_size);