Received: by 10.192.165.156 with SMTP id m28csp3011617imm; Sun, 15 Apr 2018 14:59:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+VSECAf+YVt7gEAFgfwJD8IEue5xEdmAHCEQmwMkqUViK5uujCpq8mSg/qpG6IVwQO1nbW X-Received: by 10.99.98.66 with SMTP id w63mr9774582pgb.377.1523829549211; Sun, 15 Apr 2018 14:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523829549; cv=none; d=google.com; s=arc-20160816; b=vDjYxF4yD6+CY6AqVqV9RfIZOcUjH64Mp/whsqG6CU5I8uXAkjO/4ZSX9P3HSXQ+qf 3cQ0EpnCZAk324NxBjnW8IoAkeZUfjXnSfzxglKqmeKb24LG7GOwNwHQj6Z0j/h7ZW6W RwiTXkxG2H2mMvj1rgnLLuMqlMM/gfLHdSMPfyqx7605Xc4RyhhX4Fd7Ge3vErcpb/Eg /8U7jrAQttDimXTY9v9ZjLuO+1b//lkXb5mQxM1I/WTCRdrN6Z/62rkZEosexcepF3UE U7QJh2NPT5jzAHZ2moLAt7sKvVqOkC79u618dIdFAEPFTtNjNe1roroDntsNmD+W51qj NTJQ== 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:arc-authentication-results; bh=1Ora0UyNd9OblHOxvNF9a3m8gJ38EjuhYn8IieXcoaA=; b=CxjtF2t8oDBOcJXxusoGJjiRWnumsA06b5AU2fSGfHBQEve0ihyy5BLxLOzXAPzLC3 cyxekULX2kQuPgM4YxO3uoBTO7NGBTESmPA+pfaQVd3zkVrsTBaYzuxmZD5ckfwuox2J cnf4PdaUpQUUtBZdxKMzBUQacaow68J5AQXN0fhYGO+HOJfmn5XzpC7cW+ZIX6Wq7VQ7 GCnUkQ/SRu/IpPRE+E2gI/hLJcUl2DGNZv9Ha19nyLwmSnf62raluRIcHgkhpk7gmAkJ neet+A7a4ACD/Mha6rFgxgCevVqfAHhR3jsp+YZdC3j652jjX18CKkovDShnK6y3uI0T PnPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=JQfUGVw0; 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 s1si2630464pgb.281.2018.04.15.14.58.55; Sun, 15 Apr 2018 14:59:09 -0700 (PDT) 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=JQfUGVw0; 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 S1752750AbeDOVzA (ORCPT + 99 others); Sun, 15 Apr 2018 17:55:00 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:59935 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750960AbeDOVyy (ORCPT ); Sun, 15 Apr 2018 17:54:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1523829294; x=1555365294; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=1Ora0UyNd9OblHOxvNF9a3m8gJ38EjuhYn8IieXcoaA=; b=JQfUGVw0viALLG/QHStwK+xdNdCaS0CuV6BjdlFHELE7OMR1u8+uG4QW 9jSHhEtIdnSXNzFyvS4RxOpKdM4lLErdgmNt6RoTXExqrjLXUlt7mt7n6 a59R/395emdg1cUUBzpz5AOY7/TciqXAjq6f7e5uG+0jA6L9QMUT0/jz9 8=; X-IronPort-AV: E=Sophos;i="5.48,456,1517875200"; d="scan'208";a="339837512" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-f273de60.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Apr 2018 21:54:53 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (iad1-ws-svc-lb91-vlan2.amazon.com [10.0.103.146]) by email-inbound-relay-1d-f273de60.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id w3FLsm6b055521 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 15 Apr 2018 21:54:51 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 w3FLsmaE013419; Sun, 15 Apr 2018 23:54:48 +0200 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id w3FLslx9013418; Sun, 15 Apr 2018 23:54:47 +0200 From: KarimAllah Ahmed To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com Cc: KarimAllah Ahmed Subject: [PATCH v2 03/12] X86/nVMX: Update the PML table without mapping and unmapping the page Date: Sun, 15 Apr 2018 23:53:09 +0200 Message-Id: <1523829198-13236-4-git-send-email-karahmed@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523829198-13236-1-git-send-email-karahmed@amazon.de> References: <1523829198-13236-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. Signed-off-by: KarimAllah Ahmed --- 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.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 810ba7a..179061d 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -12294,9 +12294,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); @@ -12316,15 +12314,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