asm-offsets_32.c 5.1 KB

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