Skip to contentSkip to conversation

i386 linux: eliminate init_tss

PATCH New Jan Beulich 1 participant 1 message Feb 14, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386 linux: eliminate init_tss

init_tss is meaningless in a paravirtualized kernel, and consumes 25% of the per-cpu area. Jan

From: [email protected]
Subject: eliminate init_tss

$subject says it all.

arch/i386/kernel/asm-offsets.c +2 -0
Index: head-2006-02-13/arch/i386/kernel/asm-offsets.c
===================================================================
@@ -63,9 +63,11 @@ void foo(void)
 	OFFSET(pbe_orig_address, pbe, orig_address);
 	OFFSET(pbe_next, pbe, next);
 
+#ifndef CONFIG_XEN
 	/* Offset from the sysenter stack to tss.esp0 */
 	DEFINE(TSS_sysenter_esp0, offsetof(struct tss_struct, esp0) -
 		 sizeof(struct tss_struct));
+#endif
 
 	DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
 	DEFINE(VSYSCALL_BASE, __fix_to_virt(FIX_VSYSCALL));
arch/i386/kernel/sysenter.c +2 -0
Index: head-2006-02-13/arch/i386/kernel/sysenter.c
===================================================================
@@ -23,6 +23,7 @@ extern asmlinkage void sysenter_entry(vo
 
 void enable_sep_cpu(void)
 {
+#ifndef CONFIG_XEN
 	int cpu = get_cpu();
 	struct tss_struct *tss = &per_cpu(init_tss, cpu);
 
@@ -37,6 +38,7 @@ void enable_sep_cpu(void)
 	wrmsr(MSR_IA32_SYSENTER_ESP, tss->esp1, 0);
 	wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long) sysenter_entry, 0);
 	put_cpu();	
+#endif
 }
 
 /*
arch/i386/kernel/vm86.c +9 -0
Index: head-2006-02-13/arch/i386/kernel/vm86.c
===================================================================
@@ -97,7 +97,9 @@
 struct pt_regs * FASTCALL(save_v86_state(struct kernel_vm86_regs * regs));
 struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs)
 {
+#ifndef CONFIG_XEN
 	struct tss_struct *tss;
+#endif
 	struct pt_regs *ret;
 	unsigned long tmp;
 
@@ -122,7 +124,9 @@ struct pt_regs * fastcall save_v86_state
 		do_exit(SIGSEGV);
 	}
 
+#ifndef CONFIG_XEN
 	tss = &per_cpu(init_tss, get_cpu());
+#endif
 	current->thread.esp0 = current->thread.saved_esp0;
 	current->thread.sysenter_cs = __KERNEL_CS;
 	load_esp0(tss, &current->thread);
@@ -251,7 +255,10 @@ out:
 
 static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk)
 {
+#ifndef CONFIG_XEN
 	struct tss_struct *tss;
+#endif
+
 /*
  * make sure the vm86() system call doesn't try to do anything silly
  */
