Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1013540imu; Wed, 23 Jan 2019 09:23:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN5r3FLzcgGG+4IWzHT9Ft16SZKf8h4pg7PRDkG12aQ9ycILRnA7ZA9rXkbluaaT2npVYwzW X-Received: by 2002:a65:500c:: with SMTP id f12mr2703489pgo.226.1548264195228; Wed, 23 Jan 2019 09:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548264195; cv=none; d=google.com; s=arc-20160816; b=cmV0iO5hMDSwZp+zTCjihXhY875mFWy3DDVlgTvJ33ln3c3fYpv+LixnG/i+3VeOXs RT4Zze5ycXrk53N0e9IN26dQY1z0DhjPdZg4AH7DfXNyg2BkCnpX9buGtKUh67cI89P1 ftIRkDo82PGaRZ80TJ4ghCwYfccW9INdaa0M8tNwWcBUJDgNfi33BTe/C8Aza3Pgd1be aGgNYkUyXgRDe0xGkFQbCAAesZrFgyt5rVqbpD7TlGYwkjQNdo5y+C3GucLldwtNorFy zNSSXMVwJOBCmcszbKbLpJfGfVEKVQbw0dMMnNXxGiyKgO2ehNhY9MNdUmyCrm2M0vLn m6aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BYlqG3bym7VGNeB5A/g5IXhdKxNY1y+E06xHBj5zteA=; b=0tgO0v/7v41WkgUPGCbtxs9CSyALj1FDcZz69ntipXnXKUPbRAcXOO7e29S6LooVTP 6oBaCGpyCGe6Tz8MKN9BA+HUDQ10f7eJteQZSB63SWXRbf6YQwO31l1SrdPBW8spvw/9 36FGR7tmVlKQU8+0jtxVxt/QKOOKCFhk5+y0f7DHbMxKxNdoVZvqCD7UGmnBax7DHOxM sdnr/6kmZCKNEEkRiHXLLYtINc52MMpYpsuhuVK0/HnrqUC7Z8oBJeYToQk9j1zmyY03 twu4XyF9qRBeP1pXgpd7/cNthgArJ8FV88mktELm6Y4Yz4tZPHG0uSl26ajyikjxjDo9 2Cpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=DTcCmUPU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h19si8321386pgb.231.2019.01.23.09.22.49; Wed, 23 Jan 2019 09:23:15 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=DTcCmUPU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726363AbfAWRSI (ORCPT + 99 others); Wed, 23 Jan 2019 12:18:08 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:50832 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbfAWRSH (ORCPT ); Wed, 23 Jan 2019 12:18:07 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0NHEgVE022802; Wed, 23 Jan 2019 17:18:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=BYlqG3bym7VGNeB5A/g5IXhdKxNY1y+E06xHBj5zteA=; b=DTcCmUPUikRM12hY9LFuRmxeVEwTZjU1oYCScL3WuIMuGuhWdsW2ockSLv4sm0j6kjEQ sHX5XuoNBhillu4v0ZvnpIgzPLtt58ocBFrAdiD4V5HCfbzKCLIB1fC8PP3OourtBM8c ffGRlgyO7WShVT7xJAk9M2uLgP4X4nTpww8HAFQJtkn7e/6HuR5Bdcwag0Y//OpqQnf/ mPOqKpzoJo5KaFOucM5UNdg9OefhyeOa4w32OZuCjVxAZCMVhKOw6Ikh/9RTvEXbvLvL QsjW1HAAlII0rdDb4i0U/goNbBRVSUgVrZ4z5bL+8vcw27rAlFFEI/WVjEzT4A7zkwyY YQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2q3sdekdva-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Jan 2019 17:18:03 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0NHI2bM027152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Jan 2019 17:18:03 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0NHI18r016619; Wed, 23 Jan 2019 17:18:01 GMT Received: from Konrads-MacBook-Pro.local (/75.104.64.133) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 23 Jan 2019 09:18:00 -0800 Date: Wed, 23 Jan 2019 12:17:44 -0500 From: Konrad Rzeszutek Wilk To: KarimAllah Ahmed Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com Subject: Re: [PATCH v5 02/13] X86/nVMX: Update the PML table without mapping and unmapping the page Message-ID: <20190123171730.GG19289@Konrads-MacBook-Pro.local> References: <1547026933-31226-1-git-send-email-karahmed@amazon.de> <1547026933-31226-3-git-send-email-karahmed@amazon.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1547026933-31226-3-git-send-email-karahmed@amazon.de> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9145 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=904 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901230127 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 09, 2019 at 10:42:02AM +0100, KarimAllah Ahmed wrote: > Update the PML table without mapping and unmapping the page. This also > avoids using kvm_vcpu_gpa_to_page(..) which assumes that there is a "struct > page" for guest memory. > > As a side-effect of using kvm_write_guest_page the page is also properly > marked as dirty. > > Signed-off-by: KarimAllah Ahmed > Reviewed-by: David Hildenbrand Reviewed-by: Konrad Rzeszutek Wilk > --- > v1 -> v2: > - Use kvm_write_guest_page instead of kvm_write_guest (pbonzini) > - Do not use pointer arithmetic for pml_address (pbonzini) > --- > arch/x86/kvm/vmx/vmx.c | 14 +++++--------- > 1 file changed, 5 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index 4d39f73..71d88df 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -7199,9 +7199,7 @@ static int vmx_write_pml_buffer(struct kvm_vcpu *vcpu) > { > struct vmcs12 *vmcs12; > struct vcpu_vmx *vmx = to_vmx(vcpu); > - gpa_t gpa; > - struct page *page = NULL; > - u64 *pml_address; > + gpa_t gpa, dst; > > if (is_guest_mode(vcpu)) { > WARN_ON_ONCE(vmx->nested.pml_full); > @@ -7221,15 +7219,13 @@ static int vmx_write_pml_buffer(struct kvm_vcpu *vcpu) > } > > gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS) & ~0xFFFull; > + dst = vmcs12->pml_address + sizeof(u64) * vmcs12->guest_pml_index; > > - page = kvm_vcpu_gpa_to_page(vcpu, vmcs12->pml_address); > - if (is_error_page(page)) > + if (kvm_write_guest_page(vcpu->kvm, gpa_to_gfn(dst), &gpa, > + offset_in_page(dst), sizeof(gpa))) > return 0; > > - pml_address = kmap(page); > - pml_address[vmcs12->guest_pml_index--] = gpa; > - kunmap(page); > - kvm_release_page_clean(page); > + vmcs12->guest_pml_index--; > } > > return 0; > -- > 2.7.4 >