From patchwork Fri Sep 7 18:03:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10591911 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 E56AC13BB for ; Fri, 7 Sep 2018 09:24:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD71728537 for ; Fri, 7 Sep 2018 09:24:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D17DB2AD99; Fri, 7 Sep 2018 09:24:02 +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 70B0528537 for ; Fri, 7 Sep 2018 09:24:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E6C56B7D9C; Fri, 7 Sep 2018 05:24:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 697116B7D9D; Fri, 7 Sep 2018 05:24:01 -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 5ADDA6B7D9E; Fri, 7 Sep 2018 05:24:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 16B3E6B7D9C for ; Fri, 7 Sep 2018 05:24:01 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id 2-v6so6835382plc.11 for ; Fri, 07 Sep 2018 02:24:01 -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=kbMd7Mix1na6RrVY+Z79yEPVpb1XaC1alk7wmIZh7Bk=; b=csf4YqVumKu32KFuNYLccMIM37jFo4boxng6WxGDaAzPGWQcfGhTDvH5TakYi1z7TF 1DTj23khiRkt8hBpLZzm2SNW9c0+1+36XIiq8vWNS1d997AyemEb0wkUrDFhRHgxOi9X HMgMdFd14yTXkT2qpw7DM4btZg0Nu6ocCv54YC/zIOf8eX/NJyv4cdGY1ufu/ANCFfmG 3WHSUUP/Oae5hBbGuQYyK0VJ32rdBOEcCPWSPtNNFoCMLltFt0NfELyEzhfi5Vkq54KN /AhJdYI436v2GdRBBnHClLno+L+KXaONGj2jxbw61Z6NX/kU25+IUoVPQMf/hkIX0cE5 jxkg== 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.115 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: APzg51ARsU1Qy4S6IYBtYr52TwBbm60MmzFmpXpGXpDR3EPNOJFxLFJ9 mRIByxFRomFuXxWcC360BenhA+aHbcfnmG4z16FcRBIPcEO8gAgzlexUPNXq4Ctf2Sa6jZd1ve9 XRIxabriUPTl4uaXjEuanWxCVyvvM/u5X36T7bqWzVzlIEq1hZ/kkf/mJO5N9ZAbMvQ== X-Received: by 2002:a17:902:8a92:: with SMTP id p18-v6mr6936722plo.148.1536312240723; Fri, 07 Sep 2018 02:24:00 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZobHxJoBX9s7xEXxrOi5CpuhuY45vA92c/geQr3bAm/HC0gt1G/91A2pbCG06oJDOtqCwi X-Received: by 2002:a17:902:8a92:: with SMTP id p18-v6mr6936672plo.148.1536312239894; Fri, 07 Sep 2018 02:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536312239; cv=none; d=google.com; s=arc-20160816; b=kowOZbpVSG/Sk5o8QWFg3ivue6lojIsJD9Au8zDUsuKffFxelavJEXj8U3700ks/GB O3hc5rPhpIqeQT9SZrHl/TNNtPtjSrMPfqelZ+A/3ByjvMKLxUm8A57oabAQxvgky8mu xrzllq2gylH0wr1iZUFM3vPFVEyDIHYMryosghX4pa+6u/sOQNObKiLfEiH9WSxC/tto TyeDEd4fsIjI4irowjS0JwKzo2wDSR8K0OEvF0nu3bFqaIIucKk2ARWrxN0lbCGmyd9q Zy5/7b0aqdkm/LbN0y7o04ScjaZeG7r88zk6jy0gc/JK/bC7HQnT+npOv0iKJKA1NbqY AqTQ== 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; bh=kbMd7Mix1na6RrVY+Z79yEPVpb1XaC1alk7wmIZh7Bk=; b=VvjRvzbFVFz2bCJ8oWF8K7qMrqiUGGBebNod37RNYugpqlhcV0keZfEj6N8wR0g1jS 5kpbzbaZL7ftqTIPHAxn/2c1GlDLE4wg5bcpk/kw7rBifzjhgEgMdnpLs/pN9atlONU1 I91SV9D1vO+RRzLCIFGKQFLObvY9DZ5dSfa1Thme1xjSkRGO154D99TmeJF4d/WnjDJK Qfu5wxGDwvciDw/ehBVABbLmL40nGXIOn+JAe+6TdpInbDhzj6SuyjOG/n/LXivo6Yaq NzqvO/LdNll3ZJYiWhr05wL7o+xi7cZgIKgw8HHNcTzRwcuq7nbREVKWb5223HVNGSjh uZWg== 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.115 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 mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id a8-v6si6744516plp.61.2018.09.07.02.23.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 02:23:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; 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.115 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 orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2018 02:23:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,341,1531810800"; d="scan'208";a="255286464" Received: from linux.intel.com ([10.54.29.200]) by orsmga005.jf.intel.com with ESMTP; 07 Sep 2018 02:23:58 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id 3EBE25803DA; Fri, 7 Sep 2018 02:23:56 -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 V5 0/4] Fix kvm misconceives NVDIMM pages as reserved mmio Date: Sat, 8 Sep 2018 02:03:02 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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: https://lkml.org/lkml/2018/8/22/17 V5: [PATCH V3 1/4] Reviewed-by: David / Acked-by: Pankaj [PATCH V3 2/4] Reviewed-by: Jan [PATCH V3 3/4] Acked-by: Jan [PATCH V3 4/4] Added "Acked-by: Pankaj", Added in-line comments: Dave 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 | 24 ++++++++++++++++-------- 4 files changed, 37 insertions(+), 8 deletions(-)