Lines Matching full:nested

13 #include "nested.h"
183 to_vmx(vcpu)->nested.need_vmcs12_to_shadow_sync = true; in nested_vmx_failValid()
196 if (vmx->nested.current_vmptr == INVALID_GPA && in nested_vmx_fail()
207 pr_debug_ratelimited("nested vmx abort, indicator %d\n", indicator); in nested_vmx_abort()
224 vmx->nested.need_vmcs12_to_shadow_sync = false; in vmx_disable_shadow_vmcs()
234 kvm_vcpu_unmap(vcpu, &vmx->nested.hv_evmcs_map, true); in nested_release_evmcs()
235 vmx->nested.hv_evmcs = NULL; in nested_release_evmcs()
238 vmx->nested.hv_evmcs_vmptr = EVMPTR_INVALID; in nested_release_evmcs()
241 hv_vcpu->nested.pa_page_gpa = INVALID_GPA; in nested_release_evmcs()
242 hv_vcpu->nested.vm_id = 0; in nested_release_evmcs()
243 hv_vcpu->nested.vp_id = 0; in nested_release_evmcs()
260 * vmx->nested.hv_evmcs but this shouldn't be a problem. in nested_evmcs_handle_vmclear()
266 if (nested_vmx_evmcs(vmx) && vmptr == vmx->nested.hv_evmcs_vmptr) in nested_evmcs_handle_vmclear()
320 * Free whatever needs to be freed from vmx->nested when L1 goes down, or
330 if (!vmx->nested.vmxon && !vmx->nested.smm.vmxon) in free_nested()
335 vmx->nested.vmxon = false; in free_nested()
336 vmx->nested.smm.vmxon = false; in free_nested()
337 vmx->nested.vmxon_ptr = INVALID_GPA; in free_nested()
338 free_vpid(vmx->nested.vpid02); in free_nested()
339 vmx->nested.posted_intr_nv = -1; in free_nested()
340 vmx->nested.current_vmptr = INVALID_GPA; in free_nested()
347 kfree(vmx->nested.cached_vmcs12); in free_nested()
348 vmx->nested.cached_vmcs12 = NULL; in free_nested()
349 kfree(vmx->nested.cached_shadow_vmcs12); in free_nested()
350 vmx->nested.cached_shadow_vmcs12 = NULL; in free_nested()
356 kvm_vcpu_unmap(vcpu, &vmx->nested.apic_access_page_map, false); in free_nested()
357 kvm_vcpu_unmap(vcpu, &vmx->nested.virtual_apic_map, true); in free_nested()
358 kvm_vcpu_unmap(vcpu, &vmx->nested.pi_desc_map, true); in free_nested()
359 vmx->nested.pi_desc = NULL; in free_nested()
365 free_loaded_vmcs(&vmx->nested.vmcs02); in free_nested()
415 if (vmx->nested.pml_full) { in nested_ept_inject_page_fault()
417 vmx->nested.pml_full = false; in nested_ept_inject_page_fault()
443 bool execonly = vmx->nested.msrs.ept_caps & VMX_EPT_EXECUTE_ONLY_BIT; in nested_ept_new_eptp()
444 int ept_lpage_level = ept_caps_to_lpage_level(vmx->nested.msrs.ept_caps); in nested_ept_new_eptp()
603 unsigned long *msr_bitmap_l0 = vmx->nested.vmcs02.msr_bitmap; in nested_vmx_prepare_msr_bitmap()
604 struct kvm_host_map *map = &vmx->nested.msr_bitmap_map; in nested_vmx_prepare_msr_bitmap()
614 * - Nested hypervisor (L1) is attempting to launch the same L2 as in nested_vmx_prepare_msr_bitmap()
616 * - Nested hypervisor (L1) has enabled 'Enlightened MSR Bitmap' feature in nested_vmx_prepare_msr_bitmap()
619 if (!vmx->nested.force_msr_bitmap_recalc) { in nested_vmx_prepare_msr_bitmap()
694 kvm_vcpu_unmap(vcpu, &vmx->nested.msr_bitmap_map, false); in nested_vmx_prepare_msr_bitmap()
696 vmx->nested.force_msr_bitmap_recalc = false; in nested_vmx_prepare_msr_bitmap()
705 struct gfn_to_hva_cache *ghc = &vmx->nested.shadow_vmcs12_cache; in nested_cache_shadow_vmcs12()
724 struct gfn_to_hva_cache *ghc = &vmx->nested.shadow_vmcs12_cache; in nested_flush_cached_shadow_vmcs12()
740 * In nested virtualization, check if L1 has set
923 u64 vmx_misc = vmx_control_msr(vmx->nested.msrs.misc_low, in nested_vmx_max_atomic_switch_msrs()
924 vmx->nested.msrs.misc_high); in nested_vmx_max_atomic_switch_msrs()
930 * Load guest's/host's msr at nested entry/exit.
1110 * Load guest's/host's cr3 at nested entry/exit. @nested_ept is true if we are
1157 * while L2 entries are tagged with vmx->nested.vpid02).
1164 (nested_cpu_has_vpid(vmcs12) && to_vmx(vcpu)->nested.vpid02); in nested_has_guest_tlb_tag()
1183 * Note, using TLB_FLUSH_GUEST is correct even if nested EPT is in use. in nested_vmx_transition_tlb_flush()
1205 if (is_vmenter && vmcs12->virtual_processor_id != vmx->nested.last_vpid) { in nested_vmx_transition_tlb_flush()
1206 vmx->nested.last_vpid = vmcs12->virtual_processor_id; in nested_vmx_transition_tlb_flush()
1236 u64 vmx_basic = vmcs_config.nested.basic; in vmx_restore_vmx_basic()
1255 vmx->nested.msrs.basic = data; in vmx_restore_vmx_basic()
1294 vmx_get_control_msr(&vmcs_config.nested, msr_index, &lowp, &highp); in vmx_restore_control_msr()
1306 vmx_get_control_msr(&vmx->nested.msrs, msr_index, &lowp, &highp); in vmx_restore_control_msr()
1320 u64 vmx_misc = vmx_control_msr(vmcs_config.nested.misc_low, in vmx_restore_vmx_misc()
1321 vmcs_config.nested.misc_high); in vmx_restore_vmx_misc()
1326 if ((vmx->nested.msrs.pinbased_ctls_high & in vmx_restore_vmx_misc()
1341 vmx->nested.msrs.misc_low = data; in vmx_restore_vmx_misc()
1342 vmx->nested.msrs.misc_high = data >> 32; in vmx_restore_vmx_misc()
1349 u64 vmx_ept_vpid_cap = vmx_control_msr(vmcs_config.nested.ept_caps, in vmx_restore_vmx_ept_vpid_cap()
1350 vmcs_config.nested.vpid_caps); in vmx_restore_vmx_ept_vpid_cap()
1356 vmx->nested.msrs.ept_caps = data; in vmx_restore_vmx_ept_vpid_cap()
1357 vmx->nested.msrs.vpid_caps = data >> 32; in vmx_restore_vmx_ept_vpid_cap()
1375 const u64 *msr = vmx_get_fixed0_msr(&vmcs_config.nested, msr_index); in vmx_restore_fixed0_msr()
1384 *vmx_get_fixed0_msr(&vmx->nested.msrs, msr_index) = data; in vmx_restore_fixed0_msr()
1401 if (vmx->nested.vmxon) in vmx_set_vmx_msr()
1442 vmx->nested.msrs.vmcs_enum = data; in vmx_set_vmx_msr()
1445 if (data & ~vmcs_config.nested.vmfunc_controls) in vmx_set_vmx_msr()
1447 vmx->nested.msrs.vmfunc_controls = data; in vmx_set_vmx_msr()
1607 struct vmcs12 *vmcs12 = vmx->nested.cached_vmcs12; in copy_enlightened_to_vmcs12()
1617 hv_vcpu->nested.pa_page_gpa = evmcs->partition_assist_page; in copy_enlightened_to_vmcs12()
1618 hv_vcpu->nested.vm_id = evmcs->hv_vm_id; in copy_enlightened_to_vmcs12()
1619 hv_vcpu->nested.vp_id = evmcs->hv_vp_id; in copy_enlightened_to_vmcs12()
1855 struct vmcs12 *vmcs12 = vmx->nested.cached_vmcs12; in copy_vmcs12_to_enlightened()
2031 * This is an equivalent of the nested hypervisor executing the vmptrld
2051 if (unlikely(evmcs_gpa != vmx->nested.hv_evmcs_vmptr)) { in nested_vmx_handle_enlightened_vmptrld()
2052 vmx->nested.current_vmptr = INVALID_GPA; in nested_vmx_handle_enlightened_vmptrld()
2057 &vmx->nested.hv_evmcs_map)) in nested_vmx_handle_enlightened_vmptrld()
2060 vmx->nested.hv_evmcs = vmx->nested.hv_evmcs_map.hva; in nested_vmx_handle_enlightened_vmptrld()
2084 if ((vmx->nested.hv_evmcs->revision_id != KVM_EVMCS_VERSION) && in nested_vmx_handle_enlightened_vmptrld()
2085 (vmx->nested.hv_evmcs->revision_id != VMCS12_REVISION)) { in nested_vmx_handle_enlightened_vmptrld()
2090 vmx->nested.hv_evmcs_vmptr = evmcs_gpa; in nested_vmx_handle_enlightened_vmptrld()
2112 vmx->nested.hv_evmcs->hv_clean_fields &= in nested_vmx_handle_enlightened_vmptrld()
2115 vmx->nested.force_msr_bitmap_recalc = true; in nested_vmx_handle_enlightened_vmptrld()
2133 vmx->nested.need_vmcs12_to_shadow_sync = false; in nested_sync_vmcs12_to_shadow()
2139 container_of(timer, struct vcpu_vmx, nested.preemption_timer); in vmx_preemption_timer_fn()
2141 vmx->nested.preemption_timer_expired = true; in vmx_preemption_timer_fn()
2156 if (!vmx->nested.has_preemption_timer_deadline) { in vmx_calc_preemption_timer_value()
2157 vmx->nested.preemption_timer_deadline = in vmx_calc_preemption_timer_value()
2159 vmx->nested.has_preemption_timer_deadline = true; in vmx_calc_preemption_timer_value()
2161 return vmx->nested.preemption_timer_deadline - l1_scaled_tsc; in vmx_calc_preemption_timer_value()
2174 vmx_preemption_timer_fn(&vmx->nested.preemption_timer); in vmx_start_preemption_timer()
2184 hrtimer_start(&vmx->nested.preemption_timer, in vmx_start_preemption_timer()
2191 if (vmx->nested.nested_run_pending && in nested_vmx_calc_efer()
2210 if (vmx->nested.vmcs02_initialized) in prepare_vmcs02_constant_state()
2212 vmx->nested.vmcs02_initialized = true; in prepare_vmcs02_constant_state()
2231 vmcs_write64(MSR_BITMAP, __pa(vmx->nested.vmcs02.msr_bitmap)); in prepare_vmcs02_constant_state()
2269 if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02) in prepare_vmcs02_early_rare()
2270 vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->nested.vpid02); in prepare_vmcs02_early_rare()
2282 if (vmx->nested.dirty_vmcs12 || nested_vmx_is_evmptr12_valid(vmx)) in prepare_vmcs02_early()
2293 vmx->nested.pi_pending = false; in prepare_vmcs02_early()
2295 vmx->nested.posted_intr_nv = vmcs12->posted_intr_nv; in prepare_vmcs02_early()
2309 vmx->nested.l1_tpr_threshold = -1; in prepare_vmcs02_early()
2425 if (vmx->nested.nested_run_pending) { in prepare_vmcs02_early()
2506 if (kvm_mpx_supported() && vmx->nested.nested_run_pending && in prepare_vmcs02_rare()
2560 * prepare_vmcs02 is called when the L1 guest hypervisor runs its nested
2578 if (vmx->nested.dirty_vmcs12 || nested_vmx_is_evmptr12_valid(vmx)) { in prepare_vmcs02()
2580 vmx->nested.dirty_vmcs12 = false; in prepare_vmcs02()
2586 if (vmx->nested.nested_run_pending && in prepare_vmcs02()
2592 vmcs_write64(GUEST_IA32_DEBUGCTL, vmx->nested.pre_vmenter_debugctl); in prepare_vmcs02()
2594 if (kvm_mpx_supported() && (!vmx->nested.nested_run_pending || in prepare_vmcs02()
2596 vmcs_write64(GUEST_BNDCFGS, vmx->nested.pre_vmenter_bndcfgs); in prepare_vmcs02()
2607 if (vmx->nested.nested_run_pending && in prepare_vmcs02()
2654 * loading nested state after migration, it is possible to in prepare_vmcs02()
2670 * on nested VM-Exit, which can occur without actually running L2 and in prepare_vmcs02()
2730 if (CC(!(vmx->nested.msrs.ept_caps & VMX_EPTP_UC_BIT))) in nested_vmx_check_eptp()
2734 if (CC(!(vmx->nested.msrs.ept_caps & VMX_EPTP_WB_BIT))) in nested_vmx_check_eptp()
2744 if (CC(!(vmx->nested.msrs.ept_caps & VMX_EPT_PAGE_WALK_5_BIT))) in nested_vmx_check_eptp()
2748 if (CC(!(vmx->nested.msrs.ept_caps & VMX_EPT_PAGE_WALK_4_BIT))) in nested_vmx_check_eptp()
2761 if (CC(!(vmx->nested.msrs.ept_caps & VMX_EPT_AD_BIT))) in nested_vmx_check_eptp()
2777 vmx->nested.msrs.pinbased_ctls_low, in nested_check_vm_execution_controls()
2778 vmx->nested.msrs.pinbased_ctls_high)) || in nested_check_vm_execution_controls()
2780 vmx->nested.msrs.procbased_ctls_low, in nested_check_vm_execution_controls()
2781 vmx->nested.msrs.procbased_ctls_high))) in nested_check_vm_execution_controls()
2786 vmx->nested.msrs.secondary_ctls_low, in nested_check_vm_execution_controls()
2787 vmx->nested.msrs.secondary_ctls_high))) in nested_check_vm_execution_controls()
2814 ~vmx->nested.msrs.vmfunc_controls)) in nested_check_vm_execution_controls()
2836 vmx->nested.msrs.exit_ctls_low, in nested_check_vm_exit_controls()
2837 vmx->nested.msrs.exit_ctls_high)) || in nested_check_vm_exit_controls()
2853 vmx->nested.msrs.entry_ctls_low, in nested_check_vm_entry_controls()
2854 vmx->nested.msrs.entry_ctls_high))) in nested_check_vm_entry_controls()
3019 struct gfn_to_hva_cache *ghc = &vmx->nested.shadow_vmcs12_cache; in nested_vmx_check_vmcs_link_ptr()
3104 if (to_vmx(vcpu)->nested.nested_run_pending && in nested_vmx_check_guest_state()
3213 vmx->nested.hv_evmcs_vmptr == EVMPTR_MAP_PENDING) { in nested_get_evmcs_page()
3225 vmx->nested.need_vmcs12_to_shadow_sync = true; in nested_get_evmcs_page()
3242 * the guest CR3 might be restored prior to setting the nested in nested_get_vmcs12_pages()
3251 map = &vmx->nested.apic_access_page_map; in nested_get_vmcs12_pages()
3267 map = &vmx->nested.virtual_apic_map; in nested_get_vmcs12_pages()
3293 map = &vmx->nested.pi_desc_map; in nested_get_vmcs12_pages()
3296 vmx->nested.pi_desc = in nested_get_vmcs12_pages()
3308 vmx->nested.pi_desc = NULL; in nested_get_vmcs12_pages()
3356 if (WARN_ON_ONCE(vmx->nested.pml_full)) in nested_vmx_write_pml_buffer()
3360 * Check if PML is enabled for the nested guest. Whether eptp bit 6 is in nested_vmx_write_pml_buffer()
3368 vmx->nested.pml_full = true; in nested_vmx_write_pml_buffer()
3393 if (!to_vmx(vcpu)->nested.vmxon) { in nested_vmx_check_permission()
3441 vmx->nested.current_vmptr, in nested_vmx_enter_non_root_mode()
3459 if (!vmx->nested.nested_run_pending || in nested_vmx_enter_non_root_mode()
3461 vmx->nested.pre_vmenter_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL); in nested_vmx_enter_non_root_mode()
3463 (!vmx->nested.nested_run_pending || in nested_vmx_enter_non_root_mode()
3465 vmx->nested.pre_vmenter_bndcfgs = vmcs_read64(GUEST_BNDCFGS); in nested_vmx_enter_non_root_mode()
3469 * nested early checks are disabled. In the event of a "late" VM-Fail, in nested_vmx_enter_non_root_mode()
3475 * the correct value. Smashing vmcs01.GUEST_CR3 is safe because nested in nested_vmx_enter_non_root_mode()
3478 * L1. Don't stuff vmcs01.GUEST_CR3 when using nested early checks as in nested_vmx_enter_non_root_mode()
3486 vmx_switch_vmcs(vcpu, &vmx->nested.vmcs02); in nested_vmx_enter_non_root_mode()
3551 vmx->nested.preemption_timer_expired = false; in nested_vmx_enter_non_root_mode()
3584 vmx->nested.need_vmcs12_to_shadow_sync = true; in nested_vmx_enter_non_root_mode()
3589 * nested_vmx_run() handles a nested entry, i.e., a VMLAUNCH or VMRESUME on L1
3590 * for running an L2 nested guest.
3615 vmx->nested.current_vmptr == INVALID_GPA)) in nested_vmx_run()
3640 * The nested entry process starts with enforcing various prerequisites in nested_vmx_run()
3668 * the nested entry. in nested_vmx_run()
3670 vmx->nested.nested_run_pending = 1; in nested_vmx_run()
3671 vmx->nested.has_preemption_timer_deadline = false; in nested_vmx_run()
3678 kvm_apic_has_interrupt(vcpu) == vmx->nested.posted_intr_nv) { in nested_vmx_run()
3679 vmx->nested.pi_pending = true; in nested_vmx_run()
3681 kvm_apic_clear_irr(vcpu, vmx->nested.posted_intr_nv); in nested_vmx_run()
3684 /* Hide L1D cache contents from the nested guest. */ in nested_vmx_run()
3710 vmx->nested.nested_run_pending = 0; in nested_vmx_run()
3715 vmx->nested.nested_run_pending = 0; in nested_vmx_run()
3725 vmx->nested.nested_run_pending = 0; in nested_vmx_run()
3735 * On a nested exit from L2 to L1, vmcs12.guest_cr0 might not be up-to-date
3866 if (!vmx->nested.pi_pending) in vmx_complete_nested_posted_interrupt()
3869 if (!vmx->nested.pi_desc) in vmx_complete_nested_posted_interrupt()
3872 vmx->nested.pi_pending = false; in vmx_complete_nested_posted_interrupt()
3874 if (!pi_test_and_clear_on(vmx->nested.pi_desc)) in vmx_complete_nested_posted_interrupt()
3877 max_irr = find_last_bit((unsigned long *)vmx->nested.pi_desc->pir, 256); in vmx_complete_nested_posted_interrupt()
3879 vapic_page = vmx->nested.virtual_apic_map.hva; in vmx_complete_nested_posted_interrupt()
3883 __kvm_apic_update_irr(vmx->nested.pi_desc->pir, in vmx_complete_nested_posted_interrupt()
3930 * hardware and avoid inducing failure on nested VM-Entry if L1 in nested_vmx_inject_exception_vmexit()
4006 to_vmx(vcpu)->nested.preemption_timer_expired; in nested_vmx_preemption_timer_pending()
4012 to_vmx(vcpu)->nested.mtf_pending; in vmx_has_nested_events()
4103 * Only a pending nested run blocks a pending exception. If there is a in vmx_check_nested_events()
4107 bool block_nested_exceptions = vmx->nested.nested_run_pending; in vmx_check_nested_events()
4127 vmx->nested.mtf_pending = false; in vmx_check_nested_events()
4171 if (vmx->nested.mtf_pending) { in vmx_check_nested_events()
4240 hrtimer_get_remaining(&to_vmx(vcpu)->nested.preemption_timer); in vmx_get_preemption_timer_value()
4340 vmx->nested.need_sync_vmcs02_to_vmcs12_rare = false; in sync_vmcs02_to_vmcs12_rare()
4349 if (!vmx->nested.need_sync_vmcs02_to_vmcs12_rare) in copy_vmcs02_to_vmcs12_rare()
4356 vmx->loaded_vmcs = &vmx->nested.vmcs02; in copy_vmcs02_to_vmcs12_rare()
4362 vmx_vcpu_load_vmcs(vcpu, cpu, &vmx->nested.vmcs02); in copy_vmcs02_to_vmcs12_rare()
4379 vmx->nested.need_sync_vmcs02_to_vmcs12_rare = in sync_vmcs02_to_vmcs12()
4404 !vmx->nested.nested_run_pending) in sync_vmcs02_to_vmcs12()
4409 * In some cases (usually, nested EPT), L2 is allowed to change its in sync_vmcs02_to_vmcs12()
4443 * prepare_vmcs12 is part of what we need to do when the nested L2 guest exits
4501 * A part of what we need to when the nested L2 guest exits and we want to
4504 * This function is to be called not only on normal nested exit, but also on
4505 * a nested entry failure, as explained in Intel's spec, 3B.23.7 ("VM-Entry
4672 * nested VMENTER (not worth adding a variable in nested_vmx). in nested_vmx_restore_host_state()
4710 * of VMFail), leaving the nested VM's MSRs in the software model in nested_vmx_restore_host_state()
4713 * MSR that was (prematurely) loaded from the nested VMEntry load in nested_vmx_restore_host_state()
4763 * Emulate an exit from nested guest (L2) to L1, i.e., prepare to run L1
4774 vmx->nested.mtf_pending = false; in nested_vmx_vmexit()
4777 WARN_ON_ONCE(vmx->nested.nested_run_pending); in nested_vmx_vmexit()
4805 hrtimer_cancel(&to_vmx(vcpu)->nested.preemption_timer); in nested_vmx_vmexit()
4873 if (vmx->nested.l1_tpr_threshold != -1) in nested_vmx_vmexit()
4874 vmcs_write32(TPR_THRESHOLD, vmx->nested.l1_tpr_threshold); in nested_vmx_vmexit()
4876 if (vmx->nested.change_vmcs01_virtual_apic_mode) { in nested_vmx_vmexit()
4877 vmx->nested.change_vmcs01_virtual_apic_mode = false; in nested_vmx_vmexit()
4881 if (vmx->nested.update_vmcs01_cpu_dirty_logging) { in nested_vmx_vmexit()
4882 vmx->nested.update_vmcs01_cpu_dirty_logging = false; in nested_vmx_vmexit()
4887 kvm_vcpu_unmap(vcpu, &vmx->nested.apic_access_page_map, false); in nested_vmx_vmexit()
4888 kvm_vcpu_unmap(vcpu, &vmx->nested.virtual_apic_map, true); in nested_vmx_vmexit()
4889 kvm_vcpu_unmap(vcpu, &vmx->nested.pi_desc_map, true); in nested_vmx_vmexit()
4890 vmx->nested.pi_desc = NULL; in nested_vmx_vmexit()
4892 if (vmx->nested.reload_vmcs01_apic_access_page) { in nested_vmx_vmexit()
4893 vmx->nested.reload_vmcs01_apic_access_page = false; in nested_vmx_vmexit()
4897 if (vmx->nested.update_vmcs01_apicv_status) { in nested_vmx_vmexit()
4898 vmx->nested.update_vmcs01_apicv_status = false; in nested_vmx_vmexit()
4904 vmx->nested.need_vmcs12_to_shadow_sync = true; in nested_vmx_vmexit()
5123 * when L1 executes VMXOFF or the vCPU is forced out of nested in alloc_shadow_vmcs()
5144 r = alloc_loaded_vmcs(&vmx->nested.vmcs02); in enter_vmx_operation()
5148 vmx->nested.cached_vmcs12 = kzalloc(VMCS12_SIZE, GFP_KERNEL_ACCOUNT); in enter_vmx_operation()
5149 if (!vmx->nested.cached_vmcs12) in enter_vmx_operation()
5152 vmx->nested.shadow_vmcs12_cache.gpa = INVALID_GPA; in enter_vmx_operation()
5153 vmx->nested.cached_shadow_vmcs12 = kzalloc(VMCS12_SIZE, GFP_KERNEL_ACCOUNT); in enter_vmx_operation()
5154 if (!vmx->nested.cached_shadow_vmcs12) in enter_vmx_operation()
5160 hrtimer_init(&vmx->nested.preemption_timer, CLOCK_MONOTONIC, in enter_vmx_operation()
5162 vmx->nested.preemption_timer.function = vmx_preemption_timer_fn; in enter_vmx_operation()
5164 vmx->nested.vpid02 = allocate_vpid(); in enter_vmx_operation()
5166 vmx->nested.vmcs02_initialized = false; in enter_vmx_operation()
5167 vmx->nested.vmxon = true; in enter_vmx_operation()
5177 kfree(vmx->nested.cached_shadow_vmcs12); in enter_vmx_operation()
5180 kfree(vmx->nested.cached_vmcs12); in enter_vmx_operation()
5183 free_loaded_vmcs(&vmx->nested.vmcs02); in enter_vmx_operation()
5235 if (vmx->nested.vmxon) in handle_vmxon()
5263 * Note - IA32_VMX_BASIC[48] will never be 1 for the nested case; in handle_vmxon()
5273 vmx->nested.vmxon_ptr = vmptr; in handle_vmxon()
5285 if (vmx->nested.current_vmptr == INVALID_GPA) in nested_release_vmcs12()
5296 vmx->nested.posted_intr_nv = -1; in nested_release_vmcs12()
5300 vmx->nested.current_vmptr >> PAGE_SHIFT, in nested_release_vmcs12()
5301 vmx->nested.cached_vmcs12, 0, VMCS12_SIZE); in nested_release_vmcs12()
5305 vmx->nested.current_vmptr = INVALID_GPA; in nested_release_vmcs12()
5339 if (vmptr == vmx->nested.vmxon_ptr) in handle_vmclear()
5343 if (vmptr == vmx->nested.current_vmptr) in handle_vmclear()
5402 if (vmx->nested.current_vmptr == INVALID_GPA || in handle_vmread()
5512 if (vmx->nested.current_vmptr == INVALID_GPA || in handle_vmwrite()
5584 vmx->nested.dirty_vmcs12 = true; in handle_vmwrite()
5592 vmx->nested.current_vmptr = vmptr; in set_current_vmptr()
5597 vmx->nested.need_vmcs12_to_shadow_sync = true; in set_current_vmptr()
5599 vmx->nested.dirty_vmcs12 = true; in set_current_vmptr()
5600 vmx->nested.force_msr_bitmap_recalc = true; in set_current_vmptr()
5619 if (vmptr == vmx->nested.vmxon_ptr) in handle_vmptrld()
5626 if (vmx->nested.current_vmptr != vmptr) { in handle_vmptrld()
5627 struct gfn_to_hva_cache *ghc = &vmx->nested.vmcs12_cache; in handle_vmptrld()
5661 if (kvm_read_guest_cached(vcpu->kvm, ghc, vmx->nested.cached_vmcs12, in handle_vmptrld()
5678 gpa_t current_vmptr = to_vmx(vcpu)->nested.current_vmptr; in handle_vmptrst()
5715 if (!(vmx->nested.msrs.secondary_ctls_high & in handle_invept()
5717 !(vmx->nested.msrs.ept_caps & VMX_EPT_INVEPT_BIT)) { in handle_invept()
5729 types = (vmx->nested.msrs.ept_caps >> VMX_EPT_EXTENT_SHIFT) & 6; in handle_invept()
5745 * Nested EPT roots are always held through guest_mmu, in handle_invept()
5796 if (!(vmx->nested.msrs.secondary_ctls_high & in handle_invvpid()
5798 !(vmx->nested.msrs.vpid_caps & VMX_VPID_INVVPID_BIT)) { in handle_invvpid()
5810 types = (vmx->nested.msrs.vpid_caps & in handle_invvpid()
5916 * VMFUNC for nested VMs, but not for L1. in handle_vmfunc()
5950 * nested VM-Exit. Pass the original exit reason, i.e. don't hardcode in handle_vmfunc()
6218 * L0 always deals with the EPT violation. If nested EPT is in nested_vmx_l0_wants_exit()
6219 * used, and the nested mmu code discovers that the address is in nested_vmx_l0_wants_exit()
6400 WARN_ON_ONCE(vmx->nested.nested_run_pending); in nested_vmx_reflect_vmexit()
6403 * Late nested VM-Fail shares the same flow as nested VM-Exit since KVM in nested_vmx_reflect_vmexit()
6470 (vmx->nested.vmxon || vmx->nested.smm.vmxon)) { in vmx_get_nested_state()
6471 kvm_state.hdr.vmx.vmxon_pa = vmx->nested.vmxon_ptr; in vmx_get_nested_state()
6472 kvm_state.hdr.vmx.vmcs12_pa = vmx->nested.current_vmptr; in vmx_get_nested_state()
6487 if (vmx->nested.smm.vmxon) in vmx_get_nested_state()
6490 if (vmx->nested.smm.guest_mode) in vmx_get_nested_state()
6496 if (vmx->nested.nested_run_pending) in vmx_get_nested_state()
6499 if (vmx->nested.mtf_pending) in vmx_get_nested_state()
6503 vmx->nested.has_preemption_timer_deadline) { in vmx_get_nested_state()
6507 vmx->nested.preemption_timer_deadline; in vmx_get_nested_state()
6533 if (!vmx->nested.need_vmcs12_to_shadow_sync) { in vmx_get_nested_state()
6571 to_vmx(vcpu)->nested.nested_run_pending = 0; in vmx_leave_nested()
6645 !vmx->nested.enlightened_vmcs_enabled)) in vmx_set_nested_state()
6653 vmx->nested.vmxon_ptr = kvm_state->hdr.vmx.vmxon_pa; in vmx_set_nested_state()
6683 vmx->nested.hv_evmcs_vmptr = EVMPTR_MAP_PENDING; in vmx_set_nested_state()
6691 vmx->nested.smm.vmxon = true; in vmx_set_nested_state()
6692 vmx->nested.vmxon = false; in vmx_set_nested_state()
6695 vmx->nested.smm.guest_mode = true; in vmx_set_nested_state()
6708 vmx->nested.nested_run_pending = in vmx_set_nested_state()
6711 vmx->nested.mtf_pending = in vmx_set_nested_state()
6736 vmx->nested.has_preemption_timer_deadline = false; in vmx_set_nested_state()
6738 vmx->nested.has_preemption_timer_deadline = true; in vmx_set_nested_state()
6739 vmx->nested.preemption_timer_deadline = in vmx_set_nested_state()
6748 vmx->nested.dirty_vmcs12 = true; in vmx_set_nested_state()
6749 vmx->nested.force_msr_bitmap_recalc = true; in vmx_set_nested_state()
6754 if (vmx->nested.mtf_pending) in vmx_set_nested_state()
6760 vmx->nested.nested_run_pending = 0; in vmx_set_nested_state()
6932 /* nested EPT: emulate EPT also to L1 */ in nested_vmx_setup_secondary_ctls()
7037 * returned for the various VMX controls MSRs when nested VMX is enabled.
7039 * valid during nested entry from L1 to L2.
7047 struct nested_vmx_msrs *msrs = &vmcs_conf->nested; in nested_vmx_setup_ctls_msrs()