processor_64.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 1994 Linus Torvalds
  3. */
  4. #ifndef __ASM_X86_64_PROCESSOR_H
  5. #define __ASM_X86_64_PROCESSOR_H
  6. #include <asm/segment.h>
  7. #include <asm/page.h>
  8. #include <asm/types.h>
  9. #include <asm/sigcontext.h>
  10. #include <asm/cpufeature.h>
  11. #include <linux/threads.h>
  12. #include <asm/msr.h>
  13. #include <asm/current.h>
  14. #include <asm/system.h>
  15. #include <linux/personality.h>
  16. #include <asm/desc_defs.h>
  17. /*
  18. * User space process size. 47bits minus one guard page.
  19. */
  20. #define TASK_SIZE64 (0x800000000000UL - 4096)
  21. /* This decides where the kernel will search for a free chunk of vm
  22. * space during mmap's.
  23. */
  24. #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000)
  25. #define TASK_SIZE (test_thread_flag(TIF_IA32) ? IA32_PAGE_OFFSET : TASK_SIZE64)
  26. #define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_IA32)) ? IA32_PAGE_OFFSET : TASK_SIZE64)
  27. struct i387_fxsave_struct {
  28. u16 cwd;
  29. u16 swd;
  30. u16 twd;
  31. u16 fop;
  32. u64 rip;
  33. u64 rdp;
  34. u32 mxcsr;
  35. u32 mxcsr_mask;
  36. u32 st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
  37. u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
  38. u32 padding[24];
  39. } __attribute__ ((aligned (16)));
  40. union i387_union {
  41. struct i387_fxsave_struct fxsave;
  42. };
  43. DECLARE_PER_CPU(struct orig_ist, orig_ist);
  44. #define INIT_THREAD { \
  45. .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
  46. }
  47. #define INIT_TSS { \
  48. .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
  49. }
  50. #define start_thread(regs,new_rip,new_rsp) do { \
  51. asm volatile("movl %0,%%fs; movl %0,%%es; movl %0,%%ds": :"r" (0)); \
  52. load_gs_index(0); \
  53. (regs)->ip = (new_rip); \
  54. (regs)->sp = (new_rsp); \
  55. write_pda(oldrsp, (new_rsp)); \
  56. (regs)->cs = __USER_CS; \
  57. (regs)->ss = __USER_DS; \
  58. (regs)->flags = 0x200; \
  59. set_fs(USER_DS); \
  60. } while(0)
  61. /*
  62. * Return saved PC of a blocked thread.
  63. * What is this good for? it will be always the scheduler or ret_from_fork.
  64. */
  65. #define thread_saved_pc(t) (*(unsigned long *)((t)->thread.sp - 8))
  66. #define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
  67. #define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
  68. #endif /* __ASM_X86_64_PROCESSOR_H */