x86: cpa: set_memory_notpresent()
[sfrench/cifs-2.6.git] / arch / x86 / mm / init_64.c
index 05bb12db0b09cb065f5223bc18923c0f8b761249..4757be7b5e5554dd5f476cfc1ef27fa0c6f9ccf7 100644 (file)
@@ -559,8 +559,21 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
                free_page(addr);
                totalram_pages++;
        }
-       if (addr > __START_KERNEL_map)
-               global_flush_tlb();
+#ifdef CONFIG_DEBUG_RODATA
+       /*
+        * This will make the __init pages not present and
+        * not executable, so that any attempt to use a
+        * __init function from now on will fault immediately
+        * rather than supriously later when memory gets reused.
+        *
+        * We only do this for DEBUG_RODATA to not break up the
+        * 2Mb kernel mapping just for this debug feature.
+        */
+       if (begin >= __START_KERNEL_map) {
+               set_memory_np(begin, (end - begin)/PAGE_SIZE);
+               set_memory_nx(begin, (end - begin)/PAGE_SIZE);
+       }
+#endif
 }
 
 void free_initmem(void)