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
 
                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;
         * 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
 
 
         * 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