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  *     Anup Patel <anup.patel@wdc.com>
8  */
9 
10 #ifndef __KVM_VCPU_RISCV_FP_H
11 #define __KVM_VCPU_RISCV_FP_H
12 
13 #include <linux/types.h>
14 
15 struct kvm_cpu_context;
16 
17 #ifdef CONFIG_FPU
18 void __kvm_riscv_fp_f_save(struct kvm_cpu_context *context);
19 void __kvm_riscv_fp_f_restore(struct kvm_cpu_context *context);
20 void __kvm_riscv_fp_d_save(struct kvm_cpu_context *context);
21 void __kvm_riscv_fp_d_restore(struct kvm_cpu_context *context);
22 
23 void kvm_riscv_vcpu_fp_reset(struct kvm_vcpu *vcpu);
24 void kvm_riscv_vcpu_guest_fp_save(struct kvm_cpu_context *cntx,
25 				  unsigned long isa);
26 void kvm_riscv_vcpu_guest_fp_restore(struct kvm_cpu_context *cntx,
27 				     unsigned long isa);
28 void kvm_riscv_vcpu_host_fp_save(struct kvm_cpu_context *cntx);
29 void kvm_riscv_vcpu_host_fp_restore(struct kvm_cpu_context *cntx);
30 #else
kvm_riscv_vcpu_fp_reset(struct kvm_vcpu * vcpu)31 static inline void kvm_riscv_vcpu_fp_reset(struct kvm_vcpu *vcpu)
32 {
33 }
kvm_riscv_vcpu_guest_fp_save(struct kvm_cpu_context * cntx,unsigned long isa)34 static inline void kvm_riscv_vcpu_guest_fp_save(struct kvm_cpu_context *cntx,
35 						unsigned long isa)
36 {
37 }
kvm_riscv_vcpu_guest_fp_restore(struct kvm_cpu_context * cntx,unsigned long isa)38 static inline void kvm_riscv_vcpu_guest_fp_restore(
39 					struct kvm_cpu_context *cntx,
40 					unsigned long isa)
41 {
42 }
kvm_riscv_vcpu_host_fp_save(struct kvm_cpu_context * cntx)43 static inline void kvm_riscv_vcpu_host_fp_save(struct kvm_cpu_context *cntx)
44 {
45 }
kvm_riscv_vcpu_host_fp_restore(struct kvm_cpu_context * cntx)46 static inline void kvm_riscv_vcpu_host_fp_restore(
47 					struct kvm_cpu_context *cntx)
48 {
49 }
50 #endif
51 
52 int kvm_riscv_vcpu_get_reg_fp(struct kvm_vcpu *vcpu,
53 			      const struct kvm_one_reg *reg,
54 			      unsigned long rtype);
55 int kvm_riscv_vcpu_set_reg_fp(struct kvm_vcpu *vcpu,
56 			      const struct kvm_one_reg *reg,
57 			      unsigned long rtype);
58 
59 #endif
60