KVM: PPC: Fix vmx/vsx mixup in mmio emulation
authorFabiano Rosas <farosas@linux.ibm.com>
Tue, 25 Jan 2022 21:56:52 +0000 (18:56 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:23:26 +0000 (14:23 +0200)
[ Upstream commit b99234b918c6e36b9aa0a5b2981e86b6bd11f8e2 ]

The MMIO emulation code for vector instructions is duplicated between
VSX and VMX. When emulating VMX we should check the VMX copy size
instead of the VSX one.

Fixes: acc9eb9305fe ("KVM: PPC: Reimplement LOAD_VMX/STORE_VMX instruction ...")
Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220125215655.1026224-3-farosas@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/kvm/powerpc.c

index b4e6f70b97b940e14faa5f7e27a68cee792613e5..ee305455bd8db41bba8da4520d04fc187e705f5c 100644 (file)
@@ -1507,7 +1507,7 @@ int kvmppc_handle_vmx_load(struct kvm_vcpu *vcpu,
 {
        enum emulation_result emulated = EMULATE_DONE;
 
-       if (vcpu->arch.mmio_vsx_copy_nums > 2)
+       if (vcpu->arch.mmio_vmx_copy_nums > 2)
                return EMULATE_FAIL;
 
        while (vcpu->arch.mmio_vmx_copy_nums) {
@@ -1604,7 +1604,7 @@ int kvmppc_handle_vmx_store(struct kvm_vcpu *vcpu,
        unsigned int index = rs & KVM_MMIO_REG_MASK;
        enum emulation_result emulated = EMULATE_DONE;
 
-       if (vcpu->arch.mmio_vsx_copy_nums > 2)
+       if (vcpu->arch.mmio_vmx_copy_nums > 2)
                return EMULATE_FAIL;
 
        vcpu->arch.io_gpr = rs;