Patch "s390/mm: Prevent lowcore vs identity mapping overlap" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    s390/mm: Prevent lowcore vs identity mapping overlap

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     s390-mm-prevent-lowcore-vs-identity-mapping-overlap.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4b415d5497099086b01b2e99a38c1b956f13db7f
Author: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
Date:   Fri Aug 9 08:47:15 2024 +0200

    s390/mm: Prevent lowcore vs identity mapping overlap
    
    [ Upstream commit a3ca27c405faad584af6e8e38cdafe5be73230a1 ]
    
    The identity mapping position in virtual memory is randomized
    together with the kernel mapping. That position can never
    overlap with the lowcore even when the lowcore is relocated.
    
    Prevent overlapping with the lowcore to allow independent
    positioning of the identity mapping. With the current value
    of the alternative lowcore address of 0x70000 the overlap
    could happen in case the identity mapping is placed at zero.
    
    This is a prerequisite for uncoupling of randomization base
    of kernel image and identity mapping in virtual memory.
    
    Acked-by: Vasily Gorbik <gor@xxxxxxxxxxxxx>
    Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
    Signed-off-by: Vasily Gorbik <gor@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index d48c7afe97e6..89fe0764af84 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -741,7 +741,23 @@ static void __init memblock_add_physmem_info(void)
 }
 
 /*
- * Reserve memory used for lowcore/command line/kernel image.
+ * Reserve memory used for lowcore.
+ */
+static void __init reserve_lowcore(void)
+{
+	void *lowcore_start = get_lowcore();
+	void *lowcore_end = lowcore_start + sizeof(struct lowcore);
+	void *start, *end;
+
+	if ((void *)__identity_base < lowcore_end) {
+		start = max(lowcore_start, (void *)__identity_base);
+		end = min(lowcore_end, (void *)(__identity_base + ident_map_size));
+		memblock_reserve(__pa(start), __pa(end));
+	}
+}
+
+/*
+ * Reserve memory used for absolute lowcore/command line/kernel image.
  */
 static void __init reserve_kernel(void)
 {
@@ -939,6 +955,7 @@ void __init setup_arch(char **cmdline_p)
 
 	/* Do some memory reservations *before* memory is added to memblock */
 	reserve_pgtables();
+	reserve_lowcore();
 	reserve_kernel();
 	reserve_initrd();
 	reserve_certificate_list();




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux