]>
Commit | Line | Data |
---|---|---|
cf70be9d AP |
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 | ||
c62a7685 AP |
12 | #define KVM_SBI_IMPID 3 |
13 | ||
b88e87a0 | 14 | #define KVM_SBI_VERSION_MAJOR 2 |
d837f191 | 15 | #define KVM_SBI_VERSION_MINOR 0 |
cf70be9d | 16 | |
9f9e3ebe | 17 | enum kvm_riscv_sbi_ext_status { |
95c99104 | 18 | KVM_RISCV_SBI_EXT_UNINITIALIZED, |
9f9e3ebe AJ |
19 | KVM_RISCV_SBI_EXT_AVAILABLE, |
20 | KVM_RISCV_SBI_EXT_UNAVAILABLE, | |
21 | }; | |
22 | ||
23fe562e AP |
23 | struct kvm_vcpu_sbi_context { |
24 | int return_handled; | |
9f9e3ebe | 25 | enum kvm_riscv_sbi_ext_status ext_status[KVM_RISCV_SBI_EXT_MAX]; |
23fe562e AP |
26 | }; |
27 | ||
bae0dfd7 AP |
28 | struct kvm_vcpu_sbi_return { |
29 | unsigned long out_val; | |
30 | unsigned long err_val; | |
31 | struct kvm_cpu_trap *utrap; | |
32 | bool uexit; | |
33 | }; | |
34 | ||
cf70be9d AP |
35 | struct kvm_vcpu_sbi_extension { |
36 | unsigned long extid_start; | |
37 | unsigned long extid_end; | |
56d8a385 AP |
38 | |
39 | bool default_unavail; | |
40 | ||
cf70be9d AP |
41 | /** |
42 | * SBI extension handler. It can be defined for a given extension or group of | |
43 | * extension. But it should always return linux error codes rather than SBI | |
44 | * specific error codes. | |
45 | */ | |
46 | int (*handler)(struct kvm_vcpu *vcpu, struct kvm_run *run, | |
bae0dfd7 | 47 | struct kvm_vcpu_sbi_return *retdata); |
026bac45 AP |
48 | |
49 | /* Extension specific probe function */ | |
50 | unsigned long (*probe)(struct kvm_vcpu *vcpu); | |
cf70be9d AP |
51 | }; |
52 | ||
a046c2d8 | 53 | void kvm_riscv_vcpu_sbi_forward(struct kvm_vcpu *vcpu, struct kvm_run *run); |
4b11d865 AP |
54 | void kvm_riscv_vcpu_sbi_system_reset(struct kvm_vcpu *vcpu, |
55 | struct kvm_run *run, | |
56 | u32 type, u64 flags); | |
23fe562e | 57 | int kvm_riscv_vcpu_sbi_return(struct kvm_vcpu *vcpu, struct kvm_run *run); |
96b3d4bd AP |
58 | int kvm_riscv_vcpu_set_reg_sbi_ext(struct kvm_vcpu *vcpu, |
59 | const struct kvm_one_reg *reg); | |
60 | int kvm_riscv_vcpu_get_reg_sbi_ext(struct kvm_vcpu *vcpu, | |
61 | const struct kvm_one_reg *reg); | |
62 | const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext( | |
63 | struct kvm_vcpu *vcpu, unsigned long extid); | |
23fe562e | 64 | int kvm_riscv_vcpu_sbi_ecall(struct kvm_vcpu *vcpu, struct kvm_run *run); |
56d8a385 | 65 | void kvm_riscv_vcpu_sbi_init(struct kvm_vcpu *vcpu); |
a046c2d8 | 66 | |
3e5e56c6 CD |
67 | #ifdef CONFIG_RISCV_SBI_V01 |
68 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_v01; | |
69 | #endif | |
70 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_base; | |
71 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_time; | |
72 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_ipi; | |
73 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_rfence; | |
74 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_srst; | |
75 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_hsm; | |
c667ad22 | 76 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_dbcn; |
3e5e56c6 CD |
77 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_experimental; |
78 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_vendor; | |
79 | ||
377f71f6 BD |
80 | #ifdef CONFIG_RISCV_PMU_SBI |
81 | extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_pmu; | |
82 | #endif | |
cf70be9d | 83 | #endif /* __RISCV_KVM_VCPU_SBI_H__ */ |