Skip to content

Commit d425243

Browse files
heicarstAlex Shi
authored andcommitted
s390: add DEBUG_RODATA support
git commit d2aa1acad22f ("mm/init: Add 'rodata=off' boot cmdline parameter to disable read-only kernel mappings") adds a bogus warning to the console which states that s390 does not support kernel memory protection. This however is not true. We do support that since a couple of years however in a different way than the author of the above named patch expected. To get rid of the misleading message implement the mark_rodata_ro function and emit a message which states the amount of memory which was write protected already earlier. This is the same what parisc currently does. We currently do not support the kernel parameter "rodata=off" which would allow to write to the rodata section again. However since we have this feature since years without any problems there is no reason to add support for this. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> (cherry picked from commit 91d37211769510ae0b4747045d8f81d3b9dd4278) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent 8966317 commit d425243

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

arch/s390/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ config PCI_QUIRKS
6262
config ARCH_SUPPORTS_UPROBES
6363
def_bool y
6464

65+
config DEBUG_RODATA
66+
def_bool y
67+
6568
config S390
6669
def_bool y
6770
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE

arch/s390/mm/init.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ void __init paging_init(void)
108108
free_area_init_nodes(max_zone_pfns);
109109
}
110110

111+
void mark_rodata_ro(void)
112+
{
113+
/* Text and rodata are already protected. Nothing to do here. */
114+
pr_info("Write protecting the kernel read-only data: %luk\n",
115+
((unsigned long)&_eshared - (unsigned long)&_stext) >> 10);
116+
}
117+
111118
void __init mem_init(void)
112119
{
113120
if (MACHINE_HAS_TLB_LC)
@@ -126,9 +133,6 @@ void __init mem_init(void)
126133
setup_zero_pages(); /* Setup zeroed pages. */
127134

128135
mem_init_print_info(NULL);
129-
printk("Write protected kernel read-only data: %#lx - %#lx\n",
130-
(unsigned long)&_stext,
131-
PFN_ALIGN((unsigned long)&_eshared) - 1);
132136
}
133137

134138
void free_initmem(void)

0 commit comments

Comments
 (0)