From 8058921f586eb21c42c5cc82f404258d93e0ef7c Mon Sep 17 00:00:00 2001 From: Steffen Eiden Date: Wed, 21 Jun 2023 12:29:57 +0200 Subject: [PATCH] Reorganize boot-loader header files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit include/boot/s390.h relies on s390 specific kernel headers. However, some tools used this header for non-s390 code (outside of boot-loaders). To solve this the PSW and PAGE_SIZE definitions are now in separate header files. All includes for s390.h which are not in boot-loader code are replaced with one of psw.h or page.h. This fixes the compilation failure on ppc64le due to conflicting types for `__vector128`. Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/151 Reviewed-by: Jan Höppner Reviewed-by: Marc Hartmayer Signed-off-by: Steffen Eiden --- genprotimg/boot/stage3a.c | 1 - genprotimg/boot/stage3b.c | 2 +- genprotimg/boot/stage3b.h | 2 +- genprotimg/src/common.h | 1 - genprotimg/src/include/pv_hdr_def.h | 2 +- genprotimg/src/pv/pv_comp.c | 1 - genprotimg/src/pv/pv_comps.c | 2 +- genprotimg/src/pv/pv_comps.h | 2 +- genprotimg/src/pv/pv_hdr.c | 2 +- genprotimg/src/pv/pv_hdr.h | 1 - genprotimg/src/pv/pv_image.c | 2 +- genprotimg/src/pv/pv_image.h | 2 +- genprotimg/src/pv/pv_ipib.c | 1 - genprotimg/src/pv/pv_stage3.h | 1 - genprotimg/src/utils/align.h | 2 +- genprotimg/src/utils/crypto.c | 2 +- include/boot/ipl.h | 2 +- include/boot/page.h | 15 ++++++++++++++ include/boot/psw.h | 31 +++++++++++++++++++++++++++++ include/boot/s390.h | 26 +++++------------------- include/libpv/se-hdr.h | 2 +- zipl/include/envblk.h | 2 +- zipl/src/bootmap.c | 1 - 23 files changed, 64 insertions(+), 41 deletions(-) create mode 100644 include/boot/page.h create mode 100644 include/boot/psw.h diff --git a/genprotimg/boot/stage3a.c b/genprotimg/boot/stage3a.c index ae944d23..543b70a0 100644 --- a/genprotimg/boot/stage3a.c +++ b/genprotimg/boot/stage3a.c @@ -11,7 +11,6 @@ #include "stage3a.h" #include "lib/zt_common.h" -#include "boot/s390.h" #include "boot/ipl.h" #include "sclp.h" #include "error.h" diff --git a/genprotimg/boot/stage3b.c b/genprotimg/boot/stage3b.c index 34a087dd..c40e29f1 100644 --- a/genprotimg/boot/stage3b.c +++ b/genprotimg/boot/stage3b.c @@ -11,7 +11,7 @@ #include "stage3b.h" #include "lib/zt_common.h" -#include "boot/s390.h" +#include "boot/psw.h" #include "boot/linux_layout.h" #include "boot/loaders_layout.h" #include "sclp.h" diff --git a/genprotimg/boot/stage3b.h b/genprotimg/boot/stage3b.h index 421f0ea5..90419ed5 100644 --- a/genprotimg/boot/stage3b.h +++ b/genprotimg/boot/stage3b.h @@ -21,7 +21,7 @@ #include -#include "boot/s390.h" +#include "boot/psw.h" /* Must not have any padding included */ struct memblob { diff --git a/genprotimg/src/common.h b/genprotimg/src/common.h index 96b6e610..10b4f5a0 100644 --- a/genprotimg/src/common.h +++ b/genprotimg/src/common.h @@ -13,7 +13,6 @@ #include #include "boot/linux_layout.h" -#include "boot/s390.h" #include "lib/zt_common.h" static const gchar tool_name[] = "genprotimg"; diff --git a/genprotimg/src/include/pv_hdr_def.h b/genprotimg/src/include/pv_hdr_def.h index 1a839a6d..6fc04d4c 100644 --- a/genprotimg/src/include/pv_hdr_def.h +++ b/genprotimg/src/include/pv_hdr_def.h @@ -12,7 +12,7 @@ #include -#include "boot/s390.h" +#include "boot/psw.h" #include "lib/zt_common.h" #include "utils/crypto.h" diff --git a/genprotimg/src/pv/pv_comp.c b/genprotimg/src/pv/pv_comp.c index 41c4b8d8..a9c0d397 100644 --- a/genprotimg/src/pv/pv_comp.c +++ b/genprotimg/src/pv/pv_comp.c @@ -15,7 +15,6 @@ #include #include -#include "boot/s390.h" #include "common.h" #include "utils/align.h" #include "utils/buffer.h" diff --git a/genprotimg/src/pv/pv_comps.c b/genprotimg/src/pv/pv_comps.c index 2d364fd0..310ca4be 100644 --- a/genprotimg/src/pv/pv_comps.c +++ b/genprotimg/src/pv/pv_comps.c @@ -12,7 +12,7 @@ #include #include -#include "boot/s390.h" +#include "boot/psw.h" #include "boot/stage3b.h" #include "common.h" #include "utils/align.h" diff --git a/genprotimg/src/pv/pv_comps.h b/genprotimg/src/pv/pv_comps.h index 891ecdff..a041b6e3 100644 --- a/genprotimg/src/pv/pv_comps.h +++ b/genprotimg/src/pv/pv_comps.h @@ -14,7 +14,7 @@ #include #include -#include "boot/s390.h" +#include "boot/psw.h" #include "boot/stage3b.h" #include "utils/buffer.h" diff --git a/genprotimg/src/pv/pv_hdr.c b/genprotimg/src/pv/pv_hdr.c index f2ac90cf..713c38bc 100644 --- a/genprotimg/src/pv/pv_hdr.c +++ b/genprotimg/src/pv/pv_hdr.c @@ -14,7 +14,7 @@ #include #include -#include "boot/s390.h" +#include "boot/psw.h" #include "include/pv_crypto_def.h" #include "utils/buffer.h" #include "utils/crypto.h" diff --git a/genprotimg/src/pv/pv_hdr.h b/genprotimg/src/pv/pv_hdr.h index fbcc9e9e..7287dbd4 100644 --- a/genprotimg/src/pv/pv_hdr.h +++ b/genprotimg/src/pv/pv_hdr.h @@ -13,7 +13,6 @@ #include #include -#include "boot/s390.h" #include "include/pv_hdr_def.h" #include "utils/crypto.h" #include "utils/buffer.h" diff --git a/genprotimg/src/pv/pv_image.c b/genprotimg/src/pv/pv_image.c index 8399901d..bfc13eef 100644 --- a/genprotimg/src/pv/pv_image.c +++ b/genprotimg/src/pv/pv_image.c @@ -15,7 +15,7 @@ #include #include -#include "boot/s390.h" +#include "boot/psw.h" #include "boot/stage3a.h" #include "common.h" #include "include/pv_crypto_def.h" diff --git a/genprotimg/src/pv/pv_image.h b/genprotimg/src/pv/pv_image.h index 116fb1a9..10182028 100644 --- a/genprotimg/src/pv/pv_image.h +++ b/genprotimg/src/pv/pv_image.h @@ -15,7 +15,7 @@ #include #include -#include "boot/s390.h" +#include "boot/psw.h" #include "utils/buffer.h" #include "pv_args.h" diff --git a/genprotimg/src/pv/pv_ipib.c b/genprotimg/src/pv/pv_ipib.c index 59fe0086..152f1d78 100644 --- a/genprotimg/src/pv/pv_ipib.c +++ b/genprotimg/src/pv/pv_ipib.c @@ -13,7 +13,6 @@ #include #include "boot/ipl.h" -#include "boot/s390.h" #include "common.h" #include "include/pv_hdr_def.h" #include "lib/zt_common.h" diff --git a/genprotimg/src/pv/pv_stage3.h b/genprotimg/src/pv/pv_stage3.h index 364408ee..7b3e8d07 100644 --- a/genprotimg/src/pv/pv_stage3.h +++ b/genprotimg/src/pv/pv_stage3.h @@ -15,7 +15,6 @@ #include #include "boot/ipl.h" -#include "boot/s390.h" #include "boot/stage3b.h" #include "utils/buffer.h" diff --git a/genprotimg/src/utils/align.h b/genprotimg/src/utils/align.h index fa19e58f..57f940fd 100644 --- a/genprotimg/src/utils/align.h +++ b/genprotimg/src/utils/align.h @@ -10,8 +10,8 @@ #ifndef PV_UTILS_ALIGN_H #define PV_UTILS_ALIGN_H -#include "boot/s390.h" #include "lib/zt_common.h" +#include "boot/page.h" #define IS_ALIGNED(addr, size) (!(addr & (size - 1))) diff --git a/genprotimg/src/utils/crypto.c b/genprotimg/src/utils/crypto.c index d4943b6d..e3bbf1b2 100644 --- a/genprotimg/src/utils/crypto.c +++ b/genprotimg/src/utils/crypto.c @@ -24,7 +24,7 @@ #include #include -#include "boot/s390.h" +#include "boot/page.h" #include "common.h" #include "include/pv_crypto_def.h" #include "pv/pv_error.h" diff --git a/include/boot/ipl.h b/include/boot/ipl.h index bc9b7fe2..0427420c 100644 --- a/include/boot/ipl.h +++ b/include/boot/ipl.h @@ -11,7 +11,7 @@ #define IPL_H #include "lib/zt_common.h" -#include "s390.h" +#include "page.h" #define IPL_FLAG_SECURE 0x40 diff --git a/include/boot/page.h b/include/boot/page.h new file mode 100644 index 00000000..6fb94ea0 --- /dev/null +++ b/include/boot/page.h @@ -0,0 +1,15 @@ +/* + * Page related definitions and functions. + * + * Copyright IBM Corp. 2023 + * + * s390-tools is free software; you can redistribute it and/or modify + * it under the terms of the MIT license. See LICENSE for details. + */ + +#ifndef BOOT_PAGE_H +#define BOOT_PAGE_H +#include "lib/zt_common.h" + +#define PAGE_SIZE _AC(4096, UL) +#endif diff --git a/include/boot/psw.h b/include/boot/psw.h new file mode 100644 index 00000000..6b9f9010 --- /dev/null +++ b/include/boot/psw.h @@ -0,0 +1,31 @@ +/* + * Program Status Word related definitions and functions. + * + * Copyright IBM Corp. 2023 + * + * s390-tools is free software; you can redistribute it and/or modify + * it under the terms of the MIT license. See LICENSE for details. + */ + +#ifndef BOOT_PSW_H +#define BOOT_PSW_H + +#include "lib/zt_common.h" + +#define PSW32_ADDR_MASK _AC(0x000000007fffffff, UL) +#define PSW_MASK_BA _AC(0x0000000080000000, UL) +#define PSW_MASK_EA _AC(0x0000000100000000, UL) +#define PSW_MASK_BIT_12 _AC(0x0008000000000000, UL) +#define PSW_LOAD _AC(0x0008000080000000, UL) +#define PSW_DISABLED_WAIT _AC(0x000a000000000000, UL) + +#ifndef __ASSEMBLER__ +#include + +struct psw_t { + uint64_t mask; + uint64_t addr; +} __aligned(8); + +#endif +#endif diff --git a/include/boot/s390.h b/include/boot/s390.h index a50f4cd2..eeef87f1 100644 --- a/include/boot/s390.h +++ b/include/boot/s390.h @@ -1,7 +1,8 @@ /* * s390 related definitions and functions. + * Should only be used for code targeting s390 (bootloader code) * - * Copyright IBM Corp. 2013, 2020 + * Copyright IBM Corp. 2013, 2023 * * s390-tools is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See LICENSE for details. @@ -12,29 +13,22 @@ #include "lib/zt_common.h" #include "boot/sigp.h" +#include "boot/psw.h" +#include "boot/page.h" #define __LC_IPLDEV 0x0c6c #define __LC_OS_INFO 0x0e18 #define LOWCORE_SIZE _AC(0x2000, UL) -#define PAGE_SIZE _AC(4096, UL) - /* Minimum size of a stack frame in bytes */ #define STACK_FRAME_OVERHEAD _AC(160, U) /* Facilities */ #define UNPACK_FACILITY _AC(161, U) -#define PSW32_ADDR_MASK _AC(0x000000007fffffff, UL) -#define PSW_MASK_BA _AC(0x0000000080000000, UL) -#define PSW_MASK_EA _AC(0x0000000100000000, UL) -#define PSW_MASK_BIT_12 _AC(0x0008000000000000, UL) -#define PSW_LOAD _AC(0x0008000080000000, UL) -#define PSW_DISABLED_WAIT _AC(0x000a000000000000, UL) - - #ifndef __ASSEMBLER__ +#include /* * Helper macro for exception table entries @@ -46,16 +40,6 @@ ".long (" #_target ")\n" \ ".previous\n" -struct psw_t { - uint64_t mask; - uint64_t addr; -} __aligned(8); - -struct psw32_t { - uint32_t mask; - uint32_t addr; -} __aligned(8); - void load_wait_psw(uint64_t, struct psw_t *); struct subchannel_id { diff --git a/include/libpv/se-hdr.h b/include/libpv/se-hdr.h index f73372d5..c8d306ea 100644 --- a/include/libpv/se-hdr.h +++ b/include/libpv/se-hdr.h @@ -13,7 +13,7 @@ #include -#include "boot/s390.h" +#include "boot/psw.h" #include "libpv/crypto.h" #include "libpv/macros.h" diff --git a/zipl/include/envblk.h b/zipl/include/envblk.h index 07bf6fe1..9c38c5a3 100644 --- a/zipl/include/envblk.h +++ b/zipl/include/envblk.h @@ -8,7 +8,7 @@ * it under the terms of the MIT license. See LICENSE for details. * */ -#include "boot/s390.h" /* for PAGE_SIZE */ +#include "boot/page.h" #define ZIPL_ENVBLK_SIGNATURE "# zIPL Environment Block\n" #define ENVBLK_DEFAULT_IMPORT_SOURCE "/etc/ziplenv" diff --git a/zipl/src/bootmap.c b/zipl/src/bootmap.c index 1e18ecbf..326f14d1 100644 --- a/zipl/src/bootmap.c +++ b/zipl/src/bootmap.c @@ -25,7 +25,6 @@ #include "lib/util_libc.h" #include "lib/util_part.h" #include "lib/util_path.h" -#include "boot/s390.h" #include "stage3.h" #include "boot.h"