@@ -8219,6 +8219,10 @@ static bool nested_vmx_exit_reflected(struct kvm_vcpu *vcpu, u32 exit_reason)
8219
8219
* table is L0's fault.
8220
8220
*/
8221
8221
return false;
8222
+ case EXIT_REASON_INVPCID :
8223
+ return
8224
+ nested_cpu_has2 (vmcs12 , SECONDARY_EXEC_ENABLE_INVPCID ) &&
8225
+ nested_cpu_has (vmcs12 , CPU_BASED_INVLPG_EXITING );
8222
8226
case EXIT_REASON_WBINVD :
8223
8227
return nested_cpu_has2 (vmcs12 , SECONDARY_EXEC_WBINVD_EXITING );
8224
8228
case EXIT_REASON_XSETBV :
@@ -9469,7 +9473,6 @@ static void nested_vmx_cr_fixed1_bits_update(struct kvm_vcpu *vcpu)
9469
9473
9470
9474
static void vmx_cpuid_update (struct kvm_vcpu * vcpu )
9471
9475
{
9472
- struct kvm_cpuid_entry2 * best ;
9473
9476
struct vcpu_vmx * vmx = to_vmx (vcpu );
9474
9477
u32 secondary_exec_ctl = vmx_secondary_exec_control (vmx );
9475
9478
@@ -9488,15 +9491,27 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
9488
9491
}
9489
9492
}
9490
9493
9491
- /* Exposing INVPCID only when PCID is exposed */
9492
- best = kvm_find_cpuid_entry ( vcpu , 0x7 , 0 );
9493
- if ( vmx_invpcid_supported () &&
9494
- (! best || !( best -> ebx & bit ( X86_FEATURE_INVPCID )) ||
9495
- ! guest_cpuid_has_pcid ( vcpu ))) {
9496
- secondary_exec_ctl &= ~ SECONDARY_EXEC_ENABLE_INVPCID ;
9494
+ if ( vmx_invpcid_supported ()) {
9495
+ /* Exposing INVPCID only when PCID is exposed */
9496
+ struct kvm_cpuid_entry2 * best = kvm_find_cpuid_entry ( vcpu , 0x7 , 0 );
9497
+ bool invpcid_enabled =
9498
+ best && best -> ebx & bit ( X86_FEATURE_INVPCID ) &&
9499
+ guest_cpuid_has_pcid ( vcpu ) ;
9497
9500
9498
- if (best )
9499
- best -> ebx &= ~bit (X86_FEATURE_INVPCID );
9501
+ if (!invpcid_enabled ) {
9502
+ secondary_exec_ctl &= ~SECONDARY_EXEC_ENABLE_INVPCID ;
9503
+ if (best )
9504
+ best -> ebx &= ~bit (X86_FEATURE_INVPCID );
9505
+ }
9506
+
9507
+ if (nested ) {
9508
+ if (invpcid_enabled )
9509
+ vmx -> nested .nested_vmx_secondary_ctls_high |=
9510
+ SECONDARY_EXEC_ENABLE_INVPCID ;
9511
+ else
9512
+ vmx -> nested .nested_vmx_secondary_ctls_high &=
9513
+ ~SECONDARY_EXEC_ENABLE_INVPCID ;
9514
+ }
9500
9515
}
9501
9516
9502
9517
if (cpu_has_secondary_exec_ctrls ())
@@ -10198,6 +10213,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
10198
10213
10199
10214
/* Take the following fields only from vmcs12 */
10200
10215
exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
10216
+ SECONDARY_EXEC_ENABLE_INVPCID |
10201
10217
SECONDARY_EXEC_RDTSCP |
10202
10218
SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
10203
10219
SECONDARY_EXEC_APIC_REGISTER_VIRT );
0 commit comments