From: Catalin Marinas <catalin.marinas@arm.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: will@kernel.org, jean-philippe@linaro.org, ardb@kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] random: remove early archrandom abstraction
Date: Sun, 30 Oct 2022 17:30:09 +0000 [thread overview]
Message-ID: <Y160oanRPF3ZLINw@arm.com> (raw)
In-Reply-To: <20221028234025.82222-1-Jason@zx2c4.com>
On Sat, Oct 29, 2022 at 01:40:25AM +0200, Jason A. Donenfeld wrote:
> diff --git a/arch/arm64/include/asm/archrandom.h b/arch/arm64/include/asm/archrandom.h
> index 109e2a4454be..8a059a9033af 100644
> --- a/arch/arm64/include/asm/archrandom.h
> +++ b/arch/arm64/include/asm/archrandom.h
> @@ -58,6 +58,16 @@ static inline bool __arm64_rndrrs(unsigned long *v)
> return ok;
> }
>
> +static __always_inline bool __cpu_has_rng(void)
> +{
> + if (!system_capabilities_finalized()) {
> + /* Open code as we run prior to the first call to cpufeature. */
> + unsigned long ftr = read_sysreg_s(SYS_ID_AA64ISAR0_EL1);
> + return (ftr >> ID_AA64ISAR0_EL1_RNDR_SHIFT) & 0xf;
> + }
> + return cpus_have_const_cap(ARM64_HAS_RNG);
> +}
We need to be careful with this check as it is only valid on the CPU it
was called on. Is the result used only on this CPU and with the
preemption disabled? We have big.LITTLE systems where CPUs may differ
and the ARM64_HAS_RNG feature may not be enabled once all the CPUs have
been initialised (capabilities finalised).
We could make this capability an ARM64_CPUCAP_BOOT_CPU_FEATURE, though
I'd have to check whether any systems in the wild have such mixed CPUs.
--
Catalin
_______________________________________________
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:[~2022-10-30 17:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 23:40 [PATCH] random: remove early archrandom abstraction Jason A. Donenfeld
2022-10-30 17:30 ` Catalin Marinas [this message]
2022-10-30 21:07 ` Jason A. Donenfeld
2022-10-30 21:21 ` [PATCH v2] " Jason A. Donenfeld
2022-10-31 10:28 ` [PATCH v3] " Jason A. Donenfeld
2022-11-01 11:39 ` Catalin Marinas
2022-11-01 11:54 ` Jason A. Donenfeld
2022-11-01 11:56 ` [PATCH v4] " Jason A. Donenfeld
2022-11-01 12:25 ` [PATCH v5] " Jason A. Donenfeld
2022-11-01 12:36 ` Mark Rutland
2022-11-01 13:02 ` Jason A. Donenfeld
2022-11-01 13:07 ` Mark Rutland
2022-11-01 14:05 ` Catalin Marinas
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=Y160oanRPF3ZLINw@arm.com \
--to=catalin.marinas@arm.com \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=jean-philippe@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).