@@ -573,7 +573,7 @@ static void __svm_write_tsc_multiplier(u64 multiplier)
573573
574574static __always_inline struct sev_es_save_area * sev_es_host_save_area (struct svm_cpu_data * sd )
575575{
576- return page_address ( sd -> save_area ) + 0x400 ;
576+ return & sd -> save_area -> host_sev_es_save ;
577577}
578578
579579static inline void kvm_cpu_svm_disable (void )
@@ -696,31 +696,32 @@ static void svm_cpu_uninit(int cpu)
696696 return ;
697697
698698 kfree (sd -> sev_vmcbs );
699- __free_page (sd -> save_area );
699+ __free_page (__sme_pa_to_page ( sd -> save_area_pa ) );
700700 sd -> save_area_pa = 0 ;
701701 sd -> save_area = NULL ;
702702}
703703
704704static int svm_cpu_init (int cpu )
705705{
706706 struct svm_cpu_data * sd = per_cpu_ptr (& svm_data , cpu );
707+ struct page * save_area_page ;
707708 int ret = - ENOMEM ;
708709
709710 memset (sd , 0 , sizeof (struct svm_cpu_data ));
710- sd -> save_area = snp_safe_alloc_page_node (cpu_to_node (cpu ), GFP_KERNEL );
711- if (!sd -> save_area )
711+ save_area_page = snp_safe_alloc_page_node (cpu_to_node (cpu ), GFP_KERNEL );
712+ if (!save_area_page )
712713 return ret ;
713714
714715 ret = sev_cpu_init (sd );
715716 if (ret )
716717 goto free_save_area ;
717718
718- sd -> save_area_pa = __sme_page_pa (sd -> save_area );
719+ sd -> save_area = page_address (save_area_page );
720+ sd -> save_area_pa = __sme_page_pa (save_area_page );
719721 return 0 ;
720722
721723free_save_area :
722- __free_page (sd -> save_area );
723- sd -> save_area = NULL ;
724+ __free_page (save_area_page );
724725 return ret ;
725726
726727}
@@ -1124,8 +1125,7 @@ static void svm_hardware_unsetup(void)
11241125 for_each_possible_cpu (cpu )
11251126 svm_cpu_uninit (cpu );
11261127
1127- __free_pages (pfn_to_page (iopm_base >> PAGE_SHIFT ),
1128- get_order (IOPM_SIZE ));
1128+ __free_pages (__sme_pa_to_page (iopm_base ), get_order (IOPM_SIZE ));
11291129 iopm_base = 0 ;
11301130}
11311131
@@ -1301,7 +1301,7 @@ static void init_vmcb(struct kvm_vcpu *vcpu)
13011301 if (!kvm_hlt_in_guest (vcpu -> kvm ))
13021302 svm_set_intercept (svm , INTERCEPT_HLT );
13031303
1304- control -> iopm_base_pa = __sme_set ( iopm_base ) ;
1304+ control -> iopm_base_pa = iopm_base ;
13051305 control -> msrpm_base_pa = __sme_set (__pa (svm -> msrpm ));
13061306 control -> int_ctl = V_INTR_MASKING_MASK ;
13071307
@@ -1503,7 +1503,7 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu)
15031503
15041504 sev_free_vcpu (vcpu );
15051505
1506- __free_page (pfn_to_page ( __sme_clr ( svm -> vmcb01 .pa ) >> PAGE_SHIFT ));
1506+ __free_page (__sme_pa_to_page ( svm -> vmcb01 .pa ));
15071507 __free_pages (virt_to_page (svm -> msrpm ), get_order (MSRPM_SIZE ));
15081508}
15091509
@@ -5281,7 +5281,7 @@ static __init int svm_hardware_setup(void)
52815281
52825282 iopm_va = page_address (iopm_pages );
52835283 memset (iopm_va , 0xff , PAGE_SIZE * (1 << order ));
5284- iopm_base = page_to_pfn (iopm_pages ) << PAGE_SHIFT ;
5284+ iopm_base = __sme_page_pa (iopm_pages );
52855285
52865286 init_msrpm_offsets ();
52875287
0 commit comments