@@ -38,86 +38,6 @@ const struct kvm_stats_header kvm_vcpu_stats_header = {
38
38
sizeof (kvm_vcpu_stats_desc ),
39
39
};
40
40
41
- #ifdef CONFIG_FPU
42
- static void kvm_riscv_vcpu_fp_reset (struct kvm_vcpu * vcpu )
43
- {
44
- unsigned long isa = vcpu -> arch .isa ;
45
- struct kvm_cpu_context * cntx = & vcpu -> arch .guest_context ;
46
-
47
- cntx -> sstatus &= ~SR_FS ;
48
- if (riscv_isa_extension_available (& isa , f ) ||
49
- riscv_isa_extension_available (& isa , d ))
50
- cntx -> sstatus |= SR_FS_INITIAL ;
51
- else
52
- cntx -> sstatus |= SR_FS_OFF ;
53
- }
54
-
55
- static void kvm_riscv_vcpu_fp_clean (struct kvm_cpu_context * cntx )
56
- {
57
- cntx -> sstatus &= ~SR_FS ;
58
- cntx -> sstatus |= SR_FS_CLEAN ;
59
- }
60
-
61
- static void kvm_riscv_vcpu_guest_fp_save (struct kvm_cpu_context * cntx ,
62
- unsigned long isa )
63
- {
64
- if ((cntx -> sstatus & SR_FS ) == SR_FS_DIRTY ) {
65
- if (riscv_isa_extension_available (& isa , d ))
66
- __kvm_riscv_fp_d_save (cntx );
67
- else if (riscv_isa_extension_available (& isa , f ))
68
- __kvm_riscv_fp_f_save (cntx );
69
- kvm_riscv_vcpu_fp_clean (cntx );
70
- }
71
- }
72
-
73
- static void kvm_riscv_vcpu_guest_fp_restore (struct kvm_cpu_context * cntx ,
74
- unsigned long isa )
75
- {
76
- if ((cntx -> sstatus & SR_FS ) != SR_FS_OFF ) {
77
- if (riscv_isa_extension_available (& isa , d ))
78
- __kvm_riscv_fp_d_restore (cntx );
79
- else if (riscv_isa_extension_available (& isa , f ))
80
- __kvm_riscv_fp_f_restore (cntx );
81
- kvm_riscv_vcpu_fp_clean (cntx );
82
- }
83
- }
84
-
85
- static void kvm_riscv_vcpu_host_fp_save (struct kvm_cpu_context * cntx )
86
- {
87
- /* No need to check host sstatus as it can be modified outside */
88
- if (riscv_isa_extension_available (NULL , d ))
89
- __kvm_riscv_fp_d_save (cntx );
90
- else if (riscv_isa_extension_available (NULL , f ))
91
- __kvm_riscv_fp_f_save (cntx );
92
- }
93
-
94
- static void kvm_riscv_vcpu_host_fp_restore (struct kvm_cpu_context * cntx )
95
- {
96
- if (riscv_isa_extension_available (NULL , d ))
97
- __kvm_riscv_fp_d_restore (cntx );
98
- else if (riscv_isa_extension_available (NULL , f ))
99
- __kvm_riscv_fp_f_restore (cntx );
100
- }
101
- #else
102
- static void kvm_riscv_vcpu_fp_reset (struct kvm_vcpu * vcpu )
103
- {
104
- }
105
- static void kvm_riscv_vcpu_guest_fp_save (struct kvm_cpu_context * cntx ,
106
- unsigned long isa )
107
- {
108
- }
109
- static void kvm_riscv_vcpu_guest_fp_restore (struct kvm_cpu_context * cntx ,
110
- unsigned long isa )
111
- {
112
- }
113
- static void kvm_riscv_vcpu_host_fp_save (struct kvm_cpu_context * cntx )
114
- {
115
- }
116
- static void kvm_riscv_vcpu_host_fp_restore (struct kvm_cpu_context * cntx )
117
- {
118
- }
119
- #endif
120
-
121
41
#define KVM_RISCV_ISA_ALLOWED (riscv_isa_extension_mask(a) | \
122
42
riscv_isa_extension_mask(c) | \
123
43
riscv_isa_extension_mask(d) | \
@@ -414,98 +334,6 @@ static int kvm_riscv_vcpu_set_reg_csr(struct kvm_vcpu *vcpu,
414
334
return 0 ;
415
335
}
416
336
417
- static int kvm_riscv_vcpu_get_reg_fp (struct kvm_vcpu * vcpu ,
418
- const struct kvm_one_reg * reg ,
419
- unsigned long rtype )
420
- {
421
- struct kvm_cpu_context * cntx = & vcpu -> arch .guest_context ;
422
- unsigned long isa = vcpu -> arch .isa ;
423
- unsigned long __user * uaddr =
424
- (unsigned long __user * )(unsigned long )reg -> addr ;
425
- unsigned long reg_num = reg -> id & ~(KVM_REG_ARCH_MASK |
426
- KVM_REG_SIZE_MASK |
427
- rtype );
428
- void * reg_val ;
429
-
430
- if ((rtype == KVM_REG_RISCV_FP_F ) &&
431
- riscv_isa_extension_available (& isa , f )) {
432
- if (KVM_REG_SIZE (reg -> id ) != sizeof (u32 ))
433
- return - EINVAL ;
434
- if (reg_num == KVM_REG_RISCV_FP_F_REG (fcsr ))
435
- reg_val = & cntx -> fp .f .fcsr ;
436
- else if ((KVM_REG_RISCV_FP_F_REG (f [0 ]) <= reg_num ) &&
437
- reg_num <= KVM_REG_RISCV_FP_F_REG (f [31 ]))
438
- reg_val = & cntx -> fp .f .f [reg_num ];
439
- else
440
- return - EINVAL ;
441
- } else if ((rtype == KVM_REG_RISCV_FP_D ) &&
442
- riscv_isa_extension_available (& isa , d )) {
443
- if (reg_num == KVM_REG_RISCV_FP_D_REG (fcsr )) {
444
- if (KVM_REG_SIZE (reg -> id ) != sizeof (u32 ))
445
- return - EINVAL ;
446
- reg_val = & cntx -> fp .d .fcsr ;
447
- } else if ((KVM_REG_RISCV_FP_D_REG (f [0 ]) <= reg_num ) &&
448
- reg_num <= KVM_REG_RISCV_FP_D_REG (f [31 ])) {
449
- if (KVM_REG_SIZE (reg -> id ) != sizeof (u64 ))
450
- return - EINVAL ;
451
- reg_val = & cntx -> fp .d .f [reg_num ];
452
- } else
453
- return - EINVAL ;
454
- } else
455
- return - EINVAL ;
456
-
457
- if (copy_to_user (uaddr , reg_val , KVM_REG_SIZE (reg -> id )))
458
- return - EFAULT ;
459
-
460
- return 0 ;
461
- }
462
-
463
- static int kvm_riscv_vcpu_set_reg_fp (struct kvm_vcpu * vcpu ,
464
- const struct kvm_one_reg * reg ,
465
- unsigned long rtype )
466
- {
467
- struct kvm_cpu_context * cntx = & vcpu -> arch .guest_context ;
468
- unsigned long isa = vcpu -> arch .isa ;
469
- unsigned long __user * uaddr =
470
- (unsigned long __user * )(unsigned long )reg -> addr ;
471
- unsigned long reg_num = reg -> id & ~(KVM_REG_ARCH_MASK |
472
- KVM_REG_SIZE_MASK |
473
- rtype );
474
- void * reg_val ;
475
-
476
- if ((rtype == KVM_REG_RISCV_FP_F ) &&
477
- riscv_isa_extension_available (& isa , f )) {
478
- if (KVM_REG_SIZE (reg -> id ) != sizeof (u32 ))
479
- return - EINVAL ;
480
- if (reg_num == KVM_REG_RISCV_FP_F_REG (fcsr ))
481
- reg_val = & cntx -> fp .f .fcsr ;
482
- else if ((KVM_REG_RISCV_FP_F_REG (f [0 ]) <= reg_num ) &&
483
- reg_num <= KVM_REG_RISCV_FP_F_REG (f [31 ]))
484
- reg_val = & cntx -> fp .f .f [reg_num ];
485
- else
486
- return - EINVAL ;
487
- } else if ((rtype == KVM_REG_RISCV_FP_D ) &&
488
- riscv_isa_extension_available (& isa , d )) {
489
- if (reg_num == KVM_REG_RISCV_FP_D_REG (fcsr )) {
490
- if (KVM_REG_SIZE (reg -> id ) != sizeof (u32 ))
491
- return - EINVAL ;
492
- reg_val = & cntx -> fp .d .fcsr ;
493
- } else if ((KVM_REG_RISCV_FP_D_REG (f [0 ]) <= reg_num ) &&
494
- reg_num <= KVM_REG_RISCV_FP_D_REG (f [31 ])) {
495
- if (KVM_REG_SIZE (reg -> id ) != sizeof (u64 ))
496
- return - EINVAL ;
497
- reg_val = & cntx -> fp .d .f [reg_num ];
498
- } else
499
- return - EINVAL ;
500
- } else
501
- return - EINVAL ;
502
-
503
- if (copy_from_user (reg_val , uaddr , KVM_REG_SIZE (reg -> id )))
504
- return - EFAULT ;
505
-
506
- return 0 ;
507
- }
508
-
509
337
static int kvm_riscv_vcpu_set_reg (struct kvm_vcpu * vcpu ,
510
338
const struct kvm_one_reg * reg )
511
339
{
0 commit comments