]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/cpufeature: Convert MACHINE_HAS_TLB_LC to cpu_has_tlb_lc()
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 7 Feb 2025 14:48:51 +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/mm/pgtable.c

index 64ff316a69e3e46932331f75cc2d864822c7d2be..6ba487a7c84233d938bc40322fdf2eb3625d55d5 100644 (file)
@@ -26,5 +26,6 @@ int cpu_have_feature(unsigned int nr);
 #define cpu_has_nx()           test_facility(130)
 #define cpu_has_rdp()          test_facility(194)
 #define cpu_has_seq_insn()     test_facility(85)
+#define cpu_has_tlb_lc()       test_facility(51)
 
 #endif /* __ASM_S390_CPUFEATURE_H */
index 914d694960e42f7944fe1a47cb237b55ec57de3e..b117f3a4b4c23fb391f912a1473cd2865d54a68e 100644 (file)
@@ -27,7 +27,6 @@
 #define MACHINE_FLAG_EDAT2     BIT(8)
 #define MACHINE_FLAG_TOPOLOGY  BIT(10)
 #define MACHINE_FLAG_TE                BIT(11)
-#define MACHINE_FLAG_TLB_LC    BIT(12)
 #define MACHINE_FLAG_TLB_GUEST BIT(14)
 #define MACHINE_FLAG_SCC       BIT(17)
 #define MACHINE_FLAG_PCI_MIO   BIT(18)
@@ -85,7 +84,6 @@ extern unsigned long mio_wb_bit_mask;
 #define MACHINE_HAS_EDAT2      (get_lowcore()->machine_flags & MACHINE_FLAG_EDAT2)
 #define MACHINE_HAS_TOPOLOGY   (get_lowcore()->machine_flags & MACHINE_FLAG_TOPOLOGY)
 #define MACHINE_HAS_TE         (get_lowcore()->machine_flags & MACHINE_FLAG_TE)
-#define MACHINE_HAS_TLB_LC     (get_lowcore()->machine_flags & MACHINE_FLAG_TLB_LC)
 #define MACHINE_HAS_TLB_GUEST  (get_lowcore()->machine_flags & MACHINE_FLAG_TLB_GUEST)
 #define MACHINE_HAS_SCC                (get_lowcore()->machine_flags & MACHINE_FLAG_SCC)
 #define MACHINE_HAS_PCI_MIO    (get_lowcore()->machine_flags & MACHINE_FLAG_PCI_MIO)
index 32a0983a0378ee40daab89ccee26f1c10fe42f7a..1f22dd8094ecef8fec09dc4600e68ac6726e9b03 100644 (file)
@@ -249,8 +249,6 @@ static __init void detect_machine_facilities(void)
                get_lowcore()->machine_flags |= MACHINE_FLAG_TE;
                system_ctl_set_bit(0, CR0_TRANSACTIONAL_EXECUTION_BIT);
        }
-       if (test_facility(51))
-               get_lowcore()->machine_flags |= MACHINE_FLAG_TLB_LC;
        if (test_facility(129))
                system_ctl_set_bit(0, CR0_VECTOR_BIT);
        if (test_facility(139) && (tod_clock_base.tod >> 63)) {
index f05e62e037c28410f97d8b9d60cb8eb46244ecb1..03cbe8ce05ca523dd73df022c566f43347261e3e 100644 (file)
@@ -4,6 +4,7 @@
  *    Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
  */
 
+#include <linux/cpufeature.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -94,7 +95,7 @@ static inline pte_t ptep_flush_direct(struct mm_struct *mm,
        if (unlikely(pte_val(old) & _PAGE_INVALID))
                return old;
        atomic_inc(&mm->context.flush_count);
-       if (MACHINE_HAS_TLB_LC &&
+       if (cpu_has_tlb_lc() &&
            cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id())))
                ptep_ipte_local(mm, addr, ptep, nodat);
        else
@@ -411,7 +412,7 @@ static inline pmd_t pmdp_flush_direct(struct mm_struct *mm,
        if (pmd_val(old) & _SEGMENT_ENTRY_INVALID)
                return old;
        atomic_inc(&mm->context.flush_count);
-       if (MACHINE_HAS_TLB_LC &&
+       if (cpu_has_tlb_lc() &&
            cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id())))
                pmdp_idte_local(mm, addr, pmdp);
        else
@@ -537,7 +538,7 @@ static inline pud_t pudp_flush_direct(struct mm_struct *mm,
        if (pud_val(old) & _REGION_ENTRY_INVALID)
                return old;
        atomic_inc(&mm->context.flush_count);
-       if (MACHINE_HAS_TLB_LC &&
+       if (cpu_has_tlb_lc() &&
            cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id())))
                pudp_idte_local(mm, addr, pudp);
        else