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 {
550550struct kvm_host_data {
551551 struct kvm_cpu_context host_ctxt ;
552552
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+ };
555561
556562 /* Ownership of the FP regs */
557563 enum {
Original file line number Diff line number Diff line change @@ -2444,14 +2444,22 @@ static void finalize_init_hyp_mode(void)
24442444{
24452445 int cpu ;
24462446
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 ;
24492450
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 ;
24522458
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+ }
24552463 }
24562464}
24572465
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)
5959}
6060
6161void pkvm_hyp_vm_table_init (void * tbl );
62- void pkvm_host_fpsimd_state_init (void );
6362
6463int __pkvm_init_vm (struct kvm * host_kvm , unsigned long vm_hva ,
6564 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)
249249 vm_table = tbl ;
250250}
251251
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-
263252/*
264253 * Return the hyp vm structure corresponding to the handle.
265254 */
Original file line number Diff line number Diff line change @@ -324,7 +324,6 @@ void __noreturn __pkvm_init_finalise(void)
324324 goto out ;
325325
326326 pkvm_hyp_vm_table_init (vm_table_base );
327- pkvm_host_fpsimd_state_init ();
328327out :
329328 /*
330329 * 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