Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp65663ima; Thu, 31 Jan 2019 12:29:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN7TKUYVXa5CJBHd/ZuSX7MMvBrJGD8egHtPC4pUWlF/2puarz3vm1nC6wHIFAdTg6E4G9Db X-Received: by 2002:a63:4706:: with SMTP id u6mr31065602pga.95.1548966564792; Thu, 31 Jan 2019 12:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548966564; cv=none; d=google.com; s=arc-20160816; b=hZ3dkHCQOohJtj/aPnccWSs82Vm7qPvArpKRbOnqGY8d/MVnC2bvgZFe9Pp5PihbVI p1Q5usvIZNuS+2X6zfGmRwrDkcGvDGx1juP1G1a4XJi6JfKWu+EVYVvw+SMMQ1wydI63 LXj5j70cGusPN9yZshynA/oz77L2UXWookKVOQL7a3uKdRxprQ3OXGOvDd/Hr09Q/kzi I2Bdsg1iD6VBsrwgkmSbfCs/Iln+3EN3bKvYxLvVHLW7/4YVN0NLs5AJZ0cyOXdrOEnz a/Pj/ITdCWsj4r48RhC5Ls3xsJZ+do0I5a+z8+FOQjoIAqt/NoKVBxJAf73ut/saa1EH ydmw== 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=yyv/ktHqXfbgyu4K/Sv+eYMPLlWFGHe4R+6uDph1f1A=; b=sZCSDqu8hx9NfiXp2+BTzC+FMu/Vo/L5p5cc3TdRSJs5UjUhB3aevAf7ZYogD77/w3 UmyBa6m9jmq5DpkIPD1FM90jvOGSzfL/HKx1dauiX4R0+PFw3kbTUYSZMQv7nI+cy0qA ZpKwa4ZKwx+2s9I3SFD4NzgIBL/VsV8Z2BkzXSoOQscVBo9g15H9buOxF6+pv/bPPvFr bboEOhf7G5Vppq7MKh94CgX9aD3/ck9Yx4AmKW24j0cCs//ch0h+Ig7PS9JQHCBmGamH jwf4if4h1Oasr0nQlcJzOXVXdu1GbcuNOiRr2sHxnFDWExVNcgirNU6Z8nBvwfE8uMCW sK2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=Zgy1gWU2; 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 f18si5208615pgl.457.2019.01.31.12.29.09; Thu, 31 Jan 2019 12:29:24 -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=Zgy1gWU2; 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 S1728276AbfAaU1F (ORCPT + 99 others); Thu, 31 Jan 2019 15:27:05 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:49881 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727997AbfAaU1C (ORCPT ); Thu, 31 Jan 2019 15:27:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1548966421; x=1580502421; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=yyv/ktHqXfbgyu4K/Sv+eYMPLlWFGHe4R+6uDph1f1A=; b=Zgy1gWU2cH4x4KiMEl0go19cDGM+GzECgJW1uP5PR5htdShR71E5yn7Z yUJB65volDgHalDQZITjZz8NjyKKiv0l/DvSIOBwBqy2rlpWJ/l3cz4mT S7TLJB2r2A6ADK7zWrWP14Tc7JQ6h5MZbXj7KBS8pE0prF6fs8ZQ4fGuS s=; X-IronPort-AV: E=Sophos;i="5.56,545,1539648000"; d="scan'208";a="384482656" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-4e7c8266.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 31 Jan 2019 20:27:00 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2c-4e7c8266.us-west-2.amazon.com (Postfix) with ESMTPS id 8E1D6A23A5; Thu, 31 Jan 2019 20:26:59 +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 x0VKQvDb028959; Thu, 31 Jan 2019 21:26:57 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id x0VKQuJf028958; Thu, 31 Jan 2019 21:26:56 +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 05/14] X86/nVMX: handle_vmptrld: Use kvm_vcpu_map when copying VMCS12 from guest memory Date: Thu, 31 Jan 2019 21:24:35 +0100 Message-Id: <1548966284-28642-6-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 Use kvm_vcpu_map to the map the VMCS12 from guest memory because kvm_vcpu_gpa_to_page() and kmap() will only work for guest memory that has a "struct page". Signed-off-by: KarimAllah Ahmed Reviewed-by: Konrad Rzeszutek Wilk --- v4 -> v5: - Switch to the new guest mapping API instead of reading directly from guest. - unmap with dirty flag v3 -> v4: - Return VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID on failure (jmattson@) v1 -> v2: - Massage commit message a bit. --- arch/x86/kvm/vmx/nested.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 11b44a9..8fc327f 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -4521,11 +4521,10 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu) return 1; if (vmx->nested.current_vmptr != vmptr) { + struct kvm_host_map map; struct vmcs12 *new_vmcs12; - struct page *page; - page = kvm_vcpu_gpa_to_page(vcpu, vmptr); - if (is_error_page(page)) { + if (kvm_vcpu_map(vcpu, gpa_to_gfn(vmptr), &map)) { /* * Reads from an unbacked page return all 1s, * which means that the 32 bits located at the @@ -4535,12 +4534,13 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu) return nested_vmx_failValid(vcpu, VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID); } - new_vmcs12 = kmap(page); + + new_vmcs12 = map.hva; + if (new_vmcs12->hdr.revision_id != VMCS12_REVISION || (new_vmcs12->hdr.shadow_vmcs && !nested_cpu_has_vmx_shadow_vmcs(vcpu))) { - kunmap(page); - kvm_release_page_clean(page); + kvm_vcpu_unmap(vcpu, &map, false); return nested_vmx_failValid(vcpu, VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID); } @@ -4552,8 +4552,7 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu) * cached. */ memcpy(vmx->nested.cached_vmcs12, new_vmcs12, VMCS12_SIZE); - kunmap(page); - kvm_release_page_clean(page); + kvm_vcpu_unmap(vcpu, &map, false); set_current_vmptr(vmx, vmptr); } -- 2.7.4