Commit ae6af41f authored by Tejun Heo's avatar Tejun Heo Committed by Ingo Molnar

x86: math_emu info cleanup

Impact: cleanup

* Come on, struct info?  s/struct info/struct math_emu_info/

* Use struct pt_regs and kernel_vm86_regs instead of defining its own
  register frame structure.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 914c3d63
#ifndef _ASM_X86_MATH_EMU_H #ifndef _ASM_X86_MATH_EMU_H
#define _ASM_X86_MATH_EMU_H #define _ASM_X86_MATH_EMU_H
#include <asm/ptrace.h>
#include <asm/vm86.h>
/* This structure matches the layout of the data saved to the stack /* This structure matches the layout of the data saved to the stack
following a device-not-present interrupt, part of it saved following a device-not-present interrupt, part of it saved
automatically by the 80386/80486. automatically by the 80386/80486.
*/ */
struct info { struct math_emu_info {
long ___orig_eip; long ___orig_eip;
long ___ebx; union {
long ___ecx; struct pt_regs regs;
long ___edx; struct kernel_vm86_regs vm86;
long ___esi; };
long ___edi;
long ___ebp;
long ___eax;
long ___ds;
long ___es;
long ___fs;
long ___orig_eax;
long ___eip;
long ___cs;
long ___eflags;
long ___esp;
long ___ss;
long ___vm86_es; /* This and the following only in vm86 mode */
long ___vm86_ds;
long ___vm86_fs;
long ___vm86_gs;
}; };
#endif /* _ASM_X86_MATH_EMU_H */ #endif /* _ASM_X86_MATH_EMU_H */
...@@ -353,7 +353,7 @@ struct i387_soft_struct { ...@@ -353,7 +353,7 @@ struct i387_soft_struct {
u8 no_update; u8 no_update;
u8 rm; u8 rm;
u8 alimit; u8 alimit;
struct info *info; struct math_emu_info *info;
u32 entry_eip; u32 entry_eip;
}; };
......
...@@ -659,7 +659,7 @@ static int valid_prefix(u_char *Byte, u_char __user **fpu_eip, ...@@ -659,7 +659,7 @@ static int valid_prefix(u_char *Byte, u_char __user **fpu_eip,
} }
} }
void math_abort(struct info *info, unsigned int signal) void math_abort(struct math_emu_info *info, unsigned int signal)
{ {
FPU_EIP = FPU_ORIG_EIP; FPU_EIP = FPU_ORIG_EIP;
current->thread.trap_no = 16; current->thread.trap_no = 16;
......
...@@ -52,7 +52,7 @@ extern void fst_i_(void); ...@@ -52,7 +52,7 @@ extern void fst_i_(void);
extern void fstp_i(void); extern void fstp_i(void);
/* fpu_entry.c */ /* fpu_entry.c */
asmlinkage extern void math_emulate(long arg); asmlinkage extern void math_emulate(long arg);
extern void math_abort(struct info *info, unsigned int signal); extern void math_abort(struct math_emu_info *info, unsigned int signal);
/* fpu_etc.c */ /* fpu_etc.c */
extern void FPU_etc(void); extern void FPU_etc(void);
/* fpu_tags.c */ /* fpu_tags.c */
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
/* This sets the pointer FPU_info to point to the argument part /* This sets the pointer FPU_info to point to the argument part
of the stack frame of math_emulate() */ of the stack frame of math_emulate() */
#define SETUP_DATA_AREA(arg) FPU_info = (struct info *) &arg #define SETUP_DATA_AREA(arg) FPU_info = (struct math_emu_info *) &arg
/* s is always from a cpu register, and the cpu does bounds checking /* s is always from a cpu register, and the cpu does bounds checking
* during register load --> no further bounds checks needed */ * during register load --> no further bounds checks needed */
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
#define I387 (current->thread.xstate) #define I387 (current->thread.xstate)
#define FPU_info (I387->soft.info) #define FPU_info (I387->soft.info)
#define FPU_CS (*(unsigned short *) &(FPU_info->___cs)) #define FPU_CS (*(unsigned short *) &(FPU_info->regs.cs))
#define FPU_SS (*(unsigned short *) &(FPU_info->___ss)) #define FPU_SS (*(unsigned short *) &(FPU_info->regs.ss))
#define FPU_DS (*(unsigned short *) &(FPU_info->___ds)) #define FPU_DS (*(unsigned short *) &(FPU_info->regs.ds))
#define FPU_EAX (FPU_info->___eax) #define FPU_EAX (FPU_info->regs.ax)
#define FPU_EFLAGS (FPU_info->___eflags) #define FPU_EFLAGS (FPU_info->regs.flags)
#define FPU_EIP (FPU_info->___eip) #define FPU_EIP (FPU_info->regs.ip)
#define FPU_ORIG_EIP (FPU_info->___orig_eip) #define FPU_ORIG_EIP (FPU_info->___orig_eip)
#define FPU_lookahead (I387->soft.lookahead) #define FPU_lookahead (I387->soft.lookahead)
......
...@@ -29,42 +29,39 @@ ...@@ -29,42 +29,39 @@
#define FPU_WRITE_BIT 0x10 #define FPU_WRITE_BIT 0x10
static int reg_offset[] = { static int reg_offset[] = {
offsetof(struct info, ___eax), offsetof(struct math_emu_info, regs.ax),
offsetof(struct info, ___ecx), offsetof(struct math_emu_info, regs.cx),
offsetof(struct info, ___edx), offsetof(struct math_emu_info, regs.dx),
offsetof(struct info, ___ebx), offsetof(struct math_emu_info, regs.bx),
offsetof(struct info, ___esp), offsetof(struct math_emu_info, regs.sp),
offsetof(struct info, ___ebp), offsetof(struct math_emu_info, regs.bp),
offsetof(struct info, ___esi), offsetof(struct math_emu_info, regs.si),
offsetof(struct info, ___edi) offsetof(struct math_emu_info, regs.di)
}; };
#define REG_(x) (*(long *)(reg_offset[(x)]+(u_char *) FPU_info)) #define REG_(x) (*(long *)(reg_offset[(x)]+(u_char *) FPU_info))
static int reg_offset_vm86[] = { static int reg_offset_vm86[] = {
offsetof(struct info, ___cs), offsetof(struct math_emu_info, regs.cs),
offsetof(struct info, ___vm86_ds), offsetof(struct math_emu_info, vm86.ds),
offsetof(struct info, ___vm86_es), offsetof(struct math_emu_info, vm86.es),
offsetof(struct info, ___vm86_fs), offsetof(struct math_emu_info, vm86.fs),
offsetof(struct info, ___vm86_gs), offsetof(struct math_emu_info, vm86.gs),
offsetof(struct info, ___ss), offsetof(struct math_emu_info, regs.ss),
offsetof(struct info, ___vm86_ds) offsetof(struct math_emu_info, vm86.ds)
}; };
#define VM86_REG_(x) (*(unsigned short *) \ #define VM86_REG_(x) (*(unsigned short *) \
(reg_offset_vm86[((unsigned)x)]+(u_char *) FPU_info)) (reg_offset_vm86[((unsigned)x)]+(u_char *) FPU_info))
/* This dummy, gs is not saved on the stack. */
#define ___GS ___ds
static int reg_offset_pm[] = { static int reg_offset_pm[] = {
offsetof(struct info, ___cs), offsetof(struct math_emu_info, regs.cs),
offsetof(struct info, ___ds), offsetof(struct math_emu_info, regs.ds),
offsetof(struct info, ___es), offsetof(struct math_emu_info, regs.es),
offsetof(struct info, ___fs), offsetof(struct math_emu_info, regs.fs),
offsetof(struct info, ___GS), offsetof(struct math_emu_info, regs.ds), /* dummy, not saved on stack */
offsetof(struct info, ___ss), offsetof(struct math_emu_info, regs.ss),
offsetof(struct info, ___ds) offsetof(struct math_emu_info, regs.ds)
}; };
#define PM_REG_(x) (*(unsigned short *) \ #define PM_REG_(x) (*(unsigned short *) \
...@@ -349,34 +346,34 @@ void __user *FPU_get_address_16(u_char FPU_modrm, unsigned long *fpu_eip, ...@@ -349,34 +346,34 @@ void __user *FPU_get_address_16(u_char FPU_modrm, unsigned long *fpu_eip,
} }
switch (rm) { switch (rm) {
case 0: case 0:
address += FPU_info->___ebx + FPU_info->___esi; address += FPU_info->regs.bx + FPU_info->regs.si;
break; break;
case 1: case 1:
address += FPU_info->___ebx + FPU_info->___edi; address += FPU_info->regs.bx + FPU_info->regs.di;
break; break;
case 2: case 2:
address += FPU_info->___ebp + FPU_info->___esi; address += FPU_info->regs.bp + FPU_info->regs.si;
if (addr_modes.override.segment == PREFIX_DEFAULT) if (addr_modes.override.segment == PREFIX_DEFAULT)
addr_modes.override.segment = PREFIX_SS_; addr_modes.override.segment = PREFIX_SS_;
break; break;
case 3: case 3:
address += FPU_info->___ebp + FPU_info->___edi; address += FPU_info->regs.bp + FPU_info->regs.di;
if (addr_modes.override.segment == PREFIX_DEFAULT) if (addr_modes.override.segment == PREFIX_DEFAULT)
addr_modes.override.segment = PREFIX_SS_; addr_modes.override.segment = PREFIX_SS_;
break; break;
case 4: case 4:
address += FPU_info->___esi; address += FPU_info->regs.si;
break; break;
case 5: case 5:
address += FPU_info->___edi; address += FPU_info->regs.di;
break; break;
case 6: case 6:
address += FPU_info->___ebp; address += FPU_info->regs.bp;
if (addr_modes.override.segment == PREFIX_DEFAULT) if (addr_modes.override.segment == PREFIX_DEFAULT)
addr_modes.override.segment = PREFIX_SS_; addr_modes.override.segment = PREFIX_SS_;
break; break;
case 7: case 7:
address += FPU_info->___ebx; address += FPU_info->regs.bx;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment