Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/purgatory: Remove duplicate variable definitions

Currently there are some variables in the purgatory (e.g. kernel_entry)
which are defined twice, once in assembler- and once in c-code. The reason
for this is that these variables are set during purgatory load, where
sanity checks on the corresponding Elf_Sym's are made, while they are used
in assembler-code. Thus adding a second definition in c-code is a handy
workaround to guarantee correct Elf_Sym's are created.

When the purgatory is compiled with -fcommon (default for gcc on s390) this
is no problem because both symbols are merged by the linker. However this
is not required by ISO C and when the purgatory is built with -fno-common
the linker fails with errors like

arch/s390/purgatory/purgatory.o:(.bss+0x18): multiple definition of `kernel_entry'
arch/s390/purgatory/head.o:/.../arch/s390/purgatory/head.S:230: first defined here

Thus remove the duplicate definitions and add the required size and type
information to the assembler definition. Also add -fno-common to the
command line options to prevent similar hacks in the future.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Philipp Rudo and committed by
Martin Schwidefsky
287d6070 c315e693

+20 -42
-6
arch/s390/include/asm/purgatory.h
··· 13 13 14 14 int verify_sha256_digest(void); 15 15 16 - extern u64 kernel_entry; 17 - extern u64 kernel_type; 18 - 19 - extern u64 crash_start; 20 - extern u64 crash_size; 21 - 22 16 #endif /* __ASSEMBLY__ */ 23 17 #endif /* _S390_PURGATORY_H_ */
+1 -1
arch/s390/purgatory/Makefile
··· 21 21 KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes 22 22 KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare 23 23 KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding 24 - KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float 24 + KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float -fno-common 25 25 KBUILD_CFLAGS += $(call cc-option,-fno-PIE) 26 26 KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS)) 27 27
+19 -26
arch/s390/purgatory/head.S
··· 243 243 .quad 0 244 244 .endr 245 245 246 - purgatory_sha256_digest: 247 - .global purgatory_sha256_digest 248 - .rept 32 /* SHA256_DIGEST_SIZE */ 249 - .byte 0 250 - .endr 246 + /* Macro to define a global variable with name and size (in bytes) to be 247 + * shared with C code. 248 + * 249 + * Add the .size and .type attribute to satisfy checks on the Elf_Sym during 250 + * purgatory load. 251 + */ 252 + .macro GLOBAL_VARIABLE name,size 253 + \name: 254 + .global \name 255 + .size \name,\size 256 + .type \name,object 257 + .skip \size,0 258 + .endm 251 259 252 - purgatory_sha_regions: 253 - .global purgatory_sha_regions 254 - .rept 16 * __KEXEC_SHA_REGION_SIZE /* KEXEC_SEGMENTS_MAX */ 255 - .byte 0 256 - .endr 257 - 258 - kernel_entry: 259 - .global kernel_entry 260 - .quad 0 261 - 262 - kernel_type: 263 - .global kernel_type 264 - .quad 0 265 - 266 - crash_start: 267 - .global crash_start 268 - .quad 0 269 - 270 - crash_size: 271 - .global crash_size 272 - .quad 0 260 + GLOBAL_VARIABLE purgatory_sha256_digest,32 261 + GLOBAL_VARIABLE purgatory_sha_regions,16*__KEXEC_SHA_REGION_SIZE 262 + GLOBAL_VARIABLE kernel_entry,8 263 + GLOBAL_VARIABLE kernel_type,8 264 + GLOBAL_VARIABLE crash_start,8 265 + GLOBAL_VARIABLE crash_size,8 273 266 274 267 .align PAGE_SIZE 275 268 stack:
-9
arch/s390/purgatory/purgatory.c
··· 12 12 #include <linux/string.h> 13 13 #include <asm/purgatory.h> 14 14 15 - struct kexec_sha_region purgatory_sha_regions[KEXEC_SEGMENT_MAX]; 16 - u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE]; 17 - 18 - u64 kernel_entry; 19 - u64 kernel_type; 20 - 21 - u64 crash_start; 22 - u64 crash_size; 23 - 24 15 int verify_sha256_digest(void) 25 16 { 26 17 struct kexec_sha_region *ptr, *end;