Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10994032imu; Thu, 6 Dec 2018 09:49:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/WDUT31fOJh/1bH0GkwdlCPeHPQwGgvoW2EIPkoMw9fLy4OEEAGE3NZb4/Ap+7NR2JF//xr X-Received: by 2002:a65:6148:: with SMTP id o8mr24820494pgv.451.1544118543492; Thu, 06 Dec 2018 09:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544118543; cv=none; d=google.com; s=arc-20160816; b=lrHFCBw/B+Ag6fgeWgjdU91nwJxXhcru96pHyXRA7UCnzThERYI/duKhO+3ob1hnu2 UhWCc6+ihJ4+2UOP5PgbrHwkNnlbsrT9DbYP7MCqIqktpeuQqwMrrGgTmQlVFloiEYNt z/tc1SV1idIW1BOr6pixmYowQxFT1f2uqnErj2figHpYncjU69/bcMDV2z5ZZYPej2sC BghUPbvsRIJorjUqkW3k+421/OrBLRCQq7DlxGfEjrLOudFyxaAR0+ABtfaUMDZ8DW/8 43AL214z81aS/07m6SRshdgOb9UpDstj3daFCIv7vwPf0oGJ3RIEsrLKyZfnMpL0gLds zUnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=MbGrniH5+4Ep233t5Mjo9ZAAed7+aYA6fPbD/yiVKWM=; b=IdWO2yh0Zw0lx3eAD6Xs9J0jnK5T75XsTOw3RpK9akGmqZREj7mMjaVkEngO29b3JF fvoBzn2Py0O4QroFbya/r+mrcoW9EyodM2dVu7qXqCnf2cCsDiqbneoPs89zfBLRD4eW zOhmn+nmlk+GowlLJdSteqeqvkMAY744bR9znJoohyu5ZrUBqnofYayk00PymSp5iuLQ 4CpTt4ueit3O3Yz484tPYQx6Ft0TXsxAUSxP1uxcvfWOZuWhJL/KiNzEUg2j49NW+Lit r0S4JdP57KWeXoNT93HxKxvLR2W9L1HvrpNOF+kQC3JiU8rBSpJXQ3uUjaYeVnzt0rDc ifnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v185si745789pfb.65.2018.12.06.09.48.44; Thu, 06 Dec 2018 09:49:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726150AbeLFRqM (ORCPT + 99 others); Thu, 6 Dec 2018 12:46:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55722 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725898AbeLFRqM (ORCPT ); Thu, 6 Dec 2018 12:46:12 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1EAFBE1F05; Thu, 6 Dec 2018 17:46:12 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.34.244.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A038579D43; Thu, 6 Dec 2018 17:46:10 +0000 (UTC) From: Vitaly Kuznetsov To: KarimAllah Ahmed Cc: rkrcmar@redhat.com, pbonzini@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, jmattson@google.com Subject: Re: [PATCH v4 14/14] KVM/nVMX: Use kvm_vcpu_map for accessing the enhanced VMCS In-Reply-To: <1543829467-18025-15-git-send-email-karahmed@amazon.de> References: <1543829467-18025-1-git-send-email-karahmed@amazon.de> <1543829467-18025-15-git-send-email-karahmed@amazon.de> Date: Thu, 06 Dec 2018 18:46:09 +0100 Message-ID: <875zw67dlq.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 06 Dec 2018 17:46:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org KarimAllah Ahmed writes: > Use kvm_vcpu_map for accessing the enhanced VMCS since using just a nitpick: "eVMCS" stands for Enlightened VMCS, not 'enhanced' :-) > kvm_vcpu_gpa_to_page() and kmap() will only work for guest memory that has > a "struct page". > > Signed-off-by: KarimAllah Ahmed > --- > arch/x86/kvm/vmx.c | 16 ++++++---------- > 1 file changed, 6 insertions(+), 10 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index a958700..83a614f 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -894,7 +894,7 @@ struct nested_vmx { > } smm; > > gpa_t hv_evmcs_vmptr; > - struct page *hv_evmcs_page; > + struct kvm_host_map hv_evmcs_map; > struct hv_enlightened_vmcs *hv_evmcs; > }; > > @@ -8456,10 +8456,8 @@ static inline void nested_release_evmcs(struct kvm_vcpu *vcpu) > if (!vmx->nested.hv_evmcs) > return; > > - kunmap(vmx->nested.hv_evmcs_page); > - kvm_release_page_dirty(vmx->nested.hv_evmcs_page); > + kvm_vcpu_unmap(&vmx->nested.hv_evmcs_map); > vmx->nested.hv_evmcs_vmptr = -1ull; > - vmx->nested.hv_evmcs_page = NULL; > vmx->nested.hv_evmcs = NULL; > } > > @@ -8559,7 +8557,7 @@ static int handle_vmclear(struct kvm_vcpu *vcpu) > return nested_vmx_failValid(vcpu, > VMXERR_VMCLEAR_VMXON_POINTER); > > - if (vmx->nested.hv_evmcs_page) { > + if (vmx->nested.hv_evmcs_map.hva) { > if (vmptr == vmx->nested.hv_evmcs_vmptr) > nested_release_evmcs(vcpu); > } else { > @@ -9355,13 +9353,11 @@ static int nested_vmx_handle_enlightened_vmptrld(struct kvm_vcpu *vcpu, > > nested_release_evmcs(vcpu); > > - vmx->nested.hv_evmcs_page = kvm_vcpu_gpa_to_page( > - vcpu, assist_page.current_nested_vmcs); > - > - if (unlikely(is_error_page(vmx->nested.hv_evmcs_page))) > + if (kvm_vcpu_map(vcpu, gpa_to_gfn(assist_page.current_nested_vmcs), > + &vmx->nested.hv_evmcs_map)) > return 0; > > - vmx->nested.hv_evmcs = kmap(vmx->nested.hv_evmcs_page); > + vmx->nested.hv_evmcs = vmx->nested.hv_evmcs_map.hva; > > /* > * Currently, KVM only supports eVMCS version 1 -- Vitaly