xref: /linux/arch/x86/kernel/asm-offsets.c (revision fada1935590f66dc6784981e0d557ca09013c847)
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 
21 #ifdef CONFIG_XEN
22 #include <xen/interface/xen.h>
23 #endif
24 
25 #ifdef CONFIG_X86_32
26 # include "asm-offsets_32.c"
27 #else
28 # include "asm-offsets_64.c"
29 #endif
30 
31 void common(void) {
32 	BLANK();
33 	OFFSET(TASK_threadsp, task_struct, thread.sp);
34 #ifdef CONFIG_CC_STACKPROTECTOR
35 	OFFSET(TASK_stack_canary, task_struct, stack_canary);
36 #endif
37 
38 	BLANK();
39 	OFFSET(TASK_TI_flags, task_struct, thread_info.flags);
40 	OFFSET(TASK_addr_limit, task_struct, thread.addr_limit);
41 
42 	BLANK();
43 	OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
44 
45 	BLANK();
46 	OFFSET(pbe_address, pbe, address);
47 	OFFSET(pbe_orig_address, pbe, orig_address);
48 	OFFSET(pbe_next, pbe, next);
49 
50 #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
51 	BLANK();
52 	OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax);
53 	OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx);
54 	OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx);
55 	OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx);
56 	OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si);
57 	OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di);
58 	OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
59 	OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
60 	OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
61 
62 	BLANK();
63 	OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
64 #endif
65 
66 #ifdef CONFIG_PARAVIRT
67 	BLANK();
68 	OFFSET(PARAVIRT_PATCH_pv_cpu_ops, paravirt_patch_template, pv_cpu_ops);
69 	OFFSET(PARAVIRT_PATCH_pv_irq_ops, paravirt_patch_template, pv_irq_ops);
70 	OFFSET(PV_IRQ_irq_disable, pv_irq_ops, irq_disable);
71 	OFFSET(PV_IRQ_irq_enable, pv_irq_ops, irq_enable);
72 	OFFSET(PV_CPU_iret, pv_cpu_ops, iret);
73 	OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
74 	OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
75 #endif
76 
77 #ifdef CONFIG_XEN
78 	BLANK();
79 	OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
80 	OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
81 #endif
82 
83 	BLANK();
84 	OFFSET(BP_scratch, boot_params, scratch);
85 	OFFSET(BP_secure_boot, boot_params, secure_boot);
86 	OFFSET(BP_loadflags, boot_params, hdr.loadflags);
87 	OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
88 	OFFSET(BP_version, boot_params, hdr.version);
89 	OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
90 	OFFSET(BP_init_size, boot_params, hdr.init_size);
91 	OFFSET(BP_pref_address, boot_params, hdr.pref_address);
92 	OFFSET(BP_code32_start, boot_params, hdr.code32_start);
93 
94 	BLANK();
95 	DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
96 }
97