Received: by 10.192.165.156 with SMTP id m28csp3011386imm; Sun, 15 Apr 2018 14:58:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/KP14PRff53kmH4SENG74sALjmaZVfVac40cbc0H5bpBrrPw+aaJLVaZi1IQGZJFYN039e X-Received: by 2002:a17:902:6c07:: with SMTP id q7-v6mr13249192plk.67.1523829527053; Sun, 15 Apr 2018 14:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523829527; cv=none; d=google.com; s=arc-20160816; b=0E+KYEACMWcOauQH1Ava+CPeY7DyDNZs5UG40MMLkNAOt2VcLPwHWJGXYKGFzCiC7D vVE9pph9dsEYOh504Sc689+T2btuDN7isR2ptUI9IajEfGVmEhPWiNQoAWBp1iQw3IaL sIQp8N8VkXP1HX8HGoxsqVjGa+L7hvINPfpQ4XwRbV7SW6XZ889uGO9+5R9ZJYofka4V v7i6MV5WlvD2IffuUf83wBeeMSQs68nTgacbp51Bu3mo0HBsapnGpICMciGUpyOYQvBr XAPmbEAgx32UnhE6WFhbcNdVskJ3n2nCEmSchu7esxMp3EpaZJKIdVLYU8Qa1J44qXM+ zIBQ== 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=XffGxACyfAU5BT/F/KtgMj/aXojN2/Uw7gSOic0ZsOE=; b=myyH5GEvKDEKa1SlBlP8F7QRuNUy8dqVJ79gyDnfJyvBWkNj4igWxhcizBJ0Hl3zqa RYU4JxxeJw9AFVVcm/CsOc5KxxFLwmNWvWlqYtYaGwQEMGS4hsHAcgr05G5mnU8SlEVp Ovs52TXXiVDhZhgSFyTSbwrrZbvKefAYNY3o6zmJoD9NzAISEMGZM9p49Fbf33xnQ4Yq xhESP6NYqIwJgzYLdl/8JC1wBAAMf9jds0/LYERL2rTBGO1HJOc/nto5MP0zAOn/b4/k eZ6nTSnDnfzddefWU6CVVz/ypK5VrZ0b7U7JNKfVrFn8uAh4N2TGUebUzLbXlF6aAnPs s0uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=Zh67pbj7; 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 az11-v6si9356984plb.81.2018.04.15.14.58.05; Sun, 15 Apr 2018 14:58:47 -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=Zh67pbj7; 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 S1753083AbeDOVzt (ORCPT + 99 others); Sun, 15 Apr 2018 17:55:49 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:40933 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750960AbeDOVzB (ORCPT ); Sun, 15 Apr 2018 17:55:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1523829301; x=1555365301; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=XffGxACyfAU5BT/F/KtgMj/aXojN2/Uw7gSOic0ZsOE=; b=Zh67pbj7g2FHlM9C2ZcAerEZIYXRitwmOlr0eAybJb4T+sVbYI/BtCcy zyU5/rxpAO0Mnmmxum2CZY5s7m7+MMBEkqJX6OGMLySdn92Nu1pTegayp UkEGoRVgh3p3qizy2hmT4erYAyOUQf74rLUtgR+7a7E3RjJd4ghqswI31 Q=; X-IronPort-AV: E=Sophos;i="5.48,456,1517875200"; d="scan'208";a="726275411" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Apr 2018 21:54:52 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (iad1-ws-svc-lb91-vlan2.amazon.com [10.0.103.146]) by email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id w3FLsltD080744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 15 Apr 2018 21:54: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 w3FLskIk013406; Sun, 15 Apr 2018 23:54:46 +0200 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id w3FLsk9m013405; Sun, 15 Apr 2018 23:54:46 +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 01/12] X86/nVMX: handle_vmon: Read 4 bytes from guest memory Date: Sun, 15 Apr 2018 23:53:07 +0200 Message-Id: <1523829198-13236-2-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 Read the data directly from guest memory instead 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 --- v1 -> v2: - Massage commit message a bit. --- arch/x86/kvm/vmx.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 55ab0ca..77fc1ee 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -7672,7 +7672,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; @@ -7718,19 +7718,11 @@ static int handle_vmon(struct kvm_vcpu *vcpu) return kvm_skip_emulated_instruction(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) { nested_vmx_failInvalid(vcpu); return kvm_skip_emulated_instruction(vcpu); } - if (*(u32 *)kmap(page) != VMCS12_REVISION) { - kunmap(page); - kvm_release_page_clean(page); - nested_vmx_failInvalid(vcpu); - return kvm_skip_emulated_instruction(vcpu); - } - kunmap(page); - kvm_release_page_clean(page); vmx->nested.vmxon_ptr = vmptr; ret = enter_vmx_operation(vcpu); -- 2.7.4