Lines Matching refs:nested

44 		 * TODO: track the cause of the nested page fault, and
62 u64 cr3 = svm->nested.ctl.nested_cr3;
77 return svm->nested.ctl.nested_cr3;
95 svm->nested.ctl.nested_cr3);
116 if (!(svm->nested.ctl.virt_ext & VIRTUAL_VMLOAD_VMSAVE_ENABLE_MASK))
135 g = &svm->nested.ctl;
157 * We want to see VMMCALLs from a nested guest only when Hyper-V L2 TLB
201 if (!svm->nested.force_msr_bitmap_recalc) {
202 struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments;
206 (svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS)))
211 if (!(vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_MSR_PROT)))
223 /* x2apic msrs are intercepted always for the nested guest */
227 offset = svm->nested.ctl.msrpm_base_pa + (p * 4);
232 svm->nested.msrpm[p] = svm->msrpm[p] | value;
235 svm->nested.force_msr_bitmap_recalc = false;
240 svm->vmcb->control.msrpm_base_pa = __sme_set(__pa(svm->nested.msrpm));
322 struct vmcb_save_area_cached *save = &svm->nested.save;
330 struct vmcb_ctrl_area_cached *ctl = &svm->nested.ctl;
385 __nested_copy_vmcb_control_to_cache(&svm->vcpu, &svm->nested.ctl, control);
407 __nested_copy_vmcb_save_to_cache(&svm->nested.save, save);
417 svm->nested.ctl.event_inj = svm->vmcb->control.event_inj;
418 svm->nested.ctl.event_inj_err = svm->vmcb->control.event_inj_err;
431 !test_bit(INTERCEPT_VINTR, (unsigned long *)svm->nested.ctl.intercepts))
440 svm->nested.ctl.int_ctl &= ~mask;
441 svm->nested.ctl.int_ctl |= svm->vmcb->control.int_ctl & mask;
491 * - Honor L1's request to flush an ASID on nested VMRUN
492 * - Sync nested NPT MMU on VMRUN that flushes L2's ASID[*]
493 * - Don't crush a pending TLB flush in vmcb02 on nested VMRUN
496 * [*] Unlike nested EPT, SVM's ASID management can invalidate nested
504 * Load guest's/host's cr3 on nested vmentry or vmexit. @nested_npt is true
530 if (!svm->nested.vmcb02.ptr)
534 svm->nested.vmcb02.ptr->save.g_pat = svm->vmcb01.ptr->save.g_pat;
541 struct vmcb *vmcb02 = svm->nested.vmcb02.ptr;
546 /* Load the nested guest state */
547 if (svm->nested.vmcb12_gpa != svm->nested.last_vmcb12_gpa) {
549 svm->nested.last_vmcb12_gpa = svm->nested.vmcb12_gpa;
550 svm->nested.force_msr_bitmap_recalc = true;
570 svm_set_efer(vcpu, svm->nested.save.efer);
572 svm_set_cr0(vcpu, svm->nested.save.cr0);
573 svm_set_cr4(vcpu, svm->nested.save.cr4);
588 vmcb02->save.dr7 = svm->nested.save.dr7 | DR7_FIXED_1;
589 svm->vcpu.arch.dr6 = svm->nested.save.dr6 | DR6_ACTIVE_LOW;
594 (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK))) {
641 struct vmcb *vmcb02 = svm->nested.vmcb02.ptr;
651 (svm->nested.ctl.int_ctl & V_GIF_ENABLE_MASK))
683 svm->nested.ctl.tsc_offset,
693 (svm->nested.ctl.int_ctl & int_ctl_vmcb12_bits) |
696 vmcb02->control.int_vector = svm->nested.ctl.int_vector;
697 vmcb02->control.int_state = svm->nested.ctl.int_state;
698 vmcb02->control.event_inj = svm->nested.ctl.event_inj;
699 vmcb02->control.event_inj_err = svm->nested.ctl.event_inj_err;
710 vmcb02->control.next_rip = svm->nested.ctl.next_rip;
720 svm->soft_int_next_rip = svm->nested.ctl.next_rip;
729 (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK);
735 pause_count12 = svm->nested.ctl.pause_filter_count;
739 pause_thresh12 = svm->nested.ctl.pause_filter_thresh;
753 if (vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_PAUSE)) {
777 * moved at the time of nested vmrun and vmexit.
809 svm->nested.vmcb12_gpa = vmcb12_gpa;
811 WARN_ON(svm->vmcb == svm->nested.vmcb02.ptr);
813 nested_svm_copy_common_state(svm->vmcb01.ptr, svm->nested.vmcb02.ptr);
815 svm_switch_vmcb(svm, &svm->nested.vmcb02);
819 ret = nested_svm_load_cr3(&svm->vcpu, svm->nested.save.cr3,
846 if (!svm->nested.hsave_msr) {
876 if (WARN_ON_ONCE(!svm->nested.initialized))
904 svm->nested.nested_run_pending = 1;
913 svm->nested.nested_run_pending = 0;
971 struct vmcb *vmcb02 = svm->nested.vmcb02.ptr;
976 rc = kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.vmcb12_gpa), &map);
987 svm->nested.vmcb12_gpa = 0;
988 WARN_ON_ONCE(svm->nested.nested_run_pending);
1028 vmcb12->control.int_ctl = svm->nested.ctl.int_ctl;
1029 vmcb12->control.event_inj = svm->nested.ctl.event_inj;
1030 vmcb12->control.event_inj_err = svm->nested.ctl.event_inj_err;
1038 nested_svm_copy_common_state(svm->nested.vmcb02.ptr, svm->vmcb01.ptr);
1057 * V_GIF: If nested vGIF is not used, KVM uses vmcb02's V_GIF for L1's
1065 (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK))) {
1106 svm->nested.ctl.nested_cr3 = 0;
1170 if (!vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_SHUTDOWN))
1181 if (svm->nested.initialized)
1187 svm->nested.vmcb02.ptr = page_address(vmcb02_page);
1188 svm->nested.vmcb02.pa = __sme_set(page_to_pfn(vmcb02_page) << PAGE_SHIFT);
1190 svm->nested.msrpm = svm_vcpu_alloc_msrpm();
1191 if (!svm->nested.msrpm)
1193 svm_vcpu_init_msrpm(&svm->vcpu, svm->nested.msrpm);
1195 svm->nested.initialized = true;
1205 if (!svm->nested.initialized)
1211 svm_vcpu_free_msrpm(svm->nested.msrpm);
1212 svm->nested.msrpm = NULL;
1214 __free_page(virt_to_page(svm->nested.vmcb02.ptr));
1215 svm->nested.vmcb02.ptr = NULL;
1224 svm->nested.last_vmcb12_gpa = INVALID_GPA;
1226 svm->nested.initialized = false;
1234 svm->nested.nested_run_pending = 0;
1235 svm->nested.vmcb12_gpa = INVALID_GPA;
1256 if (!(vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_MSR_PROT)))
1270 if (kvm_vcpu_read_guest(&svm->vcpu, svm->nested.ctl.msrpm_base_pa + offset, &value, 4))
1283 if (!(vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_IOIO_PROT)))
1289 gpa = svm->nested.ctl.iopm_base_pa + (port / 8);
1314 if (vmcb12_is_intercept(&svm->nested.ctl, exit_code))
1319 if (vmcb12_is_intercept(&svm->nested.ctl, exit_code))
1337 if (vmcb12_is_intercept(&svm->nested.ctl, exit_code))
1377 return (svm->nested.ctl.intercepts[INTERCEPT_EXCEPTION] & BIT(vector));
1418 return vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_INIT);
1426 * Only a pending nested run blocks a pending exception. If there is a
1430 bool block_nested_exceptions = svm->nested.nested_run_pending;
1603 kvm_state.hdr.svm.vmcb_pa = svm->nested.vmcb12_gpa;
1607 if (svm->nested.nested_run_pending)
1631 nested_copy_vmcb_cache_to_control(ctl, &svm->nested.ctl);
1742 svm->nested.vmcb02.ptr->save = svm->vmcb01.ptr->save;
1746 svm->nested.nested_run_pending =
1749 svm->nested.vmcb12_gpa = kvm_state->hdr.svm.vmcb_pa;
1754 svm_switch_vmcb(svm, &svm->nested.vmcb02);
1758 * While the nested guest CR3 is already checked and set by
1759 * KVM_SET_SREGS, it was set when nested state was yet loaded,
1769 svm->nested.force_msr_bitmap_recalc = true;
1791 * the guest CR3 might be restored prior to setting the nested