[PATCH v2 0/3] arm64/boot: Forbid the use of BSS symbols in startup code

Ard Biesheuvel posted 3 patches 7 months, 1 week ago
arch/arm64/include/asm/pgtable.h |  2 -
arch/arm64/kernel/cpufeature.c   | 22 +++----
arch/arm64/kernel/head.S         |  6 +-
arch/arm64/kernel/image-vars.h   | 66 ++++++++++----------
arch/arm64/kernel/pi/pi.h        |  1 +
arch/arm64/kernel/vmlinux.lds.S  | 10 +--
6 files changed, 54 insertions(+), 53 deletions(-)
[PATCH v2 0/3] arm64/boot: Forbid the use of BSS symbols in startup code
Posted by Ard Biesheuvel 7 months, 1 week ago
From: Ard Biesheuvel <ardb@kernel.org>

Move any variables accessed or assigned by the startup code out of BSS,
and into .data, so that we can forbid the use of BSS variables
altogether, by ASSERT()'ing in the linker script that each symbol made
available to the startup code lives before __bss_start in the linker
map.

Changes since v1:
- fix build error due to missing declaration in #1
- work around Clang complaining about the ASSERT() expression in the
  linker script

Cc: Yeoreum Yun <yeoreum.yun@arm.com>

Ard Biesheuvel (3):
  arm64/boot: Move init_pgdir[] and init_idmap_pgdir[] into __pi_
    namespace
  arm64/boot: Move global CPU override variables out of BSS
  arm64/boot: Disallow BSS exports to startup code

 arch/arm64/include/asm/pgtable.h |  2 -
 arch/arm64/kernel/cpufeature.c   | 22 +++----
 arch/arm64/kernel/head.S         |  6 +-
 arch/arm64/kernel/image-vars.h   | 66 ++++++++++----------
 arch/arm64/kernel/pi/pi.h        |  1 +
 arch/arm64/kernel/vmlinux.lds.S  | 10 +--
 6 files changed, 54 insertions(+), 53 deletions(-)


base-commit: 363cd2b81cfdf706bbfc9ec78db000c9b1ecc552
-- 
2.49.0.987.g0cc8ee98dc-goog
Re: [PATCH v2 0/3] arm64/boot: Forbid the use of BSS symbols in startup code
Posted by Will Deacon 7 months ago
On Thu, 08 May 2025 13:43:29 +0200, Ard Biesheuvel wrote:
> Move any variables accessed or assigned by the startup code out of BSS,
> and into .data, so that we can forbid the use of BSS variables
> altogether, by ASSERT()'ing in the linker script that each symbol made
> available to the startup code lives before __bss_start in the linker
> map.
> 
> Changes since v1:
> - fix build error due to missing declaration in #1
> - work around Clang complaining about the ASSERT() expression in the
>   linker script
> 
> [...]

Applied to arm64 (for-next/mm), thanks!

[1/3] arm64/boot: Move init_pgdir[] and init_idmap_pgdir[] into __pi_ namespace
      https://git.kernel.org/arm64/c/93d0d6f8a654
[2/3] arm64/boot: Move global CPU override variables out of BSS
      https://git.kernel.org/arm64/c/4afff6cc9a55
[3/3] arm64/boot: Disallow BSS exports to startup code
      https://git.kernel.org/arm64/c/90530521079e

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
Re: [PATCH v2 0/3] arm64/boot: Forbid the use of BSS symbols in startup code
Posted by Yeoreum Yun 7 months, 1 week ago
Hi Ard,
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Move any variables accessed or assigned by the startup code out of BSS,
> and into .data, so that we can forbid the use of BSS variables
> altogether, by ASSERT()'ing in the linker script that each symbol made
> available to the startup code lives before __bss_start in the linker
> map.
>
> Changes since v1:
> - fix build error due to missing declaration in #1
> - work around Clang complaining about the ASSERT() expression in the
>   linker script
>
> Cc: Yeoreum Yun <yeoreum.yun@arm.com>

Sorry for late.
with commit 117c3b21d3c7 ("arm64: Rework checks for broken Cavium HW in the PI code"):

Tested-by: Yeoreum Yun <yeoreum.yun@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>

Thanks!

>
> Ard Biesheuvel (3):
>   arm64/boot: Move init_pgdir[] and init_idmap_pgdir[] into __pi_
>     namespace
>   arm64/boot: Move global CPU override variables out of BSS
>   arm64/boot: Disallow BSS exports to startup code
>
>  arch/arm64/include/asm/pgtable.h |  2 -
>  arch/arm64/kernel/cpufeature.c   | 22 +++----
>  arch/arm64/kernel/head.S         |  6 +-
>  arch/arm64/kernel/image-vars.h   | 66 ++++++++++----------
>  arch/arm64/kernel/pi/pi.h        |  1 +
>  arch/arm64/kernel/vmlinux.lds.S  | 10 +--
>  6 files changed, 54 insertions(+), 53 deletions(-)
>
>
> base-commit: 363cd2b81cfdf706bbfc9ec78db000c9b1ecc552
> --
> 2.49.0.987.g0cc8ee98dc-goog
>

--
Sincerely,
Yeoreum Yun