]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/tx: Convert MACHINE_HAS_TE to machine_has_tx()
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 7 Feb 2025 14:49:01 +0000 (15:49 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 4 Mar 2025 16:18:06 +0000 (17:18 +0100)
Use static branch(es) to implement and use machine_has_tx() instead of
a runtime check with MACHINE_HAS_TE.

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/boot/startup.c
arch/s390/include/asm/machine.h
arch/s390/include/asm/setup.h
arch/s390/kernel/early.c
arch/s390/kernel/processor.c
arch/s390/kernel/ptrace.c

index 4ef2622f3d300d258cee2f5d1db5c2ef4d7285ef..50ae83aaef165ae61618e8acb994c21cead5f904 100644 (file)
@@ -84,6 +84,10 @@ static void detect_facilities(void)
                clock_comparator_max = -1UL >> 1;
                local_ctl_set_bit(0, CR0_CLOCK_COMPARATOR_SIGN_BIT);
        }
+       if (test_facility(50) && test_facility(73)) {
+               set_machine_feature(MFEATURE_TX);
+               local_ctl_set_bit(0, CR0_TRANSACTIONAL_EXECUTION_BIT);
+       }
 }
 
 static int cmma_test_essa(void)
index 33cb4403fc82b56eb79825396934136442a79f18..c31682d6c35d393aaf7450558b79a173632a4169 100644 (file)
@@ -12,6 +12,7 @@
 #define MFEATURE_PCI_MIO       1
 #define MFEATURE_SCC           2
 #define MFEATURE_TLB_GUEST     3
+#define MFEATURE_TX            4
 
 #ifndef __ASSEMBLY__
 
@@ -82,6 +83,7 @@ static __always_inline bool machine_has_##name(void)                          \
 DEFINE_MACHINE_HAS_FEATURE(relocated_lowcore, MFEATURE_LOWCORE)
 DEFINE_MACHINE_HAS_FEATURE(scc, MFEATURE_SCC)
 DEFINE_MACHINE_HAS_FEATURE(tlb_guest, MFEATURE_TLB_GUEST)
+DEFINE_MACHINE_HAS_FEATURE(tx, MFEATURE_TX)
 
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_S390_MACHINE_H */
index bb9d701ec9a6fa0b2bd909f513bfa608f00332b6..7762fb342c396a47ce87791ad050105375c52a44 100644 (file)
@@ -22,7 +22,6 @@
 #define MACHINE_FLAG_LPAR      BIT(2)
 #define MACHINE_FLAG_DIAG9C    BIT(3)
 #define MACHINE_FLAG_ESOP      BIT(4)
-#define MACHINE_FLAG_TE                BIT(11)
 
 #define LPP_MAGIC              BIT(31)
 #define LPP_PID_MASK           _AC(0xffffffff, UL)
@@ -72,7 +71,6 @@ extern unsigned long mio_wb_bit_mask;
 
 #define MACHINE_HAS_DIAG9C     (get_lowcore()->machine_flags & MACHINE_FLAG_DIAG9C)
 #define MACHINE_HAS_ESOP       (get_lowcore()->machine_flags & MACHINE_FLAG_ESOP)
-#define MACHINE_HAS_TE         (get_lowcore()->machine_flags & MACHINE_FLAG_TE)
 
 /*
  * Console mode. Override with conmode=
index 708f158cc60ef626d62de668c938661ea51088ee..cc4e3d4dc55f948d81c8ac9da6de90726df7d8c4 100644 (file)
@@ -222,10 +222,6 @@ static __init void detect_diag9c(void)
 
 static __init void detect_machine_facilities(void)
 {
-       if (test_facility(50) && test_facility(73)) {
-               get_lowcore()->machine_flags |= MACHINE_FLAG_TE;
-               system_ctl_set_bit(0, CR0_TRANSACTIONAL_EXECUTION_BIT);
-       }
        if (test_facility(129))
                system_ctl_set_bit(0, CR0_VECTOR_BIT);
 }
index 487c943cbc4c48311ae93fc9b38512287301edcd..6594ded7b722bc213f06ce35375a50b0a550b012 100644 (file)
@@ -218,7 +218,7 @@ static int __init setup_hwcaps(void)
        elf_hwcap |= HWCAP_HIGH_GPRS;
 
        /* transactional execution */
-       if (MACHINE_HAS_TE)
+       if (machine_has_tx())
                elf_hwcap |= HWCAP_TE;
 
        /* vector */
index 9ed3017bb968d8db6508a773f46bfb1a77c728f1..e2acbbadc75e309df3e21071ac78495980fcd03d 100644 (file)
@@ -32,6 +32,7 @@
 #include <asm/unistd.h>
 #include <asm/runtime_instr.h>
 #include <asm/facility.h>
+#include <asm/machine.h>
 #include <asm/fpu.h>
 
 #include "entry.h"
@@ -61,7 +62,7 @@ void update_cr_regs(struct task_struct *task)
        cr0_new = cr0_old;
        cr2_new = cr2_old;
        /* Take care of the enable/disable of transactional execution. */
-       if (MACHINE_HAS_TE) {
+       if (machine_has_tx()) {
                /* Set or clear transaction execution TXC bit 8. */
                cr0_new.tcx = 1;
                if (task->thread.per_flags & PER_FLAG_NO_TE)
@@ -471,18 +472,18 @@ long arch_ptrace(struct task_struct *child, long request,
        case PTRACE_GET_LAST_BREAK:
                return put_user(child->thread.last_break, (unsigned long __user *)data);
        case PTRACE_ENABLE_TE:
-               if (!MACHINE_HAS_TE)
+               if (!machine_has_tx())
                        return -EIO;
                child->thread.per_flags &= ~PER_FLAG_NO_TE;
                return 0;
        case PTRACE_DISABLE_TE:
-               if (!MACHINE_HAS_TE)
+               if (!machine_has_tx())
                        return -EIO;
                child->thread.per_flags |= PER_FLAG_NO_TE;
                child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND;
                return 0;
        case PTRACE_TE_ABORT_RAND:
-               if (!MACHINE_HAS_TE || (child->thread.per_flags & PER_FLAG_NO_TE))
+               if (!machine_has_tx() || (child->thread.per_flags & PER_FLAG_NO_TE))
                        return -EIO;
                switch (data) {
                case 0UL: