1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 2b82fef82SJan Beulich /* 3b82fef82SJan Beulich * Generate definitions needed by assembly language modules. 4b82fef82SJan Beulich * This code generates raw asm output which is post-processed to extract 5b82fef82SJan Beulich * and format the required data. 6b82fef82SJan Beulich */ 7b82fef82SJan Beulich #define COMPILE_OFFSETS 8b82fef82SJan Beulich 9b82fef82SJan Beulich #include <linux/crypto.h> 1035344cf3STaehee Yoo #include <crypto/aria.h> 11b82fef82SJan Beulich #include <linux/sched.h> 12b82fef82SJan Beulich #include <linux/stddef.h> 13b82fef82SJan Beulich #include <linux/hardirq.h> 14b82fef82SJan Beulich #include <linux/suspend.h> 15b82fef82SJan Beulich #include <linux/kbuild.h> 16b82fef82SJan Beulich #include <asm/processor.h> 17b82fef82SJan Beulich #include <asm/thread_info.h> 18b82fef82SJan Beulich #include <asm/sigframe.h> 19b82fef82SJan Beulich #include <asm/bootparam.h> 20b82fef82SJan Beulich #include <asm/suspend.h> 216fd166aaSPeter Zijlstra #include <asm/tlbflush.h> 22527a534cSKirill A. Shutemov #include <asm/tdx.h> 23b82fef82SJan Beulich 24b82fef82SJan Beulich #ifdef CONFIG_XEN 25b82fef82SJan Beulich #include <xen/interface/xen.h> 26b82fef82SJan Beulich #endif 27b82fef82SJan Beulich 289a163ed8SThomas Gleixner #ifdef CONFIG_X86_32 299a163ed8SThomas Gleixner # include "asm-offsets_32.c" 309a163ed8SThomas Gleixner #else 319a163ed8SThomas Gleixner # include "asm-offsets_64.c" 329a163ed8SThomas Gleixner #endif 33b82fef82SJan Beulich 34ad3bc25aSBorislav Petkov static void __used common(void) 35ad3bc25aSBorislav Petkov { 36b82fef82SJan Beulich BLANK(); 370100301bSBrian Gerst OFFSET(TASK_threadsp, task_struct, thread.sp); 38050e9baaSLinus Torvalds #ifdef CONFIG_STACKPROTECTOR 390100301bSBrian Gerst OFFSET(TASK_stack_canary, task_struct, stack_canary); 400100301bSBrian Gerst #endif 410100301bSBrian Gerst 420100301bSBrian Gerst BLANK(); 43b82fef82SJan Beulich OFFSET(pbe_address, pbe, address); 44b82fef82SJan Beulich OFFSET(pbe_orig_address, pbe, orig_address); 45b82fef82SJan Beulich OFFSET(pbe_next, pbe, next); 46b82fef82SJan Beulich 474d178f94SBrian Gerst #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) 484d178f94SBrian Gerst BLANK(); 498fcb346bSIngo Molnar OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax); 508fcb346bSIngo Molnar OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx); 518fcb346bSIngo Molnar OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx); 528fcb346bSIngo Molnar OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx); 538fcb346bSIngo Molnar OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si); 548fcb346bSIngo Molnar OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di); 558fcb346bSIngo Molnar OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp); 568fcb346bSIngo Molnar OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp); 578fcb346bSIngo Molnar OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip); 584d178f94SBrian Gerst 594d178f94SBrian Gerst BLANK(); 604d178f94SBrian Gerst OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext); 614d178f94SBrian Gerst #endif 624d178f94SBrian Gerst 63b82fef82SJan Beulich #ifdef CONFIG_XEN 64b82fef82SJan Beulich BLANK(); 65b82fef82SJan Beulich OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask); 66b82fef82SJan Beulich OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending); 6755aedddbSPeter Zijlstra OFFSET(XEN_vcpu_info_arch_cr2, vcpu_info, arch.cr2); 68b82fef82SJan Beulich #endif 69b82fef82SJan Beulich 70b82fef82SJan Beulich BLANK(); 7157a420bbSKai Huang OFFSET(TDX_MODULE_rcx, tdx_module_args, rcx); 7257a420bbSKai Huang OFFSET(TDX_MODULE_rdx, tdx_module_args, rdx); 7357a420bbSKai Huang OFFSET(TDX_MODULE_r8, tdx_module_args, r8); 7457a420bbSKai Huang OFFSET(TDX_MODULE_r9, tdx_module_args, r9); 7557a420bbSKai Huang OFFSET(TDX_MODULE_r10, tdx_module_args, r10); 7657a420bbSKai Huang OFFSET(TDX_MODULE_r11, tdx_module_args, r11); 77*12f34ed8SKai Huang OFFSET(TDX_MODULE_r12, tdx_module_args, r12); 78*12f34ed8SKai Huang OFFSET(TDX_MODULE_r13, tdx_module_args, r13); 79*12f34ed8SKai Huang OFFSET(TDX_MODULE_r14, tdx_module_args, r14); 80*12f34ed8SKai Huang OFFSET(TDX_MODULE_r15, tdx_module_args, r15); 81*12f34ed8SKai Huang OFFSET(TDX_MODULE_rbx, tdx_module_args, rbx); 82*12f34ed8SKai Huang OFFSET(TDX_MODULE_rdi, tdx_module_args, rdi); 83*12f34ed8SKai Huang OFFSET(TDX_MODULE_rsi, tdx_module_args, rsi); 84527a534cSKirill A. Shutemov 85527a534cSKirill A. Shutemov BLANK(); 860da908c2SKirill A. Shutemov OFFSET(TDX_HYPERCALL_r8, tdx_hypercall_args, r8); 870da908c2SKirill A. Shutemov OFFSET(TDX_HYPERCALL_r9, tdx_hypercall_args, r9); 88eb94f1b6SKuppuswamy Sathyanarayanan OFFSET(TDX_HYPERCALL_r10, tdx_hypercall_args, r10); 89eb94f1b6SKuppuswamy Sathyanarayanan OFFSET(TDX_HYPERCALL_r11, tdx_hypercall_args, r11); 90eb94f1b6SKuppuswamy Sathyanarayanan OFFSET(TDX_HYPERCALL_r12, tdx_hypercall_args, r12); 91eb94f1b6SKuppuswamy Sathyanarayanan OFFSET(TDX_HYPERCALL_r13, tdx_hypercall_args, r13); 92eb94f1b6SKuppuswamy Sathyanarayanan OFFSET(TDX_HYPERCALL_r14, tdx_hypercall_args, r14); 93eb94f1b6SKuppuswamy Sathyanarayanan OFFSET(TDX_HYPERCALL_r15, tdx_hypercall_args, r15); 940da908c2SKirill A. Shutemov OFFSET(TDX_HYPERCALL_rdi, tdx_hypercall_args, rdi); 950da908c2SKirill A. Shutemov OFFSET(TDX_HYPERCALL_rsi, tdx_hypercall_args, rsi); 960da908c2SKirill A. Shutemov OFFSET(TDX_HYPERCALL_rbx, tdx_hypercall_args, rbx); 970da908c2SKirill A. Shutemov OFFSET(TDX_HYPERCALL_rdx, tdx_hypercall_args, rdx); 98eb94f1b6SKuppuswamy Sathyanarayanan 99eb94f1b6SKuppuswamy Sathyanarayanan BLANK(); 100b82fef82SJan Beulich OFFSET(BP_scratch, boot_params, scratch); 101de8cb458SDavid Howells OFFSET(BP_secure_boot, boot_params, secure_boot); 102b82fef82SJan Beulich OFFSET(BP_loadflags, boot_params, hdr.loadflags); 103b82fef82SJan Beulich OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch); 104b82fef82SJan Beulich OFFSET(BP_version, boot_params, hdr.version); 105b82fef82SJan Beulich OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment); 106974f221cSYinghai Lu OFFSET(BP_init_size, boot_params, hdr.init_size); 107291f3632SMatt Fleming OFFSET(BP_pref_address, boot_params, hdr.pref_address); 1086783eaa2SAl Viro 1096783eaa2SAl Viro BLANK(); 1106783eaa2SAl Viro DEFINE(PTREGS_SIZE, sizeof(struct pt_regs)); 1111a79797bSAndy Lutomirski 1126fd166aaSPeter Zijlstra /* TLB state for the entry code */ 1136fd166aaSPeter Zijlstra OFFSET(TLB_STATE_user_pcid_flush_mask, tlb_state, user_pcid_flush_mask); 1146fd166aaSPeter Zijlstra 11572f5e08dSAndy Lutomirski /* Layout info for cpu_entry_area */ 1164fe2d8b1SDave Hansen OFFSET(CPU_ENTRY_AREA_entry_stack, cpu_entry_area, entry_stack_page); 1174fe2d8b1SDave Hansen DEFINE(SIZEOF_entry_stack, sizeof(struct entry_stack)); 11845d7b255SJoerg Roedel DEFINE(MASK_entry_stack, (~(sizeof(struct entry_stack) - 1))); 1199e97b73fSJoerg Roedel 12098f05b51SAndy Lutomirski /* Offset for fields in tss_struct */ 1219e97b73fSJoerg Roedel OFFSET(TSS_sp0, tss_struct, x86_tss.sp0); 1229e97b73fSJoerg Roedel OFFSET(TSS_sp1, tss_struct, x86_tss.sp1); 12398f05b51SAndy Lutomirski OFFSET(TSS_sp2, tss_struct, x86_tss.sp2); 124c063a217SThomas Gleixner OFFSET(X86_top_of_stack, pcpu_hot, top_of_stack); 1253adee777SBrian Gerst OFFSET(X86_current_task, pcpu_hot, current_task); 1265d821386SThomas Gleixner #ifdef CONFIG_CALL_DEPTH_TRACKING 1275d821386SThomas Gleixner OFFSET(X86_call_depth, pcpu_hot, call_depth); 1285d821386SThomas Gleixner #endif 12935344cf3STaehee Yoo #if IS_ENABLED(CONFIG_CRYPTO_ARIA_AESNI_AVX_X86_64) 13035344cf3STaehee Yoo /* Offset for fields in aria_ctx */ 13135344cf3STaehee Yoo BLANK(); 13235344cf3STaehee Yoo OFFSET(ARIA_CTX_enc_key, aria_ctx, enc_key); 13335344cf3STaehee Yoo OFFSET(ARIA_CTX_dec_key, aria_ctx, dec_key); 13435344cf3STaehee Yoo OFFSET(ARIA_CTX_rounds, aria_ctx, rounds); 13535344cf3STaehee Yoo #endif 136c063a217SThomas Gleixner 137b82fef82SJan Beulich } 138