diff options
author | Heiko Carstens <hca@linux.ibm.com> | 2025-02-07 15:48:54 +0100 |
---|---|---|
committer | Vasily Gorbik <gor@linux.ibm.com> | 2025-03-04 17:18:05 +0100 |
commit | 3f5eede6dfdd2cf9f4c0156ccee20bd0e5d927aa (patch) | |
tree | 276d04deb2cccb6970d24eda5ffd95525fa9ee72 | |
parent | 2e2ff71febfe30963deff1897b7d1d1ceb8628dd (diff) |
s390/cpufeature: Convert MACHINE_HAS_EDAT2 to cpu_has_edat2()
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>
-rw-r--r-- | arch/s390/boot/boot.h | 4 | ||||
-rw-r--r-- | arch/s390/boot/startup.c | 4 | ||||
-rw-r--r-- | arch/s390/boot/vmem.c | 2 | ||||
-rw-r--r-- | arch/s390/include/asm/cpufeature.h | 1 | ||||
-rw-r--r-- | arch/s390/include/asm/setup.h | 2 | ||||
-rw-r--r-- | arch/s390/kernel/early.c | 2 | ||||
-rw-r--r-- | arch/s390/kernel/setup.c | 2 | ||||
-rw-r--r-- | arch/s390/mm/hugetlbpage.c | 2 | ||||
-rw-r--r-- | arch/s390/mm/pageattr.c | 2 | ||||
-rw-r--r-- | arch/s390/mm/vmem.c | 2 |
10 files changed, 6 insertions, 17 deletions
diff --git a/arch/s390/boot/boot.h b/arch/s390/boot/boot.h index 668d88fbeccb..f4af23c142cc 100644 --- a/arch/s390/boot/boot.h +++ b/arch/s390/boot/boot.h @@ -11,10 +11,6 @@ #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 */ diff --git a/arch/s390/boot/startup.c b/arch/s390/boot/startup.c index 124bf13dedf9..72d48e1d67be 100644 --- a/arch/s390/boot/startup.c +++ b/arch/s390/boot/startup.c @@ -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; diff --git a/arch/s390/boot/vmem.c b/arch/s390/boot/vmem.c index 4d27428c5233..1e87cffac2f1 100644 --- a/arch/s390/boot/vmem.c +++ b/arch/s390/boot/vmem.c @@ -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; diff --git a/arch/s390/include/asm/cpufeature.h b/arch/s390/include/asm/cpufeature.h index f4f3ca95872f..dca25fd29f77 100644 --- a/arch/s390/include/asm/cpufeature.h +++ b/arch/s390/include/asm/cpufeature.h @@ -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) diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h index bd46e5206941..5e5536f586d0 100644 --- a/arch/s390/include/asm/setup.h +++ b/arch/s390/include/asm/setup.h @@ -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) diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c index dd9c32e3cf1c..73f8824971ac 100644 --- a/arch/s390/kernel/early.c +++ b/arch/s390/kernel/early.c @@ -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)) { diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index d78bcfe707b5..c9dd34461625 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -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(); diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c index 380a42a34841..ddbe14bb808d 100644 --- a/arch/s390/mm/hugetlbpage.c +++ b/arch/s390/mm/hugetlbpage.c @@ -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; diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c index 70c73fe96b39..3a6041dda17a 100644 --- a/arch/s390/mm/pageattr.c +++ b/arch/s390/mm/pageattr.c @@ -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); diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c index d4d77e89741b..5d2d39f05d8c 100644 --- a/arch/s390/mm/vmem.c +++ b/arch/s390/mm/vmem.c @@ -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++; |