Re: [PATCH v3 7/9] KVM: nSVM: implement nested_svm_load_cr3() and use it for host->guest switch

Paolo Bonzini
2020-07-09T17:57:26Z

On 09/07/20 16:53, Vitaly Kuznetsov wrote:
> + if (nested_npt_enabled(svm))
> + nested_svm_init_mmu_context(&svm->vcpu);
> +
> ret = nested_svm_load_cr3(&svm->vcpu, nested_vmcb->save.cr3,
> nested_npt_enabled(svm));

This needs to be done in svm_set_nested_state, so my suggestion is that
the previous patch includes a call to nested_svm_load_cr3 in
svm_set_nested_state, and this one adds the "if" inside
nested_svm_load_cr3 itself.

Paolo

> @@ -364,13 +388,6 @@ static int nested_prepare_vmcb_save(struct vcpu_svm *svm, struct vmcb *nested_vm
> static void nested_prepare_vmcb_control(struct vcpu_svm *svm)
> {
> const u32 mask = V_INTR_MASKING_MASK | V_GIF_ENABLE_MASK | V_GIF_MASK;
> - if (nested_npt_enabled(svm))
> - nested_svm_init_mmu_context(&svm->vcpu);
> -
> - /* Guest paging mode is active - reset mmu */
> - kvm_mmu_reset_context(&svm->vcpu);
> -
> - svm_flush_tlb(&svm->vcpu);
>