@@ -295,7 +302,9 @@ static void do_sys_vm86(struct kernel_vm
 	savesegment(fs, tsk->thread.saved_fs);
 	savesegment(gs, tsk->thread.saved_gs);
 
+#ifndef CONFIG_XEN
 	tss = &per_cpu(init_tss, get_cpu());
+#endif
 	tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0;
 	if (cpu_has_sep)
 		tsk->thread.sysenter_cs = 0;
arch/i386/kernel/cpu/common-xen.c +2 -0
Index: head-2006-02-13/arch/i386/kernel/cpu/common-xen.c
===================================================================
@@ -598,7 +598,9 @@ void __cpuinit cpu_gdt_init(struct Xgt_d
 void __cpuinit cpu_init(void)
 {
 	int cpu = smp_processor_id();
+#ifndef CONFIG_XEN
 	struct tss_struct * t = &per_cpu(init_tss, cpu);
+#endif
 	struct thread_struct *thread = &current->thread;
 
 	if (cpu_test_and_set(cpu, cpu_initialized)) {
arch/i386/kernel/entry-xen.S +6 -0
Index: head-2006-02-13/arch/i386/kernel/entry-xen.S
===================================================================
@@ -223,6 +223,7 @@ need_resched:
 	jmp need_resched
 #endif
 
+#if 0 /* XEN */
 /* SYSENTER_RETURN points to after the "sysenter" instruction in
    the vsyscall page.  See vsyscall-sysentry.S, which defines the symbol.  */
 
@@ -270,6 +271,7 @@ sysenter_past_esp:
 	xorl %ebp,%ebp
 	sti
 	sysexit
+#endif /* XEN */
 
 
 	# system call handler stub
@@ -662,6 +664,7 @@ ENTRY(device_not_available)
 	call math_state_restore
 	jmp ret_from_exception
 
+#if 0 /* XEN */
 /*
  * Debug traps and NMI can happen at the one SYSENTER instruction
  * that sets up the real kernel stack. Check here, since we can't
@@ -683,12 +686,15 @@ label:						\
 	pushfl;					\
 	pushl $__KERNEL_CS;			\
 	pushl $sysenter_past_esp
+#endif /* XEN */
 
 KPROBE_ENTRY(debug)
+#if 0 /* XEN */
 	cmpl $sysenter_entry,(%esp)
 	jne debug_stack_correct
 	FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn)
 debug_stack_correct:
+#endif /* XEN */
 	pushl $-1			# mark this as an int
 	SAVE_ALL
 	xorl %edx,%edx			# error code 0
arch/i386/kernel/init_task-xen.c +2 -1
Index: head-2006-02-13/arch/i386/kernel/init_task-xen.c
===================================================================
@@ -41,9 +41,10 @@ struct task_struct init_task = INIT_TASK
 
 EXPORT_SYMBOL(init_task);
 
+#ifndef CONFIG_XEN
 /*
  * per-CPU TSS segments. Threads are completely 'soft' on Linux,
  * no more per-task TSS's.
  */ 
 DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_internodealigned_in_smp = INIT_TSS;
-
+#endif
arch/i386/kernel/process-xen.c +4 -3
Index: head-2006-02-13/arch/i386/kernel/process-xen.c
===================================================================
@@ -518,7 +518,9 @@ struct task_struct fastcall * __switch_t
 	struct thread_struct *prev = &prev_p->thread,
 				 *next = &next_p->thread;
 	int cpu = smp_processor_id();
+#ifndef CONFIG_XEN
 	struct tss_struct *tss = &per_cpu(init_tss, cpu);
+#endif
 	physdev_op_t iopl_op, iobmp_op;
 	multicall_entry_t _mcl[8], *mcl = _mcl;
 
@@ -543,10 +545,9 @@ struct task_struct fastcall * __switch_t
 	 * Reload esp0.
 	 * This is load_esp0(tss, next) with a multicall.
 	 */
-	tss->esp0 = next->esp0;
 	mcl->op      = __HYPERVISOR_stack_switch;
-	mcl->args[0] = tss->ss0;
-	mcl->args[1] = tss->esp0;
+	mcl->args[0] = __KERNEL_DS;
+	mcl->args[1] = next->esp0;
 	mcl++;
 
 	/*
include/asm-i386/mach-xen/asm/desc.h +0 -8
Index: head-2006-02-13/include/asm-i386/mach-xen/asm/desc.h
===================================================================
@@ -61,14 +61,6 @@ __asm__ __volatile__ ("movw %w3,0(%2)\n\
 	"rorl $16,%1" \
 	: "=m"(*(n)) : "q" (addr), "r"(n), "ir"(limit), "i"(type))
 
-static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, void *addr)
-{
-	_set_tssldt_desc(&get_cpu_gdt_table(cpu)[entry], (int)addr,
-		offsetof(struct tss_struct, __cacheline_filler) - 1, 0x89);
-}
-
-#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
-
 static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int size)
 {
 	_set_tssldt_desc(&get_cpu_gdt_table(cpu)[GDT_ENTRY_LDT], (int)addr, ((size << 3)-1), 0x82);
include/asm-i386/mach-xen/asm/processor.h +2 -73

99 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel