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)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 31 Jan 2022 02:42:59 +0000 (13:42 +1100)
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
arch/powerpc/kvm/powerpc.c

index 50414fb2a5eaa957c86821d5a3c9d6a662fadebb..c2bd29e903140bd8d0884a9e70ce86034dfb12f7 100644 (file)
@@ -1499,7 +1499,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) {
@@ -1596,7 +1596,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;