Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP2
s390-tools.17983
s390-tools-sles15sp2-44-genprotimg-boot-use-C-p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File s390-tools-sles15sp2-44-genprotimg-boot-use-C-pre-processor-for-linker-scrip.patch of Package s390-tools.17983
Subject: [PATCH] [FEAT VS1804] genprotimg: boot: use C pre-processor for linker script generation From: Marc Hartmayer <mhartmay@linux.ibm.com> Summary: genprotimg: Introduce new tool for the creation of PV images Description: genprotimg takes a kernel, host-key documents, optionally an initrd, optionally a file with the kernel command line, and it generates a single, loadable image file. The image consists of a concatenation of a plain text boot loader, the encrypted components for kernel, initrd, and cmdline, and the integrity-protected PV header, containing metadata necessary for running the guest in PV mode. It's possible to use this image file as a kernel for zIPL or for a direct kernel boot using QEMU. Upstream-ID: 2d600570df98a1d26a6f3947ae8c39bcde00b464 Problem-ID: VS1804 Upstream-Description: genprotimg: boot: use C pre-processor for linker script generation Use C pre-processor for linker script generation. This allows the usage of constants in our "linker scripts" `*.lds.S` (actually, these are assembler files, so we can make us of the C pre-processor and its capabilities). Suggested-by: Philipp Rudo <prudo@linux.ibm.com> Reviewed-by: Philipp Rudo <prudo@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- genprotimg/boot/.gitignore | 1 genprotimg/boot/Makefile | 13 ++++- genprotimg/boot/stage3a.lds | 101 ----------------------------------------- genprotimg/boot/stage3a.lds.S | 103 ++++++++++++++++++++++++++++++++++++++++++ genprotimg/boot/stage3b.h | 4 + genprotimg/boot/stage3b.lds | 87 ----------------------------------- genprotimg/boot/stage3b.lds.S | 87 +++++++++++++++++++++++++++++++++++ 7 files changed, 207 insertions(+), 189 deletions(-) --- a/genprotimg/boot/.gitignore +++ b/genprotimg/boot/.gitignore @@ -1,3 +1,4 @@ *.elf +*.lds *.bin *.d --- a/genprotimg/boot/Makefile +++ b/genprotimg/boot/Makefile @@ -39,6 +39,17 @@ all: $(FILES) $(CC) $(ALL_CFLAGS) -c -o $@ $< +# Dependencies for the .lds generation +sources_lds_S = $(wildcard *.lds.S) +dependencies_lds_S = $(sources_lds_s:%.lds.S=.%.lds.d) +# Include all ".lds.d" dependency files for all make targets except for "clean" +ifneq ($(MAKECMDGOALS),clean) +-include $(dependencies_lds_S) +endif + +%.lds: %.lds.S Makefile + $(CPP) -Wp,-MD,.$@.d,-MT,$@ $(INCLUDE_PARMS) -P -C -o $@ $< + # Special rules for zipl object files $(ZIPL_OBJS_C): %.o : $(ZIPL_BOOT_DIR)/%.c $(CC) $(ALL_CFLAGS) -c -o $@ $< @@ -78,6 +89,6 @@ stage3b.elf: head.o stage3b.o stage3b.ld @chmod a-x $@ clean: - rm -f *.o *.elf *.bin *.map .*.d + rm -f *.o *.elf *.bin *.map .*.d *.lds .PHONY: all clean --- a/genprotimg/boot/stage3a.lds +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Memory layout for stage 3a - * ========================== - * - * General memory layout - * --------------------- - * - * 0x00000 - 0x01fff Lowcore - * 0x02000 - 0x05fff Memory allocation (heap) - * 0x0f000 - 0x0ffff Stack - * 0x10000 - 0x10012 Jump to the "actual" stage3a code - * 0x11000 - 0x12fff Stage3a code + arguments (offsets and lengths to the - * actual data: IPIB and UV header) - */ - -OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390") -OUTPUT_ARCH(s390:64-bit) - -ENTRY(_init) - -__heap_size__ = 0x4000; -__stack_size__ = 0x1000; - -SECTIONS -{ - . = 0x0; - - . = 0x2000; - __heap_start = .; - .heap : { - . = . + __heap_size__; - ASSERT(__heap_stop - __heap_start == __heap_size__, - "Heap section doesn't conform to the described memory layout"); - } - __heap_stop = .; - - . = 0xf000; - __stack_start = .; - .stack : { - . = . + __stack_size__; - ASSERT(__stack_end - __stack_start == __stack_size__, - "Stack section doesn't conform to the described memory layout"); - } - __stack_end = .; - - . = 0x10000; - __text_init_start = .; - .text : { - stage3a_init.o(.text.init) - __text_init_stop = ABSOLUTE(.); - /* Text size of text_init must be smaller than 'PARMAREA - IMAGE_ENTRY', - * otherwise the text data could be overwritten by the original zipl stage3 - * boot loader */ - ASSERT(__text_init_stop - __text_init_start < 0x400, - "Text size must be smaller than 'PARMAREA - IMAGE_ENTRY'"); - . = 0x1000; - head.o(.text.start) - *(.text) - } - - .ex_table ALIGN(16) : { - __ex_table_start = .; - *(.ex_table) - __ex_table_stop = .; - } - - .bss ALIGN(16) : { - __bss_start = .; - *(.bss) - __bss_stop = .; - } - - .rodata ALIGN(16) : { - *(.rodata) - *(.rodata.*) - } - - .data ALIGN(16) : { - *(.data) - . = ALIGN(16); - /* The IPIB offset and the UV header offset and size will be - * saved in 'loader_parms' */ - __loader_parms_start = .; - KEEP(*(.loader_parms)); - __loader_parms_stop = .; - ASSERT(__loader_parms_stop - __loader_parms_start == 3 * 8, - "Data size must be equal to 'sizeof(struct stage3a_args)'"); - ASSERT(ABSOLUTE(.) < 0x13000, "Data section doesn't conform to the described memory layout"); - } - - /* List this explicitly as otherwise .note.gnu.build-id will be - * put at 0x0 */ - .notes : { - *(.note.*) - } - - /* Sections to be discarded */ - /DISCARD/ : { - *(.eh_frame) - } -} --- /dev/null +++ b/genprotimg/boot/stage3a.lds.S @@ -0,0 +1,103 @@ +/* + * Memory layout for stage 3a + * ========================== + * + * General memory layout + * --------------------- + * + * 0x00000 - 0x01fff Lowcore + * 0x02000 - 0x05fff Memory allocation (heap) + * 0x0f000 - 0x0ffff Stack + * 0x10000 - 0x10012 Jump to the "actual" stage3a code + * 0x11000 - 0x12fff Stage3a code + arguments (offsets and lengths to the + * actual data: IPIB and UV header) + */ + +#include "stage3a.h" +#include "common_memory_layout.h" + +OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390") +OUTPUT_ARCH(s390:64-bit) + +ENTRY(_init) + +SECTIONS +{ + . = 0x0; + + . = HEAP_ADDRESS; + __heap_start = .; + .heap : { + . = . + HEAP_SIZE; + ASSERT(__heap_stop - __heap_start == HEAP_SIZE, + "Heap section doesn't conform to the described memory layout"); + } + __heap_stop = .; + + . = STACK_ADDRESS; + __stack_start = .; + .stack : { + . = . + STACK_SIZE; + ASSERT(__stack_end - __stack_start == STACK_SIZE, + "Stack section doesn't conform to the described memory layout"); + } + __stack_end = .; + + . = STAGE3A_INIT_ENTRY; + __text_init_start = .; + .text : { + stage3a_init.o(.text.init) + __text_init_stop = ABSOLUTE(.); + /* Text size of text_init must be smaller than 'PARMAREA - IMAGE_ENTRY', + * otherwise the text data could be overwritten by the original zipl stage3 + * boot loader */ + ASSERT(__text_init_stop - __text_init_start < PARMAREA - IMAGE_ENTRY, + "Text size must be smaller than 'PARMAREA - IMAGE_ENTRY'"); + . = 0x1000; + ASSERT(ABSOLUTE(.) == STAGE3A_ENTRY, + "Text section doesn't conform to the described memory layout"); + head.o(.text.start) + *(.text) + } + + .ex_table ALIGN(16) : { + __ex_table_start = .; + *(.ex_table) + __ex_table_stop = .; + } + + .bss ALIGN(16) : { + __bss_start = .; + *(.bss) + __bss_stop = .; + } + + .rodata ALIGN(16) : { + *(.rodata) + *(.rodata.*) + } + + .data ALIGN(16) : { + *(.data) + . = ALIGN(16); + /* The IPIB offset and the UV header offset and size will be + * saved in 'loader_parms' */ + __loader_parms_start = .; + KEEP(*(.loader_parms)); + __loader_parms_stop = .; + ASSERT(__loader_parms_stop - __loader_parms_start == 3 * 8, + "Data size must be equal to 'sizeof(struct stage3a_args)'"); + ASSERT(ABSOLUTE(.) < 0x13000, "Data section doesn't conform to the described memory layout"); + } + + /* List this explicitly as otherwise .note.gnu.build-id will be + * put at 0x0 */ + .notes : { + *(.note.*) + } + + /* Sections to be discarded */ + /DISCARD/ : { + *(.eh_frame) + } +} --- a/genprotimg/boot/stage3b.h +++ b/genprotimg/boot/stage3b.h @@ -11,6 +11,10 @@ #define STAGE3B_H #include "lib/zt_common.h" +#include "boot/loaders_layout.h" + +#define STAGE3B_ENTRY STAGE3_ENTRY +#define STAGE3B_LOAD_ADDRESS STAGE3B_ENTRY #ifndef __ASSEMBLER__ --- a/genprotimg/boot/stage3b.lds +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Memory layout for stage 3b - * ========================== - * - * General memory layout - * --------------------- - * - * 0x00000 - 0x01fff Lowcore - * 0x02000 - 0x05fff Memory allocation (heap) - * 0x0a000 - 0x0efff Stage3b code - * 0x0f000 - 0x0ffff Stack - */ - -OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390") -OUTPUT_ARCH(s390:64-bit) - -ENTRY(_start) - -__heap_size__ = 0x4000; -__stack_size__ = 0x1000; - -SECTIONS -{ - . = 0x0; - - . = 0x2000; - __heap_start = .; - .heap : { - . = . + __heap_size__; - ASSERT(__heap_stop - __heap_start == __heap_size__, - "Heap section doesn't conform to the described memory layout"); - } - __heap_stop = .; - - . = 0xa000; - .text : { - head.o(.text.start) - *(.text) - } - - .ex_table ALIGN(16) : { - __ex_table_start = .; - *(.ex_table) - __ex_table_stop = .; - } - - .bss ALIGN(16) : { - __bss_start = .; - *(.bss) - __bss_stop = .; - } - - .rodata ALIGN(16) : { - *(.rodata) - *(.rodata.*) - } - - .data ALIGN(16) : { - *(.data) - . = ALIGN(16); - __loader_parms_start = .; - KEEP(*(.loader_parms)); - __loader_parms_end = .; - ASSERT(__loader_parms_end - __loader_parms_start == 3 * 16 + 16, - "Data size must be equal to 'sizeof(struct stage3b_args)'"); - } - - . = 0xf000; - __stack_start = .; - .stack : { - . = . + __stack_size__; - ASSERT(__stack_end - __stack_start == __stack_size__, - "Stack section doesn't conform to the described memory layout"); - } - __stack_end = .; - - /* List this explicitly as otherwise .note.gnu.build-id will be - * put at 0x0 */ - .notes : { - *(.note.*) - } - - /* Sections to be discarded */ - /DISCARD/ : { - *(.eh_frame) - } -} --- /dev/null +++ b/genprotimg/boot/stage3b.lds.S @@ -0,0 +1,87 @@ +/* + * Memory layout for stage 3b + * ========================== + * + * General memory layout + * --------------------- + * + * 0x00000 - 0x01fff Lowcore + * 0x02000 - 0x05fff Memory allocation (heap) + * 0x0a000 - 0x0efff Stage3b code + * 0x0f000 - 0x0ffff Stack + */ + +#include "stage3b.h" +#include "common_memory_layout.h" + +OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390") +OUTPUT_ARCH(s390:64-bit) + +ENTRY(_start) + +SECTIONS +{ + . = 0x0; + + . = HEAP_ADDRESS; + __heap_start = .; + .heap : { + . = . + HEAP_SIZE; + ASSERT(__heap_stop - __heap_start == HEAP_SIZE, + "Heap section doesn't conform to the described memory layout"); + } + __heap_stop = .; + + . = STAGE3B_ENTRY; + .text : { + head.o(.text.start) + *(.text) + } + + .ex_table ALIGN(16) : { + __ex_table_start = .; + *(.ex_table) + __ex_table_stop = .; + } + + .bss ALIGN(16) : { + __bss_start = .; + *(.bss) + __bss_stop = .; + } + + .rodata ALIGN(16) : { + *(.rodata) + *(.rodata.*) + } + + .data ALIGN(16) : { + *(.data) + . = ALIGN(16); + __loader_parms_start = .; + KEEP(*(.loader_parms)); + __loader_parms_end = .; + ASSERT(__loader_parms_end - __loader_parms_start == 3 * 16 + 16, + "Data size must be equal to 'sizeof(struct stage3b_args)'"); + } + + . = STACK_ADDRESS; + __stack_start = .; + .stack : { + . = . + STACK_SIZE; + ASSERT(__stack_end - __stack_start == STACK_SIZE, + "Stack section doesn't conform to the described memory layout"); + } + __stack_end = .; + + /* List this explicitly as otherwise .note.gnu.build-id will be + * put at 0x0 */ + .notes : { + *(.note.*) + } + + /* Sections to be discarded */ + /DISCARD/ : { + *(.eh_frame) + } +}
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor