asm-offsets.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #include <asm/tdx.h>
  21. #ifdef CONFIG_XEN
  22. #include <xen/interface/xen.h>
  23. #endif
  24. #ifdef CONFIG_X86_32
  25. # include "asm-offsets_32.c"
  26. #else
  27. # include "asm-offsets_64.c"
  28. #endif
  29. static void __used common(void)
  30. {
  31. BLANK();
  32. OFFSET(TASK_threadsp, task_struct, thread.sp);
  33. #ifdef CONFIG_STACKPROTECTOR
  34. OFFSET(TASK_stack_canary, task_struct, stack_canary);
  35. #endif
  36. BLANK();
  37. OFFSET(pbe_address, pbe, address);
  38. OFFSET(pbe_orig_address, pbe, orig_address);
  39. OFFSET(pbe_next, pbe, next);
  40. #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
  41. BLANK();
  42. OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax);
  43. OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx);
  44. OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx);
  45. OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx);
  46. OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si);
  47. OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di);
  48. OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
  49. OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
  50. OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
  51. BLANK();
  52. OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
  53. #endif
  54. #ifdef CONFIG_XEN
  55. BLANK();
  56. OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
  57. OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
  58. OFFSET(XEN_vcpu_info_arch_cr2, vcpu_info, arch.cr2);
  59. #endif
  60. BLANK();
  61. OFFSET(TDX_MODULE_rcx, tdx_module_output, rcx);
  62. OFFSET(TDX_MODULE_rdx, tdx_module_output, rdx);
  63. OFFSET(TDX_MODULE_r8, tdx_module_output, r8);
  64. OFFSET(TDX_MODULE_r9, tdx_module_output, r9);
  65. OFFSET(TDX_MODULE_r10, tdx_module_output, r10);
  66. OFFSET(TDX_MODULE_r11, tdx_module_output, r11);
  67. BLANK();
  68. OFFSET(TDX_HYPERCALL_r10, tdx_hypercall_args, r10);
  69. OFFSET(TDX_HYPERCALL_r11, tdx_hypercall_args, r11);
  70. OFFSET(TDX_HYPERCALL_r12, tdx_hypercall_args, r12);
  71. OFFSET(TDX_HYPERCALL_r13, tdx_hypercall_args, r13);
  72. OFFSET(TDX_HYPERCALL_r14, tdx_hypercall_args, r14);
  73. OFFSET(TDX_HYPERCALL_r15, tdx_hypercall_args, r15);
  74. BLANK();
  75. OFFSET(BP_scratch, boot_params, scratch);
  76. OFFSET(BP_secure_boot, boot_params, secure_boot);
  77. OFFSET(BP_loadflags, boot_params, hdr.loadflags);
  78. OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
  79. OFFSET(BP_version, boot_params, hdr.version);
  80. OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
  81. OFFSET(BP_init_size, boot_params, hdr.init_size);
  82. OFFSET(BP_pref_address, boot_params, hdr.pref_address);
  83. BLANK();
  84. DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
  85. /* TLB state for the entry code */
  86. OFFSET(TLB_STATE_user_pcid_flush_mask, tlb_state, user_pcid_flush_mask);
  87. /* Layout info for cpu_entry_area */
  88. OFFSET(CPU_ENTRY_AREA_entry_stack, cpu_entry_area, entry_stack_page);
  89. DEFINE(SIZEOF_entry_stack, sizeof(struct entry_stack));
  90. DEFINE(MASK_entry_stack, (~(sizeof(struct entry_stack) - 1)));
  91. /* Offset for fields in tss_struct */
  92. OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
  93. OFFSET(TSS_sp1, tss_struct, x86_tss.sp1);
  94. OFFSET(TSS_sp2, tss_struct, x86_tss.sp2);
  95. }