Commit c2857374 authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Michael Ellerman

powerpc/64s: Make hash MMU support configurable

This adds Kconfig selection which allows 64s hash MMU support to be
disabled. It can be disabled if radix support is enabled, the minimum
supported CPU type is POWER9 (or higher), and KVM is not selected.
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20211201144153.2456614-17-npiggin@gmail.com
parent debeda01
...@@ -846,7 +846,7 @@ config FORCE_MAX_ZONEORDER ...@@ -846,7 +846,7 @@ config FORCE_MAX_ZONEORDER
config PPC_SUBPAGE_PROT config PPC_SUBPAGE_PROT
bool "Support setting protections for 4k subpages (subpage_prot syscall)" bool "Support setting protections for 4k subpages (subpage_prot syscall)"
default n default n
depends on PPC_BOOK3S_64 && PPC_64K_PAGES depends on PPC_64S_HASH_MMU && PPC_64K_PAGES
help help
This option adds support for system call to allow user programs This option adds support for system call to allow user programs
to set access permissions (read/write, readonly, or no access) to set access permissions (read/write, readonly, or no access)
...@@ -944,6 +944,7 @@ config PPC_MEM_KEYS ...@@ -944,6 +944,7 @@ config PPC_MEM_KEYS
prompt "PowerPC Memory Protection Keys" prompt "PowerPC Memory Protection Keys"
def_bool y def_bool y
depends on PPC_BOOK3S_64 depends on PPC_BOOK3S_64
depends on PPC_64S_HASH_MMU
select ARCH_USES_HIGH_VMA_FLAGS select ARCH_USES_HIGH_VMA_FLAGS
select ARCH_HAS_PKEYS select ARCH_HAS_PKEYS
help help
......
...@@ -157,7 +157,7 @@ DECLARE_PER_CPU(int, next_tlbcam_idx); ...@@ -157,7 +157,7 @@ DECLARE_PER_CPU(int, next_tlbcam_idx);
enum { enum {
MMU_FTRS_POSSIBLE = MMU_FTRS_POSSIBLE =
#if defined(CONFIG_PPC_BOOK3S_64) || defined(CONFIG_PPC_BOOK3S_604) #if defined(CONFIG_PPC_BOOK3S_604)
MMU_FTR_HPTE_TABLE | MMU_FTR_HPTE_TABLE |
#endif #endif
#ifdef CONFIG_PPC_8xx #ifdef CONFIG_PPC_8xx
...@@ -184,15 +184,18 @@ enum { ...@@ -184,15 +184,18 @@ enum {
MMU_FTR_USE_TLBRSRV | MMU_FTR_USE_PAIRED_MAS | MMU_FTR_USE_TLBRSRV | MMU_FTR_USE_PAIRED_MAS |
#endif #endif
#ifdef CONFIG_PPC_BOOK3S_64 #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_NO_SLBIE_B | MMU_FTR_16M_PAGE | MMU_FTR_TLBIEL |
MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_CI_LARGE_PAGE | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_CI_LARGE_PAGE |
MMU_FTR_1T_SEGMENT | MMU_FTR_TLBIE_CROP_VA | 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 #endif
#ifdef CONFIG_PPC_RADIX_MMU #ifdef CONFIG_PPC_RADIX_MMU
MMU_FTR_TYPE_RADIX | MMU_FTR_TYPE_RADIX |
MMU_FTR_GTSE | MMU_FTR_GTSE |
#endif /* CONFIG_PPC_RADIX_MMU */ #endif /* CONFIG_PPC_RADIX_MMU */
#endif
#ifdef CONFIG_PPC_KUAP #ifdef CONFIG_PPC_KUAP
MMU_FTR_BOOK3S_KUAP | MMU_FTR_BOOK3S_KUAP |
#endif /* CONFIG_PPC_KUAP */ #endif /* CONFIG_PPC_KUAP */
...@@ -224,6 +227,13 @@ enum { ...@@ -224,6 +227,13 @@ enum {
#define MMU_FTRS_ALWAYS MMU_FTR_TYPE_FSL_E #define MMU_FTRS_ALWAYS MMU_FTR_TYPE_FSL_E
#endif #endif
/* BOOK3S_64 options */
#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
#ifndef MMU_FTRS_ALWAYS #ifndef MMU_FTRS_ALWAYS
#define MMU_FTRS_ALWAYS 0 #define MMU_FTRS_ALWAYS 0
#endif #endif
...@@ -329,7 +339,7 @@ static __always_inline bool radix_enabled(void) ...@@ -329,7 +339,7 @@ static __always_inline bool radix_enabled(void)
return mmu_has_feature(MMU_FTR_TYPE_RADIX); 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); return early_mmu_has_feature(MMU_FTR_TYPE_RADIX);
} }
......
...@@ -273,6 +273,9 @@ static int __init feat_enable_mmu_hash(struct dt_cpu_feature *f) ...@@ -273,6 +273,9 @@ static int __init feat_enable_mmu_hash(struct dt_cpu_feature *f)
{ {
u64 lpcr; u64 lpcr;
if (!IS_ENABLED(CONFIG_PPC_64S_HASH_MMU))
return 0;
lpcr = mfspr(SPRN_LPCR); lpcr = mfspr(SPRN_LPCR);
lpcr &= ~LPCR_ISL; lpcr &= ~LPCR_ISL;
...@@ -292,6 +295,9 @@ static int __init feat_enable_mmu_hash_v3(struct dt_cpu_feature *f) ...@@ -292,6 +295,9 @@ static int __init feat_enable_mmu_hash_v3(struct dt_cpu_feature *f)
{ {
u64 lpcr; u64 lpcr;
if (!IS_ENABLED(CONFIG_PPC_64S_HASH_MMU))
return 0;
lpcr = mfspr(SPRN_LPCR); lpcr = mfspr(SPRN_LPCR);
lpcr &= ~(LPCR_ISL | LPCR_UPRT | LPCR_HR); lpcr &= ~(LPCR_ISL | LPCR_UPRT | LPCR_HR);
mtspr(SPRN_LPCR, lpcr); mtspr(SPRN_LPCR, lpcr);
...@@ -305,15 +311,15 @@ static int __init feat_enable_mmu_hash_v3(struct dt_cpu_feature *f) ...@@ -305,15 +311,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) 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_FTR_TYPE_RADIX;
cur_cpu_spec->mmu_features |= MMU_FTRS_HASH_BASE;
cur_cpu_spec->mmu_features |= MMU_FTR_GTSE; cur_cpu_spec->mmu_features |= MMU_FTR_GTSE;
cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_MMU; cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_MMU;
return 1; return 1;
#endif
return 0;
} }
static int __init feat_enable_dscr(struct dt_cpu_feature *f) static int __init feat_enable_dscr(struct dt_cpu_feature *f)
......
...@@ -69,6 +69,7 @@ config KVM_BOOK3S_64 ...@@ -69,6 +69,7 @@ config KVM_BOOK3S_64
select KVM_BOOK3S_64_HANDLER select KVM_BOOK3S_64_HANDLER
select KVM select KVM
select KVM_BOOK3S_PR_POSSIBLE if !KVM_BOOK3S_HV_POSSIBLE 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) select SPAPR_TCE_IOMMU if IOMMU_SUPPORT && (PPC_PSERIES || PPC_POWERNV)
help help
Support running unmodified book3s_64 and book3s_32 guest kernels Support running unmodified book3s_64 and book3s_32 guest kernels
......
...@@ -472,8 +472,12 @@ void __init mmu_early_init_devtree(void) ...@@ -472,8 +472,12 @@ void __init mmu_early_init_devtree(void)
bool hvmode = !!(mfmsr() & MSR_HV); bool hvmode = !!(mfmsr() & MSR_HV);
/* Disable radix mode based on kernel command line. */ /* Disable radix mode based on kernel command line. */
if (disable_radix) if (disable_radix) {
cur_cpu_spec->mmu_features &= ~MMU_FTR_TYPE_RADIX; if (IS_ENABLED(CONFIG_PPC_64S_HASH_MMU))
cur_cpu_spec->mmu_features &= ~MMU_FTR_TYPE_RADIX;
else
pr_warn("WARNING: Ignoring cmdline option disable_radix\n");
}
of_scan_flat_dt(dt_scan_mmu_pid_width, NULL); of_scan_flat_dt(dt_scan_mmu_pid_width, NULL);
if (hvmode && !mmu_lpid_bits) { if (hvmode && !mmu_lpid_bits) {
...@@ -498,6 +502,7 @@ void __init mmu_early_init_devtree(void) ...@@ -498,6 +502,7 @@ void __init mmu_early_init_devtree(void)
if (early_radix_enabled()) { if (early_radix_enabled()) {
radix__early_init_devtree(); radix__early_init_devtree();
/* /*
* We have finalized the translation we are going to use by now. * We have finalized the translation we are going to use by now.
* Radix mode is not limited by RMA / VRMA addressing. * Radix mode is not limited by RMA / VRMA addressing.
...@@ -507,5 +512,9 @@ void __init mmu_early_init_devtree(void) ...@@ -507,5 +512,9 @@ void __init mmu_early_init_devtree(void)
memblock_set_current_limit(MEMBLOCK_ALLOC_ANYWHERE); memblock_set_current_limit(MEMBLOCK_ALLOC_ANYWHERE);
} else } else
hash__early_init_devtree(); hash__early_init_devtree();
if (!(cur_cpu_spec->mmu_features & MMU_FTR_HPTE_TABLE) &&
!(cur_cpu_spec->mmu_features & MMU_FTR_TYPE_RADIX))
panic("kernel does not support any MMU type offered by platform");
} }
#endif /* CONFIG_PPC_BOOK3S_64 */ #endif /* CONFIG_PPC_BOOK3S_64 */
...@@ -105,9 +105,9 @@ config PPC_BOOK3S_64 ...@@ -105,9 +105,9 @@ config PPC_BOOK3S_64
select HAVE_MOVE_PMD select HAVE_MOVE_PMD
select HAVE_MOVE_PUD select HAVE_MOVE_PUD
select IRQ_WORK select IRQ_WORK
select PPC_MM_SLICES
select PPC_HAVE_KUEP select PPC_HAVE_KUEP
select PPC_HAVE_KUAP select PPC_HAVE_KUAP
select PPC_64S_HASH_MMU if !PPC_RADIX_MMU
config PPC_BOOK3E_64 config PPC_BOOK3E_64
bool "Embedded processors" bool "Embedded processors"
...@@ -130,11 +130,13 @@ choice ...@@ -130,11 +130,13 @@ choice
config GENERIC_CPU config GENERIC_CPU
bool "Generic (POWER4 and above)" bool "Generic (POWER4 and above)"
depends on PPC64 && !CPU_LITTLE_ENDIAN depends on PPC64 && !CPU_LITTLE_ENDIAN
select PPC_64S_HASH_MMU if PPC_BOOK3S_64
config GENERIC_CPU config GENERIC_CPU
bool "Generic (POWER8 and above)" bool "Generic (POWER8 and above)"
depends on PPC64 && CPU_LITTLE_ENDIAN depends on PPC64 && CPU_LITTLE_ENDIAN
select ARCH_HAS_FAST_MULTIPLIER select ARCH_HAS_FAST_MULTIPLIER
select PPC_64S_HASH_MMU
config GENERIC_CPU config GENERIC_CPU
bool "Generic 32 bits powerpc" bool "Generic 32 bits powerpc"
...@@ -143,24 +145,29 @@ config GENERIC_CPU ...@@ -143,24 +145,29 @@ config GENERIC_CPU
config CELL_CPU config CELL_CPU
bool "Cell Broadband Engine" bool "Cell Broadband Engine"
depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
select PPC_64S_HASH_MMU
config POWER5_CPU config POWER5_CPU
bool "POWER5" bool "POWER5"
depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
select PPC_64S_HASH_MMU
config POWER6_CPU config POWER6_CPU
bool "POWER6" bool "POWER6"
depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
select PPC_64S_HASH_MMU
config POWER7_CPU config POWER7_CPU
bool "POWER7" bool "POWER7"
depends on PPC_BOOK3S_64 depends on PPC_BOOK3S_64
select ARCH_HAS_FAST_MULTIPLIER select ARCH_HAS_FAST_MULTIPLIER
select PPC_64S_HASH_MMU
config POWER8_CPU config POWER8_CPU
bool "POWER8" bool "POWER8"
depends on PPC_BOOK3S_64 depends on PPC_BOOK3S_64
select ARCH_HAS_FAST_MULTIPLIER select ARCH_HAS_FAST_MULTIPLIER
select PPC_64S_HASH_MMU
config POWER9_CPU config POWER9_CPU
bool "POWER9" bool "POWER9"
...@@ -364,6 +371,22 @@ config SPE ...@@ -364,6 +371,22 @@ config SPE
If in doubt, say Y here. If in doubt, say Y here.
config PPC_64S_HASH_MMU
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 64-bit Book3S CPUs before ISA v3.0. The
OpenPOWER ISA does not mandate the hash MMU and some CPUs do not
implement it (e.g., Microwatt).
Note that POWER9 PowerVM platforms only support the hash
MMU. From POWER10 radix is also supported by PowerVM.
If you're unsure, say Y.
config PPC_RADIX_MMU config PPC_RADIX_MMU
bool "Radix MMU Support" bool "Radix MMU Support"
depends on PPC_BOOK3S_64 depends on PPC_BOOK3S_64
...@@ -375,7 +398,8 @@ config PPC_RADIX_MMU ...@@ -375,7 +398,8 @@ config PPC_RADIX_MMU
you can probably disable this. you can probably disable this.
config PPC_RADIX_MMU_DEFAULT config PPC_RADIX_MMU_DEFAULT
bool "Default to using the Radix MMU when possible" bool "Default to using the Radix MMU when possible" if PPC_64S_HASH_MMU
depends on PPC_BOOK3S_64
depends on PPC_RADIX_MMU depends on PPC_RADIX_MMU
default y default y
help help
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
config PPC_CELL config PPC_CELL
select PPC_64S_HASH_MMU if PPC64
bool bool
config PPC_CELL_COMMON config PPC_CELL_COMMON
......
...@@ -9,6 +9,7 @@ config PPC_MAPLE ...@@ -9,6 +9,7 @@ config PPC_MAPLE
select GENERIC_TBSYNC select GENERIC_TBSYNC
select PPC_UDBG_16550 select PPC_UDBG_16550
select PPC_970_NAP select PPC_970_NAP
select PPC_64S_HASH_MMU
select PPC_HASH_MMU_NATIVE select PPC_HASH_MMU_NATIVE
select PPC_RTAS select PPC_RTAS
select MMIO_NVRAM select MMIO_NVRAM
......
...@@ -5,7 +5,7 @@ config PPC_MICROWATT ...@@ -5,7 +5,7 @@ config PPC_MICROWATT
select PPC_XICS select PPC_XICS
select PPC_ICS_NATIVE select PPC_ICS_NATIVE
select PPC_ICP_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 PPC_UDBG_16550
select ARCH_RANDOM select ARCH_RANDOM
help help
......
...@@ -5,6 +5,7 @@ config PPC_PASEMI ...@@ -5,6 +5,7 @@ config PPC_PASEMI
select MPIC select MPIC
select FORCE_PCI select FORCE_PCI
select PPC_UDBG_16550 select PPC_UDBG_16550
select PPC_64S_HASH_MMU
select PPC_HASH_MMU_NATIVE select PPC_HASH_MMU_NATIVE
select MPIC_BROKEN_REGREAD select MPIC_BROKEN_REGREAD
help help
......
...@@ -6,6 +6,7 @@ config PPC_PMAC ...@@ -6,6 +6,7 @@ config PPC_PMAC
select FORCE_PCI select FORCE_PCI
select PPC_INDIRECT_PCI if PPC32 select PPC_INDIRECT_PCI if PPC32
select PPC_MPC106 if PPC32 select PPC_MPC106 if PPC32
select PPC_64S_HASH_MMU if PPC64
select PPC_HASH_MMU_NATIVE select PPC_HASH_MMU_NATIVE
select ZONE_DMA if PPC32 select ZONE_DMA if PPC32
default y default y
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
config PPC_POWERNV config PPC_POWERNV
depends on PPC64 && PPC_BOOK3S depends on PPC64 && PPC_BOOK3S
bool "IBM PowerNV (Non-Virtualized) platform support" 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_XICS
select PPC_ICP_NATIVE select PPC_ICP_NATIVE
select PPC_XIVE_NATIVE select PPC_XIVE_NATIVE
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
config CXL_BASE config CXL_BASE
bool bool
select PPC_COPRO_BASE select PPC_COPRO_BASE
select PPC_64S_HASH_MMU
config CXL config CXL
tristate "Support for IBM Coherent Accelerators (CXL)" tristate "Support for IBM Coherent Accelerators (CXL)"
......
...@@ -11,7 +11,7 @@ lkdtm-$(CONFIG_LKDTM) += usercopy.o ...@@ -11,7 +11,7 @@ lkdtm-$(CONFIG_LKDTM) += usercopy.o
lkdtm-$(CONFIG_LKDTM) += stackleak.o lkdtm-$(CONFIG_LKDTM) += stackleak.o
lkdtm-$(CONFIG_LKDTM) += cfi.o lkdtm-$(CONFIG_LKDTM) += cfi.o
lkdtm-$(CONFIG_LKDTM) += fortify.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_rodata.o := n
KASAN_SANITIZE_stackleak.o := n KASAN_SANITIZE_stackleak.o := n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment