From patchwork Fri Jul 5 14:03:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 11032615 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 5E3C913B1 for ; Fri, 5 Jul 2019 14:05:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45A5B288F8 for ; Fri, 5 Jul 2019 14:05:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 330EC289F3; Fri, 5 Jul 2019 14:05:07 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 79429288F8 for ; Fri, 5 Jul 2019 14:05:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3D16D212B0FC6; Fri, 5 Jul 2019 07:05:06 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=pagupta@redhat.com; receiver=linux-nvdimm@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E80FE212AD583 for ; Fri, 5 Jul 2019 07:05:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4150E85541; Fri, 5 Jul 2019 14:04:48 +0000 (UTC) Received: from dhcp201-121.englab.pnq.redhat.com (ovpn-116-58.sin2.redhat.com [10.67.116.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA42C1B46C; Fri, 5 Jul 2019 14:03:51 +0000 (UTC) From: Pankaj Gupta To: dm-devel@redhat.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-acpi@vger.kernel.org, qemu-devel@nongnu.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v15 0/7] virtio pmem driver Date: Fri, 5 Jul 2019 19:33:21 +0530 Message-Id: <20190705140328.20190-1-pagupta@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 05 Jul 2019 14:05:04 +0000 (UTC) X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: rdunlap@infradead.org, jack@suse.cz, snitzer@redhat.com, mst@redhat.com, jasowang@redhat.com, david@fromorbit.com, lcapitulino@redhat.com, adilger.kernel@dilger.ca, zwisler@kernel.org, aarcange@redhat.com, jstaron@google.com, darrick.wong@oracle.com, david@redhat.com, willy@infradead.org, hch@infradead.org, nilal@redhat.com, lenb@kernel.org, kilobyte@angband.pl, riel@surriel.com, yuval.shaia@oracle.com, stefanha@redhat.com, pbonzini@redhat.com, kwolf@redhat.com, tytso@mit.edu, xiaoguangrong.eric@gmail.com, cohuck@redhat.com, rjw@rjwysocki.net, imammedo@redhat.com Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Hi Dan, This series has only change in patch 2 for linux-next build failure. There is no functional change. Keeping all the existing review/acks and reposting the patch series for merging via libnvdimm tree. --- This patch series has implementation for "virtio pmem". "virtio pmem" is fake persistent memory(nvdimm) in guest which allows to bypass the guest page cache. This also implements a VIRTIO based asynchronous flush mechanism. Sharing guest kernel driver in this patchset with the changes suggested in v4. Tested with Qemu side device emulation [5] for virtio-pmem. Documented the impact of possible page cache side channel attacks with suggested countermeasures. Details of project idea for 'virtio pmem' flushing interface is shared [3] & [4]. Implementation is divided into two parts: New virtio pmem guest driver and qemu code changes for new virtio pmem paravirtualized device. 1. Guest virtio-pmem kernel driver --------------------------------- - Reads persistent memory range from paravirt device and registers with 'nvdimm_bus'. - 'nvdimm/pmem' driver uses this information to allocate persistent memory region and setup filesystem operations to the allocated memory. - virtio pmem driver implements asynchronous flushing interface to flush from guest to host. 2. Qemu virtio-pmem device --------------------------------- - Creates virtio pmem device and exposes a memory range to KVM guest. - At host side this is file backed memory which acts as persistent memory. - Qemu side flush uses aio thread pool API's and virtio for asynchronous guest multi request handling. Virtio-pmem security implications and countermeasures: ----------------------------------------------------- In previous posting of kernel driver, there was discussion [7] on possible implications of page cache side channel attacks with virtio pmem. After thorough analysis of details of known side channel attacks, below are the suggestions: - Depends entirely on how host backing image file is mapped into guest address space. - virtio-pmem device emulation, by default shared mapping is used to map host backing file. It is recommended to use separate backing file at host side for every guest. This will prevent any possibility of executing common code from multiple guests and any chance of inferring guest local data based based on execution time. - If backing file is required to be shared among multiple guests it is recommended to don't support host page cache eviction commands from the guest driver. This will avoid any possibility of inferring guest local data or host data from another guest. - Proposed device specification [6] for virtio-pmem device with details of possible security implications and suggested countermeasures for device emulation. Virtio-pmem errors handling: ---------------------------------------- Checked behaviour of virtio-pmem for below types of errors Need suggestions on expected behaviour for handling these errors? - Hardware Errors: Uncorrectable recoverable Errors: a] virtio-pmem: - As per current logic if error page belongs to Qemu process, host MCE handler isolates(hwpoison) that page and send SIGBUS. Qemu SIGBUS handler injects exception to KVM guest. - KVM guest then isolates the page and send SIGBUS to guest userspace process which has mapped the page. b] Existing implementation for ACPI pmem driver: - Handles such errors with MCE notifier and creates a list of bad blocks. Read/direct access DAX operation return EIO if accessed memory page fall in bad block list. - It also starts backgound scrubbing. - Similar functionality can be reused in virtio-pmem with MCE notifier but without scrubbing(no ACPI/ARS)? Need inputs to confirm if this behaviour is ok or needs any change? Changes from PATCH v13: [1] - Rebase to Linux-5.2-rc7 - Fix Linux-next build failure for undefined type Changes from PATCH v13: [2] - Rebased to Linux-5.2-rc5 - Fix S390x build failure in patch 3 - Fix for !CONFIG_DAX with dax_synchronous - Fix sparse warning in virtio patch 2 Changes from PATCH v12: - Minor changes(function name, dev_err -> dev_info & make function static in virtio patch - [Cornelia] - Added r-o-b of Mike in patch 4 Changes from PATCH v11: - Change implmentation for setting of synchronous DAX type for device mapper - [Mike] Changes from PATCH v10: - Rebased on Linux-5.2-rc4 Changes from PATCH v9: - Kconfig help text add two spaces - Randy - Fixed libnvdimm 'bio' include warning - Dan - virtio-pmem, separate request/resp struct and move to uapi file with updated license - DavidH - Use virtio32* type for req/resp endianess - DavidH - Added tested-by & ack-by of Jakob - Rebased to 5.2-rc1 Changes from PATCH v8: - Set device mapper synchronous if all target devices support - Dan - Move virtio_pmem.h to nvdimm directory - Dan - Style, indentation & better error messages in patch 2 - DavidH - Added MST's ack in patch 2. Changes from PATCH v7: - Corrected pending request queue logic (patch 2) - Jakub Staroń - Used unsigned long flags for passing DAXDEV_F_SYNC (patch 3) - Dan - Fixed typo => vma 'flag' to 'vm_flag' (patch 4) - Added rob in patch 6 & patch 2 Changes from PATCH v6: - Corrected comment format in patch 5 & patch 6. [Dave] - Changed variable declaration indentation in patch 6 [Darrick] - Add Reviewed-by tag by 'Jan Kara' in patch 4 & patch 5 Changes from PATCH v5: Changes suggested in by - [Cornelia, Yuval] - Remove assignment chaining in virtio driver - Better error message and remove not required free - Check nd_region before use Changes suggested by - [Jan Kara] - dax_synchronous() for !CONFIG_DAX - Correct 'daxdev_mapping_supported' comment and non-dax implementation Changes suggested by - [Dan Williams] - Pass meaningful flag 'DAXDEV_F_SYNC' to alloc_dax - Gate nvdimm_flush instead of additional async parameter - Move block chaining logic to flush callback than common nvdimm_flush - Use NULL flush callback for generic flush for better readability [Dan, Jan] - Use virtio device id 27 from 25(already used) - [MST] Changes from PATCH v4: - Factor out MAP_SYNC supported functionality to a common helper [Dave, Darrick, Jan] - Comment, indentation and virtqueue_kick failure handle - Yuval Shaia Changes from PATCH v3: - Use generic dax_synchronous() helper to check for DAXDEV_SYNC flag - [Dan, Darrick, Jan] - Add 'is_nvdimm_async' function - Document page cache side channel attacks implications & countermeasures - [Dave Chinner, Michael] Changes from PATCH v2: - Disable MAP_SYNC for ext4 & XFS filesystems - [Dan] - Use name 'virtio pmem' in place of 'fake dax' Changes from PATCH v1: - 0-day build test for build dependency on libnvdimm Changes suggested by - [Dan Williams] - Split the driver into two parts virtio & pmem - Move queuing of async block request to block layer - Add "sync" parameter in nvdimm_flush function - Use indirect call for nvdimm_flush - Don’t move declarations to common global header e.g nd.h - nvdimm_flush() return 0 or -EIO if it fails - Teach nsio_rw_bytes() that the flush can fail - Rename nvdimm_flush() to generic_nvdimm_flush() - Use 'nd_region->provider_data' for long dereferencing - Remove virtio_pmem_freeze/restore functions - Remove BSD license text with SPDX license text - Add might_sleep() in virtio_pmem_flush - [Luiz] - Make spin_lock_irqsave() narrow Pankaj Gupta (7): libnvdimm: nd_region flush callback support virtio-pmem: Add virtio-pmem guest driver libnvdimm: add nd_region buffered dax_dev flag dax: check synchronous mapping is supported dm: dm: Enable synchronous dax ext4: disable map_sync for virtio pmem xfs: disable map_sync for virtio pmem [1] https://lkml.org/lkml/2019/6/21/452 [2] https://lkml.org/lkml/2019/6/12/624 [3] https://www.spinics.net/lists/kvm/msg149761.html [4] https://www.spinics.net/lists/kvm/msg153095.html [5] https://marc.info/?l=qemu-devel&m=155860751202202&w=2 [6] https://lists.oasis-open.org/archives/virtio-dev/201903/msg00083.html [7] https://lkml.org/lkml/2019/1/9/1191 drivers/acpi/nfit/core.c | 4 - drivers/dax/bus.c | 2 drivers/dax/super.c | 19 +++++ drivers/md/dm-table.c | 24 +++++-- drivers/md/dm.c | 5 - drivers/md/dm.h | 5 + drivers/nvdimm/Makefile | 1 drivers/nvdimm/claim.c | 6 + drivers/nvdimm/nd.h | 1 drivers/nvdimm/nd_virtio.c | 125 +++++++++++++++++++++++++++++++++++++++ drivers/nvdimm/pmem.c | 18 +++-- drivers/nvdimm/region_devs.c | 33 +++++++++- drivers/nvdimm/virtio_pmem.c | 122 ++++++++++++++++++++++++++++++++++++++ drivers/nvdimm/virtio_pmem.h | 55 +++++++++++++++++ drivers/s390/block/dcssblk.c | 2 drivers/virtio/Kconfig | 11 +++ fs/ext4/file.c | 10 +-- fs/xfs/xfs_file.c | 9 +- include/linux/dax.h | 41 ++++++++++++ include/linux/libnvdimm.h | 10 ++- include/uapi/linux/virtio_ids.h | 1 include/uapi/linux/virtio_pmem.h | 34 ++++++++++ 22 files changed, 504 insertions(+), 34 deletions(-)