xref: /openbmc/linux/arch/x86/kernel/asm-offsets_32.c (revision 59f2a619)
1 // SPDX-License-Identifier: GPL-2.0
2 #ifndef __LINUX_KBUILD_H
3 # error "Please do not build this file directly, build asm-offsets.c instead"
4 #endif
5 
6 #include <linux/efi.h>
7 
8 #include <asm/ucontext.h>
9 
10 #define __SYSCALL_I386(nr, sym, qual) [nr] = 1,
11 static char syscalls[] = {
12 #include <asm/syscalls_32.h>
13 };
14 
15 /* workaround for a warning with -Wmissing-prototypes */
16 void foo(void);
17 
18 void foo(void)
19 {
20 	OFFSET(CPUINFO_x86, cpuinfo_x86, x86);
21 	OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor);
22 	OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model);
23 	OFFSET(CPUINFO_x86_stepping, cpuinfo_x86, x86_stepping);
24 	OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level);
25 	OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability);
26 	OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id);
27 	BLANK();
28 
29 	OFFSET(PT_EBX, pt_regs, bx);
30 	OFFSET(PT_ECX, pt_regs, cx);
31 	OFFSET(PT_EDX, pt_regs, dx);
32 	OFFSET(PT_ESI, pt_regs, si);
33 	OFFSET(PT_EDI, pt_regs, di);
34 	OFFSET(PT_EBP, pt_regs, bp);
35 	OFFSET(PT_EAX, pt_regs, ax);
36 	OFFSET(PT_DS,  pt_regs, ds);
37 	OFFSET(PT_ES,  pt_regs, es);
38 	OFFSET(PT_FS,  pt_regs, fs);
39 	OFFSET(PT_GS,  pt_regs, gs);
40 	OFFSET(PT_ORIG_EAX, pt_regs, orig_ax);
41 	OFFSET(PT_EIP, pt_regs, ip);
42 	OFFSET(PT_CS,  pt_regs, cs);
43 	OFFSET(PT_EFLAGS, pt_regs, flags);
44 	OFFSET(PT_OLDESP, pt_regs, sp);
45 	OFFSET(PT_OLDSS,  pt_regs, ss);
46 	BLANK();
47 
48 	OFFSET(saved_context_gdt_desc, saved_context, gdt_desc);
49 	BLANK();
50 
51 	/*
52 	 * Offset from the entry stack to task stack stored in TSS. Kernel entry
53 	 * happens on the per-cpu entry-stack, and the asm code switches to the
54 	 * task-stack pointer stored in x86_tss.sp1, which is a copy of
55 	 * task->thread.sp0 where entry code can find it.
56 	 */
57 	DEFINE(TSS_entry2task_stack,
58 	       offsetof(struct cpu_entry_area, tss.x86_tss.sp1) -
59 	       offsetofend(struct cpu_entry_area, entry_stack_page.stack));
60 
61 #ifdef CONFIG_STACKPROTECTOR
62 	BLANK();
63 	OFFSET(stack_canary_offset, stack_canary, canary);
64 #endif
65 
66 	BLANK();
67 	DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
68 	DEFINE(NR_syscalls, sizeof(syscalls));
69 
70 	BLANK();
71 	DEFINE(EFI_svam, offsetof(efi_runtime_services_t, set_virtual_address_map));
72 }
73