powerpc: Make hash MMU code build configurable
Subsystems (7)
Nicholas Piggin
reviewerv2 cover powerpc: Make hash MMU code build configurable
Now that there's a platform that can make good use of it, here's a series that can prevent the hash MMU code being built for 64s platforms that don't need it.
Since v1:
- Split out most of the Kconfig change from the conditional compilation changes.
- Split out several more changes into preparatory patches.
- Reduced some ifdefs.
- Caught a few missing hash bits: pgtable dump, lkdtm, memremap_compat_align.
Since RFC:
- Split out large code movement from other changes.
- Used mmu ftr test constant folding rather than adding new constant true/false for radix_enabled().
- Restore tlbie trace point that had to be commented out in the previous.
- Avoid minor (probably unreachable) behaviour change in machine check handler when hash was not compiled.
- Fix microwatt updates so !HASH is not enforced.
- Rebase, build fixes.
Thanks,
Nick
Nicholas Piggin (16):
powerpc: Remove unused FW_FEATURE_NATIVE references
powerpc: Rename PPC_NATIVE to PPC_HASH_MMU_NATIVE powerpc/pseries: Stop selecting PPC_HASH_MMU_NATIVE powerpc/64s: Move and rename do_bad_slb_fault as it is not hash
specific
powerpc/pseries: move pseries_lpar_register_process_table() out from
hash specific code
powerpc/pseries: lparcfg don't include slb_size line in radix mode powerpc/64s: move THP trace point creation out of hash specific file powerpc/64s: Make flush_and_reload_slb a no-op when radix is enabled powerpc/64s: move page size definitions from hash specific file powerpc/64s: Rename hash_hugetlbpage.c to hugetlbpage.c powerpc/64: pcpu setup avoid reading mmu_linear_psize on 64e or radix powerpc/64e: remove mmu_linear_psize
powerpc/64s: Move hash MMU code under a new Kconfig name powerpc/64s: Make hash MMU support configurable powerpc/configs/microwatt: add POWER9_CPU powerpc/microwatt: Don't select the hash MMU code
arch/powerpc/Kconfig | 3 +-
arch/powerpc/configs/microwatt_defconfig | 2 +-
arch/powerpc/include/asm/book3s/64/mmu.h | 19 ++-
.../include/asm/book3s/64/tlbflush-hash.h | 7 ++
arch/powerpc/include/asm/book3s/64/tlbflush.h | 4 -
arch/powerpc/include/asm/book3s/pgtable.h | 4 +
arch/powerpc/include/asm/firmware.h | 8 --
arch/powerpc/include/asm/interrupt.h | 2 +-
arch/powerpc/include/asm/mmu.h | 16 ++-
arch/powerpc/include/asm/mmu_context.h | 2 +
arch/powerpc/include/asm/paca.h | 8 ++
arch/powerpc/kernel/asm-offsets.c | 2 +
arch/powerpc/kernel/dt_cpu_ftrs.c | 14 ++-
arch/powerpc/kernel/entry_64.S | 4 +-
arch/powerpc/kernel/exceptions-64s.S | 20 +++-
arch/powerpc/kernel/mce.c | 2 +-
arch/powerpc/kernel/mce_power.c | 16 ++-
arch/powerpc/kernel/paca.c | 18 ++-
arch/powerpc/kernel/process.c | 13 +-
arch/powerpc/kernel/prom.c | 2 +
arch/powerpc/kernel/setup_64.c | 26 +++-
arch/powerpc/kexec/core_64.c | 4 +-
arch/powerpc/kexec/ranges.c | 4 +
arch/powerpc/kvm/Kconfig | 1 +
arch/powerpc/mm/book3s64/Makefile | 19 +--
arch/powerpc/mm/book3s64/hash_native.c | 104 ----------------
arch/powerpc/mm/book3s64/hash_pgtable.c | 1 -
arch/powerpc/mm/book3s64/hash_utils.c | 111 +++++++++++++++++-
.../{hash_hugetlbpage.c => hugetlbpage.c} | 2 +
arch/powerpc/mm/book3s64/mmu_context.c | 34 +++++-
arch/powerpc/mm/book3s64/pgtable.c | 8 ++
arch/powerpc/mm/book3s64/radix_pgtable.c | 4 +
arch/powerpc/mm/book3s64/slb.c | 16 ---
arch/powerpc/mm/book3s64/trace.c | 8 ++
arch/powerpc/mm/copro_fault.c | 2 +
arch/powerpc/mm/fault.c | 17 +++
arch/powerpc/mm/ioremap.c | 19 ++-
arch/powerpc/mm/nohash/tlb.c | 9 --
arch/powerpc/mm/pgtable.c | 10 +-
arch/powerpc/mm/ptdump/Makefile | 2 +-
arch/powerpc/platforms/52xx/Kconfig | 2 +-
arch/powerpc/platforms/Kconfig | 4 +-
arch/powerpc/platforms/Kconfig.cputype | 21 +++-
arch/powerpc/platforms/cell/Kconfig | 3 +-
arch/powerpc/platforms/chrp/Kconfig | 2 +-
arch/powerpc/platforms/embedded6xx/Kconfig | 2 +-
arch/powerpc/platforms/maple/Kconfig | 3 +-
arch/powerpc/platforms/microwatt/Kconfig | 1 -
arch/powerpc/platforms/pasemi/Kconfig | 3 +-
arch/powerpc/platforms/powermac/Kconfig | 3 +-
arch/powerpc/platforms/powernv/Kconfig | 2 +-
arch/powerpc/platforms/powernv/idle.c | 2 +
arch/powerpc/platforms/powernv/setup.c | 2 +
arch/powerpc/platforms/pseries/Kconfig | 1 -
arch/powerpc/platforms/pseries/lpar.c | 67 ++++++-----
arch/powerpc/platforms/pseries/lparcfg.c | 5 +-
arch/powerpc/platforms/pseries/mobility.c | 6 +
arch/powerpc/platforms/pseries/ras.c | 2 +
arch/powerpc/platforms/pseries/reconfig.c | 2 +
arch/powerpc/platforms/pseries/setup.c | 6 +-
arch/powerpc/xmon/xmon.c | 8 +-
drivers/misc/lkdtm/Makefile | 2 +-
drivers/misc/lkdtm/core.c | 2 +-
63 files changed, 448 insertions(+), 270 deletions(-)
rename arch/powerpc/mm/book3s64/{hash_hugetlbpage.c => hugetlbpage.c} (99%)
create mode 100644 arch/powerpc/mm/book3s64/trace.cSignature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 1/16 powerpc: Remove unused FW_FEATURE_NATIVE references
FW_FEATURE_NATIVE_ALWAYS and FW_FEATURE_NATIVE_POSSIBLE are always zero and never do anything. Remove them.
--- arch/powerpc/include/asm/firmware.h | 8 -------- 1 file changed, 8 deletions(-)
arch/powerpc/include/asm/firmware.h +0 -8
@@ -80,8 +80,6 @@ enum {FW_FEATURE_POWERNV_ALWAYS =0 ,FW_FEATURE_PS3_POSSIBLE =FW_FEATURE_LPAR |FW_FEATURE_PS3_LV1 ,FW_FEATURE_PS3_ALWAYS =FW_FEATURE_LPAR |FW_FEATURE_PS3_LV1 , -FW_FEATURE_NATIVE_POSSIBLE =0 , -FW_FEATURE_NATIVE_ALWAYS =0 ,FW_FEATURE_POSSIBLE = #ifdef CONFIG_PPC_PSERIES FW_FEATURE_PSERIES_POSSIBLE |
@@ -91,9 +89,6 @@ enum {#endif #ifdef CONFIG_PPC_PS3 FW_FEATURE_PS3_POSSIBLE | -#endif -#ifdef CONFIG_PPC_NATIVE -FW_FEATURE_NATIVE_ALWAYS | #endif0 , FW_FEATURE_ALWAYS =
@@ -105,9 +100,6 @@ enum {#endif #ifdef CONFIG_PPC_PS3 FW_FEATURE_PS3_ALWAYS & -#endif -#ifdef CONFIG_PPC_NATIVE -FW_FEATURE_NATIVE_ALWAYS & #endif FW_FEATURE_POSSIBLE,
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 2/16 powerpc: Rename PPC_NATIVE to PPC_HASH_MMU_NATIVE
In reply to Nicholas PigginPPC_NATIVE now only controls the native HPT code, so rename it to be more descriptive. Restrict it to Book3S only.
--- arch/powerpc/mm/book3s64/Makefile | 2 +- arch/powerpc/mm/book3s64/hash_utils.c | 2 +- arch/powerpc/platforms/52xx/Kconfig | 2 +- arch/powerpc/platforms/Kconfig | 4 ++-- arch/powerpc/platforms/cell/Kconfig | 2 +- arch/powerpc/platforms/chrp/Kconfig | 2 +- arch/powerpc/platforms/embedded6xx/Kconfig | 2 +- arch/powerpc/platforms/maple/Kconfig | 2 +- arch/powerpc/platforms/microwatt/Kconfig | 2 +- arch/powerpc/platforms/pasemi/Kconfig | 2 +- arch/powerpc/platforms/powermac/Kconfig | 2 +- arch/powerpc/platforms/powernv/Kconfig | 2 +- arch/powerpc/platforms/pseries/Kconfig | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-)
arch/powerpc/mm/book3s64/Makefile +1 -1
@@ -6,7 +6,7 @@ CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE) obj-y += hash_pgtable.o hash_utils.o slb.o \ mmu_context.o pgtable.o hash_tlb.o -obj-$(CONFIG_PPC_NATIVE) += hash_native.o +obj-$(CONFIG_PPC_HASH_MMU_NATIVE) += hash_native.o obj-$(CONFIG_PPC_RADIX_MMU) += radix_pgtable.o radix_tlb.o obj-$(CONFIG_PPC_4K_PAGES) += hash_4k.o obj-$(CONFIG_PPC_64K_PAGES) += hash_64k.o
arch/powerpc/mm/book3s64/hash_utils.c +1 -1
@@ -1091,7 +1091,7 @@ void __init hash__early_init_mmu(void)ps3_early_mm_init (); else if (firmware_has_feature(FW_FEATURE_LPAR)) hpte_init_pseries(); - else if (IS_ENABLED(CONFIG_PPC_NATIVE)) + else if (IS_ENABLED(CONFIG_PPC_HASH_MMU_NATIVE)) hpte_init_native();if (!mmu_hash_ops.hpte_insert)
arch/powerpc/platforms/52xx/Kconfig +1 -1
@@ -34,7 +34,7 @@ config PPC_EFIKA bool "bPlan Efika 5k2. MPC5200B based computer" depends on PPC_MPC52xx select PPC_RTAS - select PPC_NATIVE + select PPC_HASH_MMU_NATIVE config PPC_LITE5200 bool "Freescale Lite5200 Eval Board"
arch/powerpc/platforms/Kconfig +2 -2
@@ -40,9 +40,9 @@ config EPAPR_PARAVIRT In case of doubt, say Y -config PPC_NATIVE +config PPC_HASH_MMU_NATIVE bool - depends on PPC_BOOK3S_32 || PPC64 + depends on PPC_BOOK3S help Support for running natively on the hardware, i.e. without a hypervisor. This option is not user-selectable but should
arch/powerpc/platforms/cell/Kconfig +1 -1
@@ -8,7 +8,7 @@ config PPC_CELL_COMMON select PPC_DCR_MMIO select PPC_INDIRECT_PIO select PPC_INDIRECT_MMIO - select PPC_NATIVE + select PPC_HASH_MMU_NATIVE select PPC_RTAS select IRQ_EDGE_EOI_HANDLER
arch/powerpc/platforms/chrp/Kconfig +1 -1
@@ -11,6 +11,6 @@ config PPC_CHRP select RTAS_ERROR_LOGGING select PPC_MPC106 select PPC_UDBG_16550 - select PPC_NATIVE + select PPC_HASH_MMU_NATIVE select FORCE_PCI default y
arch/powerpc/platforms/embedded6xx/Kconfig +1 -1
@@ -55,7 +55,7 @@ config MVME5100 select FORCE_PCI select PPC_INDIRECT_PCI select PPC_I8259 - select PPC_NATIVE + select PPC_HASH_MMU_NATIVE select PPC_UDBG_16550 help This option enables support for the Motorola (now Emerson) MVME5100
arch/powerpc/platforms/maple/Kconfig +1 -1
@@ -9,7 +9,7 @@ config PPC_MAPLE select GENERIC_TBSYNC select PPC_UDBG_16550 select PPC_970_NAP - select PPC_NATIVE + select PPC_HASH_MMU_NATIVE select PPC_RTAS select MMIO_NVRAM select ATA_NONSTANDARD if ATA
arch/powerpc/platforms/microwatt/Kconfig +1 -1
@@ -5,7 +5,7 @@ config PPC_MICROWATT select PPC_XICS select PPC_ICS_NATIVE select PPC_ICP_NATIVE - select PPC_NATIVE + select PPC_HASH_MMU_NATIVE select PPC_UDBG_16550 select ARCH_RANDOM help
arch/powerpc/platforms/pasemi/Kconfig +1 -1
@@ -5,7 +5,7 @@ config PPC_PASEMI select MPIC select FORCE_PCI select PPC_UDBG_16550 - select PPC_NATIVE + select PPC_HASH_MMU_NATIVE select MPIC_BROKEN_REGREAD help This option enables support for PA Semi's PWRficient line
arch/powerpc/platforms/powermac/Kconfig +1 -1
@@ -6,7 +6,7 @@ config PPC_PMAC select FORCE_PCI select PPC_INDIRECT_PCI if PPC32 select PPC_MPC106 if PPC32 - select PPC_NATIVE + select PPC_HASH_MMU_NATIVE select ZONE_DMA if PPC32 default y
arch/powerpc/platforms/powernv/Kconfig +1 -1
@@ -2,7 +2,7 @@ config PPC_POWERNV depends on PPC64 && PPC_BOOK3S bool "IBM PowerNV (Non-Virtualized) platform support" - select PPC_NATIVE + select PPC_HASH_MMU_NATIVE select PPC_XICS select PPC_ICP_NATIVE select PPC_XIVE_NATIVE
arch/powerpc/platforms/pseries/Kconfig +1 -1
@@ -17,7 +17,7 @@ config PPC_PSERIES select PPC_RTAS_DAEMON select RTAS_ERROR_LOGGING select PPC_UDBG_16550 - select PPC_NATIVE + select PPC_HASH_MMU_NATIVE select PPC_DOORBELL select HOTPLUG_CPU select ARCH_RANDOM
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 3/16 powerpc/pseries: Stop selecting PPC_HASH_MMU_NATIVE
In reply to Nicholas PigginThe pseries platform does not use the native hash code but the PAPR virtualised hash interfaces, so remove PPC_HASH_MMU_NATIVE.
This requires moving tlbiel code from hash_native.c to hash_utils.c.
--- arch/powerpc/include/asm/book3s/64/tlbflush.h | 4 - arch/powerpc/mm/book3s64/hash_native.c | 104 ------------------ arch/powerpc/mm/book3s64/hash_utils.c | 104 ++++++++++++++++++ arch/powerpc/platforms/pseries/Kconfig | 1 - 4 files changed, 104 insertions(+), 109 deletions(-)
arch/powerpc/include/asm/book3s/64/tlbflush.h +0 -4
@@ -14,7 +14,6 @@ enum { TLB_INVAL_SCOPE_LPID = 1, /* invalidate TLBs for current LPID */ }; -#ifdef CONFIG_PPC_NATIVE static inline void tlbiel_all (void ) {/*
@@ -30,9 +29,6 @@ static inline void tlbiel_all(void)else hash__tlbiel_all (TLB_INVAL_SCOPE_GLOBAL ); } -#else -static inline void tlbiel_all (void ) {BUG (); } -#endif static inline void tlbiel_all_lpid (bool radix) {
arch/powerpc/mm/book3s64/hash_native.c +0 -104
110 lines not on this page · raw message
arch/powerpc/mm/book3s64/hash_utils.c +104 -0
110 lines not on this page · raw message
arch/powerpc/platforms/pseries/Kconfig +0 -1
@@ -17,7 +17,6 @@ config PPC_PSERIES select PPC_RTAS_DAEMON select RTAS_ERROR_LOGGING select PPC_UDBG_16550 - select PPC_HASH_MMU_NATIVE select PPC_DOORBELL select HOTPLUG_CPU select ARCH_RANDOM
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 4/16 powerpc/64s: Move and rename do_bad_slb_fault as it is not hash specific
In reply to Nicholas Pigginslb.c is hash-specific SLB management, but do_bad_slb_fault deals with segment interrupts that occur with radix MMU as well.
--- arch/powerpc/include/asm/interrupt.h | 2 +- arch/powerpc/kernel/exceptions-64s.S | 4 ++-- arch/powerpc/mm/book3s64/slb.c | 16 ---------------- arch/powerpc/mm/fault.c | 17 +++++++++++++++++ 4 files changed, 20 insertions(+), 19 deletions(-)
arch/powerpc/include/asm/interrupt.h +1 -1
@@ -564,7 +564,7 @@ DECLARE_INTERRUPT_HANDLER(kernel_bad_stack);/* slb.c */ DECLARE_INTERRUPT_HANDLER_RAW (do_slb_fault); -DECLARE_INTERRUPT_HANDLER (do_bad_slb_fault); +DECLARE_INTERRUPT_HANDLER (do_bad_segment_interrupt);/* hash_utils.c */ DECLARE_INTERRUPT_HANDLER_RAW (do_hash_fault);
arch/powerpc/kernel/exceptions-64s.S +2 -2
@@ -1430,7 +1430,7 @@ MMU_FTR_SECTION_ELSE ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) std r3,RESULT(r1) addi r3,r1,STACK_FRAME_OVERHEAD - bl do_bad_slb_fault + bl do_bad_segment_interrupt b interrupt_return_srr
@@ -1510,7 +1510,7 @@ MMU_FTR_SECTION_ELSE ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) std r3,RESULT(r1) addi r3,r1,STACK_FRAME_OVERHEAD - bl do_bad_slb_fault + bl do_bad_segment_interrupt b interrupt_return_srr
arch/powerpc/mm/book3s64/slb.c +0 -16
@@ -868,19 +868,3 @@ DEFINE_INTERRUPT_HANDLER_RAW(do_slb_fault)return err; } } - -DEFINE_INTERRUPT_HANDLER (do_bad_slb_fault) -{ -int err = regs->result; - -if (err == -EFAULT ) { -if (user_mode (regs)) -_exception (SIGSEGV , regs,SEGV_BNDERR , regs->dar); -else -bad_page_fault (regs,SIGSEGV ); - }else if (err == -EINVAL ) { -unrecoverable_exception (regs); - }else { -BUG (); - } -}
arch/powerpc/mm/fault.c +17 -0
@@ -35,6 +35,7 @@#include <linux/kfence.h> #include <linux/pkeys.h> +#include <asm/asm-prototypes.h> #include <asm/firmware.h> #include <asm/interrupt.h> #include <asm/page.h>
@@ -620,4 +621,20 @@ DEFINE_INTERRUPT_HANDLER(do_bad_page_fault_segv) {bad_page_fault (regs,SIGSEGV ); } + +DEFINE_INTERRUPT_HANDLER (do_bad_segment_interrupt) +{ +int err = regs->result; + +if (err == -EFAULT ) { +if (user_mode (regs)) +_exception (SIGSEGV , regs,SEGV_BNDERR , regs->dar); +else +bad_page_fault (regs,SIGSEGV ); + }else if (err == -EINVAL ) { +unrecoverable_exception (regs); + }else { +BUG (); + } +}#endif
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 5/16 powerpc/pseries: move pseries_lpar_register_process_table() out from hash specific code
In reply to Nicholas PigginThis reduces ifdefs in a later change making hash support configurable.
--- arch/powerpc/platforms/pseries/lpar.c | 56 +++++++++++++-------------- 1 file changed, 28 insertions(+), 28 deletions(-)
arch/powerpc/platforms/pseries/lpar.c +28 -28
@@ -712,6 +712,34 @@ void vpa_init(int cpu)#ifdef CONFIG_PPC_BOOK3S_64 +static int pseries_lpar_register_process_table (unsigned long base, +unsigned long page_size,unsigned long table_size) +{ +long rc; +unsigned long flags =0 ; + +if (table_size) + flags |=PROC_TABLE_NEW ; +if (radix_enabled ()) { + flags |=PROC_TABLE_RADIX ; +if (mmu_has_feature (MMU_FTR_GTSE )) + flags |=PROC_TABLE_GTSE ; + }else + flags |=PROC_TABLE_HPT_SLB ; +for (;;) { + rc =plpar_hcall_norets (H_REGISTER_PROC_TBL , flags, base, + page_size, table_size); +if (!H_IS_LONG_BUSY (rc)) +break ; +mdelay (get_longbusy_msecs (rc)); + } +if (rc !=H_SUCCESS ) { +pr_err ("Failed to register process table (rc=%ld)\n" , rc); +BUG (); + } +return rc; +} + static long pSeries_lpar_hpte_insert(unsigned long hpte_group, unsigned long vpn, unsigned long pa, unsigned long rflags, unsigned long vflags,
@@ -1680,34 +1708,6 @@ static int pseries_lpar_resize_hpt(unsigned long shift)return 0 ; } -static int pseries_lpar_register_process_table (unsigned long base, -unsigned long page_size,unsigned long table_size) -{ -long rc; -unsigned long flags =0 ; - -if (table_size) - flags |=PROC_TABLE_NEW ; -if (radix_enabled ()) { - flags |=PROC_TABLE_RADIX ; -if (mmu_has_feature (MMU_FTR_GTSE )) - flags |=PROC_TABLE_GTSE ; - }else - flags |=PROC_TABLE_HPT_SLB ; -for (;;) { - rc =plpar_hcall_norets (H_REGISTER_PROC_TBL , flags, base, - page_size, table_size); -if (!H_IS_LONG_BUSY (rc)) -break ; -mdelay (get_longbusy_msecs (rc)); - } -if (rc !=H_SUCCESS ) { -pr_err ("Failed to register process table (rc=%ld)\n" , rc); -BUG (); - } -return rc; -} -void __init hpte_init_pseries (void ) { mmu_hash_ops.hpte_invalidate = pSeries_lpar_hpte_invalidate;
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 6/16 powerpc/pseries: lparcfg don't include slb_size line in radix mode
In reply to Nicholas PigginThis avoids a change in behaviour in the later patch making hash support configurable. This is possibly a user interface change, so the alternative would be a hard-coded slb_size=0 here.
--- arch/powerpc/platforms/pseries/lparcfg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/platforms/pseries/lparcfg.c +2 -1
@@ -532,7 +532,8 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v) lppaca_shared_proc(get_lppaca()));#ifdef CONFIG_PPC_BOOK3S_64 -seq_printf (m,"slb_size=%d\n" , mmu_slb_size); +if (!radix_enabled ()) +seq_printf (m,"slb_size=%d\n" , mmu_slb_size);#endif parse_em_data (m);maxmem_data (m);
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 7/16 powerpc/64s: move THP trace point creation out of hash specific file
In reply to Nicholas PigginIn preparation for making hash MMU support configurable, move THP trace point function definitions out of an otherwise hash specific file.
--- arch/powerpc/mm/book3s64/Makefile | 2 +- arch/powerpc/mm/book3s64/hash_pgtable.c | 1 - arch/powerpc/mm/book3s64/pgtable.c | 1 + arch/powerpc/mm/book3s64/trace.c | 8 ++++++++ 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/mm/book3s64/trace.c
arch/powerpc/mm/book3s64/Makefile +1 -1
@@ -5,7 +5,7 @@ ccflags-y := $(NO_MINIMAL_TOC) CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE) obj-y += hash_pgtable.o hash_utils.o slb.o \ - mmu_context.o pgtable.o hash_tlb.o + mmu_context.o pgtable.o hash_tlb.o trace.o obj-$(CONFIG_PPC_HASH_MMU_NATIVE) += hash_native.o obj-$(CONFIG_PPC_RADIX_MMU) += radix_pgtable.o radix_tlb.o obj-$(CONFIG_PPC_4K_PAGES) += hash_4k.o
arch/powerpc/mm/book3s64/hash_pgtable.c +0 -1
@@ -16,7 +16,6 @@#include <mm/mmu_decl.h> -#define CREATE_TRACE_POINTS #include <trace/events/thp.h> #if H_PGTABLE_RANGE > (USER_VSID_RANGE * (TASK_SIZE_USER64 /TASK_CONTEXT_SIZE ))
arch/powerpc/mm/book3s64/pgtable.c +1 -0
@@ -28,6 +28,7 @@ unsigned long __pmd_frag_size_shift;EXPORT_SYMBOL (__pmd_frag_size_shift);#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/* * This is called when relaxing access to a hugepage. It's also called in the page * fault path when we don't hit any of the major fault cases, ie, a minor
arch/powerpc/mm/book3s64/trace.c new file +8 -0
@@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* This file is for defining trace points and trace related helpers. +*/ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#define CREATE_TRACE_POINTS +#include <trace/events/thp.h> +#endif
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 8/16 powerpc/64s: Make flush_and_reload_slb a no-op when radix is enabled
In reply to Nicholas PigginThe radix test can exclude slb_flush_all_realmode() from being called because flush_and_reload_slb() is only expected to flush ERAT when called by flush_erat(), which is only on pre-ISA v3.0 CPUs that do not support radix.
This helps the later change to make hash support configurable to not introduce runtime changes to radix mode behaviour.
--- arch/powerpc/kernel/mce_power.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/kernel/mce_power.c +3 -3
@@ -80,12 +80,12 @@ static bool mce_in_guest(void)#ifdef CONFIG_PPC_BOOK3S_64 void flush_and_reload_slb (void ) { -/* Invalidate all SLBs */ -slb_flush_all_realmode (); -if (early_radix_enabled ())return ; +/* Invalidate all SLBs */ +slb_flush_all_realmode (); +/* * This probably shouldn't happen, but it may be possible it's * called in early boot before SLB shadows are allocated.
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 9/16 powerpc/64s: move page size definitions from hash specific file
In reply to Nicholas PigginThe radix code uses some of the psize variables. Move the common ones from hash_utils.c to pgtable.c.
--- arch/powerpc/mm/book3s64/hash_utils.c | 5 ----- arch/powerpc/mm/book3s64/pgtable.c | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/mm/book3s64/hash_utils.c +0 -5
@@ -99,8 +99,6 @@*/ static unsigned long _SDR1; -struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT ]; -EXPORT_SYMBOL_GPL (mmu_psize_defs);u8 hpte_page_sizes[1 <<LP_BITS ];EXPORT_SYMBOL_GPL (hpte_page_sizes);
@@ -114,9 +112,6 @@ EXPORT_SYMBOL_GPL(mmu_linear_psize);int mmu_virtual_psize =MMU_PAGE_4K ;int mmu_vmalloc_psize =MMU_PAGE_4K ;EXPORT_SYMBOL_GPL (mmu_vmalloc_psize); -#ifdef CONFIG_SPARSEMEM_VMEMMAP -int mmu_vmemmap_psize =MMU_PAGE_4K ; -#endif int mmu_io_psize =MMU_PAGE_4K ;int mmu_kernel_ssize =MMU_SEGSIZE_256M ;EXPORT_SYMBOL_GPL (mmu_kernel_ssize);
arch/powerpc/mm/book3s64/pgtable.c +7 -0
@@ -22,6 +22,13 @@#include "internal.h" +struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT ]; +EXPORT_SYMBOL_GPL (mmu_psize_defs); + +#ifdef CONFIG_SPARSEMEM_VMEMMAP +int mmu_vmemmap_psize =MMU_PAGE_4K ; +#endif +unsigned long __pmd_frag_nr;EXPORT_SYMBOL (__pmd_frag_nr);unsigned long __pmd_frag_size_shift;
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 10/16 powerpc/64s: Rename hash_hugetlbpage.c to hugetlbpage.c
In reply to Nicholas PigginThis file contains functions and data common to radix, so rename it to remove the hash_ prefix.
---
arch/powerpc/mm/book3s64/Makefile | 2 +-
arch/powerpc/mm/book3s64/{hash_hugetlbpage.c => hugetlbpage.c} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename arch/powerpc/mm/book3s64/{hash_hugetlbpage.c => hugetlbpage.c} (100%)arch/powerpc/mm/book3s64/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-$(CONFIG_PPC_HASH_MMU_NATIVE) += hash_native.o obj-$(CONFIG_PPC_RADIX_MMU) += radix_pgtable.o radix_tlb.o obj-$(CONFIG_PPC_4K_PAGES) += hash_4k.o obj-$(CONFIG_PPC_64K_PAGES) += hash_64k.o -obj-$(CONFIG_HUGETLB_PAGE) += hash_hugetlbpage.o +obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o ifdef CONFIG_HUGETLB_PAGE obj-$(CONFIG_PPC_RADIX_MMU) += radix_hugetlbpage.o endif
arch/powerpc/mm/book3s64/hugetlbpage.c renamed from arch/powerpc/mm/book3s64/hash_hugetlbpage.c +0 -0
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 11/16 powerpc/64: pcpu setup avoid reading mmu_linear_psize on 64e or radix
In reply to Nicholas PigginRadix never sets mmu_linear_psize so it's always 4K, which causes pcpu atom_size to always be PAGE_SIZE. 64e sets it to 1GB always.
Make paths for these platforms to be explicit about what value they set atom_size to.
--- arch/powerpc/kernel/setup_64.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
arch/powerpc/kernel/setup_64.c +15 -6
@@ -880,14 +880,23 @@ void __init setup_per_cpu_areas(void)int rc = -EINVAL ;/* -* Linear mapping is one of 4K, 1M and 16M. For 4K, no need -* to group units. For larger mappings, use 1M atom which -* should be large enough to contain a number of units. +* BookE and BookS radix are historical values and should be revisited. */ -if (mmu_linear_psize ==MMU_PAGE_4K ) - atom_size =PAGE_SIZE ; -else +if (IS_ENABLED (CONFIG_PPC_BOOK3E )) { atom_size =1 <<20 ; + }else if (radix_enabled ()) { + atom_size =PAGE_SIZE ; + }else { +/* +* Linear mapping is one of 4K, 1M and 16M. For 4K, no need +* to group units. For larger mappings, use 1M atom which +* should be large enough to contain a number of units. +*/ +if (mmu_linear_psize ==MMU_PAGE_4K ) + atom_size =PAGE_SIZE ; +else + atom_size =1 <<20 ; + }if (pcpu_chosen_fc !=PCPU_FC_PAGE ) { rc = pcpu_embed_first_chunk(0, dyn_size, atom_size, pcpu_cpu_distance,
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 12/16 powerpc/64e: remove mmu_linear_psize
In reply to Nicholas Pigginmmu_linear_psize is only set at boot once on 64e, is not necessarily the correct size of the linear map pages, and is never used anywhere except memremap_compat_align.
Remove mmu_linear_psize and hard code the 1GB value instead in memremap_compat_align.
--- arch/powerpc/mm/ioremap.c | 6 +++++- arch/powerpc/mm/nohash/tlb.c | 9 --------- 2 files changed, 5 insertions(+), 10 deletions(-)
arch/powerpc/mm/ioremap.c +5 -1
@@ -109,12 +109,16 @@ void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size,*/ unsigned long memremap_compat_align (void ) { +#ifdef CONFIG_PPC_BOOK3E_64 +// 1GB maximum possible size of the linear mapping. +return max (SUBSECTION_SIZE ,1UL <<30 ); +#else unsigned int shift = mmu_psize_defs[mmu_linear_psize].shift;if (radix_enabled ())return SUBSECTION_SIZE ;return max (SUBSECTION_SIZE ,1UL << shift); - +#endif }EXPORT_SYMBOL_GPL (memremap_compat_align);#endif
arch/powerpc/mm/nohash/tlb.c +0 -9
@@ -150,7 +150,6 @@ static inline int mmu_get_tsize(int psize)*/ #ifdef CONFIG_PPC64 -int mmu_linear_psize;/* Page size used for the linear mapping */ int mmu_pte_psize;/* Page size used for PTE pages */ int mmu_vmemmap_psize;/* Page size used for the virtual mem map */ int book3e_htw_mode;/* HW tablewalk? Value is PPC_HTW_* */
@@ -655,14 +654,6 @@ static void early_init_this_mmu(void)static void __init early_init_mmu_global (void ) { -/* XXX This will have to be decided at runtime, but right -* now our boot and TLB miss code hard wires it. Ideally -* we should find out a suitable page size and patch the -* TLB miss code (either that or use the PACA to store -* the value we want) -*/ - mmu_linear_psize =MMU_PAGE_1G ; -/* XXX This should be decided at runtime based on supported * page sizes in the TLB, but for now let's assume 16M is * always there and a good fit (which it probably is)
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 13/16 powerpc/64s: Move hash MMU code under a new Kconfig name
In reply to Nicholas PigginIntroduce a new option CONFIG_PPC_64S_HASH_MMU, and make 64s hash code depend on it.
--- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/book3s/64/mmu.h | 19 +++++++++-- .../include/asm/book3s/64/tlbflush-hash.h | 7 ++++ arch/powerpc/include/asm/book3s/pgtable.h | 4 +++ arch/powerpc/include/asm/mmu.h | 16 +++++++-- arch/powerpc/include/asm/mmu_context.h | 2 ++ arch/powerpc/include/asm/paca.h | 8 +++++ arch/powerpc/kernel/asm-offsets.c | 2 ++ arch/powerpc/kernel/dt_cpu_ftrs.c | 14 +++++--- arch/powerpc/kernel/entry_64.S | 4 +-- arch/powerpc/kernel/exceptions-64s.S | 16 +++++++++ arch/powerpc/kernel/mce.c | 2 +- arch/powerpc/kernel/mce_power.c | 10 ++++-- arch/powerpc/kernel/paca.c | 18 ++++------ arch/powerpc/kernel/process.c | 13 +++---- arch/powerpc/kernel/prom.c | 2 ++ arch/powerpc/kernel/setup_64.c | 5 +++ arch/powerpc/kexec/core_64.c | 4 +-- arch/powerpc/kexec/ranges.c | 4 +++ arch/powerpc/mm/book3s64/Makefile | 15 ++++---- arch/powerpc/mm/book3s64/hugetlbpage.c | 2 ++ arch/powerpc/mm/book3s64/mmu_context.c | 34 +++++++++++++++---- arch/powerpc/mm/book3s64/radix_pgtable.c | 4 +++ arch/powerpc/mm/copro_fault.c | 2 ++ arch/powerpc/mm/ioremap.c | 13 ++++--- arch/powerpc/mm/pgtable.c | 10 ++++-- arch/powerpc/mm/ptdump/Makefile | 2 +- arch/powerpc/platforms/Kconfig.cputype | 4 +++ arch/powerpc/platforms/powernv/idle.c | 2 ++ arch/powerpc/platforms/powernv/setup.c | 2 ++ arch/powerpc/platforms/pseries/lpar.c | 11 ++++-- arch/powerpc/platforms/pseries/lparcfg.c | 2 +- arch/powerpc/platforms/pseries/mobility.c | 6 ++++ arch/powerpc/platforms/pseries/ras.c | 2 ++ arch/powerpc/platforms/pseries/reconfig.c | 2 ++ arch/powerpc/platforms/pseries/setup.c | 6 ++-- arch/powerpc/xmon/xmon.c | 8 +++-- drivers/misc/lkdtm/Makefile | 2 +- drivers/misc/lkdtm/core.c | 2 +- 39 files changed, 219 insertions(+), 64 deletions(-)
arch/powerpc/Kconfig +1 -1
@@ -838,7 +838,7 @@ config FORCE_MAX_ZONEORDER config PPC_SUBPAGE_PROT bool "Support setting protections for 4k subpages (subpage_prot syscall)" default n - depends on PPC_BOOK3S_64 && PPC_64K_PAGES + depends on PPC_64S_HASH_MMU && PPC_64K_PAGES help This option adds support for system call to allow user programs to set access permissions (read/write, readonly, or no access)
arch/powerpc/include/asm/book3s/64/mmu.h +17 -2
@@ -98,7 +98,9 @@ typedef struct {* from EA and new context ids to build the new VAs. */ mm_context_id_t id; +#ifdef CONFIG_PPC_64S_HASH_MMU mm_context_id_t extended_id[TASK_SIZE_USER64 /TASK_CONTEXT_SIZE ]; +#endif };/* Number of bits in the mm_cpumask */
@@ -110,7 +112,9 @@ typedef struct {/* Number of user space windows opened in process mm_context */ atomic_t vas_windows; +#ifdef CONFIG_PPC_64S_HASH_MMU struct hash_mm_context *hash_context; +#endif void __user *vdso;/*
@@ -133,6 +137,7 @@ typedef struct {#endif } mm_context_t; +#ifdef CONFIG_PPC_64S_HASH_MMU static inline u16 mm_ctx_user_psize (mm_context_t *ctx) {return ctx->hash_context->user_psize;
@@ -193,8 +198,15 @@ static inline struct subpage_prot_table *mm_ctx_subpage_prot(mm_context_t *ctx)extern int mmu_linear_psize;extern int mmu_virtual_psize;extern int mmu_vmalloc_psize; -extern int mmu_vmemmap_psize;extern int mmu_io_psize; +#else /* CONFIG_PPC_64S_HASH_MMU */ +#ifdef CONFIG_PPC_64K_PAGES +#define mmu_virtual_psize MMU_PAGE_64K +#else +#define mmu_virtual_psize MMU_PAGE_4K +#endif +#endif +extern int mmu_vmemmap_psize;/* MMU initialization */ void mmu_early_init_devtree (void );
@@ -233,7 +245,8 @@ static inline void setup_initial_memory_limit(phys_addr_t first_memblock_base,* know which translations we will pick. Hence go with hash * restrictions. */ -return hash__setup_initial_memory_limit (first_memblock_base, +if (!radix_enabled ()) +return hash__setup_initial_memory_limit (first_memblock_base, first_memblock_size); }
@@ -255,6 +268,7 @@ static inline void radix_init_pseries(void) { }void cleanup_cpu_mmu_context (void );#endif +#ifdef CONFIG_PPC_64S_HASH_MMU static inline int get_user_context (mm_context_t *ctx,unsigned long ea) {int index = ea >>MAX_EA_BITS_PER_CONTEXT ;
@@ -274,6 +288,7 @@ static inline unsigned long get_user_vsid(mm_context_t *ctx,return get_vsid (context, ea, ssize); } +#endif #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_BOOK3S_64_MMU_H_ */
arch/powerpc/include/asm/book3s/64/tlbflush-hash.h +7 -0
@@ -112,8 +112,15 @@ static inline void hash__flush_tlb_kernel_range(unsigned long start,struct mmu_gather ;extern void hash__tlb_flush (struct mmu_gather *tlb); +extern void flush_tlb_pmd_range (struct mm_struct *mm,pmd_t *pmd, +unsigned long addr); + +#ifdef CONFIG_PPC_64S_HASH_MMU /* Private function for use by PCI IO mapping code */ extern void __flush_hash_table_range (unsigned long start,unsigned long end);extern void flush_tlb_pmd_range (struct mm_struct *mm,pmd_t *pmd,unsigned long addr); +#else +static inline void __flush_hash_table_range (unsigned long start,unsigned long end) { } +#endif #endif /* _ASM_POWERPC_BOOK3S_64_TLBFLUSH_HASH_H */
arch/powerpc/include/asm/book3s/pgtable.h +4 -0
@@ -25,6 +25,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, unsigned long size, pgprot_t vma_prot);#define __HAVE_PHYS_MEM_ACCESS_PROT +#if defined(CONFIG_PPC_HASH_MMU_NATIVE ) || defined(CONFIG_PPC_64S_HASH_MMU )/* * This gets called at the end of handling a page fault, when * the kernel has put a new PTE into the page table for the process.
@@ -35,6 +36,9 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,* waiting for the inevitable extra hash-table miss exception. */ void update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t *ptep); +#else +static inline void update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t *ptep) {} +#endif #endif /* __ASSEMBLY__ */ #endif
arch/powerpc/include/asm/mmu.h +13 -3
@@ -157,7 +157,7 @@ DECLARE_PER_CPU(int, next_tlbcam_idx);enum { MMU_FTRS_POSSIBLE = -#if defined(CONFIG_PPC_BOOK3S_64) || defined(CONFIG_PPC_BOOK3S_604) +#if defined(CONFIG_PPC_BOOK3S_604) MMU_FTR_HPTE_TABLE | #endif#ifdef CONFIG_PPC_8xx
@@ -184,15 +184,18 @@ enum { MMU_FTR_USE_TLBRSRV | MMU_FTR_USE_PAIRED_MAS |#endif #ifdef CONFIG_PPC_BOOK3S_64 + MMU_FTR_KERNEL_RO | +#ifdef CONFIG_PPC_64S_HASH_MMU MMU_FTR_NO_SLBIE_B | MMU_FTR_16M_PAGE | MMU_FTR_TLBIEL | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_CI_LARGE_PAGE | MMU_FTR_1T_SEGMENT | MMU_FTR_TLBIE_CROP_VA | - MMU_FTR_KERNEL_RO | MMU_FTR_68_BIT_VA | + MMU_FTR_68_BIT_VA | MMU_FTR_HPTE_TABLE |#endif #ifdef CONFIG_PPC_RADIX_MMU MMU_FTR_TYPE_RADIX | MMU_FTR_GTSE |#endif /* CONFIG_PPC_RADIX_MMU */ +#endif #ifdef CONFIG_PPC_KUAP MMU_FTR_BOOK3S_KUAP |#endif /* CONFIG_PPC_KUAP */
@@ -223,6 +226,13 @@ enum {#ifdef CONFIG_E500 #define MMU_FTRS_ALWAYS MMU_FTR_TYPE_FSL_E#endif +#ifdef CONFIG_PPC_BOOK3S_64 +#if defined(CONFIG_PPC_RADIX_MMU ) && !defined(CONFIG_PPC_64S_HASH_MMU ) +#define MMU_FTRS_ALWAYS MMU_FTR_TYPE_RADIX +#elif !defined(CONFIG_PPC_RADIX_MMU ) && defined(CONFIG_PPC_64S_HASH_MMU ) +#define MMU_FTRS_ALWAYS MMU_FTR_HPTE_TABLE +#endif +#endif #ifndef MMU_FTRS_ALWAYS #define MMU_FTRS_ALWAYS 0
@@ -329,7 +339,7 @@ static __always_inline bool radix_enabled(void)return mmu_has_feature (MMU_FTR_TYPE_RADIX ); } -static inline bool early_radix_enabled (void ) +static __always_inline bool early_radix_enabled(void) {return early_mmu_has_feature (MMU_FTR_TYPE_RADIX ); }
arch/powerpc/include/asm/mmu_context.h +2 -0
@@ -75,6 +75,7 @@ extern void hash__reserve_context_id(int id);extern void __destroy_context (int context_id);static inline void mmu_context_init (void ) { } +#ifdef CONFIG_PPC_64S_HASH_MMU static inline int alloc_extended_context (struct mm_struct *mm,unsigned long ea) {
@@ -100,6 +101,7 @@ static inline bool need_extra_context(struct mm_struct *mm, unsigned long ea)return true;return false; } +#endif #else extern void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next,
arch/powerpc/include/asm/paca.h +8 -0
@@ -97,7 +97,9 @@ struct paca_struct {/* this becomes non-zero. */ u8 kexec_state;/* set when kexec down has irqs off */ #ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU struct slb_shadow *slb_shadow_ptr; +#endif struct dtl_entry *dispatch_log;struct dtl_entry *dispatch_log_end;#endif
@@ -110,6 +112,7 @@ struct paca_struct {/* used for most interrupts/exceptions */ u64 exgen[EX_SIZE] __attribute__((aligned(0x80))); +#ifdef CONFIG_PPC_64S_HASH_MMU /* SLB related definitions */ u16 vmalloc_sllp;u8 slb_cache_ptr;
@@ -120,6 +123,7 @@ struct paca_struct {u32 slb_used_bitmap;/* Bitmaps for first 32 SLB entries. */ u32 slb_kern_bitmap;u32 slb_cache[SLB_CACHE_ENTRIES ]; +#endif #endif /* CONFIG_PPC_BOOK3S_64 */ #ifdef CONFIG_PPC_BOOK3E
@@ -149,6 +153,7 @@ struct paca_struct {#endif /* CONFIG_PPC_BOOK3E */ #ifdef CONFIG_PPC_BOOK3S +#ifdef CONFIG_PPC_64S_HASH_MMU #ifdef CONFIG_PPC_MM_SLICES unsigned char mm_ctx_low_slices_psize[BITS_PER_LONG /BITS_PER_BYTE ];unsigned char mm_ctx_high_slices_psize[SLICE_ARRAY_SIZE ];
@@ -156,6 +161,7 @@ struct paca_struct {u16 mm_ctx_user_psize;u16 mm_ctx_sllp;#endif +#endif #endif /*
@@ -268,9 +274,11 @@ struct paca_struct {#endif /* CONFIG_PPC_PSERIES */ #ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU /* Capture SLB related old contents in MCE handler. */ struct slb_entry *mce_faulty_slbs;u16 slb_save_cache_ptr; +#endif #endif /* CONFIG_PPC_BOOK3S_64 */ #ifdef CONFIG_STACKPROTECTOR unsigned long canary;
arch/powerpc/kernel/asm-offsets.c +2 -0
@@ -220,10 +220,12 @@ int main(void)OFFSET (PACA_EXGEN , paca_struct, exgen);OFFSET (PACA_EXMC , paca_struct, exmc);OFFSET (PACA_EXNMI , paca_struct, exnmi); +#ifdef CONFIG_PPC_64S_HASH_MMU OFFSET (PACA_SLBSHADOWPTR , paca_struct, slb_shadow_ptr);OFFSET (SLBSHADOW_STACKVSID , slb_shadow, save_area[SLB_NUM_BOLTED -1 ].vsid);OFFSET (SLBSHADOW_STACKESID , slb_shadow, save_area[SLB_NUM_BOLTED -1 ].esid);OFFSET (SLBSHADOW_SAVEAREA , slb_shadow, save_area); +#endif OFFSET (LPPACA_PMCINUSE , lppaca, pmcregs_in_use);#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE OFFSET (PACA_PMCINUSE , paca_struct, pmcregs_in_use);
arch/powerpc/kernel/dt_cpu_ftrs.c +10 -4
@@ -271,6 +271,9 @@ static int __init feat_enable_mmu_hash(struct dt_cpu_feature *f) {u64 lpcr; +if (!IS_ENABLED (CONFIG_PPC_64S_HASH_MMU )) +return 0 ; + lpcr =mfspr (SPRN_LPCR ); lpcr &= ~LPCR_ISL ;
@@ -290,6 +293,9 @@ static int __init feat_enable_mmu_hash_v3(struct dt_cpu_feature *f) {u64 lpcr; +if (!IS_ENABLED (CONFIG_PPC_64S_HASH_MMU )) +return 0 ; + lpcr =mfspr (SPRN_LPCR ); lpcr &= ~(LPCR_ISL |LPCR_UPRT |LPCR_HR );mtspr (SPRN_LPCR , lpcr);
@@ -303,15 +309,15 @@ static int __init feat_enable_mmu_hash_v3(struct dt_cpu_feature *f)static int __init feat_enable_mmu_radix (struct dt_cpu_feature *f) { -#ifdef CONFIG_PPC_RADIX_MMU +if (!IS_ENABLED (CONFIG_PPC_RADIX_MMU )) +return 0 ; + + cur_cpu_spec->mmu_features |=MMU_FTR_KERNEL_RO ; cur_cpu_spec->mmu_features |=MMU_FTR_TYPE_RADIX ; - cur_cpu_spec->mmu_features |=MMU_FTRS_HASH_BASE ; cur_cpu_spec->mmu_features |=MMU_FTR_GTSE ; cur_cpu_spec->cpu_user_features |=PPC_FEATURE_HAS_MMU ;return 1 ; -#endif -return 0 ; }static int __init feat_enable_dscr (struct dt_cpu_feature *f)
arch/powerpc/kernel/entry_64.S +2 -2
@@ -180,7 +180,7 @@ _GLOBAL(_switch) #endif ld r8,KSP(r4) /* new stack pointer */ -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU BEGIN_MMU_FTR_SECTION b 2f END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_RADIX)
@@ -232,7 +232,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) slbmte r7,r0 isync 2: -#endif /* CONFIG_PPC_BOOK3S_64 */ +#endif /* CONFIG_PPC_64S_HASH_MMU */ clrrdi r7, r8, THREAD_SHIFT /* base of new stack */ /* Note: this uses SWITCH_FRAME_SIZE rather than INT_FRAME_SIZE
arch/powerpc/kernel/exceptions-64s.S +16 -0
@@ -1369,11 +1369,15 @@ EXC_COMMON_BEGIN(data_access_common) addi r3,r1,STACK_FRAME_OVERHEAD andis. r0,r4,DSISR_DABRMATCH@h bne- 1f +#ifdef CONFIG_PPC_64S_HASH_MMU BEGIN_MMU_FTR_SECTION bl do_hash_fault MMU_FTR_SECTION_ELSE bl do_page_fault ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) +#else + bl do_page_fault +#endif b interrupt_return_srr 1: bl do_break
@@ -1416,6 +1420,7 @@ EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x80) EXC_VIRT_END(data_access_slb, 0x4380, 0x80) EXC_COMMON_BEGIN(data_access_slb_common) GEN_COMMON data_access_slb +#ifdef CONFIG_PPC_64S_HASH_MMU BEGIN_MMU_FTR_SECTION /* HPT case, do SLB fault */ addi r3,r1,STACK_FRAME_OVERHEAD
@@ -1428,6 +1433,9 @@ MMU_FTR_SECTION_ELSE /* Radix case, access is outside page table range */ li r3,-EFAULT ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) +#else + li r3,-EFAULT +#endif std r3,RESULT(r1) addi r3,r1,STACK_FRAME_OVERHEAD bl do_bad_segment_interrupt
@@ -1462,11 +1470,15 @@ EXC_VIRT_END(instruction_access, 0x4400, 0x80) EXC_COMMON_BEGIN(instruction_access_common) GEN_COMMON instruction_access addi r3,r1,STACK_FRAME_OVERHEAD +#ifdef CONFIG_PPC_64S_HASH_MMU BEGIN_MMU_FTR_SECTION bl do_hash_fault MMU_FTR_SECTION_ELSE bl do_page_fault ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) +#else + bl do_page_fault +#endif b interrupt_return_srr
@@ -1496,6 +1508,7 @@ EXC_VIRT_BEGIN(instruction_access_slb, 0x4480, 0x80) EXC_VIRT_END(instruction_access_slb, 0x4480, 0x80) EXC_COMMON_BEGIN(instruction_access_slb_common) GEN_COMMON instruction_access_slb +#ifdef CONFIG_PPC_64S_HASH_MMU BEGIN_MMU_FTR_SECTION /* HPT case, do SLB fault */ addi r3,r1,STACK_FRAME_OVERHEAD
@@ -1508,6 +1521,9 @@ MMU_FTR_SECTION_ELSE /* Radix case, access is outside page table range */ li r3,-EFAULT ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) +#else + li r3,-EFAULT +#endif std r3,RESULT(r1) addi r3,r1,STACK_FRAME_OVERHEAD bl do_bad_segment_interrupt
arch/powerpc/kernel/mce.c +1 -1
@@ -586,7 +586,7 @@ void machine_check_print_event_info(struct machine_check_event *evt, mc_error_class[evt->error_class] : "Unknown";printk ("%sMCE: CPU%d: %s\n" , level, evt->cpu, subtype); -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU /* Display faulty slb contents for SLB errors. */ if (evt->error_type ==MCE_ERROR_TYPE_SLB && !in_guest)slb_dump_contents (local_paca->mce_faulty_slbs);
arch/powerpc/kernel/mce_power.c +7 -3
@@ -77,7 +77,7 @@ static bool mce_in_guest(void) }/* flush SLBs and reload */ -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU void flush_and_reload_slb (void ) {if (early_radix_enabled ())
@@ -99,7 +99,7 @@ void flush_and_reload_slb(void)void flush_erat (void ) { -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU if (!early_cpu_has_feature (CPU_FTR_ARCH_300 )) {flush_and_reload_slb ();return ;
@@ -114,7 +114,7 @@ void flush_erat(void)static int mce_flush (int what) { -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU if (what ==MCE_FLUSH_SLB ) {flush_and_reload_slb ();return 1 ;
@@ -499,8 +499,10 @@ static int mce_handle_ierror(struct pt_regs *regs, unsigned long srr1,/* attempt to correct the error */ switch (table[i].error_type) {case MCE_ERROR_TYPE_SLB : +#ifdef CONFIG_PPC_64S_HASH_MMU if (local_paca->in_mce ==1 )slb_save_contents (local_paca->mce_faulty_slbs); +#endif handled =mce_flush (MCE_FLUSH_SLB );break ;case MCE_ERROR_TYPE_ERAT :
@@ -588,8 +590,10 @@ static int mce_handle_derror(struct pt_regs *regs,/* attempt to correct the error */ switch (table[i].error_type) {case MCE_ERROR_TYPE_SLB : +#ifdef CONFIG_PPC_64S_HASH_MMU if (local_paca->in_mce ==1 )slb_save_contents (local_paca->mce_faulty_slbs); +#endif if (mce_flush (MCE_FLUSH_SLB )) handled =1 ;break ;
arch/powerpc/kernel/paca.c +7 -11
@@ -139,8 +139,7 @@ static struct lppaca * __init new_lppaca(int cpu, unsigned long limit) }#endif /* CONFIG_PPC_PSERIES */ -#ifdef CONFIG_PPC_BOOK3S_64 - +#ifdef CONFIG_PPC_64S_HASH_MMU /* * 3 persistent SLBs are allocated here. The buffer will be zero * initially, hence will all be invaild until we actually write them.
@@ -169,8 +168,7 @@ static struct slb_shadow * __init new_slb_shadow(int cpu, unsigned long limit) return s; } - -#endif /* CONFIG_PPC_BOOK3S_64 */ +#endif /* CONFIG_PPC_64S_HASH_MMU */ #ifdef CONFIG_PPC_PSERIES /**
@@ -226,7 +224,7 @@ void __init initialise_paca(struct paca_struct *new_paca, int cpu) new_paca->kexec_state =KEXEC_STATE_NONE ; new_paca->__current = &init_task; new_paca->data_offset =0xfeeeeeeeeeeeeeeeULL ; -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU new_paca->slb_shadow_ptr =NULL ;#endif
@@ -307,7 +305,7 @@ void __init allocate_paca(int cpu)#ifdef CONFIG_PPC_PSERIES paca->lppaca_ptr =new_lppaca (cpu, limit);#endif -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU paca->slb_shadow_ptr =new_slb_shadow (cpu, limit);#endif #ifdef CONFIG_PPC_PSERIES
@@ -328,7 +326,7 @@ void __init free_unused_pacas(void) paca_nr_cpu_ids = nr_cpu_ids; paca_ptrs_size = new_ptrs_size; -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU if (early_radix_enabled ()) {/* Ugly fixup, see new_slb_shadow() */ memblock_free(__pa(paca_ptrs[boot_cpuid]->slb_shadow_ptr),
@@ -341,9 +339,9 @@ void __init free_unused_pacas(void) paca_ptrs_size + paca_struct_size, nr_cpu_ids); } +#ifdef CONFIG_PPC_64S_HASH_MMU void copy_mm_to_paca (struct mm_struct *mm) { -#ifdef CONFIG_PPC_BOOK3S mm_context_t *context = &mm->context;#ifdef CONFIG_PPC_MM_SLICES
@@ -356,7 +354,5 @@ void copy_mm_to_paca(struct mm_struct *mm)get_paca ()->mm_ctx_user_psize = context->user_psize;get_paca ()->mm_ctx_sllp = context->sllp; #endif -#else /* !CONFIG_PPC_BOOK3S */ -return ; -#endif } +#endif /* CONFIG_PPC_64S_HASH_MMU */
arch/powerpc/kernel/process.c +7 -6
@@ -1206,7 +1206,7 @@ struct task_struct *__switch_to(struct task_struct *prev, {struct thread_struct *new_thread, *old_thread;struct task_struct *last; -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU struct ppc64_tlb_batch *batch;#endif
@@ -1215,7 +1215,7 @@ struct task_struct *__switch_to(struct task_struct *prev,WARN_ON (!irqs_disabled ()); -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU batch =this_cpu_ptr (&ppc64_tlb_batch);if (batch->active) {current_thread_info ()->local_flags |= _TLF_LAZY_MMU;
@@ -1294,6 +1294,7 @@ struct task_struct *__switch_to(struct task_struct *prev,*/ #ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU /* * This applies to a process that was context switched while inside * arch_enter_lazy_mmu_mode(), to re-activate the batch that was
@@ -1305,6 +1306,7 @@ struct task_struct *__switch_to(struct task_struct *prev, batch =this_cpu_ptr (&ppc64_tlb_batch); batch->active = 1; } +#endif /* * Math facilities are masked out of the child MSR in copy_thread.
@@ -1655,7 +1657,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)static void setup_ksp_vsid (struct task_struct *p,unsigned long sp) { -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU unsigned long sp_vsid;unsigned long llp = mmu_psize_defs[mmu_linear_psize].sllp;
@@ -2302,10 +2304,9 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)* the heap, we can put it above 1TB so it is backed by a 1TB * segment. Otherwise the heap will be in the bottom 1TB * which always uses 256MB segments and this may result in a -* performance penalty. We don't need to worry about radix. For -* radix, mmu_highuser_ssize remains unchanged from 256MB. +* performance penalty. */ -if (!is_32bit_task () && (mmu_highuser_ssize ==MMU_SEGSIZE_1T )) +if (!radix_enabled () && !is_32bit_task () && (mmu_highuser_ssize ==MMU_SEGSIZE_1T )) base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);#endif
arch/powerpc/kernel/prom.c +2 -0
@@ -234,6 +234,7 @@ static void __init check_cpu_pa_features(unsigned long node)#ifdef CONFIG_PPC_BOOK3S_64 static void __init init_mmu_slb_size (unsigned long node) { +#ifdef CONFIG_PPC_64S_HASH_MMU const __be32 *slb_size_ptr; slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL) ? :
@@ -241,6 +242,7 @@ static void __init init_mmu_slb_size(unsigned long node)if (slb_size_ptr) mmu_slb_size =be32_to_cpup (slb_size_ptr); +#endif }#else #define init_mmu_slb_size (node) do { } while(0)
arch/powerpc/kernel/setup_64.c +5 -0
@@ -887,6 +887,8 @@ void __init setup_per_cpu_areas(void) }else if (radix_enabled ()) { atom_size =PAGE_SIZE ; }else { +#ifdef CONFIG_PPC_64S_HASH_MMU +/* * Linear mapping is one of 4K, 1M and 16M. For 4K, no need * to group units. For larger mappings, use 1M atom which
@@ -896,6 +898,9 @@ void __init setup_per_cpu_areas(void) atom_size =PAGE_SIZE ; else atom_size =1 <<20 ; +#else +BUILD_BUG ();// radix_enabled() should be constant true +#endif }if (pcpu_chosen_fc !=PCPU_FC_PAGE ) {
arch/powerpc/kexec/core_64.c +2 -2
@@ -378,7 +378,7 @@ void default_machine_kexec(struct kimage *image)/* NOTREACHED */ } -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU /* Values we need to export to the second kernel via the device tree. */ static unsigned long htab_base;static unsigned long htab_size;
@@ -420,4 +420,4 @@ static int __init export_htab_values(void) return 0; }late_initcall (export_htab_values); -#endif /* CONFIG_PPC_BOOK3S_64 */ +#endif /* CONFIG_PPC_64S_HASH_MMU */
arch/powerpc/kexec/ranges.c +4 -0
@@ -306,10 +306,14 @@ int add_initrd_mem_range(struct crash_mem **mem_ranges)*/ int add_htab_mem_range (struct crash_mem **mem_ranges) { +#ifdef CONFIG_PPC_64S_HASH_MMU if (!htab_address)return 0 ;return add_mem_range (mem_ranges,__pa (htab_address), htab_size_bytes); +#else +return 0 ; +#endif }#endif
arch/powerpc/mm/book3s64/Makefile +9 -6
@@ -2,20 +2,23 @@ ccflags-y := $(NO_MINIMAL_TOC) +obj-y += mmu_context.o pgtable.o trace.o +ifdef CONFIG_PPC_64S_HASH_MMU CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE) - -obj-y += hash_pgtable.o hash_utils.o slb.o \ - mmu_context.o pgtable.o hash_tlb.o trace.o +obj-y += hash_pgtable.o hash_utils.o hash_tlb.o slb.o obj-$(CONFIG_PPC_HASH_MMU_NATIVE) += hash_native.o -obj-$(CONFIG_PPC_RADIX_MMU) += radix_pgtable.o radix_tlb.o obj-$(CONFIG_PPC_4K_PAGES) += hash_4k.o obj-$(CONFIG_PPC_64K_PAGES) += hash_64k.o +obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += hash_hugepage.o +obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage_prot.o +endif + obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o + +obj-$(CONFIG_PPC_RADIX_MMU) += radix_pgtable.o radix_tlb.o ifdef CONFIG_HUGETLB_PAGE obj-$(CONFIG_PPC_RADIX_MMU) += radix_hugetlbpage.o endif -obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += hash_hugepage.o -obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage_prot.o obj-$(CONFIG_SPAPR_TCE_IOMMU) += iommu_api.o obj-$(CONFIG_PPC_PKEY) += pkeys.o
arch/powerpc/mm/book3s64/hugetlbpage.c +2 -0
@@ -16,6 +16,7 @@unsigned int hpage_shift;EXPORT_SYMBOL (hpage_shift); +#ifdef CONFIG_PPC_64S_HASH_MMU int __hash_page_huge (unsigned long ea,unsigned long access,unsigned long vsid,pte_t *ptep,unsigned long trap,unsigned long flags,int ssize,unsigned int shift,unsigned int mmu_psize)
@@ -122,6 +123,7 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, *ptep =__pte (new_pte & ~H_PAGE_BUSY ); return 0; } +#endif pte_t huge_ptep_modify_prot_start (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep)
arch/powerpc/mm/book3s64/mmu_context.c +28 -6
@@ -31,6 +31,7 @@ static int alloc_context_id(int min_id, int max_id)return ida_alloc_range (&mmu_context_ida, min_id, max_id,GFP_KERNEL ); } +#ifdef CONFIG_PPC_64S_HASH_MMU void hash__reserve_context_id (int id) {int result =ida_alloc_range (&mmu_context_ida, id, id,GFP_KERNEL );
@@ -50,7 +51,9 @@ int hash__alloc_context_id(void)return alloc_context_id (MIN_USER_CONTEXT , max); }EXPORT_SYMBOL_GPL (hash__alloc_context_id); +#endif +#ifdef CONFIG_PPC_64S_HASH_MMU static int realloc_context_ids (mm_context_t *ctx) {int i, id;
@@ -144,12 +147,21 @@ static int hash__init_new_context(struct mm_struct *mm) return index; } +void slb_setup_new_exec (void ); +void hash__setup_new_exec (void ) {slice_setup_new_exec ();slb_setup_new_exec (); } +#else +static inline int hash__init_new_context (struct mm_struct *mm) +{ +BUILD_BUG (); +return 0 ; +} +#endif static int radix__init_new_context (struct mm_struct *mm) {
@@ -175,7 +187,9 @@ static int radix__init_new_context(struct mm_struct *mm)*/ asmvolatile ("ptesync;isync" : : :"memory" ); +#ifdef CONFIG_PPC_64S_HASH_MMU mm->context.hash_context =NULL ; +#endif return index; }
@@ -213,14 +227,22 @@ EXPORT_SYMBOL_GPL(__destroy_context);static void destroy_contexts (mm_context_t *ctx) { -int index, context_id; +if (radix_enabled ()) { +ida_free (&mmu_context_ida, ctx->id); + }else { +#ifdef CONFIG_PPC_64S_HASH_MMU +int index, context_id; -for (index =0 ; index <ARRAY_SIZE (ctx->extended_id); index++) { - context_id = ctx->extended_id[index]; -if (context_id) -ida_free (&mmu_context_ida, context_id); +for (index =0 ; index <ARRAY_SIZE (ctx->extended_id); index++) { + context_id = ctx->extended_id[index]; +if (context_id) +ida_free (&mmu_context_ida, context_id); + } +kfree (ctx->hash_context); +#else +BUILD_BUG ();// radix_enabled() should be constant true +#endif } -kfree (ctx->hash_context); }static void pmd_frag_destroy (void *pmd_frag)
arch/powerpc/mm/book3s64/radix_pgtable.c +4 -0
@@ -334,8 +334,10 @@ static void __init radix_init_pgtable(void)phys_addr_t start, end;u64 i; +#ifdef CONFIG_PPC_64S_HASH_MMU /* We don't support slb for radix */ mmu_slb_size =0 ; +#endif /* * Create the linear mapping
@@ -588,6 +590,7 @@ void __init radix__early_init_mmu(void) {unsigned long lpcr; +#ifdef CONFIG_PPC_64S_HASH_MMU #ifdef CONFIG_PPC_64K_PAGES /* PAGE_SIZE mappings */ mmu_virtual_psize =MMU_PAGE_64K ;
@@ -604,6 +607,7 @@ void __init radix__early_init_mmu(void) mmu_vmemmap_psize =MMU_PAGE_2M ; } else mmu_vmemmap_psize = mmu_virtual_psize; +#endif #endif /* * initialize page table size
arch/powerpc/mm/copro_fault.c +2 -0
@@ -82,6 +82,7 @@ int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea, }EXPORT_SYMBOL_GPL (copro_handle_mm_fault); +#ifdef CONFIG_PPC_64S_HASH_MMU int copro_calculate_slb (struct mm_struct *mm,u64 ea,struct copro_slb *slb) {u64 vsid, vsidkey;
@@ -146,3 +147,4 @@ void copro_flush_all_slbs(struct mm_struct *mm) cxl_slbia(mm); }EXPORT_SYMBOL_GPL (copro_flush_all_slbs); +#endif
arch/powerpc/mm/ioremap.c +9 -4
@@ -113,11 +113,16 @@ unsigned long memremap_compat_align(void)// 1GB maximum possible size of the linear mapping. return max (SUBSECTION_SIZE ,1UL <<30 );#else -unsigned int shift = mmu_psize_defs[mmu_linear_psize].shift; - -if (radix_enabled ()) +if (radix_enabled ()) {return SUBSECTION_SIZE ; -return max (SUBSECTION_SIZE ,1UL << shift); + }else { +#ifdef CONFIG_PPC_64S_HASH_MMU +unsigned int shift = mmu_psize_defs[mmu_linear_psize].shift; +return max (SUBSECTION_SIZE ,1UL << shift); +#else +BUILD_BUG ();// radix_enabled() should be constant true +#endif + }#endif }EXPORT_SYMBOL_GPL (memremap_compat_align);
arch/powerpc/mm/pgtable.c +7 -3
@@ -81,9 +81,6 @@ static struct page *maybe_pte_to_page(pte_t pte)static pte_t set_pte_filter_hash (pte_t pte) { -if (radix_enabled ()) -return pte; - pte =__pte (pte_val (pte) & ~_PAGE_HPTEFLAGS);if (pte_looks_normal (pte) && !(cpu_has_feature (CPU_FTR_COHERENT_ICACHE ) ||cpu_has_feature (CPU_FTR_NOEXECUTE ))) {
@@ -112,6 +109,9 @@ static inline pte_t set_pte_filter(pte_t pte) {struct page *pg; +if (radix_enabled ()) +return pte; +if (mmu_has_feature (MMU_FTR_HPTE_TABLE ))return set_pte_filter_hash (pte);
@@ -144,6 +144,10 @@ static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma, {struct page *pg; +#ifdef CONFIG_PPC_BOOK3S_64 +return pte; +#endif +if (mmu_has_feature (MMU_FTR_HPTE_TABLE ))return pte;
arch/powerpc/mm/ptdump/Makefile +1 -1
@@ -10,5 +10,5 @@ obj-$(CONFIG_PPC_BOOK3S_64) += book3s64.o ifdef CONFIG_PTDUMP_DEBUGFS obj-$(CONFIG_PPC_BOOK3S_32) += bats.o segment_regs.o -obj-$(CONFIG_PPC_BOOK3S_64) += hashpagetable.o +obj-$(CONFIG_PPC_64S_HASH_MMU) += hashpagetable.o endif
arch/powerpc/platforms/Kconfig.cputype +4 -0
@@ -105,6 +105,7 @@ config PPC_BOOK3S_64 select HAVE_MOVE_PMD select HAVE_MOVE_PUD select IRQ_WORK + select PPC_64S_HASH_MMU select PPC_MM_SLICES select PPC_HAVE_KUEP select PPC_HAVE_KUAP
@@ -364,6 +365,9 @@ config SPE If in doubt, say Y here. +config PPC_64S_HASH_MMU + bool + config PPC_RADIX_MMU bool "Radix MMU Support" depends on PPC_BOOK3S_64
arch/powerpc/platforms/powernv/idle.c +2 -0
@@ -492,12 +492,14 @@ static unsigned long power7_idle_insn(unsigned long type)mtspr (SPRN_SPRG3 , local_paca->sprg_vdso); +#ifdef CONFIG_PPC_64S_HASH_MMU /* * The SLB has to be restored here, but it sometimes still * contains entries, so the __ variant must be used to prevent * multi hits. */ __slb_restore_bolted_realmode (); +#endif return srr1; }
arch/powerpc/platforms/powernv/setup.c +2 -0
@@ -207,6 +207,7 @@ static void __init pnv_init(void)#endif add_preferred_console ("hvc" ,0 ,NULL ); +#ifdef CONFIG_PPC_64S_HASH_MMU if (!radix_enabled ()) {size_t size =sizeof (struct slb_entry ) * mmu_slb_size;int i;
@@ -219,6 +220,7 @@ static void __init pnv_init(void) cpu_to_node(i)); } } +#endif }static void __init pnv_init_IRQ (void )
arch/powerpc/platforms/pseries/lpar.c +9 -2
@@ -58,6 +58,7 @@ EXPORT_SYMBOL(plpar_hcall);EXPORT_SYMBOL (plpar_hcall9);EXPORT_SYMBOL (plpar_hcall_norets); +#ifdef CONFIG_PPC_64S_HASH_MMU /* * H_BLOCK_REMOVE supported block size for this page size in segment who's base * page size is that page size.
@@ -66,6 +67,7 @@ EXPORT_SYMBOL(plpar_hcall_norets);* page size. */ static int hblkrm_size[MMU_PAGE_COUNT ][MMU_PAGE_COUNT ]__ro_after_init ; +#endif /* * Due to the involved complexity, and that the current hypervisor is only
@@ -689,7 +691,7 @@ void vpa_init(int cpu)return ; } -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU /* * PAPR says this feature is SLB-Buffer but firmware never * reports that. All SPLPAR support SLB shadow buffer.
@@ -702,7 +704,7 @@ void vpa_init(int cpu)"cpu %d (hw %d) of area %lx failed with %ld\n" , cpu, hwcpu, addr, ret); } -#endif /* CONFIG_PPC_BOOK3S_64 */ +#endif /* CONFIG_PPC_64S_HASH_MMU */ /* * Register dispatch trace log, if one has been allocated.
@@ -740,6 +742,8 @@ static int pseries_lpar_register_process_table(unsigned long base,return rc; } +#ifdef CONFIG_PPC_64S_HASH_MMU + static long pSeries_lpar_hpte_insert(unsigned long hpte_group, unsigned long vpn, unsigned long pa, unsigned long rflags, unsigned long vflags,
@@ -1730,6 +1734,7 @@ void __init hpte_init_pseries(void)if (cpu_has_feature (CPU_FTR_ARCH_300 )) pseries_lpar_register_process_table(0, 0, 0); } +#endif /* CONFIG_PPC_64S_HASH_MMU */ #ifdef CONFIG_PPC_RADIX_MMU void radix_init_pseries (void )
@@ -1932,6 +1937,7 @@ int h_get_mpp_x(struct hvcall_mpp_x_data *mpp_x_data)return rc; } +#ifdef CONFIG_PPC_64S_HASH_MMU static unsigned long vsid_unscramble (unsigned long vsid,int ssize) {unsigned long protovsid;
@@ -1992,6 +1998,7 @@ static int __init reserve_vrma_context_id(void) return 0; }machine_device_initcall (pseries, reserve_vrma_context_id); +#endif #ifdef CONFIG_DEBUG_FS /* debugfs file interface for vpa data */
arch/powerpc/platforms/pseries/lparcfg.c +1 -1
@@ -531,7 +531,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)seq_printf (m,"shared_processor_mode=%d\n" ,lppaca_shared_proc (get_lppaca ())); -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU if (!radix_enabled ())seq_printf (m,"slb_size=%d\n" , mmu_slb_size);#endif
arch/powerpc/platforms/pseries/mobility.c +6 -0
@@ -417,11 +417,15 @@ static void prod_others(void)static u16 clamp_slb_size (void ) { +#ifdef CONFIG_PPC_64S_HASH_MMU u16 prev = mmu_slb_size;slb_set_size (SLB_MIN_SIZE );return prev; +#else +return 0 ; +#endif }static int do_suspend (void )
@@ -446,7 +450,9 @@ static int do_suspend(void) ret =rtas_ibm_suspend_me (&status);if (ret !=0 ) {pr_err ("ibm,suspend-me error: %d\n" , status); +#ifdef CONFIG_PPC_64S_HASH_MMU slb_set_size (saved_slb_size); +#endif }return ret;
arch/powerpc/platforms/pseries/ras.c +2 -0
@@ -526,6 +526,7 @@ static int mce_handle_err_realmode(int disposition, u8 error_type) disposition =RTAS_DISP_FULLY_RECOVERED ;break ;case MC_ERROR_TYPE_SLB : +#ifdef CONFIG_PPC_64S_HASH_MMU /* * Store the old slb content in paca before flushing. * Print this when we go to virtual mode.
@@ -538,6 +539,7 @@ static int mce_handle_err_realmode(int disposition, u8 error_type)slb_save_contents (local_paca->mce_faulty_slbs);flush_and_reload_slb (); disposition =RTAS_DISP_FULLY_RECOVERED ; +#endif break ;default :break ;
arch/powerpc/platforms/pseries/reconfig.c +2 -0
@@ -337,8 +337,10 @@ static int do_update_property(char *buf, size_t bufsize)if (!newprop)return -ENOMEM ; +#ifdef CONFIG_PPC_64S_HASH_MMU if (!strcmp (name,"slb-size" ) || !strcmp (name,"ibm,slb-size" ))slb_set_size (*(int *)value); +#endif return of_update_property (np, newprop); }
arch/powerpc/platforms/pseries/setup.c +4 -2
@@ -113,7 +113,7 @@ static void __init fwnmi_init(void)u8 *mce_data_buf;unsigned int i;int nr_cpus =num_possible_cpus (); -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU struct slb_entry *slb_ptr;size_t size;#endif
@@ -153,7 +153,7 @@ static void __init fwnmi_init(void) (RTAS_ERROR_LOG_MAX * i); } -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU if (!radix_enabled ()) {/* Allocate per cpu area to save old slb contents during MCE */ size =sizeof (struct slb_entry ) * mmu_slb_size * nr_cpus;
@@ -802,7 +802,9 @@ static void __init pSeries_setup_arch(void)fwnmi_init ();pseries_setup_security_mitigations (); +#ifdef CONFIG_PPC_64S_HASH_MMU pseries_lpar_read_hblkrm_characteristics (); +#endif /* By default, only probe PCI (can be overridden by rtas_pci) */ pci_add_flags (PCI_PROBE_ONLY );
arch/powerpc/xmon/xmon.c +6 -2
@@ -1160,9 +1160,11 @@ cmds(struct pt_regs *excp)show_tasks ();break ;#ifdef CONFIG_PPC_BOOK3S +#ifdef CONFIG_PPC_64S_HASH_MMU case 'u' :dump_segments ();break ; +#endif #elif defined(CONFIG_44x)case 'u' :dump_tlb_44x ();
@@ -2608,7 +2610,7 @@ static void dump_tracing(void)static void dump_one_paca (int cpu) {struct paca_struct *p; -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU int i =0 ;#endif
@@ -2650,6 +2652,7 @@ static void dump_one_paca(int cpu)DUMP (p, cpu_start,"%#-*x" );DUMP (p, kexec_state,"%#-*x" ); #ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU if (!early_radix_enabled()) { for (i = 0; i < SLB_NUM_BOLTED; i++) { u64 esid, vsid;
@@ -2677,6 +2680,7 @@ static void dump_one_paca(int cpu) 22, "slb_cache", i, p->slb_cache[i]); } } +#endif DUMP (p, rfi_flush_fallback_area,"%-*px" );#endif
@@ -3741,7 +3745,7 @@ static void xmon_print_symbol(unsigned long address, const char *mid,printf ("%s" , after); } -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU void dump_segments (void ) {int i;
drivers/misc/lkdtm/Makefile +1 -1
@@ -11,7 +11,7 @@ lkdtm-$(CONFIG_LKDTM) += usercopy.o lkdtm-$(CONFIG_LKDTM) += stackleak.o lkdtm-$(CONFIG_LKDTM) += cfi.o lkdtm-$(CONFIG_LKDTM) += fortify.o -lkdtm-$(CONFIG_PPC_BOOK3S_64) += powerpc.o +lkdtm-$(CONFIG_PPC_64S_HASH_MMU) += powerpc.o KASAN_SANITIZE_rodata.o := n KASAN_SANITIZE_stackleak.o := n
drivers/misc/lkdtm/core.c +1 -1
@@ -181,7 +181,7 @@ static const struct crashtype crashtypes[] = {CRASHTYPE (FORTIFIED_SUBOBJECT ),CRASHTYPE (FORTIFIED_STRSCPY ),CRASHTYPE (DOUBLE_FAULT ), -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_64S_HASH_MMU CRASHTYPE(PPC_SLB_MULTIHIT), #endif };
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 14/16 powerpc/64s: Make hash MMU support configurable
In reply to Nicholas PigginThisa adds Kconfig selection which allows the 64s hash MMU code to be compiled out if radix is selected and the minimum supported CPU type is POWER9 or higher, and KVM is not selected.
This saves 128kB kernel image size (90kB text) on powernv_defconfig minus KVM, 350kB on pseries_defconfig minus KVM, 40kB on a tiny config.
--- arch/powerpc/Kconfig | 1 + arch/powerpc/kvm/Kconfig | 1 + arch/powerpc/platforms/Kconfig.cputype | 21 ++++++++++++++++++--- arch/powerpc/platforms/cell/Kconfig | 1 + arch/powerpc/platforms/maple/Kconfig | 1 + arch/powerpc/platforms/microwatt/Kconfig | 2 +- arch/powerpc/platforms/pasemi/Kconfig | 1 + arch/powerpc/platforms/powermac/Kconfig | 1 + arch/powerpc/platforms/powernv/Kconfig | 2 +- 9 files changed, 26 insertions(+), 5 deletions(-)
arch/powerpc/Kconfig +1 -0
@@ -936,6 +936,7 @@ config PPC_MEM_KEYS prompt "PowerPC Memory Protection Keys" def_bool y depends on PPC_BOOK3S_64 + depends on PPC_64S_HASH_MMU select ARCH_USES_HIGH_VMA_FLAGS select ARCH_HAS_PKEYS help
arch/powerpc/kvm/Kconfig +1 -0
@@ -69,6 +69,7 @@ config KVM_BOOK3S_64 select KVM_BOOK3S_64_HANDLER select KVM select KVM_BOOK3S_PR_POSSIBLE if !KVM_BOOK3S_HV_POSSIBLE + select PPC_64S_HASH_MMU select SPAPR_TCE_IOMMU if IOMMU_SUPPORT && (PPC_PSERIES || PPC_POWERNV) help Support running unmodified book3s_64 and book3s_32 guest kernels
arch/powerpc/platforms/Kconfig.cputype +18 -3
@@ -105,10 +105,9 @@ config PPC_BOOK3S_64 select HAVE_MOVE_PMD select HAVE_MOVE_PUD select IRQ_WORK - select PPC_64S_HASH_MMU - select PPC_MM_SLICES select PPC_HAVE_KUEP select PPC_HAVE_KUAP + select PPC_64S_HASH_MMU if !PPC_RADIX_MMU config PPC_BOOK3E_64 bool "Embedded processors"
@@ -131,11 +130,13 @@ choice config GENERIC_CPU bool "Generic (POWER4 and above)" depends on PPC64 && !CPU_LITTLE_ENDIAN + select PPC_64S_HASH_MMU if PPC_BOOK3S_64 config GENERIC_CPU bool "Generic (POWER8 and above)" depends on PPC64 && CPU_LITTLE_ENDIAN select ARCH_HAS_FAST_MULTIPLIER + select PPC_64S_HASH_MMU config GENERIC_CPU bool "Generic 32 bits powerpc"
@@ -144,24 +145,29 @@ config GENERIC_CPU config CELL_CPU bool "Cell Broadband Engine" depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN + select PPC_64S_HASH_MMU config POWER5_CPU bool "POWER5" depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN + select PPC_64S_HASH_MMU config POWER6_CPU bool "POWER6" depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN + select PPC_64S_HASH_MMU config POWER7_CPU bool "POWER7" depends on PPC_BOOK3S_64 select ARCH_HAS_FAST_MULTIPLIER + select PPC_64S_HASH_MMU config POWER8_CPU bool "POWER8" depends on PPC_BOOK3S_64 select ARCH_HAS_FAST_MULTIPLIER + select PPC_64S_HASH_MMU config POWER9_CPU bool "POWER9"
@@ -366,7 +372,15 @@ config SPE If in doubt, say Y here. config PPC_64S_HASH_MMU - bool + bool "Hash MMU Support" + depends on PPC_BOOK3S_64 + select PPC_MM_SLICES + default y + help + Enable support for the Power ISA Hash style MMU. This is implemented + by all IBM Power and other Book3S CPUs. + + If you're unsure, say Y. config PPC_RADIX_MMU bool "Radix MMU Support"
@@ -381,6 +395,7 @@ config PPC_RADIX_MMU config PPC_RADIX_MMU_DEFAULT bool "Default to using the Radix MMU when possible" depends on PPC_RADIX_MMU + depends on PPC_64S_HASH_MMU default y help When the hardware supports the Radix MMU, default to using it unless
arch/powerpc/platforms/cell/Kconfig +1 -0
@@ -8,6 +8,7 @@ config PPC_CELL_COMMON select PPC_DCR_MMIO select PPC_INDIRECT_PIO select PPC_INDIRECT_MMIO + select PPC_64S_HASH_MMU select PPC_HASH_MMU_NATIVE select PPC_RTAS select IRQ_EDGE_EOI_HANDLER
arch/powerpc/platforms/maple/Kconfig +1 -0
@@ -9,6 +9,7 @@ config PPC_MAPLE select GENERIC_TBSYNC select PPC_UDBG_16550 select PPC_970_NAP + select PPC_64S_HASH_MMU select PPC_HASH_MMU_NATIVE select PPC_RTAS select MMIO_NVRAM
arch/powerpc/platforms/microwatt/Kconfig +1 -1
@@ -5,7 +5,7 @@ config PPC_MICROWATT select PPC_XICS select PPC_ICS_NATIVE select PPC_ICP_NATIVE - select PPC_HASH_MMU_NATIVE + select PPC_HASH_MMU_NATIVE if PPC_64S_HASH_MMU select PPC_UDBG_16550 select ARCH_RANDOM help
arch/powerpc/platforms/pasemi/Kconfig +1 -0
@@ -5,6 +5,7 @@ config PPC_PASEMI select MPIC select FORCE_PCI select PPC_UDBG_16550 + select PPC_64S_HASH_MMU select PPC_HASH_MMU_NATIVE select MPIC_BROKEN_REGREAD help
arch/powerpc/platforms/powermac/Kconfig +1 -0
@@ -6,6 +6,7 @@ config PPC_PMAC select FORCE_PCI select PPC_INDIRECT_PCI if PPC32 select PPC_MPC106 if PPC32 + select PPC_64S_HASH_MMU if PPC64 select PPC_HASH_MMU_NATIVE select ZONE_DMA if PPC32 default y
arch/powerpc/platforms/powernv/Kconfig +1 -1
@@ -2,7 +2,7 @@ config PPC_POWERNV depends on PPC64 && PPC_BOOK3S bool "IBM PowerNV (Non-Virtualized) platform support" - select PPC_HASH_MMU_NATIVE + select PPC_HASH_MMU_NATIVE if PPC_64S_HASH_MMU select PPC_XICS select PPC_ICP_NATIVE select PPC_XIVE_NATIVE
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 15/16 powerpc/configs/microwatt: add POWER9_CPU
In reply to Nicholas PigginMicrowatt implements a subset of ISA v3.0 (which is equivalent to the POWER9_CPU option).
--- arch/powerpc/configs/microwatt_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/configs/microwatt_defconfig +1 -0
@@ -15,6 +15,7 @@ CONFIG_EMBEDDED=y # CONFIG_COMPAT_BRK is not set # CONFIG_SLAB_MERGE_DEFAULT is not set CONFIG_PPC64=y +CONFIG_POWER9_CPU=y # CONFIG_PPC_KUEP is not set # CONFIG_PPC_KUAP is not set CONFIG_CPU_LITTLE_ENDIAN=y
Signature · 1 line
2.23.0
Nicholas Piggin
reviewerPATCH v2 16/16 powerpc/microwatt: Don't select the hash MMU code
In reply to Nicholas PigginMicrowatt is radix-only, so it does not require hash MMU support.
This saves 20kB compressed dtbImage and 56kB vmlinux size.
--- arch/powerpc/configs/microwatt_defconfig | 1 - arch/powerpc/platforms/microwatt/Kconfig | 1 - 2 files changed, 2 deletions(-)
arch/powerpc/configs/microwatt_defconfig +0 -1
@@ -27,7 +27,6 @@ CONFIG_PPC_MICROWATT=y # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set CONFIG_CPU_FREQ=y CONFIG_HZ_100=y -# CONFIG_PPC_MEM_KEYS is not set # CONFIG_SECCOMP is not set # CONFIG_MQ_IOSCHED_KYBER is not set # CONFIG_COREDUMP is not set
arch/powerpc/platforms/microwatt/Kconfig +0 -1
@@ -5,7 +5,6 @@ config PPC_MICROWATT select PPC_XICS select PPC_ICS_NATIVE select PPC_ICP_NATIVE - select PPC_HASH_MMU_NATIVE if PPC_64S_HASH_MMU select PPC_UDBG_16550 select ARCH_RANDOM help
Signature · 1 line
2.23.0
Re: [PATCH v2 11/16] powerpc/64: pcpu setup avoid reading mmu_linear_psize on 64e or radix
In reply to Nicholas PigginLe 21/10/2021 à 05:54, Nicholas Piggin a écrit :
Quoted 22 lines
Radix never sets
mmu_linear_psizeso it's always 4K, which causes pcpuatom_sizeto always bePAGE_SIZE. 64e sets it to 1GB always.Make paths for these platforms to be explicit about what value they set
atom_sizeto.Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/kernel/setup_64.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)arch/powerpc/kernel/setup_64.c +0
-3@@ -880,14 +880,23 @@ void __init setup_per_cpu_areas(void)int rc = -EINVAL ;/* -* Linear mapping is one of 4K, 1M and 16M. For 4K, no need -* to group units. For larger mappings, use 1M atom which -* should be large enough to contain a number of units.
arch/powerpc/kernel/setup_64.c void __init setup_per_cpu_areas(void) · line 889
Quoted 10 lines
arch/powerpc/kernel/setup_64.c +5
-3+* BookE and BookS radix are historical values and should be revisited. */ -if (mmu_linear_psize ==MMU_PAGE_4K ) - atom_size =PAGE_SIZE ; -else +if (IS_ENABLED (CONFIG_PPC_BOOK3E )) { atom_size =1 <<20 ; + }else if (radix_enabled ()) { + atom_size =PAGE_SIZE ; + }else {
You can keep a single level (and remove the brackets)
if (IS_ENABLED(CONFIG_PPC_BOOK3E)) atom_size = SZ_1M; else if (radix_enabled()) atom_size = PAGE_SIZE; else if (mmu_linear_psize == MMU_PAGE_4K) atom_size = PAGE_SIZE; else atom_size = SZ_1M;
arch/powerpc/kernel/setup_64.c void __init setup_per_cpu_areas(void) · line 898
Quoted 9 lines
arch/powerpc/kernel/setup_64.c +9
-0+/* +* Linear mapping is one of 4K, 1M and 16M. For 4K, no need +* to group units. For larger mappings, use 1M atom which +* should be large enough to contain a number of units. +*/ +if (mmu_linear_psize ==MMU_PAGE_4K ) + atom_size =PAGE_SIZE ; +else + atom_size =1 <<20 ;
Use SZ_1M instead of hardcoding.
Quoted 5 lines
arch/powerpc/kernel/setup_64.c +1
-0+ }if (pcpu_chosen_fc !=PCPU_FC_PAGE ) { rc = pcpu_embed_first_chunk(0, dyn_size, atom_size, pcpu_cpu_distance,
Re: [PATCH v2 12/16] powerpc/64e: remove mmu_linear_psize
In reply to Nicholas PigginLe 21/10/2021 à 05:54, Nicholas Piggin a écrit :
Quoted 18 lines
mmu_linear_psizeis only set at boot once on 64e, is not necessarily the correct size of the linear map pages, and is never used anywhere exceptmemremap_compat_align.Remove
mmu_linear_psizeand hard code the 1GB value instead inmemremap_compat_align.Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/mm/ioremap.c | 6 +++++- arch/powerpc/mm/nohash/tlb.c | 9 --------- 2 files changed, 5 insertions(+), 10 deletions(-)arch/powerpc/mm/ioremap.c +0
-0
arch/powerpc/mm/ioremap.c void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, · line 112
Quoted 4 lines
arch/powerpc/mm/ioremap.c +1
-0@@ -109,12 +109,16 @@ void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size,*/ unsigned long memremap_compat_align (void ) { +#ifdef CONFIG_PPC_BOOK3E_64
I don't think this function really belongs to ioremap.c
Could avoid the #ifdef by going in:
arch/powerpc/mm/nohash/book3e_pgtable.c
and
arch/powerpc/mm/book3s64/pgtable.c
arch/powerpc/mm/ioremap.c void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, · line 114
Quoted 2 lines
arch/powerpc/mm/ioremap.c +2
-0+// 1GB maximum possible size of the linear mapping. +return max (SUBSECTION_SIZE ,1UL <<30 );
Use SZ_1G
Quoted 39 lines
arch/powerpc/mm/ioremap.c +2
-1+#else unsigned int shift = mmu_psize_defs[mmu_linear_psize].shift;if (radix_enabled ())return SUBSECTION_SIZE ;return max (SUBSECTION_SIZE ,1UL << shift); - +#endif }EXPORT_SYMBOL_GPL (memremap_compat_align);#endif arch/powerpc/mm/nohash/tlb.c +0
-9@@ -150,7 +150,6 @@ static inline int mmu_get_tsize(int psize)*/ #ifdef CONFIG_PPC64 -int mmu_linear_psize;/* Page size used for the linear mapping */ int mmu_pte_psize;/* Page size used for PTE pages */ int mmu_vmemmap_psize;/* Page size used for the virtual mem map */ int book3e_htw_mode;/* HW tablewalk? Value is PPC_HTW_* */ @@ -655,14 +654,6 @@ static void early_init_this_mmu(void)static void __init early_init_mmu_global (void ) { -/* XXX This will have to be decided at runtime, but right -* now our boot and TLB miss code hard wires it. Ideally -* we should find out a suitable page size and patch the -* TLB miss code (either that or use the PACA to store -* the value we want) -*/ - mmu_linear_psize =MMU_PAGE_1G ; -/* XXX This should be decided at runtime based on supported * page sizes in the TLB, but for now let's assume 16M is * always there and a good fit (which it probably is)
Re: [PATCH v2 16/16] powerpc/microwatt: Don't select the hash MMU code
In reply to Nicholas PigginQuoted 16 lines · Nicholas Piggin
Microwatt is radix-only, so it does not require hash MMU support.
This saves 20kB compressed dtbImage and 56kB vmlinux size.
Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/configs/microwatt_defconfig | 1 - arch/powerpc/platforms/microwatt/Kconfig | 1 - 2 files changed, 2 deletions(-)arch/powerpc/configs/microwatt_defconfig +0
-0
arch/powerpc/configs/microwatt_defconfig CONFIG_PPC_MICROWATT=y · line 32
Quoted 7 lines
arch/powerpc/configs/microwatt_defconfig +0
-1@@ -27,7 +27,6 @@ CONFIG_PPC_MICROWATT=y # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set CONFIG_CPU_FREQ=y CONFIG_HZ_100=y -# CONFIG_PPC_MEM_KEYS is not set # CONFIG_SECCOMP is not set # CONFIG_MQ_IOSCHED_KYBER is not set # CONFIG_COREDUMP is not set
We still end up with CONFIG_PPC_64S_HASH_MMU=y in the config as it defaults to y.
We should disable in the defconfig it so your new changes are tested by that defconfig:
+# CONFIG_PPC_64S_HASH_MMU is not set
I boot tested your series on Microwatt with microwatt_defconfig (with and without that option set) and ppc64le_defconfig.
Cheers,
Joel
Quoted 15 lines
arch/powerpc/platforms/microwatt/Kconfig +0
-2@@ -5,7 +5,6 @@ config PPC_MICROWATT select PPC_XICS select PPC_ICS_NATIVE select PPC_ICP_NATIVE - select PPC_HASH_MMU_NATIVE if PPC_64S_HASH_MMU select PPC_UDBG_16550 select ARCH_RANDOM help --2.23.0
Re: [PATCH v2 13/16] powerpc/64s: Move hash MMU code under a new Kconfig name
In reply to Nicholas PigginLe 21/10/2021 à 05:54, Nicholas Piggin a écrit :
Quoted 37 lines
Introduce a new option
CONFIG_PPC_64S_HASH_MMU, and make 64s hash code depend on it.Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/book3s/64/mmu.h | 19 +++++++++-- .../include/asm/book3s/64/tlbflush-hash.h | 7 ++++ arch/powerpc/include/asm/book3s/pgtable.h | 4 +++ arch/powerpc/include/asm/mmu.h | 16 +++++++-- arch/powerpc/include/asm/mmu_context.h | 2 ++ arch/powerpc/include/asm/paca.h | 8 +++++ arch/powerpc/kernel/asm-offsets.c | 2 ++ arch/powerpc/kernel/dt_cpu_ftrs.c | 14 +++++--- arch/powerpc/kernel/entry_64.S | 4 +-- arch/powerpc/kernel/exceptions-64s.S | 16 +++++++++ arch/powerpc/kernel/mce.c | 2 +- arch/powerpc/kernel/mce_power.c | 10 ++++-- arch/powerpc/kernel/paca.c | 18 ++++------ arch/powerpc/kernel/process.c | 13 +++---- arch/powerpc/kernel/prom.c | 2 ++ arch/powerpc/kernel/setup_64.c | 5 +++ arch/powerpc/kexec/core_64.c | 4 +-- arch/powerpc/kexec/ranges.c | 4 +++ arch/powerpc/mm/book3s64/Makefile | 15 ++++---- arch/powerpc/mm/book3s64/hugetlbpage.c | 2 ++ arch/powerpc/mm/book3s64/mmu_context.c | 34 +++++++++++++++---- arch/powerpc/mm/book3s64/radix_pgtable.c | 4 +++ arch/powerpc/mm/copro_fault.c | 2 ++ arch/powerpc/mm/ioremap.c | 13 ++++--- arch/powerpc/mm/pgtable.c | 10 ++++-- arch/powerpc/mm/ptdump/Makefile | 2 +- arch/powerpc/platforms/Kconfig.cputype | 4 +++ arch/powerpc/platforms/powernv/idle.c | 2 ++ arch/powerpc/platforms/powernv/setup.c | 2 ++ arch/powerpc/platforms/pseries/lpar.c | 11 ++++-- arch/powerpc/platforms/pseries/lparcfg.c | 2 +-
Quoted 8 lines
arch/powerpc/platforms/pseries/mobility.c | 6 ++++ arch/powerpc/platforms/pseries/ras.c | 2 ++ arch/powerpc/platforms/pseries/reconfig.c | 2 ++ arch/powerpc/platforms/pseries/setup.c | 6 ++-- arch/powerpc/xmon/xmon.c | 8 +++-- drivers/misc/lkdtm/Makefile | 2 +- drivers/misc/lkdtm/core.c | 2 +- 39 files changed, 219 insertions(+), 64 deletions(-)
I'm still unconfortable with the quantity of files impacted in that commit.
Quoted 8 lines
arch/powerpc/include/asm/book3s/64/mmu.h +0
-0
arch/powerpc/include/asm/book3s/64/mmu.h static inline struct subpage_prot_table *mm_ctx_subpage_prot(mm_context_t *ctx) · line 203
Quoted 7 lines
arch/powerpc/include/asm/book3s/64/mmu.h +2
-1@@ -193,8 +198,15 @@ static inline struct subpage_prot_table *mm_ctx_subpage_prot(mm_context_t *ctx)extern int mmu_linear_psize;extern int mmu_virtual_psize;extern int mmu_vmalloc_psize; -extern int mmu_vmemmap_psize;extern int mmu_io_psize; +#else /* CONFIG_PPC_64S_HASH_MMU */ +#ifdef CONFIG_PPC_64K_PAGES
Avoid nested #ifdefs and do
#elif defined(CONFIG_PPC_64K_PAGES)
Quoted 40 lines
arch/powerpc/include/asm/book3s/64/mmu.h +10
-1+#define mmu_virtual_psize MMU_PAGE_64K +#else +#define mmu_virtual_psize MMU_PAGE_4K +#endif +#endif +extern int mmu_vmemmap_psize;/* MMU initialization */ void mmu_early_init_devtree (void );@@ -233,7 +245,8 @@ static inline void setup_initial_memory_limit(phys_addr_t first_memblock_base,* know which translations we will pick. Hence go with hash * restrictions. */ -return hash__setup_initial_memory_limit (first_memblock_base, +if (!radix_enabled ()) +return hash__setup_initial_memory_limit (first_memblock_base, first_memblock_size); }@@ -255,6 +268,7 @@ static inline void radix_init_pseries(void) { }void cleanup_cpu_mmu_context (void );#endif +#ifdef CONFIG_PPC_64S_HASH_MMU static inline int get_user_context (mm_context_t *ctx,unsigned long ea) {int index = ea >>MAX_EA_BITS_PER_CONTEXT ;@@ -274,6 +288,7 @@ static inline unsigned long get_user_vsid(mm_context_t *ctx,return get_vsid (context, ea, ssize); } +#endif #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_BOOK3S_64_MMU_H_ */ arch/powerpc/include/asm/book3s/64/tlbflush-hash.h +0
-0
arch/powerpc/include/asm/book3s/64/tlbflush-hash.h static inline void hash__flush_tlb_kernel_range(unsigned long start, · line 115
Quoted 4 lines
arch/powerpc/include/asm/book3s/64/tlbflush-hash.h +1
-0@@ -112,8 +112,15 @@ static inline void hash__flush_tlb_kernel_range(unsigned long start,struct mmu_gather ;extern void hash__tlb_flush (struct mmu_gather *tlb); +extern void flush_tlb_pmd_range(struct mm_struct *mm, pmd_t *pmd,
'extern' is superfluous.
Quoted 46 lines
arch/powerpc/include/asm/book3s/64/tlbflush-hash.h +6
-0+ unsigned long addr); + +#ifdef CONFIG_PPC_64S_HASH_MMU /* Private function for use by PCI IO mapping code */ extern void __flush_hash_table_range (unsigned long start,unsigned long end);extern void flush_tlb_pmd_range (struct mm_struct *mm,pmd_t *pmd,unsigned long addr); +#else +static inline void __flush_hash_table_range (unsigned long start,unsigned long end) { } +#endif #endif /* _ASM_POWERPC_BOOK3S_64_TLBFLUSH_HASH_H */ arch/powerpc/include/asm/mmu.h +5
-2@@ -157,7 +157,7 @@ DECLARE_PER_CPU(int, next_tlbcam_idx);enum { MMU_FTRS_POSSIBLE = -#if defined(CONFIG_PPC_BOOK3S_64) || defined(CONFIG_PPC_BOOK3S_604) +#if defined(CONFIG_PPC_BOOK3S_604) MMU_FTR_HPTE_TABLE | #endif#ifdef CONFIG_PPC_8xx@@ -184,15 +184,18 @@ enum { MMU_FTR_USE_TLBRSRV | MMU_FTR_USE_PAIRED_MAS |#endif #ifdef CONFIG_PPC_BOOK3S_64 + MMU_FTR_KERNEL_RO | +#ifdef CONFIG_PPC_64S_HASH_MMU MMU_FTR_NO_SLBIE_B | MMU_FTR_16M_PAGE | MMU_FTR_TLBIEL | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_CI_LARGE_PAGE | MMU_FTR_1T_SEGMENT | MMU_FTR_TLBIE_CROP_VA | - MMU_FTR_KERNEL_RO | MMU_FTR_68_BIT_VA | + MMU_FTR_68_BIT_VA | MMU_FTR_HPTE_TABLE |#endif #ifdef CONFIG_PPC_RADIX_MMU MMU_FTR_TYPE_RADIX | MMU_FTR_GTSE |#endif /* CONFIG_PPC_RADIX_MMU */ +#endif #ifdef CONFIG_PPC_KUAP MMU_FTR_BOOK3S_KUAP |#endif /* CONFIG_PPC_KUAP */
arch/powerpc/include/asm/mmu.h enum { · line 229
Quoted 4 lines
arch/powerpc/include/asm/mmu.h +1
-0@@ -223,6 +226,13 @@ enum {#ifdef CONFIG_E500 #define MMU_FTRS_ALWAYS MMU_FTR_TYPE_FSL_E#endif +#ifdef CONFIG_PPC_BOOK3S_64
No need of this CONFIG_PPC_BOOK3S_64 ifdef, it is necessarily defined if either CONFIG_PPC_RADIX_MMU or CONFIG_PPC_64S_HASH_MMU is defined
Quoted 17 lines
arch/powerpc/include/asm/mmu.h +6
-0+#if defined(CONFIG_PPC_RADIX_MMU ) && !defined(CONFIG_PPC_64S_HASH_MMU ) +#define MMU_FTRS_ALWAYS MMU_FTR_TYPE_RADIX +#elif !defined(CONFIG_PPC_RADIX_MMU ) && defined(CONFIG_PPC_64S_HASH_MMU ) +#define MMU_FTRS_ALWAYS MMU_FTR_HPTE_TABLE +#endif +#endif #ifndef MMU_FTRS_ALWAYS #define MMU_FTRS_ALWAYS 0arch/powerpc/kernel/exceptions-64s.S +0
-0@@ -1369,11 +1369,15 @@ EXC_COMMON_BEGIN(data_access_common) addi r3,r1,STACK_FRAME_OVERHEAD andis. r0,r4,DSISR_DABRMATCH@h
arch/powerpc/kernel/exceptions-64s.S EXC_COMMON_BEGIN(data_access_common) · line 1380
Quoted 10 lines
arch/powerpc/kernel/exceptions-64s.S +4
-0bne- 1f +#ifdef CONFIG_PPC_64S_HASH_MMU BEGIN_MMU_FTR_SECTION bl do_hash_fault MMU_FTR_SECTION_ELSE bl do_page_fault ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) +#else + bl do_page_fault +#endif
Maybe we could always branch to do_page_fault() and get redirected to do_hash_fault() from do_page_fault() if BOOK3S64 && !radix_enabled() ?
Another solution is to make it a GAS macro ?
Quoted 24 lines
arch/powerpc/kernel/exceptions-64s.S +4
-0b interrupt_return_srr 1: bl do_break@@ -1416,6 +1420,7 @@ EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x80) EXC_VIRT_END(data_access_slb, 0x4380, 0x80) EXC_COMMON_BEGIN(data_access_slb_common) GEN_COMMON data_access_slb +#ifdef CONFIG_PPC_64S_HASH_MMU BEGIN_MMU_FTR_SECTION /* HPT case, do SLB fault */ addi r3,r1,STACK_FRAME_OVERHEAD@@ -1428,6 +1433,9 @@ MMU_FTR_SECTION_ELSE /* Radix case, access is outside page table range */ li r3,-EFAULT ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) +#else + li r3,-EFAULT +#endif std r3,RESULT(r1) addi r3,r1,STACK_FRAME_OVERHEAD bl do_bad_segment_interrupt@@ -1462,11 +1470,15 @@ EXC_VIRT_END(instruction_access, 0x4400, 0x80) EXC_COMMON_BEGIN(instruction_access_common) GEN_COMMON instruction_access
arch/powerpc/kernel/exceptions-64s.S EXC_VIRT_END(instruction_access, 0x4400, 0x80) · line 1481
Quoted 10 lines
arch/powerpc/kernel/exceptions-64s.S +4
-0addi r3,r1,STACK_FRAME_OVERHEAD +#ifdef CONFIG_PPC_64S_HASH_MMU BEGIN_MMU_FTR_SECTION bl do_hash_fault MMU_FTR_SECTION_ELSE bl do_page_fault ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) +#else + bl do_page_fault +#endif
Same as above.
arch/powerpc/kernel/setup_64.c void __init setup_per_cpu_areas(void) · line 890
Quoted 13 lines
arch/powerpc/kernel/exceptions-64s.S +0
-0b interrupt_return_srrarch/powerpc/kernel/setup_64.c +1
-0@@ -887,6 +887,8 @@ void __init setup_per_cpu_areas(void) }else if (radix_enabled ()) { atom_size =PAGE_SIZE ; }else { +#ifdef CONFIG_PPC_64S_HASH_MMU
Use IS_ENABLED()
Quoted 40 lines
arch/powerpc/kernel/setup_64.c +4
-0+/* * Linear mapping is one of 4K, 1M and 16M. For 4K, no need * to group units. For larger mappings, use 1M atom which @@ -896,6 +898,9 @@ void __init setup_per_cpu_areas(void) atom_size =PAGE_SIZE ; else atom_size =1 <<20 ; +#else +BUILD_BUG ();// radix_enabled() should be constant true +#endif }if (pcpu_chosen_fc !=PCPU_FC_PAGE ) {arch/powerpc/mm/pgtable.c +3
-3@@ -81,9 +81,6 @@ static struct page *maybe_pte_to_page(pte_t pte)static pte_t set_pte_filter_hash (pte_t pte) { -if (radix_enabled ()) -return pte; - pte =__pte (pte_val (pte) & ~_PAGE_HPTEFLAGS);if (pte_looks_normal (pte) && !(cpu_has_feature (CPU_FTR_COHERENT_ICACHE ) ||cpu_has_feature (CPU_FTR_NOEXECUTE ))) {@@ -112,6 +109,9 @@ static inline pte_t set_pte_filter(pte_t pte) {struct page *pg; +if (radix_enabled ()) +return pte; +if (mmu_has_feature (MMU_FTR_HPTE_TABLE ))return set_pte_filter_hash (pte);
arch/powerpc/mm/pgtable.c static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma, · line 149
Quoted 6 lines
arch/powerpc/mm/pgtable.c +3
-0@@ -144,6 +144,10 @@ static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma, {struct page *pg; +#ifdef CONFIG_PPC_BOOK3S_64 +return pte; +#endif
Aren't you changing the behaviour here for RADIX ?
Anyway, can use IS_ENABLED()
Quoted 20 lines
arch/powerpc/mm/pgtable.c +1
-0+if (mmu_has_feature (MMU_FTR_HPTE_TABLE ))return pte;arch/powerpc/mm/ptdump/Makefile +1
-1@@ -10,5 +10,5 @@ obj-$(CONFIG_PPC_BOOK3S_64) += book3s64.o ifdef CONFIG_PTDUMP_DEBUGFS obj-$(CONFIG_PPC_BOOK3S_32) += bats.o segment_regs.o -obj-$(CONFIG_PPC_BOOK3S_64) += hashpagetable.o +obj-$(CONFIG_PPC_64S_HASH_MMU) += hashpagetable.o endifarch/powerpc/platforms/Kconfig.cputype +0
-0
arch/powerpc/platforms/Kconfig.cputype config PPC_BOOK3S_64 · line 108
Quoted 4 lines
arch/powerpc/platforms/Kconfig.cputype +1
-0@@ -105,6 +105,7 @@ config PPC_BOOK3S_64 select HAVE_MOVE_PMD select HAVE_MOVE_PUD select IRQ_WORK + select PPC_64S_HASH_MMU
Not needed
arch/powerpc/platforms/Kconfig.cputype config SPE · line 369
Quoted 9 lines
arch/powerpc/platforms/Kconfig.cputype +2
-0select PPC_MM_SLICES select PPC_HAVE_KUEP select PPC_HAVE_KUAP@@ -364,6 +365,9 @@ config SPE If in doubt, say Y here. +config PPC_64S_HASH_MMU + bool
Add
depends on PPC_BOOK3S_64
default y
Quoted 10 lines
arch/powerpc/platforms/Kconfig.cputype +1
-0+ config PPC_RADIX_MMU bool "Radix MMU Support" depends on PPC_BOOK3S_64arch/powerpc/xmon/xmon.c +0
-0
arch/powerpc/xmon/xmon.c cmds(struct pt_regs *excp) · line 1163
Quoted 4 lines
arch/powerpc/xmon/xmon.c +1
-0@@ -1160,9 +1160,11 @@ cmds(struct pt_regs *excp)show_tasks ();break ;#ifdef CONFIG_PPC_BOOK3S +#ifdef CONFIG_PPC_64S_HASH_MMU
And BOOK3S/32 ???
Quoted 7 lines
arch/powerpc/xmon/xmon.c +1
-0case 'u' :dump_segments ();break ; +#endif #elif defined(CONFIG_44x)case 'u' :dump_tlb_44x ();
Re: [PATCH v2 14/16] powerpc/64s: Make hash MMU support configurable
In reply to Nicholas PigginLe 21/10/2021 à 05:54, Nicholas Piggin a écrit :
Quoted 105 lines
Thisa adds
Kconfigselection which allows the 64s hash MMU code to be compiled out if radix is selected and the minimum supported CPU type is POWER9 or higher, and KVM is not selected.This saves 128kB kernel image size (90kB text) on
powernv_defconfigminus KVM, 350kB onpseries_defconfigminus KVM, 40kB on a tiny config.Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/Kconfig | 1 + arch/powerpc/kvm/Kconfig | 1 + arch/powerpc/platforms/Kconfig.cputype | 21 ++++++++++++++++++--- arch/powerpc/platforms/cell/Kconfig | 1 + arch/powerpc/platforms/maple/Kconfig | 1 + arch/powerpc/platforms/microwatt/Kconfig | 2 +- arch/powerpc/platforms/pasemi/Kconfig | 1 + arch/powerpc/platforms/powermac/Kconfig | 1 + arch/powerpc/platforms/powernv/Kconfig | 2 +- 9 files changed, 26 insertions(+), 5 deletions(-)arch/powerpc/Kconfig +1
-0@@ -936,6 +936,7 @@ config PPC_MEM_KEYS prompt "PowerPC Memory Protection Keys" def_bool y depends on PPC_BOOK3S_64 + depends on PPC_64S_HASH_MMU select ARCH_USES_HIGH_VMA_FLAGS select ARCH_HAS_PKEYS helparch/powerpc/kvm/Kconfig +1
-0@@ -69,6 +69,7 @@ config KVM_BOOK3S_64 select KVM_BOOK3S_64_HANDLER select KVM select KVM_BOOK3S_PR_POSSIBLE if !KVM_BOOK3S_HV_POSSIBLE + select PPC_64S_HASH_MMU select SPAPR_TCE_IOMMU if IOMMU_SUPPORT && (PPC_PSERIES || PPC_POWERNV) help Support running unmodified book3s_64 and book3s_32 guest kernelsarch/powerpc/platforms/Kconfig.cputype +8
-2@@ -105,10 +105,9 @@ config PPC_BOOK3S_64 select HAVE_MOVE_PMD select HAVE_MOVE_PUD select IRQ_WORK - select PPC_64S_HASH_MMU - select PPC_MM_SLICES select PPC_HAVE_KUEP select PPC_HAVE_KUAP + select PPC_64S_HASH_MMU if !PPC_RADIX_MMU config PPC_BOOK3E_64 bool "Embedded processors"@@ -131,11 +130,13 @@ choice config GENERIC_CPU bool "Generic (POWER4 and above)" depends on PPC64 && !CPU_LITTLE_ENDIAN + select PPC_64S_HASH_MMU if PPC_BOOK3S_64 config GENERIC_CPU bool "Generic (POWER8 and above)" depends on PPC64 && CPU_LITTLE_ENDIAN select ARCH_HAS_FAST_MULTIPLIER + select PPC_64S_HASH_MMU config GENERIC_CPU bool "Generic 32 bits powerpc"@@ -144,24 +145,29 @@ config GENERIC_CPU config CELL_CPU bool "Cell Broadband Engine" depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN + select PPC_64S_HASH_MMU config POWER5_CPU bool "POWER5" depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN + select PPC_64S_HASH_MMU config POWER6_CPU bool "POWER6" depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN + select PPC_64S_HASH_MMU config POWER7_CPU bool "POWER7" depends on PPC_BOOK3S_64 select ARCH_HAS_FAST_MULTIPLIER + select PPC_64S_HASH_MMU config POWER8_CPU bool "POWER8" depends on PPC_BOOK3S_64 select ARCH_HAS_FAST_MULTIPLIER + select PPC_64S_HASH_MMU config POWER9_CPU bool "POWER9"
arch/powerpc/platforms/Kconfig.cputype config SPE · line 376
Quoted 6 lines
arch/powerpc/platforms/Kconfig.cputype +2
-1@@ -366,7 +372,15 @@ config SPE If in doubt, say Y here. config PPC_64S_HASH_MMU - bool + bool "Hash MMU Support" + depends on PPC_BOOK3S_64
Should already be in previous patch
arch/powerpc/platforms/Kconfig.cputype config SPE · line 378
Quoted 2 lines
arch/powerpc/platforms/Kconfig.cputype +2
-0+ select PPC_MM_SLICES + default y
Should already be in previous patch
Quoted 91 lines
arch/powerpc/platforms/Kconfig.cputype +6
-0+ help + Enable support for the Power ISA Hash style MMU. This is implemented + by all IBM Power and other Book3S CPUs. + + If you're unsure, say Y. config PPC_RADIX_MMU bool "Radix MMU Support"@@ -381,6 +395,7 @@ config PPC_RADIX_MMU config PPC_RADIX_MMU_DEFAULT bool "Default to using the Radix MMU when possible" depends on PPC_RADIX_MMU + depends on PPC_64S_HASH_MMU default y help When the hardware supports the Radix MMU, default to using it unlessarch/powerpc/platforms/cell/Kconfig +1
-0@@ -8,6 +8,7 @@ config PPC_CELL_COMMON select PPC_DCR_MMIO select PPC_INDIRECT_PIO select PPC_INDIRECT_MMIO + select PPC_64S_HASH_MMU select PPC_HASH_MMU_NATIVE select PPC_RTAS select IRQ_EDGE_EOI_HANDLERarch/powerpc/platforms/maple/Kconfig +1
-0@@ -9,6 +9,7 @@ config PPC_MAPLE select GENERIC_TBSYNC select PPC_UDBG_16550 select PPC_970_NAP + select PPC_64S_HASH_MMU select PPC_HASH_MMU_NATIVE select PPC_RTAS select MMIO_NVRAMarch/powerpc/platforms/microwatt/Kconfig +1
-1@@ -5,7 +5,7 @@ config PPC_MICROWATT select PPC_XICS select PPC_ICS_NATIVE select PPC_ICP_NATIVE - select PPC_HASH_MMU_NATIVE + select PPC_HASH_MMU_NATIVE if PPC_64S_HASH_MMU select PPC_UDBG_16550 select ARCH_RANDOM helparch/powerpc/platforms/pasemi/Kconfig +1
-0@@ -5,6 +5,7 @@ config PPC_PASEMI select MPIC select FORCE_PCI select PPC_UDBG_16550 + select PPC_64S_HASH_MMU select PPC_HASH_MMU_NATIVE select MPIC_BROKEN_REGREAD helparch/powerpc/platforms/powermac/Kconfig +1
-0@@ -6,6 +6,7 @@ config PPC_PMAC select FORCE_PCI select PPC_INDIRECT_PCI if PPC32 select PPC_MPC106 if PPC32 + select PPC_64S_HASH_MMU if PPC64 select PPC_HASH_MMU_NATIVE select ZONE_DMA if PPC32 default yarch/powerpc/platforms/powernv/Kconfig +1
-1@@ -2,7 +2,7 @@ config PPC_POWERNV depends on PPC64 && PPC_BOOK3S bool "IBM PowerNV (Non-Virtualized) platform support" - select PPC_HASH_MMU_NATIVE + select PPC_HASH_MMU_NATIVE if PPC_64S_HASH_MMU select PPC_XICS select PPC_ICP_NATIVE select PPC_XIVE_NATIVE
Re: [PATCH v2 16/16] powerpc/microwatt: Don't select the hash MMU code
In reply to Nicholas PigginLe 21/10/2021 à 05:54, Nicholas Piggin a écrit :
Quoted 1 line
Microwatt is radix-only, so it does not require hash MMU support.
Patches 15 and 16 could be squashed into a single patch, say Microwatt is a radix-only POWER9.
Quoted 34 lines
This saves 20kB compressed dtbImage and 56kB vmlinux size.
Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/configs/microwatt_defconfig | 1 - arch/powerpc/platforms/microwatt/Kconfig | 1 - 2 files changed, 2 deletions(-)arch/powerpc/configs/microwatt_defconfig +0
-1@@ -27,7 +27,6 @@ CONFIG_PPC_MICROWATT=y # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set CONFIG_CPU_FREQ=y CONFIG_HZ_100=y -# CONFIG_PPC_MEM_KEYS is not set # CONFIG_SECCOMP is not set # CONFIG_MQ_IOSCHED_KYBER is not set # CONFIG_COREDUMP is not setarch/powerpc/platforms/microwatt/Kconfig +0
-1@@ -5,7 +5,6 @@ config PPC_MICROWATT select PPC_XICS select PPC_ICS_NATIVE select PPC_ICP_NATIVE - select PPC_HASH_MMU_NATIVE if PPC_64S_HASH_MMU select PPC_UDBG_16550 select ARCH_RANDOM help
Nicholas Piggin
reviewerRe: [PATCH v2 11/16] powerpc/64: pcpu setup avoid reading mmu_linear_psize on 64e or radix
In reply to Christophe LeroyExcerpts from Christophe Leroy's message of October 21, 2021 2:52 pm:
Quoted 38 lines
Le 21/10/2021 à 05:54, Nicholas Piggin a écrit :
Quoted 22 lines
Radix never sets
mmu_linear_psizeso it's always 4K, which causes pcpuatom_sizeto always bePAGE_SIZE. 64e sets it to 1GB always.Make paths for these platforms to be explicit about what value they set
atom_sizeto.Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/kernel/setup_64.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)arch/powerpc/kernel/setup_64.c +0
-3@@ -880,14 +880,23 @@ void __init setup_per_cpu_areas(void)int rc = -EINVAL ;/* -* Linear mapping is one of 4K, 1M and 16M. For 4K, no need -* to group units. For larger mappings, use 1M atom which -* should be large enough to contain a number of units. arch/powerpc/kernel/setup_64.c void __init setup_per_cpu_areas(void) · line 889
Quoted 10 lines
arch/powerpc/kernel/setup_64.c +5
-3+* BookE and BookS radix are historical values and should be revisited. */ -if (mmu_linear_psize ==MMU_PAGE_4K ) - atom_size =PAGE_SIZE ; -else +if (IS_ENABLED (CONFIG_PPC_BOOK3E )) { atom_size =1 <<20 ; + }else if (radix_enabled ()) { + atom_size =PAGE_SIZE ; + }else {You can keep a single level (and remove the brackets)
Quoted 8 lines
if (IS_ENABLED(CONFIG_PPC_BOOK3E)) atom_size = SZ_1M; else if (radix_enabled()) atom_size = PAGE_SIZE; else if (mmu_linear_psize == MMU_PAGE_4K) atom_size = PAGE_SIZE; else atom_size = SZ_1M;
I could but the below comment and logic applies to BookS hash so I'm happier to put it in its own block. Radix later might also inherit a comment and size from x86-64.
Quoted 11 lines
arch/powerpc/kernel/setup_64.c void __init setup_per_cpu_areas(void) · line 898
Quoted 9 lines
arch/powerpc/kernel/setup_64.c +9
-0+/* +* Linear mapping is one of 4K, 1M and 16M. For 4K, no need +* to group units. For larger mappings, use 1M atom which +* should be large enough to contain a number of units. +*/ +if (mmu_linear_psize ==MMU_PAGE_4K ) + atom_size =PAGE_SIZE ; +else + atom_size =1 <<20 ;Use
SZ_1Minstead of hardcoding.
Sure.
Thanks,
Nick
Nicholas Piggin
reviewerRe: [PATCH v2 12/16] powerpc/64e: remove mmu_linear_psize
In reply to Christophe LeroyExcerpts from Christophe Leroy's message of October 21, 2021 3:03 pm:
Quoted 28 lines
Le 21/10/2021 à 05:54, Nicholas Piggin a écrit :
Quoted 18 lines
mmu_linear_psizeis only set at boot once on 64e, is not necessarily the correct size of the linear map pages, and is never used anywhere exceptmemremap_compat_align.Remove
mmu_linear_psizeand hard code the 1GB value instead inmemremap_compat_align.Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/mm/ioremap.c | 6 +++++- arch/powerpc/mm/nohash/tlb.c | 9 --------- 2 files changed, 5 insertions(+), 10 deletions(-)arch/powerpc/mm/ioremap.c +0
-0arch/powerpc/mm/ioremap.c void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, · line 112
Quoted 4 lines
arch/powerpc/mm/ioremap.c +1
-0@@ -109,12 +109,16 @@ void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size,*/ unsigned long memremap_compat_align (void ) { +#ifdef CONFIG_PPC_BOOK3E_64 I don't think this function really belongs to
ioremap.c
Quoted 7 lines
Could avoid the #ifdef by going in:
arch/powerpc/mm/nohash/book3e_pgtable.cand
arch/powerpc/mm/book3s64/pgtable.c
Yeah that might work.
Thanks,
Nick
Nicholas Piggin
reviewerRe: [PATCH v2 13/16] powerpc/64s: Move hash MMU code under a new Kconfig name
In reply to Christophe LeroyExcerpts from Christophe Leroy's message of October 21, 2021 3:43 pm:
Quoted 49 lines
Le 21/10/2021 à 05:54, Nicholas Piggin a écrit :
Quoted 37 lines
Introduce a new option
CONFIG_PPC_64S_HASH_MMU, and make 64s hash code depend on it.Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/book3s/64/mmu.h | 19 +++++++++-- .../include/asm/book3s/64/tlbflush-hash.h | 7 ++++ arch/powerpc/include/asm/book3s/pgtable.h | 4 +++ arch/powerpc/include/asm/mmu.h | 16 +++++++-- arch/powerpc/include/asm/mmu_context.h | 2 ++ arch/powerpc/include/asm/paca.h | 8 +++++ arch/powerpc/kernel/asm-offsets.c | 2 ++ arch/powerpc/kernel/dt_cpu_ftrs.c | 14 +++++--- arch/powerpc/kernel/entry_64.S | 4 +-- arch/powerpc/kernel/exceptions-64s.S | 16 +++++++++ arch/powerpc/kernel/mce.c | 2 +- arch/powerpc/kernel/mce_power.c | 10 ++++-- arch/powerpc/kernel/paca.c | 18 ++++------ arch/powerpc/kernel/process.c | 13 +++---- arch/powerpc/kernel/prom.c | 2 ++ arch/powerpc/kernel/setup_64.c | 5 +++ arch/powerpc/kexec/core_64.c | 4 +-- arch/powerpc/kexec/ranges.c | 4 +++ arch/powerpc/mm/book3s64/Makefile | 15 ++++---- arch/powerpc/mm/book3s64/hugetlbpage.c | 2 ++ arch/powerpc/mm/book3s64/mmu_context.c | 34 +++++++++++++++---- arch/powerpc/mm/book3s64/radix_pgtable.c | 4 +++ arch/powerpc/mm/copro_fault.c | 2 ++ arch/powerpc/mm/ioremap.c | 13 ++++--- arch/powerpc/mm/pgtable.c | 10 ++++-- arch/powerpc/mm/ptdump/Makefile | 2 +- arch/powerpc/platforms/Kconfig.cputype | 4 +++ arch/powerpc/platforms/powernv/idle.c | 2 ++ arch/powerpc/platforms/powernv/setup.c | 2 ++ arch/powerpc/platforms/pseries/lpar.c | 11 ++++-- arch/powerpc/platforms/pseries/lparcfg.c | 2 +-Quoted 8 lines
arch/powerpc/platforms/pseries/mobility.c | 6 ++++ arch/powerpc/platforms/pseries/ras.c | 2 ++ arch/powerpc/platforms/pseries/reconfig.c | 2 ++ arch/powerpc/platforms/pseries/setup.c | 6 ++-- arch/powerpc/xmon/xmon.c | 8 +++-- drivers/misc/lkdtm/Makefile | 2 +- drivers/misc/lkdtm/core.c | 2 +- 39 files changed, 219 insertions(+), 64 deletions(-)
Quoted 1 line
I'm still unconfortable with the quantity of files impacted in that commit.
Hmm. Splitting it into N partial patches that have the same result doesn't seem better to me. There's a few other little things that are be better split out, but size of the patch will not shrink much.
Quoted 16 lines
arch/powerpc/include/asm/book3s/64/mmu.h static inline struct subpage_prot_table *mm_ctx_subpage_prot(mm_context_t *ctx) · line 203
Quoted 13 lines
arch/powerpc/include/asm/book3s/64/mmu.h +2
-1@@ -193,8 +198,15 @@ static inline struct subpage_prot_table *mm_ctx_subpage_prot(mm_context_t *ctx)extern int mmu_linear_psize;extern int mmu_virtual_psize;extern int mmu_vmalloc_psize; -extern int mmu_vmemmap_psize;extern int mmu_io_psize; +#else /* CONFIG_PPC_64S_HASH_MMU */ +#ifdef CONFIG_PPC_64K_PAGES Avoid nested #ifdefs and do
Quoted 1 line
#elif
defined(CONFIG_PPC_64K_PAGES)
I sort of like the nesting because this is the !HASH block. But I don't care much so I can do it your way if you prefer.
Quoted 8 lines
arch/powerpc/include/asm/book3s/64/mmu.h enum { · line 229
Quoted 5 lines
arch/powerpc/include/asm/book3s/64/mmu.h +1
-0@@ -223,6 +226,13 @@ enum {#ifdef CONFIG_E500 #define MMU_FTRS_ALWAYS MMU_FTR_TYPE_FSL_E#endif +#ifdef CONFIG_PPC_BOOK3S_64 No need of this
CONFIG_PPC_BOOK3S_64ifdef, it is necessarily defined if eitherCONFIG_PPC_RADIX_MMUorCONFIG_PPC_64S_HASH_MMUis defined
Good point.
Quoted 22 lines
Quoted 22 lines
arch/powerpc/include/asm/book3s/64/mmu.h +6
-0+#if defined(CONFIG_PPC_RADIX_MMU ) && !defined(CONFIG_PPC_64S_HASH_MMU ) +#define MMU_FTRS_ALWAYS MMU_FTR_TYPE_RADIX +#elif !defined(CONFIG_PPC_RADIX_MMU ) && defined(CONFIG_PPC_64S_HASH_MMU ) +#define MMU_FTRS_ALWAYS MMU_FTR_HPTE_TABLE +#endif +#endif #ifndef MMU_FTRS_ALWAYS #define MMU_FTRS_ALWAYS 0arch/powerpc/kernel/exceptions-64s.S +1
-0@@ -1369,11 +1369,15 @@ EXC_COMMON_BEGIN(data_access_common) addi r3,r1,STACK_FRAME_OVERHEAD andis. r0,r4,DSISR_DABRMATCH@h bne- 1f +#ifdef CONFIG_PPC_64S_HASH_MMU BEGIN_MMU_FTR_SECTION bl do_hash_fault MMU_FTR_SECTION_ELSE
Quoted 8 lines
arch/powerpc/kernel/exceptions-64s.S EXC_COMMON_BEGIN(data_access_common) · line 1380
Quoted 5 lines
arch/powerpc/kernel/exceptions-64s.S +3
-0bl do_page_fault ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) +#else + bl do_page_fault +#endifMaybe we could always branch to
do_page_fault()and get redirected todo_hash_fault()fromdo_page_fault()if BOOK3S64 && !radix_enabled() ?
Not trivial because of do_hash_fault().
A book3s_64_do_page_fault() raw hander which calls do_hash_fault or do_page_fault if necessary, but that's less optimal and we already have this gunk so might as well keep it.
Quoted 2 lines
Another solution is to make it a GAS macro ?
For this I don't find it too bad. Another macro means another thing to look up. Maybe if we had more callers but for now this isn't too terrible.
Quoted 11 lines
arch/powerpc/kernel/setup_64.c void __init setup_per_cpu_areas(void) · line 890
Quoted 9 lines
arch/powerpc/kernel/setup_64.c +1
-0@@ -887,6 +887,8 @@ void __init setup_per_cpu_areas(void) }else if (radix_enabled ()) { atom_size =PAGE_SIZE ; }else { +#ifdef CONFIG_PPC_64S_HASH_MMU Use
IS_ENABLED()
Can't because of mmu_linear_psize.
Quoted 28 lines
Quoted 28 lines
arch/powerpc/mm/pgtable.c +3
-3@@ -81,9 +81,6 @@ static struct page *maybe_pte_to_page(pte_t pte)static pte_t set_pte_filter_hash (pte_t pte) { -if (radix_enabled ()) -return pte; - pte =__pte (pte_val (pte) & ~_PAGE_HPTEFLAGS);if (pte_looks_normal (pte) && !(cpu_has_feature (CPU_FTR_COHERENT_ICACHE ) ||cpu_has_feature (CPU_FTR_NOEXECUTE ))) {@@ -112,6 +109,9 @@ static inline pte_t set_pte_filter(pte_t pte) {struct page *pg; +if (radix_enabled ()) +return pte; +if (mmu_has_feature (MMU_FTR_HPTE_TABLE ))return set_pte_filter_hash (pte);@@ -144,6 +144,10 @@ static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma, {struct page *pg;
Quoted 5 lines
arch/powerpc/mm/pgtable.c static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma, · line 149
Quoted 3 lines
arch/powerpc/mm/pgtable.c +3
-0+#ifdef CONFIG_PPC_BOOK3S_64 +return pte; +#endif Aren't you changing the behaviour here for RADIX ?
No, 64s always has MMU_FTR_HPTE_TABLE until now. I should actually split this change out.
Quoted 1 line
Anyway, can use
IS_ENABLED()
Good point.
Quoted 47 lines
Quoted 21 lines
arch/powerpc/mm/pgtable.c +1
-0+if (mmu_has_feature (MMU_FTR_HPTE_TABLE ))return pte;arch/powerpc/mm/ptdump/Makefile +1
-1@@ -10,5 +10,5 @@ obj-$(CONFIG_PPC_BOOK3S_64) += book3s64.o ifdef CONFIG_PTDUMP_DEBUGFS obj-$(CONFIG_PPC_BOOK3S_32) += bats.o segment_regs.o -obj-$(CONFIG_PPC_BOOK3S_64) += hashpagetable.o +obj-$(CONFIG_PPC_64S_HASH_MMU) += hashpagetable.o endifarch/powerpc/platforms/Kconfig.cputype +0
-0arch/powerpc/platforms/Kconfig.cputype config PPC_BOOK3S_64 · line 108
Quoted 4 lines
arch/powerpc/platforms/Kconfig.cputype +1
-0@@ -105,6 +105,7 @@ config PPC_BOOK3S_64 select HAVE_MOVE_PMD select HAVE_MOVE_PUD select IRQ_WORK + select PPC_64S_HASH_MMUNot needed
arch/powerpc/platforms/Kconfig.cputype config SPE · line 369
Quoted 9 lines
arch/powerpc/platforms/Kconfig.cputype +2
-0select PPC_MM_SLICES select PPC_HAVE_KUEP select PPC_HAVE_KUAP@@ -364,6 +365,9 @@ config SPE If in doubt, say Y here. +config PPC_64S_HASH_MMU + boolAdd
depends onPPC_BOOK3S_64
default yQuoted 4 lines
arch/powerpc/platforms/Kconfig.cputype +1
-0+ config PPC_RADIX_MMU bool "Radix MMU Support" depends on PPC_BOOK3S_64
Quoted 11 lines
arch/powerpc/xmon/xmon.c cmds(struct pt_regs *excp) · line 1163
Quoted 9 lines
arch/powerpc/xmon/xmon.c +1
-0@@ -1160,9 +1160,11 @@ cmds(struct pt_regs *excp)show_tasks ();break ;#ifdef CONFIG_PPC_BOOK3S +#ifdef CONFIG_PPC_64S_HASH_MMU And BOOK3S/32 ???
Oops, good catch.
Thanks,
Nick
Quoted 8 lines
Quoted 8 lines
arch/powerpc/xmon/xmon.c +1
-0case 'u' :dump_segments ();break ; +#endif #elif defined(CONFIG_44x)case 'u' :dump_tlb_44x ();
Nicholas Piggin
reviewerRe: [PATCH v2 16/16] powerpc/microwatt: Don't select the hash MMU code
In reply to Joel StanleyExcerpts from Joel Stanley's message of October 21, 2021 3:19 pm:
Quoted 12 lines · Nicholas Piggin
Quoted 11 lines
Microwatt is radix-only, so it does not require hash MMU support.
This saves 20kB compressed dtbImage and 56kB vmlinux size.
Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/configs/microwatt_defconfig | 1 - arch/powerpc/platforms/microwatt/Kconfig | 1 - 2 files changed, 2 deletions(-)
Quoted 15 lines
arch/powerpc/configs/microwatt_defconfig CONFIG_PPC_MICROWATT=y · line 32
Quoted 12 lines
arch/powerpc/configs/microwatt_defconfig +0
-1@@ -27,7 +27,6 @@ CONFIG_PPC_MICROWATT=y # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set CONFIG_CPU_FREQ=y CONFIG_HZ_100=y -# CONFIG_PPC_MEM_KEYS is not set # CONFIG_SECCOMP is not set # CONFIG_MQ_IOSCHED_KYBER is not set # CONFIG_COREDUMP is not setWe still end up with
CONFIG_PPC_64S_HASH_MMU=yin the config as it defaults to y.
If you make microwatt_defconfig? Hm, IIRC this came from savedefconfig after unselecting hash mmu so I'm not sure why that doesn't work.
Quoted 8 lines
We should disable in the defconfig it so your new changes are tested by that defconfig:
+#
CONFIG_PPC_64S_HASH_MMUis not setI boot tested your series on Microwatt with
microwatt_defconfig(with and without that option set) andppc64le_defconfig.
Nice.
Thanks,
Nick
Quoted 21 lines
Cheers,
Joel
Quoted 15 lines
arch/powerpc/platforms/microwatt/Kconfig +0
-2@@ -5,7 +5,6 @@ config PPC_MICROWATT select PPC_XICS select PPC_ICS_NATIVE select PPC_ICP_NATIVE - select PPC_HASH_MMU_NATIVE if PPC_64S_HASH_MMU select PPC_UDBG_16550 select ARCH_RANDOM help --2.23.0