xref: /linux/arch/x86/kernel/asm-offsets.c (revision 0da908c291070d89482f6211dbe81d4d43c3f7cb)
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>
10b82fef82SJan Beulich #include <linux/sched.h>
11b82fef82SJan Beulich #include <linux/stddef.h>
12b82fef82SJan Beulich #include <linux/hardirq.h>
13b82fef82SJan Beulich #include <linux/suspend.h>
14b82fef82SJan Beulich #include <linux/kbuild.h>
15b82fef82SJan Beulich #include <asm/processor.h>
16b82fef82SJan Beulich #include <asm/thread_info.h>
17b82fef82SJan Beulich #include <asm/sigframe.h>
18b82fef82SJan Beulich #include <asm/bootparam.h>
19b82fef82SJan Beulich #include <asm/suspend.h>
206fd166aaSPeter Zijlstra #include <asm/tlbflush.h>
21527a534cSKirill A. Shutemov #include <asm/tdx.h>
22b82fef82SJan Beulich 
23b82fef82SJan Beulich #ifdef CONFIG_XEN
24b82fef82SJan Beulich #include <xen/interface/xen.h>
25b82fef82SJan Beulich #endif
26b82fef82SJan Beulich 
279a163ed8SThomas Gleixner #ifdef CONFIG_X86_32
289a163ed8SThomas Gleixner # include "asm-offsets_32.c"
299a163ed8SThomas Gleixner #else
309a163ed8SThomas Gleixner # include "asm-offsets_64.c"
319a163ed8SThomas Gleixner #endif
32b82fef82SJan Beulich 
33ad3bc25aSBorislav Petkov static void __used common(void)
34ad3bc25aSBorislav Petkov {
35b82fef82SJan Beulich 	BLANK();
360100301bSBrian Gerst 	OFFSET(TASK_threadsp, task_struct, thread.sp);
37050e9baaSLinus Torvalds #ifdef CONFIG_STACKPROTECTOR
380100301bSBrian Gerst 	OFFSET(TASK_stack_canary, task_struct, stack_canary);
390100301bSBrian Gerst #endif
400100301bSBrian Gerst 
410100301bSBrian Gerst 	BLANK();
42b82fef82SJan Beulich 	OFFSET(pbe_address, pbe, address);
43b82fef82SJan Beulich 	OFFSET(pbe_orig_address, pbe, orig_address);
44b82fef82SJan Beulich 	OFFSET(pbe_next, pbe, next);
45b82fef82SJan Beulich 
464d178f94SBrian Gerst #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
474d178f94SBrian Gerst 	BLANK();
488fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax);
498fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx);
508fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx);
518fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx);
528fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si);
538fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di);
548fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
558fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
568fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
574d178f94SBrian Gerst 
584d178f94SBrian Gerst 	BLANK();
594d178f94SBrian Gerst 	OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
604d178f94SBrian Gerst #endif
614d178f94SBrian Gerst 
62b82fef82SJan Beulich #ifdef CONFIG_XEN
63b82fef82SJan Beulich 	BLANK();
64b82fef82SJan Beulich 	OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
65b82fef82SJan Beulich 	OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
6655aedddbSPeter Zijlstra 	OFFSET(XEN_vcpu_info_arch_cr2, vcpu_info, arch.cr2);
67b82fef82SJan Beulich #endif
68b82fef82SJan Beulich 
69b82fef82SJan Beulich 	BLANK();
70527a534cSKirill A. Shutemov 	OFFSET(TDX_MODULE_rcx, tdx_module_output, rcx);
71527a534cSKirill A. Shutemov 	OFFSET(TDX_MODULE_rdx, tdx_module_output, rdx);
72527a534cSKirill A. Shutemov 	OFFSET(TDX_MODULE_r8,  tdx_module_output, r8);
73527a534cSKirill A. Shutemov 	OFFSET(TDX_MODULE_r9,  tdx_module_output, r9);
74527a534cSKirill A. Shutemov 	OFFSET(TDX_MODULE_r10, tdx_module_output, r10);
75527a534cSKirill A. Shutemov 	OFFSET(TDX_MODULE_r11, tdx_module_output, r11);
76527a534cSKirill A. Shutemov 
77527a534cSKirill A. Shutemov 	BLANK();
78*0da908c2SKirill A. Shutemov 	OFFSET(TDX_HYPERCALL_r8,  tdx_hypercall_args, r8);
79*0da908c2SKirill A. Shutemov 	OFFSET(TDX_HYPERCALL_r9,  tdx_hypercall_args, r9);
80eb94f1b6SKuppuswamy Sathyanarayanan 	OFFSET(TDX_HYPERCALL_r10, tdx_hypercall_args, r10);
81eb94f1b6SKuppuswamy Sathyanarayanan 	OFFSET(TDX_HYPERCALL_r11, tdx_hypercall_args, r11);
82eb94f1b6SKuppuswamy Sathyanarayanan 	OFFSET(TDX_HYPERCALL_r12, tdx_hypercall_args, r12);
83eb94f1b6SKuppuswamy Sathyanarayanan 	OFFSET(TDX_HYPERCALL_r13, tdx_hypercall_args, r13);
84eb94f1b6SKuppuswamy Sathyanarayanan 	OFFSET(TDX_HYPERCALL_r14, tdx_hypercall_args, r14);
85eb94f1b6SKuppuswamy Sathyanarayanan 	OFFSET(TDX_HYPERCALL_r15, tdx_hypercall_args, r15);
86*0da908c2SKirill A. Shutemov 	OFFSET(TDX_HYPERCALL_rdi, tdx_hypercall_args, rdi);
87*0da908c2SKirill A. Shutemov 	OFFSET(TDX_HYPERCALL_rsi, tdx_hypercall_args, rsi);
88*0da908c2SKirill A. Shutemov 	OFFSET(TDX_HYPERCALL_rbx, tdx_hypercall_args, rbx);
89*0da908c2SKirill A. Shutemov 	OFFSET(TDX_HYPERCALL_rdx, tdx_hypercall_args, rdx);
90eb94f1b6SKuppuswamy Sathyanarayanan 
91eb94f1b6SKuppuswamy Sathyanarayanan 	BLANK();
92b82fef82SJan Beulich 	OFFSET(BP_scratch, boot_params, scratch);
93de8cb458SDavid Howells 	OFFSET(BP_secure_boot, boot_params, secure_boot);
94b82fef82SJan Beulich 	OFFSET(BP_loadflags, boot_params, hdr.loadflags);
95b82fef82SJan Beulich 	OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
96b82fef82SJan Beulich 	OFFSET(BP_version, boot_params, hdr.version);
97b82fef82SJan Beulich 	OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
98974f221cSYinghai Lu 	OFFSET(BP_init_size, boot_params, hdr.init_size);
99291f3632SMatt Fleming 	OFFSET(BP_pref_address, boot_params, hdr.pref_address);
1006783eaa2SAl Viro 
1016783eaa2SAl Viro 	BLANK();
1026783eaa2SAl Viro 	DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
1031a79797bSAndy Lutomirski 
1046fd166aaSPeter Zijlstra 	/* TLB state for the entry code */
1056fd166aaSPeter Zijlstra 	OFFSET(TLB_STATE_user_pcid_flush_mask, tlb_state, user_pcid_flush_mask);
1066fd166aaSPeter Zijlstra 
10772f5e08dSAndy Lutomirski 	/* Layout info for cpu_entry_area */
1084fe2d8b1SDave Hansen 	OFFSET(CPU_ENTRY_AREA_entry_stack, cpu_entry_area, entry_stack_page);
1094fe2d8b1SDave Hansen 	DEFINE(SIZEOF_entry_stack, sizeof(struct entry_stack));
11045d7b255SJoerg Roedel 	DEFINE(MASK_entry_stack, (~(sizeof(struct entry_stack) - 1)));
1119e97b73fSJoerg Roedel 
11298f05b51SAndy Lutomirski 	/* Offset for fields in tss_struct */
1139e97b73fSJoerg Roedel 	OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
1149e97b73fSJoerg Roedel 	OFFSET(TSS_sp1, tss_struct, x86_tss.sp1);
11598f05b51SAndy Lutomirski 	OFFSET(TSS_sp2, tss_struct, x86_tss.sp2);
116c063a217SThomas Gleixner 	OFFSET(X86_top_of_stack, pcpu_hot, top_of_stack);
1175d821386SThomas Gleixner #ifdef CONFIG_CALL_DEPTH_TRACKING
1185d821386SThomas Gleixner 	OFFSET(X86_call_depth, pcpu_hot, call_depth);
1195d821386SThomas Gleixner #endif
120c063a217SThomas Gleixner 
121b82fef82SJan Beulich }
122