Linux Kernel Architecture

(Jacob Rumans) #1
Mauerer runapp01.tex V1 - 09/04/2008 6:08pm Page 1123

Appendix A: Architecture Specifics


Newer versions of the architecture use a much larger register set, which the kernel saves only as needed.
Consequently, the corresponding elements are held in thethread_structstructure, as shown here:


include/asm-x86/processor_32.h
struct thread_struct {
/* cached TLS descriptors. */
struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
unsigned long esp0;
unsigned long sysenter_cs;
unsigned long eip;
unsigned long esp;
unsigned long fs;
unsigned long gs;
/* Hardware debugging registers */
unsigned long debugreg[8]; /* %%db0-7 debug registers */
/* fault info */
unsigned long cr2, trap_no, error_code;
/* floating point info */
union i387_union i387;
/* virtual 86 mode info */
struct vm86_struct __user * vm86_info;
unsigned long screen_bitmap;
unsigned long v86flags, v86mask, saved_esp0;
unsigned int saved_fs, saved_gs;
/* IO permissions */
unsigned long *io_bitmap_ptr;
unsigned long iopl;
/* max allowed port in the bitmap, in bytes: */
unsigned long io_bitmap_max;
};

Depending on the processor version, the coprocessor provides various register sets as specified in
i387_union:^1


include/asm-x86/processor_32.h
union i387_union {
struct i387_fsave_struct fsave;
struct i387_fxsave_struct fxsave;
struct i387_soft_struct soft;
};

Old 80386 and 80486SX processors that do not have a hardware-based coprocessor employ kernel-
side software emulation whose state is held ini387_soft_struct. Machines whose coprocessors sup-
port only the classic registers (that is, eight 10-byte-wide floating-point registers) store their data in
i387_fsave_struct. Because most registers are never used alone but are always read or written to
block-by-block, the kernel puts them in a contiguous memory area provided in the structure by an array
of suitable size:


include/asm-x86/processor_32.h
struct i387_fsave_struct {
long cwd;
long swd;

(^1) Coincidentally, the definition ofi387_unionfor kernel 2.6.17 is located in line 387.

Free download pdf