@@ -179,7 +179,7 @@ static int nested_vmx_failValid(struct kvm_vcpu *vcpu,
179
179
* VM_INSTRUCTION_ERROR is not shadowed. Enlightened VMCS 'shadows' all
180
180
* fields and thus must be synced.
181
181
*/
182
- if (to_vmx (vcpu )-> nested . hv_evmcs_vmptr != EVMPTR_INVALID )
182
+ if (nested_vmx_is_evmptr12_set ( to_vmx (vcpu )) )
183
183
to_vmx (vcpu )-> nested .need_vmcs12_to_shadow_sync = true;
184
184
185
185
return kvm_skip_emulated_instruction (vcpu );
@@ -194,7 +194,7 @@ static int nested_vmx_fail(struct kvm_vcpu *vcpu, u32 vm_instruction_error)
194
194
* can't be done if there isn't a current VMCS.
195
195
*/
196
196
if (vmx -> nested .current_vmptr == INVALID_GPA &&
197
- !evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
197
+ !nested_vmx_is_evmptr12_valid (vmx ))
198
198
return nested_vmx_failInvalid (vcpu );
199
199
200
200
return nested_vmx_failValid (vcpu , vm_instruction_error );
@@ -230,7 +230,7 @@ static inline void nested_release_evmcs(struct kvm_vcpu *vcpu)
230
230
struct kvm_vcpu_hv * hv_vcpu = to_hv_vcpu (vcpu );
231
231
struct vcpu_vmx * vmx = to_vmx (vcpu );
232
232
233
- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr )) {
233
+ if (nested_vmx_is_evmptr12_valid (vmx )) {
234
234
kvm_vcpu_unmap (vcpu , & vmx -> nested .hv_evmcs_map , true);
235
235
vmx -> nested .hv_evmcs = NULL ;
236
236
}
@@ -2123,7 +2123,7 @@ void nested_sync_vmcs12_to_shadow(struct kvm_vcpu *vcpu)
2123
2123
{
2124
2124
struct vcpu_vmx * vmx = to_vmx (vcpu );
2125
2125
2126
- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
2126
+ if (nested_vmx_is_evmptr12_valid (vmx ))
2127
2127
copy_vmcs12_to_enlightened (vmx );
2128
2128
else
2129
2129
copy_vmcs12_to_shadow (vmx );
@@ -2277,7 +2277,7 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct loaded_vmcs *vmcs0
2277
2277
u32 exec_control ;
2278
2278
u64 guest_efer = nested_vmx_calc_efer (vmx , vmcs12 );
2279
2279
2280
- if (vmx -> nested .dirty_vmcs12 || evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
2280
+ if (vmx -> nested .dirty_vmcs12 || nested_vmx_is_evmptr12_valid (vmx ))
2281
2281
prepare_vmcs02_early_rare (vmx , vmcs12 );
2282
2282
2283
2283
/*
@@ -2572,11 +2572,11 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
2572
2572
struct vcpu_vmx * vmx = to_vmx (vcpu );
2573
2573
bool load_guest_pdptrs_vmcs12 = false;
2574
2574
2575
- if (vmx -> nested .dirty_vmcs12 || evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr )) {
2575
+ if (vmx -> nested .dirty_vmcs12 || nested_vmx_is_evmptr12_valid (vmx )) {
2576
2576
prepare_vmcs02_rare (vmx , vmcs12 );
2577
2577
vmx -> nested .dirty_vmcs12 = false;
2578
2578
2579
- load_guest_pdptrs_vmcs12 = !evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ) ||
2579
+ load_guest_pdptrs_vmcs12 = !nested_vmx_is_evmptr12_valid (vmx ) ||
2580
2580
!(vmx -> nested .hv_evmcs -> hv_clean_fields &
2581
2581
HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 );
2582
2582
}
@@ -2699,7 +2699,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
2699
2699
* bits when it changes a field in eVMCS. Mark all fields as clean
2700
2700
* here.
2701
2701
*/
2702
- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
2702
+ if (nested_vmx_is_evmptr12_valid (vmx ))
2703
2703
vmx -> nested .hv_evmcs -> hv_clean_fields |=
2704
2704
HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;
2705
2705
@@ -3579,7 +3579,7 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
3579
3579
3580
3580
load_vmcs12_host_state (vcpu , vmcs12 );
3581
3581
vmcs12 -> vm_exit_reason = exit_reason .full ;
3582
- if (enable_shadow_vmcs || evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
3582
+ if (enable_shadow_vmcs || nested_vmx_is_evmptr12_valid (vmx ))
3583
3583
vmx -> nested .need_vmcs12_to_shadow_sync = true;
3584
3584
return NVMX_VMENTRY_VMEXIT ;
3585
3585
}
@@ -3610,7 +3610,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
3610
3610
if (CC (evmptrld_status == EVMPTRLD_VMFAIL ))
3611
3611
return nested_vmx_failInvalid (vcpu );
3612
3612
3613
- if (CC (!evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ) &&
3613
+ if (CC (!nested_vmx_is_evmptr12_valid (vmx ) &&
3614
3614
vmx -> nested .current_vmptr == INVALID_GPA ))
3615
3615
return nested_vmx_failInvalid (vcpu );
3616
3616
@@ -3625,7 +3625,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
3625
3625
if (CC (vmcs12 -> hdr .shadow_vmcs ))
3626
3626
return nested_vmx_failInvalid (vcpu );
3627
3627
3628
- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr )) {
3628
+ if (nested_vmx_is_evmptr12_valid (vmx )) {
3629
3629
copy_enlightened_to_vmcs12 (vmx , vmx -> nested .hv_evmcs -> hv_clean_fields );
3630
3630
/* Enlightened VMCS doesn't have launch state */
3631
3631
vmcs12 -> launch_state = !launch ;
@@ -4370,11 +4370,11 @@ static void sync_vmcs02_to_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
4370
4370
{
4371
4371
struct vcpu_vmx * vmx = to_vmx (vcpu );
4372
4372
4373
- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
4373
+ if (nested_vmx_is_evmptr12_valid (vmx ))
4374
4374
sync_vmcs02_to_vmcs12_rare (vcpu , vmcs12 );
4375
4375
4376
4376
vmx -> nested .need_sync_vmcs02_to_vmcs12_rare =
4377
- !evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr );
4377
+ !nested_vmx_is_evmptr12_valid (vmx );
4378
4378
4379
4379
vmcs12 -> guest_cr0 = vmcs12_guest_cr0 (vcpu , vmcs12 );
4380
4380
vmcs12 -> guest_cr4 = vmcs12_guest_cr4 (vcpu , vmcs12 );
@@ -4897,7 +4897,7 @@ void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
4897
4897
}
4898
4898
4899
4899
if ((vm_exit_reason != -1 ) &&
4900
- (enable_shadow_vmcs || evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr )))
4900
+ (enable_shadow_vmcs || nested_vmx_is_evmptr12_valid (vmx )))
4901
4901
vmx -> nested .need_vmcs12_to_shadow_sync = true;
4902
4902
4903
4903
/* in case we halted in L2 */
@@ -5390,7 +5390,7 @@ static int handle_vmread(struct kvm_vcpu *vcpu)
5390
5390
/* Decode instruction info and find the field to read */
5391
5391
field = kvm_register_read (vcpu , (((instr_info ) >> 28 ) & 0xf ));
5392
5392
5393
- if (!evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr )) {
5393
+ if (!nested_vmx_is_evmptr12_valid (vmx )) {
5394
5394
/*
5395
5395
* In VMX non-root operation, when the VMCS-link pointer is INVALID_GPA,
5396
5396
* any VMREAD sets the ALU flags for VMfailInvalid.
@@ -5616,7 +5616,7 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
5616
5616
return nested_vmx_fail (vcpu , VMXERR_VMPTRLD_VMXON_POINTER );
5617
5617
5618
5618
/* Forbid normal VMPTRLD if Enlightened version was used */
5619
- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
5619
+ if (nested_vmx_is_evmptr12_valid (vmx ))
5620
5620
return 1 ;
5621
5621
5622
5622
if (vmx -> nested .current_vmptr != vmptr ) {
@@ -5679,7 +5679,7 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu)
5679
5679
if (!nested_vmx_check_permission (vcpu ))
5680
5680
return 1 ;
5681
5681
5682
- if (unlikely (evmptr_is_valid (to_vmx (vcpu )-> nested . hv_evmcs_vmptr )))
5682
+ if (unlikely (nested_vmx_is_evmptr12_valid (to_vmx (vcpu ))))
5683
5683
return 1 ;
5684
5684
5685
5685
if (get_vmx_mem_address (vcpu , exit_qual , instr_info ,
@@ -6467,7 +6467,7 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu,
6467
6467
kvm_state .size += sizeof (user_vmx_nested_state -> vmcs12 );
6468
6468
6469
6469
/* 'hv_evmcs_vmptr' can also be EVMPTR_MAP_PENDING here */
6470
- if (vmx -> nested . hv_evmcs_vmptr != EVMPTR_INVALID )
6470
+ if (nested_vmx_is_evmptr12_set ( vmx ) )
6471
6471
kvm_state .flags |= KVM_STATE_NESTED_EVMCS ;
6472
6472
6473
6473
if (is_guest_mode (vcpu ) &&
@@ -6523,7 +6523,7 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu,
6523
6523
} else {
6524
6524
copy_vmcs02_to_vmcs12_rare (vcpu , get_vmcs12 (vcpu ));
6525
6525
if (!vmx -> nested .need_vmcs12_to_shadow_sync ) {
6526
- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
6526
+ if (nested_vmx_is_evmptr12_valid (vmx ))
6527
6527
/*
6528
6528
* L1 hypervisor is not obliged to keep eVMCS
6529
6529
* clean fields data always up-to-date while
0 commit comments