]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/cpufeature: Convert MACHINE_HAS_IDTE to cpu_has_idte()
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 7 Feb 2025 14:48:55 +0000 (15:48 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 4 Mar 2025 16:18:05 +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/include/asm/tlbflush.h
arch/s390/kernel/early.c
arch/s390/mm/gmap.c
arch/s390/mm/pageattr.c
arch/s390/mm/pgtable.c

index dca25fd29f77ddffe60d8ddcbcebdaaac7ee6c73..026a43b86fd7279a881a67a8dd89d93bae0cfd10 100644 (file)
@@ -25,6 +25,7 @@ int cpu_have_feature(unsigned int nr);
 #define cpu_has_edat1()                test_facility(8)
 #define cpu_has_edat2()                test_facility(78)
 #define cpu_has_gs()           test_facility(133)
+#define cpu_has_idte()         test_facility(3)
 #define cpu_has_nx()           test_facility(130)
 #define cpu_has_rdp()          test_facility(194)
 #define cpu_has_seq_insn()     test_facility(85)
index 5e5536f586d0e5c24aa6ff84fae0cc5e78e31712..668dd3e9435adf404f62dce2d106053bcc172bf9 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_IDTE      BIT(5)
 #define MACHINE_FLAG_TE                BIT(11)
 #define MACHINE_FLAG_TLB_GUEST BIT(14)
 #define MACHINE_FLAG_SCC       BIT(17)
@@ -76,7 +75,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_IDTE       (get_lowcore()->machine_flags & MACHINE_FLAG_IDTE)
 #define MACHINE_HAS_TE         (get_lowcore()->machine_flags & MACHINE_FLAG_TE)
 #define MACHINE_HAS_TLB_GUEST  (get_lowcore()->machine_flags & MACHINE_FLAG_TLB_GUEST)
 #define MACHINE_HAS_SCC                (get_lowcore()->machine_flags & MACHINE_FLAG_SCC)
index 9dfd46dd03c64cf71985173e306892a2db9f53b3..4a062317ca714aeaec4400dbe8fc3880b2da4e93 100644 (file)
@@ -2,6 +2,7 @@
 #ifndef _S390_TLBFLUSH_H
 #define _S390_TLBFLUSH_H
 
+#include <linux/cpufeature.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <asm/processor.h>
@@ -52,7 +53,7 @@ static inline void __tlb_flush_mm(struct mm_struct *mm)
        cpumask_copy(mm_cpumask(mm), &mm->context.cpu_attach_mask);
        barrier();
        gmap_asce = READ_ONCE(mm->context.gmap_asce);
-       if (MACHINE_HAS_IDTE && gmap_asce != -1UL) {
+       if (cpu_has_idte() && gmap_asce != -1UL) {
                if (gmap_asce)
                        __tlb_flush_idte(gmap_asce);
                __tlb_flush_idte(mm->context.asce);
@@ -66,7 +67,7 @@ static inline void __tlb_flush_mm(struct mm_struct *mm)
 
 static inline void __tlb_flush_kernel(void)
 {
-       if (MACHINE_HAS_IDTE)
+       if (cpu_has_idte())
                __tlb_flush_idte(init_mm.context.asce);
        else
                __tlb_flush_global();
index 73f8824971ace3dd67eee2c7d75ead85406712b0..2af5886702282b58d2b243423dbb9534ae37e8f5 100644 (file)
@@ -237,8 +237,6 @@ static __init void detect_diag9c(void)
 
 static __init void detect_machine_facilities(void)
 {
-       if (test_facility(3))
-               get_lowcore()->machine_flags |= MACHINE_FLAG_IDTE;
        if (test_facility(50) && test_facility(73)) {
                get_lowcore()->machine_flags |= MACHINE_FLAG_TE;
                system_ctl_set_bit(0, CR0_TRANSACTIONAL_EXECUTION_BIT);
index 94d9277858009d7b96be717786485b1694c18534..7a2f5effd626323fe4a04025a4e0951254f1ca1c 100644 (file)
@@ -8,6 +8,7 @@
  *              Janosch Frank <frankja@linux.vnet.ibm.com>
  */
 
+#include <linux/cpufeature.h>
 #include <linux/kernel.h>
 #include <linux/pagewalk.h>
 #include <linux/swap.h>
@@ -135,7 +136,7 @@ EXPORT_SYMBOL_GPL(gmap_create);
 
 static void gmap_flush_tlb(struct gmap *gmap)
 {
-       if (MACHINE_HAS_IDTE)
+       if (cpu_has_idte())
                __tlb_flush_idte(gmap->asce);
        else
                __tlb_flush_global();
@@ -2028,7 +2029,7 @@ static void gmap_pmdp_xchg(struct gmap *gmap, pmd_t *pmdp, pmd_t new,
        if (MACHINE_HAS_TLB_GUEST)
                __pmdp_idte(gaddr, (pmd_t *)pmdp, IDTE_GUEST_ASCE, gmap->asce,
                            IDTE_GLOBAL);
-       else if (MACHINE_HAS_IDTE)
+       else if (cpu_has_idte())
                __pmdp_idte(gaddr, (pmd_t *)pmdp, 0, 0, IDTE_GLOBAL);
        else
                __pmdp_csp(pmdp);
@@ -2106,7 +2107,7 @@ void gmap_pmdp_idte_local(struct mm_struct *mm, unsigned long vmaddr)
                        if (MACHINE_HAS_TLB_GUEST)
                                __pmdp_idte(gaddr, pmdp, IDTE_GUEST_ASCE,
                                            gmap->asce, IDTE_LOCAL);
-                       else if (MACHINE_HAS_IDTE)
+                       else if (cpu_has_idte())
                                __pmdp_idte(gaddr, pmdp, 0, 0, IDTE_LOCAL);
                        *pmdp = __pmd(_SEGMENT_ENTRY_EMPTY);
                }
@@ -2139,7 +2140,7 @@ void gmap_pmdp_idte_global(struct mm_struct *mm, unsigned long vmaddr)
                        if (MACHINE_HAS_TLB_GUEST)
                                __pmdp_idte(gaddr, pmdp, IDTE_GUEST_ASCE,
                                            gmap->asce, IDTE_GLOBAL);
-                       else if (MACHINE_HAS_IDTE)
+                       else if (cpu_has_idte())
                                __pmdp_idte(gaddr, pmdp, 0, 0, IDTE_GLOBAL);
                        else
                                __pmdp_csp(pmdp);
index 3a6041dda17a9fe31a71a6ad1ec3e49c353852a9..348e759840e7c34d0a617afa74c8d2872f11278a 100644 (file)
@@ -78,7 +78,7 @@ static void pgt_set(unsigned long *old, unsigned long new, unsigned long addr,
                }
                table = (unsigned long *)((unsigned long)old & mask);
                crdte(*old, new, table, dtt, addr, get_lowcore()->kernel_asce.val);
-       } else if (MACHINE_HAS_IDTE) {
+       } else if (cpu_has_idte()) {
                cspg(old, *old, new);
        } else {
                csp((unsigned int *)old + 1, *old, new);
index 03cbe8ce05ca523dd73df022c566f43347261e3e..ee3c4fec5055aeaaec3cffae95d68215d6d3553f 100644 (file)
@@ -392,7 +392,7 @@ static inline void pmdp_idte_global(struct mm_struct *mm,
                            mm->context.asce, IDTE_GLOBAL);
                if (mm_has_pgste(mm) && mm->context.allow_gmap_hpage_1m)
                        gmap_pmdp_idte_global(mm, addr);
-       } else if (MACHINE_HAS_IDTE) {
+       } else if (cpu_has_idte()) {
                __pmdp_idte(addr, pmdp, 0, 0, IDTE_GLOBAL);
                if (mm_has_pgste(mm) && mm->context.allow_gmap_hpage_1m)
                        gmap_pmdp_idte_global(mm, addr);
@@ -519,7 +519,7 @@ static inline void pudp_idte_global(struct mm_struct *mm,
        if (MACHINE_HAS_TLB_GUEST)
                __pudp_idte(addr, pudp, IDTE_NODAT | IDTE_GUEST_ASCE,
                            mm->context.asce, IDTE_GLOBAL);
-       else if (MACHINE_HAS_IDTE)
+       else if (cpu_has_idte())
                __pudp_idte(addr, pudp, 0, 0, IDTE_GLOBAL);
        else
                /*