Skip to content

Commit e2b623f

Browse files
committed
Merge tag 's390-4.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 updates from Martin Schwidefsky: - Improved access control for the zcrypt driver, multiple device nodes can now be created with different access control lists - Extend the pkey API to provide random protected keys, this is useful for encrypted swap device with ephemeral protected keys - Add support for virtually mapped kernel stacks - Rework the early boot code, this moves the memory detection into the boot code that runs prior to decompression. - Add KASAN support - Bug fixes and cleanups * tag 's390-4.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (83 commits) s390/pkey: move pckmo subfunction available checks away from module init s390/kasan: support preemptible kernel build s390/pkey: Load pkey kernel module automatically s390/perf: Return error when debug_register fails s390/sthyi: Fix machine name validity indication s390/zcrypt: fix broken zcrypt_send_cprb in-kernel api function s390/vmalloc: fix VMALLOC_START calculation s390/mem_detect: add missing include s390/dumpstack: print psw mask and address again s390/crypto: Enhance paes cipher to accept variable length key material s390/pkey: Introduce new API for transforming key blobs s390/pkey: Introduce new API for random protected key verification s390/pkey: Add sysfs attributes to emit secure key blobs s390/pkey: Add sysfs attributes to emit protected key blobs s390/pkey: Define protected key blob format s390/pkey: Introduce new API for random protected key generation s390/zcrypt: add ap_adapter_mask sysfs attribute s390/zcrypt: provide apfs failure code on type 86 error reply s390/zcrypt: zcrypt device driver cleanup s390/kasan: add support for mem= kernel parameter ...
2 parents 70408a9 + f822ad2 commit e2b623f

121 files changed

Lines changed: 3712 additions & 1183 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/s390/Kconfig‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ config PCI_QUIRKS
5656
config ARCH_SUPPORTS_UPROBES
5757
def_bool y
5858

59+
config KASAN_SHADOW_OFFSET
60+
hex
61+
depends on KASAN
62+
default 0x18000000000000 if KASAN_S390_4_LEVEL_PAGING
63+
default 0x30000000000
64+
5965
config S390
6066
def_bool y
6167
select ARCH_BINFMT_ELF_STATE
@@ -120,11 +126,13 @@ config S390
120126
select HAVE_ALIGNED_STRUCT_PAGE if SLUB
121127
select HAVE_ARCH_AUDITSYSCALL
122128
select HAVE_ARCH_JUMP_LABEL
129+
select HAVE_ARCH_KASAN
123130
select CPU_NO_EFFICIENT_FFS if !HAVE_MARCH_Z9_109_FEATURES
124131
select HAVE_ARCH_SECCOMP_FILTER
125132
select HAVE_ARCH_SOFT_DIRTY
126133
select HAVE_ARCH_TRACEHOOK
127134
select HAVE_ARCH_TRANSPARENT_HUGEPAGE
135+
select HAVE_ARCH_VMAP_STACK
128136
select HAVE_EBPF_JIT if PACK_STACK && HAVE_MARCH_Z196_FEATURES
129137
select HAVE_CMPXCHG_DOUBLE
130138
select HAVE_CMPXCHG_LOCAL
@@ -649,6 +657,7 @@ config PACK_STACK
649657

650658
config CHECK_STACK
651659
def_bool y
660+
depends on !VMAP_STACK
652661
prompt "Detect kernel stack overflow"
653662
help
654663
This option enables the compiler option -mstack-guard and

‎arch/s390/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-option,-ffreestanding)
2727
KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
2828
KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
2929
UTS_MACHINE := s390x
30-
STACK_SIZE := 16384
30+
STACK_SIZE := $(if $(CONFIG_KASAN),32768,16384)
3131
CHECKFLAGS += -D__s390__ -D__s390x__
3232

3333
export LD_BFD

‎arch/s390/appldata/appldata_base.c‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ static void appldata_work_fn(struct work_struct *work)
137137
mutex_unlock(&appldata_ops_mutex);
138138
}
139139

