s390 updates for 6.11-rc2

- Remove unused empty CPU alternatives header file
 
 - Fix recently and erroneously removed exception handling when loading
   an invalid floating point register
 
 - Couple of ptdump fixes to reflect the recent changes due to the
   uncoupling of physical vs virtual kernel address spaces
 
 - Couple of changes to avoid the unnecessary splitting of large pages
   in kernel mappings
 
 - Add the missing MODULE_DESCRIPTION for the CIO modules
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEE3QHqV+H2a8xAv27vjYWKoQLXFBgFAmas5D8ACgkQjYWKoQLX
 FBhDOAf8DjT43CeXhIEsukXN/qfOXacFx4XMQ6T/vJecIAkHheRGYngropKIVY8z
 zs/jw9uBluRG/u5O7NMEiHT71HRj2CtjblzvFvtR6xKhFGhCsbePnyVfxiF/k/oJ
 SHFfumtTt8EvPMZvdlkB4hmVnxTW5NYZI02ZLS5Nn1OhmminSju332O9rZXZRgc8
 t28f/Po4TDUkxt+L5Hax0NpfHwMuohRtWhdFhNoPxyCQMFqdmMEMEHoqf+M4DRCh
 0ZrMY81gyEpksAHAwMrfJiIdTPvQKXLA+zyTY0vCbBGNRm4Gj8qLhzyJ5H8eVQj4
 qVf0Q1b5T9pPZB+tz3Et7ssf0boe/Q==
 =2XKI
 -----END PGP SIGNATURE-----

Merge tag 's390-6.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull s390 fixes from Vasily Gorbik:

 - remove unused empty CPU alternatives header file

 - fix recently and erroneously removed exception handling when loading
   an invalid floating point register

 - ptdump fixes to reflect the recent changes due to the uncoupling of
   physical vs virtual kernel address spaces

 - changes to avoid the unnecessary splitting of large pages in kernel
   mappings

 - add the missing MODULE_DESCRIPTION for the CIO modules

* tag 's390-6.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
  s390: Keep inittext section writable
  s390/vmlinux.lds.S: Move ro_after_init section behind rodata section
  s390/mm: Get rid of RELOC_HIDE()
  s390/mm/ptdump: Improve sorting of markers
  s390/mm/ptdump: Add support for relocated lowcore mapping
  s390/mm/ptdump: Fix handling of identity mapping area
  s390/cio: Add missing MODULE_DESCRIPTION() macros
  s390/alternatives: Remove unused empty header file
  s390/fpu: Re-add exception handling in load_fpu_state()
This commit is contained in:
Linus Torvalds 2024-08-02 09:29:54 -07:00
commit 66242ef25e
8 changed files with 95 additions and 88 deletions

View File

