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

s390/cpufeature: Convert MACHINE_HAS_SEQ_INSN to cpu_has_seq_insn()

Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

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
679b110b 4a66f273

+13 -11
+4
arch/s390/include/asm/cpufeature.h
··· 9 9 #ifndef __ASM_S390_CPUFEATURE_H 10 10 #define __ASM_S390_CPUFEATURE_H 11 11 12 + #include <asm/facility.h> 13 + 12 14 enum { 13 15 S390_CPU_FEATURE_MSA, 14 16 S390_CPU_FEATURE_VXRS, ··· 21 19 #define cpu_feature(feature) (feature) 22 20 23 21 int cpu_have_feature(unsigned int nr); 22 + 23 + #define cpu_has_seq_insn() test_facility(85) 24 24 25 25 #endif /* __ASM_S390_CPUFEATURE_H */
-2
arch/s390/include/asm/setup.h
··· 34 34 #define MACHINE_FLAG_SCC BIT(17) 35 35 #define MACHINE_FLAG_PCI_MIO BIT(18) 36 36 #define MACHINE_FLAG_RDP BIT(19) 37 - #define MACHINE_FLAG_SEQ_INSN BIT(20) 38 37 39 38 #define LPP_MAGIC BIT(31) 40 39 #define LPP_PID_MASK _AC(0xffffffff, UL) ··· 95 96 #define MACHINE_HAS_SCC (get_lowcore()->machine_flags & MACHINE_FLAG_SCC) 96 97 #define MACHINE_HAS_PCI_MIO (get_lowcore()->machine_flags & MACHINE_FLAG_PCI_MIO) 97 98 #define MACHINE_HAS_RDP (get_lowcore()->machine_flags & MACHINE_FLAG_RDP) 98 - #define MACHINE_HAS_SEQ_INSN (get_lowcore()->machine_flags & MACHINE_FLAG_SEQ_INSN) 99 99 100 100 /* 101 101 * Console mode. Override with conmode=
-2
arch/s390/kernel/early.c
··· 269 269 } 270 270 if (test_facility(194)) 271 271 get_lowcore()->machine_flags |= MACHINE_FLAG_RDP; 272 - if (test_facility(85)) 273 - get_lowcore()->machine_flags |= MACHINE_FLAG_SEQ_INSN; 274 272 } 275 273 276 274 static inline void save_vector_registers(void)
+6 -5
arch/s390/kernel/ftrace.c
··· 13 13 #include <linux/kernel.h> 14 14 #include <linux/types.h> 15 15 #include <linux/kmsan-checks.h> 16 + #include <linux/cpufeature.h> 16 17 #include <linux/kprobes.h> 17 18 #include <linux/execmem.h> 18 19 #include <trace/syscall.h> ··· 70 69 71 70 bool ftrace_need_init_nop(void) 72 71 { 73 - return !MACHINE_HAS_SEQ_INSN; 72 + return !cpu_has_seq_insn(); 74 73 } 75 74 76 75 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec) ··· 190 189 int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, 191 190 unsigned long addr) 192 191 { 193 - if (MACHINE_HAS_SEQ_INSN) 192 + if (cpu_has_seq_insn()) 194 193 return ftrace_patch_branch_insn(rec->ip, old_addr, addr); 195 194 else 196 195 return ftrace_modify_trampoline_call(rec, old_addr, addr); ··· 214 213 int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, 215 214 unsigned long addr) 216 215 { 217 - /* Expect brcl 0xf,... for the !MACHINE_HAS_SEQ_INSN case */ 218 - if (MACHINE_HAS_SEQ_INSN) 216 + /* Expect brcl 0xf,... for the !cpu_has_seq_insn() case */ 217 + if (cpu_has_seq_insn()) 219 218 return ftrace_patch_branch_insn(rec->ip, addr, 0); 220 219 else 221 220 return ftrace_patch_branch_mask((void *)rec->ip, 0xc0f4, false); ··· 235 234 236 235 int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) 237 236 { 238 - if (MACHINE_HAS_SEQ_INSN) 237 + if (cpu_has_seq_insn()) 239 238 return ftrace_patch_branch_insn(rec->ip, 0, addr); 240 239 else 241 240 return ftrace_make_trampoline_call(rec, addr);
+3 -2
arch/s390/kernel/kprobes.c
··· 13 13 #include <linux/ptrace.h> 14 14 #include <linux/preempt.h> 15 15 #include <linux/stop_machine.h> 16 + #include <linux/cpufeature.h> 16 17 #include <linux/kdebug.h> 17 18 #include <linux/uaccess.h> 18 19 #include <linux/extable.h> ··· 154 153 { 155 154 struct swap_insn_args args = {.p = p, .arm_kprobe = 1}; 156 155 157 - if (MACHINE_HAS_SEQ_INSN) { 156 + if (cpu_has_seq_insn()) { 158 157 swap_instruction(&args); 159 158 text_poke_sync(); 160 159 } else { ··· 167 166 { 168 167 struct swap_insn_args args = {.p = p, .arm_kprobe = 0}; 169 168 170 - if (MACHINE_HAS_SEQ_INSN) { 169 + if (cpu_has_seq_insn()) { 171 170 swap_instruction(&args); 172 171 text_poke_sync(); 173 172 } else {