From 0c42f392767d3592e1cf676857d398ef69be7c9c Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Wed, 30 Jan 2008 13:33:42 +0100 Subject: 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 Acked-by: Jan Beulich Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- arch/x86/mm/init_32.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'arch/x86/mm/init_32.c') diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 459b384acda..724a5eff6f3 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -799,6 +799,20 @@ void mark_rodata_ro(void) change_page_attr(virt_to_page(start), size >> PAGE_SHIFT, PAGE_KERNEL_RX); printk("Write protecting the kernel text: %luk\n", size >> 10); + +#ifdef CONFIG_CPA_DEBUG + global_flush_tlb(); + + printk("Testing CPA: Reverting %lx-%lx\n", start, start+size); + change_page_attr(virt_to_page(start), size>>PAGE_SHIFT, + PAGE_KERNEL_EXEC); + global_flush_tlb(); + + printk("Testing CPA: write protecting again\n"); + change_page_attr(virt_to_page(start), size>>PAGE_SHIFT, + PAGE_KERNEL_RX); + global_flush_tlb(); +#endif } #endif start += size; @@ -815,6 +829,18 @@ void mark_rodata_ro(void) * of who is the culprit. */ global_flush_tlb(); + +#ifdef CONFIG_CPA_DEBUG + printk("Testing CPA: undo %lx-%lx\n", start, start + size); + change_page_attr(virt_to_page(start), size >> PAGE_SHIFT, + PAGE_KERNEL); + global_flush_tlb(); + + printk("Testing CPA: write protecting again\n"); + change_page_attr(virt_to_page(start), size >> PAGE_SHIFT, + PAGE_KERNEL_RO); + global_flush_tlb(); +#endif } #endif -- cgit v1.2.3