]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/bear: Convert cpu_has_bear() to cpu feature function
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 7 Feb 2025 14:49:09 +0000 (15:49 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 4 Mar 2025 16:18:07 +0000 (17:18 +0100)
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>
arch/s390/include/asm/cpufeature.h
arch/s390/kernel/irq.c
arch/s390/kernel/setup.c
arch/s390/kernel/syscall.c
arch/s390/kernel/traps.c
arch/s390/mm/dump_pagetables.c
arch/s390/mm/vmem.c

index 781f45e88821c88c134c8fba4eb9c5963cb27eb4..e08169bd63a55d1448507a79bcaf469d9ce9366d 100644 (file)
@@ -22,6 +22,7 @@ enum {
 
 int cpu_have_feature(unsigned int nr);
 
+#define cpu_has_bear()         test_facility(193)
 #define cpu_has_edat1()                test_facility(8)
 #define cpu_has_edat2()                test_facility(78)
 #define cpu_has_gs()           test_facility(133)
index d0a596f1c2f6f387d73b6dd2364b1cf64d2273fc..17c074b11c5178b0b4bb505773bb5830e9b3cea3 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/kernel_stat.h>
+#include <linux/cpufeature.h>
 #include <linux/interrupt.h>
 #include <linux/seq_file.h>
 #include <linux/proc_fs.h>
@@ -150,7 +151,7 @@ void noinstr do_io_irq(struct pt_regs *regs)
 
        if (user_mode(regs)) {
                update_timer_sys();
-               if (static_branch_likely(&cpu_has_bear))
+               if (cpu_has_bear())
                        current->thread.last_break = regs->last_break;
        }
 
@@ -186,7 +187,7 @@ void noinstr do_ext_irq(struct pt_regs *regs)
 
        if (user_mode(regs)) {
                update_timer_sys();
-               if (static_branch_likely(&cpu_has_bear))
+               if (cpu_has_bear())
                        current->thread.last_break = regs->last_break;
        }
 
index dc8ccc5e8edf4a5db2705d35dd495219ea730584..b6686d63b75414f783efbfdaa05fd6fbae7f16e1 100644 (file)
@@ -181,8 +181,6 @@ unsigned long __bootdata_preserved(MODULES_END);
 struct lowcore *lowcore_ptr[NR_CPUS];
 EXPORT_SYMBOL(lowcore_ptr);
 
-DEFINE_STATIC_KEY_FALSE(cpu_has_bear);
-
 /*
  * The Write Back bit position in the physaddr is given by the SLPC PCI.
  * Leaving the mask zero always uses write through which is safe
@@ -982,10 +980,6 @@ void __init setup_arch(char **cmdline_p)
        numa_setup();
        smp_detect_cpus();
        topology_init_early();
-
-       if (test_facility(193))
-               static_branch_enable(&cpu_has_bear);
-
        setup_protection_map();
        /*
         * Create kernel page tables.
index 5ec28028315b5f415e99915c26b035c5564e21cf..c8df656b08bcf14d68cb999d022ed2e9454e0aca 100644 (file)
@@ -12,6 +12,7 @@
  *  platform.
  */
 
+#include <linux/cpufeature.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
@@ -127,7 +128,7 @@ void noinstr __do_syscall(struct pt_regs *regs, int per_trap)
        regs->psw = get_lowcore()->svc_old_psw;
        regs->int_code = get_lowcore()->svc_int_code;
        update_timer_sys();
-       if (static_branch_likely(&cpu_has_bear))
+       if (cpu_has_bear())
                current->thread.last_break = regs->last_break;
 
        local_irq_enable();
index 24fee11b030d8bd5f6dbee7ae259998b97e3c3e4..a27053a405a7444633ac7655bd378eeee0c8e7d5 100644 (file)
@@ -15,6 +15,7 @@
  */
 #include "asm/irqflags.h"
 #include "asm/ptrace.h"
+#include <linux/cpufeature.h>
 #include <linux/kprobes.h>
 #include <linux/kdebug.h>
 #include <linux/randomize_kstack.h>
@@ -341,7 +342,7 @@ void noinstr __do_pgm_check(struct pt_regs *regs)
 
        if (user_mode(regs)) {
                update_timer_sys();
-               if (!static_branch_likely(&cpu_has_bear)) {
+               if (!cpu_has_bear()) {
                        if (regs->last_break < 4096)
                                regs->last_break = 1;
                }
index b60bc2b4287158128c4b28e73e924d15903c95ab..d3e943752fa0a46aae4167837b2da55875e26998 100644 (file)
@@ -84,7 +84,7 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr)
         * in which case we have two lpswe instructions in lowcore that need
         * to be executable.
         */
-       if (addr == PAGE_SIZE && (nospec_uses_trampoline() || !static_key_enabled(&cpu_has_bear)))
+       if (addr == PAGE_SIZE && (nospec_uses_trampoline() || !cpu_has_bear()))
                return;
        WARN_ONCE(IS_ENABLED(CONFIG_DEBUG_WX),
                  "s390/mm: Found insecure W+X mapping at address %pS\n",
@@ -178,7 +178,7 @@ bool ptdump_check_wx(void)
                return false;
        } else {
                pr_info("Checked W+X mappings: passed, no %sW+X pages found\n",
-                       (nospec_uses_trampoline() || !static_key_enabled(&cpu_has_bear)) ?
+                       (nospec_uses_trampoline() || !cpu_has_bear()) ?
                        "unexpected " : "");
 
                return true;
index 5d2d39f05d8cdd3dcd277b5256da2916fc70b496..448dd6ed1069b7336dd8ed0ab618900b3e46e420 100644 (file)
@@ -660,7 +660,7 @@ void __init vmem_map_init(void)
         * prefix page is used to return to the previous context with
         * an LPSWE instruction and therefore must be executable.
         */
-       if (!static_key_enabled(&cpu_has_bear))
+       if (!cpu_has_bear())
                set_memory_x(0, 1);
        if (debug_pagealloc_enabled())
                __set_memory_4k(__va(0), absolute_pointer(__va(0)) + ident_map_size);