]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/cpufeature: Convert MACHINE_HAS_SEQ_INSN to cpu_has_seq_insn()
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 7 Feb 2025 14:48:47 +0000 (15:48 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 4 Mar 2025 16:18:04 +0000 (17:18 +0100)
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>
arch/s390/include/asm/cpufeature.h
arch/s390/include/asm/setup.h
arch/s390/kernel/early.c
arch/s390/kernel/ftrace.c
arch/s390/kernel/kprobes.c

index 9312046137531646a0fc05997699bac954788ecb..496d0758b902fd4df004704462682c5042727da9 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef __ASM_S390_CPUFEATURE_H
 #define __ASM_S390_CPUFEATURE_H
 
+#include <asm/facility.h>
+
 enum {
        S390_CPU_FEATURE_MSA,
        S390_CPU_FEATURE_VXRS,
@@ -20,4 +22,6 @@ enum {
 
 int cpu_have_feature(unsigned int nr);
 
+#define cpu_has_seq_insn()     test_facility(85)
+
 #endif /* __ASM_S390_CPUFEATURE_H */
index 70b920b32827e8bbf913bd5cfc72dd7d6e2a285f..50b943f301553c5c116532d15d3585d3ca00aea1 100644 (file)
@@ -34,7 +34,6 @@
 #define MACHINE_FLAG_SCC       BIT(17)
 #define MACHINE_FLAG_PCI_MIO   BIT(18)
 #define MACHINE_FLAG_RDP       BIT(19)
-#define MACHINE_FLAG_SEQ_INSN  BIT(20)
 
 #define LPP_MAGIC              BIT(31)
 #define LPP_PID_MASK           _AC(0xffffffff, UL)
@@ -96,7 +95,6 @@ extern unsigned long mio_wb_bit_mask;
 #define MACHINE_HAS_SCC                (get_lowcore()->machine_flags & MACHINE_FLAG_SCC)
 #define MACHINE_HAS_PCI_MIO    (get_lowcore()->machine_flags & MACHINE_FLAG_PCI_MIO)
 #define MACHINE_HAS_RDP                (get_lowcore()->machine_flags & MACHINE_FLAG_RDP)
-#define MACHINE_HAS_SEQ_INSN   (get_lowcore()->machine_flags & MACHINE_FLAG_SEQ_INSN)
 
 /*
  * Console mode. Override with conmode=
index 2fa25164df7d1ebf92b4a89984a0974201d54fe7..6cee9a74374c27281d8d1da97b67a495b1ca36c8 100644 (file)
@@ -269,8 +269,6 @@ static __init void detect_machine_facilities(void)
        }
        if (test_facility(194))
                get_lowcore()->machine_flags |= MACHINE_FLAG_RDP;
-       if (test_facility(85))
-               get_lowcore()->machine_flags |= MACHINE_FLAG_SEQ_INSN;
 }
 
 static inline void save_vector_registers(void)
index 63ba6306632ef39a806c00e919d55ddc5ea81a5c..f2eb9686e033c6531119d16dc412a5ef773c32bf 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/kmsan-checks.h>
+#include <linux/cpufeature.h>
 #include <linux/kprobes.h>
 #include <linux/execmem.h>
 #include <trace/syscall.h>
@@ -69,7 +70,7 @@ static const char *ftrace_shared_hotpatch_trampoline(const char **end)
 
 bool ftrace_need_init_nop(void)
 {
-       return !MACHINE_HAS_SEQ_INSN;
+       return !cpu_has_seq_insn();
 }
 
 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
@@ -189,7 +190,7 @@ static int ftrace_modify_trampoline_call(struct dyn_ftrace *rec,
 int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
                       unsigned long addr)
 {
-       if (MACHINE_HAS_SEQ_INSN)
+       if (cpu_has_seq_insn())
                return ftrace_patch_branch_insn(rec->ip, old_addr, addr);
        else
                return ftrace_modify_trampoline_call(rec, old_addr, addr);
@@ -213,8 +214,8 @@ static int ftrace_patch_branch_mask(void *addr, u16 expected, bool enable)
 int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
                    unsigned long addr)
 {
-       /* Expect brcl 0xf,... for the !MACHINE_HAS_SEQ_INSN case */
-       if (MACHINE_HAS_SEQ_INSN)
+       /* Expect brcl 0xf,... for the !cpu_has_seq_insn() case */
+       if (cpu_has_seq_insn())
                return ftrace_patch_branch_insn(rec->ip, addr, 0);
        else
                return ftrace_patch_branch_mask((void *)rec->ip, 0xc0f4, false);
@@ -234,7 +235,7 @@ static int ftrace_make_trampoline_call(struct dyn_ftrace *rec, unsigned long add
 
 int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
 {
-       if (MACHINE_HAS_SEQ_INSN)
+       if (cpu_has_seq_insn())
                return ftrace_patch_branch_insn(rec->ip, 0, addr);
        else
                return ftrace_make_trampoline_call(rec, addr);
index 8b80ea57125f3c4cf305c8e479db6303045cc8a7..c450120b4474963c3a212456c65f402f244a4da5 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/ptrace.h>
 #include <linux/preempt.h>
 #include <linux/stop_machine.h>
+#include <linux/cpufeature.h>
 #include <linux/kdebug.h>
 #include <linux/uaccess.h>
 #include <linux/extable.h>
@@ -153,7 +154,7 @@ void arch_arm_kprobe(struct kprobe *p)
 {
        struct swap_insn_args args = {.p = p, .arm_kprobe = 1};
 
-       if (MACHINE_HAS_SEQ_INSN) {
+       if (cpu_has_seq_insn()) {
                swap_instruction(&args);
                text_poke_sync();
        } else {
@@ -166,7 +167,7 @@ void arch_disarm_kprobe(struct kprobe *p)
 {
        struct swap_insn_args args = {.p = p, .arm_kprobe = 0};
 
-       if (MACHINE_HAS_SEQ_INSN) {
+       if (cpu_has_seq_insn()) {
                swap_instruction(&args);
                text_poke_sync();
        } else {