Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1039744imu; Wed, 23 Jan 2019 09:47:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN7p+WGPgoU6j+pZJ+CtIArI7EEeGpQKLzrOK3sBoC1e6gTnGLHTGsEsHS1Q8KmaDL0n0qad X-Received: by 2002:a62:3811:: with SMTP id f17mr2932320pfa.206.1548265632926; Wed, 23 Jan 2019 09:47:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548265632; cv=none; d=google.com; s=arc-20160816; b=CSCkdAE9eyrAv7IbgRzfWjGcgwvLdBpN4/AvSWF1H+OXMbvEei3ZTnPnpJUr8zLKaD nqasQrLwN1kzXkJJWX3hQkp5EO0iLlUXdIjOnd5yze99AUOQDjeztfTnffw2cSBmdXFI k3tBgbr7Md85iD+w6ffZY8t/2L3n4W+lzkxXL2xXOk9NW3Qb4yAmeAS4apRyNvNvxWYS qyIYe483FxwyqVf7aSFtZyzoRd7rKexLY9YQBIuRd6mLhcv3Lx+NB83WHmI9kkXcBevf b/g/zJUiUxDExiIvhjFfsZR9uqnsknNX0fhjGIMrorsExXHibdoOXFup/+TRcC0ZDIvH t08Q== 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=SwLh9jUkuRceSleHqx133UfY6I2ewVgornbggMEcOoo=; b=Fc4xSxdUbbYSUrQX8oYKmpJA1QRiGT++yt4WmBD9gKuxEMiGltu7PMA5+JyGfb/+A1 6moj5ctr0DYistDxwDqlifGmmMVL8DuhXB0V4ItQx1Juye6KiGyTS9qPVBGir18Hgnvb BQ4+ssOWI+/+oHe11H9KbGPaVuIw+C7CMw2O4rdbsiUa+YxH4Ic0PMaEF7w5AQTbFCYE lK8d16BfwmVWUjb1Sx+dDBamCF4fveYekqA1h5VtVmy7Gi8tdiWOKw1Fv9exOWWzJl4A pC4VWJP2E23uEXgokhVQjknb0WuyLpinvKcW84I5g6XK7Y6DT1v4Z9V0KxuUq+dArQsI x17A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="svkM/mB0"; 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 g20si18997110pgh.241.2019.01.23.09.46.57; Wed, 23 Jan 2019 09:47:12 -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="svkM/mB0"; 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 S1726647AbfAWRpO (ORCPT + 99 others); Wed, 23 Jan 2019 12:45:14 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:36796 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbfAWRpO (ORCPT ); Wed, 23 Jan 2019 12:45:14 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0NHiFpr103740; Wed, 23 Jan 2019 17:45:09 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=SwLh9jUkuRceSleHqx133UfY6I2ewVgornbggMEcOoo=; b=svkM/mB0IQMi9qY16VCAyBjPQRPSLj4kKWwk0+jYTJc09YE8Y9xlRD6Ayu/TZrKYm0Va hMz3e/0Lp7aTqYFRv845v5k11dSMzgRrOy5zxFD4J/zEVt6nUqpPNUx5V7dZZmdZB0B1 4dJgnlBNxAxD2NMphTLhCX7MtJQKqO3aDzlPeH8mmzkka6hgGTUqEGivzX6dnFNPilNb SSc9hhJj02CUu59KBCOsh8lJHzqhyNJWjLy+cGSCNkaEVk1MNuUxZog9tVodn0anGLe3 MIucVOKUpyzkNil+w9Io0UYF+gHV40ubLaSSJlSuKlzNWtPZ+XcCO+U+eQG0b98EQ/pG iA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2q3uauue5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Jan 2019 17:45:09 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0NHj3ld001523 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Jan 2019 17:45:03 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x0NHj3Jb020889; Wed, 23 Jan 2019 17:45:03 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:45:02 -0800 Date: Wed, 23 Jan 2019 12:44:41 -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 05/13] X86/nVMX: handle_vmptrld: Use kvm_vcpu_map when copying VMCS12 from guest memory Message-ID: <20190123174438.GJ19289@Konrads-MacBook-Pro.local> References: <1547026933-31226-1-git-send-email-karahmed@amazon.de> <1547026933-31226-6-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-6-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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901230131 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:05AM +0100, KarimAllah Ahmed wrote: > Use kvm_vcpu_map to the map the VMCS12 from guest memory because > kvm_vcpu_gpa_to_page() and kmap() will only work for guest memory that has > a "struct page". > > Signed-off-by: KarimAllah Ahmed Reviewed-by: Konrad Rzeszutek Wilk > --- > v4 -> v5: > - Switch to the new guest mapping API instead of reading directly from > guest. > - unmap with dirty flag > v3 -> v4: > - Return VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID on failure (jmattson@) > v1 -> v2: > - Massage commit message a bit. > --- > arch/x86/kvm/vmx/nested.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > index 536468a..5602b0c 100644 > --- a/arch/x86/kvm/vmx/nested.c > +++ b/arch/x86/kvm/vmx/nested.c > @@ -4521,11 +4521,10 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu) > return 1; > > if (vmx->nested.current_vmptr != vmptr) { > + struct kvm_host_map map; > struct vmcs12 *new_vmcs12; > - struct page *page; > > - page = kvm_vcpu_gpa_to_page(vcpu, vmptr); > - if (is_error_page(page)) { > + if (kvm_vcpu_map(vcpu, gpa_to_gfn(vmptr), &map)) { > /* > * Reads from an unbacked page return all 1s, > * which means that the 32 bits located at the > @@ -4536,12 +4535,13 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu) > VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID); > return kvm_skip_emulated_instruction(vcpu); > } > - new_vmcs12 = kmap(page); > + > + new_vmcs12 = map.hva; > + > if (new_vmcs12->hdr.revision_id != VMCS12_REVISION || > (new_vmcs12->hdr.shadow_vmcs && > !nested_cpu_has_vmx_shadow_vmcs(vcpu))) { > - kunmap(page); > - kvm_release_page_clean(page); > + kvm_vcpu_unmap(&map, false); > return nested_vmx_failValid(vcpu, > VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID); > } > @@ -4553,8 +4553,7 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu) > * cached. > */ > memcpy(vmx->nested.cached_vmcs12, new_vmcs12, VMCS12_SIZE); > - kunmap(page); > - kvm_release_page_clean(page); > + kvm_vcpu_unmap(&map, false); > > set_current_vmptr(vmx, vmptr); > } > -- > 2.7.4 >