]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86/boot/32: Fix UP boot on Quark and possibly other platforms
authorAndy Lutomirski <luto@kernel.org>
Tue, 9 May 2017 00:09:10 +0000 (17:09 -0700)
committerIngo Molnar <mingo@kernel.org>
Tue, 9 May 2017 06:14:24 +0000 (08:14 +0200)
This partially reverts commit:

  23b2a4ddebdd17f ("x86/boot/32: Defer resyncing initial_page_table until per-cpu is set up")

That commit had one definite bug and one potential bug.  The
definite bug is that setup_per_cpu_areas() uses a differnet generic
implementation on UP kernels, so initial_page_table never got
resynced.  This was fine for access to percpu data (it's in the
identity map on UP), but it breaks other users of
initial_page_table.  The potential bug is that helpers like
efi_init() would be called before the tables were synced.

Avoid both problems by just syncing the page tables in setup_arch()
*and* setup_per_cpu_areas().

Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/setup.c
arch/x86/kernel/setup_percpu.c

index 603a1669a2ecf2ba62f0b24bee93955296a9f97c..0b4d3c686b1ef94463c8caabce01e38404d1b8c1 100644 (file)
@@ -1225,6 +1225,21 @@ void __init setup_arch(char **cmdline_p)
 
        kasan_init();
 
+#ifdef CONFIG_X86_32
+       /* sync back kernel address range */
+       clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,
+                       swapper_pg_dir     + KERNEL_PGD_BOUNDARY,
+                       KERNEL_PGD_PTRS);
+
+       /*
+        * sync back low identity map too.  It is used for example
+        * in the 32-bit EFI stub.
+        */
+       clone_pgd_range(initial_page_table,
+                       swapper_pg_dir     + KERNEL_PGD_BOUNDARY,
+                       min(KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
+#endif
+
        tboot_probe();
 
        map_vsyscall();
index bb1e8cc0bc84816b8976dec088d3c18b038f8c01..10edd1e69a68bffcc7ee22ef220b25c24cadfc62 100644 (file)
@@ -291,11 +291,11 @@ void __init setup_per_cpu_areas(void)
 
 #ifdef CONFIG_X86_32
        /*
-        * Sync back kernel address range.  We want to make sure that
-        * all kernel mappings, including percpu mappings, are available
-        * in the smpboot asm.  We can't reliably pick up percpu
-        * mappings using vmalloc_fault(), because exception dispatch
-        * needs percpu data.
+        * Sync back kernel address range again.  We already did this in
+        * setup_arch(), but percpu data also needs to be available in
+        * the smpboot asm.  We can't reliably pick up percpu mappings
+        * using vmalloc_fault(), because exception dispatch needs
+        * percpu data.
         */
        clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,
                        swapper_pg_dir     + KERNEL_PGD_BOUNDARY,