aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2008-01-30 07:33:42 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:33:42 -0500
commit0c42f392767d3592e1cf676857d398ef69be7c9c (patch)
tree0ae79fb0424ed9340ad973bea013251e05553be4
parentb4416a1be86b0c7bdde4e6ba526715c1a055746f (diff)
c_p_a(): do a simple self test at boot
When CONFIG_DEBUG_RODATA is enabled undo the ro mapping and redo it again. This gives some simple testing for change_page_attr(). Signed-off-by: Andi Kleen <ak@suse.de> Acked-by: Jan Beulich <jbeulich@novell.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/Kconfig.debug5
-rw-r--r--arch/x86/mm/init_32.c26
-rw-r--r--arch/x86/mm/init_64.c10
3 files changed, 41 insertions, 0 deletions
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 9bb61e1aed69..38211ff0447f 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -204,4 +204,9 @@ config DEBUG_BOOT_PARAMS
204 help 204 help
205 This option will cause struct boot_params to be exported via debugfs. 205 This option will cause struct boot_params to be exported via debugfs.
206 206
207config CPA_DEBUG
208 bool "CPA self test code"
209 help
210 Do change_page_attr self tests at boot.
211
207endmenu 212endmenu
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 459b384acda9..724a5eff6f34 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -799,6 +799,20 @@ void mark_rodata_ro(void)
799 change_page_attr(virt_to_page(start), 799 change_page_attr(virt_to_page(start),
800 size >> PAGE_SHIFT, PAGE_KERNEL_RX); 800 size >> PAGE_SHIFT, PAGE_KERNEL_RX);
801 printk("Write protecting the kernel text: %luk\n", size >> 10); 801 printk("Write protecting the kernel text: %luk\n", size >> 10);
802
803#ifdef CONFIG_CPA_DEBUG
804 global_flush_tlb();
805
806 printk("Testing CPA: Reverting %lx-%lx\n", start, start+size);
807 change_page_attr(virt_to_page(start), size>>PAGE_SHIFT,
808 PAGE_KERNEL_EXEC);
809 global_flush_tlb();
810
811 printk("Testing CPA: write protecting again\n");
812 change_page_attr(virt_to_page(start), size>>PAGE_SHIFT,
813 PAGE_KERNEL_RX);
814 global_flush_tlb();
815#endif
802 } 816 }
803#endif 817#endif
804 start += size; 818 start += size;
@@ -815,6 +829,18 @@ void mark_rodata_ro(void)
815 * of who is the culprit. 829 * of who is the culprit.
816 */ 830 */
817 global_flush_tlb(); 831 global_flush_tlb();
832
833#ifdef CONFIG_CPA_DEBUG
834 printk("Testing CPA: undo %lx-%lx\n", start, start + size);
835 change_page_attr(virt_to_page(start), size >> PAGE_SHIFT,
836 PAGE_KERNEL);
837 global_flush_tlb();
838
839 printk("Testing CPA: write protecting again\n");
840 change_page_attr(virt_to_page(start), size >> PAGE_SHIFT,
841 PAGE_KERNEL_RO);
842 global_flush_tlb();
843#endif
818} 844}
819#endif 845#endif
820 846
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 8198840c3dcb..0fd9d7f77786 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -606,6 +606,16 @@ void mark_rodata_ro(void)
606 * of who is the culprit. 606 * of who is the culprit.
607 */ 607 */
608 global_flush_tlb(); 608 global_flush_tlb();
609
610#ifdef CONFIG_CPA_DEBUG
611 printk("Testing CPA: undo %lx-%lx\n", start, end);
612 change_page_attr_addr(start, (end - start) >> PAGE_SHIFT, PAGE_KERNEL);
613 global_flush_tlb();
614
615 printk("Testing CPA: again\n");
616 change_page_attr_addr(start, (end - start) >> PAGE_SHIFT, PAGE_KERNEL_RO);
617 global_flush_tlb();
618#endif
609} 619}
610#endif 620#endif
611 621