OSDN Git Service

s390/purgatory: Remove duplicate variable definitions
authorPhilipp Rudo <prudo@linux.ibm.com>
Wed, 27 Jun 2018 10:03:43 +0000 (12:03 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 6 Jul 2018 06:47:51 +0000 (08:47 +0200)
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>
arch/s390/include/asm/purgatory.h
arch/s390/purgatory/Makefile
arch/s390/purgatory/head.S
arch/s390/purgatory/purgatory.c

index 6090670..e297bcf 100644 (file)
 
 int verify_sha256_digest(void);
 
-extern u64 kernel_entry;
-extern u64 kernel_type;
-
-extern u64 crash_start;
-extern u64 crash_size;
-
 #endif /* __ASSEMBLY__ */
 #endif /* _S390_PURGATORY_H_ */
index abfa8c7..8d61218 100644 (file)
@@ -21,7 +21,7 @@ LDFLAGS_purgatory.ro += -z nodefaultlib
 KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes
 KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare
 KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding
-KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float
+KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float -fno-common
 KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
 KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
 
index 660c96a..2e3707b 100644 (file)
@@ -243,33 +243,26 @@ gprregs:
        .quad   0
        .endr
 
-purgatory_sha256_digest:
-       .global purgatory_sha256_digest
-       .rept   32      /* SHA256_DIGEST_SIZE */
-       .byte   0
-       .endr
-
-purgatory_sha_regions:
-       .global purgatory_sha_regions
-       .rept   16 * __KEXEC_SHA_REGION_SIZE    /* KEXEC_SEGMENTS_MAX */
-       .byte   0
-       .endr
-
-kernel_entry:
-       .global kernel_entry
-       .quad   0
-
-kernel_type:
-       .global kernel_type
-       .quad   0
-
-crash_start:
-       .global crash_start
-       .quad   0
+/* Macro to define a global variable with name and size (in bytes) to be
+ * shared with C code.
+ *
+ * Add the .size and .type attribute to satisfy checks on the Elf_Sym during
+ * purgatory load.
+ */
+.macro GLOBAL_VARIABLE name,size
+\name:
+       .global \name
+       .size   \name,\size
+       .type   \name,object
+       .skip   \size,0
+.endm
 
-crash_size:
-       .global crash_size
-       .quad   0
+GLOBAL_VARIABLE purgatory_sha256_digest,32
+GLOBAL_VARIABLE purgatory_sha_regions,16*__KEXEC_SHA_REGION_SIZE
+GLOBAL_VARIABLE kernel_entry,8
+GLOBAL_VARIABLE kernel_type,8
+GLOBAL_VARIABLE crash_start,8
+GLOBAL_VARIABLE crash_size,8
 
        .align  PAGE_SIZE
 stack:
index 4e2beb3..3528e6d 100644 (file)
 #include <linux/string.h>
 #include <asm/purgatory.h>
 
-struct kexec_sha_region purgatory_sha_regions[KEXEC_SEGMENT_MAX];
-u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE];
-
-u64 kernel_entry;
-u64 kernel_type;
-
-u64 crash_start;
-u64 crash_size;
-
 int verify_sha256_digest(void)
 {
        struct kexec_sha_region *ptr, *end;