Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp541700imu; Wed, 9 Jan 2019 02:07:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Vbl3TwGhQTWREtWOriqpAEvsE3Ay+vQbWiXVPQTmQgWEcsuE4WXmadi856L81SA3hKa3V X-Received: by 2002:a62:3811:: with SMTP id f17mr5430425pfa.206.1547028433550; Wed, 09 Jan 2019 02:07:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547028433; cv=none; d=google.com; s=arc-20160816; b=NxMJYnDWhk8edoloOFn9q3ktHEZXvJs7Dlu4DOfB4GNxFnH/T6cC7TNMc1sH+VNF5j I9v0cR1MNT59uRRnbfFHotR2l8jyjPHRIvu9bUJI24nVV1/o9nXT+F/JYQXpzFR7749r fDDeL/Ma41cXf92AsYY/sBgBwF4uvrPTVxgRqW/eH/xaESYS2bVbr0Qtf58pq7RQyvjV sS5KlRkLbDaKmeqt5UnXB3LOygtSlS7YmGF9N/K+8dCHzCSKHcDJdf0PrzgHiIobsMh1 Yw3T4tCAncwJVdCo2ICWVBgomJ3m9HageFe1fobUO6OlJMGm8NzKkrJH54uZbagEcpVe DThQ== 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=ZYLquAt/UJH2B+U3x9AIYwZ9ehf1JWHBceR3nijqvug=; b=Ty7AyrGEa6e0NTXTOCMTy50hvYGpzuX8cvMjgilcQOdGfBNvkMyPEL59uBjpR4mmVT Nw4TOmuN+w52J12YYvK4BKocaetpHKZYpAyLnjt+8ztHz3378QxyCXr3QigRwQA411rd uB0sBybYpjqmOJfR9xyQAU6UzcrvzUnnOB6KTOY1hAm51CMn+jlMV6Ny+ubWhwJftG6x +TN/P9f6HCQOXxDrEratNNt79wPLf4AimcmIzMaF9+DBb06JUldeWQR7e5j+7IYqro8y GMzQY6Bx8yByb7jBvnoXUTIJRbJ+Qv2IMD3cVbeDgiwy5c7NGrlgwQ9nqEnBshn4X3vs jcow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=nF37EElz; 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 l5si69824674pls.423.2019.01.09.02.06.58; Wed, 09 Jan 2019 02:07:13 -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=nF37EElz; 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 S1730297AbfAIJmV (ORCPT + 99 others); Wed, 9 Jan 2019 04:42:21 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:29960 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727828AbfAIJmV (ORCPT ); Wed, 9 Jan 2019 04:42:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1547026939; x=1578562939; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ZYLquAt/UJH2B+U3x9AIYwZ9ehf1JWHBceR3nijqvug=; b=nF37EElzlTFix/lTX4pB4ZIwX7wSnizZ3ThbEtVEmu561ng55sSPIyMW F2TqzsNtQkbV9oxzeF2vWnbJjCgRmw+HNPmj38EjyMfWUIcZzBlERwTgC Tso04uT5EYOXanBhnUQrsS1A98aJpXhILiITjhJioxZgLWYM3CoS+8ufy 0=; X-IronPort-AV: E=Sophos;i="5.56,253,1539648000"; d="scan'208";a="380876324" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-6f38efd9.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 09 Jan 2019 09:42:18 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (pdx2-ws-svc-lb17-vlan2.amazon.com [10.247.140.66]) by email-inbound-relay-2c-6f38efd9.us-west-2.amazon.com (Postfix) with ESMTPS id 4B0E9A243A; Wed, 9 Jan 2019 09:42:18 +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 x099gGpp031294; Wed, 9 Jan 2019 10:42:16 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id x099gGSo031293; 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 01/13] X86/nVMX: handle_vmon: Read 4 bytes from guest memory Date: Wed, 9 Jan 2019 10:42:01 +0100 Message-Id: <1547026933-31226-2-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 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 --- 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 3170e29..536468a 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