aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/s390x/resets.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-06-01 11:01:58 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-11 11:48:09 -0400
commitfcba483e82462830dd368951c0df03a95676f34d (patch)
tree88f966add9f26acf511e2288c22690fbf5b7f767 /tools/testing/selftests/kvm/s390x/resets.c
parentKVM: selftests: Use TAP-friendly ksft_exit_skip() in __TEST_REQUIRE (diff)
downloadlinux-dev-fcba483e82462830dd368951c0df03a95676f34d.tar.xz
linux-dev-fcba483e82462830dd368951c0df03a95676f34d.zip
KVM: selftests: Sanity check input to ioctls() at build time
Add a static assert to the KVM/VM/vCPU ioctl() helpers to verify that the size of the argument provided matches the expected size of the IOCTL. Because ioctl() ultimately takes a "void *", it's all too easy to pass in garbage and not detect the error until runtime. E.g. while working on a CPUID rework, selftests happily compiled when vcpu_set_cpuid() unintentionally passed the cpuid() function as the parameter to ioctl() (a local "cpuid" parameter was removed, but its use was not replaced with "vcpu->cpuid" as intended). Tweak a variety of benign issues that aren't compatible with the sanity check, e.g. passing a non-pointer for ioctls(). Note, static_assert() requires a string on older versions of GCC. Feed it an empty string to make the compiler happy. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/s390x/resets.c')
-rw-r--r--tools/testing/selftests/kvm/s390x/resets.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/testing/selftests/kvm/s390x/resets.c b/tools/testing/selftests/kvm/s390x/resets.c
index e1737411accc..19486084eb30 100644
--- a/tools/testing/selftests/kvm/s390x/resets.c
+++ b/tools/testing/selftests/kvm/s390x/resets.c
@@ -225,7 +225,7 @@ static void test_normal(void)
inject_irq(vcpu);
- vcpu_ioctl(vcpu, KVM_S390_NORMAL_RESET, 0);
+ vcpu_ioctl(vcpu, KVM_S390_NORMAL_RESET, NULL);
/* must clears */
assert_normal(vcpu);
@@ -248,7 +248,7 @@ static void test_initial(void)
inject_irq(vcpu);
- vcpu_ioctl(vcpu, KVM_S390_INITIAL_RESET, 0);
+ vcpu_ioctl(vcpu, KVM_S390_INITIAL_RESET, NULL);
/* must clears */
assert_normal(vcpu);
@@ -271,7 +271,7 @@ static void test_clear(void)
inject_irq(vcpu);
- vcpu_ioctl(vcpu, KVM_S390_CLEAR_RESET, 0);
+ vcpu_ioctl(vcpu, KVM_S390_CLEAR_RESET, NULL);
/* must clears */
assert_normal(vcpu);