Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp523377imu; Wed, 9 Jan 2019 01:44:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN4z/Lv93+W194VCpjVHBqMVJWJBMAGQMhpR/AmRQop4wyNr8l45FzPkLwo0IyyAYgJ7MOBS X-Received: by 2002:a63:9809:: with SMTP id q9mr4748102pgd.109.1547027054309; Wed, 09 Jan 2019 01:44:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547027054; cv=none; d=google.com; s=arc-20160816; b=Y4HiPu669jgS58YlWS6qu3chIlCsvrn3/l3qNMUy2xRs8xMIhChwTBF+LlL4t0X0tJ 2vO6yLIitFgIKtUrhmAWsSLU9j4NXe6JEWntHIJdxiSLW/Hz2dEQHDI+WxpMKfTCB8XT HC42KVUFzAkl19rtrjvKDWdFr/8142nyOce0hhnn8Gw3DAvTSWjt2z9G2Jt5l+7Y/1fd 3dkW5CY6IxnPDV20FreNFFBJjKc2kHAvWa+0ZT431EmcrGCzizb71xpBX/WFfbsQnvSh 2R86qdGhpeoGq42WVJlUjo++ml9F7F5dSQflYByWNGOOuiUhOm07nWCzTveLfaA8cbCD V7tQ== 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=XbWRGoXnn2oE8QHX9uLOJdr6uqyHPEfkHSA8iqnU1AQ=; b=OYOQbJ1mSaeUgh2KWbsh42Vfmt9K7+uWsjvwrSc4Kff1nJ1UdRRoLQUtJMBp3To0Js gjNuXn4GwZK5XrnjXMAxZoNGidTBrKeHUc6+SudpgvFEyhIPCocN2Ru4UZuPoior4JtQ 3urax2O2vinsBnr7P3B+LgRq92Lm3P9fni+LgcQ71KoSWC2Md+M+fwME5KBYNeF7+YhC N9oTHDo3GBM4W+91Uxx3MfLSJbE5Fs60o1ZkZOIbX0eWUCJPmWKGvYf3WT8ZQ+KjjkTm 4EBaGn76vkMGAc3ap2WOXhoC0rjywG6XriITGuxw91hG4lFXs3/3C8FaX9s1MxONVpyE DDiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=q8yKGqg6; 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 o1si19409829plk.257.2019.01.09.01.43.58; Wed, 09 Jan 2019 01:44:14 -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=q8yKGqg6; 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 S1730537AbfAIJmc (ORCPT + 99 others); Wed, 9 Jan 2019 04:42:32 -0500 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:7747 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729402AbfAIJmY (ORCPT ); Wed, 9 Jan 2019 04:42:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1547026943; x=1578562943; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=XbWRGoXnn2oE8QHX9uLOJdr6uqyHPEfkHSA8iqnU1AQ=; b=q8yKGqg66sjdHXLEUxOD8/YV+fKhTAvHT6aHUc3dR6ArdDHemQ8bhmS8 /n6B8Py/oVFx96FxAIh3aiQrNO7oSuFQQfy4QgnYdkTy+xazTYZk60Zfq imiQWQO/2T0rFdTJXS11cw81LxdmeP9zRx2E5EwcaYWnb+tMBGWj+eWGd 4=; X-IronPort-AV: E=Sophos;i="5.56,253,1539648000"; d="scan'208";a="775449725" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2c-1968f9fa.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 09 Jan 2019 09:42:21 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (pdx2-ws-svc-lb17-vlan2.amazon.com [10.247.140.66]) by email-inbound-relay-2c-1968f9fa.us-west-2.amazon.com (Postfix) with ESMTPS id 75161A2774; Wed, 9 Jan 2019 09:42:20 +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 x099gIuC031311; Wed, 9 Jan 2019 10:42:18 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id x099gIc4031310; Wed, 9 Jan 2019 10:42:18 +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 05/13] X86/nVMX: handle_vmptrld: Use kvm_vcpu_map when copying VMCS12 from guest memory Date: Wed, 9 Jan 2019 10:42:05 +0100 Message-Id: <1547026933-31226-6-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 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 --- 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 536468a..5602b0c 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 @@ -4536,12 +4535,13 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu) VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID); return kvm_skip_emulated_instruction(vcpu); } - 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(&map, false); return nested_vmx_failValid(vcpu, VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID); } @@ -4553,8 +4553,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(&map, false); set_current_vmptr(vmx, vmptr); } -- 2.7.4