Re: [PATCH v12 06/12] KVM: selftests: Define wrappers for common syscalls to assert success

Ackerley Tng
2025-10-09T21:44:07Z

Sean Christopherson <seanjc@google.com> writes:

> Add kvm_<sycall> wrappers for munmap(), close(), fallocate(), and
> ftruncate() to cut down on boilerplate code when a sycall is expected
> to succeed, and to make it easier for developers to remember to assert
> success.
>
> Implement and use a macro framework similar to the kernel's SYSCALL_DEFINE
> infrastructure to further cut down on boilerplate code, and to drastically
> reduce the probability of typos as the kernel's syscall definitions can be
> copy+paste almost verbatim.
>
> Provide macros to build the raw <sycall>() wrappers as well, e.g. to
> replace hand-coded wrappers (NUMA) or pure open-coded calls.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>

Reviewed-by: Ackerley Tng <ackerleytng@google.com>
Tested-by: Ackerley Tng <ackerleytng@google.com>

> ---
> tools/testing/selftests/kvm/arm64/vgic_irq.c | 2 +-
> .../selftests/kvm/include/kvm_syscalls.h | 81 +++++++++++++++++++
> .../testing/selftests/kvm/include/kvm_util.h | 29 +------
> .../selftests/kvm/kvm_binary_stats_test.c | 4 +-
> tools/testing/selftests/kvm/lib/kvm_util.c | 31 ++-----
> .../kvm/x86/private_mem_conversions_test.c | 9 +--
> 6 files changed, 96 insertions(+), 60 deletions(-)
> create mode 100644 tools/testing/selftests/kvm/include/kvm_syscalls.h
>
>
> [...snip...]
>