Skip to content

Commit 6b38e2f

Browse files
committed
Merge tag 's390-5.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 updates from Heiko Carstens: - Add missing Kconfig option for ftrace direct multi sample, so it can be compiled again, and also add s390 support for this sample. - Update Christian Borntraeger's email address. - Various fixes for memory layout setup. Besides other this makes it possible to load shared DCSS segments again. - Fix copy to user space of swapped kdump oldmem. - Remove -mstack-guard and -mstack-size compile options when building vdso binaries. This can happen when CONFIG_VMAP_STACK is disabled and results in broken vdso code which causes more or less random exceptions. Also remove the not needed -nostdlib option. - Fix memory leak on cpu hotplug and return code handling in kexec code. - Wire up futex_waitv system call. - Replace snprintf with sysfs_emit where appropriate. * tag 's390-5.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: ftrace/samples: add s390 support for ftrace direct multi sample ftrace/samples: add missing Kconfig option for ftrace direct multi sample MAINTAINERS: update email address of Christian Borntraeger s390/kexec: fix memory leak of ipl report buffer s390/kexec: fix return code handling s390/dump: fix copying to user-space of swapped kdump oldmem s390: wire up sys_futex_waitv system call s390/vdso: filter out -mstack-guard and -mstack-size s390/vdso: remove -nostdlib compiler flag s390: replace snprintf in show functions with sysfs_emit s390/boot: simplify and fix kernel memory layout setup s390/setup: re-arrange memblock setup s390/setup: avoid using memblock_enforce_memory_limit s390/setup: avoid reserving memory above identity mapping
2 parents b38bfc7 + 890e3dc commit 6b38e2f

File tree

21 files changed

+170
-138
lines changed

21 files changed

+170
-138
lines changed

.mailmap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Chao Yu <[email protected]> <[email protected]>
7171
7272
7373
74+
Christian Borntraeger <[email protected]> <[email protected]>
75+
Christian Borntraeger <[email protected]> <[email protected]>
76+
Christian Borntraeger <[email protected]> <[email protected]>
7477
Christophe Ricard <[email protected]>
7578
Christoph Hellwig <[email protected]>
7679

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10445,7 +10445,7 @@ F: arch/riscv/include/uapi/asm/kvm*
1044510445
F: arch/riscv/kvm/
1044610446

1044710447
KERNEL VIRTUAL MACHINE for s390 (KVM/s390)
10448-
M: Christian Borntraeger <borntraeger@de.ibm.com>
10448+
M: Christian Borntraeger <borntraeger@linux.ibm.com>
1044910449
M: Janosch Frank <[email protected]>
1045010450
R: David Hildenbrand <[email protected]>
1045110451
R: Claudio Imbrenda <[email protected]>
@@ -16573,7 +16573,7 @@ F: drivers/video/fbdev/savage/
1657316573
S390
1657416574
M: Heiko Carstens <[email protected]>
1657516575
M: Vasily Gorbik <[email protected]>
16576-
M: Christian Borntraeger <borntraeger@de.ibm.com>
16576+
M: Christian Borntraeger <borntraeger@linux.ibm.com>
1657716577
R: Alexander Gordeev <[email protected]>
1657816578
1657916579
S: Supported

arch/s390/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ config ARCH_SUPPORTS_UPROBES
4747
config KASAN_SHADOW_OFFSET
4848
hex
4949
depends on KASAN
50-
default 0x18000000000000
50+
default 0x1C000000000000
5151

5252
config S390
5353
def_bool y
@@ -194,6 +194,7 @@ config S390
194194
select HAVE_RELIABLE_STACKTRACE
195195
select HAVE_RSEQ
196196
select HAVE_SAMPLE_FTRACE_DIRECT
197+
select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
197198
select HAVE_SOFTIRQ_ON_OWN_STACK
198199
select HAVE_SYSCALL_TRACEPOINTS
199200
select HAVE_VIRT_CPU_ACCOUNTING

arch/s390/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ KBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
7777
KBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
7878

7979
ifneq ($(call cc-option,-mstack-size=8192 -mstack-guard=128),)
80-
cflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
81-
ifeq ($(call cc-option,-mstack-size=8192),)
82-
cflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
83-
endif
80+
CC_FLAGS_CHECK_STACK := -mstack-size=$(STACK_SIZE)
81+
ifeq ($(call cc-option,-mstack-size=8192),)
82+
CC_FLAGS_CHECK_STACK += -mstack-guard=$(CONFIG_STACK_GUARD)
83+
endif
84+
export CC_FLAGS_CHECK_STACK
85+
cflags-$(CONFIG_CHECK_STACK) += $(CC_FLAGS_CHECK_STACK)
8486
endif
8587

