fpu_system.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. #ifndef _FPU_SYSTEM_H
  10. #define _FPU_SYSTEM_H
  11. /* system dependent definitions */
  12. #include <linux/sched.h>
  13. #include <linux/kernel.h>
  14. #include <linux/mm.h>
  15. #include <asm/desc.h>
  16. #include <asm/mmu_context.h>
  17. static inline struct desc_struct FPU_get_ldt_descriptor(unsigned seg)
  18. {
  19. static struct desc_struct zero_desc;
  20. struct desc_struct ret = zero_desc;
  21. #ifdef CONFIG_MODIFY_LDT_SYSCALL
  22. seg >>= 3;
  23. mutex_lock(&current->mm->context.lock);
  24. if (current->mm->context.ldt && seg < current->mm->context.ldt->size)
  25. ret = current->mm->context.ldt->entries[seg];
  26. mutex_unlock(&current->mm->context.lock);
  27. #endif
  28. return ret;
  29. }
  30. #define SEG_D_SIZE(x) ((x).b & (3 << 21))
  31. #define SEG_G_BIT(x) ((x).b & (1 << 23))
  32. #define SEG_GRANULARITY(x) (((x).b & (1 << 23)) ? 4096 : 1)
  33. #define SEG_286_MODE(x) ((x).b & ( 0xff000000 | 0xf0000 | (1 << 23)))
  34. #define SEG_BASE_ADDR(s) (((s).b & 0xff000000) \
  35. | (((s).b & 0xff) << 16) | ((s).a >> 16))
  36. #define SEG_LIMIT(s) (((s).b & 0xff0000) | ((s).a & 0xffff))
  37. #define SEG_EXECUTE_ONLY(s) (((s).b & ((1 << 11) | (1 << 9))) == (1 << 11))
  38. #define SEG_WRITE_PERM(s) (((s).b & ((1 << 11) | (1 << 9))) == (1 << 9))
  39. #define SEG_EXPAND_DOWN(s) (((s).b & ((1 << 11) | (1 << 10))) \
  40. == (1 << 10))
  41. #define I387 (&current->thread.fpu.state)
  42. #define FPU_info (I387->soft.info)
  43. #define FPU_CS (*(unsigned short *) &(FPU_info->regs->cs))
  44. #define FPU_SS (*(unsigned short *) &(FPU_info->regs->ss))
  45. #define FPU_DS (*(unsigned short *) &(FPU_info->regs->ds))
  46. #define FPU_EAX (FPU_info->regs->ax)
  47. #define FPU_EFLAGS (FPU_info->regs->flags)
  48. #define FPU_EIP (FPU_info->regs->ip)
  49. #define FPU_ORIG_EIP (FPU_info->___orig_eip)
  50. #define FPU_lookahead (I387->soft.lookahead)
  51. /* nz if ip_offset and cs_selector are not to be set for the current
  52. instruction. */
  53. #define no_ip_update (*(u_char *)&(I387->soft.no_update))
  54. #define FPU_rm (*(u_char *)&(I387->soft.rm))
  55. /* Number of bytes of data which can be legally accessed by the current
  56. instruction. This only needs to hold a number <= 108, so a byte will do. */
  57. #define access_limit (*(u_char *)&(I387->soft.alimit))
  58. #define partial_status (I387->soft.swd)
  59. #define control_word (I387->soft.cwd)
  60. #define fpu_tag_word (I387->soft.twd)
  61. #define registers (I387->soft.st_space)
  62. #define top (I387->soft.ftop)
  63. #define instruction_address (*(struct address *)&I387->soft.fip)
  64. #define operand_address (*(struct address *)&I387->soft.foo)
  65. #define FPU_access_ok(x,y,z) if ( !access_ok(x,y,z) ) \
  66. math_abort(FPU_info,SIGSEGV)
  67. #define FPU_abort math_abort(FPU_info, SIGSEGV)
  68. #undef FPU_IGNORE_CODE_SEGV
  69. #ifdef FPU_IGNORE_CODE_SEGV
  70. /* access_ok() is very expensive, and causes the emulator to run
  71. about 20% slower if applied to the code. Anyway, errors due to bad
  72. code addresses should be much rarer than errors due to bad data
  73. addresses. */
  74. #define FPU_code_access_ok(z)
  75. #else
  76. /* A simpler test than access_ok() can probably be done for
  77. FPU_code_access_ok() because the only possible error is to step
  78. past the upper boundary of a legal code area. */
  79. #define FPU_code_access_ok(z) FPU_access_ok(VERIFY_READ,(void __user *)FPU_EIP,z)
  80. #endif
  81. #define FPU_get_user(x,y) get_user((x),(y))
  82. #define FPU_put_user(x,y) put_user((x),(y))
  83. #endif