Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp524330imu; Wed, 9 Jan 2019 01:45:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN625AOl30xmsGpH+NmZ/QYm20GLLdDQHIRFPWhyd5F16qtHBZbd7CCmSg7o+O2z92UFXW/h X-Received: by 2002:a63:2f86:: with SMTP id v128mr4571041pgv.407.1547027134592; Wed, 09 Jan 2019 01:45:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547027134; cv=none; d=google.com; s=arc-20160816; b=yp+sCHLqVtXf1BP/unuZt7+8Me6L0PrPfAxiRZ3PMRXo1jrNlDLL4yLCx/t1nG7Sg0 M/YFIow7ISyCLI8TaTsXPTGqNm8gTqp673VNZFrRGH8HHEn4CFcWOCeXEoehgBHtxUaI P0U/smWlBaR7ERiFXXAcbJo3vxAA9iex+S0fRjUUhAeU1sB47CYwn8HNF3omqeTp0nVK z/xBF78NERqLJgWsV4XmyEXoyaFRX7mIYDusIddOgWdyS9MkHmgowVktkowIa26Nd1LP jIxvyoRSJ80CLa11G19Ed6hnVTLRi7OtclqjndXW2DsWUF6dFklhrM3JsW5Vjs7Zb6S8 FNNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=bnzeuEUS60UibzIf6CzBfmI0leq/yGJtjEHqDSi8SqA=; b=uQe1xJ57SIHJyLKvy2G2prhbqruuobI81h/vA6eo+WUg6t+NbWkC3r+JGCjOhr1Q45 fgE5EPslOQbZkM1wtds1uqtq+/OruTuvcbaxYHZi0PmYWFSn38fy7U8jO4KwCa/7GtAP 6ScjFlcn3V42YNMoBR6OglqdVXrXjK+CNhWqyJO/0sSDICARlJ4VnlV/fUKX7ahByHt3 GEP1B2SEBgNVOJjk/77vOQlSOuiRjetgiA1+1EFAFatzzu9TldZK++quq0O93aPNYICT aOLks+tjUONzdzQ0RzGbREZiqQAEfJNS71jg/rFcB6qo6T46eWx6QgMYxs8grIjclhxb GHYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=u0wQbVcj; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34si2588493pgt.455.2019.01.09.01.45.19; Wed, 09 Jan 2019 01:45:34 -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=@amazon.de header.s=amazon201209 header.b=u0wQbVcj; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730677AbfAIJno (ORCPT + 99 others); Wed, 9 Jan 2019 04:43:44 -0500 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:6461 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730364AbfAIJmX (ORCPT ); Wed, 9 Jan 2019 04:42:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1547026942; x=1578562942; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=bnzeuEUS60UibzIf6CzBfmI0leq/yGJtjEHqDSi8SqA=; b=u0wQbVcj0b2W2Oc62pUa0gBdlkSeg2wtriq/7bB/b4kqOYdOSZQZK1uD uhpG58GBn73SHwIUh/hjXF95Xh9jdGgUJpaZO5NC/bb12+hMOtcQ3SqIt QPqcNpPc/6kxuLbF3P7NSTxVPee5h0PdBb0A6iTkxdWSX5/ntjdpjkiJG w=; X-IronPort-AV: E=Sophos;i="5.56,253,1539648000"; d="scan'208";a="712024356" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2b-a7fdc47a.us-west-2.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 09 Jan 2019 09:42:21 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2b-a7fdc47a.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id x099gHWC054039 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Jan 2019 09:42:18 GMT Received: from u54e1ad5160425a4b64ea.ant.amazon.com (localhost [127.0.0.1]) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id x099gG6N031298; Wed, 9 Jan 2019 10:42:17 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id x099gGAj031297; Wed, 9 Jan 2019 10:42:16 +0100 From: KarimAllah Ahmed To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com Cc: KarimAllah Ahmed Subject: [PATCH v5 02/13] X86/nVMX: Update the PML table without mapping and unmapping the page Date: Wed, 9 Jan 2019 10:42:02 +0100 Message-Id: <1547026933-31226-3-git-send-email-karahmed@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547026933-31226-1-git-send-email-karahmed@amazon.de> References: <1547026933-31226-1-git-send-email-karahmed@amazon.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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