140+
static struct appldata_product_id appldata_id = {
141+
.prod_nr = {0xD3, 0xC9, 0xD5, 0xE4,
142+
0xE7, 0xD2, 0xD9}, /* "LINUXKR" */
143+
.prod_fn = 0xD5D3, /* "NL" */
144+
.version_nr = 0xF2F6, /* "26" */
145+
.release_nr = 0xF0F1, /* "01" */
146+
};
147+
140148
/*
141149
* appldata_diag()
142150
*
@@ -145,17 +153,22 @@ static void appldata_work_fn(struct work_struct *work)
145153
int appldata_diag(char record_nr, u16 function, unsigned long buffer,
146154
u16 length, char *mod_lvl)
147155
{
148-
struct appldata_product_id id = {
149-
.prod_nr = {0xD3, 0xC9, 0xD5, 0xE4,
150-
0xE7, 0xD2, 0xD9}, /* "LINUXKR" */
151-
.prod_fn = 0xD5D3, /* "NL" */
152-
.version_nr = 0xF2F6, /* "26" */
153-
.release_nr = 0xF0F1, /* "01" */
154-
};
156+
struct appldata_parameter_list *parm_list;
157+
struct appldata_product_id *id;
158+
int rc;
155159

156-
id.record_nr = record_nr;
157-
id.mod_lvl = (mod_lvl[0]) << 8 | mod_lvl[1];
158-
return appldata_asm(&id, function, (void *) buffer, length);
160+
parm_list = kmalloc(sizeof(*parm_list), GFP_KERNEL);
161+
id = kmemdup(&appldata_id, sizeof(appldata_id), GFP_KERNEL);
162+
rc = -ENOMEM;
163+
if (parm_list && id) {
164+
id->record_nr = record_nr;
165+
id->mod_lvl = (mod_lvl[0]) << 8 | mod_lvl[1];
166+
rc = appldata_asm(parm_list, id, function,
167+
(void *) buffer, length);
168+
}
169+
kfree(id);
170+
kfree(parm_list);
171+
return rc;
159172
}
160173
/************************ timer, work, DIAG <END> ****************************/
161174

‎arch/s390/boot/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
image
22
bzImage
3+
section_cmp.*

‎arch/s390/boot/Makefile‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
KCOV_INSTRUMENT := n
77
GCOV_PROFILE := n
88
UBSAN_SANITIZE := n
9+
KASAN_SANITIZE := n
910

1011
KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR)
1112
KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR)
@@ -27,15 +28,32 @@ endif
2728

2829
CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
2930

30-
obj-y := head.o als.o ebcdic.o sclp_early_core.o mem.o
31-
targets := bzImage startup.a $(obj-y)
31+
obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o string.o ebcdic.o
32+
obj-y += sclp_early_core.o mem.o ipl_vmparm.o cmdline.o ctype.o
33+
targets := bzImage startup.a section_cmp.boot.data $(obj-y)
3234
subdir- := compressed
3335

3436
OBJECTS := $(addprefix $(obj)/,$(obj-y))
3537

36-
$(obj)/bzImage: $(obj)/compressed/vmlinux FORCE
38+
quiet_cmd_section_cmp = SECTCMP $*
39+
define cmd_section_cmp
40+
s1=`$(OBJDUMP) -t -j "$*" "$<" | sort | \
41+
sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
42+
s2=`$(OBJDUMP) -t -j "$*" "$(word 2,$^)" | sort | \
43+
sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
44+
if [ "$$s1" != "$$s2" ]; then \
45+
echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
46+
exit 1; \
47+
fi; \
48+
touch $@
49+
endef
50+
51+
$(obj)/bzImage: $(obj)/compressed/vmlinux $(obj)/section_cmp.boot.data FORCE
3752
$(call if_changed,objcopy)
3853

