From: Joerg Roedel <[email protected]>

PTI init code clones some parts of the kernel mappings to the user-space
page-table. For the kernel and user-space page-table to be consistent,
the cloning should happen when the relevant parts of the kernel
page-table are finished, which is right after mark_readonly() returns.

Signed-off-by: Joerg Roedel <[email protected]>
---
 init/main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/init/main.c b/init/main.c
index 3b4ada1..0b5d0f1 100644
--- a/init/main.c
+++ b/init/main.c
@@ -524,8 +524,6 @@ static void __init mm_init(void)
        ioremap_huge_init();
        /* Should be run before the first non-init thread is created */
        init_espfix_bsp();
-       /* Should be run after espfix64 is set up. */
-       pti_init();
 }
 
 asmlinkage __visible void __init start_kernel(void)
@@ -1065,6 +1063,12 @@ static int __ref kernel_init(void *unused)
        jump_label_invalidate_initmem();
        free_initmem();
        mark_readonly();
+       /*
+        * Kernel text/rodata/data sections have the right protections
+        * now. If necessary, init PTI and clone the relevant pieces
+        * to the user-space page-table.
+        */
+       pti_init();
        system_state = SYSTEM_RUNNING;
        numa_default_policy();
 
-- 
2.7.4

Reply via email to