s390/vmlinux.lds.S: Move ro_after_init section behind rodata section
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 29 Jul 2024 11:06:43 +0000 (13:06 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Wed, 31 Jul 2024 14:30:20 +0000 (16:30 +0200)
The .data.rel.ro and .got section were added between the rodata and
ro_after_init data section, which adds an RW mapping in between all RO
mapping of the kernel image:

---[ Kernel Image Start ]---
0x000003ffe0000000-0x000003ffe0e00000        14M PMD RO X
0x000003ffe0e00000-0x000003ffe0ec7000       796K PTE RO X
0x000003ffe0ec7000-0x000003ffe0f00000       228K PTE RO NX
0x000003ffe0f00000-0x000003ffe1300000         4M PMD RO NX
0x000003ffe1300000-0x000003ffe1331000       196K PTE RO NX
0x000003ffe1331000-0x000003ffe13b3000       520K PTE RW NX <---
0x000003ffe13b3000-0x000003ffe13d5000       136K PTE RO NX
0x000003ffe13d5000-0x000003ffe1400000       172K PTE RW NX
0x000003ffe1400000-0x000003ffe1500000         1M PMD RW NX
0x000003ffe1500000-0x000003ffe1700000         2M PTE RW NX
0x000003ffe1700000-0x000003ffe1800000         1M PMD RW NX
0x000003ffe1800000-0x000003ffe187e000       504K PTE RW NX
---[ Kernel Image End ]---

Move the ro_after_init data section again right behind the rodata
section to prevent interleaving RO and RW mappings:

---[ Kernel Image Start ]---
0x000003ffe0000000-0x000003ffe0e00000        14M PMD RO X
0x000003ffe0e00000-0x000003ffe0ec7000       796K PTE RO X
0x000003ffe0ec7000-0x000003ffe0f00000       228K PTE RO NX
0x000003ffe0f00000-0x000003ffe1300000         4M PMD RO NX
0x000003ffe1300000-0x000003ffe1353000       332K PTE RO NX
0x000003ffe1353000-0x000003ffe1400000       692K PTE RW NX
0x000003ffe1400000-0x000003ffe1500000         1M PMD RW NX
0x000003ffe1500000-0x000003ffe1700000         2M PTE RW NX
0x000003ffe1700000-0x000003ffe1800000         1M PMD RW NX
0x000003ffe1800000-0x000003ffe187e000       504K PTE RW NX
---[ Kernel Image End ]---

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/kernel/vmlinux.lds.S

index 975c654cf5a51f42f89862895240e58c013a008d..e67cd409b8587117925e2c0d1e4e8ec7eb126ea0 100644 (file)
@@ -59,14 +59,6 @@ SECTIONS
        } :text = 0x0700
 
        RO_DATA(PAGE_SIZE)
-       .data.rel.ro : {
-               *(.data.rel.ro .data.rel.ro.*)
-       }
-       .got : {
-               __got_start = .;
-               *(.got)
-               __got_end = .;
-       }
 
        . = ALIGN(PAGE_SIZE);
        _sdata = .;             /* Start of data section */
@@ -80,6 +72,15 @@ SECTIONS
        . = ALIGN(PAGE_SIZE);
        __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)
        .data.rel : {
                *(.data.rel*)