54+
$(obj)/section_cmp%: vmlinux $(obj)/compressed/vmlinux FORCE
55+
$(call if_changed,section_cmp)
56+
3957
$(obj)/compressed/vmlinux: $(obj)/startup.a FORCE
4058
$(Q)$(MAKE) $(build)=$(obj)/compressed $@
4159

‎arch/s390/boot/boot.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef BOOT_BOOT_H
3+
#define BOOT_BOOT_H
4+
5+
void startup_kernel(void);
6+
void detect_memory(void);
7+
void store_ipl_parmblock(void);
8+
void setup_boot_command_line(void);
9+
void setup_memory_end(void);
10+
11+
#endif /* BOOT_BOOT_H */

‎arch/s390/boot/cmdline.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include "../../../lib/cmdline.c"

‎arch/s390/boot/compressed/Makefile‎

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,33 @@
88
KCOV_INSTRUMENT := n
99
GCOV_PROFILE := n
1010
UBSAN_SANITIZE := n
11+
KASAN_SANITIZE := n
1112

12-
obj-y := $(if $(CONFIG_KERNEL_UNCOMPRESSED),,head.o misc.o) piggy.o
13+
obj-y := $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) piggy.o info.o
1314
targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
1415
targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
15-
targets += vmlinux.scr.lds $(obj-y) $(if $(CONFIG_KERNEL_UNCOMPRESSED),,sizes.h)
16+
targets += info.bin $(obj-y)
1617

1718
KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR)
1819
KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR)
20+
OBJCOPYFLAGS :=
1921

2022
OBJECTS := $(addprefix $(obj)/,$(obj-y))
2123

2224
LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup -T
2325
$(obj)/vmlinux: $(obj)/vmlinux.lds $(objtree)/arch/s390/boot/startup.a $(OBJECTS)
2426
$(call if_changed,ld)
2527

26-
# extract required uncompressed vmlinux symbols and adjust them to reflect offsets inside vmlinux.bin
27-
sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\)$$/\#define SZ\2 (0x\1 - 0x100000)/p'
28-
29-
quiet_cmd_sizes = GEN $@
30-
cmd_sizes = $(NM) $< | sed -n $(sed-sizes) > $@
31-
32-
$(obj)/sizes.h: vmlinux
33-
$(call if_changed,sizes)
34-
35-
AFLAGS_head.o += -I$(objtree)/$(obj)
36-
$(obj)/head.o: $(obj)/sizes.h
28+
OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info
29+
$(obj)/info.bin: vmlinux FORCE
30+
$(call if_changed,objcopy)
3731

38-
CFLAGS_misc.o += -I$(objtree)/$(obj)
39-
$(obj)/misc.o: $(obj)/sizes.h
32+
OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
33+
$(obj)/info.o: $(obj)/info.bin FORCE
34+
$(call if_changed,objcopy)
4035

41-
OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
42-
$(obj)/vmlinux.bin: vmlinux
36+
OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
37+
$(obj)/vmlinux.bin: vmlinux FORCE
4338
$(call if_changed,objcopy)
4439

4540
vmlinux.bin.all-y := $(obj)/vmlinux.bin
@@ -64,10 +59,10 @@ $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y)
6459
$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y)
6560
$(call if_changed,xzkern)
6661

67-
LDFLAGS_piggy.o := -r --format binary --oformat $(LD_BFD) -T
68-
$(obj)/piggy.o: $(obj)/vmlinux.scr.lds $(obj)/vmlinux.bin$(suffix-y)
69-
$(call if_changed,ld)
62+
OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
63+
$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
64+
$(call if_changed,objcopy)
7065

