@@ -891,14 +891,6 @@ static inline struct vmcs12 *get_vmcs12(struct kvm_vcpu *vcpu)
891
891
return to_vmx (vcpu )-> nested .cached_vmcs12 ;
892
892
}
893
893
894
- static struct page * nested_get_page (struct kvm_vcpu * vcpu , gpa_t addr )
895
- {
896
- struct page * page = kvm_vcpu_gfn_to_page (vcpu , addr >> PAGE_SHIFT );
897
- if (is_error_page (page ))
898
- return NULL ;
899
-
900
- return page ;
901
- }
902
894
903
895
static void nested_release_page (struct page * page )
904
896
{
@@ -7156,8 +7148,8 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
7156
7148
return kvm_skip_emulated_instruction (vcpu );
7157
7149
}
7158
7150
7159
- page = nested_get_page (vcpu , vmptr );
7160
- if (page == NULL ) {
7151
+ page = kvm_vcpu_gpa_to_page (vcpu , vmptr );
7152
+ if (is_error_page ( page ) ) {
7161
7153
nested_vmx_failInvalid (vcpu );
7162
7154
return kvm_skip_emulated_instruction (vcpu );
7163
7155
}
@@ -7625,8 +7617,8 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
7625
7617
if (vmx -> nested .current_vmptr != vmptr ) {
7626
7618
struct vmcs12 * new_vmcs12 ;
7627
7619
struct page * page ;
7628
- page = nested_get_page (vcpu , vmptr );
7629
- if (page == NULL ) {
7620
+ page = kvm_vcpu_gpa_to_page (vcpu , vmptr );
7621
+ if (is_error_page ( page ) ) {
7630
7622
nested_vmx_failInvalid (vcpu );
7631
7623
return kvm_skip_emulated_instruction (vcpu );
7632
7624
}
@@ -9632,6 +9624,7 @@ static void nested_get_vmcs12_pages(struct kvm_vcpu *vcpu,
9632
9624
struct vmcs12 * vmcs12 )
9633
9625
{
9634
9626
struct vcpu_vmx * vmx = to_vmx (vcpu );
9627
+ struct page * page ;
9635
9628
u64 hpa ;
9636
9629
9637
9630
if (nested_cpu_has2 (vmcs12 , SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES )) {
@@ -9641,17 +9634,19 @@ static void nested_get_vmcs12_pages(struct kvm_vcpu *vcpu,
9641
9634
* physical address remains valid. We keep a reference
9642
9635
* to it so we can release it later.
9643
9636
*/
9644
- if (vmx -> nested .apic_access_page ) /* shouldn't happen */
9637
+ if (vmx -> nested .apic_access_page ) { /* shouldn't happen */
9645
9638
nested_release_page (vmx -> nested .apic_access_page );
9646
- vmx -> nested .apic_access_page =
9647
- nested_get_page (vcpu , vmcs12 -> apic_access_addr );
9639
+ vmx -> nested .apic_access_page = NULL ;
9640
+ }
9641
+ page = kvm_vcpu_gpa_to_page (vcpu , vmcs12 -> apic_access_addr );
9648
9642
/*
9649
9643
* If translation failed, no matter: This feature asks
9650
9644
* to exit when accessing the given address, and if it
9651
9645
* can never be accessed, this feature won't do
9652
9646
* anything anyway.
9653
9647
*/
9654
- if (vmx -> nested .apic_access_page ) {
9648
+ if (!is_error_page (page )) {
9649
+ vmx -> nested .apic_access_page = page ;
9655
9650
hpa = page_to_phys (vmx -> nested .apic_access_page );
9656
9651
vmcs_write64 (APIC_ACCESS_ADDR , hpa );
9657
9652
} else {
@@ -9666,10 +9661,11 @@ static void nested_get_vmcs12_pages(struct kvm_vcpu *vcpu,
9666
9661
}
9667
9662
9668
9663
if (nested_cpu_has (vmcs12 , CPU_BASED_TPR_SHADOW )) {
9669
- if (vmx -> nested .virtual_apic_page ) /* shouldn't happen */
9664
+ if (vmx -> nested .virtual_apic_page ) { /* shouldn't happen */
9670
9665
nested_release_page (vmx -> nested .virtual_apic_page );
9671
- vmx -> nested .virtual_apic_page =
9672
- nested_get_page (vcpu , vmcs12 -> virtual_apic_page_addr );
9666
+ vmx -> nested .virtual_apic_page = NULL ;
9667
+ }
9668
+ page = kvm_vcpu_gpa_to_page (vcpu , vmcs12 -> virtual_apic_page_addr );
9673
9669
9674
9670
/*
9675
9671
* If translation failed, VM entry will fail because
@@ -9684,7 +9680,8 @@ static void nested_get_vmcs12_pages(struct kvm_vcpu *vcpu,
9684
9680
* control. But such a configuration is useless, so
9685
9681
* let's keep the code simple.
9686
9682
*/
9687
- if (vmx -> nested .virtual_apic_page ) {
9683
+ if (!is_error_page (page )) {
9684
+ vmx -> nested .virtual_apic_page = page ;
9688
9685
hpa = page_to_phys (vmx -> nested .virtual_apic_page );
9689
9686
vmcs_write64 (VIRTUAL_APIC_PAGE_ADDR , hpa );
9690
9687
}
@@ -9694,15 +9691,13 @@ static void nested_get_vmcs12_pages(struct kvm_vcpu *vcpu,
9694
9691
if (vmx -> nested .pi_desc_page ) { /* shouldn't happen */
9695
9692
kunmap (vmx -> nested .pi_desc_page );
9696
9693
nested_release_page (vmx -> nested .pi_desc_page );
9694
+ vmx -> nested .pi_desc_page = NULL ;
9697
9695
}
9698
- vmx -> nested .pi_desc_page =
9699
- nested_get_page (vcpu , vmcs12 -> posted_intr_desc_addr );
9700
- vmx -> nested .pi_desc =
9701
- (struct pi_desc * )kmap (vmx -> nested .pi_desc_page );
9702
- if (!vmx -> nested .pi_desc ) {
9703
- nested_release_page_clean (vmx -> nested .pi_desc_page );
9696
+ page = kvm_vcpu_gpa_to_page (vcpu , vmcs12 -> posted_intr_desc_addr );
9697
+ if (is_error_page (page ))
9704
9698
return ;
9705
- }
9699
+ vmx -> nested .pi_desc_page = page ;
9700
+ vmx -> nested .pi_desc = kmap (vmx -> nested .pi_desc_page );
9706
9701
vmx -> nested .pi_desc =
9707
9702
(struct pi_desc * )((void * )vmx -> nested .pi_desc +
9708
9703
(unsigned long )(vmcs12 -> posted_intr_desc_addr &
@@ -9784,8 +9779,8 @@ static inline bool nested_vmx_merge_msr_bitmap(struct kvm_vcpu *vcpu,
9784
9779
if (!nested_cpu_has_virt_x2apic_mode (vmcs12 ))
9785
9780
return false;
9786
9781
9787
- page = nested_get_page (vcpu , vmcs12 -> msr_bitmap );
9788
- if (! page )
9782
+ page = kvm_vcpu_gpa_to_page (vcpu , vmcs12 -> msr_bitmap );
9783
+ if (is_error_page ( page ) )
9789
9784
return false;
9790
9785
msr_bitmap_l1 = (unsigned long * )kmap (page );
9791
9786
@@ -11392,8 +11387,8 @@ static int vmx_write_pml_buffer(struct kvm_vcpu *vcpu)
11392
11387
11393
11388
gpa = vmcs_read64 (GUEST_PHYSICAL_ADDRESS ) & ~0xFFFull ;
11394
11389
11395
- page = nested_get_page (vcpu , vmcs12 -> pml_address );
11396
- if (! page )
11390
+ page = kvm_vcpu_gpa_to_page (vcpu , vmcs12 -> pml_address );
11391
+ if (is_error_page ( page ) )
11397
11392
return 0 ;
11398
11393
11399
11394
pml_address = kmap (page );
0 commit comments