Skip to content

Commit f11d75e

Browse files
committed
Merge: Fix kdump problem on s390x
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7140 JIRA: https://issues.redhat.com/browse/RHEL-103929 A recent backport introduce a regression that causes the reboot after a kdump to fail on s390x. We need these patches here to fix this issue. Signed-off-by: Thomas Huth <thuth@redhat.com> Resolves: RHEL-103929 Approved-by: David Hildenbrand <david@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents fa843e6 + aea898a commit f11d75e

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

arch/s390/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,19 @@ config RANDOMIZE_BASE
623623
as a security feature that deters exploit attempts relying on
624624
knowledge of the location of kernel internals.
625625

626+
config RANDOMIZE_IDENTITY_BASE
627+
bool "Randomize the address of the identity mapping base"
628+
depends on RANDOMIZE_BASE
629+
default DEBUG_VM
630+
help
631+
The identity mapping base address is pinned to zero by default.
632+
Allow randomization of that base to expose otherwise missed
633+
notion of physical and virtual addresses of data structures.
634+
That does not have any impact on the base address at which the
635+
kernel image is loaded.
636+
637+
If unsure, say N
638+
626639
config KERNEL_IMAGE_BASE
627640
hex "Kernel image base address"
628641
range 0x100000 0x1FFFFFE0000000 if !KASAN

arch/s390/boot/startup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ static unsigned long setup_kernel_memory_layout(unsigned long kernel_size)
336336
BUILD_BUG_ON(MAX_DCSS_ADDR > (1UL << MAX_PHYSMEM_BITS));
337337
max_mappable = max(ident_map_size, MAX_DCSS_ADDR);
338338
max_mappable = min(max_mappable, vmemmap_start);
339-
__identity_base = round_down(vmemmap_start - max_mappable, rte_size);
339+
if (IS_ENABLED(CONFIG_RANDOMIZE_IDENTITY_BASE))
340+
__identity_base = round_down(vmemmap_start - max_mappable, rte_size);
340341

341342
return asce_limit;
342343
}

arch/s390/kernel/setup.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,23 @@ static void __init memblock_add_physmem_info(void)
735735
}
736736

737737
/*
738-
* Reserve memory used for lowcore/command line/kernel image.
738+
* Reserve memory used for lowcore.
739+
*/
740+
static void __init reserve_lowcore(void)
741+
{
742+
void *lowcore_start = get_lowcore();
743+
void *lowcore_end = lowcore_start + sizeof(struct lowcore);
744+
void *start, *end;
745+
746+
if ((void *)__identity_base < lowcore_end) {
747+
start = max(lowcore_start, (void *)__identity_base);
748+
end = min(lowcore_end, (void *)(__identity_base + ident_map_size));
749+
memblock_reserve(__pa(start), __pa(end));
750+
}
751+
}
752+
753+
/*
754+
* Reserve memory used for absolute lowcore/command line/kernel image.
739755
*/
740756
static void __init reserve_kernel(void)
741757
{
@@ -923,6 +939,7 @@ void __init setup_arch(char **cmdline_p)
923939

924940
/* Do some memory reservations *before* memory is added to memblock */
925941
reserve_pgtables();
942+
reserve_lowcore();
926943
reserve_kernel();
927944
reserve_initrd();
928945
reserve_certificate_list();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# CONFIG_RANDOMIZE_IDENTITY_BASE is not set

0 commit comments

Comments
 (0)