mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-25 00:52:45 -04:00
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 9e2f6498ef ("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
This commit is contained in:
@@ -21,7 +21,7 @@ static bool ucall_mmio_init(struct kvm_vm *vm, vm_paddr_t gpa)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ucall_init(struct kvm_vm *vm, void *arg)
|
||||
void ucall_arch_init(struct kvm_vm *vm, void *arg)
|
||||
{
|
||||
vm_paddr_t gpa, start, end, step, offset;
|
||||
unsigned int bits;
|
||||
@@ -64,30 +64,18 @@ void ucall_init(struct kvm_vm *vm, void *arg)
|
||||
TEST_FAIL("Can't find a ucall mmio address");
|
||||
}
|
||||
|
||||
void ucall_uninit(struct kvm_vm *vm)
|
||||
void ucall_arch_uninit(struct kvm_vm *vm)
|
||||
{
|
||||
ucall_exit_mmio_addr = 0;
|
||||
sync_global_to_guest(vm, ucall_exit_mmio_addr);
|
||||
}
|
||||
|
||||
void ucall(uint64_t cmd, int nargs, ...)
|
||||
void ucall_arch_do_ucall(vm_vaddr_t uc)
|
||||
{
|
||||
struct ucall uc = {};
|
||||
va_list va;
|
||||
int i;
|
||||
|
||||
WRITE_ONCE(uc.cmd, cmd);
|
||||
nargs = min(nargs, UCALL_MAX_ARGS);
|
||||
|
||||
va_start(va, nargs);
|
||||
for (i = 0; i < nargs; ++i)
|
||||
WRITE_ONCE(uc.args[i], va_arg(va, uint64_t));
|
||||
va_end(va);
|
||||
|
||||
WRITE_ONCE(*ucall_exit_mmio_addr, (vm_vaddr_t)&uc);
|
||||
WRITE_ONCE(*ucall_exit_mmio_addr, uc);
|
||||
}
|
||||
|
||||
uint64_t get_ucall(struct kvm_vcpu *vcpu, struct ucall *uc)
|
||||
uint64_t ucall_arch_get_ucall(struct kvm_vcpu *vcpu, struct ucall *uc)
|
||||
{
|
||||
struct kvm_run *run = vcpu->run;
|
||||
struct ucall ucall = {};
|
||||
|
||||
Reference in New Issue
Block a user