OSDN Git Service

KVM: selftests: Consolidate boilerplate code in get_ucall()
authorSean Christopherson <seanjc@google.com>
Thu, 6 Oct 2022 00:34:04 +0000 (00:34 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 17 Nov 2022 00:58:51 +0000 (16:58 -0800)
commitef38871eb22879438d2af8642ed7a52c1616f410
treebcbd4bf18b53bf9b26016eaff9b1e22ab008518f
parent7046638192d52416adbfc273c36950f0e3311191
KVM: selftests: Consolidate boilerplate code in get_ucall()

Consolidate the actual copying of a ucall struct from guest=>host into
the common get_ucall().  Return a host virtual address instead of a guest
virtual address even though the addr_gva2hva() part could be moved to
get_ucall() too.  Conceptually, get_ucall() is invoked from the host and
should return a host virtual address (and returning NULL for "nothing to
see here" is far superior to returning 0).

Use pointer shenanigans instead of an unnecessary bounce buffer when the
caller of get_ucall() provides a valid pointer.

Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Tested-by: Peter Gonda <pgonda@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20221006003409.649993-3-seanjc@google.com
tools/testing/selftests/kvm/include/ucall_common.h
tools/testing/selftests/kvm/lib/aarch64/ucall.c
tools/testing/selftests/kvm/lib/riscv/ucall.c
tools/testing/selftests/kvm/lib/s390x/ucall.c
tools/testing/selftests/kvm/lib/ucall_common.c
tools/testing/selftests/kvm/lib/x86_64/ucall.c