[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y17nqd27jHOkzeOp@zx2c4.com>
Date: Sun, 30 Oct 2022 22:07:53 +0100
From: "Jason A. Donenfeld" <Jason@...c4.com>
To: Catalin Marinas <catalin.marinas@....com>
Cc: will@...nel.org, jean-philippe@...aro.org, ardb@...nel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] random: remove early archrandom abstraction
Hi Catalin,
> > +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.
This occurred to me too and I wasn't quite sure how the interaction
worked out. It sounds like system_capabilities_finalized() might still
be false when SMP brings up other cores? In that case, I guess we just
have to make sure the system is still booting / in single CPU mode,
before interrupts have been enabled. This should be straight forward to
do; I'll send a v2.
Jason
Powered by blists - more mailing lists