asm-offsets.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 <crypto/aria.h>
  10. #include <linux/sched.h>
  11. #include <linux/stddef.h>
  12. #include <linux/hardirq.h>
  13. #include <linux/suspend.h>
  14. #include <linux/kbuild.h>
  15. #include <asm/processor.h>
  16. #include <asm/thread_info.h>
  17. #include <asm/sigframe.h>
  18. #include <asm/bootparam.h>
  19. #include <asm/suspend.h>
  20. #include <asm/tlbflush.h>
  21. #include <asm/tdx.h>
  22. #ifdef CONFIG_XEN
  23. #include <xen/interface/xen.h>
  24. #endif
  25. #ifdef CONFIG_X86_32
  26. # include "asm-offsets_32.c"
  27. #else
  28. # include "asm-offsets_64.c"
  29. #endif
  30. static void __used common(void)
  31. {
  32. BLANK();
  33. OFFSET(TASK_threadsp, task_struct, thread.sp);
  34. #ifdef CONFIG_STACKPROTECTOR
  35. OFFSET(TASK_stack_canary, task_struct, stack_canary);
  36. #endif
  37. BLANK();
  38. OFFSET(pbe_address, pbe, address);
  39. OFFSET(pbe_orig_address, pbe, orig_address);
  40. OFFSET(pbe_next, pbe, next);
  41. #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
  42. BLANK();
  43. OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax);
  44. OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx);
  45. OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx);
  46. OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx);
  47. OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si);
  48. OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di);
  49. OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
  50. OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
  51. OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
  52. BLANK();
  53. OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
  54. #endif
  55. #ifdef CONFIG_XEN
  56. BLANK();
  57. OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
  58. OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
  59. OFFSET(XEN_vcpu_info_arch_cr2, vcpu_info, arch.cr2);
  60. #endif
  61. BLANK();
  62. OFFSET(TDX_MODULE_rcx, tdx_module_args, rcx);
  63. OFFSET(TDX_MODULE_rdx, tdx_module_args, rdx);
  64. OFFSET(TDX_MODULE_r8, tdx_module_args, r8);
  65. OFFSET(TDX_MODULE_r9, tdx_module_args, r9);
  66. OFFSET(TDX_MODULE_r10, tdx_module_args, r10);
  67. OFFSET(TDX_MODULE_r11, tdx_module_args, r11);
  68. OFFSET(TDX_MODULE_r12, tdx_module_args, r12);
  69. OFFSET(TDX_MODULE_r13, tdx_module_args, r13);
  70. OFFSET(TDX_MODULE_r14, tdx_module_args, r14);
  71. OFFSET(TDX_MODULE_r15, tdx_module_args, r15);
  72. OFFSET(TDX_MODULE_rbx, tdx_module_args, rbx);
  73. OFFSET(TDX_MODULE_rdi, tdx_module_args, rdi);
  74. OFFSET(TDX_MODULE_rsi, tdx_module_args, rsi);
  75. BLANK();
  76. OFFSET(BP_scratch, boot_params, scratch);
  77. OFFSET(BP_secure_boot, boot_params, secure_boot);
  78. OFFSET(BP_loadflags, boot_params, hdr.loadflags);
  79. OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
  80. OFFSET(BP_version, boot_params, hdr.version);
  81. OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
  82. OFFSET(BP_init_size, boot_params, hdr.init_size);
  83. OFFSET(BP_pref_address, boot_params, hdr.pref_address);
  84. BLANK();
  85. DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
  86. /* TLB state for the entry code */
  87. OFFSET(TLB_STATE_user_pcid_flush_mask, tlb_state, user_pcid_flush_mask);
  88. /* Layout info for cpu_entry_area */
  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 fields in tss_struct */
  93. OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
  94. OFFSET(TSS_sp1, tss_struct, x86_tss.sp1);
  95. OFFSET(TSS_sp2, tss_struct, x86_tss.sp2);
  96. OFFSET(X86_top_of_stack, pcpu_hot, top_of_stack);
  97. OFFSET(X86_current_task, pcpu_hot, current_task);
  98. #ifdef CONFIG_MITIGATION_CALL_DEPTH_TRACKING
  99. OFFSET(X86_call_depth, pcpu_hot, call_depth);
  100. #endif
  101. #if IS_ENABLED(CONFIG_CRYPTO_ARIA_AESNI_AVX_X86_64)
  102. /* Offset for fields in aria_ctx */
  103. BLANK();
  104. OFFSET(ARIA_CTX_enc_key, aria_ctx, enc_key);
  105. OFFSET(ARIA_CTX_dec_key, aria_ctx, dec_key);
  106. OFFSET(ARIA_CTX_rounds, aria_ctx, rounds);
  107. #endif
  108. }