@@ -179,7 +179,7 @@ static int nested_vmx_failValid(struct kvm_vcpu *vcpu,
179179 * VM_INSTRUCTION_ERROR is not shadowed. Enlightened VMCS 'shadows' all
180180 * fields and thus must be synced.
181181 */
182- if (to_vmx (vcpu )-> nested . hv_evmcs_vmptr != EVMPTR_INVALID )
182+ if (nested_vmx_is_evmptr12_set ( to_vmx (vcpu )) )
183183 to_vmx (vcpu )-> nested .need_vmcs12_to_shadow_sync = true;
184184
185185 return kvm_skip_emulated_instruction (vcpu );
@@ -194,7 +194,7 @@ static int nested_vmx_fail(struct kvm_vcpu *vcpu, u32 vm_instruction_error)
194194 * can't be done if there isn't a current VMCS.
195195 */
196196 if (vmx -> nested .current_vmptr == INVALID_GPA &&
197- !evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
197+ !nested_vmx_is_evmptr12_valid (vmx ))
198198 return nested_vmx_failInvalid (vcpu );
199199
200200 return nested_vmx_failValid (vcpu , vm_instruction_error );
@@ -230,7 +230,7 @@ static inline void nested_release_evmcs(struct kvm_vcpu *vcpu)
230230 struct kvm_vcpu_hv * hv_vcpu = to_hv_vcpu (vcpu );
231231 struct vcpu_vmx * vmx = to_vmx (vcpu );
232232
233- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr )) {
233+ if (nested_vmx_is_evmptr12_valid (vmx )) {
234234 kvm_vcpu_unmap (vcpu , & vmx -> nested .hv_evmcs_map , true);
235235 vmx -> nested .hv_evmcs = NULL ;
236236 }
@@ -2123,7 +2123,7 @@ void nested_sync_vmcs12_to_shadow(struct kvm_vcpu *vcpu)
21232123{
21242124 struct vcpu_vmx * vmx = to_vmx (vcpu );
21252125
2126- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
2126+ if (nested_vmx_is_evmptr12_valid (vmx ))
21272127 copy_vmcs12_to_enlightened (vmx );
21282128 else
21292129 copy_vmcs12_to_shadow (vmx );
@@ -2277,7 +2277,7 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct loaded_vmcs *vmcs0
22772277 u32 exec_control ;
22782278 u64 guest_efer = nested_vmx_calc_efer (vmx , vmcs12 );
22792279
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 ))
22812281 prepare_vmcs02_early_rare (vmx , vmcs12 );
22822282
22832283 /*
@@ -2572,11 +2572,11 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
25722572 struct vcpu_vmx * vmx = to_vmx (vcpu );
25732573 bool load_guest_pdptrs_vmcs12 = false;
25742574
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 )) {
25762576 prepare_vmcs02_rare (vmx , vmcs12 );
25772577 vmx -> nested .dirty_vmcs12 = false;
25782578
2579- load_guest_pdptrs_vmcs12 = !evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ) ||
2579+ load_guest_pdptrs_vmcs12 = !nested_vmx_is_evmptr12_valid (vmx ) ||
25802580 !(vmx -> nested .hv_evmcs -> hv_clean_fields &
25812581 HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 );
25822582 }
@@ -2699,7 +2699,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
26992699 * bits when it changes a field in eVMCS. Mark all fields as clean
27002700 * here.
27012701 */
2702- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
2702+ if (nested_vmx_is_evmptr12_valid (vmx ))
27032703 vmx -> nested .hv_evmcs -> hv_clean_fields |=
27042704 HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL ;
27052705
@@ -3579,7 +3579,7 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
35793579
35803580 load_vmcs12_host_state (vcpu , vmcs12 );
35813581 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 ))
35833583 vmx -> nested .need_vmcs12_to_shadow_sync = true;
35843584 return NVMX_VMENTRY_VMEXIT ;
35853585}
@@ -3610,7 +3610,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
36103610 if (CC (evmptrld_status == EVMPTRLD_VMFAIL ))
36113611 return nested_vmx_failInvalid (vcpu );
36123612
3613- if (CC (!evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ) &&
3613+ if (CC (!nested_vmx_is_evmptr12_valid (vmx ) &&
36143614 vmx -> nested .current_vmptr == INVALID_GPA ))
36153615 return nested_vmx_failInvalid (vcpu );
36163616
@@ -3625,7 +3625,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
36253625 if (CC (vmcs12 -> hdr .shadow_vmcs ))
36263626 return nested_vmx_failInvalid (vcpu );
36273627
3628- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr )) {
3628+ if (nested_vmx_is_evmptr12_valid (vmx )) {
36293629 copy_enlightened_to_vmcs12 (vmx , vmx -> nested .hv_evmcs -> hv_clean_fields );
36303630 /* Enlightened VMCS doesn't have launch state */
36313631 vmcs12 -> launch_state = !launch ;
@@ -4370,11 +4370,11 @@ static void sync_vmcs02_to_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
43704370{
43714371 struct vcpu_vmx * vmx = to_vmx (vcpu );
43724372
4373- if (evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr ))
4373+ if (nested_vmx_is_evmptr12_valid (vmx ))
43744374 sync_vmcs02_to_vmcs12_rare (vcpu , vmcs12 );
43754375
43764376 vmx -> nested .need_sync_vmcs02_to_vmcs12_rare =
4377- !evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr );
4377+ !nested_vmx_is_evmptr12_valid (vmx );
43784378
43794379 vmcs12 -> guest_cr0 = vmcs12_guest_cr0 (vcpu , vmcs12 );
43804380 vmcs12 -> guest_cr4 = vmcs12_guest_cr4 (vcpu , vmcs12 );
@@ -4897,7 +4897,7 @@ void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
48974897 }
48984898
48994899 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 )))
49014901 vmx -> nested .need_vmcs12_to_shadow_sync = true;
49024902
49034903 /* in case we halted in L2 */
@@ -5390,7 +5390,7 @@ static int handle_vmread(struct kvm_vcpu *vcpu)
53905390 /* Decode instruction info and find the field to read */
53915391 field = kvm_register_read (vcpu , (((instr_info ) >> 28 ) & 0xf ));
53925392
5393- if (!evmptr_is_valid (vmx -> nested . hv_evmcs_vmptr )) {
5393+ if (!nested_vmx_is_evmptr12_valid (vmx )) {
53945394 /*
53955395 * In VMX non-root operation, when the VMCS-link pointer is INVALID_GPA,
53965396 * any VMREAD sets the ALU flags for VMfailInvalid.
@@ -5616,7 +5616,7 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
56165616 return nested_vmx_fail (vcpu , VMXERR_VMPTRLD_VMXON_POINTER );
56175617
56185618 /* 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 ))
56205620 return 1 ;
56215621
56225622 if (vmx -> nested .current_vmptr != vmptr ) {
@@ -5679,7 +5679,7 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu)
56795679 if (!nested_vmx_check_permission (vcpu ))
56805680 return 1 ;
56815681
5682- if (unlikely (evmptr_is_valid (to_vmx (vcpu )-> nested . hv_evmcs_vmptr )))
5682+ if (unlikely (nested_vmx_is_evmptr12_valid (to_vmx (vcpu ))))
56835683 return 1 ;
56845684
56855685 if (get_vmx_mem_address (vcpu , exit_qual , instr_info ,
@@ -6467,7 +6467,7 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu,
64676467 kvm_state .size += sizeof (user_vmx_nested_state -> vmcs12 );
64686468
64696469 /* '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 ) )
64716471 kvm_state .flags |= KVM_STATE_NESTED_EVMCS ;
64726472
64736473 if (is_guest_mode (vcpu ) &&
@@ -6523,7 +6523,7 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu,
65236523 } else {
65246524 copy_vmcs02_to_vmcs12_rare (vcpu , get_vmcs12 (vcpu ));
65256525 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 ))
65276527 /*
65286528 * L1 hypervisor is not obliged to keep eVMCS
65296529 * clean fields data always up-to-date while
0 commit comments