@@ -8423,8 +8423,10 @@ static void vmx_disable_shadow_vmcs(struct vcpu_vmx *vmx)
8423
8423
vmcs_write64 (VMCS_LINK_POINTER , -1ull );
8424
8424
}
8425
8425
8426
- static inline void nested_release_vmcs12 (struct vcpu_vmx * vmx )
8426
+ static inline void nested_release_vmcs12 (struct kvm_vcpu * vcpu )
8427
8427
{
8428
+ struct vcpu_vmx * vmx = to_vmx (vcpu );
8429
+
8428
8430
if (vmx -> nested .current_vmptr == -1ull )
8429
8431
return ;
8430
8432
@@ -8438,19 +8440,23 @@ static inline void nested_release_vmcs12(struct vcpu_vmx *vmx)
8438
8440
vmx -> nested .posted_intr_nv = -1 ;
8439
8441
8440
8442
/* Flush VMCS12 to guest memory */
8441
- kvm_vcpu_write_guest_page (& vmx -> vcpu ,
8443
+ kvm_vcpu_write_guest_page (vcpu ,
8442
8444
vmx -> nested .current_vmptr >> PAGE_SHIFT ,
8443
8445
vmx -> nested .cached_vmcs12 , 0 , VMCS12_SIZE );
8444
8446
8447
+ kvm_mmu_free_roots (vcpu , & vcpu -> arch .guest_mmu , KVM_MMU_ROOTS_ALL );
8448
+
8445
8449
vmx -> nested .current_vmptr = -1ull ;
8446
8450
}
8447
8451
8448
8452
/*
8449
8453
* Free whatever needs to be freed from vmx->nested when L1 goes down, or
8450
8454
* just stops using VMX.
8451
8455
*/
8452
- static void free_nested (struct vcpu_vmx * vmx )
8456
+ static void free_nested (struct kvm_vcpu * vcpu )
8453
8457
{
8458
+ struct vcpu_vmx * vmx = to_vmx (vcpu );
8459
+
8454
8460
if (!vmx -> nested .vmxon && !vmx -> nested .smm .vmxon )
8455
8461
return ;
8456
8462
@@ -8483,6 +8489,8 @@ static void free_nested(struct vcpu_vmx *vmx)
8483
8489
vmx -> nested .pi_desc = NULL ;
8484
8490
}
8485
8491
8492
+ kvm_mmu_free_roots (vcpu , & vcpu -> arch .guest_mmu , KVM_MMU_ROOTS_ALL );
8493
+
8486
8494
free_loaded_vmcs (& vmx -> nested .vmcs02 );
8487
8495
}
8488
8496
@@ -8491,7 +8499,7 @@ static int handle_vmoff(struct kvm_vcpu *vcpu)
8491
8499
{
8492
8500
if (!nested_vmx_check_permission (vcpu ))
8493
8501
return 1 ;
8494
- free_nested (to_vmx ( vcpu ) );
8502
+ free_nested (vcpu );
8495
8503
return nested_vmx_succeed (vcpu );
8496
8504
}
8497
8505
@@ -8517,7 +8525,7 @@ static int handle_vmclear(struct kvm_vcpu *vcpu)
8517
8525
VMXERR_VMCLEAR_VMXON_POINTER );
8518
8526
8519
8527
if (vmptr == vmx -> nested .current_vmptr )
8520
- nested_release_vmcs12 (vmx );
8528
+ nested_release_vmcs12 (vcpu );
8521
8529
8522
8530
kvm_vcpu_write_guest (vcpu ,
8523
8531
vmptr + offsetof(struct vmcs12 , launch_state ),
@@ -8872,7 +8880,8 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
8872
8880
VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID );
8873
8881
}
8874
8882
8875
- nested_release_vmcs12 (vmx );
8883
+ nested_release_vmcs12 (vcpu );
8884
+
8876
8885
/*
8877
8886
* Load VMCS12 from guest memory since it is not already
8878
8887
* cached.
@@ -10928,12 +10937,10 @@ static void vmx_switch_vmcs(struct kvm_vcpu *vcpu, struct loaded_vmcs *vmcs)
10928
10937
*/
10929
10938
static void vmx_free_vcpu_nested (struct kvm_vcpu * vcpu )
10930
10939
{
10931
- struct vcpu_vmx * vmx = to_vmx (vcpu );
10932
-
10933
- vcpu_load (vcpu );
10934
- vmx_switch_vmcs (vcpu , & vmx -> vmcs01 );
10935
- free_nested (vmx );
10936
- vcpu_put (vcpu );
10940
+ vcpu_load (vcpu );
10941
+ vmx_switch_vmcs (vcpu , & to_vmx (vcpu )-> vmcs01 );
10942
+ free_nested (vcpu );
10943
+ vcpu_put (vcpu );
10937
10944
}
10938
10945
10939
10946
static void vmx_free_vcpu (struct kvm_vcpu * vcpu )
@@ -11300,6 +11307,7 @@ static void nested_ept_init_mmu_context(struct kvm_vcpu *vcpu)
11300
11307
{
11301
11308
WARN_ON (mmu_is_nested (vcpu ));
11302
11309
11310
+ vcpu -> arch .mmu = & vcpu -> arch .guest_mmu ;
11303
11311
kvm_init_shadow_ept_mmu (vcpu ,
11304
11312
to_vmx (vcpu )-> nested .msrs .ept_caps &
11305
11313
VMX_EPT_EXECUTE_ONLY_BIT ,
@@ -11315,6 +11323,7 @@ static void nested_ept_init_mmu_context(struct kvm_vcpu *vcpu)
11315
11323
11316
11324
static void nested_ept_uninit_mmu_context (struct kvm_vcpu * vcpu )
11317
11325
{
11326
+ vcpu -> arch .mmu = & vcpu -> arch .root_mmu ;
11318
11327
vcpu -> arch .walk_mmu = & vcpu -> arch .root_mmu ;
11319
11328
}
11320
11329
@@ -13731,7 +13740,7 @@ static void vmx_leave_nested(struct kvm_vcpu *vcpu)
13731
13740
to_vmx (vcpu )-> nested .nested_run_pending = 0 ;
13732
13741
nested_vmx_vmexit (vcpu , -1 , 0 , 0 );
13733
13742
}
13734
- free_nested (to_vmx ( vcpu ) );
13743
+ free_nested (vcpu );
13735
13744
}
13736
13745
13737
13746
static int vmx_check_intercept (struct kvm_vcpu * vcpu ,
0 commit comments