s390-tools/s390-tools-sles15sp2-44-genprotimg-boot-use-C-pre-processor-for-linker-scrip.patch
Mark Post 30232e2023 Accepting request 786614 from home:markkp:branches:Base:System
- Added the following patches for bsc#1166850
  zipl: fix secure boot config handling:
  * s390-tools-sles15sp2-01-zipl-Add-missing-options-to-help-output.patch
  * s390-tools-sles15sp2-02-zipl-allow-stand-alone-secure-option-on-command-l.patch
  * s390-tools-sles15sp2-03-zipl-correct-secure-boot-config-handling.patch
  * s390-tools-sles15sp2-04-zipl-fix-zipl.conf-man-page-example-for-secure-boot.patch
- Modified the spec file so that the kernel used for the SCSI dump
  tool is named zfcpdump-image instead of zfcpdump_part.image. This
  is to match the new version of zipl that expects this new file name.
  (bsc#1166851)
- Added the following patches to implement jsc#SLE-7471, Enhanced
  tooling for kvm guest images (bsc#1165549):
  * s390-tools-sles15sp2-01-zipl-fix-Wdiscarded-qualifiers.patch
  * s390-tools-sles15sp2-02-zipl-fix-Waddress-of-packed-member.patch
  * s390-tools-sles15sp2-03-zipl-remove-some-useless-__packed___-attributes.patch
  * s390-tools-sles15sp2-04-zipl-Fix-entry-point-for-stand-alone-kdump.patch
  * s390-tools-sles15sp2-05-zipl-Fix-dependency-generation-in-zipl-boot.patch
  * s390-tools-sles15sp2-06-zipl-Make-use-of-__packed-macro.patch
  * s390-tools-sles15sp2-07-zipl-define-__section-macro-and-make-use-of-it.patch
  * s390-tools-sles15sp2-08-zipl-Make-use-of-__noreturn-macro.patch
  * s390-tools-sles15sp2-09-zipl-Define-__noinline-macro-and-make-use-of-it.patch
  * s390-tools-sles15sp2-10-zipl-stage3-Mark-start_kernel-__noreturn.patch
  * s390-tools-sles15sp2-11-zipl-sclp-Remove-duplicate-macros.patch
  * s390-tools-sles15sp2-12-zipl-Make-address-size-mask-macros-UL.patch
  * s390-tools-sles15sp2-13-zipl-libc-Use-stdint.h-instead-of-self-defined-macro.patch
  * s390-tools-sles15sp2-14-zipl-Consolidate-IMAGE-macros.patch
  * s390-tools-sles15sp2-15-zipl-Consolidate-STAGE-2-3-macros.patch
  * s390-tools-sles15sp2-16-zipl-stfle-use-uint64_t-instead-of-u64.patch
  * s390-tools-sles15sp2-17-zipl-boot-fix-comment-in-stage3.lds.patch
  * s390-tools-sles15sp2-18-lib-zt_common-add-STATIC_ASSERT-macro.patch
  * s390-tools-sles15sp2-19-zipl-use-STATIC_ASSERT-macro-for-no-padding-verifica.patch
  * s390-tools-sles15sp2-20-Support-lib-zt_common.h-to-be-used-in-assembler-and-.patch
  * s390-tools-sles15sp2-21-zipl-move-IPL-related-definitions-into-separate-head.patch
  * s390-tools-sles15sp2-22-zipl-move-SIGP-related-functions-and-definitions-int.patch
  * s390-tools-sles15sp2-23-zipl-add-SIGP_SET_ARCHITECTURE-to-sigp.h-and-use-it.patch
  * s390-tools-sles15sp2-24-zipl-stage3-make-IPL_DEVICE-definition-consistent-wi.patch
  * s390-tools-sles15sp2-25-zipl-move-Linux-layout-definitions-into-separate-hea.patch
  * s390-tools-sles15sp2-26-zipl-tape0-use-constants-defined-in-linux_layout.h.patch
  * s390-tools-sles15sp2-27-zipl-use-STAGE3_ENTRY-for-STAGE3_LOAD_ADDRESS.patch
  * s390-tools-sles15sp2-28-zipl-move-loaders-layout-definitions-into-separate-h.patch
  * s390-tools-sles15sp2-29-zipl-s390.h-rename-inline-macro-into-__always_inline.patch
  * s390-tools-sles15sp2-30-zipl-move-__always_inline-barrier-__pa32-pa-to-zt_co.patch
  * s390-tools-sles15sp2-31-zipl-make-BLK_PWRT-unsigned-int.patch
  * s390-tools-sles15sp2-32-Consolidate-MIN-and-MAX-macros.patch
  * s390-tools-sles15sp2-33-zipl-remove-libc.h-include-in-s390.h.patch
  * s390-tools-sles15sp2-34-zipl-move-s390.h-to-include-boot-s390.h.patch
  * s390-tools-sles15sp2-35-zipl-libc-include-s390.h.patch
  * s390-tools-sles15sp2-36-include-boot-s390.h-move-panic-and-panic_notify-to-l.patch
  * s390-tools-sles15sp2-37-include-boot-s390.h-fixes-for-Werror-sign-conversion.patch
  * s390-tools-sles15sp2-38-zipl-refactor-all-EBCDIC-code-into-separate-files.patch
  * s390-tools-sles15sp2-39-zipl-sclp-add-macros-for-the-control-program-masks.patch
  * s390-tools-sles15sp2-40-zipl-sclp-add-sclp_print_ascii.patch
  * s390-tools-sles15sp2-41-zipl-libc-printf-print-on-linemode-and-ASCII-console.patch
  * s390-tools-sles15sp2-42-Consolidate-ALIGN-__ALIGN_MASK-ARRAY_SIZE-macros.patch
  * s390-tools-sles15sp2-43-genprotimg-boot-initial-bootloader-support.patch
  * s390-tools-sles15sp2-44-genprotimg-boot-use-C-pre-processor-for-linker-scrip.patch
  * s390-tools-sles15sp2-45-genprotimg-add-relocator-for-stage3b.patch
  * s390-tools-sles15sp2-46-README.md-remove-useless-empty-line.patch
  * s390-tools-sles15sp2-47-include-boot-s390.h-add-guard-for-struct-__vector128.patch
  * s390-tools-sles15sp2-48-genprotimg-introduce-new-tool-for-the-creation-of-PV.patch
- Added a BuildRequires for glib2-devel to support the new feature.
- Added a %dir entry for /usr/share/s390-tools/genprotimg

OBS-URL: https://build.opensuse.org/request/show/786614
OBS-URL: https://build.opensuse.org/package/show/Base:System/s390-tools?expand=0&rev=92
2020-03-19 22:52:46 +00:00

480 lines
12 KiB
Diff

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)
+ }
+}