Skip to content

Commit 65ad409

Browse files
committed
Merge tag 's390-6.11-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull more s390 updates from Vasily Gorbik: - Fix KMSAN build breakage caused by the conflict between s390 and mm-stable trees - Add KMSAN page markers for ptdump - Add runtime constant support - Fix __pa/__va for modules under non-GPL licenses by exporting necessary vm_layout struct with EXPORT_SYMBOL to prevent linkage problems - Fix an endless loop in the CF_DIAG event stop in the CPU Measurement Counter Facility code when the counter set size is zero - Remove the PROTECTED_VIRTUALIZATION_GUEST config option and enable its functionality by default - Support allocation of multiple MSI interrupts per device and improve logging of architecture-specific limitations - Add support for lowcore relocation as a debugging feature to catch all null ptr dereferences in the kernel address space, improving detection beyond the current implementation's limited write access protection - Clean up and rework CPU alternatives to allow for callbacks and early patching for the lowcore relocation * tag 's390-6.11-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (39 commits) s390: Remove protvirt and kvm config guards for uv code s390/boot: Add cmdline option to relocate lowcore s390/kdump: Make kdump ready for lowcore relocation s390/entry: Make system_call() ready for lowcore relocation s390/entry: Make ret_from_fork() ready for lowcore relocation s390/entry: Make __switch_to() ready for lowcore relocation s390/entry: Make restart_int_handler() ready for lowcore relocation s390/entry: Make mchk_int_handler() ready for lowcore relocation s390/entry: Make int handlers ready for lowcore relocation s390/entry: Make pgm_check_handler() ready for lowcore relocation s390/entry: Add base register to CHECK_VMAP_STACK/CHECK_STACK macro s390/entry: Add base register to SIEEXIT macro s390/entry: Add base register to MBEAR macro s390/entry: Make __sie64a() ready for lowcore relocation s390/head64: Make startup code ready for lowcore relocation s390: Add infrastructure to patch lowcore accesses s390/atomic_ops: Disable flag outputs constraint for GCC versions below 14.2.0 s390/entry: Move SIE indicator flag to thread info s390/nmi: Simplify ptregs setup s390/alternatives: Remove alternative facility list ...
2 parents a6294b5 + 6dc2e98 commit 65ad409

Some content is hidden

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

52 files changed

+746
-525
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,9 +3830,6 @@
38303830

38313831
noalign [KNL,ARM]
38323832

3833-
noaltinstr [S390,EARLY] Disables alternative instructions
3834-
patching (CPU alternatives feature).
3835-
38363833
noapic [SMP,APIC,EARLY] Tells the kernel to not make use of any
38373834
IOAPICs that may be present in the system.
38383835

arch/s390/Kconfig

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -799,17 +799,6 @@ config HAVE_PNETID
799799

800800
menu "Virtualization"
801801

802-
config PROTECTED_VIRTUALIZATION_GUEST
803-
def_bool n
804-
prompt "Protected virtualization guest support"
805-
help
806-
Select this option, if you want to be able to run this
807-
kernel as a protected virtualization KVM guest.
808-
Protected virtualization capable machines have a mini hypervisor
809-
located at machine level (an ultravisor). With help of the
810-
Ultravisor, KVM will be able to run "protected" VMs, special
811-
VMs whose memory and management data are unavailable to KVM.
812-
813802
config PFAULT
814803
def_bool y
815804
prompt "Pseudo page fault support"

arch/s390/boot/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
3939

4040
obj-y := head.o als.o startup.o physmem_info.o ipl_parm.o ipl_report.o vmem.o
4141
obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
42-
obj-y += version.o pgm_check_info.o ctype.o ipl_data.o relocs.o
43-
obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o
42+
obj-y += version.o pgm_check_info.o ctype.o ipl_data.o relocs.o alternative.o uv.o
4443
obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
4544
obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
4645
obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o

arch/s390/boot/alternative.c

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

