]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/cpufeature: Convert MACHINE_HAS_EDAT2 to cpu_has_edat2()
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 7 Feb 2025 14:48:54 +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/boot/boot.h
arch/s390/boot/startup.c
arch/s390/boot/vmem.c
arch/s390/include/asm/cpufeature.h
arch/s390/include/asm/setup.h
arch/s390/kernel/early.c
arch/s390/kernel/setup.c
arch/s390/mm/hugetlbpage.c
arch/s390/mm/pageattr.c
arch/s390/mm/vmem.c

index 668d88fbeccbbed8a15a105e7dd1cef2d61a32b8..f4af23c142cc1d8e079e930916b970a0c8cd731d 100644 (file)
 #include <linux/printk.h>
 #include <asm/physmem_info.h>
 
-struct machine_info {
-       unsigned char has_edat2 : 1;
-};
-
 struct vmlinux_info {
        unsigned long entry;
        unsigned long image_size;       /* does not include .bss */
index 124bf13dedf9f386fb511c0127dd3070d1a7a0e0..72d48e1d67be812209b334f34b3d4ca5f1127c14 100644 (file)
@@ -39,8 +39,6 @@ int __bootdata_preserved(relocate_lowcore);
 u64 __bootdata_preserved(stfle_fac_list[16]);
 struct oldmem_data __bootdata_preserved(oldmem_data);
 
-struct machine_info machine;
-
 void error(char *x)
 {
        boot_emerg("%s\n", x);
@@ -52,8 +50,6 @@ static void detect_facilities(void)
 {
        if (cpu_has_edat1())
                local_ctl_set_bit(0, CR0_EDAT_BIT);
-       if (test_facility(78))
-               machine.has_edat2 = 1;
        page_noexec_mask = -1UL;
        segment_noexec_mask = -1UL;
        region_noexec_mask = -1UL;
index 4d27428c523335dc6a75f44ba6c3079a4ac32a4c..1e87cffac2f102632e4ed8d8b6b08fbadd5ddd1d 100644 (file)
@@ -315,7 +315,7 @@ static unsigned long try_get_large_pud_pa(pud_t *pu_dir, unsigned long addr, uns
 {
        unsigned long pa, size = end - addr;
 
-       if (!machine.has_edat2 || !large_page_mapping_allowed(mode) ||
+       if (!cpu_has_edat2() || !large_page_mapping_allowed(mode) ||
            !IS_ALIGNED(addr, PUD_SIZE) || (size < PUD_SIZE))
                return INVALID_PHYS_ADDR;
 
index f4f3ca95872f89b740854a4637c9deecbc7ad632..dca25fd29f77ddffe60d8ddcbcebdaaac7ee6c73 100644 (file)
@@ -23,6 +23,7 @@ enum {
 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_nx()           test_facility(130)
 #define cpu_has_rdp()          test_facility(194)
index bd46e5206941ca7e0442886636504e988e181dfe..5e5536f586d0e5c24aa6ff84fae0cc5e78e31712 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_EDAT2     BIT(8)
 #define MACHINE_FLAG_TE                BIT(11)
 #define MACHINE_FLAG_TLB_GUEST BIT(14)
 #define MACHINE_FLAG_SCC       BIT(17)
@@ -78,7 +77,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_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)
 #define MACHINE_HAS_SCC                (get_lowcore()->machine_flags & MACHINE_FLAG_SCC)
index dd9c32e3cf1c4b4a0d2c04fc47686a136224eb09..73f8824971ace3dd67eee2c7d75ead85406712b0 100644 (file)
@@ -237,8 +237,6 @@ static __init void detect_diag9c(void)
 
 static __init void detect_machine_facilities(void)
 {
-       if (test_facility(78))
-               get_lowcore()->machine_flags |= MACHINE_FLAG_EDAT2;
        if (test_facility(3))
                get_lowcore()->machine_flags |= MACHINE_FLAG_IDTE;
        if (test_facility(50) && test_facility(73)) {
index d78bcfe707b51717156b62b17439bd49541a0513..c9dd3446162547b1b52cd849830ca4deec898c19 100644 (file)
@@ -961,7 +961,7 @@ void __init setup_arch(char **cmdline_p)
        setup_uv();
        dma_contiguous_reserve(ident_map_size);
        vmcp_cma_reserve();
-       if (MACHINE_HAS_EDAT2)
+       if (cpu_has_edat2())
                hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT);
 
        reserve_crashkernel();
index 380a42a3484112e08ae18a0b9a2d437f058e033e..ddbe14bb808de6986191c512a48bb0746f23f6e7 100644 (file)
@@ -251,7 +251,7 @@ bool __init arch_hugetlb_valid_size(unsigned long size)
 {
        if (cpu_has_edat1() && size == PMD_SIZE)
                return true;
-       else if (MACHINE_HAS_EDAT2 && size == PUD_SIZE)
+       else if (cpu_has_edat2() && size == PUD_SIZE)
                return true;
        else
                return false;
index 70c73fe96b392cf7a8934a523de729a754cffe98..3a6041dda17a9fe31a71a6ad1ec3e49c353852a9 100644 (file)
@@ -64,7 +64,7 @@ static void pgt_set(unsigned long *old, unsigned long new, unsigned long addr,
        unsigned long *table, mask;
 
        mask = 0;
-       if (MACHINE_HAS_EDAT2) {
+       if (cpu_has_edat2()) {
                switch (dtt) {
                case CRDTE_DTT_REGION3:
                        mask = ~(PTRS_PER_PUD * sizeof(pud_t) - 1);
index d4d77e89741bbf5592d18c9201f90249abf1b489..5d2d39f05d8cdd3dcd277b5256da2916fc70b496 100644 (file)
@@ -336,7 +336,7 @@ static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long end,
                } else if (pud_none(*pud)) {
                        if (IS_ALIGNED(addr, PUD_SIZE) &&
                            IS_ALIGNED(next, PUD_SIZE) &&
-                           MACHINE_HAS_EDAT2 && direct &&
+                           cpu_has_edat2() && direct &&
                            !debug_pagealloc_enabled()) {
                                set_pud(pud, __pud(__pa(addr) | prot));
                                pages++;