8688
ifdef CONFIG_EXPOLINE

arch/s390/boot/startup.c

Lines changed: 31 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -149,82 +149,56 @@ static void setup_ident_map_size(unsigned long max_physmem_end)
149149

150150
static void setup_kernel_memory_layout(void)
151151
{
152-
bool vmalloc_size_verified = false;
153-
unsigned long vmemmap_off;
154-
unsigned long vspace_left;
152+
unsigned long vmemmap_start;
155153
unsigned long rte_size;
156154
unsigned long pages;
157-
unsigned long vmax;
158155

159156
pages = ident_map_size / PAGE_SIZE;
160157
/* vmemmap contains a multiple of PAGES_PER_SECTION struct pages */
161158
vmemmap_size = SECTION_ALIGN_UP(pages) * sizeof(struct page);
162159

163160
/* choose kernel address space layout: 4 or 3 levels. */
164-
vmemmap_off = round_up(ident_map_size, _REGION3_SIZE);
161+
vmemmap_start = round_up(ident_map_size, _REGION3_SIZE);
165162
if (IS_ENABLED(CONFIG_KASAN) ||
166163
vmalloc_size > _REGION2_SIZE ||
167-
vmemmap_off + vmemmap_size + vmalloc_size + MODULES_LEN > _REGION2_SIZE)
168-
vmax = _REGION1_SIZE;
169-
else
170-
vmax = _REGION2_SIZE;
171-
172-
/* keep vmemmap_off aligned to a top level region table entry */
173-
rte_size = vmax == _REGION1_SIZE ? _REGION2_SIZE : _REGION3_SIZE;
174-
MODULES_END = vmax;
175-
if (is_prot_virt_host()) {
176-
/*
177-
* forcing modules and vmalloc area under the ultravisor
178-
* secure storage limit, so that any vmalloc allocation
179-
* we do could be used to back secure guest storage.
180-
*/
181-
adjust_to_uv_max(&MODULES_END);
182-
}
183-
184-
#ifdef CONFIG_KASAN
185-
if (MODULES_END < vmax) {
186-
/* force vmalloc and modules below kasan shadow */
187-
MODULES_END = min(MODULES_END, KASAN_SHADOW_START);
164+
vmemmap_start + vmemmap_size + vmalloc_size + MODULES_LEN >
165+
_REGION2_SIZE) {
166+
MODULES_END = _REGION1_SIZE;
167+
rte_size = _REGION2_SIZE;
188168
} else {
189-
/*
190-
* leave vmalloc and modules above kasan shadow but make
191-
* sure they don't overlap with it
192-
*/
193-
vmalloc_size = min(vmalloc_size, vmax - KASAN_SHADOW_END - MODULES_LEN);
194-
vmalloc_size_verified = true;
195-
vspace_left = KASAN_SHADOW_START;
169+
MODULES_END = _REGION2_SIZE;
170+
rte_size = _REGION3_SIZE;
196171
}
172+
/*
173+
* forcing modules and vmalloc area under the ultravisor
174+
* secure storage limit, so that any vmalloc allocation
175+
* we do could be used to back secure guest storage.
176+
*/
177+
adjust_to_uv_max(&MODULES_END);
178+
#ifdef CONFIG_KASAN
179+
/* force vmalloc and modules below kasan shadow */
180+
MODULES_END = min(MODULES_END, KASAN_SHADOW_START);
197181
#endif
198182
MODULES_VADDR = MODULES_END - MODULES_LEN;
199183
VMALLOC_END = MODULES_VADDR;
200184

201-
if (vmalloc_size_verified) {
202-
VMALLOC_START = VMALLOC_END - vmalloc_size;
203-
} else {
204-
vmemmap_off = round_up(ident_map_size, rte_size);
205-
206-
if (vmemmap_off + vmemmap_size > VMALLOC_END ||
207-
vmalloc_size > VMALLOC_END - vmemmap_off - vmemmap_size) {
208-
/*
209-
* allow vmalloc area to occupy up to 1/2 of
210-
* the rest virtual space left.
211-
*/
212-
vmalloc_size = min(vmalloc_size, VMALLOC_END / 2);
213-
}
214-
VMALLOC_START = VMALLOC_END - vmalloc_size;
215-
vspace_left = VMALLOC_START;
216-
}
185+
/* allow vmalloc area to occupy up to about 1/2 of the rest virtual space left */
186+
vmalloc_size = min(vmalloc_size, round_down(VMALLOC_END / 2, _REGION3_SIZE));
187+
VMALLOC_START = VMALLOC_END - vmalloc_size;
217188

218-
pages = vspace_left / (PAGE_SIZE + sizeof(struct page));
189+
/* split remaining virtual space between 1:1 mapping & vmemmap array */
190+
pages = VMALLOC_START / (PAGE_SIZE + sizeof(struct page));
219191
pages = SECTION_ALIGN_UP(pages);
220-
vmemmap_off = round_up(vspace_left - pages * sizeof(struct page), rte_size);
221-
/* keep vmemmap left most starting from a fresh region table entry */
222-
vmemmap_off = min(vmemmap_off, round_up(ident_map_size, rte_size));
223-
/* take care that identity map is lower then vmemmap */
224-
ident_map_size = min(ident_map_size, vmemmap_off);
192+
/* keep vmemmap_start aligned to a top level region table entry */
193+
vmemmap_start = round_down(VMALLOC_START - pages * sizeof(struct page), rte_size);
194+
/* vmemmap_start is the future VMEM_MAX_PHYS, make sure it is within MAX_PHYSMEM */
195+
vmemmap_start = min(vmemmap_start, 1UL << MAX_PHYSMEM_BITS);
196+
/* make sure identity map doesn't overlay with vmemmap */
197+
ident_map_size = min(ident_map_size, vmemmap_start);
225198
vmemmap_size = SECTION_ALIGN_UP(ident_map_size / PAGE_SIZE) * sizeof(struct page);
226-
VMALLOC_START = max(vmemmap_off + vmemmap_size, VMALLOC_START);
227-
vmemmap = (struct page *)vmemmap_off;
199+
/* make sure vmemmap doesn't overlay with vmalloc area */
200+
VMALLOC_START = max(vmemmap_start + vmemmap_size, VMALLOC_START);
201+
vmemmap = (struct page *)vmemmap_start;
228202
}
229203

