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

Garg, Shivank shivankg at amd.com
Fri Oct 17 02:51:35 PDT 2025



On 10/16/2025 10:58 PM, Sean Christopherson wrote:
> 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.
> 
> Reviewed-by: Ackerley Tng <ackerleytng at google.com>
> Tested-by: Ackerley Tng <ackerleytng at google.com>
> Signed-off-by: Sean Christopherson <seanjc at 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
> 

Reviewed-by: Shivank Garg <shivankg at amd.com>
Tested-by: Shivank Garg <shivankg at amd.com>





More information about the linux-arm-kernel mailing list