vmenter.S (9756bba28470722dacb79ffce554336dd1f6a6cd) vmenter.S (07853adc29a058c5fd143c14e5ac528448a72ed9)
1/* SPDX-License-Identifier: GPL-2.0 */
2#include <linux/linkage.h>
3#include <asm/asm.h>
1/* SPDX-License-Identifier: GPL-2.0 */
2#include <linux/linkage.h>
3#include <asm/asm.h>
4#include <asm/asm-offsets.h>
4#include <asm/bitsperlong.h>
5#include <asm/kvm_vcpu_regs.h>
6#include <asm/nospec-branch.h>
5#include <asm/bitsperlong.h>
6#include <asm/kvm_vcpu_regs.h>
7#include <asm/nospec-branch.h>
8#include <asm/percpu.h>
7#include <asm/segment.h>
8#include "run_flags.h"
9
10#define WORD_SIZE (BITS_PER_LONG / 8)
11
12#define VCPU_RAX __VCPU_REGS_RAX * WORD_SIZE
13#define VCPU_RCX __VCPU_REGS_RCX * WORD_SIZE
14#define VCPU_RDX __VCPU_REGS_RDX * WORD_SIZE

--- 53 unchanged lines hidden (view full) ---

68 push %_ASM_ARG2
69
70 /* Copy @flags to BL, _ASM_ARG3 is volatile. */
71 mov %_ASM_ARG3B, %bl
72
73 lea (%_ASM_SP), %_ASM_ARG2
74 call vmx_update_host_rsp
75
9#include <asm/segment.h>
10#include "run_flags.h"
11
12#define WORD_SIZE (BITS_PER_LONG / 8)
13
14#define VCPU_RAX __VCPU_REGS_RAX * WORD_SIZE
15#define VCPU_RCX __VCPU_REGS_RCX * WORD_SIZE
16#define VCPU_RDX __VCPU_REGS_RDX * WORD_SIZE

--- 53 unchanged lines hidden (view full) ---

70 push %_ASM_ARG2
71
72 /* Copy @flags to BL, _ASM_ARG3 is volatile. */
73 mov %_ASM_ARG3B, %bl
74
75 lea (%_ASM_SP), %_ASM_ARG2
76 call vmx_update_host_rsp
77
78 ALTERNATIVE "jmp .Lspec_ctrl_done", "", X86_FEATURE_MSR_SPEC_CTRL
79
80 /*
81 * SPEC_CTRL handling: if the guest's SPEC_CTRL value differs from the
82 * host's, write the MSR.
83 *
84 * IMPORTANT: To avoid RSB underflow attacks and any other nastiness,
85 * there must not be any returns or indirect branches between this code
86 * and vmentry.
87 */
88 mov 2*WORD_SIZE(%_ASM_SP), %_ASM_DI
89 movl VMX_spec_ctrl(%_ASM_DI), %edi
90 movl PER_CPU_VAR(x86_spec_ctrl_current), %esi
91 cmp %edi, %esi
92 je .Lspec_ctrl_done
93 mov $MSR_IA32_SPEC_CTRL, %ecx
94 xor %edx, %edx
95 mov %edi, %eax
96 wrmsr
97
98.Lspec_ctrl_done:
99
100 /*
101 * Since vmentry is serializing on affected CPUs, there's no need for
102 * an LFENCE to stop speculation from skipping the wrmsr.
103 */
104
76 /* Load @regs to RAX. */
77 mov (%_ASM_SP), %_ASM_AX
78
79 /* Check if vmlaunch or vmresume is needed */
80 testb $VMX_RUN_VMRESUME, %bl
81
82 /* Load guest registers. Don't clobber flags. */
83 mov VCPU_RCX(%_ASM_AX), %_ASM_CX

--- 248 unchanged lines hidden ---
105 /* Load @regs to RAX. */
106 mov (%_ASM_SP), %_ASM_AX
107
108 /* Check if vmlaunch or vmresume is needed */
109 testb $VMX_RUN_VMRESUME, %bl
110
111 /* Load guest registers. Don't clobber flags. */
112 mov VCPU_RCX(%_ASM_AX), %_ASM_CX

--- 248 unchanged lines hidden ---