Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1774894imm; Thu, 9 Aug 2018 01:34:24 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyQss2Up6kWeKT3t/vFUkvm/fyZlioPvejkk0XBGeMhsRs91ONji5Cl9PTBZftjRXe9CsDB X-Received: by 2002:a63:2c8e:: with SMTP id s136-v6mr1198329pgs.390.1533803664431; Thu, 09 Aug 2018 01:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533803664; cv=none; d=google.com; s=arc-20160816; b=jNovsP0tie2VzzWbD+Y/Gnvo9ljrx4qLnnHMjer4chZCUmVFwkC1377+tZ2S5P3eYu zUgXvMrNDVV9nz0qnpaaYsw5qjZWE6UKzB/Xw42nxhx5ANDJ3ARtdo5P8gCxs/HvWIKB CKBEvh3zDAgp+W8f8kQHmwzC2NpqxKxSVaZhsHA48TVy3NCC/LLaXw/1qeTWIo/Lfjox A1MQkeXk4RnF7WkU9RbIYqSHSiub9+sp9591W2JSrD7j1ho7iHPug4dwXlD+eqnCBVXc 2wFjrAQs3ObMqeqJtpr+dVNSkcHS8YFa5hT9taBiO9yTAkryM+EGJVGyFr+7IbaeGX8M uDdg== 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=TgzwSR8PYhxb45Fo2EwZcCmBaCesILief1vP8ICJYMI=; b=RFGMi5DySWNKJ+2wQ07jRsuKWdNUe9danoVyOo6fOM/qUOFsxffCkgr2JAmyqRFkEn IMGHGohCLIgT24nn7Hss5GA2ta8+fwK6mLl6T0eqDBhm9M47zK8cETgu53wQdT5R6s6S hr020+B7IBT+pYEX6I0/mV0C4LvL9Bcigv3UGDimUwJYkXpX/tZ7gX3gCG2vQYsazE2f w6XqXDD/7ak/k8tYMQfuhPYnhREwpEw+OMSk17klbEhWtHM6suYWcK5uMEVD8Sq3CR4X nlU/ToxGpQaVlLEhG/616Kp8YhnDm0EOhiKFML38r9mUP6D4yGagofMKNIT30nlUq4gt nfuw== 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 k26-v6si7255138pfk.199.2018.08.09.01.34.09; Thu, 09 Aug 2018 01:34:24 -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 S1730058AbeHIKzw (ORCPT + 99 others); Thu, 9 Aug 2018 06:55:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52096 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727601AbeHIKzw (ORCPT ); Thu, 9 Aug 2018 06:55:52 -0400 Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF28A3082143; Thu, 9 Aug 2018 08:32:06 +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 BA46A30012DB; Thu, 9 Aug 2018 08:32:06 +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 99ABD1800B68; Thu, 9 Aug 2018 08:32:06 +0000 (UTC) Date: Thu, 9 Aug 2018 04:32:06 -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 , jack@suse.cz, hch@lst.de, yu c zhang , linux-mm@kvack.org, rkrcmar@redhat.com, yi z zhang Message-ID: <2130082365.883434.1533803526182.JavaMail.zimbra@redhat.com> In-Reply-To: <0cc6cba7020f80168695fba731b8fd72fd649dc8.1533811181.git.yi.z.zhang@linux.intel.com> References: <0cc6cba7020f80168695fba731b8fd72fd649dc8.1533811181.git.yi.z.zhang@linux.intel.com> Subject: Re: [PATCH V3 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.22, 10.4.195.8] Thread-Topic: add a check if pfn is from NVDIMM pmem. Thread-Index: 4tDt2TqHqXjz5eV1uzkL/Oc3LQTnag== X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 09 Aug 2018 08:32:07 +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 indentify these pages are from NVDIMM pmem. and let kvm treat these s/indentify/identify & remove '.' > 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 > >