]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/cpufeature: Convert MACHINE_HAS_RDP to cpu_has_rdp()
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 7 Feb 2025 14:48:48 +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/pgtable.h
arch/s390/include/asm/setup.h
arch/s390/kernel/early.c

index 496d0758b902fd4df004704462682c5042727da9..641a2780fd5a641aab39377c635dc6eb8414ce21 100644 (file)
@@ -22,6 +22,7 @@ enum {
 
 int cpu_have_feature(unsigned int nr);
 
+#define cpu_has_rdp()          test_facility(194)
 #define cpu_has_seq_insn()     test_facility(85)
 
 #endif /* __ASM_S390_CPUFEATURE_H */
index 3ca5af4cfe432e24d2484f7cb48b0393697a84bb..62452822676adef0a295168e8bf13eb68e84a6a2 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/sched.h>
 #include <linux/mm_types.h>
+#include <linux/cpufeature.h>
 #include <linux/page-flags.h>
 #include <linux/radix-tree.h>
 #include <linux/atomic.h>
@@ -1339,7 +1340,7 @@ static inline void flush_tlb_fix_spurious_fault(struct vm_area_struct *vma,
         * PTE does not have _PAGE_PROTECT set, to avoid unnecessary overhead.
         * A local RDP can be used to do the flush.
         */
-       if (MACHINE_HAS_RDP && !(pte_val(*ptep) & _PAGE_PROTECT))
+       if (cpu_has_rdp() && !(pte_val(*ptep) & _PAGE_PROTECT))
                __ptep_rdp(address, ptep, 0, 0, 1);
 }
 #define flush_tlb_fix_spurious_fault flush_tlb_fix_spurious_fault
@@ -1354,7 +1355,7 @@ static inline int ptep_set_access_flags(struct vm_area_struct *vma,
 {
        if (pte_same(*ptep, entry))
                return 0;
-       if (MACHINE_HAS_RDP && !mm_has_pgste(vma->vm_mm) && pte_allow_rdp(*ptep, entry))
+       if (cpu_has_rdp() && !mm_has_pgste(vma->vm_mm) && pte_allow_rdp(*ptep, entry))
                ptep_reset_dat_prot(vma->vm_mm, addr, ptep, entry);
        else
                ptep_xchg_direct(vma->vm_mm, addr, ptep, entry);
index 50b943f301553c5c116532d15d3585d3ca00aea1..07e7dab27dfac40d4c76701fcaa0372ed50efa3a 100644 (file)
@@ -33,7 +33,6 @@
 #define MACHINE_FLAG_GS                BIT(16)
 #define MACHINE_FLAG_SCC       BIT(17)
 #define MACHINE_FLAG_PCI_MIO   BIT(18)
-#define MACHINE_FLAG_RDP       BIT(19)
 
 #define LPP_MAGIC              BIT(31)
 #define LPP_PID_MASK           _AC(0xffffffff, UL)
@@ -94,7 +93,6 @@ extern unsigned long mio_wb_bit_mask;
 #define MACHINE_HAS_GS         (get_lowcore()->machine_flags & MACHINE_FLAG_GS)
 #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)
 
 /*
  * Console mode. Override with conmode=
index 6cee9a74374c27281d8d1da97b67a495b1ca36c8..f596a2eb428a4670474d47584ca9c8f213056a1b 100644 (file)
@@ -267,8 +267,6 @@ static __init void detect_machine_facilities(void)
                get_lowcore()->machine_flags |= MACHINE_FLAG_PCI_MIO;
                /* the control bit is set during PCI initialization */
        }
-       if (test_facility(194))
-               get_lowcore()->machine_flags |= MACHINE_FLAG_RDP;
 }
 
 static inline void save_vector_registers(void)