From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brijesh Singh Subject: Re: [PATCH v2] KVM: x86: Avoid guest page table walk when gpa_available is set Date: Tue, 30 May 2017 17:09:30 -0500 Message-ID: <51f8c2c0-44f9-8173-408d-076c7db3c015@amd.com> References: <1495206749-25393-1-git-send-email-brijesh.singh@amd.com> <20170530090548.GA2764@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Cc: , , , , , , , , , To: Joerg Roedel Return-path: In-Reply-To: <20170530090548.GA2764@8bytes.org> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Hi Jorge, On 05/30/2017 04:05 AM, Joerg Roedel wrote: > On Fri, May 19, 2017 at 11:12:29AM -0400, Brijesh Singh wrote: >> From: Brijesh Singh >> >> On AMD hardware when a guest causes a NPF which requires emulation, >> the vcpu->arch.gpa_available flag is set to indicate that cr2 contains >> a valid GPA. >> >> Currently, emulator_read_write_onepage() makes use of gpa_available flag >> to avoid a guest page walk for a known MMIO regions. Lets not limit >> the gpa_available optimization to just MMIO region. The patch extends >> the check to avoid page walk whenever gpa_available flag is set. >> >> Signed-off-by: Brijesh Singh >> --- >> v1: http://marc.info/?l=kvm&m=149304930814202&w=2 >> >> Changes in v2: >> - move gpa_val setting in pf_interception >> >> arch/x86/include/asm/kvm_host.h | 1 + >> arch/x86/kvm/svm.c | 4 ++++ >> arch/x86/kvm/x86.c | 14 +++++++------- >> 3 files changed, 12 insertions(+), 7 deletions(-) > > I havn't checked in detail, but maybe you have: Does that take nesting > into account, where we might run on a shadow nested page-table and we > actually get a nested gpa (which still needs translation) instead of a > normal gpa? > nesting should not be an issue. all we're doing is avoiding the GVA->GPA translation for the lowest level guest. The nested case should still use the original code path and perform the nested page walk. I have verified the nesting support and it all seem to work just fine. You can find the original gpa_available patch here [1] [1] https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?id=0f89b207b04a1a399e19d35293658e3a571da3d7 -Brijesh