diff --git a/include/boot/os_info.h b/include/boot/os_info.h new file mode 100644 index 00000000..1793771b --- /dev/null +++ b/include/boot/os_info.h @@ -0,0 +1,41 @@ +/* + * zipl - zSeries Initial Program Loader tool + * + * os-info definitions + * + * 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. + */ + +#ifndef OS_INFO_H +#define OS_INFO_H + +#include "lib/zt_common.h" +#include + +#define OS_INFO_MAGIC 0x4f53494e464f535aULL /* OSINFOSZ */ +#define OS_INFO_CSUM_SIZE (sizeof(struct os_info) - offsetof(struct os_info, version_major)) + +#define OS_INFO_VMCOREINFO 0 +#define OS_INFO_REIPL_BLOCK 1 + +struct os_info_entry { + uint64_t addr; + uint64_t size; + uint32_t csum; +} __packed; + +struct os_info { + uint64_t magic; + uint32_t csum; + uint16_t version_major; + uint16_t version_minor; + uint64_t crashkernel_addr; + uint64_t crashkernel_size; + struct os_info_entry entry[2]; + uint8_t reserved[4024]; +} __packed; + +#endif /* OS_INFO_H */ diff --git a/zipl/boot/kdump.c b/zipl/boot/kdump.c index eb3ae07c..dd711f79 100644 --- a/zipl/boot/kdump.c +++ b/zipl/boot/kdump.c @@ -3,7 +3,7 @@ * * Stand-alone kdump support * - * Copyright IBM Corp. 2013, 2017 + * 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. @@ -14,13 +14,14 @@ #include "libc.h" #include "menu.h" #include "boot/s390.h" +#include "boot/os_info.h" void kdump_failed(unsigned long reason) { panic(reason, "Dump failed: Check disabled wait code"); } -void os_info_check(struct os_info *os_info) +void kdump_os_info_check(struct os_info *os_info) { if (os_info == NULL) kdump_failed(EOS_INFO_MISSING); @@ -30,7 +31,7 @@ void os_info_check(struct os_info *os_info) kdump_failed(EOS_INFO_MISSING); if (os_info->magic != OS_INFO_MAGIC) kdump_failed(EOS_INFO_MISSING); - if (csum_partial(&os_info->version_major, OS_INF0_CSUM_SIZE, 0) != + if (csum_partial(&os_info->version_major, OS_INFO_CSUM_SIZE, 0) != os_info->csum) kdump_failed(EOS_INFO_CSUM_FAILED); if (os_info->version_major > OS_INFO_VERSION_MAJOR_SUPPORTED) diff --git a/zipl/boot/kdump.h b/zipl/boot/kdump.h index f81d20cf..4a62fb17 100644 --- a/zipl/boot/kdump.h +++ b/zipl/boot/kdump.h @@ -3,7 +3,7 @@ * * Stand-alone kdump definitions * - * Copyright IBM Corp. 2013, 2017 + * 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. @@ -13,34 +13,11 @@ #ifndef KDUMP_H #define KDUMP_H -#include "libc.h" -#include "boot/s390.h" +#include "boot/os_info.h" #define OS_INFO_VERSION_MAJOR_SUPPORTED 1 -#define OS_INFO_MAGIC 0x4f53494e464f535aULL /* OSINFOSZ */ -#define OS_INF0_CSUM_SIZE 4084 -#define OS_INFO_VMCOREINFO 0 -#define OS_INFO_REIPL_BLOCK 1 - -struct os_info_entry { - uint64_t addr; - uint64_t size; - uint32_t csum; -} __packed; - -struct os_info { - uint64_t magic; - uint32_t csum; - uint16_t version_major; - uint16_t version_minor; - uint64_t crashkernel_addr; - uint64_t crashkernel_size; - struct os_info_entry entry[2]; - uint8_t reserved[4024]; -} __packed; - -void os_info_check(struct os_info *os_info); +void kdump_os_info_check(struct os_info *os_info); void kdump_failed(unsigned long reason); #endif /* KDUMP_H */ diff --git a/zipl/boot/kdump2.c b/zipl/boot/kdump2.c index f461c4d7..6b796ac9 100644 --- a/zipl/boot/kdump2.c +++ b/zipl/boot/kdump2.c @@ -3,7 +3,7 @@ * * Stand-alone kdump support (stage 2) * - * Copyright IBM Corp. 2013, 2017 + * 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. @@ -14,6 +14,7 @@ #include "libc.h" #include "menu.h" #include "stage2.h" +#include "boot/os_info.h" /* * Copy crashkernel memory from [0, crash size] to @@ -31,7 +32,7 @@ void kdump_stage2(unsigned long config_nr) if (!(__stage2_params.config_kdump & (0x1 << config_nr))) return; - os_info_check(os_info); + kdump_os_info_check(os_info); /* Copy crashkernel memory */ crash_base = (void *) os_info->crashkernel_addr; diff --git a/zipl/boot/kdump3.c b/zipl/boot/kdump3.c index caa730c1..fd328e09 100644 --- a/zipl/boot/kdump3.c +++ b/zipl/boot/kdump3.c @@ -3,7 +3,7 @@ * * Stand-alone kdump support (stage 3) * - * Copyright IBM Corp. 2013, 2017 + * 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. @@ -14,7 +14,7 @@ #include "libc.h" #include "sclp_stage3.h" #include "stage3.h" - +#include "boot/os_info.h" /* * Copy memory from HSA and exit in case of an error @@ -54,7 +54,7 @@ static void kdump_stage3_scsi(unsigned long *base, unsigned long *size) } else { os_info = (void *) os_info_addr; } - os_info_check(os_info); + kdump_os_info_check(os_info); crash_base = os_info->crashkernel_addr; crash_size = os_info->crashkernel_size; crash_end = crash_base + crash_size;