Commit 6abe2819 authored by Vasily Gorbik's avatar Vasily Gorbik Committed by Heiko Carstens

s390: enable detection of kernel version from bzImage

Extend "parmarea" to include an offset of the version string, which is
stored as 8-byte big endian value.

To retrieve version string from bzImage reliably, one should check the
presence of "S390EP" ascii string at 0x10008 (available since v3.2),
then read the version string offset from 0x10428 (which has been 0
since v3.2 up to now). The string is null terminated.

Could be retrieved with the following "file" command magic (requires
file v5.34):
8 string \x02\x00\x00\x18\x60\x00\x00\x50\x02\x00\x00\x68\x60\x00\x00\x50\x40\x40\x40\x40\x40\x40\x40\x40 Linux S390
>0x10008       string          S390EP
>>0x10428      bequad          >0
>>>(0x10428.Q) string          >\0             \b, version %s
Reported-by: default avatarPetr Tesarik <ptesarik@suse.com>
Suggested-by: default avatarPetr Tesarik <ptesarik@suse.com>
Reviewed-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
parent 5f9e832c
...@@ -36,7 +36,7 @@ CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char ...@@ -36,7 +36,7 @@ CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o
obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
obj-y += ctype.o text_dma.o obj-y += version.o ctype.o text_dma.o
obj-$(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) += uv.o obj-$(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) += uv.o
obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o
obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
......
...@@ -12,6 +12,7 @@ void print_missing_facilities(void); ...@@ -12,6 +12,7 @@ void print_missing_facilities(void);
unsigned long get_random_base(unsigned long safe_addr); unsigned long get_random_base(unsigned long safe_addr);
extern int kaslr_enabled; extern int kaslr_enabled;
extern const char kernel_version[];
unsigned long read_ipl_report(unsigned long safe_offset); unsigned long read_ipl_report(unsigned long safe_offset);
......
...@@ -361,6 +361,7 @@ ENTRY(startup_kdump) ...@@ -361,6 +361,7 @@ ENTRY(startup_kdump)
.quad 0 # INITRD_SIZE .quad 0 # INITRD_SIZE
.quad 0 # OLDMEM_BASE .quad 0 # OLDMEM_BASE
.quad 0 # OLDMEM_SIZE .quad 0 # OLDMEM_SIZE
.quad kernel_version # points to kernel version string
.org COMMAND_LINE .org COMMAND_LINE
.byte "root=/dev/ram0 ro" .byte "root=/dev/ram0 ro"
......
// SPDX-License-Identifier: GPL-2.0
#include <generated/utsrelease.h>
#include <generated/compile.h>
#include "boot.h"
const char kernel_version[] = UTS_RELEASE
" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ") " UTS_VERSION;
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#define INITRD_SIZE_OFFSET 0x10410 #define INITRD_SIZE_OFFSET 0x10410
#define OLDMEM_BASE_OFFSET 0x10418 #define OLDMEM_BASE_OFFSET 0x10418
#define OLDMEM_SIZE_OFFSET 0x10420 #define OLDMEM_SIZE_OFFSET 0x10420
#define KERNEL_VERSION_OFFSET 0x10428
#define COMMAND_LINE_OFFSET 0x10480 #define COMMAND_LINE_OFFSET 0x10480
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
...@@ -74,7 +75,8 @@ struct parmarea { ...@@ -74,7 +75,8 @@ struct parmarea {
unsigned long initrd_size; /* 0x10410 */ unsigned long initrd_size; /* 0x10410 */
unsigned long oldmem_base; /* 0x10418 */ unsigned long oldmem_base; /* 0x10418 */
unsigned long oldmem_size; /* 0x10420 */ unsigned long oldmem_size; /* 0x10420 */
char pad1[0x10480 - 0x10428]; /* 0x10428 - 0x10480 */ unsigned long kernel_version; /* 0x10428 */
char pad1[0x10480 - 0x10430]; /* 0x10430 - 0x10480 */
char command_line[ARCH_COMMAND_LINE_SIZE]; /* 0x10480 */ char command_line[ARCH_COMMAND_LINE_SIZE]; /* 0x10480 */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment