Message ID | 20201125051634.509286-20-aneesh.kumar@linux.ibm.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | Kernel userspace access/execution prevention with hash translation | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | Successfully applied on branch powerpc/merge (4c202167192a77481310a3cacae9f12618b92216) |
snowpatch_ozlabs/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 13 lines checked |
snowpatch_ozlabs/needsstable | success | Patch has no Fixes tags |
Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : > Reviewed-by: Sandipan Das <sandipan@linux.ibm.com> > Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> PPC_HAVE_KUAP is only selected on book3s/64 when PPC_RADIX_MMU is selected. Is that normal ? > --- > arch/powerpc/mm/book3s64/pkeys.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c > index f747d66cc87d..84f8664ffc47 100644 > --- a/arch/powerpc/mm/book3s64/pkeys.c > +++ b/arch/powerpc/mm/book3s64/pkeys.c > @@ -257,7 +257,12 @@ void __init setup_kuep(bool disabled) > #ifdef CONFIG_PPC_KUAP > void __init setup_kuap(bool disabled) > { > - if (disabled || !early_radix_enabled()) > + if (disabled) > + return; > + /* > + * On hash if PKEY feature is not enabled, disable KUAP too. > + */ > + if (!early_radix_enabled() && !early_mmu_has_feature(MMU_FTR_PKEY)) > return; > > if (smp_processor_id() == boot_cpuid) { >
On 3/15/21 5:36 PM, Christophe Leroy wrote: > > > Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : >> Reviewed-by: Sandipan Das <sandipan@linux.ibm.com> >> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> > > PPC_HAVE_KUAP is only selected on book3s/64 when PPC_RADIX_MMU is > selected. Is that normal ? > I guess we missed fixing that with this patch. How about modified arch/powerpc/platforms/Kconfig.cputype @@ -103,6 +103,8 @@ config PPC_BOOK3S_64 select ARCH_SUPPORTS_NUMA_BALANCING select IRQ_WORK select PPC_MM_SLICES + select PPC_HAVE_KUEP + select PPC_HAVE_KUAP config PPC_BOOK3E_64 bool "Embedded processors" @@ -365,8 +367,6 @@ config PPC_RADIX_MMU bool "Radix MMU Support" depends on PPC_BOOK3S_64 select ARCH_HAS_GIGANTIC_PAGE - select PPC_HAVE_KUEP - select PPC_HAVE_KUAP default y help Enable support for the Power ISA 3.0 Radix style MMU. Currently this -aneesh
Le 15/03/2021 à 13:59, Aneesh Kumar K.V a écrit : > On 3/15/21 5:36 PM, Christophe Leroy wrote: >> >> >> Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : >>> Reviewed-by: Sandipan Das <sandipan@linux.ibm.com> >>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> >> >> PPC_HAVE_KUAP is only selected on book3s/64 when PPC_RADIX_MMU is selected. Is that normal ? >> > > > I guess we missed fixing that with this patch. How about Yes, looks good to me. > > modified arch/powerpc/platforms/Kconfig.cputype > @@ -103,6 +103,8 @@ config PPC_BOOK3S_64 > select ARCH_SUPPORTS_NUMA_BALANCING > select IRQ_WORK > select PPC_MM_SLICES > + select PPC_HAVE_KUEP > + select PPC_HAVE_KUAP > > config PPC_BOOK3E_64 > bool "Embedded processors" > @@ -365,8 +367,6 @@ config PPC_RADIX_MMU > bool "Radix MMU Support" > depends on PPC_BOOK3S_64 > select ARCH_HAS_GIGANTIC_PAGE > - select PPC_HAVE_KUEP > - select PPC_HAVE_KUAP > default y > help > Enable support for the Power ISA 3.0 Radix style MMU. Currently this > > > > > > -aneesh
Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : > Reviewed-by: Sandipan Das <sandipan@linux.ibm.com> > Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> > --- > arch/powerpc/mm/book3s64/pkeys.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c > index f747d66cc87d..84f8664ffc47 100644 > --- a/arch/powerpc/mm/book3s64/pkeys.c > +++ b/arch/powerpc/mm/book3s64/pkeys.c > @@ -257,7 +257,12 @@ void __init setup_kuep(bool disabled) > #ifdef CONFIG_PPC_KUAP > void __init setup_kuap(bool disabled) > { > - if (disabled || !early_radix_enabled()) > + if (disabled) > + return; > + /* > + * On hash if PKEY feature is not enabled, disable KUAP too. > + */ > + if (!early_radix_enabled() && !early_mmu_has_feature(MMU_FTR_PKEY)) pkey_early_init_devtree() bails out without setting MMU_FTR_PKEY with the following: /* * Only P7 and above supports SPRN_AMR update with MSR[PR] = 1 */ if (!early_cpu_has_feature(CPU_FTR_ARCH_206)) return; Why would it be impossible to do KUAP in that case ? KUAP doesn't require updating SPRN_AMR with MSR[PR] = 1 > return; > > if (smp_processor_id() == boot_cpuid) { >
Christophe Leroy <christophe.leroy@csgroup.eu> writes: > Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit : >> Reviewed-by: Sandipan Das <sandipan@linux.ibm.com> >> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> >> --- >> arch/powerpc/mm/book3s64/pkeys.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c >> index f747d66cc87d..84f8664ffc47 100644 >> --- a/arch/powerpc/mm/book3s64/pkeys.c >> +++ b/arch/powerpc/mm/book3s64/pkeys.c >> @@ -257,7 +257,12 @@ void __init setup_kuep(bool disabled) >> #ifdef CONFIG_PPC_KUAP >> void __init setup_kuap(bool disabled) >> { >> - if (disabled || !early_radix_enabled()) >> + if (disabled) >> + return; >> + /* >> + * On hash if PKEY feature is not enabled, disable KUAP too. >> + */ >> + if (!early_radix_enabled() && !early_mmu_has_feature(MMU_FTR_PKEY)) > > pkey_early_init_devtree() bails out without setting MMU_FTR_PKEY with > the following: > > /* > * Only P7 and above supports SPRN_AMR update with MSR[PR] = 1 > */ > if (!early_cpu_has_feature(CPU_FTR_ARCH_206)) > return; > > > > Why would it be impossible to do KUAP in that case ? KUAP doesn't > require updating SPRN_AMR with MSR[PR] = 1 You're right, it would be possible to do KUAP in that case. That's an artifact of KUAP being implemented using PKEYs on hash. For the PKEYs user-visible API we want AMR to be user controlled. It's possible we could untangle all that, allowing KUAP to be implemented on earlier CPUs, but I'm not sure it's going to be high on anyone's todo list. cheers
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c index f747d66cc87d..84f8664ffc47 100644 --- a/arch/powerpc/mm/book3s64/pkeys.c +++ b/arch/powerpc/mm/book3s64/pkeys.c @@ -257,7 +257,12 @@ void __init setup_kuep(bool disabled) #ifdef CONFIG_PPC_KUAP void __init setup_kuap(bool disabled) { - if (disabled || !early_radix_enabled()) + if (disabled) + return; + /* + * On hash if PKEY feature is not enabled, disable KUAP too. + */ + if (!early_radix_enabled() && !early_mmu_has_feature(MMU_FTR_PKEY)) return; if (smp_processor_id() == boot_cpuid) {