Skip to content

Commit

Permalink
KVM: x86: nSVM: skip eax alignment check for non-SVM instructions
Browse files Browse the repository at this point in the history
The bug occurs on #GP triggered by VMware backdoor when eax value is
unaligned. eax alignment check should not be applied to non-SVM
instructions because it leads to incorrect omission of the instructions
emulation.
Apply the alignment check only to SVM instructions to fix.

Fixes: d1cba6c ("KVM: x86: nSVM: test eax for 4K alignment for GP errata workaround")
Signed-off-by: Denis Valeev <lemniscattaden@gmail.com>
Message-Id: <Yexlhaoe1Fscm59u@q>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Denis Valeev authored and Paolo Bonzini committed Jan 26, 2022
1 parent 1ffce09 commit 47c28d4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions arch/x86/kvm/svm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2091,10 +2091,6 @@ static int gp_interception(struct kvm_vcpu *vcpu)
if (error_code)
goto reinject;

/* All SVM instructions expect page aligned RAX */
if (svm->vmcb->save.rax & ~PAGE_MASK)
goto reinject;

/* Decode the instruction for usage later */
if (x86_decode_emulated_instruction(vcpu, 0, NULL, 0) != EMULATION_OK)
goto reinject;
Expand All @@ -2112,8 +2108,13 @@ static int gp_interception(struct kvm_vcpu *vcpu)
if (!is_guest_mode(vcpu))
return kvm_emulate_instruction(vcpu,
EMULTYPE_VMWARE_GP | EMULTYPE_NO_DECODE);
} else
} else {
/* All SVM instructions expect page aligned RAX */
if (svm->vmcb->save.rax & ~PAGE_MASK)
goto reinject;

return emulate_svm_instr(vcpu, opcode);
}

reinject:
kvm_queue_exception_e(vcpu, GP_VECTOR, error_code);
Expand Down

0 comments on commit 47c28d4

Please sign in to comment.