Skip to content

Commit 4f53ab1

Browse files
amlutobonzini
authored andcommitted
x86/asm: Define the kernel TSS limit in a macro
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>
1 parent 06ce521 commit 4f53ab1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

arch/x86/include/asm/desc.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,8 @@ static inline void __set_tss_desc(unsigned cpu, unsigned int entry, void *addr)
177177
struct desc_struct *d = get_cpu_gdt_table(cpu);
178178
tss_desc tss;
179179

180-
/*
181-
* sizeof(unsigned long) coming from an extra "long" at the end
182-
* of the iobitmap. See tss_struct definition in processor.h
183-
*
184-
* -1? seg base+limit should be pointing to the address of the
185-
* last valid byte
186-
*/
187180
set_tssldt_descriptor(&tss, (unsigned long)addr, DESC_TSS,
188-
IO_BITMAP_OFFSET + IO_BITMAP_BYTES +
189-
sizeof(unsigned long) - 1);
181+
__KERNEL_TSS_LIMIT);
190182
write_gdt_entry(d, entry, &tss, DESC_TSS);
191183
}
192184

arch/x86/include/asm/processor.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,16 @@ struct tss_struct {
341341

342342
DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss);
343343

344+
/*
345+
* sizeof(unsigned long) coming from an extra "long" at the end
346+
* of the iobitmap.
347+
*
348+
* -1? seg base+limit should be pointing to the address of the
349+
* last valid byte
350+
*/
351+
#define __KERNEL_TSS_LIMIT \
352+
(IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1)
353+
344354
#ifdef CONFIG_X86_32
345355
DECLARE_PER_CPU(unsigned long, cpu_current_top_of_stack);
346356
#endif

0 commit comments

Comments
 (0)