]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - arch/x86/kernel/asm-offsets.c
KVM: VMX: Prevent RSB underflow before vmenter
[mirror_ubuntu-jammy-kernel.git] / arch / x86 / kernel / asm-offsets.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
b82fef82
JB
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>
6fd166aa 20#include <asm/tlbflush.h>
85561a53 21#include "../kvm/vmx/vmx.h"
b82fef82
JB
22
23#ifdef CONFIG_XEN
24#include <xen/interface/xen.h>
25#endif
26
8d0d37cf
TG
27#ifdef CONFIG_X86_32
28# include "asm-offsets_32.c"
29#else
30# include "asm-offsets_64.c"
6db7016d 31#endif
b82fef82 32
ad3bc25a
BP
33static void __used common(void)
34{
0100301b
BG
35 BLANK();
36 OFFSET(TASK_threadsp, task_struct, thread.sp);
050e9baa 37#ifdef CONFIG_STACKPROTECTOR
0100301b
BG
38 OFFSET(TASK_stack_canary, task_struct, stack_canary);
39#endif
40
b82fef82
JB
41 BLANK();
42 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
43
44 BLANK();
45 OFFSET(pbe_address, pbe, address);
46 OFFSET(pbe_orig_address, pbe, orig_address);
47 OFFSET(pbe_next, pbe, next);
48
4d178f94
BG
49#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
50 BLANK();
8fcb346b
IM
51 OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax);
52 OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx);
53 OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx);
54 OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx);
55 OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si);
56 OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di);
57 OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
58 OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
59 OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
4d178f94 60
4d178f94
BG
61 BLANK();
62 OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
63#endif
64
b82fef82
JB
65#ifdef CONFIG_XEN
66 BLANK();
67 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
68 OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
55aedddb 69 OFFSET(XEN_vcpu_info_arch_cr2, vcpu_info, arch.cr2);
b82fef82
JB
70#endif
71
72 BLANK();
73 OFFSET(BP_scratch, boot_params, scratch);
de8cb458 74 OFFSET(BP_secure_boot, boot_params, secure_boot);
b82fef82
JB
75 OFFSET(BP_loadflags, boot_params, hdr.loadflags);
76 OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
77 OFFSET(BP_version, boot_params, hdr.version);
78 OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
974f221c 79 OFFSET(BP_init_size, boot_params, hdr.init_size);
291f3632 80 OFFSET(BP_pref_address, boot_params, hdr.pref_address);
6783eaa2
AV
81
82 BLANK();
83 DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
1a79797b 84
6fd166aa
PZ
85 /* TLB state for the entry code */
86 OFFSET(TLB_STATE_user_pcid_flush_mask, tlb_state, user_pcid_flush_mask);
87
72f5e08d 88 /* Layout info for cpu_entry_area */
4fe2d8b1
DH
89 OFFSET(CPU_ENTRY_AREA_entry_stack, cpu_entry_area, entry_stack_page);
90 DEFINE(SIZEOF_entry_stack, sizeof(struct entry_stack));
45d7b255 91 DEFINE(MASK_entry_stack, (~(sizeof(struct entry_stack) - 1)));
9e97b73f 92
98f05b51 93 /* Offset for fields in tss_struct */
9e97b73f
JR
94 OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
95 OFFSET(TSS_sp1, tss_struct, x86_tss.sp1);
98f05b51 96 OFFSET(TSS_sp2, tss_struct, x86_tss.sp2);
85561a53
JP
97
98 if (IS_ENABLED(CONFIG_KVM_INTEL)) {
99 BLANK();
100 OFFSET(VMX_spec_ctrl, vcpu_vmx, spec_ctrl);
101 }
b82fef82 102}