Re: [PATCH v4 3/4] KVM: async_pf: Force a nested vmexit if the injected #PF is async_pf

From: Paolo Bonzini
Date: Wed Jun 28 2017 - 07:40:35 EST




On 28/06/2017 00:33, Wanpeng Li wrote:
> I have already added the same logic in kvm_inject_page_fault in patch
> 3/4, in addition, there is a guarantee it is in guest mode when we set
> svm->vmcb->control.xxxx in nested_svm_check_exception, how about just
> as what we do in nested_vmx_check_exception?
>
> + if (svm->vcpu.arch.exception.async_page_fault)
> + svm->vmcb->control.exit_info_2 = svm->vcpu.arch.apf.nested_apf_token;
> + else
> + svm->vmcb->control.exit_info_2 = svm->vcpu.arch.cr2;

Yes, see my reply to [PATCH v5 3/4].

What do you think of moving "is_guest_mode(vcpu) &&" from this "if":

>
> void kvm_inject_page_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault)
> {
> ++vcpu->stat.pf_guest;
> - vcpu->arch.cr2 = fault->address;
> + vcpu->arch.exception.async_page_fault = fault->async_page_fault;
> + if (is_guest_mode(vcpu) && vcpu->arch.exception.async_page_fault)
> + vcpu->arch.apf.nested_apf_token = fault->address;


to the previous assignment of vcpu->arch.exception.async_page_fault (so
that it can be renamed to nested_apf)?

Thanks,

Paolo