x86/gdt: Fix setup_fixmap_gdt() to use the correct PA
authorAndy Lutomirski <[email protected]>
Wed, 22 Mar 2017 21:32:30 +0000 (14:32 -0700)
committerIngo Molnar <[email protected]>
Thu, 23 Mar 2017 07:25:07 +0000 (08:25 +0100)
__pa() cannot be used on percpu pointers because they may be
virtually mapped.  Use per_cpu_ptr_to_phys() instead.

This fixes a boot crash on a some 32-bit configurations.  I assume
this is related to which allocation strategy is chosen by the percpu
core.

Signed-off-by: Andy Lutomirski <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Garnier <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Fixes: 69218e47994d x86: ("Remap GDT tables in the fixmap section")
Link: http://lkml.kernel.org/r/22e0069c29fba31998f193201e359eebfdac4960.1490218061.git.luto@kernel.org
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/include/asm/desc.h
arch/x86/kernel/cpu/common.c

index ec05f9c1a62c84dbcece3c2f754da8fe4e79f153..bde11696b893fdab2ad262031f363fc473e994ae 100644 (file)
@@ -98,6 +98,12 @@ static inline unsigned long get_current_gdt_ro_vaddr(void)
        return (unsigned long)get_current_gdt_ro();
 }
 
+/* Provide the physical address of the GDT page. */
+static inline phys_addr_t get_cpu_gdt_paddr(unsigned int cpu)
+{
+       return per_cpu_ptr_to_phys(get_cpu_gdt_rw(cpu));
+}
+
 #ifdef CONFIG_X86_64
 
 static inline void pack_gate(gate_desc *gate, unsigned type, unsigned long func,
index f8e22dbad86c2c633d46ed9fba4d4443fcca6c6b..f6e20e2dbfa57772539e99cb09628631235fc301 100644 (file)
@@ -461,8 +461,8 @@ pgprot_t pg_fixmap_gdt_flags = PAGE_KERNEL;
 /* Setup the fixmap mapping only once per-processor */
 static inline void setup_fixmap_gdt(int cpu)
 {
-       __set_fixmap(get_cpu_gdt_ro_index(cpu),
-                    __pa(get_cpu_gdt_rw(cpu)), pg_fixmap_gdt_flags);
+       __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu),
+                    pg_fixmap_gdt_flags);
 }
 
 /* Load the original GDT from the per-cpu structure */