浏览代码

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>
Heiko Carstens 9 年之前
父节点
当前提交
91d3721176
共有 2 个文件被更改,包括 10 次插入3 次删除
  1. 3 0
      arch/s390/Kconfig
  2. 7 3
      arch/s390/mm/init.c

+ 3 - 0
arch/s390/Kconfig

@@ -59,6 +59,9 @@ config PCI_QUIRKS
 config ARCH_SUPPORTS_UPROBES
 config ARCH_SUPPORTS_UPROBES
 	def_bool y
 	def_bool y
 
 
+config DEBUG_RODATA
+	def_bool y
+
 config S390
 config S390
 	def_bool y
 	def_bool y
 	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
 	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE

+ 7 - 3
arch/s390/mm/init.c

@@ -108,6 +108,13 @@ void __init paging_init(void)
 	free_area_init_nodes(max_zone_pfns);
 	free_area_init_nodes(max_zone_pfns);
 }
 }
 
 
+void mark_rodata_ro(void)
+{
+	/* Text and rodata are already protected. Nothing to do here. */
+	pr_info("Write protecting the kernel read-only data: %luk\n",
+		((unsigned long)&_eshared - (unsigned long)&_stext) >> 10);
+}
+
 void __init mem_init(void)
 void __init mem_init(void)
 {
 {
 	if (MACHINE_HAS_TLB_LC)
 	if (MACHINE_HAS_TLB_LC)
@@ -126,9 +133,6 @@ void __init mem_init(void)
 	setup_zero_pages();	/* Setup zeroed pages. */
 	setup_zero_pages();	/* Setup zeroed pages. */
 
 
 	mem_init_print_info(NULL);
 	mem_init_print_info(NULL);
-	printk("Write protected kernel read-only data: %#lx - %#lx\n",
-	       (unsigned long)&_stext,
-	       PFN_ALIGN((unsigned long)&_eshared) - 1);
 }
 }
 
 
 void free_initmem(void)
 void free_initmem(void)