]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - tools/testing/selftests/kvm/lib/riscv/ucall.c
Merge tag 'kvm-x86-generic-6.8' of https://github.com/kvm-x86/linux into HEAD
[thirdparty/kernel/stable.git] / tools / testing / selftests / kvm / lib / riscv / ucall.c
CommitLineData
3e06cdf1
AP
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * ucall support. A ucall is a "hypercall to userspace".
4 *
5 * Copyright (C) 2021 Western Digital Corporation or its affiliates.
6 */
7
8#include <linux/kvm.h>
9
10#include "kvm_util.h"
3e06cdf1
AP
11#include "processor.h"
12
ef38871e 13void *ucall_arch_get_ucall(struct kvm_vcpu *vcpu)
3e06cdf1 14{
768e9a61 15 struct kvm_run *run = vcpu->run;
3e06cdf1
AP
16
17 if (run->exit_reason == KVM_EXIT_RISCV_SBI &&
ac6c85e9
AP
18 run->riscv_sbi.extension_id == KVM_RISCV_SELFTESTS_SBI_EXT) {
19 switch (run->riscv_sbi.function_id) {
20 case KVM_RISCV_SELFTESTS_SBI_UCALL:
426729b2 21 return (void *)run->riscv_sbi.args[0];
ac6c85e9 22 case KVM_RISCV_SELFTESTS_SBI_UNEXP:
768e9a61 23 vcpu_dump(stderr, vcpu, 2);
ac6c85e9
AP
24 TEST_ASSERT(0, "Unexpected trap taken by guest");
25 break;
26 default:
27 break;
28 }
3e06cdf1 29 }
ef38871e 30 return NULL;
3e06cdf1 31}