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