From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751685AbdF1LkI (ORCPT ); Wed, 28 Jun 2017 07:40:08 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:33987 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751626AbdF1LkH (ORCPT ); Wed, 28 Jun 2017 07:40:07 -0400 Subject: Re: [PATCH v4 3/4] KVM: async_pf: Force a nested vmexit if the injected #PF is async_pf To: Wanpeng Li Cc: "linux-kernel@vger.kernel.org" , kvm , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li References: <1498097214-6239-1-git-send-email-wanpeng.li@hotmail.com> <1498097214-6239-4-git-send-email-wanpeng.li@hotmail.com> <61bbcc19-a818-6934-75e9-8aed28523aa0@redhat.com> From: Paolo Bonzini Message-ID: Date: Wed, 28 Jun 2017 13:40:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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