]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
x86/xen/gdt: Use X86_FEATURE_XENPV instead of globals for the GDT fixup
authorAndy Lutomirski <luto@kernel.org>
Wed, 22 Mar 2017 21:32:34 +0000 (14:32 -0700)
committerIngo Molnar <mingo@kernel.org>
Thu, 23 Mar 2017 07:25:08 +0000 (08:25 +0100)
Xen imposes special requirements on the GDT.  Rather than using a
global variable for the pgprot, just use an explicit special case
for Xen -- this makes it clearer what's going on.  It also debloats
64-bit kernels very slightly.

Signed-off-by: Andy Lutomirski <luto@kernel.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: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/e9ea96abbfd6a8c87753849171bb5987ecfeb523.1490218061.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/include/asm/desc.h
arch/x86/kernel/cpu/common.c
arch/x86/xen/enlighten.c

index 17cb46e8a18450068684a95dcc81155948248ebe..d0a21b12dd585c5e73c1930f4afa37aee5a483c6 100644 (file)
@@ -39,7 +39,6 @@ extern struct desc_ptr idt_descr;
 extern gate_desc idt_table[];
 extern const struct desc_ptr debug_idt_descr;
 extern gate_desc debug_idt_table[];
-extern pgprot_t pg_fixmap_gdt_flags;
 
 struct gdt_page {
        struct desc_struct gdt[GDT_ENTRIES];
index f6e20e2dbfa57772539e99cb09628631235fc301..8ee32119144d7b475a0e4ab3c93cae1a55131d59 100644 (file)
@@ -448,21 +448,27 @@ void load_percpu_segment(int cpu)
        load_stack_canary_segment();
 }
 
-/*
- * On 64-bit the GDT remapping is read-only.
- * A global is used for Xen to change the default when required.
- */
+/* Setup the fixmap mapping only once per-processor */
+static inline void setup_fixmap_gdt(int cpu)
+{
 #ifdef CONFIG_X86_64
-pgprot_t pg_fixmap_gdt_flags = PAGE_KERNEL_RO;
+       /* On 64-bit systems, we use a read-only fixmap GDT. */
+       pgprot_t prot = PAGE_KERNEL_RO;
 #else
-pgprot_t pg_fixmap_gdt_flags = PAGE_KERNEL;
+       /*
+        * On native 32-bit systems, the GDT cannot be read-only because
+        * our double fault handler uses a task gate, and entering through
+        * a task gate needs to change an available TSS to busy.  If the GDT
+        * is read-only, that will triple fault.
+        *
+        * On Xen PV, the GDT must be read-only because the hypervisor requires
+        * it.
+        */
+       pgprot_t prot = boot_cpu_has(X86_FEATURE_XENPV) ?
+               PAGE_KERNEL_RO : PAGE_KERNEL;
 #endif
 
-/* Setup the fixmap mapping only once per-processor */
-static inline void setup_fixmap_gdt(int cpu)
-{
-       __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu),
-                    pg_fixmap_gdt_flags);
+       __set_fixmap(get_cpu_gdt_ro_index(cpu), get_cpu_gdt_paddr(cpu), prot);
 }
 
 /* Load the original GDT from the per-cpu structure */
index 08faa61de5f7709637236ca9418800e5ce087eb5..4951fcf95143cf5c3fee1c4f27e3b46b37bd50a3 100644 (file)
@@ -1545,9 +1545,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
         */
        xen_initial_gdt = &per_cpu(gdt_page, 0);
 
-       /* GDT can only be remapped RO */
-       pg_fixmap_gdt_flags = PAGE_KERNEL_RO;
-
        xen_smp_init();
 
 #ifdef CONFIG_ACPI_NUMA