@ -113,7 +113,7 @@ void load_fpu_state(struct fpu *state, int flags)
int mask; int mask;
if (flags & KERNEL_FPC) if (flags & KERNEL_FPC)
fpu_lfpc(&state->fpc); fpu_lfpc_safe(&state->fpc);
if (!cpu_has_vx()) { if (!cpu_has_vx()) {
if (flags & KERNEL_VXR_V0V7) if (flags & KERNEL_VXR_V0V7)
load_fp_regs_vx(state->vxrs); load_fp_regs_vx(state->vxrs);

View File

@ -59,14 +59,6 @@ SECTIONS
} :text = 0x0700 } :text = 0x0700
RO_DATA(PAGE_SIZE) RO_DATA(PAGE_SIZE)
.data.rel.ro : {
*(.data.rel.ro .data.rel.ro.*)
}
.got : {
__got_start = .;
*(.got)
__got_end = .;
}
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
_sdata = .; /* Start of data section */ _sdata = .; /* Start of data section */
@ -80,6 +72,15 @@ SECTIONS
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
__end_ro_after_init = .; __end_ro_after_init = .;
.data.rel.ro : {
*(.data.rel.ro .data.rel.ro.*)
}
.got : {
__got_start = .;
*(.got)
__got_end = .;
}
RW_DATA(0x100, PAGE_SIZE, THREAD_SIZE) RW_DATA(0x100, PAGE_SIZE, THREAD_SIZE)
.data.rel : { .data.rel : {
*(.data.rel*) *(.data.rel*)

View File

@ -3,6 +3,7 @@
#include <linux/ptdump.h> #include <linux/ptdump.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/sort.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/kfence.h> #include <linux/kfence.h>
#include <linux/kasan.h> #include <linux/kasan.h>
@ -15,13 +16,15 @@
static unsigned long max_addr; static unsigned long max_addr;
struct addr_marker { struct addr_marker {
int is_start;
unsigned long start_address; unsigned long start_address;
const char *name; const char *name;
}; };
enum address_markers_idx { enum address_markers_idx {
IDENTITY_BEFORE_NR = 0, KVA_NR = 0,
IDENTITY_BEFORE_END_NR, LOWCORE_START_NR,
LOWCORE_END_NR,
AMODE31_START_NR, AMODE31_START_NR,
AMODE31_END_NR, AMODE31_END_NR,
KERNEL_START_NR, KERNEL_START_NR,
@ -30,8 +33,8 @@ enum address_markers_idx {
KFENCE_START_NR, KFENCE_START_NR,
KFENCE_END_NR, KFENCE_END_NR,
#endif #endif
IDENTITY_AFTER_NR, IDENTITY_START_NR,
IDENTITY_AFTER_END_NR, IDENTITY_END_NR,
VMEMMAP_NR, VMEMMAP_NR,
VMEMMAP_END_NR, VMEMMAP_END_NR,
VMALLOC_NR, VMALLOC_NR,
@ -59,43 +62,44 @@ enum address_markers_idx {
}; };
static struct addr_marker address_markers[] = { static struct addr_marker address_markers[] = {
[IDENTITY_BEFORE_NR] = {0, "Identity Mapping Start"}, [KVA_NR] = {0, 0, "Kernel Virtual Address Space"},
[IDENTITY_BEFORE_END_NR] = {(unsigned long)_stext, "Identity Mapping End"}, [LOWCORE_START_NR] = {1, 0, "Lowcore Start"},
[AMODE31_START_NR] = {0, "Amode31 Area Start"}, [LOWCORE_END_NR] = {0, 0, "Lowcore End"},
[AMODE31_END_NR] = {0, "Amode31 Area End"}, [IDENTITY_START_NR] = {1, 0, "Identity Mapping Start"},
[KERNEL_START_NR] = {(unsigned long)_stext, "Kernel Image Start"}, [IDENTITY_END_NR] = {0, 0, "Identity Mapping End"},
[KERNEL_END_NR] = {(unsigned long)_end, "Kernel Image End"}, [AMODE31_START_NR] = {1, 0, "Amode31 Area Start"},
[AMODE31_END_NR] = {0, 0, "Amode31 Area End"},
[KERNEL_START_NR] = {1, (unsigned long)_stext, "Kernel Image Start"},
[KERNEL_END_NR] = {0, (unsigned long)_end, "Kernel Image End"},
#ifdef CONFIG_KFENCE #ifdef CONFIG_KFENCE
[KFENCE_START_NR] = {0, "KFence Pool Start"}, [KFENCE_START_NR] = {1, 0, "KFence Pool Start"},
[KFENCE_END_NR] = {0, "KFence Pool End"}, [KFENCE_END_NR] = {0, 0, "KFence Pool End"},
#endif #endif
[IDENTITY_AFTER_NR] = {(unsigned long)_end, "Identity Mapping Start"}, [VMEMMAP_NR] = {1, 0, "vmemmap Area Start"},
[IDENTITY_AFTER_END_NR] = {0, "Identity Mapping End"}, [VMEMMAP_END_NR] = {0, 0, "vmemmap Area End"},
[VMEMMAP_NR] = {0, "vmemmap Area Start"}, [VMALLOC_NR] = {1, 0, "vmalloc Area Start"},
[VMEMMAP_END_NR] = {0, "vmemmap Area End"}, [VMALLOC_END_NR] = {0, 0, "vmalloc Area End"},
[VMALLOC_NR] = {0, "vmalloc Area Start"},
[VMALLOC_END_NR] = {0, "vmalloc Area End"},
#ifdef CONFIG_KMSAN #ifdef CONFIG_KMSAN
[KMSAN_VMALLOC_SHADOW_START_NR] = {0, "Kmsan vmalloc Shadow Start"}, [KMSAN_VMALLOC_SHADOW_START_NR] = {1, 0, "Kmsan vmalloc Shadow Start"},
[KMSAN_VMALLOC_SHADOW_END_NR] = {0, "Kmsan vmalloc Shadow End"}, [KMSAN_VMALLOC_SHADOW_END_NR] = {0, 0, "Kmsan vmalloc Shadow End"},
[KMSAN_VMALLOC_ORIGIN_START_NR] = {0, "Kmsan vmalloc Origins Start"}, [KMSAN_VMALLOC_ORIGIN_START_NR] = {1, 0, "Kmsan vmalloc Origins Start"},
[KMSAN_VMALLOC_ORIGIN_END_NR] = {0, "Kmsan vmalloc Origins End"}, [KMSAN_VMALLOC_ORIGIN_END_NR] = {0, 0, "Kmsan vmalloc Origins End"},
[KMSAN_MODULES_SHADOW_START_NR] = {0, "Kmsan Modules Shadow Start"}, [KMSAN_MODULES_SHADOW_START_NR] = {1, 0, "Kmsan Modules Shadow Start"},
[KMSAN_MODULES_SHADOW_END_NR] = {0, "Kmsan Modules Shadow End"}, [KMSAN_MODULES_SHADOW_END_NR] = {0, 0, "Kmsan Modules Shadow End"},
[KMSAN_MODULES_ORIGIN_START_NR] = {0, "Kmsan Modules Origins Start"}, [KMSAN_MODULES_ORIGIN_START_NR] = {1, 0, "Kmsan Modules Origins Start"},
[KMSAN_MODULES_ORIGIN_END_NR] = {0, "Kmsan Modules Origins End"}, [KMSAN_MODULES_ORIGIN_END_NR] = {0, 0, "Kmsan Modules Origins End"},
#endif #endif
[MODULES_NR] = {0, "Modules Area Start"}, [MODULES_NR] = {1, 0, "Modules Area Start"},
[MODULES_END_NR] = {0, "Modules Area End"}, [MODULES_END_NR] = {0, 0, "Modules Area End"},
[ABS_LOWCORE_NR] = {0, "Lowcore Area Start"}, [ABS_LOWCORE_NR] = {1, 0, "Lowcore Area Start"},
[ABS_LOWCORE_END_NR] = {0, "Lowcore Area End"}, [ABS_LOWCORE_END_NR] = {0, 0, "Lowcore Area End"},
[MEMCPY_REAL_NR] = {0, "Real Memory Copy Area Start"}, [MEMCPY_REAL_NR] = {1, 0, "Real Memory Copy Area Start"},
[MEMCPY_REAL_END_NR] = {0, "Real Memory Copy Area End"}, [MEMCPY_REAL_END_NR] = {0, 0, "Real Memory Copy Area End"},
#ifdef CONFIG_KASAN #ifdef CONFIG_KASAN
[KASAN_SHADOW_START_NR] = {KASAN_SHADOW_START, "Kasan Shadow Start"}, [KASAN_SHADOW_START_NR] = {1, KASAN_SHADOW_START, "Kasan Shadow Start"},
[KASAN_SHADOW_END_NR] = {KASAN_SHADOW_END, "Kasan Shadow End"}, [KASAN_SHADOW_END_NR] = {0, KASAN_SHADOW_END, "Kasan Shadow End"},
#endif #endif
{ -1, NULL } {1, -1UL, NULL}
}; };
struct pg_state { struct pg_state {
@ -163,6 +167,19 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr)
st->wx_pages += (addr - st->start_address) / PAGE_SIZE; st->wx_pages += (addr - st->start_address) / PAGE_SIZE;
} }
static void note_page_update_state(struct pg_state *st, unsigned long addr, unsigned int prot, int level)
{
struct seq_file *m = st->seq;
while (addr >= st->marker[1].start_address) {
st->marker++;
pt_dump_seq_printf(m, "---[ %s ]---\n", st->marker->name);
}
st->start_address = addr;
st->current_prot = prot;
st->level = level;
}
static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, u64 val) static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, u64 val)
{ {
int width = sizeof(unsigned long) * 2; int width = sizeof(unsigned long) * 2;
@ -186,9 +203,7 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
addr = max_addr; addr = max_addr;
if (st->level == -1) { if (st->level == -1) {
pt_dump_seq_printf(m, "---[ %s ]---\n", st->marker->name); pt_dump_seq_printf(m, "---[ %s ]---\n", st->marker->name);
st->start_address = addr; note_page_update_state(st, addr, prot, level);
st->current_prot = prot;
st->level = level;
} else if (prot != st->current_prot || level != st->level || } else if (prot != st->current_prot || level != st->level ||
addr >= st->marker[1].start_address) { addr >= st->marker[1].start_address) {
note_prot_wx(st, addr); note_prot_wx(st, addr);
@ -202,13 +217,7 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
} }
pt_dump_seq_printf(m, "%9lu%c ", delta, *unit); pt_dump_seq_printf(m, "%9lu%c ", delta, *unit);
print_prot(m, st->current_prot, st->level); print_prot(m, st->current_prot, st->level);
while (addr >= st->marker[1].start_address) { note_page_update_state(st, addr, prot, level);
st->marker++;
pt_dump_seq_printf(m, "---[ %s ]---\n", st->marker->name);
}
st->start_address = addr;
st->current_prot = prot;
st->level = level;
} }
} }
@ -280,22 +289,25 @@ static int ptdump_show(struct seq_file *m, void *v)
DEFINE_SHOW_ATTRIBUTE(ptdump); DEFINE_SHOW_ATTRIBUTE(ptdump);
#endif /* CONFIG_PTDUMP_DEBUGFS */ #endif /* CONFIG_PTDUMP_DEBUGFS */
/* static int ptdump_cmp(const void *a, const void *b)
* Heapsort from lib/sort.c is not a stable sorting algorithm, do a simple
* insertion sort to preserve the original order of markers with the same
* start address.
*/
static void sort_address_markers(void)
{ {
struct addr_marker tmp; const struct addr_marker *ama = a;
int i, j; const struct addr_marker *amb = b;
for (i = 1; i < ARRAY_SIZE(address_markers) - 1; i++) { if (ama->start_address > amb->start_address)
tmp = address_markers[i]; return 1;
for (j = i - 1; j >= 0 && address_markers[j].start_address > tmp.start_address; j--) if (ama->start_address < amb->start_address)
address_markers[j + 1] = address_markers[j]; return -1;
address_markers[j + 1] = tmp; /*
} * If the start addresses of two markers are identical consider the
* marker which defines the start of an area higher than the one which
* defines the end of an area. This keeps pairs of markers sorted.
*/
if (ama->is_start)
return 1;
if (amb->is_start)
return -1;
return 0;
} }
static int pt_dump_init(void) static int pt_dump_init(void)
@ -303,6 +315,8 @@ static int pt_dump_init(void)
#ifdef CONFIG_KFENCE #ifdef CONFIG_KFENCE
unsigned long kfence_start = (unsigned long)__kfence_pool; unsigned long kfence_start = (unsigned long)__kfence_pool;
#endif #endif
unsigned long lowcore = (unsigned long)get_lowcore();
/* /*
* Figure out the maximum virtual address being accessible with the * Figure out the maximum virtual address being accessible with the
* kernel ASCE. We need this to keep the page table walker functions * kernel ASCE. We need this to keep the page table walker functions
@ -310,7 +324,10 @@ static int pt_dump_init(void)
*/ */
max_addr = (get_lowcore()->kernel_asce.val & _REGION_ENTRY_TYPE_MASK) >> 2; max_addr = (get_lowcore()->kernel_asce.val & _REGION_ENTRY_TYPE_MASK) >> 2;
max_addr = 1UL << (max_addr * 11 + 31); max_addr = 1UL << (max_addr * 11 + 31);
address_markers[IDENTITY_AFTER_END_NR].start_address = ident_map_size; address_markers[LOWCORE_START_NR].start_address = lowcore;
address_markers[LOWCORE_END_NR].start_address = lowcore + sizeof(struct lowcore);
address_markers[IDENTITY_START_NR].start_address = __identity_base;
address_markers[IDENTITY_END_NR].start_address = __identity_base + ident_map_size;
address_markers[AMODE31_START_NR].start_address = (unsigned long)__samode31; address_markers[AMODE31_START_NR].start_address = (unsigned long)__samode31;
address_markers[AMODE31_END_NR].start_address = (unsigned long)__eamode31; address_markers[AMODE31_END_NR].start_address = (unsigned long)__eamode31;
address_markers[MODULES_NR].start_address = MODULES_VADDR; address_markers[MODULES_NR].start_address = MODULES_VADDR;
@ -337,7 +354,8 @@ static int pt_dump_init(void)
address_markers[KMSAN_MODULES_ORIGIN_START_NR].start_address = KMSAN_MODULES_ORIGIN_START; address_markers[KMSAN_MODULES_ORIGIN_START_NR].start_address = KMSAN_MODULES_ORIGIN_START;
address_markers[KMSAN_MODULES_ORIGIN_END_NR].start_address = KMSAN_MODULES_ORIGIN_END; address_markers[KMSAN_MODULES_ORIGIN_END_NR].start_address = KMSAN_MODULES_ORIGIN_END;
#endif #endif
sort_address_markers(); sort(address_markers, ARRAY_SIZE(address_markers) - 1,
sizeof(address_markers[0]), ptdump_cmp, NULL);
#ifdef CONFIG_PTDUMP_DEBUGFS #ifdef CONFIG_PTDUMP_DEBUGFS
debugfs_create_file("kernel_page_tables", 0400, NULL, NULL, &ptdump_fops); debugfs_create_file("kernel_page_tables", 0400, NULL, NULL, &ptdump_fops);
#endif /* CONFIG_PTDUMP_DEBUGFS */ #endif /* CONFIG_PTDUMP_DEBUGFS */

View File

@ -108,6 +108,8 @@ void mark_rodata_ro(void)
{ {
unsigned long size = __end_ro_after_init - __start_ro_after_init; unsigned long size = __end_ro_after_init - __start_ro_after_init;
if (MACHINE_HAS_NX)
system_ctl_set_bit(0, CR0_INSTRUCTION_EXEC_PROTECTION_BIT);
__set_memory_ro(__start_ro_after_init, __end_ro_after_init); __set_memory_ro(__start_ro_after_init, __end_ro_after_init);
pr_info("Write protected read-only-after-init data: %luk\n", size >> 10); pr_info("Write protected read-only-after-init data: %luk\n", size >> 10);
} }
@ -170,13 +172,6 @@ void __init mem_init(void)
setup_zero_pages(); /* Setup zeroed pages. */ setup_zero_pages(); /* Setup zeroed pages. */
} }
void free_initmem(void)
{
set_memory_rwnx((unsigned long)_sinittext,
(unsigned long)(_einittext - _sinittext) >> PAGE_SHIFT);
free_initmem_default(POISON_FREE_INITMEM);
}
unsigned long memory_block_size_bytes(void) unsigned long memory_block_size_bytes(void)
{ {
/* /*

View File

@ -661,7 +661,6 @@ void __init vmem_map_init(void)
{ {
__set_memory_rox(_stext, _etext); __set_memory_rox(_stext, _etext);
__set_memory_ro(_etext, __end_rodata); __set_memory_ro(_etext, __end_rodata);
__set_memory_rox(_sinittext, _einittext);
__set_memory_rox(__stext_amode31, __etext_amode31); __set_memory_rox(__stext_amode31, __etext_amode31);
/* /*
* If the BEAR-enhancement facility is not installed the first * If the BEAR-enhancement facility is not installed the first
@ -670,16 +669,8 @@ void __init vmem_map_init(void)
*/ */
if (!static_key_enabled(&cpu_has_bear)) if (!static_key_enabled(&cpu_has_bear))
set_memory_x(0, 1); set_memory_x(0, 1);
if (debug_pagealloc_enabled()) { if (debug_pagealloc_enabled())
/* __set_memory_4k(__va(0), __va(0) + ident_map_size);
* Use RELOC_HIDE() as long as __va(0) translates to NULL,
* since performing pointer arithmetic on a NULL pointer
* has undefined behavior and generates compiler warnings.
*/
__set_memory_4k(__va(0), RELOC_HIDE(__va(0), ident_map_size));
}
if (MACHINE_HAS_NX)
system_ctl_set_bit(0, CR0_INSTRUCTION_EXEC_PROTECTION_BIT);
pr_info("Write protected kernel read-only data: %luk\n", pr_info("Write protected kernel read-only data: %luk\n",
(unsigned long)(__end_rodata - _stext) >> 10); (unsigned long)(__end_rodata - _stext) >> 10);
} }

View File

@ -550,4 +550,5 @@ void ccwgroup_remove_ccwdev(struct ccw_device *cdev)
put_device(&gdev->dev); put_device(&gdev->dev);
} }
EXPORT_SYMBOL(ccwgroup_remove_ccwdev); EXPORT_SYMBOL(ccwgroup_remove_ccwdev);
MODULE_DESCRIPTION("ccwgroup bus driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");

View File

@ -488,4 +488,5 @@ static void __exit vfio_ccw_sch_exit(void)
module_init(vfio_ccw_sch_init); module_init(vfio_ccw_sch_init);
module_exit(vfio_ccw_sch_exit); module_exit(vfio_ccw_sch_exit);
MODULE_DESCRIPTION("VFIO based Subchannel device driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");