File tree Expand file tree Collapse file tree 5 files changed +22
-21
lines changed Expand file tree Collapse file tree 5 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -550,8 +550,14 @@ struct cpu_sve_state {
550
550
struct kvm_host_data {
551
551
struct kvm_cpu_context host_ctxt ;
552
552
553
- struct user_fpsimd_state * fpsimd_state ; /* hyp VA */
554
- struct cpu_sve_state * sve_state ; /* hyp VA */
553
+ /*
554
+ * All pointers in this union are hyp VA.
555
+ * sve_state is only used in pKVM and if system_supports_sve().
556
+ */
557
+ union {
558
+ struct user_fpsimd_state * fpsimd_state ;
559
+ struct cpu_sve_state * sve_state ;
560
+ };
555
561
556
562
/* Ownership of the FP regs */
557
563
enum {
Original file line number Diff line number Diff line change @@ -2444,14 +2444,22 @@ static void finalize_init_hyp_mode(void)
2444
2444
{
2445
2445
int cpu ;
2446
2446
2447
- if (!is_protected_kvm_enabled () || !system_supports_sve ())
2448
- return ;
2447
+ if (system_supports_sve () && is_protected_kvm_enabled ()) {
2448
+ for_each_possible_cpu (cpu ) {
2449
+ struct cpu_sve_state * sve_state ;
2449
2450
2450
- for_each_possible_cpu (cpu ) {
2451
- struct cpu_sve_state * sve_state ;
2451
+ sve_state = per_cpu_ptr_nvhe_sym (kvm_host_data , cpu )-> sve_state ;
2452
+ per_cpu_ptr_nvhe_sym (kvm_host_data , cpu )-> sve_state =
2453
+ kern_hyp_va (sve_state );
2454
+ }
2455
+ } else {
2456
+ for_each_possible_cpu (cpu ) {
2457
+ struct user_fpsimd_state * fpsimd_state ;
2452
2458
2453
- sve_state = per_cpu_ptr_nvhe_sym (kvm_host_data , cpu )-> sve_state ;
2454
- per_cpu_ptr_nvhe_sym (kvm_host_data , cpu )-> sve_state = kern_hyp_va (sve_state );
2459
+ fpsimd_state = & per_cpu_ptr_nvhe_sym (kvm_host_data , cpu )-> host_ctxt .fp_regs ;
2460
+ per_cpu_ptr_nvhe_sym (kvm_host_data , cpu )-> fpsimd_state =
2461
+ kern_hyp_va (fpsimd_state );
2462
+ }
2455
2463
}
2456
2464
}
2457
2465
Original file line number Diff line number Diff line change @@ -59,7 +59,6 @@ static inline bool pkvm_hyp_vcpu_is_protected(struct pkvm_hyp_vcpu *hyp_vcpu)
59
59
}
60
60
61
61
void pkvm_hyp_vm_table_init (void * tbl );
62
- void pkvm_host_fpsimd_state_init (void );
63
62
64
63
int __pkvm_init_vm (struct kvm * host_kvm , unsigned long vm_hva ,
65
64
unsigned long pgd_hva );
Original file line number Diff line number Diff line change @@ -249,17 +249,6 @@ void pkvm_hyp_vm_table_init(void *tbl)
249
249
vm_table = tbl ;
250
250
}
251
251
252
- void pkvm_host_fpsimd_state_init (void )
253
- {
254
- unsigned long i ;
255
-
256
- for (i = 0 ; i < hyp_nr_cpus ; i ++ ) {
257
- struct kvm_host_data * host_data = per_cpu_ptr (& kvm_host_data , i );
258
-
259
- host_data -> fpsimd_state = & host_data -> host_ctxt .fp_regs ;
260
- }
261
- }
262
-
263
252
/*
264
253
* Return the hyp vm structure corresponding to the handle.
265
254
*/
Original file line number Diff line number Diff line change @@ -324,7 +324,6 @@ void __noreturn __pkvm_init_finalise(void)
324
324
goto out ;
325
325
326
326
pkvm_hyp_vm_table_init (vm_table_base );
327
- pkvm_host_fpsimd_state_init ();
328
327
out :
329
328
/*
330
329
* We tail-called to here from handle___pkvm_init() and will not return,
You can’t perform that action at this time.
0 commit comments