asm-offsets_32.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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_32.h"
  13. #include <asm/pgtable.h>
  14. #include <asm/fixmap.h>
  15. #include <asm/processor.h>
  16. #include <asm/thread_info.h>
  17. #include <asm/elf.h>
  18. #include <xen/interface/xen.h>
  19. #ifdef CONFIG_LGUEST_GUEST
  20. #include <linux/lguest.h>
  21. #include "../../../drivers/lguest/lg.h"
  22. #endif
  23. #define DEFINE(sym, val) \
  24. asm volatile("\n->" #sym " %0 " #val : : "i" (val))
  25. #define BLANK() asm volatile("\n->" : : )
  26. #define OFFSET(sym, str, mem) \
  27. DEFINE(sym, offsetof(struct str, mem));
  28. /* workaround for a warning with -Wmissing-prototypes */
  29. void foo(void);
  30. void foo(void)
  31. {
  32. OFFSET(SIGCONTEXT_eax, sigcontext, eax);
  33. OFFSET(SIGCONTEXT_ebx, sigcontext, ebx);
  34. OFFSET(SIGCONTEXT_ecx, sigcontext, ecx);
  35. OFFSET(SIGCONTEXT_edx, sigcontext, edx);
  36. OFFSET(SIGCONTEXT_esi, sigcontext, esi);
  37. OFFSET(SIGCONTEXT_edi, sigcontext, edi);
  38. OFFSET(SIGCONTEXT_ebp, sigcontext, ebp);
  39. OFFSET(SIGCONTEXT_esp, sigcontext, esp);
  40. OFFSET(SIGCONTEXT_eip, sigcontext, eip);
  41. BLANK();
  42. OFFSET(CPUINFO_x86, cpuinfo_x86, x86);
  43. OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor);
  44. OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model);
  45. OFFSET(CPUINFO_x86_mask, cpuinfo_x86, x86_mask);
  46. OFFSET(CPUINFO_hard_math, cpuinfo_x86, hard_math);
  47. OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level);
  48. OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability);
  49. OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id);
  50. BLANK();
  51. OFFSET(TI_task, thread_info, task);
  52. OFFSET(TI_exec_domain, thread_info, exec_domain);
  53. OFFSET(TI_flags, thread_info, flags);
  54. OFFSET(TI_status, thread_info, status);
  55. OFFSET(TI_preempt_count, thread_info, preempt_count);
  56. OFFSET(TI_addr_limit, thread_info, addr_limit);
  57. OFFSET(TI_restart_block, thread_info, restart_block);
  58. OFFSET(TI_sysenter_return, thread_info, sysenter_return);
  59. OFFSET(TI_cpu, thread_info, cpu);
  60. BLANK();
  61. OFFSET(GDS_size, Xgt_desc_struct, size);
  62. OFFSET(GDS_address, Xgt_desc_struct, address);
  63. OFFSET(GDS_pad, Xgt_desc_struct, pad);
  64. BLANK();
  65. OFFSET(PT_EBX, pt_regs, ebx);
  66. OFFSET(PT_ECX, pt_regs, ecx);
  67. OFFSET(PT_EDX, pt_regs, edx);
  68. OFFSET(PT_ESI, pt_regs, esi);
  69. OFFSET(PT_EDI, pt_regs, edi);
  70. OFFSET(PT_EBP, pt_regs, ebp);
  71. OFFSET(PT_EAX, pt_regs, eax);
  72. OFFSET(PT_DS, pt_regs, xds);
  73. OFFSET(PT_ES, pt_regs, xes);
  74. OFFSET(PT_FS, pt_regs, xfs);
  75. OFFSET(PT_ORIG_EAX, pt_regs, orig_eax);
  76. OFFSET(PT_EIP, pt_regs, eip);
  77. OFFSET(PT_CS, pt_regs, xcs);
  78. OFFSET(PT_EFLAGS, pt_regs, eflags);
  79. OFFSET(PT_OLDESP, pt_regs, esp);
  80. OFFSET(PT_OLDSS, pt_regs, xss);
  81. BLANK();
  82. OFFSET(EXEC_DOMAIN_handler, exec_domain, handler);
  83. OFFSET(RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext);
  84. BLANK();
  85. OFFSET(pbe_address, pbe, address);
  86. OFFSET(pbe_orig_address, pbe, orig_address);
  87. OFFSET(pbe_next, pbe, next);
  88. /* Offset from the sysenter stack to tss.esp0 */
  89. DEFINE(TSS_sysenter_esp0, offsetof(struct tss_struct, x86_tss.esp0) -
  90. sizeof(struct tss_struct));
  91. DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
  92. DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
  93. DEFINE(PTRS_PER_PTE, PTRS_PER_PTE);
  94. DEFINE(PTRS_PER_PMD, PTRS_PER_PMD);
  95. DEFINE(PTRS_PER_PGD, PTRS_PER_PGD);
  96. DEFINE(VDSO_PRELINK_asm, VDSO_PRELINK);
  97. OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
  98. #ifdef CONFIG_PARAVIRT
  99. BLANK();
  100. OFFSET(PARAVIRT_enabled, paravirt_ops, paravirt_enabled);
  101. OFFSET(PARAVIRT_irq_disable, paravirt_ops, irq_disable);
  102. OFFSET(PARAVIRT_irq_enable, paravirt_ops, irq_enable);
  103. OFFSET(PARAVIRT_irq_enable_sysexit, paravirt_ops, irq_enable_sysexit);
  104. OFFSET(PARAVIRT_iret, paravirt_ops, iret);
  105. OFFSET(PARAVIRT_read_cr0, paravirt_ops, read_cr0);
  106. #endif
  107. #ifdef CONFIG_XEN
  108. BLANK();
  109. OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
  110. OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
  111. #endif
  112. #ifdef CONFIG_LGUEST_GUEST
  113. BLANK();
  114. OFFSET(LGUEST_DATA_irq_enabled, lguest_data, irq_enabled);
  115. OFFSET(LGUEST_PAGES_host_gdt_desc, lguest_pages, state.host_gdt_desc);
  116. OFFSET(LGUEST_PAGES_host_idt_desc, lguest_pages, state.host_idt_desc);
  117. OFFSET(LGUEST_PAGES_host_cr3, lguest_pages, state.host_cr3);
  118. OFFSET(LGUEST_PAGES_host_sp, lguest_pages, state.host_sp);
  119. OFFSET(LGUEST_PAGES_guest_gdt_desc, lguest_pages,state.guest_gdt_desc);
  120. OFFSET(LGUEST_PAGES_guest_idt_desc, lguest_pages,state.guest_idt_desc);
  121. OFFSET(LGUEST_PAGES_guest_gdt, lguest_pages, state.guest_gdt);
  122. OFFSET(LGUEST_PAGES_regs_trapnum, lguest_pages, regs.trapnum);
  123. OFFSET(LGUEST_PAGES_regs_errcode, lguest_pages, regs.errcode);
  124. OFFSET(LGUEST_PAGES_regs, lguest_pages, regs);
  125. #endif
  126. }