Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp63581ima; Thu, 31 Jan 2019 12:27:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IZDyox5ie6lqTaRwFtJdK98ySyQkNtxIG+pjNkryin2kIZehq3s0oC7g/5wsze/AKSnk9Bv X-Received: by 2002:a62:8a57:: with SMTP id y84mr5264276pfd.197.1548966442843; Thu, 31 Jan 2019 12:27:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548966442; cv=none; d=google.com; s=arc-20160816; b=pSDirREY1cJdK20chCTTd7mRvycG3cpVUoihTVEPzuLwmBjNPt5BCdd9YyD/6T9+2I +YDeHsAJ1FoBFBFf5r4mE+zqjZVsfu+osngYcMi/itZ5ZxuKa04afUMrxVHrj1tkDnxO G+Tf91jRmLKrRU5BnNNq4cUANTWKi4mISqMa9DcErixdbedF+1k07JZC+iAE2B8MGLmq Kxotg0lbwQqAQJ6JoPa6CbEII2tCGr8OmaRBJvT+cRAcpTFdtZMvZJp3N6FgmanugSfn Jbvwd32jQZDj6dLClptKLbMft1O7RwiOZbpo2IwAwZuLD0Ve80rqr2XEVBLWOiygwAeo 4Igg== 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=f9uDHmL2VR9YxEOmcnUkqCx0VWRQBeZ8FR9P+ZAbcIw=; b=ZPpffOkx7jJoIYoqOZTGDdJTu37/DVhIT5vpgsCkuDDUaEIGIqySOlcTFLkfZ0QCRK KkAZjUlOSiHsJbyM52w36FHE90u4ikPOtil0o1SKrmhkqi4xG/bzTgdwFaz6SKGoaJ1h 6/N799CrVzFQkz97vpxg3l5ssPFydz3yxjsDj8WiyDeM8X776UU1kM+GL0XF1HD4JzPA JlLcih6pHTgcf0v98o3u5VpK8aj0oGZzELw5D+9rg/YoA20/ZLdat3njtzbl+n9TBBe5 Z23CfIrLAq5EldOWD0JYYF+xXi8ppyv2wSHWCyttt4+nTVQMg0Xu7ucXH/hIrAtxdfJ3 hOew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=LhylDaW2; 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 v6si5307735pfv.181.2019.01.31.12.27.06; Thu, 31 Jan 2019 12:27:22 -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=LhylDaW2; 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 S1727962AbfAaU1A (ORCPT + 99 others); Thu, 31 Jan 2019 15:27:00 -0500 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:11820 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727779AbfAaU05 (ORCPT ); Thu, 31 Jan 2019 15:26:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1548966416; x=1580502416; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=f9uDHmL2VR9YxEOmcnUkqCx0VWRQBeZ8FR9P+ZAbcIw=; b=LhylDaW2g/JHAo/io9VhJfDHyBoR0PE1n3IgStJsWIKiKhVyxliT1Tn4 8KadWiewnM9cSS6z1mVqqF3qNupCYdGf6cWo1wnyaG+d4WS/iI3xiysLt SDoMEDM+iFWtDDVVLjrymltMJ1X79ic24GLIj8okzmzHnJyrjeaXg/FPu 0=; X-IronPort-AV: E=Sophos;i="5.56,545,1539648000"; d="scan'208";a="784846688" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 31 Jan 2019 20:26:53 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (iad7-ws-svc-lb50-vlan2.amazon.com [10.0.93.210]) by email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id x0VKQkMt014462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 31 Jan 2019 20:26:49 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 x0VKQiFY028884; Thu, 31 Jan 2019 21:26:45 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id x0VKQiFq028883; Thu, 31 Jan 2019 21:26:44 +0100 From: KarimAllah Ahmed To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Paolo Bonzini Cc: KarimAllah Ahmed Subject: [PATCH v6 01/14] X86/nVMX: handle_vmon: Read 4 bytes from guest memory Date: Thu, 31 Jan 2019 21:24:31 +0100 Message-Id: <1548966284-28642-2-git-send-email-karahmed@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548966284-28642-1-git-send-email-karahmed@amazon.de> References: <1548966284-28642-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 Read the data directly from guest memory instead of the map->read->unmap sequence. This also avoids using kvm_vcpu_gpa_to_page() and kmap() which assumes that there is a "struct page" for guest memory. Suggested-by: Jim Mattson Signed-off-by: KarimAllah Ahmed Reviewed-by: Jim Mattson Reviewed-by: David Hildenbrand Reviewed-by: Konrad Rzeszutek Wilk --- v1 -> v2: - Massage commit message a bit. --- arch/x86/kvm/vmx/nested.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 8ff2052..11b44a9 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -4192,7 +4192,7 @@ static int handle_vmon(struct kvm_vcpu *vcpu) { int ret; gpa_t vmptr; - struct page *page; + uint32_t revision; struct vcpu_vmx *vmx = to_vmx(vcpu); const u64 VMXON_NEEDED_FEATURES = FEATURE_CONTROL_LOCKED | FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX; @@ -4241,18 +4241,10 @@ static int handle_vmon(struct kvm_vcpu *vcpu) if (!PAGE_ALIGNED(vmptr) || (vmptr >> cpuid_maxphyaddr(vcpu))) return nested_vmx_failInvalid(vcpu); - page = kvm_vcpu_gpa_to_page(vcpu, vmptr); - if (is_error_page(page)) + if (kvm_read_guest(vcpu->kvm, vmptr, &revision, sizeof(revision)) || + revision != VMCS12_REVISION) return nested_vmx_failInvalid(vcpu); - if (*(u32 *)kmap(page) != VMCS12_REVISION) { - kunmap(page); - kvm_release_page_clean(page); - return nested_vmx_failInvalid(vcpu); - } - kunmap(page); - kvm_release_page_clean(page); - vmx->nested.vmxon_ptr = vmptr; ret = enter_vmx_operation(vcpu); if (ret) -- 2.7.4