init: move stack canary initialization after setup_arch
[sfrench/cifs-2.6.git] / init / main.c
index b78f63c30b1718d5683e992ab264d421b8888e5b..ae5d1fd780819ecf8dc3a8a899344e7f0869fcfc 100644 (file)
@@ -487,6 +487,8 @@ void __init __weak thread_stack_cache_init(void)
 }
 #endif
 
+void __init __weak mem_encrypt_init(void) { }
+
 /*
  * Set up kernel memory allocators
  */
@@ -499,7 +501,6 @@ static void __init mm_init(void)
        page_ext_init_flatmem();
        mem_init();
        kmem_cache_init();
-       percpu_init_late();
        pgtable_init();
        vmalloc_init();
        ioremap_huge_init();
@@ -514,12 +515,6 @@ asmlinkage __visible void __init start_kernel(void)
        smp_setup_processor_id();
        debug_objects_early_init();
 
-       /*
-        * Set up the initial canary ASAP:
-        */
-       add_latent_entropy();
-       boot_init_stack_canary();
-
        cgroup_init_early();
 
        local_irq_disable();
@@ -533,6 +528,11 @@ asmlinkage __visible void __init start_kernel(void)
        page_address_init();
        pr_notice("%s", linux_banner);
        setup_arch(&command_line);
+       /*
+        * Set up the the initial canary and entropy after arch
+        */
+       add_latent_entropy();
+       boot_init_stack_canary();
        mm_init_cpumask(&init_mm);
        setup_command_line(command_line);
        setup_nr_cpu_ids();
@@ -540,7 +540,7 @@ asmlinkage __visible void __init start_kernel(void)
        boot_cpu_state_init();
        smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
 
-       build_all_zonelists(NULL, NULL);
+       build_all_zonelists(NULL);
        page_alloc_init();
 
        pr_notice("Kernel command line: %s\n", boot_command_line);
@@ -640,6 +640,14 @@ asmlinkage __visible void __init start_kernel(void)
         */
        locking_selftest();
 
+       /*
+        * This needs to be called before any devices perform DMA
+        * operations that might use the SWIOTLB bounce buffers. It will
+        * mark the bounce buffers as decrypted so that their usage will
+        * not cause "plain-text" data to be decrypted when accessed.
+        */
+       mem_encrypt_init();
+
 #ifdef CONFIG_BLK_DEV_INITRD
        if (initrd_start && !initrd_below_start_ok &&
            page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) {