Skip to content

Commit 834979c

Browse files
committed
s390/boot: convert initial lowcore to C
Convert initial lowcore to C and use proper defines and structures to initialize it. This should make the z/VM ipl procedure a bit less magic. Acked-by: Peter Oberparleiter <[email protected]> Reviewed-by: Vasily Gorbik <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent 67a9c42 commit 834979c

File tree

5 files changed

+103
-56
lines changed

5 files changed

+103
-56
lines changed

arch/s390/boot/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
3737

3838
obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o
3939
obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
40-
obj-y += version.o pgm_check_info.o ctype.o
40+
obj-y += version.o pgm_check_info.o ctype.o ipl_data.o
4141
obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o
4242
obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o
4343
obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o

arch/s390/boot/boot.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
#ifndef BOOT_BOOT_H
33
#define BOOT_BOOT_H
44

5-
#include <asm/extable.h>
65
#include <linux/types.h>
76

7+
#define IPL_START 0x200
8+
9+
#ifndef __ASSEMBLY__
10+
811
void startup_kernel(void);
912
unsigned long detect_memory(void);
1013
bool is_ipl_block_dump(void);
@@ -31,4 +34,5 @@ extern char _stack_start[], _stack_end[];
3134

3235
unsigned long read_ipl_report(unsigned long safe_offset);
3336

37+
#endif /* __ASSEMBLY__ */
3438
#endif /* BOOT_BOOT_H */

arch/s390/boot/head.S

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -27,61 +27,15 @@
2727
#include <asm/page.h>
2828
#include <asm/ptrace.h>
2929
#include <asm/sclp.h>
30+
#include "boot.h"
3031

3132
#define ARCH_OFFSET 4
3233

3334
#define EP_OFFSET 0x10008
3435
#define EP_STRING "S390EP"
35-
36-
#define IPL_START 0x200
36+
#define IPL_BS 0x730
3737

3838
__HEAD
39-
40-
#define IPL_BS 0x730
41-
.org 0
42-
.long 0x00080000,0x80000000+IPL_START # The first 24 bytes are loaded
43-
.long 0x02000018,0x60000050 # by ipl to addresses 0-23.
44-
.long 0x02000068,0x60000050 # (a PSW and two CCWs).
45-
.fill 80-24,1,0x40 # bytes 24-79 are discarded !!
46-
.long 0x020000f0,0x60000050 # The next 160 byte are loaded
47-
.long 0x02000140,0x60000050 # to addresses 0x18-0xb7
48-
.long 0x02000190,0x60000050 # They form the continuation
49-
.long 0x020001e0,0x60000050 # of the CCW program started
50-
.long 0x02000230,0x60000050 # by ipl and load the range
51-
.long 0x02000280,0x60000050 # 0x0f0-0x730 from the image
52-
.long 0x020002d0,0x60000050 # to the range 0x0f0-0x730
53-
.long 0x02000320,0x60000050 # in memory. At the end of
54-
.long 0x02000370,0x60000050 # the channel program the PSW
55-
.long 0x020003c0,0x60000050 # at location 0 is loaded.
56-
.long 0x02000410,0x60000050 # Initial processing starts
57-
.long 0x02000460,0x60000050 # at 0x200 = iplstart.
58-
.long 0x020004b0,0x60000050
59-
.long 0x02000500,0x60000050
60-
.long 0x02000550,0x60000050
61-
.long 0x020005a0,0x60000050
62-
.long 0x020005f0,0x60000050
63-
.long 0x02000640,0x60000050
64-
.long 0x02000690,0x60000050
65-
.long 0x020006e0,0x20000050
66-
67-
# The restart psw points to ipl_entry, which allows to load a kernel image
68-
# into memory and starting it by a psw restart on any cpu.
69-
# All other default psw new locations contain a disabled wait psw where the
70-
# address indicates which psw was loaded.
71-
.org __LC_RST_NEW_PSW
72-
.quad 0,IPL_START
73-
.org __LC_EXT_NEW_PSW
74-
.quad 0x0002000180000000,__LC_EXT_NEW_PSW
75-
.org __LC_SVC_NEW_PSW
76-
.quad 0x0002000180000000,__LC_SVC_NEW_PSW
77-
.org __LC_PGM_NEW_PSW
78-
.quad 0x0002000180000000,__LC_PGM_NEW_PSW
79-
.org __LC_MCK_NEW_PSW
80-
.quad 0x0002000180000000,__LC_MCK_NEW_PSW
81-
.org __LC_IO_NEW_PSW
82-
.quad 0x0002000180000000,__LC_IO_NEW_PSW
83-
84-
.org IPL_START
8539
ipl_start:
8640
j .Liplcont
8741
#
@@ -279,10 +233,10 @@ ipl_start:
279233
# this is called either by the ipl loader or directly by PSW restart
280234
# or linload or SALIPL
281235
#
282-
.org STARTUP_NORMAL_OFFSET
236+
.org STARTUP_NORMAL_OFFSET - IPL_START
283237
SYM_CODE_START(startup)
284238
j startup_normal
285-
.org EP_OFFSET
239+
.org EP_OFFSET - IPL_START
286240
#
287241
# This is a list of s390 kernel entry points. At address 0x1000f the number of
288242
# valid entry points is stored.
@@ -294,7 +248,7 @@ SYM_CODE_START(startup)
294248
#
295249
# kdump startup-code, running in 64 bit absolute addressing mode
296250
#
297-
.org STARTUP_KDUMP_OFFSET
251+
.org STARTUP_KDUMP_OFFSET - IPL_START
298252
j startup_kdump
299253
SYM_CODE_END(startup)
300254
SYM_CODE_START_LOCAL(startup_normal)
@@ -384,7 +338,7 @@ SYM_CODE_END(startup_pgm_check_handler)
384338
# params at 10400 (setup.h)
385339
# Must be keept in sync with struct parmarea in setup.h
386340
#
387-
.org PARMAREA
341+
.org PARMAREA - IPL_START
388342
SYM_DATA_START(parmarea)
389343
.quad 0 # IPL_DEVICE
390344
.quad 0 # INITRD_START
@@ -394,8 +348,8 @@ SYM_DATA_START(parmarea)
394348
.quad kernel_version # points to kernel version string
395349
.quad COMMAND_LINE_SIZE
396350

397-
.org COMMAND_LINE
351+
.org COMMAND_LINE - IPL_START
398352
.byte "root=/dev/ram0 ro"
399353
.byte 0
400-
.org PARMAREA+__PARMAREA_SIZE
354+
.org PARMAREA+__PARMAREA_SIZE - IPL_START
401355
SYM_DATA_END(parmarea)

arch/s390/boot/ipl_data.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/compat.h>
4+
#include <linux/ptrace.h>
5+
#include <asm/cio.h>
6+
#include <asm/asm-offsets.h>
7+
#include "boot.h"
8+
9+
#define CCW0(cmd, addr, cnt, flg) \
10+
{ .cmd_code = cmd, .cda = addr, .count = cnt, .flags = flg, }
11+
12+
#define PSW_MASK_DISABLED (PSW_MASK_WAIT | PSW_MASK_EA | PSW_MASK_BA)
13+
14+
struct ipl_lowcore {
15+
psw_t32 ipl_psw; /* 0x0000 */
16+
struct ccw0 ccwpgm[2]; /* 0x0008 */
17+
u8 fill[56]; /* 0x0018 */
18+
struct ccw0 ccwpgmcc[20]; /* 0x0050 */
19+
u8 pad_0xf0[0x01a0-0x00f0]; /* 0x00f0 */
20+
psw_t restart_psw; /* 0x01a0 */
21+
psw_t external_new_psw; /* 0x01b0 */
22+
psw_t svc_new_psw; /* 0x01c0 */
23+
psw_t program_new_psw; /* 0x01d0 */
24+
psw_t mcck_new_psw; /* 0x01e0 */
25+
psw_t io_new_psw; /* 0x01f0 */
26+
};
27+
28+
/*
29+
* Initial lowcore for IPL: the first 24 bytes are loaded by IPL to
30+
* addresses 0-23 (a PSW and two CCWs). Bytes 24-79 are discarded.
31+
* The next 160 bytes are loaded to addresses 0x18-0xb7. They form
32+
* the continuation of the CCW program started by IPL and load the
33+
* range 0x0f0-0x730 from the image to the range 0x0f0-0x730 in
34+
* memory. At the end of the channel program the PSW at location 0 is
35+
* loaded.
36+
* Initial processing starts at 0x200 = iplstart.
37+
*
38+
* The restart psw points to iplstart which allows to load a kernel
39+
* image into memory and starting it by a psw restart on any cpu. All
40+
* other default psw new locations contain a disabled wait psw where
41+
* the address indicates which psw was loaded.
42+
*
43+
* Note that the 'file' utility can detect s390 kernel images. For
44+
* that to succeed the two initial CCWs, and the 0x40 fill bytes must
45+
* be present.
46+
*/
47+
struct ipl_lowcore ipl_lowcore __section(".ipldata") = {
48+
.ipl_psw = { .mask = PSW32_MASK_BASE, .addr = PSW32_ADDR_AMODE | IPL_START },
49+
.ccwpgm = {
50+
[ 0] = CCW0(CCW_CMD_READ_IPL, 0x018, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
51+
[ 1] = CCW0(CCW_CMD_READ_IPL, 0x068, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
52+
},
53+
.fill = {
54+
[ 0 ... 55] = 0x40,
55+
},
56+
.ccwpgmcc = {
57+
[ 0] = CCW0(CCW_CMD_READ_IPL, 0x0f0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
58+
[ 1] = CCW0(CCW_CMD_READ_IPL, 0x140, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
59+
[ 2] = CCW0(CCW_CMD_READ_IPL, 0x190, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
60+
[ 3] = CCW0(CCW_CMD_READ_IPL, 0x1e0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
61+
[ 4] = CCW0(CCW_CMD_READ_IPL, 0x230, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
62+
[ 5] = CCW0(CCW_CMD_READ_IPL, 0x280, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
63+
[ 6] = CCW0(CCW_CMD_READ_IPL, 0x2d0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
64+
[ 7] = CCW0(CCW_CMD_READ_IPL, 0x320, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
65+
[ 8] = CCW0(CCW_CMD_READ_IPL, 0x370, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
66+
[ 9] = CCW0(CCW_CMD_READ_IPL, 0x3c0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
67+
[10] = CCW0(CCW_CMD_READ_IPL, 0x410, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
68+
[11] = CCW0(CCW_CMD_READ_IPL, 0x460, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
69+
[12] = CCW0(CCW_CMD_READ_IPL, 0x4b0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
70+
[13] = CCW0(CCW_CMD_READ_IPL, 0x500, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
71+
[14] = CCW0(CCW_CMD_READ_IPL, 0x550, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
72+
[15] = CCW0(CCW_CMD_READ_IPL, 0x5a0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
73+
[16] = CCW0(CCW_CMD_READ_IPL, 0x5f0, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
74+
[17] = CCW0(CCW_CMD_READ_IPL, 0x640, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
75+
[18] = CCW0(CCW_CMD_READ_IPL, 0x690, 0x50, CCW_FLAG_SLI | CCW_FLAG_CC),
76+
[19] = CCW0(CCW_CMD_READ_IPL, 0x6e0, 0x50, CCW_FLAG_SLI),
77+
},
78+
.restart_psw = { .mask = 0, .addr = IPL_START, },
79+
.external_new_psw = { .mask = PSW_MASK_DISABLED, .addr = __LC_EXT_NEW_PSW, },
80+
.svc_new_psw = { .mask = PSW_MASK_DISABLED, .addr = __LC_SVC_NEW_PSW, },
81+
.program_new_psw = { .mask = PSW_MASK_DISABLED, .addr = __LC_PGM_NEW_PSW, },
82+
.mcck_new_psw = { .mask = PSW_MASK_DISABLED, .addr = __LC_MCK_NEW_PSW, },
83+
.io_new_psw = { .mask = PSW_MASK_DISABLED, .addr = __LC_IO_NEW_PSW, },
84+
};

arch/s390/boot/vmlinux.lds.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <asm/thread_info.h>
55
#include <asm/page.h>
66
#include <asm/sclp.h>
7+
#include "boot.h"
78

89
OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
910
OUTPUT_ARCH(s390:64-bit)
@@ -13,6 +14,10 @@ ENTRY(startup)
1314
SECTIONS
1415
{
1516
. = 0;
17+
.ipldata : {
18+
*(.ipldata)
19+
}
20+
. = IPL_START;
1621
.head.text : {
1722
_head = . ;
1823
HEAD_TEXT

0 commit comments

Comments
 (0)