KVM: selftests: Consolidate common code for populating ucall struct
authorSean Christopherson <seanjc@google.com>
Thu, 6 Oct 2022 00:34:03 +0000 (00:34 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 17 Nov 2022 00:58:51 +0000 (16:58 -0800)
commit7046638192d52416adbfc273c36950f0e3311191
tree6483dab78b419e0b8e16b3f8d8547ff811e2be2c
parentb3d937722de0e64eebe267451a0e3d5ed5107ef7
KVM: selftests: Consolidate common code for populating ucall struct

Make ucall() a common helper that populates struct ucall, and only calls
into arch code to make the actually call out to userspace.

Rename all arch-specific helpers to make it clear they're arch-specific,
and to avoid collisions with common helpers (one more on its way...)

Add WRITE_ONCE() to stores in ucall() code (as already done to aarch64
code in commit 9e2f6498efbb ("selftests: KVM: Handle compiler
optimizations in ucall")) to prevent clang optimizations breaking ucalls.

Cc: Colton Lewis <coltonlewis@google.com>
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-2-seanjc@google.com
tools/testing/selftests/kvm/Makefile
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 [new file with mode: 0644]
tools/testing/selftests/kvm/lib/x86_64/ucall.c