]> err.no Git - linux-2.6/commitdiff
c_p_a(): do a simple self test at boot
authorAndi Kleen <ak@suse.de>
Wed, 30 Jan 2008 12:33:42 +0000 (13:33 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 30 Jan 2008 12:33:42 +0000 (13:33 +0100)
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>
arch/x86/Kconfig.debug
arch/x86/mm/init_32.c
arch/x86/mm/init_64.c

index 9bb61e1aed69c5311b3df96256460c15886ef3fd..38211ff0447f86beb5d541649b4bf045e1ab2187 100644 (file)
@@ -204,4 +204,9 @@ config DEBUG_BOOT_PARAMS
        help
          This option will cause struct boot_params to be exported via debugfs.
 
+config CPA_DEBUG
+       bool "CPA self test code"
+       help
+         Do change_page_attr self tests at boot.
+
 endmenu
index 459b384acda9ea40282becd59ba9190fa31ef860..724a5eff6f343f27d2c3d8c0b7e719aacc2dafcc 100644 (file)
@@ -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
 
index 8198840c3dcba73cc156719d45f6126a7b46b0f8..0fd9d7f77786193a7fc77f18e1093fa150118d84 100644 (file)
@@ -606,6 +606,16 @@ 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, end);
+       change_page_attr_addr(start, (end - start) >> PAGE_SHIFT, PAGE_KERNEL);
+       global_flush_tlb();
+
+       printk("Testing CPA: again\n");
+       change_page_attr_addr(start, (end - start) >> PAGE_SHIFT, PAGE_KERNEL_RO);
+       global_flush_tlb();
+#endif
 }
 #endif