linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i386 - remove unnecessary unbusy TSS code
@ 2004-08-13 22:09 Zachary Amsden
  0 siblings, 0 replies; only message in thread
From: Zachary Amsden @ 2004-08-13 22:09 UTC (permalink / raw)
  To: linux-kernel, davej, hpa

[-- Attachment #1: Type: text/plain, Size: 334 bytes --]

I was looking at GDT updates in the Linux kernel and noticed some 
redundant code in initialization of the per-CPU GDT.  This code is no 
longer necessary or commented, so I removed it for simplicity (and it 
saves 20 bytes of code space).

Version: patched against 2.6.7
Testing: compile and boot a Linux 2.6.7 kernel with my patch.

[-- Attachment #2: README.gdt-unbusy --]
[-- Type: text/plain, Size: 2043 bytes --]

The TSS no longer needs to be unbusied before loading the task register,
since the set_tss_desc macros set the system gate type to Available IA-32 TSS.
This obscure, uncommented legacy code can now be removed for better
readability and saves 20 bytes of code space. 

Here is a breakdown of __set_tss_desc + load_TR before and after.  The
doublefault TSS GDT setup has similar savings.

- Zachary Amsden (zach@vmware.com)

before:
c01d4535:       ba 80 20 1b c0          mov    $0xc01b2080,%edx
c01d453a:       b8 00 d8 1c c0          mov    $0xc01cd800,%eax
c01d453f:       66 c7 42 00 eb 00       movw   $0xeb,0x0(%edx)
c01d4545:       66 89 42 02             mov    %ax,0x2(%edx)
c01d4549:       c1 c8 10                ror    $0x10,%eax
c01d454c:       88 42 04                mov    %al,0x4(%edx)
c01d454f:       c6 42 05 89             movb   $0x89,0x5(%edx)
                                                  ^^ non-busy
c01d4553:       c6 42 06 00             movb   $0x0,0x6(%edx)
c01d4557:       88 62 07                mov    %ah,0x7(%edx)
c01d455a:       c1 c8 10                ror    $0x10,%eax
c01d455d:       81 25 84 20 1b c0 ff    andl   $0xfffffdff,0xc01b2084
c01d4564:       fd ff ff
c01d4567:       b8 80 00 00 00          mov    $0x80,%eax
c01d456c:       0f 00 d8                ltr    %ax

now:
c01d4535:       ba 80 20 1b c0          mov    $0xc01b2080,%edx
c01d453a:       b8 00 d8 1c c0          mov    $0xc01cd800,%eax
c01d453f:       66 c7 42 00 eb 00       movw   $0xeb,0x0(%edx)
c01d4545:       66 89 42 02             mov    %ax,0x2(%edx)
c01d4549:       c1 c8 10                ror    $0x10,%eax
c01d454c:       88 42 04                mov    %al,0x4(%edx)
c01d454f:       c6 42 05 89             movb   $0x89,0x5(%edx)
c01d4553:       c6 42 06 00             movb   $0x0,0x6(%edx)
c01d4557:       88 62 07                mov    %ah,0x7(%edx)
c01d455a:       c1 c8 10                ror    $0x10,%eax
c01d455d:       b8 80 00 00 00          mov    $0x80,%eax
c01d4562:       0f 00 d8                ltr    %ax


[-- Attachment #3: gdt-unbusy.patch --]
[-- Type: text/plain, Size: 599 bytes --]

--- arch/i386/kernel/cpu/common.c.orig	2004-08-13 14:16:28.000000000 -0700
+++ arch/i386/kernel/cpu/common.c	2004-08-13 14:16:46.000000000 -0700
@@ -552,13 +552,11 @@
 
 	load_esp0(t, thread);
 	set_tss_desc(cpu,t);
-	cpu_gdt_table[cpu][GDT_ENTRY_TSS].b &= 0xfffffdff;
 	load_TR_desc();
 	load_LDT(&init_mm.context);
 
 	/* Set up doublefault TSS pointer in the GDT */
 	__set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss);
-	cpu_gdt_table[cpu][GDT_ENTRY_DOUBLEFAULT_TSS].b &= 0xfffffdff;
 
 	/* Clear %fs and %gs. */
 	asm volatile ("xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs");

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-08-13 22:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-13 22:09 [PATCH] i386 - remove unnecessary unbusy TSS code Zachary Amsden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).