Skip to content

Commit d1b52a4

Browse files
Vasily GorbikMartin Schwidefsky
authored andcommitted
s390: introduce .boot.data section
Introduce .boot.data section which is "shared" between the decompressor code and the decompressed kernel. The decompressor will store values in it, and copy over to the decompressed image before starting it. This method allows to avoid using pre-defined addresses and other hacks to pass values between those boot phases. .boot.data section is a part of init data, and will be freed after kernel initialization is complete. For uncompressed kernel image, .boot.data section is basically the same as .init.data Reviewed-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 7516fc1 commit d1b52a4

6 files changed

Lines changed: 56 additions & 4 deletions

File tree

‎arch/s390/boot/compressed/decompressor.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ struct vmlinux_info {
1515
void (*entry)(void);
1616
unsigned long image_size; /* does not include .bss */
1717
unsigned long bss_size; /* uncompressed image .bss size */
18+
unsigned long bootdata_off;
19+
unsigned long bootdata_size;
1820
};
1921

2022
extern char _vmlinux_info[];

‎arch/s390/boot/compressed/vmlinux.lds.S‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#include <asm-generic/vmlinux.lds.h>
3+
#include <asm/vmlinux.lds.h>
34

45
OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
56
OUTPUT_ARCH(s390:64-bit)
@@ -32,6 +33,8 @@ SECTIONS
3233
*(.data.*)
3334
_edata = . ;
3435
}
36+
BOOT_DATA
37+
3538
/*
3639
* uncompressed image info used by the decompressor it should match
3740
* struct vmlinux_info. It comes from .vmlinux.info section of

‎arch/s390/boot/startup.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "compressed/decompressor.h"
66
#include "boot.h"
77

8+
extern char __boot_data_start[], __boot_data_end[];
9+
810
void error(char *x)
911
{
1012
sclp_early_printk("\n\n");
@@ -36,6 +38,13 @@ static void rescue_initrd(void)
3638
INITRD_START = min_initrd_addr;
3739
}
3840

41+
static void copy_bootdata(void)
42+
{
43+
if (__boot_data_end - __boot_data_start != vmlinux.bootdata_size)
44+
error(".boot.data section size mismatch");
45+
memcpy((void *)vmlinux.bootdata_off, __boot_data_start, vmlinux.bootdata_size);
46+
}
47+
3948
void startup_kernel(void)
4049
{
4150
void *img;
@@ -45,5 +54,6 @@ void startup_kernel(void)
4554
img = decompress_kernel();
4655
memmove((void *)vmlinux.default_lma, img, vmlinux.image_size);
4756
}
57+
copy_bootdata();
4858
vmlinux.entry();
4959
}

‎arch/s390/include/asm/sections.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,16 @@
44

55
#include <asm-generic/sections.h>
66

7+
/*
8+
* .boot.data section contains variables "shared" between the decompressor and
9+
* the decompressed kernel. The decompressor will store values in them, and
10+
* copy over to the decompressed image before starting it.
11+
*
12+
* Each variable end up in its own intermediate section .boot.data.<var name>,
13+
* those sections are later sorted by alignment + name and merged together into
14+
* final .boot.data section, which should be identical in the decompressor and
15+
* the decompressed kernel (that is checked during the build).
16+
*/
17+
#define __bootdata(var) __section(.boot.data.var) var
18+
719
#endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#include <asm/page.h>
3+
4+
/*
5+
* .boot.data section is shared between the decompressor code and the
6+
* decompressed kernel. The decompressor will store values in it, and copy
7+
* over to the decompressed image before starting it.
8+
*
9+
* .boot.data variables are kept in separate .boot.data.<var name> sections,
10+
* which are sorted by alignment first, then by name before being merged
11+
* into single .boot.data section. This way big holes cased by page aligned
12+
* structs are avoided and linker produces consistent result.
13+
*/
14+
#define BOOT_DATA \
15+
. = ALIGN(PAGE_SIZE); \
16+
.boot.data : { \
17+
__boot_data_start = .; \
18+
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.boot.data*))) \
19+
__boot_data_end = .; \
20+
}

‎arch/s390/kernel/vmlinux.lds.S‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define RO_AFTER_INIT_DATA
1717

1818
#include <asm-generic/vmlinux.lds.h>
19+
#include <asm/vmlinux.lds.h>
1920

2021
OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
2122
OUTPUT_ARCH(s390:64-bit)
@@ -134,6 +135,8 @@ SECTIONS
134135
__nospec_return_end = . ;
135136
}
136137

138+
BOOT_DATA
139+
137140
/* early.c uses stsi, which requires page aligned data. */
138141
. = ALIGN(PAGE_SIZE);
139142
INIT_DATA_SECTION(0x100)
@@ -151,10 +154,12 @@ SECTIONS
151154
* it should match struct vmlinux_info
152155
*/
153156
.vmlinux.info 0 : {
154-
QUAD(_stext) /* default_lma */
155-
QUAD(startup_continue) /* entry */
156-
QUAD(__bss_start - _stext) /* image_size */
157-
QUAD(__bss_stop - __bss_start) /* bss_size */
157+
QUAD(_stext) /* default_lma */
158+
QUAD(startup_continue) /* entry */
159+
QUAD(__bss_start - _stext) /* image_size */
160+
QUAD(__bss_stop - __bss_start) /* bss_size */
161+
QUAD(__boot_data_start) /* bootdata_off */
162+
QUAD(__boot_data_end - __boot_data_start) /* bootdata_size */
158163
}
159164

160165
/* Debugging sections. */

0 commit comments

Comments
 (0)