Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp414343imm; Wed, 29 Aug 2018 03:17:12 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY4/Yg1J9vMl1n9213C1LMIudL1Ui3hO2RFsO5raGOUaeWexVfVGnLiU+5DZ8a83vxxfplh X-Received: by 2002:a65:4d42:: with SMTP id j2-v6mr5053209pgt.232.1535537832374; Wed, 29 Aug 2018 03:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535537832; cv=none; d=google.com; s=arc-20160816; b=fvavNZSy0jevwLPAfnSnMRKyxipmDhuzbJ2IoWeF6D0grh9kR3LIp2vHMvN89DVtwb OQNOTNt96gps7We9EeKoiAvZ9ZQeNxLMhqmv9JenOOALhIyYFOv3LjJDyq3hfDdY4fvB 9mwM4BLHAXMCanxAINXZCCdMqG+G6xDYBe/UxsNhGRmFvcj8JnhtulN1dus7QuSl2uWB ee8i/mDdE1sNaD9qwqNIi4wBQO+xXBmefh8xpubHe5FLPUtuDSULjz3utSjwt2+Qg6Yv rdTtyFeIieBuSxFmJqrOFt/YXt1I17DmEtFEku9roan1Bzc+CZJcH9MEQ5hmhMt2liFi oqKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:arc-authentication-results; bh=bIagNCpvimnt1vbDsC8iRpRD/N6JuVPk48xEO9gS5OQ=; b=ibwDXLufcHvgiho8QQQJPybgToxjCrGi3SIOdwHktjD4tK9F5d0jVWXH5oArK6a4jW pHp8HKT0JHBUNyPz/Wua0sIyx1fZBI0pv4lN+4/Ot0lWVjfqTiM2cMK5yfffgh1xW5Vf egaHW7F+P1ZSXWkE1ZXmC2Huz3XtUU332r2+sTkRp16cUXVrpfPOiOp+b8KUZhRHTrjO UClq4FZyCxa8BwiLqzW0tAs4v/rdq+dcvVsZRfd8iN8qAFALe23hxLe06OnI7Cuy7/Kx VVg/LEJMOEsTnAejzcWp3MhZM+1pyxNFSEIE+QBjldWx3JKfi6QAK0z/SpfVBwwvfgmP +Qsw== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3-v6si3109069plk.406.2018.08.29.03.16.56; Wed, 29 Aug 2018 03:17:12 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727492AbeH2OMB (ORCPT + 99 others); Wed, 29 Aug 2018 10:12:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8172 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbeH2OMB (ORCPT ); Wed, 29 Aug 2018 10:12:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D7B73082A41; Wed, 29 Aug 2018 10:15:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD2FD5DEF9; Wed, 29 Aug 2018 10:15:49 +0000 (UTC) Received: from zmail21.collab.prod.int.phx2.redhat.com (zmail21.collab.prod.int.phx2.redhat.com [10.5.83.24]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 44A3F1808855; Wed, 29 Aug 2018 10:15:49 +0000 (UTC) Date: Wed, 29 Aug 2018 06:15:48 -0400 (EDT) From: Pankaj Gupta To: Zhang Yi Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, pbonzini@redhat.com, dan j williams , dave jiang , yu c zhang , david@redhat.com, jack@suse.cz, hch@lst.de, linux-mm@kvack.org, rkrcmar@redhat.com, jglisse@redhat.com, yi z zhang Message-ID: <380594559.7598107.1535537748154.JavaMail.zimbra@redhat.com> In-Reply-To: References: Subject: Re: [PATCH V4 4/4] kvm: add a check if pfn is from NVDIMM pmem. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.65.193.73, 10.4.195.27] Thread-Topic: add a check if pfn is from NVDIMM pmem. Thread-Index: JCvcOeCBF3io5zdQkGycpA4mvM3AIA== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 29 Aug 2018 10:15:50 +0000 (UTC) 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; > } Acked-by: Pankaj Gupta > -- > 2.7.4 > >