nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Cc: tony.luck@intel.com, Andrew Morton <akpm@linux-foundation.org>,
	Mike Snitzer <snitzer@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Andy Lutomirski <luto@amacapital.net>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>
Subject: [PATCH v2 0/9] use memcpy_mcsafe() for copy_to_iter()
Date: Wed, 02 May 2018 21:58:35 -0700	[thread overview]
Message-ID: <152532351517.17218.3583455156840230837.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)

Changes since v1 [1]:

* Remove the loop unrolling in the assembly implementation since it
  significantly complicates the exception handling (Linus)

* Introduce a ->copy_to_iter() dax operation for symmetry with the
  existing ->copy_from_iter() operation to allow platform /
  device-specific implementations.

[1]: https://lists.01.org/pipermail/linux-nvdimm/2018-May/015548.html

---

Currently memcpy_mcsafe() is only deployed in the pmem driver when
reading through a /dev/pmemX block device. However, a filesystem in dax
mode mounted on a /dev/pmemX block device will bypass the block layer
and the driver for reads. The filesystem-dax (fsdax) read case uses
dax_direct_access() and copy_to_iter() to bypass the block layer.

The result of the bypass is that the kernel treats machine checks during
read as system fatal (reboot) when they could simply be flagged as an
I/O error, similar to performing reads through the pmem driver. Prevent
this fatal condition by deploying memcpy_mcsafe() in the fsdax read
path.

The main differences between this copy_to_user_mcsafe() and
copy_user_generic_unrolled() are:

* Typical tail/residue handling after a fault retries the copy
  byte-by-byte until the fault happens again. Re-triggering machine
  checks is potentially fatal so the implementation uses source alignment
  and poison alignment assumptions to avoid re-triggering machine
  checks.

* SMAP coordination is handled external to the assembly with
  __uaccess_begin() and __uaccess_end().

* ITER_KVEC and ITER_BVEC can now end prematurely with an error.

The new MCSAFE_DEBUG facility is proposed as a way to unit test the
exception handling without requiring an ACPI EINJ capable platform.

---

Dan Williams (9):
      x86, memcpy_mcsafe: remove loop unrolling
      x86, memcpy_mcsafe: add labels for write fault handling
      x86, memcpy_mcsafe: return bytes remaining
      x86, memcpy_mcsafe: add write-protection-fault handling
      x86, memcpy_mcsafe: define copy_to_iter_mcsafe()
      dax: introduce a ->copy_to_iter dax operation
      dax: report bytes remaining in dax_iomap_actor()
      pmem: switch to copy_to_iter_mcsafe()
      x86, nfit_test: unit test for memcpy_mcsafe()


 arch/x86/Kconfig                    |    1 
 arch/x86/Kconfig.debug              |    3 +
 arch/x86/include/asm/mcsafe_debug.h |   50 ++++++++++++++++
 arch/x86/include/asm/string_64.h    |   10 ++-
 arch/x86/include/asm/uaccess_64.h   |   14 ++++
 arch/x86/lib/memcpy_64.S            |  109 ++++++++++++++++-------------------
 arch/x86/lib/usercopy_64.c          |   17 +++++
 drivers/dax/super.c                 |   10 +++
 drivers/md/dm-linear.c              |   16 +++++
 drivers/md/dm-log-writes.c          |   15 +++++
 drivers/md/dm-stripe.c              |   21 +++++++
 drivers/md/dm.c                     |   25 ++++++++
 drivers/nvdimm/claim.c              |    3 +
 drivers/nvdimm/pmem.c               |   13 +++-
 drivers/s390/block/dcssblk.c        |    7 ++
 fs/dax.c                            |   21 ++++---
 include/linux/dax.h                 |    5 ++
 include/linux/device-mapper.h       |    5 +-
 include/linux/string.h              |    4 +
 include/linux/uio.h                 |   15 +++++
 lib/iov_iter.c                      |   61 ++++++++++++++++++++
 tools/testing/nvdimm/test/nfit.c    |   48 +++++++++++++++
 22 files changed, 394 insertions(+), 79 deletions(-)
 create mode 100644 arch/x86/include/asm/mcsafe_debug.h
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

             reply	other threads:[~2018-05-03  5:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03  4:58 Dan Williams [this message]
2018-05-03  4:58 ` [PATCH v2 1/9] x86, memcpy_mcsafe: remove loop unrolling Dan Williams
2018-05-03  4:58 ` [PATCH v2 2/9] x86, memcpy_mcsafe: add labels for write fault handling Dan Williams
2018-05-03  4:58 ` [PATCH v2 3/9] x86, memcpy_mcsafe: return bytes remaining Dan Williams
2018-05-03  4:59 ` [PATCH v2 4/9] x86, memcpy_mcsafe: add write-protection-fault handling Dan Williams
2018-05-03  5:29   ` Mika Penttilä
2018-05-03 14:19     ` Dan Williams
2018-05-03  4:59 ` [PATCH v2 5/9] x86, memcpy_mcsafe: define copy_to_iter_mcsafe() Dan Williams
2018-05-03  4:59 ` [PATCH v2 6/9] dax: introduce a ->copy_to_iter dax operation Dan Williams
2018-05-03  4:59 ` [PATCH v2 7/9] dax: report bytes remaining in dax_iomap_actor() Dan Williams
2018-05-03  4:59 ` [PATCH v2 8/9] pmem: switch to copy_to_iter_mcsafe() Dan Williams
2018-05-03  4:59 ` [PATCH v2 9/9] x86, nfit_test: unit test for memcpy_mcsafe() Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=152532351517.17218.3583455156840230837.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=snitzer@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).