vmlinux.lds.h: Handle decrypted data section with !SMP
PATCH 1/1 vmlinux.lds.h: Handle decrypted data section with !SMP
With x86_64_defconfig and the following configs, there is an orphan section warning:
CONFIG_SMP=nCONFIG_AMD_MEM_ENCRYPT=yCONFIG_HYPERVISOR_GUEST=yCONFIG_KVM=yCONFIG_PARAVIRT=y
ld: warning: orphan section .data..decrypted' from arch/x86/kernel/cpu/vmware.o' being placed in section `.data..decrypted'
ld: warning: orphan section .data..decrypted' from arch/x86/kernel/kvm.o' being placed in section `.data..decrypted'
These sections are created with DEFINE_PER_CPU_DECRYPTED, which ultimately turns into __PCPU_ATTRS, which in turn has a section attribute with a value of PER_CPU_BASE_SECTION + the section name. When CONFIG_SMP is not set, the base section is .data and that is not currently handled in any linker script.
Add .data..decrypted to PERCPU_DECRYPTED_SECTION, which is included in PERCPU_INPUT -> PERCPU_SECTION, which is include in the x86 linker script when either CONFIG_X86_64 or CONFIG_SMP is unset, taking care of the warning.
---
I took the simple fix route with this patch since I highly doubt someone is actually running a CONFIG_AMD_MEM_ENCRYPT=y + CONFIG_SMP=n kernel. If this section should actually be in .data, I can respin.
include/asm-generic/vmlinux.lds.h | 1 + 1 file changed, 1 insertion(+)
include/asm-generic/vmlinux.lds.h +1 -0
@@ -960,6 +960,7 @@#ifdef CONFIG_AMD_MEM_ENCRYPT #define PERCPU_DECRYPTED_SECTION \ . = ALIGN(PAGE_SIZE); \ + *(.data..decrypted) \ *(.data..percpu..decrypted) \ . = ALIGN(PAGE_SIZE);#else
base-commit: 8404c9fbc84b741f66cff7d4934a25dd2c344452
Signature · 1 line
2.31.1.442.g7e39198978
Quoted 24 lines · Nathan Chancellor
With
x86_64_defconfigand the following configs, there is an orphan section warning:
CONFIG_SMP=nCONFIG_AMD_MEM_ENCRYPT=yCONFIG_HYPERVISOR_GUEST=yCONFIG_KVM=yCONFIG_PARAVIRT=yld: warning: orphan section
.data..decrypted' fromarch/x86/kernel/cpu/vmware.o' being placed in section `.data..decrypted'
ld: warning: orphan section.data..decrypted' fromarch/x86/kernel/kvm.o' being placed in section `.data..decrypted'These sections are created with
DEFINE_PER_CPU_DECRYPTED, which ultimately turns into__PCPU_ATTRS, which in turn has a section attribute with a value ofPER_CPU_BASE_SECTION+ the section name. WhenCONFIG_SMPis not set, the base section is .data and that is not currently handled in any linker script.Add .data..decrypted to
PERCPU_DECRYPTED_SECTION, which is included inPERCPU_INPUT->PERCPU_SECTION, which is include in the x86 linker script when eitherCONFIG_X86_64orCONFIG_SMPis unset, taking care of the warning.
Quoted 4 lines
Fixes ac26963a1175 ("percpu: Introduce DEFINE_PER_CPU_DECRYPTED")Reported-by kernel test robot <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Thanks for the patch; LGTM.
Quoted 26 lines
---
I took the simple fix route with this patch since I highly doubt someone is actually running a
CONFIG_AMD_MEM_ENCRYPT=y+CONFIG_SMP=nkernel. If this section should actually be in .data, I can respin.include/asm-generic/vmlinux.lds.h | 1 + 1 file changed, 1 insertion(+)include/asm-generic/vmlinux.lds.h +1
-0@@ -960,6 +960,7 @@#ifdef CONFIG_AMD_MEM_ENCRYPT #define PERCPU_DECRYPTED_SECTION \ . = ALIGN(PAGE_SIZE); \ + *(.data..decrypted) \ *(.data..percpu..decrypted) \ . = ALIGN(PAGE_SIZE);#else base-commit:
8404c9fbc84b741f66cff7d4934a25dd2c344452--
2.31.1.442.g7e39198978
Signature · 2 lines
Thanks, ~Nick Desaulniers
Kees Cook
AppliedQuoted 10 lines · Nathan Chancellor
With
x86_64_defconfigand the following configs, there is an orphan section warning:
CONFIG_SMP=nCONFIG_AMD_MEM_ENCRYPT=yCONFIG_HYPERVISOR_GUEST=yCONFIG_KVM=yCONFIG_PARAVIRT=y[...]
Applied to for-next/orphans, thanks!
[1/1] vmlinux.lds.h: Avoid orphan section with !SMP
https://git.kernel.org/kees/c/d4c639990036
Signature · 1 line
Kees Cook