public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i386-unbusy-tss
@ 2004-08-17 22:36 Zachary Amsden
  0 siblings, 0 replies; only message in thread
From: Zachary Amsden @ 2004-08-17 22:36 UTC (permalink / raw)
  To: davej, hpa, Riley, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 565 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.   Basically, the code 
was trying to unbusy the TSS descriptor (which the set_tss_desc and 
__set_tss_desc functions already do by setting the descriptor type).  
This change saves only 20 bytes of space and makes the code more 
readable and maintainable.

Version: patched against 2.6.8.1-mm1
Testing: compile and boot a Linux 2.6 kernel with my patch.

Cheers,

Zachary Amsden

[-- Attachment #2: i386-unbusy-tss.patch --]
[-- Type: text/plain, Size: 652 bytes --]

--- linux-2.6.8.1-mm1.orig/arch/i386/kernel/cpu/common.c	2004-08-17 15:09:03.000000000 -0700
+++ linux-2.6.8.1-mm1/arch/i386/kernel/cpu/common.c	2004-08-17 15:10:51.000000000 -0700
@@ -559,13 +559,11 @@
 
 	load_esp0(t, thread);
 	set_tss_desc(cpu,t);
-	per_cpu(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);
-	per_cpu(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");

[-- Attachment #3: README.i386-unbusy-tss --]
[-- Type: text/plain, Size: 2123 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:
c01e0556:       ba 80 66 1f c0          mov    $0xc01f6680,%edx
c01e055b:       b8 e0 8f 1b c0          mov    $0xc01b8fe0,%eax
c01e0560:       66 c7 42 00 6b 20       movw   $0x206b,0x0(%edx)
c01e0566:       66 89 42 02             mov    %ax,0x2(%edx)
c01e056a:       c1 c8 10                ror    $0x10,%eax
c01e056d:       88 42 04                mov    %al,0x4(%edx)
c01e0570:       c6 42 05 89             movb   $0x89,0x5(%edx)
                                                  ^^ not busy TSS
c01e0574:       c6 42 06 00             movb   $0x0,0x6(%edx)
c01e0578:       88 62 07                mov    %ah,0x7(%edx)
c01e057b:       c1 c8 10                ror    $0x10,%eax
c01e057e:       81 25 84 66 1f c0 ff    andl   $0xfffffdff,0xc01f6684
c01e0585:       fd ff ff
                                                      ^^ clear busy
c01e0588:       b8 80 00 00 00          mov    $0x80,%eax
c01e058d:       0f 00 d8                ltr    %ax


after:

c01e0556:       ba 80 66 1f c0          mov    $0xc01f6680,%edx
c01e055b:       b8 e0 8f 1b c0          mov    $0xc01b8fe0,%eax
c01e0560:       66 c7 42 00 6b 20       movw   $0x206b,0x0(%edx)
c01e0566:       66 89 42 02             mov    %ax,0x2(%edx)
c01e056a:       c1 c8 10                ror    $0x10,%eax
c01e056d:       88 42 04                mov    %al,0x4(%edx)
c01e0570:       c6 42 05 89             movb   $0x89,0x5(%edx)
c01e0574:       c6 42 06 00             movb   $0x0,0x6(%edx)
c01e0578:       88 62 07                mov    %ah,0x7(%edx)
c01e057b:       c1 c8 10                ror    $0x10,%eax
c01e057e:       b8 80 00 00 00          mov    $0x80,%eax
c01e0583:       0f 00 d8                ltr    %ax


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

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

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-17 22:36 [PATCH] i386-unbusy-tss Zachary Amsden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox