diff options
author | Arjan van de Ven <arjan@infradead.org> | 2007-06-21 01:23:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-06-21 19:02:50 -0400 |
commit | 0864a4e201b1ea442f4c8b887418a29f67e24d30 (patch) | |
tree | cee5372bb22502e52029543dfb72c571a1e89faa /arch | |
parent | 79d9a72f87d0a6f910be262a9dd4c36e96972a92 (diff) |
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/i386/Kconfig.debug | 1 | ||||
-rw-r--r-- | arch/i386/mm/init.c | 3 | ||||
-rw-r--r-- | arch/x86_64/Kconfig.debug | 1 | ||||
-rw-r--r-- | arch/x86_64/mm/init.c | 5 |
4 files changed, 7 insertions, 3 deletions
diff --git a/arch/i386/Kconfig.debug b/arch/i386/Kconfig.debug index 6293920cd1be..b31c0802e1cc 100644 --- a/arch/i386/Kconfig.debug +++ b/arch/i386/Kconfig.debug | |||
@@ -49,7 +49,6 @@ config DEBUG_PAGEALLOC | |||
49 | config DEBUG_RODATA | 49 | config DEBUG_RODATA |
50 | bool "Write protect kernel read-only data structures" | 50 | bool "Write protect kernel read-only data structures" |
51 | depends on DEBUG_KERNEL | 51 | depends on DEBUG_KERNEL |
52 | depends on !KPROBES # temporary for 2.6.22 | ||
53 | help | 52 | help |
54 | Mark the kernel read-only data as write-protected in the pagetables, | 53 | Mark the kernel read-only data as write-protected in the pagetables, |
55 | in order to catch accidental (and incorrect) writes to such const | 54 | in order to catch accidental (and incorrect) writes to such const |
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c index b22ce8d6b1ba..7135946d3663 100644 --- a/arch/i386/mm/init.c +++ b/arch/i386/mm/init.c | |||
@@ -799,6 +799,7 @@ void mark_rodata_ro(void) | |||
799 | unsigned long start = PFN_ALIGN(_text); | 799 | unsigned long start = PFN_ALIGN(_text); |
800 | unsigned long size = PFN_ALIGN(_etext) - start; | 800 | unsigned long size = PFN_ALIGN(_etext) - start; |
801 | 801 | ||
802 | #ifndef CONFIG_KPROBES | ||
802 | #ifdef CONFIG_HOTPLUG_CPU | 803 | #ifdef CONFIG_HOTPLUG_CPU |
803 | /* It must still be possible to apply SMP alternatives. */ | 804 | /* It must still be possible to apply SMP alternatives. */ |
804 | if (num_possible_cpus() <= 1) | 805 | if (num_possible_cpus() <= 1) |
@@ -808,7 +809,7 @@ void mark_rodata_ro(void) | |||
808 | size >> PAGE_SHIFT, PAGE_KERNEL_RX); | 809 | size >> PAGE_SHIFT, PAGE_KERNEL_RX); |
809 | printk("Write protecting the kernel text: %luk\n", size >> 10); | 810 | printk("Write protecting the kernel text: %luk\n", size >> 10); |
810 | } | 811 | } |
811 | 812 | #endif | |
812 | start += size; | 813 | start += size; |
813 | size = (unsigned long)__end_rodata - start; | 814 | size = (unsigned long)__end_rodata - start; |
814 | change_page_attr(virt_to_page(start), | 815 | change_page_attr(virt_to_page(start), |
diff --git a/arch/x86_64/Kconfig.debug b/arch/x86_64/Kconfig.debug index 8a8677518447..775d211a5cf9 100644 --- a/arch/x86_64/Kconfig.debug +++ b/arch/x86_64/Kconfig.debug | |||
@@ -9,7 +9,6 @@ source "lib/Kconfig.debug" | |||
9 | config DEBUG_RODATA | 9 | config DEBUG_RODATA |
10 | bool "Write protect kernel read-only data structures" | 10 | bool "Write protect kernel read-only data structures" |
11 | depends on DEBUG_KERNEL | 11 | depends on DEBUG_KERNEL |
12 | depends on !KPROBES # temporary for 2.6.22 | ||
13 | help | 12 | help |
14 | Mark the kernel read-only data as write-protected in the pagetables, | 13 | Mark the kernel read-only data as write-protected in the pagetables, |
15 | in order to catch accidental (and incorrect) writes to such const data. | 14 | in order to catch accidental (and incorrect) writes to such const data. |
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c index efb6e845114e..9a0e98accf04 100644 --- a/arch/x86_64/mm/init.c +++ b/arch/x86_64/mm/init.c | |||
@@ -605,6 +605,11 @@ void mark_rodata_ro(void) | |||
605 | if (num_possible_cpus() > 1) | 605 | if (num_possible_cpus() > 1) |
606 | start = (unsigned long)_etext; | 606 | start = (unsigned long)_etext; |
607 | #endif | 607 | #endif |
608 | |||
609 | #ifdef CONFIG_KPROBES | ||
610 | start = (unsigned long)__start_rodata; | ||
611 | #endif | ||
612 | |||
608 | end = (unsigned long)__end_rodata; | 613 | end = (unsigned long)__end_rodata; |
609 | start = (start + PAGE_SIZE - 1) & PAGE_MASK; | 614 | start = (start + PAGE_SIZE - 1) & PAGE_MASK; |
610 | end &= PAGE_MASK; | 615 | end &= PAGE_MASK; |