arch/s390/boot/boot.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ struct vmlinux_info {
3030
unsigned long init_mm_off;
3131
unsigned long swapper_pg_dir_off;
3232
unsigned long invalid_pg_dir_off;
33+
unsigned long alt_instructions;
34+
unsigned long alt_instructions_end;
3335
#ifdef CONFIG_KASAN
3436
unsigned long kasan_early_shadow_page_off;
3537
unsigned long kasan_early_shadow_pte_off;
@@ -89,8 +91,10 @@ extern char _end[], _decompressor_end[];
8991
extern unsigned char _compressed_start[];
9092
extern unsigned char _compressed_end[];
9193
extern struct vmlinux_info _vmlinux_info;
94+
9295
#define vmlinux _vmlinux_info
9396

97+
#define __lowcore_pa(x) ((unsigned long)(x) % sizeof(struct lowcore))
9498
#define __abs_lowcore_pa(x) (((unsigned long)(x) - __abs_lowcore) % sizeof(struct lowcore))
9599
#define __kernel_va(x) ((void *)((unsigned long)(x) - __kaslr_offset_phys + __kaslr_offset))
96100
#define __kernel_pa(x) ((unsigned long)(x) - __kaslr_offset + __kaslr_offset_phys)

arch/s390/boot/ipl_parm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <linux/init.h>
44
#include <linux/ctype.h>
55
#include <linux/pgtable.h>
6+
#include <asm/abs_lowcore.h>
67
#include <asm/page-states.h>
78
#include <asm/ebcdic.h>
89
#include <asm/sclp.h>
@@ -310,5 +311,7 @@ void parse_boot_command_line(void)
310311
prot_virt_host = 1;
311312
}
312313
#endif
314+
if (!strcmp(param, "relocate_lowcore") && test_facility(193))
315+
relocate_lowcore = 1;
313316
}
314317
}

arch/s390/boot/startup.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ unsigned long __bootdata_preserved(vmemmap_size);
3030
unsigned long __bootdata_preserved(MODULES_VADDR);
3131
unsigned long __bootdata_preserved(MODULES_END);
3232
unsigned long __bootdata_preserved(max_mappable);
33+
int __bootdata_preserved(relocate_lowcore);
3334

3435
u64 __bootdata_preserved(stfle_fac_list[16]);
3536
struct oldmem_data __bootdata_preserved(oldmem_data);
@@ -376,6 +377,8 @@ static void kaslr_adjust_vmlinux_info(long offset)
376377
vmlinux.init_mm_off += offset;
377378
vmlinux.swapper_pg_dir_off += offset;
378379
vmlinux.invalid_pg_dir_off += offset;
380+
vmlinux.alt_instructions += offset;
381+
vmlinux.alt_instructions_end += offset;
379382
#ifdef CONFIG_KASAN
380383
vmlinux.kasan_early_shadow_page_off += offset;
381384
vmlinux.kasan_early_shadow_pte_off += offset;
@@ -478,8 +481,12 @@ void startup_kernel(void)
478481
* before the kernel started. Therefore, in case the two sections
479482
* overlap there is no risk of corrupting any data.
480483
*/
481-
if (kaslr_enabled())
482-
amode31_lma = randomize_within_range(vmlinux.amode31_size, PAGE_SIZE, 0, SZ_2G);
484+
if (kaslr_enabled()) {
485+
unsigned long amode31_min;
486+
487+
amode31_min = (unsigned long)_decompressor_end;
488+
amode31_lma = randomize_within_range(vmlinux.amode31_size, PAGE_SIZE, amode31_min, SZ_2G);
489+
}
483490
if (!amode31_lma)
484491
amode31_lma = __kaslr_offset_phys - vmlinux.amode31_size;
485492
physmem_reserve(RR_AMODE31, amode31_lma, vmlinux.amode31_size);
@@ -503,6 +510,9 @@ void startup_kernel(void)
503510
kaslr_adjust_got(__kaslr_offset);
504511
setup_vmem(__kaslr_offset, __kaslr_offset + kernel_size, asce_limit);
505512
copy_bootdata();
513+
__apply_alternatives((struct alt_instr *)_vmlinux_info.alt_instructions,
514+
(struct alt_instr *)_vmlinux_info.alt_instructions_end,
515+
ALT_CTX_EARLY);
506516

507517
/*
508518
* Save KASLR offset for early dumps, before vmcore_info is set.

arch/s390/boot/uv.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88
#include "uv.h"
99

1010
/* will be used in arch/s390/kernel/uv.c */
11-
#ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST
1211
int __bootdata_preserved(prot_virt_guest);
13-
#endif
14-
#if IS_ENABLED(CONFIG_KVM)
1512
int __bootdata_preserved(prot_virt_host);
16-
#endif
1713
struct uv_info __bootdata_preserved(uv_info);
1814

