Allow DEBUG_RODATA and KPROBES to co-exist

Do not mark the kernel text read only if KPROBES is in the kernel;
kprobes needs to hot-patch the kernel text to insert it's
instrumentation.

In this case, only mark the .rodata segment as read only.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Tested-by: S. P. Prasanna <prasanna@in.ibm.com>
Cc: Andi Kleen <ak@suse.de>
Cc: William Cohen <wcohen@redhat.com>
Cc: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Arjan van de Ven and committed by Linus Torvalds 0864a4e2 79d9a72f

+7 -3
-1
arch/i386/Kconfig.debug
··· 49 49 config DEBUG_RODATA 50 50 bool "Write protect kernel read-only data structures" 51 51 depends on DEBUG_KERNEL 52 - depends on !KPROBES # temporary for 2.6.22 53 52 help 54 53 Mark the kernel read-only data as write-protected in the pagetables, 55 54 in order to catch accidental (and incorrect) writes to such const
+2 -1
arch/i386/mm/init.c
··· 799 799 unsigned long start = PFN_ALIGN(_text); 800 800 unsigned long size = PFN_ALIGN(_etext) - start; 801 801 802 + #ifndef CONFIG_KPROBES 802 803 #ifdef CONFIG_HOTPLUG_CPU 803 804 /* It must still be possible to apply SMP alternatives. */ 804 805 if (num_possible_cpus() <= 1) ··· 809 808 size >> PAGE_SHIFT, PAGE_KERNEL_RX); 810 809 printk("Write protecting the kernel text: %luk\n", size >> 10); 811 810 } 812 - 811 + #endif 813 812 start += size; 814 813 size = (unsigned long)__end_rodata - start; 815 814 change_page_attr(virt_to_page(start),
-1
arch/x86_64/Kconfig.debug
··· 9 9 config DEBUG_RODATA 10 10 bool "Write protect kernel read-only data structures" 11 11 depends on DEBUG_KERNEL 12 - depends on !KPROBES # temporary for 2.6.22 13 12 help 14 13 Mark the kernel read-only data as write-protected in the pagetables, 15 14 in order to catch accidental (and incorrect) writes to such const data.
+5
arch/x86_64/mm/init.c
··· 605 605 if (num_possible_cpus() > 1) 606 606 start = (unsigned long)_etext; 607 607 #endif 608 + 609 + #ifdef CONFIG_KPROBES 610 + start = (unsigned long)__start_rodata; 611 + #endif 612 + 608 613 end = (unsigned long)__end_rodata; 609 614 start = (start + PAGE_SIZE - 1) & PAGE_MASK; 610 615 end &= PAGE_MASK;