]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
KVM: x86: nSVM: test eax for 4K alignment for GP errata workaround
authorMaxim Levitsky <mlevitsk@redhat.com>
Tue, 14 Sep 2021 15:48:14 +0000 (18:48 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 23 Sep 2021 14:05:29 +0000 (10:05 -0400)
GP SVM errata workaround made the #GP handler always emulate
the SVM instructions.

However these instructions #GP in case the operand is not 4K aligned,
but the workaround code didn't check this and we ended up
emulating these instructions anyway.

This is only an emulation accuracy check bug as there is no harm for
KVM to read/write unaligned vmcb images.

Fixes: 82a11e9c6fa2 ("KVM: SVM: Add emulation support for #GP triggered by SVM instructions")
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20210914154825.104886-4-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/svm.c

index d674304d45a2cea1c60e6a399815f0e46c0c97c5..989685098b3ea7d62f251bd3b1ac39de7e2391c6 100644 (file)
@@ -2224,6 +2224,10 @@ 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;