Re: [V3 07/11] KVM: selftests: Consolidate boilerplate code in get_ucall()

From: Andrew Jones
Date: Tue Aug 16 2022 - 11:32:53 EST


On Wed, Aug 10, 2022 at 08:20:29AM -0700, Peter Gonda wrote:
> From: Sean Christopherson <seanjc@xxxxxxxxxx>
>
> 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.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> Signed-off-by: Peter Gonda <pgonda@xxxxxxxxxx>
> ---
> .../selftests/kvm/include/ucall_common.h | 8 ++------
> .../testing/selftests/kvm/lib/aarch64/ucall.c | 14 +++-----------
> tools/testing/selftests/kvm/lib/riscv/ucall.c | 19 +++----------------
> tools/testing/selftests/kvm/lib/s390x/ucall.c | 16 +++-------------
> .../testing/selftests/kvm/lib/ucall_common.c | 19 +++++++++++++++++++
> .../testing/selftests/kvm/lib/x86_64/ucall.c | 16 +++-------------
> 6 files changed, 33 insertions(+), 59 deletions(-)
>

Reviewed-by: Andrew Jones <andrew.jones@xxxxxxxxx>