Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp269889imm; Tue, 21 Aug 2018 19:20:38 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxjyQbFG8ncPOrl9VyeNcXQkdal3k91E1+izVktCbIfMC5IJvISxHyNhzYqoda1cB2gSXOz X-Received: by 2002:a17:902:9f86:: with SMTP id g6-v6mr20342367plq.304.1534904438472; Tue, 21 Aug 2018 19:20:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534904438; cv=none; d=google.com; s=arc-20160816; b=TbDMHAqiYxitjFxJuVpM0Vi87Cf9Sq+6/cDBG4kdOKuY2cmtJ8niQU/8UuZWhY3973 WuRmYIr0bc2kfrVUDCVqsHvQu4/iv4dP7mdDZ0fDhMZAwkem/kpDVHAhSzPcmNmzI4we IY7tsjd+UwhVTrELvo1sxssT8VzIsEBGEBgI1HiLm34byuR4o3KWs6hRFCLQxV69hS8d Q+biVrNZtrIFefIaGVridGhGxY2t9TPT+gPFjijM8u9T7IKIMdGWxKgSSGW2m4NERMPs g3Eh33ZpL9dT0tcXZZoELYs/0oyVeJ/vZsafu7XpzETKmozFrYD1QB4ExJ8bgkMtDtPg 2gnA== 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:arc-authentication-results; bh=/S5I0vc4uBBKNzwfsj2Hye0o7S98ojvXNwNXYVIqaJA=; b=miru023UtlNqyMYHang39z8P8m+o0QPrEq/prtX1yjLBoMIQN0jECsfztgp3SX/IR3 o04yBiRF9GC9lYr6R2bI9U/ojgqL7ioDI9ow8r23/gMFfh8CD87LG8rTgm0ikrRKwyGi +r/l3lWkjOLvxeOhbNkLcseG9Xy1e/CBKbZ7dd6BXy5jqlmU4x9mszxRifkXCoIa5st4 O8kpHLd00HUqgw3pD9CriWafn7ar8ysErZpexQn/t9wyFQFcwZhx3a1xmgpKR+BVTooD n7P32PXcPqyxhRwFeF2IwHGpg3UEpqbR4KmtfrsS0mIIYlIbqPzyRPsFbJUWlrEQwZTc v+1w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q16-v6si495438pfi.183.2018.08.21.19.20.23; Tue, 21 Aug 2018 19:20:38 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727865AbeHVFmB (ORCPT + 99 others); Wed, 22 Aug 2018 01:42:01 -0400 Received: from mga18.intel.com ([134.134.136.126]:53099 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726298AbeHVFmB (ORCPT ); Wed, 22 Aug 2018 01:42:01 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2018 19:19:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,272,1531810800"; d="scan'208";a="83404610" Received: from linux.intel.com ([10.54.29.200]) by fmsmga001.fm.intel.com with ESMTP; 21 Aug 2018 19:19:18 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id 95AB55802C8; Tue, 21 Aug 2018 19:19:15 -0700 (PDT) From: Zhang Yi To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, pbonzini@redhat.com, dan.j.williams@intel.com, dave.jiang@intel.com, yu.c.zhang@intel.com, pagupta@redhat.com, david@redhat.com, jack@suse.cz, hch@lst.de Cc: linux-mm@kvack.org, rkrcmar@redhat.com, jglisse@redhat.com, yi.z.zhang@intel.com, Zhang Yi Subject: [PATCH V4 4/4] kvm: add a check if pfn is from NVDIMM pmem. Date: Wed, 22 Aug 2018 18:58:10 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For device specific memory space, when we move these area of pfn to memory zone, we will set the page reserved flag at that time, some of these reserved for device mmio, and some of these are not, such as NVDIMM pmem. Now, we map these dev_dax or fs_dax pages to kvm for DIMM/NVDIMM backend, since these pages are reserved, the check of kvm_is_reserved_pfn() misconceives those pages as MMIO. Therefor, we introduce 2 page map types, MEMORY_DEVICE_FS_DAX/MEMORY_DEVICE_DEV_DAX, to identify these pages are from NVDIMM pmem and let kvm treat these as normal pages. Without this patch, many operations will be missed due to this mistreatment to pmem pages, for example, a page may not have chance to be unpinned for KVM guest(in kvm_release_pfn_clean), not able to be marked as dirty/accessed(in kvm_set_pfn_dirty/accessed) etc. Signed-off-by: Zhang Yi --- virt/kvm/kvm_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c44c406..969b6ca 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -147,8 +147,12 @@ __weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, bool kvm_is_reserved_pfn(kvm_pfn_t pfn) { - if (pfn_valid(pfn)) - return PageReserved(pfn_to_page(pfn)); + struct page *page; + + if (pfn_valid(pfn)) { + page = pfn_to_page(pfn); + return PageReserved(page) && !is_dax_page(page); + } return true; } -- 2.7.4