forked from Minki/linux
KVM: SVM: replace regs argument of __svm_vcpu_run() with vcpu_svm
Since registers are reachable through vcpu_svm, and we will
need to access more fields of that struct, pass it instead
of the regs[] array.
No functional change intended.
Cc: stable@vger.kernel.org
Fixes: a149180fbc
("x86: Add magic AMD return-thunk")
Reviewed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
debc5a1ec0
commit
16fdc1de16
@ -35,6 +35,9 @@ obj-$(CONFIG_KVM) += kvm.o
|
||||
obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
|
||||
obj-$(CONFIG_KVM_AMD) += kvm-amd.o
|
||||
|
||||
AFLAGS_svm/vmenter.o := -iquote $(obj)
|
||||
$(obj)/svm/vmenter.o: $(obj)/kvm-asm-offsets.h
|
||||
|
||||
AFLAGS_vmx/vmenter.o := -iquote $(obj)
|
||||
$(obj)/vmx/vmenter.o: $(obj)/kvm-asm-offsets.h
|
||||
|
||||
|
@ -8,9 +8,15 @@
|
||||
|
||||
#include <linux/kbuild.h>
|
||||
#include "vmx/vmx.h"
|
||||
#include "svm/svm.h"
|
||||
|
||||
static void __used common(void)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_KVM_AMD)) {
|
||||
BLANK();
|
||||
OFFSET(SVM_vcpu_arch_regs, vcpu_svm, vcpu.arch.regs);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_KVM_INTEL)) {
|
||||
BLANK();
|
||||
OFFSET(VMX_spec_ctrl, vcpu_vmx, spec_ctrl);
|
||||
|
@ -3930,7 +3930,7 @@ static noinstr void svm_vcpu_enter_exit(struct kvm_vcpu *vcpu)
|
||||
* vmcb02 when switching vmcbs for nested virtualization.
|
||||
*/
|
||||
vmload(svm->vmcb01.pa);
|
||||
__svm_vcpu_run(vmcb_pa, (unsigned long *)&vcpu->arch.regs);
|
||||
__svm_vcpu_run(vmcb_pa, svm);
|
||||
vmsave(svm->vmcb01.pa);
|
||||
|
||||
vmload(__sme_page_pa(sd->save_area));
|
||||
|
@ -684,6 +684,6 @@ void sev_es_unmap_ghcb(struct vcpu_svm *svm);
|
||||
/* vmenter.S */
|
||||
|
||||
void __svm_sev_es_vcpu_run(unsigned long vmcb_pa);
|
||||
void __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);
|
||||
void __svm_vcpu_run(unsigned long vmcb_pa, struct vcpu_svm *svm);
|
||||
|
||||
#endif
|
||||
|
@ -4,27 +4,28 @@
|
||||
#include <asm/bitsperlong.h>
|
||||
#include <asm/kvm_vcpu_regs.h>
|
||||
#include <asm/nospec-branch.h>
|
||||
#include "kvm-asm-offsets.h"
|
||||
|
||||
#define WORD_SIZE (BITS_PER_LONG / 8)
|
||||
|
||||
/* Intentionally omit RAX as it's context switched by hardware */
|
||||
#define VCPU_RCX __VCPU_REGS_RCX * WORD_SIZE
|
||||
#define VCPU_RDX __VCPU_REGS_RDX * WORD_SIZE
|
||||
#define VCPU_RBX __VCPU_REGS_RBX * WORD_SIZE
|
||||
#define VCPU_RCX (SVM_vcpu_arch_regs + __VCPU_REGS_RCX * WORD_SIZE)
|
||||
#define VCPU_RDX (SVM_vcpu_arch_regs + __VCPU_REGS_RDX * WORD_SIZE)
|
||||
#define VCPU_RBX (SVM_vcpu_arch_regs + __VCPU_REGS_RBX * WORD_SIZE)
|
||||
/* Intentionally omit RSP as it's context switched by hardware */
|
||||
#define VCPU_RBP __VCPU_REGS_RBP * WORD_SIZE
|
||||
#define VCPU_RSI __VCPU_REGS_RSI * WORD_SIZE
|
||||
#define VCPU_RDI __VCPU_REGS_RDI * WORD_SIZE
|
||||
#define VCPU_RBP (SVM_vcpu_arch_regs + __VCPU_REGS_RBP * WORD_SIZE)
|
||||
#define VCPU_RSI (SVM_vcpu_arch_regs + __VCPU_REGS_RSI * WORD_SIZE)
|
||||
#define VCPU_RDI (SVM_vcpu_arch_regs + __VCPU_REGS_RDI * WORD_SIZE)
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
#define VCPU_R8 __VCPU_REGS_R8 * WORD_SIZE
|
||||
#define VCPU_R9 __VCPU_REGS_R9 * WORD_SIZE
|
||||
#define VCPU_R10 __VCPU_REGS_R10 * WORD_SIZE
|
||||
#define VCPU_R11 __VCPU_REGS_R11 * WORD_SIZE
|
||||
#define VCPU_R12 __VCPU_REGS_R12 * WORD_SIZE
|
||||
#define VCPU_R13 __VCPU_REGS_R13 * WORD_SIZE
|
||||
#define VCPU_R14 __VCPU_REGS_R14 * WORD_SIZE
|
||||
#define VCPU_R15 __VCPU_REGS_R15 * WORD_SIZE
|
||||
#define VCPU_R8 (SVM_vcpu_arch_regs + __VCPU_REGS_R8 * WORD_SIZE)
|
||||
#define VCPU_R9 (SVM_vcpu_arch_regs + __VCPU_REGS_R9 * WORD_SIZE)
|
||||
#define VCPU_R10 (SVM_vcpu_arch_regs + __VCPU_REGS_R10 * WORD_SIZE)
|
||||
#define VCPU_R11 (SVM_vcpu_arch_regs + __VCPU_REGS_R11 * WORD_SIZE)
|
||||
#define VCPU_R12 (SVM_vcpu_arch_regs + __VCPU_REGS_R12 * WORD_SIZE)
|
||||
#define VCPU_R13 (SVM_vcpu_arch_regs + __VCPU_REGS_R13 * WORD_SIZE)
|
||||
#define VCPU_R14 (SVM_vcpu_arch_regs + __VCPU_REGS_R14 * WORD_SIZE)
|
||||
#define VCPU_R15 (SVM_vcpu_arch_regs + __VCPU_REGS_R15 * WORD_SIZE)
|
||||
#endif
|
||||
|
||||
.section .noinstr.text, "ax"
|
||||
@ -32,7 +33,7 @@
|
||||
/**
|
||||
* __svm_vcpu_run - Run a vCPU via a transition to SVM guest mode
|
||||
* @vmcb_pa: unsigned long
|
||||
* @regs: unsigned long * (to guest registers)
|
||||
* @svm: struct vcpu_svm *
|
||||
*/
|
||||
SYM_FUNC_START(__svm_vcpu_run)
|
||||
push %_ASM_BP
|
||||
@ -47,13 +48,13 @@ SYM_FUNC_START(__svm_vcpu_run)
|
||||
#endif
|
||||
push %_ASM_BX
|
||||
|
||||
/* Save @regs. */
|
||||
/* Save @svm. */
|
||||
push %_ASM_ARG2
|
||||
|
||||
/* Save @vmcb. */
|
||||
push %_ASM_ARG1
|
||||
|
||||
/* Move @regs to RAX. */
|
||||
/* Move @svm to RAX. */
|
||||
mov %_ASM_ARG2, %_ASM_AX
|
||||
|
||||
/* Load guest registers. */
|
||||
@ -89,7 +90,7 @@ SYM_FUNC_START(__svm_vcpu_run)
|
||||
FILL_RETURN_BUFFER %_ASM_AX, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE
|
||||
#endif
|
||||
|
||||
/* "POP" @regs to RAX. */
|
||||
/* "POP" @svm to RAX. */
|
||||
pop %_ASM_AX
|
||||
|
||||
/* Save all guest registers. */
|
||||
|
Loading…
Reference in New Issue
Block a user