Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1044288imm; Fri, 11 May 2018 10:12:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpgXszvbks738r/uOi7v3HPPzItfGsdsc1fqyecEbwHD/wqfyI6aSGxlnyh6k5JJ5Kx0pxY X-Received: by 2002:a17:902:b7cb:: with SMTP id v11-v6mr6454126plz.266.1526058747243; Fri, 11 May 2018 10:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526058747; cv=none; d=google.com; s=arc-20160816; b=izHodPD0AnyWnF07sgiAYRB8P9HAdBHDX/XmScRKmWWugZc339yOW5Qflo8o6eHM67 tSR3WdLa9/wR8dRrqpuK6HU9yPIYZMsB48OI3zgPOv1Dy7tUnej2SbRn/drFU5kjLGRV ZaDsRlmBCqxh40j8lIIW5LfrlBdnV9cF04+8jQKUhGIEYVnCFZGYbNf6ND3/7mooanz9 FjTwIyvcJw7UcTftp5ms1efkOfekjajbVthYrnPrsXPZj8eGALFoenLE4NDtU61xK8Hg 26hZFP4skQIDHKHbeeW8JJrr18//2z0SrXgHYfEP4cVIedH/jwulVMzbhL8Usqj0qq+K SMWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version:dkim-signature:arc-authentication-results; bh=OU5A9rllUDrhAQM/NzFjl5/jP+ILCzZG13KCSpW2yVs=; b=idGZYyMKJgu3Rryat3Q9nuPkp2dE6lvp1INpEwBPlTplRdsx1zGjXvRavaZI3xAAk2 /macvb5YYH/bJZKuyNsdRBd3n/u4iIcu8guiQqgdzIbkMGUnrJIm9CLi61rUIUDOUhGs ihOaRVYRmdea/zHJdxd+Y+PzepIsdeqpODACPTl9azQPI04i3V97QTp4fUIYVdEKOr7F tWVDnWPZyfDOE9XjT8AWNef16LKJRa1GARAHDRlKvHvsbF9A7PBJFvrNBSyj00UlNViD ihQ8QALehom/xWI6YmpTvgbYXI7FLC2xuDQ3oIp2uWx3D3hBxIweOQ7ASvSZzz5VFgNz kZhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=lC1CZh4N; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9-v6si3631652pfg.247.2018.05.11.10.12.12; Fri, 11 May 2018 10:12:27 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=lC1CZh4N; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751564AbeEKRKZ (ORCPT + 99 others); Fri, 11 May 2018 13:10:25 -0400 Received: from mail-ot0-f196.google.com ([74.125.82.196]:40490 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbeEKRKX (ORCPT ); Fri, 11 May 2018 13:10:23 -0400 Received: by mail-ot0-f196.google.com with SMTP id n1-v6so7019996otf.7 for ; Fri, 11 May 2018 10:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to:cc; bh=OU5A9rllUDrhAQM/NzFjl5/jP+ILCzZG13KCSpW2yVs=; b=lC1CZh4NrKl2gNMt5TCbd2DmbPQFhaeZ8mN+nQLA8AMIfMjmlo0yBtcD7iqMhkO/t0 WcaNWMbsth0f+xVAMdf5UH+uv2zhXE2kCRY53jjesH9NrpRIIpQTwmz6Y6afySQyRUUJ Hwqyp+odtKYnR/47VQIMW28NTXITW+Ax8Yqst64t8pwxA6YKIlVTGDz3Qq9Igd5muBjJ FnxyynSlE/BG0SzbOLO3zXhLHoPhfg2kgN/OMj1iSV/+g9ardoFoPKONTjTYPCcUUz/O w8sE2HjWrER8zSDIstp5CQcLBjhVPRSKzRnBccjyyzQe+VnoFZO2abBTgk4uNLw10taC tHOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=OU5A9rllUDrhAQM/NzFjl5/jP+ILCzZG13KCSpW2yVs=; b=IG0ekOVwK2lYe+gM05xA67NE4eRRA4ZK1RTDNsFqwNCF8y+rl/fRnR0zFsSOiCB21S +fZDvdi6LJfiEnHTDSh3oewlxEfAQdWKwqw8KDEKVaT8PtQRvI/V0zvzQFV6wnUhah4E xHnLUsEXT8Ea4dxPCfLXjCAU2PhJYUAf7Fq/z8axopnY5YG6azGPvW+gFwTU2f1L4Bt0 6Efwe4ZM4YTQ0lDlM3Hi+7XWBltBosGBFpIEmIFAC96wdpvIdlVOEJnYcdKhh9xCnhwH EQh6UWEMX4gAmq8I6nW4E8JPw01SxV+CHXQw6J9fV5EtZbKF0EMRtMon6d5AfEVB6CmQ Lkaw== X-Gm-Message-State: ALKqPwcNRN59ctcnsp8J+vicNOzx7Spv8zg0+n01OMmi090nwhvTmIkF i07aI8/TB7hcA9rG/29DeQ6E8GCcLg5UYI/o3qNWMQ== X-Received: by 2002:a9d:5a17:: with SMTP id v23-v6mr4649151oth.387.1526058622965; Fri, 11 May 2018 10:10:22 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2d36:0:0:0:0:0 with HTTP; Fri, 11 May 2018 10:10:22 -0700 (PDT) From: Dan Williams Date: Fri, 11 May 2018 10:10:22 -0700 Message-ID: Subject: use memcpy_mcsafe() for copy_to_iter() (was: Re: [PATCH v3 0/9] Series short description) To: linux-nvdimm Cc: "Luck, Tony" , Andrew Morton , Mike Snitzer , Peter Zijlstra , X86 ML , Linux Kernel Mailing List , Andy Lutomirski , Ingo Molnar , Borislav Petkov , =?UTF-8?Q?Mika_Penttil=C3=A4?= , linux-fsdevel , Thomas Gleixner , Linus Torvalds , Christoph Hellwig , Al Viro Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ingo, Thomas, Al, any concerns with this series? On Thu, May 3, 2018 at 5:06 PM, Dan Williams wrote: > Changes since v2 [1]: > > * Fix source address increment in mcsafe_handle_tail() (Mika) > > * Extend the unit test to inject simulated write faults and validate > that data is properly transferred. > > * Rename MCSAFE_DEBUG to MCSAFE_TEST > > [1]: https://lists.01.org/pipermail/linux-nvdimm/2018-May/015583.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_TEST 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_test.h | 75 ++++++++++++++++++++++++ > arch/x86/include/asm/string_64.h | 10 ++- > arch/x86/include/asm/uaccess_64.h | 14 +++++ > arch/x86/lib/memcpy_64.S | 112 +++++++++++++++++------------------- > arch/x86/lib/usercopy_64.c | 21 +++++++ > 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 | 104 +++++++++++++++++++++++++++++++++ > 22 files changed, 482 insertions(+), 79 deletions(-) > create mode 100644 arch/x86/include/asm/mcsafe_test.h > _______________________________________________ > Linux-nvdimm mailing list > Linux-nvdimm@lists.01.org > https://lists.01.org/mailman/listinfo/linux-nvdimm