230204
/*

arch/s390/include/asm/kexec.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ void *kexec_file_add_components(struct kimage *image,
7474
int arch_kexec_do_relocs(int r_type, void *loc, unsigned long val,
7575
unsigned long addr);
7676

77+
#define ARCH_HAS_KIMAGE_ARCH
78+
79+
struct kimage_arch {
80+
void *ipl_buf;
81+
};
82+
7783
extern const struct kexec_file_ops s390_kexec_image_ops;
7884
extern const struct kexec_file_ops s390_kexec_elf_ops;
7985

arch/s390/kernel/crash_dump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ static int copy_oldmem_user(void __user *dst, void *src, size_t count)
191191
return rc;
192192
} else {
193193
/* Check for swapped kdump oldmem areas */
194-
if (oldmem_data.start && from - oldmem_data.size < oldmem_data.size) {
195-
from -= oldmem_data.size;
194+
if (oldmem_data.start && from - oldmem_data.start < oldmem_data.size) {
195+
from -= oldmem_data.start;
196196
len = min(count, oldmem_data.size - from);
197197
} else if (oldmem_data.start && from < oldmem_data.size) {
198198
len = min(count, oldmem_data.size - from);

arch/s390/kernel/ipl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,7 @@ void *ipl_report_finish(struct ipl_report *report)
21562156

21572157
buf = vzalloc(report->size);
21582158
if (!buf)
2159-
return ERR_PTR(-ENOMEM);
2159+
goto out;
21602160
ptr = buf;
21612161

21622162
memcpy(ptr, report->ipib, report->ipib->hdr.len);
@@ -2195,6 +2195,7 @@ void *ipl_report_finish(struct ipl_report *report)
21952195
}
21962196

21972197
BUG_ON(ptr > buf + report->size);
2198+
out:
21982199
return buf;
21992200
}
22002201