1915
void uv_query_info(void)
@@ -53,14 +49,11 @@ void uv_query_info(void)
5349
uv_info.max_secrets = uvcb.max_secrets;
5450
}
5551

56-
#ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST
5752
if (test_bit_inv(BIT_UVC_CMD_SET_SHARED_ACCESS, (unsigned long *)uvcb.inst_calls_list) &&
5853
test_bit_inv(BIT_UVC_CMD_REMOVE_SHARED_ACCESS, (unsigned long *)uvcb.inst_calls_list))
5954
prot_virt_guest = 1;
60-
#endif
6155
}
6256

63-
#if IS_ENABLED(CONFIG_KVM)
6457
unsigned long adjust_to_uv_max(unsigned long limit)
6558
{
6659
if (is_prot_virt_host() && uv_info.max_sec_stor_addr)
@@ -92,4 +85,3 @@ void sanitize_prot_virt_host(void)
9285
{
9386
prot_virt_host = is_prot_virt_host_capable();
9487
}
95-
#endif

arch/s390/boot/uv.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,8 @@
22
#ifndef BOOT_UV_H
33
#define BOOT_UV_H
44

5-
#if IS_ENABLED(CONFIG_KVM)
65
unsigned long adjust_to_uv_max(unsigned long limit);
76
void sanitize_prot_virt_host(void);
8-
#else
9-
static inline unsigned long adjust_to_uv_max(unsigned long limit)
10-
{
11-
return limit;
12-
}
13-
static inline void sanitize_prot_virt_host(void) {}
14-
#endif
15-
16-
#if defined(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) || IS_ENABLED(CONFIG_KVM)
177
void uv_query_info(void);
18-
#else
19-
static inline void uv_query_info(void) {}
20-
#endif
218

229
#endif /* BOOT_UV_H */

arch/s390/boot/vmem.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ atomic_long_t __bootdata_preserved(direct_pages_count[PG_DIRECT_MAP_MAX]);
2626
enum populate_mode {
2727
POPULATE_NONE,
2828
POPULATE_DIRECT,
29+
POPULATE_LOWCORE,
2930
POPULATE_ABS_LOWCORE,
3031
POPULATE_IDENTITY,
3132
POPULATE_KERNEL,
@@ -242,6 +243,8 @@ static unsigned long _pa(unsigned long addr, unsigned long size, enum populate_m
242243
return -1;
243244
case POPULATE_DIRECT:
244245
return addr;
246+
case POPULATE_LOWCORE:
247+
return __lowcore_pa(addr);
245248
case POPULATE_ABS_LOWCORE:
246249
return __abs_lowcore_pa(addr);
247250
case POPULATE_KERNEL:
@@ -418,6 +421,7 @@ static void pgtable_populate(unsigned long addr, unsigned long end, enum populat
418421

419422
void setup_vmem(unsigned long kernel_start, unsigned long kernel_end, unsigned long asce_limit)
420423
{
424+
unsigned long lowcore_address = 0;
421425
unsigned long start, end;
422426
unsigned long asce_type;
423427
unsigned long asce_bits;
@@ -455,12 +459,17 @@ void setup_vmem(unsigned long kernel_start, unsigned long kernel_end, unsigned l
455459
__arch_set_page_dat((void *)swapper_pg_dir, 1UL << CRST_ALLOC_ORDER);
456460
__arch_set_page_dat((void *)invalid_pg_dir, 1UL << CRST_ALLOC_ORDER);
457461

462+
if (relocate_lowcore)
463+
lowcore_address = LOWCORE_ALT_ADDRESS;
464+
458465
/*
459466
* To allow prefixing the lowcore must be mapped with 4KB pages.
460467
* To prevent creation of a large page at address 0 first map
461468
* the lowcore and create the identity mapping only afterwards.
462469
*/
463-
pgtable_populate(0, sizeof(struct lowcore), POPULATE_DIRECT);
470+
pgtable_populate(lowcore_address,
471+
lowcore_address + sizeof(struct lowcore),
472+
POPULATE_LOWCORE);
464473
for_each_physmem_usable_range(i, &start, &end) {
465474
pgtable_populate((unsigned long)__identity_va(start),
466475
(unsigned long)__identity_va(end),

0 commit comments

Comments
 (0)