From patchwork Wed Aug 22 10:55:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10572513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC4E7112E for ; Wed, 22 Aug 2018 02:16:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC0482B298 for ; Wed, 22 Aug 2018 02:16:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF5582B2A3; Wed, 22 Aug 2018 02:16:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 460FD2B2A6 for ; Wed, 22 Aug 2018 02:16:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 487B96B21EB; Tue, 21 Aug 2018 22:16:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4101A6B21EC; Tue, 21 Aug 2018 22:16:37 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B1BD6B21ED; Tue, 21 Aug 2018 22:16:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id DB94D6B21EB for ; Tue, 21 Aug 2018 22:16:36 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id q67-v6so296171pgq.9 for ; Tue, 21 Aug 2018 19:16:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=wanBcbq/yF+jBQEp+neJiKsEo/O9XaVJFA4o+oKSU0M=; b=Zz5phC0gXlsjYRaJr4j57b3PxoEG4kCEXBa83Y9Togq4V9jZWS4e+7l3ZWk8BMpeGM c7jeaT18SH8kUED8NMQzLZ/DccG1q5ANxhe0kiDy6cM0HXdG3DgWnOpJBMF0nOu5l1me CBohB85Xmk/t/1dj5lu2C3CrCgoiWa1QaDwoEgYs8avJDOW/E9XADLkZr/Qbe7387QnD 7YmiXPw5e1W7c9UK+XVAIGpCloZD3VYylafmz9kTrasI9uDK/1FOUn/Yj+rRKEPjfdpa KmpW7pVbYMqPh7eUC6Tgn5dT1+jj5XweIkVSGWQz8caToj274AHjrOdObJpdY9fEwMOu +UKg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlEsv9Jf74zGirMewHfNhAsyiofKKiAyOtFFRFPb+CKQkzRQW5nP eA5mcrV2u+IPVW4Zd+avUVi0LBlIoTh2pN2KEluMKNXFXG87ABZ+dGd+uR27jwWxnPozb2yPpYO xNugnmOhG/UXmSbeyI1OiTI/TimyPx5EFSB9tOuzuuB0wCVhqJ0Qhbr0rMiwFcGFjwA== X-Received: by 2002:a63:a54f:: with SMTP id r15-v6mr19064154pgu.336.1534904196212; Tue, 21 Aug 2018 19:16:36 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzDRXC7sMPmJ1ySBdDjL4smKpaJPeDZkRW4EGjNlA3LiXZFvvN1gPeL10IGZvy1e7SEZ8RV X-Received: by 2002:a63:a54f:: with SMTP id r15-v6mr19064121pgu.336.1534904195415; Tue, 21 Aug 2018 19:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534904195; cv=none; d=google.com; s=arc-20160816; b=yY+j1677ZW8CFNYcW/ud9qoUuHn8sxx4tDqC420TCFwC+FkGxjsrscqIfNOeLPkTgs WcDozGb+l1mxFPYaO7d1QhlHuas/elufDlGKC8rdVE+2mdyMr9o5tvMLdlFs1V2cOBBh LTwb+PG7zWapXdiNv+aM931jZ1+5cCo2Llm1SazKHmuOAnKB/BIvJPz/HGF8QFbc91D2 R/6nwf4CpudGdrZXRnrZraNEGf/njMU1dAgBO7OhfBY5EvDvK4IYl6szxxeeGqMN71Od JOHVOKH2y9b60oiAQY4rSorBoVetRaUOkSakBRXsoD5k0bQvM50tSy76K/8m+GVZlcLU 6hTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=wanBcbq/yF+jBQEp+neJiKsEo/O9XaVJFA4o+oKSU0M=; b=TWQGajsXtHYgPpCyymximJlgIrqVx9IQ65GEYZhmvjBhA1n+rTZxkXkfxwpnQzKAN5 lEHAhPbxWWj0M4O5AXg43ypvWJfm/QFeDyVzAXzYbnLvH3HTJ3YuMQ1+3fZ/7rEe+Pee Ei1eOciIA2HgSShH2MRBOzFn+EGhci61wQdmaq+tH5aYXgYcc6lye6H//WjB67Lfp3cj 3kjMQWQGrd0cOjKY6oJ8rpqC4XoGsCBAPjzMyNBHqhUH6PQhb2i2Dt/YpjY6HbqXXlYZ TeHDMNuqye1b1xDCLxX2+iL9epR3xLvv1gobZ1iS7uIfM6X3GmKDmaTMv16xawg1+Sqe oMhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id a8-v6si441282ple.189.2018.08.21.19.16.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 19:16:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2018 19:16:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,272,1531810800"; d="scan'208";a="83404287" Received: from linux.intel.com ([10.54.29.200]) by fmsmga001.fm.intel.com with ESMTP; 21 Aug 2018 19:16:25 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id B7C3E5802C8; Tue, 21 Aug 2018 19:16:22 -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 0/4] Fix kvm misconceives NVDIMM pages as reserved mmio Date: Wed, 22 Aug 2018 18:55:17 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 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. V1: https://lkml.org/lkml/2018/7/4/91 V2: https://lkml.org/lkml/2018/7/10/135 V3: https://lkml.org/lkml/2018/8/9/17 V4: [PATCH V3 1/4] Added "Reviewed-by: David / Acked-by: Pankaj" [PATCH V3 2/4] Added "Reviewed-by: Jan" [PATCH V3 3/4] Added "Acked-by: Jan" [PATCH V3 4/4] Fix several typos Zhang Yi (4): kvm: remove redundant reserved page check mm: introduce memory type MEMORY_DEVICE_DEV_DAX mm: add a function to differentiate the pages is from DAX device memory kvm: add a check if pfn is from NVDIMM pmem. drivers/dax/pmem.c | 1 + include/linux/memremap.h | 8 ++++++++ include/linux/mm.h | 12 ++++++++++++ virt/kvm/kvm_main.c | 16 ++++++++-------- 4 files changed, 29 insertions(+), 8 deletions(-)