xref: /linux/arch/x86/kernel/asm-offsets.c (revision 55aedddb6149ab71bec9f050846855113977b033)
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>
21b82fef82SJan Beulich 
22b82fef82SJan Beulich #ifdef CONFIG_XEN
23b82fef82SJan Beulich #include <xen/interface/xen.h>
24b82fef82SJan Beulich #endif
25b82fef82SJan Beulich 
269a163ed8SThomas Gleixner #ifdef CONFIG_X86_32
279a163ed8SThomas Gleixner # include "asm-offsets_32.c"
289a163ed8SThomas Gleixner #else
299a163ed8SThomas Gleixner # include "asm-offsets_64.c"
309a163ed8SThomas Gleixner #endif
31b82fef82SJan Beulich 
32ad3bc25aSBorislav Petkov static void __used common(void)
33ad3bc25aSBorislav Petkov {
34b82fef82SJan Beulich 	BLANK();
350100301bSBrian Gerst 	OFFSET(TASK_threadsp, task_struct, thread.sp);
36050e9baaSLinus Torvalds #ifdef CONFIG_STACKPROTECTOR
370100301bSBrian Gerst 	OFFSET(TASK_stack_canary, task_struct, stack_canary);
380100301bSBrian Gerst #endif
390100301bSBrian Gerst 
400100301bSBrian Gerst 	BLANK();
4113d4ea09SAndy Lutomirski 	OFFSET(TASK_addr_limit, task_struct, thread.addr_limit);
42b82fef82SJan Beulich 
43b82fef82SJan Beulich 	BLANK();
44b82fef82SJan Beulich 	OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
45b82fef82SJan Beulich 
46b82fef82SJan Beulich 	BLANK();
47b82fef82SJan Beulich 	OFFSET(pbe_address, pbe, address);
48b82fef82SJan Beulich 	OFFSET(pbe_orig_address, pbe, orig_address);
49b82fef82SJan Beulich 	OFFSET(pbe_next, pbe, next);
50b82fef82SJan Beulich 
514d178f94SBrian Gerst #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
524d178f94SBrian Gerst 	BLANK();
538fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax);
548fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx);
558fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx);
568fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx);
578fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si);
588fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di);
598fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
608fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
618fcb346bSIngo Molnar 	OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
624d178f94SBrian Gerst 
634d178f94SBrian Gerst 	BLANK();
644d178f94SBrian Gerst 	OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
654d178f94SBrian Gerst #endif
664d178f94SBrian Gerst 
676da63eb2SJuergen Gross #ifdef CONFIG_PARAVIRT_XXL
68fdc0269eSJuergen Gross 	BLANK();
695c83511bSJuergen Gross 	OFFSET(PV_IRQ_irq_disable, paravirt_patch_template, irq.irq_disable);
705c83511bSJuergen Gross 	OFFSET(PV_IRQ_irq_enable, paravirt_patch_template, irq.irq_enable);
715c83511bSJuergen Gross 	OFFSET(PV_CPU_iret, paravirt_patch_template, cpu.iret);
725c83511bSJuergen Gross 	OFFSET(PV_MMU_read_cr2, paravirt_patch_template, mmu.read_cr2);
73b82fef82SJan Beulich #endif
74b82fef82SJan Beulich 
75b82fef82SJan Beulich #ifdef CONFIG_XEN
76b82fef82SJan Beulich 	BLANK();
77b82fef82SJan Beulich 	OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
78b82fef82SJan Beulich 	OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
79*55aedddbSPeter Zijlstra 	OFFSET(XEN_vcpu_info_arch_cr2, vcpu_info, arch.cr2);
80b82fef82SJan Beulich #endif
81b82fef82SJan Beulich 
82b82fef82SJan Beulich 	BLANK();
83b82fef82SJan Beulich 	OFFSET(BP_scratch, boot_params, scratch);
84de8cb458SDavid Howells 	OFFSET(BP_secure_boot, boot_params, secure_boot);
85b82fef82SJan Beulich 	OFFSET(BP_loadflags, boot_params, hdr.loadflags);
86b82fef82SJan Beulich 	OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
87b82fef82SJan Beulich 	OFFSET(BP_version, boot_params, hdr.version);
88b82fef82SJan Beulich 	OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
89974f221cSYinghai Lu 	OFFSET(BP_init_size, boot_params, hdr.init_size);
90291f3632SMatt Fleming 	OFFSET(BP_pref_address, boot_params, hdr.pref_address);
91291f3632SMatt Fleming 	OFFSET(BP_code32_start, boot_params, hdr.code32_start);
926783eaa2SAl Viro 
936783eaa2SAl Viro 	BLANK();
946783eaa2SAl Viro 	DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
951a79797bSAndy Lutomirski 
966fd166aaSPeter Zijlstra 	/* TLB state for the entry code */
976fd166aaSPeter Zijlstra 	OFFSET(TLB_STATE_user_pcid_flush_mask, tlb_state, user_pcid_flush_mask);
986fd166aaSPeter Zijlstra 
9972f5e08dSAndy Lutomirski 	/* Layout info for cpu_entry_area */
1004fe2d8b1SDave Hansen 	OFFSET(CPU_ENTRY_AREA_entry_stack, cpu_entry_area, entry_stack_page);
1014fe2d8b1SDave Hansen 	DEFINE(SIZEOF_entry_stack, sizeof(struct entry_stack));
10245d7b255SJoerg Roedel 	DEFINE(MASK_entry_stack, (~(sizeof(struct entry_stack) - 1)));
1039e97b73fSJoerg Roedel 
10498f05b51SAndy Lutomirski 	/* Offset for fields in tss_struct */
1059e97b73fSJoerg Roedel 	OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
1069e97b73fSJoerg Roedel 	OFFSET(TSS_sp1, tss_struct, x86_tss.sp1);
10798f05b51SAndy Lutomirski 	OFFSET(TSS_sp2, tss_struct, x86_tss.sp2);
108b82fef82SJan Beulich }
109