71-
chkbss := $(filter-out $(obj)/misc.o $(obj)/piggy.o,$(OBJECTS))
66+
chkbss := $(filter-out $(obj)/piggy.o $(obj)/info.o,$(OBJECTS))
7267
chkbss-target := $(obj)/vmlinux.bin
7368
include $(srctree)/arch/s390/scripts/Makefile.chkbss
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Definitions and wrapper functions for kernel decompressor
4+
*
5+
* Copyright IBM Corp. 2010
6+
*
7+
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
8+
*/
9+
10+
#include <linux/kernel.h>
11+
#include <linux/string.h>
12+
#include <asm/page.h>
13+
#include "decompressor.h"
14+
15+
/*
16+
* gzip declarations
17+
*/
18+
#define STATIC static
19+
#define STATIC_RW_DATA static __section(.data)
20+
21+
#undef memset
22+
#undef memcpy
23+
#undef memmove
24+
#define memmove memmove
25+
#define memzero(s, n) memset((s), 0, (n))
26+
27+
/* Symbols defined by linker scripts */
28+
extern char _end[];
29+
extern unsigned char _compressed_start[];
30+
extern unsigned char _compressed_end[];
31+
32+
#ifdef CONFIG_HAVE_KERNEL_BZIP2
33+
#define HEAP_SIZE 0x400000
34+
#else
35+
#define HEAP_SIZE 0x10000
36+
#endif
37+
38+
static unsigned long free_mem_ptr = (unsigned long) _end;
39+
static unsigned long free_mem_end_ptr = (unsigned long) _end + HEAP_SIZE;
40+
41+
#ifdef CONFIG_KERNEL_GZIP
42+
#include "../../../../lib/decompress_inflate.c"
43+
#endif
44+
45+
#ifdef CONFIG_KERNEL_BZIP2
46+
#include "../../../../lib/decompress_bunzip2.c"
47+
#endif
48+
49+
#ifdef CONFIG_KERNEL_LZ4
50+
#include "../../../../lib/decompress_unlz4.c"
51+
#endif
52+
53+
#ifdef CONFIG_KERNEL_LZMA
54+
#include "../../../../lib/decompress_unlzma.c"
55+
#endif
56+
57+
#ifdef CONFIG_KERNEL_LZO
58+
#include "../../../../lib/decompress_unlzo.c"
59+
#endif
60+
61+
#ifdef CONFIG_KERNEL_XZ
62+
#include "../../../../lib/decompress_unxz.c"
63+
#endif
64+
65+
#define decompress_offset ALIGN((unsigned long)_end + HEAP_SIZE, PAGE_SIZE)
66+
67+
unsigned long mem_safe_offset(void)
68+
{
69+
/*
70+
* due to 4MB HEAD_SIZE for bzip2
71+
* 'decompress_offset + vmlinux.image_size' could be larger than
72+
* kernel at final position + its .bss, so take the larger of two
73+
*/
74+
return max(decompress_offset + vmlinux.image_size,
75+
vmlinux.default_lma + vmlinux.image_size + vmlinux.bss_size);
76+
}
77+
78+
void *decompress_kernel(void)
79+
{
80+
void *output = (void *)decompress_offset;
81+
82+
__decompress(_compressed_start, _compressed_end - _compressed_start,
83+
NULL, NULL, output, 0, NULL, error);
84+
return output;
85+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef BOOT_COMPRESSED_DECOMPRESSOR_H
3+
#define BOOT_COMPRESSED_DECOMPRESSOR_H
4+
5+
#ifdef CONFIG_KERNEL_UNCOMPRESSED
6+
static inline void *decompress_kernel(void) {}
7+
#else
8+
void *decompress_kernel(void);
9+
#endif
10+
unsigned long mem_safe_offset(void);
11+
void error(char *m);
12+
13+
struct vmlinux_info {
14+
unsigned long default_lma;
15+
void (*entry)(void);
16+
unsigned long image_size; /* does not include .bss */
17+
unsigned long bss_size; /* uncompressed image .bss size */
18+
unsigned long bootdata_off;
19+
unsigned long bootdata_size;
20+
};
21+
22+
extern char _vmlinux_info[];
23+
#define vmlinux (*(struct vmlinux_info *)_vmlinux_info)
24+
25+
#endif /* BOOT_COMPRESSED_DECOMPRESSOR_H */

0 commit comments

Comments
 (0)