[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200317124323.GA16200@willie-the-truck>
Date: Tue, 17 Mar 2020 12:43:24 +0000
From: Will Deacon <will@...nel.org>
To: Mark Rutland <mark.rutland@....com>
Cc: Hongbo Yao <yaohongbo@...wei.com>, broonie@...nel.org,
linux-kernel@...r.kernel.org, catalin.marinas@....com,
linux-arm-kernel@...ts.infradead.org
Subject: Re: [RFC PATCH] arm64: fix the missing ktpi= cmdline check in
arm64_kernel_unmapped_at_el0()
On Tue, Mar 17, 2020 at 12:10:51PM +0000, Mark Rutland wrote:
> [Adding Catalin and LAKML]
>
> Mark.
>
> On Tue, Mar 17, 2020 at 07:47:08PM +0800, Hongbo Yao wrote:
> > Kpti cannot be disabled from the kernel cmdline after the commit
> > 09e3c22a("arm64: Use a variable to store non-global mappings decision").
> >
> > Bring back the missing check of kpti= command-line option to fix the
> > case where the SPE driver complains the missing "kpti-off" even it has
> > already been set.
> >
> > Signed-off-by: Hongbo Yao <yaohongbo@...wei.com>
> > ---
> > arch/arm64/include/asm/mmu.h | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
> > index 3c9533322558..ebbc0d3ac2f7 100644
> > --- a/arch/arm64/include/asm/mmu.h
> > +++ b/arch/arm64/include/asm/mmu.h
> > @@ -34,7 +34,8 @@ extern bool arm64_use_ng_mappings;
> >
> > static inline bool arm64_kernel_unmapped_at_el0(void)
> > {
> > - return arm64_use_ng_mappings;
> > + return arm64_use_ng_mappings &&
> > + cpus_have_const_cap(ARM64_UNMAP_KERNEL_AT_EL0);
> > }
This probably isn't the right fix, since this will mean that early mappings
will be global and we'll have to go through the painful page-table rewrite
logic when the cap gets enabled for KASLR-enabled kernels.
Maybe a better bodge is something like:
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 0b6715625cf6..ad10f55b7bb9 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1085,6 +1085,8 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
if (!__kpti_forced) {
str = "KASLR";
__kpti_forced = 1;
+ } else if (__kpti_forced < 0) {
+ arm64_use_ng_mappings = false;
}
}
Will
Powered by blists - more mailing lists