Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0c42f392767d3592e1cf676857d398ef69be7c9c
Commit:     0c42f392767d3592e1cf676857d398ef69be7c9c
Parent:     b4416a1be86b0c7bdde4e6ba526715c1a055746f
Author:     Andi Kleen <[EMAIL PROTECTED]>
AuthorDate: Wed Jan 30 13:33:42 2008 +0100
Committer:  Ingo Molnar <[EMAIL PROTECTED]>
CommitDate: Wed Jan 30 13:33:42 2008 +0100

    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 <[EMAIL PROTECTED]>
    Acked-by: Jan Beulich <[EMAIL PROTECTED]>
    Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
    Signed-off-by: Thomas Gleixner <[EMAIL PROTECTED]>
---
 arch/x86/Kconfig.debug |    5 +++++
 arch/x86/mm/init_32.c  |   26 ++++++++++++++++++++++++++
 arch/x86/mm/init_64.c  |   10 ++++++++++
 3 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 9bb61e1..38211ff 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -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
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 459b384..724a5ef 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
 
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 8198840..0fd9d7f 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -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
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to