1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /**
3  * Copyright (c) 2021 Western Digital Corporation or its affiliates.
4  *
5  * Authors:
6  *     Atish Patra <atish.patra@wdc.com>
7  */
8 
9 #ifndef __RISCV_KVM_VCPU_SBI_H__
10 #define __RISCV_KVM_VCPU_SBI_H__
11 
12 #define KVM_SBI_IMPID 3
13 
14 #define KVM_SBI_VERSION_MAJOR 0
15 #define KVM_SBI_VERSION_MINOR 3
16 
17 struct kvm_vcpu_sbi_extension {
18 	unsigned long extid_start;
19 	unsigned long extid_end;
20 	/**
21 	 * SBI extension handler. It can be defined for a given extension or group of
22 	 * extension. But it should always return linux error codes rather than SBI
23 	 * specific error codes.
24 	 */
25 	int (*handler)(struct kvm_vcpu *vcpu, struct kvm_run *run,
26 		       unsigned long *out_val, struct kvm_cpu_trap *utrap,
27 		       bool *exit);
28 };
29 
30 void kvm_riscv_vcpu_sbi_forward(struct kvm_vcpu *vcpu, struct kvm_run *run);
31 void kvm_riscv_vcpu_sbi_system_reset(struct kvm_vcpu *vcpu,
32 				     struct kvm_run *run,
33 				     u32 type, u64 flags);
34 const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext(unsigned long extid);
35 
36 #endif /* __RISCV_KVM_VCPU_SBI_H__ */
37