KVM: s390: selftest: memop: Pass mop_desc via pointer
authorJanis Schoetterl-Glausch <scgl@linux.ibm.com>
Mon, 6 Feb 2023 16:45:49 +0000 (17:45 +0100)
committerJanosch Frank <frankja@linux.ibm.com>
Tue, 7 Feb 2023 17:05:59 +0000 (18:05 +0100)
The struct is quite large, so this seems nicer.

Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20230206164602.138068-2-scgl@linux.ibm.com
Message-Id: <20230206164602.138068-2-scgl@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
tools/testing/selftests/kvm/s390x/memop.c

index 3fd81e58f40c214bbd83e43ab71c0ebd319bf241..9c05d12051145de94abedc35239e07ef86367727 100644 (file)
@@ -48,53 +48,53 @@ struct mop_desc {
        uint8_t key;
 };
 
-static struct kvm_s390_mem_op ksmo_from_desc(struct mop_desc desc)
+static struct kvm_s390_mem_op ksmo_from_desc(const struct mop_desc *desc)
 {
        struct kvm_s390_mem_op ksmo = {
-               .gaddr = (uintptr_t)desc.gaddr,
-               .size = desc.size,
-               .buf = ((uintptr_t)desc.buf),
+               .gaddr = (uintptr_t)desc->gaddr,
+               .size = desc->size,
+               .buf = ((uintptr_t)desc->buf),
                .reserved = "ignored_ignored_ignored_ignored"
        };
 
-       switch (desc.target) {
+       switch (desc->target) {
        case LOGICAL:
-               if (desc.mode == READ)
+               if (desc->mode == READ)
                        ksmo.op = KVM_S390_MEMOP_LOGICAL_READ;
-               if (desc.mode == WRITE)
+               if (desc->mode == WRITE)
                        ksmo.op = KVM_S390_MEMOP_LOGICAL_WRITE;
                break;
        case SIDA:
-               if (desc.mode == READ)
+               if (desc->mode == READ)
                        ksmo.op = KVM_S390_MEMOP_SIDA_READ;
-               if (desc.mode == WRITE)
+               if (desc->mode == WRITE)
                        ksmo.op = KVM_S390_MEMOP_SIDA_WRITE;
                break;
        case ABSOLUTE:
-               if (desc.mode == READ)
+               if (desc->mode == READ)
                        ksmo.op = KVM_S390_MEMOP_ABSOLUTE_READ;
-               if (desc.mode == WRITE)
+               if (desc->mode == WRITE)
                        ksmo.op = KVM_S390_MEMOP_ABSOLUTE_WRITE;
                break;
        case INVALID:
                ksmo.op = -1;
        }
-       if (desc.f_check)
+       if (desc->f_check)
                ksmo.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
-       if (desc.f_inject)
+       if (desc->f_inject)
                ksmo.flags |= KVM_S390_MEMOP_F_INJECT_EXCEPTION;
-       if (desc._set_flags)
-               ksmo.flags = desc.set_flags;
-       if (desc.f_key) {
+       if (desc->_set_flags)
+               ksmo.flags = desc->set_flags;
+       if (desc->f_key) {
                ksmo.flags |= KVM_S390_MEMOP_F_SKEY_PROTECTION;
-               ksmo.key = desc.key;
+               ksmo.key = desc->key;
        }
-       if (desc._ar)
-               ksmo.ar = desc.ar;
+       if (desc->_ar)
+               ksmo.ar = desc->ar;
        else
                ksmo.ar = 0;
-       if (desc._sida_offset)
-               ksmo.sida_offset = desc.sida_offset;
+       if (desc->_sida_offset)
+               ksmo.sida_offset = desc->sida_offset;
 
        return ksmo;
 }
@@ -183,7 +183,7 @@ static int err_memop_ioctl(struct test_info info, struct kvm_s390_mem_op *ksmo)
                else                                                            \
                        __desc.gaddr = __desc.gaddr_v;                          \
        }                                                                       \
-       __ksmo = ksmo_from_desc(__desc);                                        \
+       __ksmo = ksmo_from_desc(&__desc);                                       \
        print_memop(__info.vcpu, &__ksmo);                                      \
        err##memop_ioctl(__info, &__ksmo);                                      \
 })