arch/s390/kernel/machine_kexec_file.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/kexec.h>
1313
#include <linux/module_signature.h>
1414
#include <linux/verification.h>
15+
#include <linux/vmalloc.h>
1516
#include <asm/boot_data.h>
1617
#include <asm/ipl.h>
1718
#include <asm/setup.h>
@@ -170,6 +171,7 @@ static int kexec_file_add_ipl_report(struct kimage *image,
170171
struct kexec_buf buf;
171172
unsigned long addr;
172173
void *ptr, *end;
174+
int ret;
173175

174176
buf.image = image;
175177

@@ -199,17 +201,23 @@ static int kexec_file_add_ipl_report(struct kimage *image,
199201
ptr += len;
200202
}
201203

204+
ret = -ENOMEM;
202205
buf.buffer = ipl_report_finish(data->report);
206+
if (!buf.buffer)
207+
goto out;
203208
buf.bufsz = data->report->size;
204209
buf.memsz = buf.bufsz;
210+
image->arch.ipl_buf = buf.buffer;
205211

206212
data->memsz += buf.memsz;
207213

208214
lc_ipl_parmblock_ptr =
209215
data->kernel_buf + offsetof(struct lowcore, ipl_parmblock_ptr);
210216
*lc_ipl_parmblock_ptr = (__u32)buf.mem;
211217

212-
return kexec_add_buffer(&buf);
218+
ret = kexec_add_buffer(&buf);
219+
out:
220+
return ret;
213221
}
214222

215223
void *kexec_file_add_components(struct kimage *image,
@@ -322,3 +330,11 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
322330
}
323331
return 0;
324332
}
333+
334+
int arch_kimage_file_post_load_cleanup(struct kimage *image)
335+
{
336+
vfree(image->arch.ipl_buf);
337+
image->arch.ipl_buf = NULL;
338+
339+
return kexec_image_post_load_cleanup_default(image);
340+
}

arch/s390/kernel/setup.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static void __init setup_resources(void)
606606

607607
static void __init setup_memory_end(void)
608608
{
609-
memblock_remove(ident_map_size, ULONG_MAX);
609+
memblock_remove(ident_map_size, PHYS_ADDR_MAX - ident_map_size);
610610
max_pfn = max_low_pfn = PFN_DOWN(ident_map_size);
611611
pr_notice("The maximum memory size is %luMB\n", ident_map_size >> 20);
612612
}
@@ -637,14 +637,6 @@ static struct notifier_block kdump_mem_nb = {
637637

638638
#endif
639639

640-
/*
641-
* Make sure that the area above identity mapping is protected
642-
*/
643-
static void __init reserve_above_ident_map(void)
644-
{
645-
memblock_reserve(ident_map_size, ULONG_MAX);
646-
}
647-
648640
/*
649641
* Reserve memory for kdump kernel to be loaded with kexec
650642
*/
@@ -785,7 +777,6 @@ static void __init memblock_add_mem_detect_info(void)
785777
}
786778
memblock_set_bottom_up(false);
787779
memblock_set_node(0, ULONG_MAX, &memblock.memory, 0);
788-
memblock_dump_all();
789780
}
790781

791782
/*
@@ -826,9 +817,6 @@ static void __init setup_memory(void)
826817
storage_key_init_range(start, end);
827818

828819
psw_set_key(PAGE_DEFAULT_KEY);
829-
830-
/* Only cosmetics */
831-
memblock_enforce_memory_limit(memblock_end_of_DRAM());
832820
}
833821

834822
static void __init relocate_amode31_section(void)
@@ -999,24 +987,24 @@ void __init setup_arch(char **cmdline_p)
999987
setup_control_program_code();
1000988

1001989
/* Do some memory reservations *before* memory is added to memblock */
1002-
reserve_above_ident_map();
1003990
reserve_kernel();
1004991
reserve_initrd();
1005992
reserve_certificate_list();
1006993
reserve_mem_detect_info();
994+
memblock_set_current_limit(ident_map_size);
1007995
memblock_allow_resize();
1008996

1009997
/* Get information about *all* installed memory */
1010998
memblock_add_mem_detect_info();
1011999

10121000
free_mem_detect_info();
1001+
setup_memory_end();
1002+
memblock_dump_all();
1003+
setup_memory();
10131004

10141005
relocate_amode31_section();
10151006
setup_cr();
1016-
10171007
setup_uv();
1018-
setup_memory_end();
1019-
setup_memory();
10201008
dma_contiguous_reserve(ident_map_size);
10211009
vmcp_cma_reserve();
10221010
if (MACHINE_HAS_EDAT2)

0 commit comments

Comments
 (0)