* [PATCH v2] arm64: kaslr: Use standard early random function
@ 2020-08-07 14:45 Guenter Roeck
2020-08-07 17:35 ` Catalin Marinas
0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2020-08-07 14:45 UTC (permalink / raw)
To: Linus Torvalds
Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, linux-kernel,
Daniel Díaz, tytso, Guenter Roeck, Qian Cai, Mark Brown
Commit 585524081ecd ("random: random.h should include archrandom.h, not
the other way around") tries to fix a problem with recursive inclusion
of linux/random.h and arch/archrandom.h for arm64. Unfortunately, this
results in the following compile error if ARCH_RANDOM is disabled.
arch/arm64/kernel/kaslr.c: In function 'kaslr_early_init':
arch/arm64/kernel/kaslr.c:128:6: error: implicit declaration of function
'__early_cpu_has_rndr'; did you mean '__early_pfn_to_nid'?
[-Werror=implicit-function-declaration]
if (__early_cpu_has_rndr()) {
^~~~~~~~~~~~~~~~~~~~
__early_pfn_to_nid
arch/arm64/kernel/kaslr.c:131:7: error: implicit declaration of function
'__arm64_rndr' [-Werror=implicit-function-declaration]
if (__arm64_rndr(&raw))
^~~~~~~~~~~~
Problem is that arch/archrandom.h is only included from linux/random.h if
ARCH_RANDOM is enabled. If not, __arm64_rndr() and __early_cpu_has_rndr()
are undeclared, causing the problem.
Use arch_get_random_seed_long_early() instead of arm64 specific functions
to solve the problem.
Reported-by: Qian Cai <cai@lca.pw>
Fixes: 585524081ecd ("random: random.h should include archrandom.h, not the other way around")
Cc: Qian Cai <cai@lca.pw>
Cc: Mark Brown <broonie@kernel.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Tested-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Added Reviewed-by: and Tested-by: tags
Removed comment about side effect
(it wasn't correct; code functionality is the same)
Removed second Fixes: tag (did not apply)
arch/arm64/kernel/kaslr.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c
index 9ded4237e1c1..b181e0544b79 100644
--- a/arch/arm64/kernel/kaslr.c
+++ b/arch/arm64/kernel/kaslr.c
@@ -84,6 +84,7 @@ u64 __init kaslr_early_init(u64 dt_phys)
void *fdt;
u64 seed, offset, mask, module_range;
const u8 *cmdline, *str;
+ unsigned long raw;
int size;
/*
@@ -122,15 +123,12 @@ u64 __init kaslr_early_init(u64 dt_phys)
}
/*
- * Mix in any entropy obtainable architecturally, open coded
- * since this runs extremely early.
+ * Mix in any entropy obtainable architecturally if enabled
+ * and supported.
*/
- if (__early_cpu_has_rndr()) {
- unsigned long raw;
- if (__arm64_rndr(&raw))
- seed ^= raw;
- }
+ if (arch_get_random_seed_long_early(&raw))
+ seed ^= raw;
if (!seed) {
kaslr_status = KASLR_DISABLED_NO_SEED;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] arm64: kaslr: Use standard early random function
2020-08-07 14:45 [PATCH v2] arm64: kaslr: Use standard early random function Guenter Roeck
@ 2020-08-07 17:35 ` Catalin Marinas
2020-08-07 17:48 ` Linus Torvalds
2020-08-07 18:00 ` Guenter Roeck
0 siblings, 2 replies; 5+ messages in thread
From: Catalin Marinas @ 2020-08-07 17:35 UTC (permalink / raw)
To: Guenter Roeck
Cc: Linus Torvalds, Will Deacon, linux-arm-kernel, linux-kernel,
Daniel Díaz, tytso, Qian Cai, Mark Brown
On Fri, Aug 07, 2020 at 07:45:21AM -0700, Guenter Roeck wrote:
> Commit 585524081ecd ("random: random.h should include archrandom.h, not
> the other way around") tries to fix a problem with recursive inclusion
> of linux/random.h and arch/archrandom.h for arm64. Unfortunately, this
> results in the following compile error if ARCH_RANDOM is disabled.
>
> arch/arm64/kernel/kaslr.c: In function 'kaslr_early_init':
> arch/arm64/kernel/kaslr.c:128:6: error: implicit declaration of function
> '__early_cpu_has_rndr'; did you mean '__early_pfn_to_nid'?
> [-Werror=implicit-function-declaration]
> if (__early_cpu_has_rndr()) {
> ^~~~~~~~~~~~~~~~~~~~
> __early_pfn_to_nid
> arch/arm64/kernel/kaslr.c:131:7: error: implicit declaration of function
> '__arm64_rndr' [-Werror=implicit-function-declaration]
> if (__arm64_rndr(&raw))
> ^~~~~~~~~~~~
>
> Problem is that arch/archrandom.h is only included from linux/random.h if
> ARCH_RANDOM is enabled. If not, __arm64_rndr() and __early_cpu_has_rndr()
> are undeclared, causing the problem.
>
> Use arch_get_random_seed_long_early() instead of arm64 specific functions
> to solve the problem.
>
> Reported-by: Qian Cai <cai@lca.pw>
> Fixes: 585524081ecd ("random: random.h should include archrandom.h, not the other way around")
> Cc: Qian Cai <cai@lca.pw>
> Cc: Mark Brown <broonie@kernel.org>
> Reviewed-by: Mark Rutland <mark.rutland@arm.com>
> Reviewed-by: Mark Brown <broonie@kernel.org>
> Tested-by: Mark Brown <broonie@kernel.org>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Linus, could you please pick this up directly? Otherwise, it will wait
until we reach -rc1 to avoid basing a branch on a random commit.
(at the moment I can't build Linus' tree at all, fails early with some
device tree errors)
Thanks.
--
Catalin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] arm64: kaslr: Use standard early random function
2020-08-07 17:35 ` Catalin Marinas
@ 2020-08-07 17:48 ` Linus Torvalds
2020-08-07 18:09 ` Catalin Marinas
2020-08-07 18:00 ` Guenter Roeck
1 sibling, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2020-08-07 17:48 UTC (permalink / raw)
To: Catalin Marinas
Cc: Guenter Roeck, Will Deacon, Linux ARM, Linux Kernel Mailing List,
Daniel Díaz, Theodore Ts'o, Qian Cai, Mark Brown
On Fri, Aug 7, 2020 at 10:35 AM Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>
>
> Linus, could you please pick this up directly? Otherwise, it will wait
> until we reach -rc1 to avoid basing a branch on a random commit.
Already done, since I was the cause of the mess. But because I did it
early, your Acked-by didn't get in.
Linus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] arm64: kaslr: Use standard early random function
2020-08-07 17:35 ` Catalin Marinas
2020-08-07 17:48 ` Linus Torvalds
@ 2020-08-07 18:00 ` Guenter Roeck
1 sibling, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2020-08-07 18:00 UTC (permalink / raw)
To: Catalin Marinas
Cc: Linus Torvalds, Will Deacon, linux-arm-kernel, linux-kernel,
Daniel Díaz, tytso, Qian Cai, Mark Brown
On 8/7/20 10:35 AM, Catalin Marinas wrote:
> On Fri, Aug 07, 2020 at 07:45:21AM -0700, Guenter Roeck wrote:
>> Commit 585524081ecd ("random: random.h should include archrandom.h, not
>> the other way around") tries to fix a problem with recursive inclusion
>> of linux/random.h and arch/archrandom.h for arm64. Unfortunately, this
>> results in the following compile error if ARCH_RANDOM is disabled.
>>
>> arch/arm64/kernel/kaslr.c: In function 'kaslr_early_init':
>> arch/arm64/kernel/kaslr.c:128:6: error: implicit declaration of function
>> '__early_cpu_has_rndr'; did you mean '__early_pfn_to_nid'?
>> [-Werror=implicit-function-declaration]
>> if (__early_cpu_has_rndr()) {
>> ^~~~~~~~~~~~~~~~~~~~
>> __early_pfn_to_nid
>> arch/arm64/kernel/kaslr.c:131:7: error: implicit declaration of function
>> '__arm64_rndr' [-Werror=implicit-function-declaration]
>> if (__arm64_rndr(&raw))
>> ^~~~~~~~~~~~
>>
>> Problem is that arch/archrandom.h is only included from linux/random.h if
>> ARCH_RANDOM is enabled. If not, __arm64_rndr() and __early_cpu_has_rndr()
>> are undeclared, causing the problem.
>>
>> Use arch_get_random_seed_long_early() instead of arm64 specific functions
>> to solve the problem.
>>
>> Reported-by: Qian Cai <cai@lca.pw>
>> Fixes: 585524081ecd ("random: random.h should include archrandom.h, not the other way around")
>> Cc: Qian Cai <cai@lca.pw>
>> Cc: Mark Brown <broonie@kernel.org>
>> Reviewed-by: Mark Rutland <mark.rutland@arm.com>
>> Reviewed-by: Mark Brown <broonie@kernel.org>
>> Tested-by: Mark Brown <broonie@kernel.org>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>
>
> Linus, could you please pick this up directly? Otherwise, it will wait
> until we reach -rc1 to avoid basing a branch on a random commit.
>
> (at the moment I can't build Linus' tree at all, fails early with some
> device tree errors)
>
You either need to revert the dts changes, or you have to pull in
"dt-bindings: agilex: add NAND_X_CLK and NAND_ECC_CLK" from
linux-next to fix that problem. I did the latter to test this patch.
Hopefully the problem resolves itself after the clock tree has been
merged (though -next itself is in pretty bad shape too, so by then
we may see other problems).
Guenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] arm64: kaslr: Use standard early random function
2020-08-07 17:48 ` Linus Torvalds
@ 2020-08-07 18:09 ` Catalin Marinas
0 siblings, 0 replies; 5+ messages in thread
From: Catalin Marinas @ 2020-08-07 18:09 UTC (permalink / raw)
To: Linus Torvalds
Cc: Guenter Roeck, Will Deacon, Linux ARM, Linux Kernel Mailing List,
Daniel Díaz, Theodore Ts'o, Qian Cai, Mark Brown
On Fri, Aug 07, 2020 at 10:48:36AM -0700, Linus Torvalds wrote:
> On Fri, Aug 7, 2020 at 10:35 AM Catalin Marinas <catalin.marinas@arm.com> wrote:
> > Acked-by: Catalin Marinas <catalin.marinas@arm.com>
> >
> > Linus, could you please pick this up directly? Otherwise, it will wait
> > until we reach -rc1 to avoid basing a branch on a random commit.
>
> Already done, since I was the cause of the mess. But because I did it
> early, your Acked-by didn't get in.
Thanks (and no problem about the ack).
--
Catalin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-07 18:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-07 14:45 [PATCH v2] arm64: kaslr: Use standard early random function Guenter Roeck
2020-08-07 17:35 ` Catalin Marinas
2020-08-07 17:48 ` Linus Torvalds
2020-08-07 18:09 ` Catalin Marinas
2020-08-07 18:00 ` Guenter Roeck
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).