asm-offsets.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Generate definitions needed by assembly language modules.
  4. * This code generates raw asm output which is post-processed to extract
  5. * and format the required data.
  6. */
  7. #define COMPILE_OFFSETS
  8. #include <linux/crypto.h>
  9. #include <linux/sched.h>
  10. #include <linux/stddef.h>
  11. #include <linux/hardirq.h>
  12. #include <linux/suspend.h>
  13. #include <linux/kbuild.h>
  14. #include <asm/processor.h>
  15. #include <asm/thread_info.h>
  16. #include <asm/sigframe.h>
  17. #include <asm/bootparam.h>
  18. #include <asm/suspend.h>
  19. #include <asm/tlbflush.h>
  20. #ifdef CONFIG_XEN
  21. #include <xen/interface/xen.h>
  22. #endif
  23. #ifdef CONFIG_X86_32
  24. # include "asm-offsets_32.c"
  25. #else
  26. # include "asm-offsets_64.c"
  27. #endif
  28. void common(void) {
  29. BLANK();
  30. OFFSET(TASK_threadsp, task_struct, thread.sp);
  31. #ifdef CONFIG_STACKPROTECTOR
  32. OFFSET(TASK_stack_canary, task_struct, stack_canary);
  33. #endif
  34. BLANK();
  35. OFFSET(TASK_TI_flags, task_struct, thread_info.flags);
  36. OFFSET(TASK_addr_limit, task_struct, thread.addr_limit);
  37. BLANK();
  38. OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
  39. BLANK();
  40. OFFSET(pbe_address, pbe, address);
  41. OFFSET(pbe_orig_address, pbe, orig_address);
  42. OFFSET(pbe_next, pbe, next);
  43. #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
  44. BLANK();
  45. OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax);
  46. OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx);
  47. OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx);
  48. OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx);
  49. OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si);
  50. OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di);
  51. OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
  52. OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
  53. OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
  54. BLANK();
  55. OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
  56. #endif
  57. #ifdef CONFIG_PARAVIRT
  58. BLANK();
  59. OFFSET(PARAVIRT_PATCH_pv_cpu_ops, paravirt_patch_template, pv_cpu_ops);
  60. OFFSET(PARAVIRT_PATCH_pv_irq_ops, paravirt_patch_template, pv_irq_ops);
  61. OFFSET(PV_IRQ_irq_disable, pv_irq_ops, irq_disable);
  62. OFFSET(PV_IRQ_irq_enable, pv_irq_ops, irq_enable);
  63. OFFSET(PV_CPU_iret, pv_cpu_ops, iret);
  64. OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
  65. OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
  66. #endif
  67. #ifdef CONFIG_XEN
  68. BLANK();
  69. OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
  70. OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
  71. #endif
  72. BLANK();
  73. OFFSET(BP_scratch, boot_params, scratch);
  74. OFFSET(BP_secure_boot, boot_params, secure_boot);
  75. OFFSET(BP_loadflags, boot_params, hdr.loadflags);
  76. OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
  77. OFFSET(BP_version, boot_params, hdr.version);
  78. OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
  79. OFFSET(BP_init_size, boot_params, hdr.init_size);
  80. OFFSET(BP_pref_address, boot_params, hdr.pref_address);
  81. OFFSET(BP_code32_start, boot_params, hdr.code32_start);
  82. BLANK();
  83. DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
  84. /* TLB state for the entry code */
  85. OFFSET(TLB_STATE_user_pcid_flush_mask, tlb_state, user_pcid_flush_mask);
  86. /* Layout info for cpu_entry_area */
  87. OFFSET(CPU_ENTRY_AREA_tss, cpu_entry_area, tss);
  88. OFFSET(CPU_ENTRY_AREA_entry_trampoline, cpu_entry_area, entry_trampoline);
  89. OFFSET(CPU_ENTRY_AREA_entry_stack, cpu_entry_area, entry_stack_page);
  90. DEFINE(SIZEOF_entry_stack, sizeof(struct entry_stack));
  91. DEFINE(MASK_entry_stack, (~(sizeof(struct entry_stack) - 1)));
  92. /* Offset for sp0 and sp1 into the tss_struct */
  93. OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
  94. OFFSET(TSS_sp1, tss_struct, x86_tss.sp1);
  95. }