mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] struct thread_struct, asm-i386/processor.h: wrong datatype?
@ 2005-06-04 15:43 Herbert Rosmanith
  2005-06-04 16:01 ` Herbert Rosmanith
  0 siblings, 1 reply; 4+ messages in thread
From: Herbert Rosmanith @ 2005-06-04 15:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: torvalds, Herbert Rosmanith


good day,

concerning this file:

/usr/src/linux/include/asm-i386/processor.h

we find a "struct thread_struct":

struct thread_struct {
        unsigned long   esp0;
        unsigned long   eip;
        unsigned long   esp;
        unsigned long   fs;
        ^^^^^^^^^^^^^^^^^^^
        unsigned long   gs;
        ^^^^^^^^^^^^^^^^^^^

as segment-registers, aren't fs and gs only 16 bit? why are they not
unsigned short (or possibly u_int16_t)?

kind regards,
herbert rosmanith

# diff -uN processor.h.orig processor.h
--- processor.h.orig    Wed Feb 18 14:36:32 2004
+++ processor.h Sat Jun  4 17:41:58 2005
@@ -2,6 +2,9 @@
  * include/asm-i386/processor.h
  *
  * Copyright (C) 1994 Linus Torvalds
+ *
+ * Sat Jun  4 17:41:23 MET DST 2005 herp - Herbert Rosmanith
+ *  fix wrong datatypes in struct thread_struct
  */

 #ifndef __ASM_I386_PROCESSOR_H
@@ -361,8 +364,8 @@
        unsigned long   esp0;
        unsigned long   eip;
        unsigned long   esp;
-       unsigned long   fs;
-       unsigned long   gs;
+       unsigned short  fs;
+       unsigned short  gs;
 /* Hardware debugging registers */
        unsigned long   debugreg[8];  /* %%db0-7 debug registers */
 /* fault info */


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] struct thread_struct, asm-i386/processor.h: wrong datatype?
  2005-06-04 15:43 [PATCH] struct thread_struct, asm-i386/processor.h: wrong datatype? Herbert Rosmanith
@ 2005-06-04 16:01 ` Herbert Rosmanith
  2005-06-06  8:16   ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Herbert Rosmanith @ 2005-06-04 16:01 UTC (permalink / raw)
  To: Herbert Rosmanith; +Cc: linux-kernel, torvalds


or better: 

> -       unsigned long   fs;
> -       unsigned long   gs;
> +       unsigned short  fs;
> +       unsigned short  gs;
>  /* Hardware debugging registers */
>         unsigned long   debugreg[8];  /* %%db0-7 debug registers */
>  /* fault info */

+ unsigned short fs, __fsh; 
+ unsigned short gs, __gsh; 

which is also done this way the structure above, the TSS. I don't know
why it's done this way, but I guess it's probably better pad with 16 bits
to avoid potential problems with 32bit movl which might overwrite portions
of the next field.

kind regards,
herbert rosmanith


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] struct thread_struct, asm-i386/processor.h: wrong datatype?
  2005-06-04 16:01 ` Herbert Rosmanith
@ 2005-06-06  8:16   ` Ingo Molnar
  2005-06-08 21:08     ` Herbert Rosmanith
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2005-06-06  8:16 UTC (permalink / raw)
  To: Herbert Rosmanith; +Cc: linux-kernel, torvalds


* Herbert Rosmanith <kernel@wildsau.enemy.org> wrote:

> 
> or better: 
> 
> > -       unsigned long   fs;
> > -       unsigned long   gs;
> > +       unsigned short  fs;
> > +       unsigned short  gs;
> >  /* Hardware debugging registers */
> >         unsigned long   debugreg[8];  /* %%db0-7 debug registers */
> >  /* fault info */
> 
> + unsigned short fs, __fsh; 
> + unsigned short gs, __gsh; 
> 
> which is also done this way the structure above, the TSS. I don't know 
> why it's done this way, but I guess it's probably better pad with 16 
> bits to avoid potential problems with 32bit movl which might overwrite 
> portions of the next field.

no. 'struct thread_struct' is the 'soft' thread-state structure. We 
store data in the most convenient (and best performing) format - word 
size in this case. The 'hard' data structure is 'struct tss_struct' - 
where we of course define things in the way the CPU expects it.

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] struct thread_struct, asm-i386/processor.h: wrong datatype?
  2005-06-06  8:16   ` Ingo Molnar
@ 2005-06-08 21:08     ` Herbert Rosmanith
  0 siblings, 0 replies; 4+ messages in thread
From: Herbert Rosmanith @ 2005-06-08 21:08 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, torvalds

> no. 'struct thread_struct' is the 'soft' thread-state structure. We 
> store data in the most convenient (and best performing) format - word 
> size in this case. The 'hard' data structure is 'struct tss_struct' - 
> where we of course define things in the way the CPU expects it.

I see. thanks for the answer.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-06-08 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-04 15:43 [PATCH] struct thread_struct, asm-i386/processor.h: wrong datatype? Herbert Rosmanith
2005-06-04 16:01 ` Herbert Rosmanith
2005-06-06  8:16   ` Ingo Molnar
2005-06-08 21:08     ` Herbert Rosmanith

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

all inboxes | Powered by JetHome®