Received: by 10.192.165.156 with SMTP id m28csp3011708imm; Sun, 15 Apr 2018 14:59:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/rV+iyjHX0ypWt52jyz125U/jdPjwQCsE1Axjb8RAxPCD4qwq0J1eqE+tM967ysczRChdM X-Received: by 2002:a17:902:525:: with SMTP id 34-v6mr13192078plf.267.1523829558154; Sun, 15 Apr 2018 14:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523829558; cv=none; d=google.com; s=arc-20160816; b=O4LqYH41j7r3RAMT+xmsTEO2rVdKiCRbuwsxIbv59S2SI20Z6Oo5nU725rtTUe3C42 v6KLcxXiCl+DP/eeZHGN2b4NXm9wzj8MiqmAJqwoAq1i0H85x9bkD+V1SI5G7bWsZdhU fopnfayyZvX30JwW4S8AfMlTnJ0N7eUNJFibtbspCUg29JCD4rpzBmm4hGkjavhtpJ8K KahbksZ35G2/tYoVl9Iduk8o9UqYzNuU+Nh2zx8lLeHDiJjjvJhqR9KefpGCc044Bonr StdJXI5hGx7aQkZdkBMhkKWcgz5y0Hs/1P0NIfmARdqA8cq6bGCUVG7Zk5EgLmZOaqrY XcFA== 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=CCLDA49EAeHCy6Sgm1hoSJ3MSIrZrg0uef9YItm68VY=; b=MuMuAJOqwoa2Dtn21djXWEO2BmqDStXFkHtgRqR7kLqwenBkSdK7qKigBe57ybKH8o 3ESpQdFAIXolzCQ5DyT894rhTrH/lC/n54voHo51kIJjo4UcbARL+n6on8LD8Q6dMD2o +hbwhl3Nw/G2rcNW6MSF4hsqy70/sMGFzyFhNDinjjbuG4UOtoMsFX5MlnW/x/pWF/7e 0YJIOE9UNte9qiI+8l8veENddPw2wIVw0cI8KcefDtSBZ7JkZh7gkaIiZm3rOvzThLB/ qqVqKLBi9Cz4/FQotOelMFXgbMU6+Lqr7Rhit075lamGsTG+dneIIvcDhtLhGfpakxft XfLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=c7KyOzOX; 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 h10si8174588pgq.514.2018.04.15.14.59.04; Sun, 15 Apr 2018 14:59:18 -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=c7KyOzOX; 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 S1753279AbeDOV5L (ORCPT + 99 others); Sun, 15 Apr 2018 17:57:11 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:7225 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752654AbeDOVy7 (ORCPT ); Sun, 15 Apr 2018 17:54:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1523829298; x=1555365298; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=CCLDA49EAeHCy6Sgm1hoSJ3MSIrZrg0uef9YItm68VY=; b=c7KyOzOXnat+Fj7H4tl4jhGTvs0XDgl3n94GZtoLV1LNOWJIoK9erZfy 8M9XUNjuBE1CDpMUSE5J2Z54m1N1wFGohBh92NgoHHqScbp0s1mOjH8a1 LidwY7I7puotGsrvUI/S6R4c+I1mP1BEB3JniUmuFetRJJS7lGaj75wPX U=; X-IronPort-AV: E=Sophos;i="5.48,456,1517875200"; d="scan'208";a="726275414" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2c-5f221cf9.us-west-2.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:55 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2c-5f221cf9.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w3FLspdP093411 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 15 Apr 2018 21:54:53 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 w3FLsoP5013438; Sun, 15 Apr 2018 23:54:50 +0200 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id w3FLso4S013437; Sun, 15 Apr 2018 23:54:50 +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 06/12] KVM/nVMX: Use kvm_vcpu_map when mapping the L1 MSR bitmap Date: Sun, 15 Apr 2018 23:53:12 +0200 Message-Id: <1523829198-13236-7-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 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 --- v1 -> v2: - Do not change the lifecycle of the mapping (pbonzini) --- arch/x86/kvm/vmx.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 179061d..6d335fc 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -494,6 +494,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; @@ -10513,9 +10516,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: * @@ -10541,11 +10545,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 @@ -10593,8 +10596,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(&to_vmx(vcpu)->nested.msr_bitmap_map); return true; } -- 2.7.4