asm-offsets_64.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Generate definitions needed by assembly language modules.
  3. * This code generates raw asm output which is post-processed to extract
  4. * and format the required data.
  5. */
  6. #include <linux/crypto.h>
  7. #include <linux/sched.h>
  8. #include <linux/stddef.h>
  9. #include <linux/errno.h>
  10. #include <linux/hardirq.h>
  11. #include <linux/suspend.h>
  12. #include <asm/pda.h>
  13. #include <asm/processor.h>
  14. #include <asm/segment.h>
  15. #include <asm/thread_info.h>
  16. #include <asm/ia32.h>
  17. #include <asm/bootparam.h>
  18. #define DEFINE(sym, val) \
  19. asm volatile("\n->" #sym " %0 " #val : : "i" (val))
  20. #define BLANK() asm volatile("\n->" : : )
  21. #define OFFSET(sym, str, mem) \
  22. DEFINE(sym, offsetof(struct str, mem))
  23. #define __NO_STUBS 1
  24. #undef __SYSCALL
  25. #undef _ASM_X86_64_UNISTD_H_
  26. #define __SYSCALL(nr, sym) [nr] = 1,
  27. static char syscalls[] = {
  28. #include <asm/unistd.h>
  29. };
  30. int main(void)
  31. {
  32. #define ENTRY(entry) DEFINE(tsk_ ## entry, offsetof(struct task_struct, entry))
  33. ENTRY(state);
  34. ENTRY(flags);
  35. ENTRY(thread);
  36. ENTRY(pid);
  37. BLANK();
  38. #undef ENTRY
  39. #define ENTRY(entry) DEFINE(threadinfo_ ## entry, offsetof(struct thread_info, entry))
  40. ENTRY(flags);
  41. ENTRY(addr_limit);
  42. ENTRY(preempt_count);
  43. ENTRY(status);
  44. BLANK();
  45. #undef ENTRY
  46. #define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))
  47. ENTRY(kernelstack);
  48. ENTRY(oldrsp);
  49. ENTRY(pcurrent);
  50. ENTRY(irqcount);
  51. ENTRY(cpunumber);
  52. ENTRY(irqstackptr);
  53. ENTRY(data_offset);
  54. BLANK();
  55. #undef ENTRY
  56. #ifdef CONFIG_IA32_EMULATION
  57. #define ENTRY(entry) DEFINE(IA32_SIGCONTEXT_ ## entry, offsetof(struct sigcontext_ia32, entry))
  58. ENTRY(eax);
  59. ENTRY(ebx);
  60. ENTRY(ecx);
  61. ENTRY(edx);
  62. ENTRY(esi);
  63. ENTRY(edi);
  64. ENTRY(ebp);
  65. ENTRY(esp);
  66. ENTRY(eip);
  67. BLANK();
  68. #undef ENTRY
  69. DEFINE(IA32_RT_SIGFRAME_sigcontext,
  70. offsetof (struct rt_sigframe32, uc.uc_mcontext));
  71. BLANK();
  72. #endif
  73. DEFINE(pbe_address, offsetof(struct pbe, address));
  74. DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
  75. DEFINE(pbe_next, offsetof(struct pbe, next));
  76. BLANK();
  77. #define ENTRY(entry) DEFINE(pt_regs_ ## entry, offsetof(struct pt_regs, entry))
  78. ENTRY(rbx);
  79. ENTRY(rbx);
  80. ENTRY(rcx);
  81. ENTRY(rdx);
  82. ENTRY(rsp);
  83. ENTRY(rbp);
  84. ENTRY(rsi);
  85. ENTRY(rdi);
  86. ENTRY(r8);
  87. ENTRY(r9);
  88. ENTRY(r10);
  89. ENTRY(r11);
  90. ENTRY(r12);
  91. ENTRY(r13);
  92. ENTRY(r14);
  93. ENTRY(r15);
  94. ENTRY(eflags);
  95. BLANK();
  96. #undef ENTRY
  97. #define ENTRY(entry) DEFINE(saved_context_ ## entry, offsetof(struct saved_context, entry))
  98. ENTRY(cr0);
  99. ENTRY(cr2);
  100. ENTRY(cr3);
  101. ENTRY(cr4);
  102. ENTRY(cr8);
  103. BLANK();
  104. #undef ENTRY
  105. DEFINE(TSS_ist, offsetof(struct tss_struct, ist));
  106. BLANK();
  107. DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
  108. BLANK();
  109. DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
  110. BLANK();
  111. OFFSET(BP_scratch, boot_params, scratch);
  112. OFFSET(BP_loadflags, boot_params, hdr.loadflags);
  113. OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
  114. OFFSET(BP_version, boot_params, hdr.version);
  115. return 0;
  116. }