asm-offsets.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Generate definitions needed by assembly language modules.
  3. * This code generates raw asm output which is post-processed
  4. * to extract and format the required data.
  5. */
  6. #include <linux/crypto.h>
  7. #include <linux/sched.h>
  8. #include <linux/signal.h>
  9. #include <linux/personality.h>
  10. #include <linux/suspend.h>
  11. #include <asm/ucontext.h>
  12. #include "sigframe.h"
  13. #include <asm/fixmap.h>
  14. #include <asm/processor.h>
  15. #include <asm/thread_info.h>
  16. #include <asm/elf.h>
  17. #include <asm/pda.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. void foo(void)
  24. {
  25. OFFSET(SIGCONTEXT_eax, sigcontext, eax);
  26. OFFSET(SIGCONTEXT_ebx, sigcontext, ebx);
  27. OFFSET(SIGCONTEXT_ecx, sigcontext, ecx);
  28. OFFSET(SIGCONTEXT_edx, sigcontext, edx);
  29. OFFSET(SIGCONTEXT_esi, sigcontext, esi);
  30. OFFSET(SIGCONTEXT_edi, sigcontext, edi);
  31. OFFSET(SIGCONTEXT_ebp, sigcontext, ebp);
  32. OFFSET(SIGCONTEXT_esp, sigcontext, esp);
  33. OFFSET(SIGCONTEXT_eip, sigcontext, eip);
  34. BLANK();
  35. OFFSET(CPUINFO_x86, cpuinfo_x86, x86);
  36. OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor);
  37. OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model);
  38. OFFSET(CPUINFO_x86_mask, cpuinfo_x86, x86_mask);
  39. OFFSET(CPUINFO_hard_math, cpuinfo_x86, hard_math);
  40. OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level);
  41. OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability);
  42. OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id);
  43. BLANK();
  44. OFFSET(TI_task, thread_info, task);
  45. OFFSET(TI_exec_domain, thread_info, exec_domain);
  46. OFFSET(TI_flags, thread_info, flags);
  47. OFFSET(TI_status, thread_info, status);
  48. OFFSET(TI_preempt_count, thread_info, preempt_count);
  49. OFFSET(TI_addr_limit, thread_info, addr_limit);
  50. OFFSET(TI_restart_block, thread_info, restart_block);
  51. OFFSET(TI_sysenter_return, thread_info, sysenter_return);
  52. BLANK();
  53. OFFSET(GDS_size, Xgt_desc_struct, size);
  54. OFFSET(GDS_address, Xgt_desc_struct, address);
  55. OFFSET(GDS_pad, Xgt_desc_struct, pad);
  56. BLANK();
  57. OFFSET(PT_EBX, pt_regs, ebx);
  58. OFFSET(PT_ECX, pt_regs, ecx);
  59. OFFSET(PT_EDX, pt_regs, edx);
  60. OFFSET(PT_ESI, pt_regs, esi);
  61. OFFSET(PT_EDI, pt_regs, edi);
  62. OFFSET(PT_EBP, pt_regs, ebp);
  63. OFFSET(PT_EAX, pt_regs, eax);
  64. OFFSET(PT_DS, pt_regs, xds);
  65. OFFSET(PT_ES, pt_regs, xes);
  66. OFFSET(PT_GS, pt_regs, xgs);
  67. OFFSET(PT_ORIG_EAX, pt_regs, orig_eax);
  68. OFFSET(PT_EIP, pt_regs, eip);
  69. OFFSET(PT_CS, pt_regs, xcs);
  70. OFFSET(PT_EFLAGS, pt_regs, eflags);
  71. OFFSET(PT_OLDESP, pt_regs, esp);
  72. OFFSET(PT_OLDSS, pt_regs, xss);
  73. BLANK();
  74. OFFSET(EXEC_DOMAIN_handler, exec_domain, handler);
  75. OFFSET(RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext);
  76. BLANK();
  77. OFFSET(pbe_address, pbe, address);
  78. OFFSET(pbe_orig_address, pbe, orig_address);
  79. OFFSET(pbe_next, pbe, next);
  80. /* Offset from the sysenter stack to tss.esp0 */
  81. DEFINE(TSS_sysenter_esp0, offsetof(struct tss_struct, esp0) -
  82. sizeof(struct tss_struct));
  83. DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
  84. DEFINE(VDSO_PRELINK, VDSO_PRELINK);
  85. OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
  86. BLANK();
  87. OFFSET(PDA_cpu, i386_pda, cpu_number);
  88. OFFSET(PDA_pcurrent, i386_pda, pcurrent);
  89. #ifdef CONFIG_PARAVIRT
  90. BLANK();
  91. OFFSET(PARAVIRT_enabled, paravirt_ops, paravirt_enabled);
  92. OFFSET(PARAVIRT_irq_disable, paravirt_ops, irq_disable);
  93. OFFSET(PARAVIRT_irq_enable, paravirt_ops, irq_enable);
  94. OFFSET(PARAVIRT_irq_enable_sysexit, paravirt_ops, irq_enable_sysexit);
  95. OFFSET(PARAVIRT_iret, paravirt_ops, iret);
  96. OFFSET(PARAVIRT_read_cr0, paravirt_ops, read_cr0);
  97. #endif
  98. }