Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /*---------------------------------------------------------------------------+ |
| 2 | | fpu_system.h | |
| 3 | | | |
| 4 | | Copyright (C) 1992,1994,1997 | |
| 5 | | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, | |
| 6 | | Australia. E-mail billm@suburbia.net | |
| 7 | | | |
| 8 | +---------------------------------------------------------------------------*/ |
| 9 | |
| 10 | #ifndef _FPU_SYSTEM_H |
| 11 | #define _FPU_SYSTEM_H |
| 12 | |
| 13 | /* system dependent definitions */ |
| 14 | |
| 15 | #include <linux/sched.h> |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/mm.h> |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | /* s is always from a cpu register, and the cpu does bounds checking |
| 20 | * during register load --> no further bounds checks needed */ |
| 21 | #define LDT_DESCRIPTOR(s) (((struct desc_struct *)current->mm->context.ldt)[(s) >> 3]) |
| 22 | #define SEG_D_SIZE(x) ((x).b & (3 << 21)) |
| 23 | #define SEG_G_BIT(x) ((x).b & (1 << 23)) |
| 24 | #define SEG_GRANULARITY(x) (((x).b & (1 << 23)) ? 4096 : 1) |
| 25 | #define SEG_286_MODE(x) ((x).b & ( 0xff000000 | 0xf0000 | (1 << 23))) |
| 26 | #define SEG_BASE_ADDR(s) (((s).b & 0xff000000) \ |
| 27 | | (((s).b & 0xff) << 16) | ((s).a >> 16)) |
| 28 | #define SEG_LIMIT(s) (((s).b & 0xff0000) | ((s).a & 0xffff)) |
| 29 | #define SEG_EXECUTE_ONLY(s) (((s).b & ((1 << 11) | (1 << 9))) == (1 << 11)) |
| 30 | #define SEG_WRITE_PERM(s) (((s).b & ((1 << 11) | (1 << 9))) == (1 << 9)) |
| 31 | #define SEG_EXPAND_DOWN(s) (((s).b & ((1 << 11) | (1 << 10))) \ |
| 32 | == (1 << 10)) |
| 33 | |
Ingo Molnar | 7366ed7 | 2015-04-27 04:19:39 +0200 | [diff] [blame] | 34 | #define I387 (¤t->thread.fpu.state) |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 35 | #define FPU_info (I387->soft.info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Tejun Heo | d315760 | 2009-02-09 22:17:39 +0900 | [diff] [blame] | 37 | #define FPU_CS (*(unsigned short *) &(FPU_info->regs->cs)) |
| 38 | #define FPU_SS (*(unsigned short *) &(FPU_info->regs->ss)) |
| 39 | #define FPU_DS (*(unsigned short *) &(FPU_info->regs->ds)) |
| 40 | #define FPU_EAX (FPU_info->regs->ax) |
| 41 | #define FPU_EFLAGS (FPU_info->regs->flags) |
| 42 | #define FPU_EIP (FPU_info->regs->ip) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #define FPU_ORIG_EIP (FPU_info->___orig_eip) |
| 44 | |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 45 | #define FPU_lookahead (I387->soft.lookahead) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | /* nz if ip_offset and cs_selector are not to be set for the current |
| 48 | instruction. */ |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 49 | #define no_ip_update (*(u_char *)&(I387->soft.no_update)) |
| 50 | #define FPU_rm (*(u_char *)&(I387->soft.rm)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | /* Number of bytes of data which can be legally accessed by the current |
| 53 | instruction. This only needs to hold a number <= 108, so a byte will do. */ |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 54 | #define access_limit (*(u_char *)&(I387->soft.alimit)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 56 | #define partial_status (I387->soft.swd) |
| 57 | #define control_word (I387->soft.cwd) |
| 58 | #define fpu_tag_word (I387->soft.twd) |
| 59 | #define registers (I387->soft.st_space) |
| 60 | #define top (I387->soft.ftop) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 62 | #define instruction_address (*(struct address *)&I387->soft.fip) |
| 63 | #define operand_address (*(struct address *)&I387->soft.foo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
| 65 | #define FPU_access_ok(x,y,z) if ( !access_ok(x,y,z) ) \ |
| 66 | math_abort(FPU_info,SIGSEGV) |
Randy Dunlap | d606f88 | 2006-12-07 02:14:00 +0100 | [diff] [blame] | 67 | #define FPU_abort math_abort(FPU_info, SIGSEGV) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
| 69 | #undef FPU_IGNORE_CODE_SEGV |
| 70 | #ifdef FPU_IGNORE_CODE_SEGV |
| 71 | /* access_ok() is very expensive, and causes the emulator to run |
| 72 | about 20% slower if applied to the code. Anyway, errors due to bad |
| 73 | code addresses should be much rarer than errors due to bad data |
| 74 | addresses. */ |
| 75 | #define FPU_code_access_ok(z) |
| 76 | #else |
| 77 | /* A simpler test than access_ok() can probably be done for |
| 78 | FPU_code_access_ok() because the only possible error is to step |
| 79 | past the upper boundary of a legal code area. */ |
| 80 | #define FPU_code_access_ok(z) FPU_access_ok(VERIFY_READ,(void __user *)FPU_EIP,z) |
| 81 | #endif |
| 82 | |
| 83 | #define FPU_get_user(x,y) get_user((x),(y)) |
| 84 | #define FPU_put_user(x,y) put_user((x),(y)) |
| 85 | |
| 86 | #endif |