]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/cpufeature: Convert MACHINE_HAS_EDAT1 to cpu_has_edat1()
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 7 Feb 2025 14:48:53 +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>
13 files changed:
arch/s390/boot/boot.h
arch/s390/boot/startup.c
arch/s390/boot/vmem.c
arch/s390/include/asm/cpufeature.h
arch/s390/include/asm/hugetlb.h
arch/s390/include/asm/pgtable.h
arch/s390/include/asm/setup.h
arch/s390/kernel/early.c
arch/s390/kernel/processor.c
arch/s390/mm/hugetlbpage.c
arch/s390/mm/pageattr.c
arch/s390/mm/vmem.c
drivers/s390/char/sclp_cmd.c

index 69f261566a64a8b78c447c0673aa83df3ad176d5..668d88fbeccbbed8a15a105e7dd1cef2d61a32b8 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/physmem_info.h>
 
 struct machine_info {
-       unsigned char has_edat1 : 1;
        unsigned char has_edat2 : 1;
 };
 
index 55b8fad06b640c5fc8f5fdc30ab033667b6862ef..124bf13dedf9f386fb511c0127dd3070d1a7a0e0 100644 (file)
@@ -50,10 +50,8 @@ void error(char *x)
 
 static void detect_facilities(void)
 {
-       if (test_facility(8)) {
-               machine.has_edat1 = 1;
+       if (cpu_has_edat1())
                local_ctl_set_bit(0, CR0_EDAT_BIT);
-       }
        if (test_facility(78))
                machine.has_edat2 = 1;
        page_noexec_mask = -1UL;
index cfca94a8eac4432ba348f3bca7b50b1d199236bf..4d27428c523335dc6a75f44ba6c3079a4ac32a4c 100644 (file)
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #define boot_fmt(fmt) "vmem: " fmt
+#include <linux/cpufeature.h>
 #include <linux/sched/task.h>
 #include <linux/pgtable.h>
 #include <linux/kasan.h>
@@ -330,7 +331,7 @@ static unsigned long try_get_large_pmd_pa(pmd_t *pm_dir, unsigned long addr, uns
 {
        unsigned long pa, size = end - addr;
 
-       if (!machine.has_edat1 || !large_page_mapping_allowed(mode) ||
+       if (!cpu_has_edat1() || !large_page_mapping_allowed(mode) ||
            !IS_ALIGNED(addr, PMD_SIZE) || (size < PMD_SIZE))
                return INVALID_PHYS_ADDR;
 
index 5c7c535a3b5bcae07c6b23f505de46dfcf2f3cca..f4f3ca95872f89b740854a4637c9deecbc7ad632 100644 (file)
@@ -22,6 +22,7 @@ enum {
 
 int cpu_have_feature(unsigned int nr);
 
+#define cpu_has_edat1()                test_facility(8)
 #define cpu_has_gs()           test_facility(133)
 #define cpu_has_nx()           test_facility(130)
 #define cpu_has_rdp()          test_facility(194)
index 7c52acaf9f8282f24905ce6f208877f2bf3b2927..e42655a8e4046456e59d0eb4edabce5c14956ad2 100644 (file)
@@ -9,12 +9,13 @@
 #ifndef _ASM_S390_HUGETLB_H
 #define _ASM_S390_HUGETLB_H
 
+#include <linux/cpufeature.h>
 #include <linux/pgtable.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
 #include <asm/page.h>
 
-#define hugepages_supported()                  (MACHINE_HAS_EDAT1)
+#define hugepages_supported()  cpu_has_edat1()
 
 #define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT
 void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
index 62452822676adef0a295168e8bf13eb68e84a6a2..fb757f5e220b0ec2fb7d15299573941ee8c43a10 100644 (file)
@@ -1891,7 +1891,7 @@ static inline int pmd_trans_huge(pmd_t pmd)
 #define has_transparent_hugepage has_transparent_hugepage
 static inline int has_transparent_hugepage(void)
 {
-       return MACHINE_HAS_EDAT1 ? 1 : 0;
+       return cpu_has_edat1() ? 1 : 0;
 }
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 
index 25f4d5b6e23bb7032c08efacdcc5e4f5d9d54fdf..bd46e5206941ca7e0442886636504e988e181dfe 100644 (file)
@@ -23,7 +23,6 @@
 #define MACHINE_FLAG_DIAG9C    BIT(3)
 #define MACHINE_FLAG_ESOP      BIT(4)
 #define MACHINE_FLAG_IDTE      BIT(5)
-#define MACHINE_FLAG_EDAT1     BIT(7)
 #define MACHINE_FLAG_EDAT2     BIT(8)
 #define MACHINE_FLAG_TE                BIT(11)
 #define MACHINE_FLAG_TLB_GUEST BIT(14)
@@ -79,7 +78,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_EDAT1      (get_lowcore()->machine_flags & MACHINE_FLAG_EDAT1)
 #define MACHINE_HAS_EDAT2      (get_lowcore()->machine_flags & MACHINE_FLAG_EDAT2)
 #define MACHINE_HAS_TE         (get_lowcore()->machine_flags & MACHINE_FLAG_TE)
 #define MACHINE_HAS_TLB_GUEST  (get_lowcore()->machine_flags & MACHINE_FLAG_TLB_GUEST)
index 68685aa23c16e9268e28ef27537f453cc0b10abd..dd9c32e3cf1c4b4a0d2c04fc47686a136224eb09 100644 (file)
@@ -237,10 +237,6 @@ static __init void detect_diag9c(void)
 
 static __init void detect_machine_facilities(void)
 {
-       if (test_facility(8)) {
-               get_lowcore()->machine_flags |= MACHINE_FLAG_EDAT1;
-               system_ctl_set_bit(0, CR0_EDAT_BIT);
-       }
        if (test_facility(78))
                get_lowcore()->machine_flags |= MACHINE_FLAG_EDAT2;
        if (test_facility(3))
index c8ce8474d769e79ef4579b05add1285be1f83c43..4c751b6539f865e33358f61e04945a1ec5e7fe6d 100644 (file)
@@ -210,7 +210,7 @@ static int __init setup_hwcaps(void)
                elf_hwcap |= HWCAP_DFP;
 
        /* huge page support */
-       if (MACHINE_HAS_EDAT1)
+       if (cpu_has_edat1())
                elf_hwcap |= HWCAP_HPAGE;
 
        /* 64-bit register support for 31-bit processes */
index d9ce199953de9e4241f0eb04f2e81271d3f26680..380a42a3484112e08ae18a0b9a2d437f058e033e 100644 (file)
@@ -9,12 +9,13 @@
 #define KMSG_COMPONENT "hugetlb"
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
-#include <asm/pgalloc.h>
+#include <linux/cpufeature.h>
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
 #include <linux/mman.h>
 #include <linux/sched/mm.h>
 #include <linux/security.h>
+#include <asm/pgalloc.h>
 
 /*
  * If the bit selected by single-bit bitmask "a" is set within "x", move
@@ -248,7 +249,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
 
 bool __init arch_hugetlb_valid_size(unsigned long size)
 {
-       if (MACHINE_HAS_EDAT1 && size == PMD_SIZE)
+       if (cpu_has_edat1() && size == PMD_SIZE)
                return true;
        else if (MACHINE_HAS_EDAT2 && size == PUD_SIZE)
                return true;
index 93c0ee36436e98c885ab8e9bff9d76cd087c3527..70c73fe96b392cf7a8934a523de729a754cffe98 100644 (file)
@@ -28,7 +28,7 @@ void __storage_key_init_range(unsigned long start, unsigned long end)
        unsigned long boundary, size;
 
        while (start < end) {
-               if (MACHINE_HAS_EDAT1) {
+               if (cpu_has_edat1()) {
                        /* set storage keys for a 1MB frame */
                        size = 1UL << 20;
                        boundary = (start + size) & ~(size - 1);
index 8ead999e340b6af63cb33196d113909028bde735..d4d77e89741bbf5592d18c9201f90249abf1b489 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/memory_hotplug.h>
+#include <linux/cpufeature.h>
 #include <linux/memblock.h>
 #include <linux/pfn.h>
 #include <linux/mm.h>
@@ -249,12 +250,12 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr,
                } else if (pmd_none(*pmd)) {
                        if (IS_ALIGNED(addr, PMD_SIZE) &&
                            IS_ALIGNED(next, PMD_SIZE) &&
-                           MACHINE_HAS_EDAT1 && direct &&
+                           cpu_has_edat1() && direct &&
                            !debug_pagealloc_enabled()) {
                                set_pmd(pmd, __pmd(__pa(addr) | prot));
                                pages++;
                                continue;
-                       } else if (!direct && MACHINE_HAS_EDAT1) {
+                       } else if (!direct && cpu_has_edat1()) {
                                void *new_page;
 
                                /*
index f905a6643a0ff4a182ecd98e756736a32413a0e3..9fcdce9bb35fc4dc657fcb2aa4a0585bf6b05a1d 100644 (file)
@@ -8,6 +8,7 @@
 #define KMSG_COMPONENT "sclp_cmd"
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
+#include <linux/cpufeature.h>
 #include <linux/completion.h>
 #include <linux/init.h>
 #include <linux/errno.h>
@@ -428,7 +429,7 @@ static void __init add_memory_merged(u16 rn)
                goto skip_add;
        for (addr = start; addr < start + size; addr += block_size)
                add_memory(0, addr, block_size,
-                          MACHINE_HAS_EDAT1 ?
+                          cpu_has_edat1() ?
                           MHP_MEMMAP_ON_MEMORY | MHP_OFFLINE_INACCESSIBLE : MHP_NONE);
 skip_add:
        first_rn = rn;