Skip to content

Commit 9bceb80

Browse files
groecktorvalds
authored andcommitted
arm64: kaslr: Use standard early random function
Commit 5855240 ("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)) ^~~~~~~~~~~~ The 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: 5855240 ("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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0f5d0a4 commit 9bceb80

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

arch/arm64/kernel/kaslr.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ u64 __init kaslr_early_init(u64 dt_phys)
8484
void *fdt;
8585
u64 seed, offset, mask, module_range;
8686
const u8 *cmdline, *str;
87+
unsigned long raw;
8788
int size;
8889

8990
/*
@@ -122,15 +123,12 @@ u64 __init kaslr_early_init(u64 dt_phys)
122123
}
123124

124125
/*
125-
* Mix in any entropy obtainable architecturally, open coded
126-
* since this runs extremely early.
126+
* Mix in any entropy obtainable architecturally if enabled
127+
* and supported.
127128
*/
128-
if (__early_cpu_has_rndr()) {
129-
unsigned long raw;
130129

131-
if (__arm64_rndr(&raw))
132-
seed ^= raw;
133-
}
130+
if (arch_get_random_seed_long_early(&raw))
131+
seed ^= raw;
134132

135133
if (!seed) {
136134
kaslr_status = KASLR_DISABLED_NO_SEED;

0 commit comments

Comments
 (0)