From: Jean-Philippe Brucker <jean-philippe@linaro.org>
To: catalin.marinas@arm.com, will@kernel.org
Cc: vladimir.murzin@arm.com, linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: context: Fix ASID limit in boot warning
Date: Mon, 24 Feb 2020 11:39:34 +0100 [thread overview]
Message-ID: <20200224103934.137314-1-jean-philippe@linaro.org> (raw)
Since commit f88f42f853a8 ("arm64: context: Free up kernel ASIDs if KPTI
is not in use"), the NUM_USER_ASIDS macro doesn't correspond to the
effective number of ASIDs when KPTI is enabled. Fix the number of
available ASIDs in the boot warning.
Fixes: f88f42f853a8 ("arm64: context: Free up kernel ASIDs if KPTI is not in use")
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
arch/arm64/mm/context.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c
index 8ef73e89d514..121aba5b1941 100644
--- a/arch/arm64/mm/context.c
+++ b/arch/arm64/mm/context.c
@@ -262,12 +262,16 @@ asmlinkage void post_ttbr_update_workaround(void)
static int asids_init(void)
{
+ unsigned long num_available_asids;
+ bool kpti = IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0);
+
asid_bits = get_cpu_asid_bits();
/*
* Expect allocation after rollover to fail if we don't have at least
* one more ASID than CPUs. ASID #0 is reserved for init_mm.
*/
- WARN_ON(NUM_USER_ASIDS - 1 <= num_possible_cpus());
+ num_available_asids = (1UL << (asid_bits - kpti)) - 1;
+ WARN_ON(num_available_asids <= num_possible_cpus());
atomic64_set(&asid_generation, ASID_FIRST_VERSION);
asid_map = kcalloc(BITS_TO_LONGS(NUM_USER_ASIDS), sizeof(*asid_map),
GFP_KERNEL);
@@ -280,7 +284,7 @@ static int asids_init(void)
* caps are not finalized yet, so it is safer to assume KPTI
* and reserve kernel ASID's from beginning.
*/
- if (IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0))
+ if (kpti)
set_kpti_asid_bits();
pr_info("ASID allocator initialised with %lu entries\n", NUM_USER_ASIDS);
--
2.25.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2020-02-24 10:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 10:39 Jean-Philippe Brucker [this message]
2020-02-24 11:06 ` [PATCH] arm64: context: Fix ASID limit in boot warning Vladimir Murzin
2020-02-25 12:13 ` Jean-Philippe Brucker
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=20200224103934.137314-1-jean-philippe@linaro.org \
--to=jean-philippe@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=vladimir.murzin@arm.com \
--cc=will@kernel.org \
/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