From: John Garry <john.garry@huawei.com>
To: James Morse <james.morse@arm.com>,
<linux-arm-kernel@lists.infradead.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
"Guohanjun \(Hanjun Guo\)" <guohanjun@huawei.com>,
Will Deacon <will.deacon@arm.com>, Linuxarm <linuxarm@huawei.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [PATCH] arm64: kpti: Update arm64_kernel_use_ng_mappings() when forced on
Date: Wed, 16 Jan 2019 09:38:21 +0000 [thread overview]
Message-ID: <21310b0b-8a75-1adf-a844-b2f3f520fa2d@huawei.com> (raw)
In-Reply-To: <20190115184917.248995-1-james.morse@arm.com>
On 15/01/2019 18:49, James Morse wrote:
> Since commit b89d82ef01b3 ("arm64: kpti: Avoid rewriting early page
About b89d82ef01b3, I got an *unconfirmed* (emphasis on this, I don't
want to cry wolf) report yesterday that the symptom I saw (boot delay)
has been seen on 5.0-rc2 on our D06 board. I could not see it.
Please note that this would be same board which we saw this on:
https://lkml.org/lkml/2018/6/20/589
I only witnessed the issue on the predecessor A72-based D05 board.
The reporter is very busy, but we'll keep tabs on it.
Thanks,
John
> tables when KASLR is enabled"), a kernel built with CONFIG_RANDOMIZE_BASE
> can decide early whether to use non-global mappings by checking the
> kaslr_offset().
>
> A kernel built without CONFIG_RANDOMIZE_BASE, instead checks the
> cpufeature static-key.
>
> This leaves a gap where CONFIG_RANDOMIZE_BASE was enabled, no
> kaslr seed was provided, but kpti was forced on using the cmdline
> option.
>
> When the decision is made late, kpti_install_ng_mappings() will re-write
> the page tables, but arm64_kernel_use_ng_mappings()'s value does not
> change as it only tests the cpufeature static-key if
> CONFIG_RANDOMIZE_BASE is disabled.
> This function influences PROT_DEFAULT via PTE_MAYBE_NG, and causes
> pgattr_change_is_safe() to catch nG->G transitions when the unchanged
> PROT_DEFAULT is used as part of PAGE_KERNEL_RO:
> [ 1.942255] alternatives: patching kernel code
> [ 1.998288] ------------[ cut here ]------------
> [ 2.000693] kernel BUG at arch/arm64/mm/mmu.c:165!
> [ 2.019215] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
> [ 2.020257] Modules linked in:
> [ 2.020807] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc2 #51
> [ 2.021917] Hardware name: linux,dummy-virt (DT)
> [ 2.022790] pstate: 40000005 (nZcv daif -PAN -UAO)
> [ 2.023742] pc : __create_pgd_mapping+0x508/0x6d0
> [ 2.024671] lr : __create_pgd_mapping+0x500/0x6d0
>
> [ 2.058059] Process swapper/0 (pid: 1, stack limit = 0x(____ptrval____))
> [ 2.059369] Call trace:
> [ 2.059845] __create_pgd_mapping+0x508/0x6d0
> [ 2.060684] update_mapping_prot+0x48/0xd0
> [ 2.061477] mark_linear_text_alias_ro+0xdc/0xe4
> [ 2.070502] smp_cpus_done+0x90/0x98
> [ 2.071216] smp_init+0x100/0x114
> [ 2.071878] kernel_init_freeable+0xd4/0x220
> [ 2.072750] kernel_init+0x10/0x100
> [ 2.073455] ret_from_fork+0x10/0x18
>
> [ 2.075414] ---[ end trace 3572f3a7782292de ]---
> [ 2.076389] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
>
> If arm64_kernel_unmapped_at_el0() is true, arm64_kernel_use_ng_mappings()
> should also be true.
>
> Signed-off-by: James Morse <james.morse@arm.com>
> CC: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> CC: John Garry <john.garry@huawei.com>
> CC: Will Deacon <will.deacon@arm.com>
>
> ---
> arch/arm64/include/asm/mmu.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
> index ac352accb3d9..3e8063f4f9d3 100644
> --- a/arch/arm64/include/asm/mmu.h
> +++ b/arch/arm64/include/asm/mmu.h
> @@ -60,8 +60,11 @@ static inline bool arm64_kernel_use_ng_mappings(void)
> * later determine that kpti is required, then
> * kpti_install_ng_mappings() will make them non-global.
> */
> + if (arm64_kernel_unmapped_at_el0())
> + return true;
> +
> if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE))
> - return arm64_kernel_unmapped_at_el0();
> + return false;
>
> /*
> * KASLR is enabled so we're going to be enabling kpti on non-broken
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-01-16 9:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-15 18:49 [PATCH] arm64: kpti: Update arm64_kernel_use_ng_mappings() when forced on James Morse
2019-01-16 9:38 ` John Garry [this message]
2019-01-16 10:33 ` James Morse
[not found] ` <835dc899-578c-d914-4ed3-fa8b3b391ae6@huawei.com>
2019-03-01 11:35 ` Will Deacon
2019-03-01 11:43 ` Ard Biesheuvel
2019-03-01 11:45 ` Will Deacon
2019-03-01 11:46 ` Ard Biesheuvel
2019-03-01 12:59 ` Hanjun Guo
2019-03-01 13:02 ` Will Deacon
2019-03-01 13:34 ` Hanjun Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=21310b0b-8a75-1adf-a844-b2f3f520fa2d@huawei.com \
--to=john.garry@huawei.com \
--cc=ard.biesheuvel@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=guohanjun@huawei.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).