Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp66276ima; Thu, 31 Jan 2019 12:30:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN6KWpeVh4/uDL1oLvRgg5IPVdXtEq7wl01s0fhtt2dt+2QD72ScbQQwFlDF/NXs5CiyCF1s X-Received: by 2002:a63:1f1c:: with SMTP id f28mr32923107pgf.193.1548966604251; Thu, 31 Jan 2019 12:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548966604; cv=none; d=google.com; s=arc-20160816; b=egjqcDIarNM6EROXq6BRI4B+M+/YnEXO81dbcHehahO4SNC681jPGZaXR+9gTx6Gpr wbKqgsMfIOORN/CRHyFZUC9F0exAC3+VrsM156lJfli/DZLulcwQqWmpbWvTEy7Of7Sz qLKV/OMV6lZdfeixX4NjlDjJyX+VKs1xTj2on5D6m2M70/lVlc0IH9oVbY3owbfZ6lZe 3hXM+PYnSEdGVIlQq0ajY/OUkFPOxWR9PkzyrfDdW3H6rhKnUUoQ7+Xr1yqb1IECUqiZ GrvW9I7Z1zzvZJiH/+bCfkiRe/AANBoTWgxUUWkADVIvVCii4p4oOYeXiZasMFPCMIQr eTFA== 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=9sgF47MrbxyAsS7U5ZelyCSmc8JbJdu5SVylQaC5hcI=; b=rxp8ODQ37I49woOGMZQ9zzzxGhMW966xnsgln8eSuRMe59P+0YTkQZgNfdMpUt3d09 WiQDbvNlFW4rN/cNd/3FBgr3ALD2raBTTucO0ZOu7xFCLM3QhdhRiZ0WlMt6jQS6bMtw 3vOVxbpT03ISA2gk27kV4wKd4vt5naPg8bolVk9DxWXtJRAP+oXXACaoFWMuz2vXrrCw 0OzzrilJeWgTpb4hiiI+Y1l+WscUuIzV1OV8W+a87MGX8yt1Myvd3eo27XCb7dk/mCDp /P9kIXR9drGdzGDHgXT1TNqZ7JcBs6vu7l33JvgnvxBmq0W6QdJ45UD6Wq4y2hROSqCx XBGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b="QeVhQt/Q"; 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 bh5si5170891plb.42.2019.01.31.12.29.49; Thu, 31 Jan 2019 12:30:04 -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="QeVhQt/Q"; 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 S1728890AbfAaU2A (ORCPT + 99 others); Thu, 31 Jan 2019 15:28:00 -0500 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:24204 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728182AbfAaU1F (ORCPT ); Thu, 31 Jan 2019 15:27:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1548966424; x=1580502424; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=9sgF47MrbxyAsS7U5ZelyCSmc8JbJdu5SVylQaC5hcI=; b=QeVhQt/Q+ergf8evqtjBMulqQHZ1j1pVo6G/DGwGrTQNlWdiL1VUkmku QmM2groth0WfoHqhVAB/OoX9+23oIlVEO+jmSWGoeYe8g8LbiYLs8onxr yjNuDoAYnPYbqZrTEXJ+bURQ8AGGonoeCHxh6GabnHGCJUYTRjeiCffwf Q=; X-IronPort-AV: E=Sophos;i="5.56,545,1539648000"; d="scan'208";a="656822797" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-2a-8549039f.us-west-2.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 31 Jan 2019 20:27:01 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2a-8549039f.us-west-2.amazon.com (Postfix) with ESMTPS id DE4B8A2185; Thu, 31 Jan 2019 20:27:00 +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 x0VKQwAW028967; Thu, 31 Jan 2019 21:26:58 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id x0VKQv24028963; Thu, 31 Jan 2019 21:26:57 +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 06/14] KVM/nVMX: Use kvm_vcpu_map when mapping the L1 MSR bitmap Date: Thu, 31 Jan 2019 21:24:36 +0100 Message-Id: <1548966284-28642-7-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 when mapping the L1 MSR bitmap since using 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: - unmap with dirty flag v1 -> v2: - Do not change the lifecycle of the mapping (pbonzini) --- arch/x86/kvm/vmx/nested.c | 11 +++++------ arch/x86/kvm/vmx/vmx.h | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 8fc327f..1813211 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -507,9 +507,10 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) { int msr; - struct page *page; unsigned long *msr_bitmap_l1; unsigned long *msr_bitmap_l0 = to_vmx(vcpu)->nested.vmcs02.msr_bitmap; + struct kvm_host_map *map = &to_vmx(vcpu)->nested.msr_bitmap_map; + /* * pred_cmd & spec_ctrl are trying to verify two things: * @@ -535,11 +536,10 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu, !pred_cmd && !spec_ctrl) return false; - page = kvm_vcpu_gpa_to_page(vcpu, vmcs12->msr_bitmap); - if (is_error_page(page)) + if (kvm_vcpu_map(vcpu, gpa_to_gfn(vmcs12->msr_bitmap), map)) return false; - msr_bitmap_l1 = (unsigned long *)kmap(page); + msr_bitmap_l1 = (unsigned long *)map->hva; if (nested_cpu_has_apic_reg_virt(vmcs12)) { /* * L0 need not intercept reads for MSRs between 0x800 and 0x8ff, it @@ -587,8 +587,7 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu, MSR_IA32_PRED_CMD, MSR_TYPE_W); - kunmap(page); - kvm_release_page_clean(page); + kvm_vcpu_unmap(vcpu, &to_vmx(vcpu)->nested.msr_bitmap_map, false); return true; } diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index 9932895..6fb69d8 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -144,6 +144,9 @@ struct nested_vmx { struct page *apic_access_page; struct page *virtual_apic_page; struct page *pi_desc_page; + + struct kvm_host_map msr_bitmap_map; + struct pi_desc *pi_desc; bool pi_pending; u16 posted_intr_nv; -- 2.7.4