Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp524118imu; Wed, 9 Jan 2019 01:45:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Ojel2bms+j4Clz+11wnuNM8tiJH1WCDII1dUsPFSRAlyURDOrCkskVOwBc8cLW8XbyUGH X-Received: by 2002:a63:7f4f:: with SMTP id p15mr4786102pgn.296.1547027117701; Wed, 09 Jan 2019 01:45:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547027117; cv=none; d=google.com; s=arc-20160816; b=uAyLsznPBMWCBQEBGrc2MbQXRRtwLwtOUvv1FpTpIUlPIqkmqbAmVWr4WeXJ9q3Apg g38q9FATXdO1Jg2vJ/K2AbLT4viIcGqpmP6QsyLW0lqoJzG1V30OWBbUKcqTz7RN+9g7 OoiB5q/jkqqtSKeX/H/d8+4J4t7AbGzNJ5QkoRq3Q9CXMRjYcGQlmwo1mdW27abzqcDz tBojJho1pSu4FlWfjarqMHc55RaARUOlVQaCMdfDV4jeeVNfrNLI1RM5HuulfAouV6Jn 0PW5bImEA0ZGQHxj0h30ifXeOtafibWeWzACUxuJWjmelwDwlMvq8TEJytn1+qDey6Io WfpQ== 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=7IzEYV9FoSpsE6ZCAmYPvlNyjLadlOMGwjgHhakmUKQ=; b=clZFEW7gQWjnVOEhIT7a0n1XmtKQn6IELevkwTiUmDC7S3lWtVSbgl8sv3VHSvg3qo PjTNzwInfuHnz5d5jTe1HZ7DjJEMyf5mRUnYI+p569T0ppiJN1Rr/x1/9OhZDBsUJsXk q+4YxskpuoXO22Gloo8plFl5RcfgA0eKeExLA3DDpNBHm5H5MHmQ1KIXeedQTW9YV94R aa60jWP0PeTQ7Hpj62Umhyq3w7n4sCGtG9dc2msJnoEJBha3pVYxpV9+22qMcD4IGf2Y 2srvtfVFjPPFiydm6WNZB5WPnyPhMFISPm17HYk81Y7PPMxTuLnXiATHpi7YmrPgssMz PuNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=DcmxWujH; 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 m3si216085pgs.8.2019.01.09.01.45.02; Wed, 09 Jan 2019 01:45:17 -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=DcmxWujH; 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 S1730676AbfAIJnU (ORCPT + 99 others); Wed, 9 Jan 2019 04:43:20 -0500 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:38448 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730443AbfAIJm3 (ORCPT ); Wed, 9 Jan 2019 04:42:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1547026947; x=1578562947; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=7IzEYV9FoSpsE6ZCAmYPvlNyjLadlOMGwjgHhakmUKQ=; b=DcmxWujHh246pxp8DZRhapkuJtzq+bi01picoVv7dTXYpSiqCVCtPDn8 x8XYkuWm2Zq/XZbqWC0JFV1mKmcmaqe1VSbeVdoBBHtP9ZDS/+W/wWoIp luM2knw69vaA4JmUXbm55MUCrPNl1eScCOMxzhCp6Y7qtYgKwiMkY6VIk A=; X-IronPort-AV: E=Sophos;i="5.56,253,1539648000"; d="scan'208";a="652219861" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-2c-c6afef2e.us-west-2.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 09 Jan 2019 09:42:24 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2c-c6afef2e.us-west-2.amazon.com (Postfix) with ESMTPS id 49969A2321; Wed, 9 Jan 2019 09:42:24 +0000 (UTC) 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 x099gMLQ031347; Wed, 9 Jan 2019 10:42:22 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id x099gMdY031346; Wed, 9 Jan 2019 10:42:22 +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 12/13] KVM/nVMX: Use kvm_vcpu_map for accessing the enlightened VMCS Date: Wed, 9 Jan 2019 10:42:12 +0100 Message-Id: <1547026933-31226-13-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 Use kvm_vcpu_map for accessing the enhanced VMCS since using kvm_vcpu_gpa_to_page() and kmap() will only work for guest memory that has a "struct page". Signed-off-by: KarimAllah Ahmed --- v4 -> v5: - s/enhanced/enlightened - unmap with dirty flag --- arch/x86/kvm/vmx/nested.c | 14 +++++--------- arch/x86/kvm/vmx/vmx.h | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 04a8b43..ccb3b63 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -193,10 +193,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, true); vmx->nested.hv_evmcs_vmptr = -1ull; - vmx->nested.hv_evmcs_page = NULL; vmx->nested.hv_evmcs = NULL; } @@ -1769,13 +1767,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 @@ -4278,7 +4274,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 { diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index bd04725..a130139 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -172,7 +172,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; }; -- 2.7.4