Skip to contentSkip to conversation

powerpc: get rid of #include <generated/compile.h>

PATCH Applied Masahiro Yamada 3 participants 3 messages Jun 4, 2022 – Jun 9, 2022 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: get rid of #include <generated/compile.h>

You cannot include <generated/compile.h> here because it is generated in init/Makefile but there is no guarantee that it happens before arch/powerpc/mm/nohash/kaslr_booke.c is compiled for parallel builds.

The places where you can reliably include <generated/compile.h> are:

- init/ (because init/Makefile can specify the dependency)
- arch/*/boot/ (because it is compiled after vmlinux)

Commit f231e4333312 ("hexagon: get rid of #include <generated/compile.h>") fixed the last breakage at that time, but powerpc re-added this.

<genearated/compile.h> was unneeded because 'build_str' is almost the same as 'linux_banner' defined in init/version.c

Let's copy the solution from MIPS. (get_random_boot() in arch/mips/kernel/relocate.c)

Fixes 6a38ea1d7b94 ("powerpc/fsl_booke/32: randomize the kernel image offset")

---

If this gets into the mainline before -rc2 or -rc3, I will base my kbuild work on top of this.

 arch/powerpc/mm/nohash/kaslr_booke.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
arch/powerpc/mm/nohash/kaslr_booke.c +2 -6
index 96c38f971603..5f81c076621f 100644
@@ -18,7 +18,6 @@
 #include <asm/prom.h>
 #include <asm/kdump.h>
 #include <mm/mmu_decl.h>
-#include <generated/compile.h>
 #include <generated/utsrelease.h>
 
 struct regions {
@@ -36,10 +35,6 @@ struct regions {
 	int reserved_mem_size_cells;
 };
 
-/* Simplified build-specific string for starting entropy. */
-static const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@"
-		LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION;
-
 struct regions __initdata regions;
 
 static __init void kaslr_get_cmdline(void *fdt)
@@ -70,7 +65,8 @@ static unsigned long __init get_boot_seed(void *fdt)
 {
 	unsigned long hash = 0;
 
-	hash = rotate_xor(hash, build_str, sizeof(build_str));
+	/* build-specific string for starting entropy. */
+	hash = rotate_xor(hash, linux_banner, strlen(linux_banner));
 	hash = rotate_xor(hash, fdt, fdt_totalsize(fdt));
 
 	return hash;
Signature · 1 line
2.32.0
Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines · Masahiro Yamada

You cannot include <generated/compile.h> here because it is generated in init/Makefile but there is no guarantee that it happens before arch/powerpc/mm/nohash/kaslr_booke.c is compiled for parallel builds.

The places where you can reliably include <generated/compile.h> are:

  - init/          (because init/Makefile can specify the dependency)
  - arch/*/boot/   (because it is compiled after vmlinux)

Commit f231e4333312 ("hexagon: get rid of #include <generated/compile.h>") fixed the last breakage at that time, but powerpc re-added this.

<genearated/compile.h> was unneeded because 'build_str' is almost the same as 'linux_banner' defined in init/version.c

Let's copy the solution from MIPS. (get_random_boot() in arch/mips/kernel/relocate.c)

Fixes 6a38ea1d7b94 ("powerpc/fsl_booke/32: randomize the kernel image

offset")

Quoted 8 lines

---

If this gets into the mainline before -rc2 or -rc3, I will base my kbuild work on top of this.

 arch/powerpc/mm/nohash/kaslr_booke.c | 8 ++------

 1 file changed, 2 insertions(+), 6 deletions(-)

-Scott

#2 lore raw
In reply to Masahiro Yamada
Quoted 10 lines · Masahiro Yamada

You cannot include <generated/compile.h> here because it is generated in init/Makefile but there is no guarantee that it happens before arch/powerpc/mm/nohash/kaslr_booke.c is compiled for parallel builds.

The places where you can reliably include <generated/compile.h> are:

- init/ (because init/Makefile can specify the dependency)
- arch/*/boot/ (because it is compiled after vmlinux)

[...]

Applied to powerpc/fixes.

[1/1] powerpc: get rid of #include <generated/compile.h>

      https://git.kernel.org/powerpc/c/7ad4bd887d27c6b6ffbef216f19c19f8fe2b8f52

cheers