x86/asm: Define the kernel TSS limit in a macro
authorAndy Lutomirski <luto@kernel.org>
Mon, 20 Feb 2017 16:56:09 +0000 (08:56 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 21 Feb 2017 10:48:35 +0000 (11:48 +0100)
Rather than open-coding the kernel TSS limit in set_tss_desc(), make
it a real macro near the TSS layout definition.

This is purely a cleanup.

Cc: Thomas Garnier <thgarnie@google.com>
Cc: Jim Mattson <jmattson@google.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/desc.h
arch/x86/include/asm/processor.h

index 12080d87da3b189f421d421c5d6a3cca5dc83014..2e781bcc5e12d2116af99a10ad02e90edff247f3 100644 (file)
@@ -177,16 +177,8 @@ static inline void __set_tss_desc(unsigned cpu, unsigned int entry, void *addr)
        struct desc_struct *d = get_cpu_gdt_table(cpu);
        tss_desc tss;
 
-       /*
-        * sizeof(unsigned long) coming from an extra "long" at the end
-        * of the iobitmap. See tss_struct definition in processor.h
-        *
-        * -1? seg base+limit should be pointing to the address of the
-        * last valid byte
-        */
        set_tssldt_descriptor(&tss, (unsigned long)addr, DESC_TSS,
-                             IO_BITMAP_OFFSET + IO_BITMAP_BYTES +
-                             sizeof(unsigned long) - 1);
+                             __KERNEL_TSS_LIMIT);
        write_gdt_entry(d, entry, &tss, DESC_TSS);
 }
 
index 1be64da0384ed8d5dea85563633c2740f5587888..f8f1b7537abee0512d733563be17922be5962626 100644 (file)
@@ -341,6 +341,16 @@ struct tss_struct {
 
 DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss);
 
+/*
+ * sizeof(unsigned long) coming from an extra "long" at the end
+ * of the iobitmap.
+ *
+ * -1? seg base+limit should be pointing to the address of the
+ * last valid byte
+ */
+#define __KERNEL_TSS_LIMIT     \
+       (IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1)
+
 #ifdef CONFIG_X86_32
 DECLARE_PER_CPU(unsigned long, cpu_current_top_of_stack);
 #endif