diff options
author | Tejun Heo <tj@kernel.org> | 2009-02-09 08:17:39 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-09 18:39:14 -0500 |
commit | d315760ffa261c15ff92699ac6f514112543d7ca (patch) | |
tree | 3f7d185cf97a06e6686521a23a1c78d1809a51c4 /arch/x86/math-emu/get_address.c | |
parent | ae6af41f5a4841f06eb92bc86ad020ad44ae2a30 (diff) |
x86: fix math_emu register frame access
do_device_not_available() is the handler for #NM and it declares that
it takes a unsigned long and calls math_emu(), which takes a long
argument and surprisingly expects the stack frame starting at the zero
argument would match struct math_emu_info, which isn't true regardless
of configuration in the current code.
This patch makes do_device_not_available() take struct pt_regs like
other exception handlers and initialize struct math_emu_info with
pointer to it and pass pointer to the math_emu_info to math_emulate()
like normal C functions do. This way, unless gcc makes a copy of
struct pt_regs in do_device_not_available(), the register frame is
correctly accessed regardless of kernel configuration or compiler
used.
This doesn't fix all math_emu problems but it at least gets it
somewhat working.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/math-emu/get_address.c')
-rw-r--r-- | arch/x86/math-emu/get_address.c | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/arch/x86/math-emu/get_address.c b/arch/x86/math-emu/get_address.c index 62daa7fcc44c..420b3b6e3915 100644 --- a/arch/x86/math-emu/get_address.c +++ b/arch/x86/math-emu/get_address.c | |||
@@ -29,43 +29,43 @@ | |||
29 | #define FPU_WRITE_BIT 0x10 | 29 | #define FPU_WRITE_BIT 0x10 |
30 | 30 | ||
31 | static int reg_offset[] = { | 31 | static int reg_offset[] = { |
32 | offsetof(struct math_emu_info, regs.ax), | 32 | offsetof(struct pt_regs, ax), |
33 | offsetof(struct math_emu_info, regs.cx), | 33 | offsetof(struct pt_regs, cx), |
34 | offsetof(struct math_emu_info, regs.dx), | 34 | offsetof(struct pt_regs, dx), |
35 | offsetof(struct math_emu_info, regs.bx), | 35 | offsetof(struct pt_regs, bx), |
36 | offsetof(struct math_emu_info, regs.sp), | 36 | offsetof(struct pt_regs, sp), |
37 | offsetof(struct math_emu_info, regs.bp), | 37 | offsetof(struct pt_regs, bp), |
38 | offsetof(struct math_emu_info, regs.si), | 38 | offsetof(struct pt_regs, si), |
39 | offsetof(struct math_emu_info, regs.di) | 39 | offsetof(struct pt_regs, di) |
40 | }; | 40 | }; |
41 | 41 | ||
42 | #define REG_(x) (*(long *)(reg_offset[(x)]+(u_char *) FPU_info)) | 42 | #define REG_(x) (*(long *)(reg_offset[(x)] + (u_char *)FPU_info->regs)) |
43 | 43 | ||
44 | static int reg_offset_vm86[] = { | 44 | static int reg_offset_vm86[] = { |
45 | offsetof(struct math_emu_info, regs.cs), | 45 | offsetof(struct pt_regs, cs), |
46 | offsetof(struct math_emu_info, vm86.ds), | 46 | offsetof(struct kernel_vm86_regs, ds), |
47 | offsetof(struct math_emu_info, vm86.es), | 47 | offsetof(struct kernel_vm86_regs, es), |
48 | offsetof(struct math_emu_info, vm86.fs), | 48 | offsetof(struct kernel_vm86_regs, fs), |
49 | offsetof(struct math_emu_info, vm86.gs), | 49 | offsetof(struct kernel_vm86_regs, gs), |
50 | offsetof(struct math_emu_info, regs.ss), | 50 | offsetof(struct pt_regs, ss), |
51 | offsetof(struct math_emu_info, vm86.ds) | 51 | offsetof(struct kernel_vm86_regs, ds) |
52 | }; | 52 | }; |
53 | 53 | ||
54 | #define VM86_REG_(x) (*(unsigned short *) \ | 54 | #define VM86_REG_(x) (*(unsigned short *) \ |
55 | (reg_offset_vm86[((unsigned)x)]+(u_char *) FPU_info)) | 55 | (reg_offset_vm86[((unsigned)x)] + (u_char *)FPU_info->regs)) |
56 | 56 | ||
57 | static int reg_offset_pm[] = { | 57 | static int reg_offset_pm[] = { |
58 | offsetof(struct math_emu_info, regs.cs), | 58 | offsetof(struct pt_regs, cs), |
59 | offsetof(struct math_emu_info, regs.ds), | 59 | offsetof(struct pt_regs, ds), |
60 | offsetof(struct math_emu_info, regs.es), | 60 | offsetof(struct pt_regs, es), |
61 | offsetof(struct math_emu_info, regs.fs), | 61 | offsetof(struct pt_regs, fs), |
62 | offsetof(struct math_emu_info, regs.ds), /* dummy, not saved on stack */ | 62 | offsetof(struct pt_regs, ds), /* dummy, not saved on stack */ |
63 | offsetof(struct math_emu_info, regs.ss), | 63 | offsetof(struct pt_regs, ss), |
64 | offsetof(struct math_emu_info, regs.ds) | 64 | offsetof(struct pt_regs, ds) |
65 | }; | 65 | }; |
66 | 66 | ||
67 | #define PM_REG_(x) (*(unsigned short *) \ | 67 | #define PM_REG_(x) (*(unsigned short *) \ |
68 | (reg_offset_pm[((unsigned)x)]+(u_char *) FPU_info)) | 68 | (reg_offset_pm[((unsigned)x)] + (u_char *)FPU_info->regs)) |
69 | 69 | ||
70 | /* Decode the SIB byte. This function assumes mod != 0 */ | 70 | /* Decode the SIB byte. This function assumes mod != 0 */ |
71 | static int sib(int mod, unsigned long *fpu_eip) | 71 | static int sib(int mod, unsigned long *fpu_eip) |
@@ -346,34 +346,34 @@ void __user *FPU_get_address_16(u_char FPU_modrm, unsigned long *fpu_eip, | |||
346 | } | 346 | } |
347 | switch (rm) { | 347 | switch (rm) { |
348 | case 0: | 348 | case 0: |
349 | address += FPU_info->regs.bx + FPU_info->regs.si; | 349 | address += FPU_info->regs->bx + FPU_info->regs->si; |
350 | break; | 350 | break; |
351 | case 1: | 351 | case 1: |
352 | address += FPU_info->regs.bx + FPU_info->regs.di; | 352 | address += FPU_info->regs->bx + FPU_info->regs->di; |
353 | break; | 353 | break; |
354 | case 2: | 354 | case 2: |
355 | address += FPU_info->regs.bp + FPU_info->regs.si; | 355 | address += FPU_info->regs->bp + FPU_info->regs->si; |
356 | if (addr_modes.override.segment == PREFIX_DEFAULT) | 356 | if (addr_modes.override.segment == PREFIX_DEFAULT) |
357 | addr_modes.override.segment = PREFIX_SS_; | 357 | addr_modes.override.segment = PREFIX_SS_; |
358 | break; | 358 | break; |
359 | case 3: | 359 | case 3: |
360 | address += FPU_info->regs.bp + FPU_info->regs.di; | 360 | address += FPU_info->regs->bp + FPU_info->regs->di; |
361 | if (addr_modes.override.segment == PREFIX_DEFAULT) | 361 | if (addr_modes.override.segment == PREFIX_DEFAULT) |
362 | addr_modes.override.segment = PREFIX_SS_; | 362 | addr_modes.override.segment = PREFIX_SS_; |
363 | break; | 363 | break; |
364 | case 4: | 364 | case 4: |
365 | address += FPU_info->regs.si; | 365 | address += FPU_info->regs->si; |
366 | break; | 366 | break; |
367 | case 5: | 367 | case 5: |
368 | address += FPU_info->regs.di; | 368 | address += FPU_info->regs->di; |
369 | break; | 369 | break; |
370 | case 6: | 370 | case 6: |
371 | address += FPU_info->regs.bp; | 371 | address += FPU_info->regs->bp; |
372 | if (addr_modes.override.segment == PREFIX_DEFAULT) | 372 | if (addr_modes.override.segment == PREFIX_DEFAULT) |
373 | addr_modes.override.segment = PREFIX_SS_; | 373 | addr_modes.override.segment = PREFIX_SS_; |
374 | break; | 374 | break; |
375 | case 7: | 375 | case 7: |
376 | address += FPU_info->regs.bx; | 376 | address += FPU_info->regs->bx; |
377 | break; | 377 | break; |
378 | } | 378 | } |
379 | 379 | ||