Re: [block] 52f019d43c: ndctl.test-libndctl.fail

2021-03-06 Thread Williams, Dan J
On Fri, 2021-03-05 at 08:42 +0100, Christoph Hellwig wrote:
> Dan,
> 
> can you make any sense of thos report?
[..]
> > check_set_config_data: dimm: 0 read2 data miscompare: 0
> > check_set_config_data: dimm: 0x1 read2 data miscompare: 0
> > check_set_config_data: dimm: 0x100 read2 data miscompare: 0
> > check_set_config_data: dimm: 0x101 read2 data miscompare: 0
> > check_dax_autodetect: dax_ndns: 0x558a74d92f00 ndns: 0x558a74d92f00
> > check_dax_autodetect: dax_ndns: 0x558a74d91f40 ndns: 0x558a74d91f40
> > check_pfn_autodetect: pfn_ndns: 0x558a74d91f40 ndns: 0x558a74d91f40
> > check_pfn_autodetect: pfn_ndns: 0x558a74d8c5e0 ndns: 0x558a74d8c5e0
> > check_btt_autodetect: btt_ndns: 0x558a74d8c5e0 ndns: 0x558a74d8c5e0
> > check_btt_autodetect: btt_ndns: 0x558a74da1390 ndns: 0x558a74da1390
> > check_btt_autodetect: btt_ndns: 0x558a74d8c5e0 ndns: 0x558a74d8c5e0
> > check_btt_autodetect: btt_ndns: 0x558a74d91f40 ndns: 0x558a74d91f40
> > namespace7.0: failed to write /dev/pmem7
> > check_namespaces: namespace7.0 validate_bdev failed
> > ndctl-test1 failed: -6
> > libkmod: ERROR ../libkmod/libkmod-module.c:793 kmod_module_remove_module: 
> > could not remove 'nfit_test': Resource temporarily unavailable
> > test-libndctl: FAIL

Yes, it looks like my unit test checks for exactly the behavior you
changed. It was convenient to test that the device could be switched
back to rw via BLKROSET, but I don't require that. The new behaviour of
letting the disk->ro take precedence makes more sense to me, so I'll
update the test for the new behaviour.

I.e. I don't think regressing a unit test counts as a userspace
regression.
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [GIT PULL] General notification queue and key notifications

2020-06-16 Thread Williams, Dan J
Hi David,

On Tue, 2020-06-02 at 16:55 +0100, David Howells wrote:
> Date: Tue, 02 Jun 2020 16:51:44 +0100
> 
> Hi Linus,
> 
> Can you pull this, please?  It adds a general notification queue
> concept
> and adds an event source for keys/keyrings, such as linking and
> unlinking
> keys and changing their attributes.
[..]

This commit:

>   keys: Make the KEY_NEED_* perms an enum rather than a mask

...upstream as:

8c0637e950d6 keys: Make the KEY_NEED_* perms an enum rather than a mask

...triggers a regression in the libnvdimm unit test that exercises the
encrypted keys used to store nvdimm passphrases. It results in the
below warning.

---

WARNING: CPU: 15 PID: 6276 at security/keys/permission.c:35 
key_task_permission+0xd3/0x140
Modules linked in: nd_blk(OE) nfit_test(OE) device_dax(OE) ebtable_filter(E) 
ebtables(E) ip6table_filter(E) ip6_tables(E) kvm_intel(E) kvm(E) irqbypass(E) 
nd_pmem(OE) dax_pmem(OE) nd_btt(OE) dax_p
ct10dif_pclmul(E) nd_e820(OE) nfit(OE) crc32_pclmul(E) libnvdimm(OE) 
crc32c_intel(E) ghash_clmulni_intel(E) serio_raw(E) encrypted_keys(E) 
trusted(E) nfit_test_iomap(OE) tpm(E) drm(E)
CPU: 15 PID: 6276 Comm: lt-ndctl Tainted: G   OE 5.7.0-rc6+ #155
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015
RIP: 0010:key_task_permission+0xd3/0x140
Code: c8 21 d9 39 d9 75 25 48 83 c4 08 4c 89 e6 48 89 ef 5b 5d 41 5c 41 5d e9 
1b a7 00 00 bb 01 00 00 00 83 fa 01 0f 84 68 ff ff ff <0f> 0b 48 83 c4 08 b8 f3 
ff ff ff 5b 5d 41 5c 41 5d c3 83 fa 06

RSP: 0018:addc42db7c90 EFLAGS: 00010297
RAX: 0001 RBX: 0001 RCX: addc42db7c7c
RDX:  RSI: 985e1c46e840 RDI: 985e3a03de01
RBP: 985e3a03de01 R08:  R09: 5461e7bc02a0
R10: 0004 R11:  R12: 985e1c46e840
R13:  R14: addc42db7cd8 R15: 985e248c6540
FS:  7f863c18a780() GS:985e3bbc() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 006d3708 CR3: 000125a1e006 CR4: 00160ee0
Call Trace:
 lookup_user_key+0xeb/0x6b0
 ? vsscanf+0x3df/0x840
 ? key_validate+0x50/0x50
 ? key_default_cmp+0x20/0x20
 nvdimm_get_user_key_payload.part.0+0x21/0x110 [libnvdimm]
 nvdimm_security_store+0x67d/0xb20 [libnvdimm]
 security_store+0x67/0x1a0 [libnvdimm]
 kernfs_fop_write+0xcf/0x1c0
 vfs_write+0xde/0x1d0
 ksys_write+0x68/0xe0
 do_syscall_64+0x5c/0xa0
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x7f863c624547
Code: 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 
8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 
c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
RSP: 002b:7ffd61d8f5e8 EFLAGS: 0246 ORIG_RAX: 0001
RAX: ffda RBX: 7ffd61d8f640 RCX: 7f863c624547
RDX: 0014 RSI: 7ffd61d8f640 RDI: 0005
RBP: 0005 R08: 0014 R09: 7ffd61d8f4a0
R10: f455 R11: 0246 R12: 006dbbf0
R13: 006cd710 R14: 7f863c18a6a8 R15: 7ffd61d8fae0
irq event stamp: 36976
hardirqs last  enabled at (36975): [] __slab_alloc+0x70/0x90
hardirqs last disabled at (36976): [] 
trace_hardirqs_off_thunk+0x1a/0x1c
softirqs last  enabled at (35474): [] __do_softirq+0x357/0x466
softirqs last disabled at (35467): [] irq_exit+0xe6/0xf0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


RE: [RESEND PATCH v9 4/5] ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific methods

2020-06-04 Thread Williams, Dan J



> -Original Message-
> From: Vaibhav Jain 
> Sent: Thursday, June 4, 2020 2:06 AM
> To: Williams, Dan J ; linuxppc-
> d...@lists.ozlabs.org; linux-nvdimm@lists.01.org; linux-
> ker...@vger.kernel.org
> Cc: Santosh Sivaraj ; Aneesh Kumar K . V
> ; Steven Rostedt ;
> Oliver O'Halloran ; Weiny, Ira 
> Subject: RE: [RESEND PATCH v9 4/5] ndctl/papr_scm,uapi: Add support for
> PAPR nvdimm specific methods
> 
> Hi Dan,
> 
> Thanks for review and insights on this. My responses below:
> 
> "Williams, Dan J"  writes:
> 
> > [ forgive formatting I'm temporarily stuck using Outlook this week...
> > ]
> >
> >> From: Vaibhav Jain 
> > [..]
> >>
> >> Introduce support for PAPR NVDIMM Specific Methods (PDSM) in
> papr_scm
> >> module and add the command family NVDIMM_FAMILY_PAPR to the
> white
> >> list of NVDIMM command sets. Also advertise support for ND_CMD_CALL
> >> for the nvdimm command mask and implement necessary scaffolding in
> >> the module to handle ND_CMD_CALL ioctl and PDSM requests that we
> receive.
> >>
> >> The layout of the PDSM request as we expect from libnvdimm/libndctl
> >> is described in newly introduced uapi header 'papr_pdsm.h' which
> >> defines a new 'struct nd_pdsm_cmd_pkg' header. This header is used to
> >> communicate the PDSM request via member
> 'nd_cmd_pkg.nd_command' and
> >> size of payload that need to be sent/received for servicing the PDSM.
> >>
> >> A new function is_cmd_valid() is implemented that reads the args to
> >> papr_scm_ndctl() and performs sanity tests on them. A new function
> >> papr_scm_service_pdsm() is introduced and is called from
> >> papr_scm_ndctl() in case of a PDSM request is received via
> >> ND_CMD_CALL command from libnvdimm.
> >>
> >> Cc: "Aneesh Kumar K . V" 
> >> Cc: Dan Williams 
> >> Cc: Michael Ellerman 
> >> Cc: Ira Weiny 
> >> Reviewed-by: Aneesh Kumar K.V 
> >> Signed-off-by: Vaibhav Jain 
> >> ---
> >> Changelog:
> >>
> >> Resend:
> >> * Added ack from Aneesh.
> >>
> >> v8..v9:
> >> * Reduced the usage of term SCM replacing it with appropriate
> >>   replacement [ Dan Williams, Aneesh ]
> >> * Renamed 'papr_scm_pdsm.h' to 'papr_pdsm.h'
> >> * s/PAPR_SCM_PDSM_*/PAPR_PDSM_*/g
> >> * s/NVDIMM_FAMILY_PAPR_SCM/NVDIMM_FAMILY_PAPR/g
> >> * Minor updates to 'papr_psdm.h' to replace usage of term 'SCM'.
> >> * Minor update to patch description.
> >>
> >> v7..v8:
> >> * Removed the 'payload_offset' field from 'struct
> >>   nd_pdsm_cmd_pkg'. Instead command payload is always assumed to
> start
> >>   at 'nd_pdsm_cmd_pkg.payload'. [ Aneesh ]
> >> * To enable introducing new fields to 'struct nd_pdsm_cmd_pkg',
> >>   'reserved' field of 10-bytes is introduced. [ Aneesh ]
> >> * Fixed a typo in "Backward Compatibility" section of papr_scm_pdsm.h
> >>   [ Ira ]
> >>
> >> Resend:
> >> * None
> >>
> >> v6..v7 :
> >> * Removed the re-definitions of __packed macro from papr_scm_pdsm.h
> >>   [Mpe].
> >> * Removed the usage of __KERNEL__ macros in papr_scm_pdsm.h
> [Mpe].
> >> * Removed macros that were unused in papr_scm.c from
> papr_scm_pdsm.h
> >>   [Mpe].
> >> * Made functions defined in papr_scm_pdsm.h as static inline. [Mpe]
> >>
> >> v5..v6 :
> >> * Changed the usage of the term DSM to PDSM to distinguish it from the
> >>   ACPI term [ Dan Williams ]
> >> * Renamed papr_scm_dsm.h to papr_scm_pdsm.h and updated various
> >> struct
> >>   to reflect the new terminology.
> >> * Updated the patch description and title to reflect the new terminology.
> >> * Squashed patch to introduce new command family in 'ndctl.h' with
> >>   this patch [ Dan Williams ]
> >> * Updated the papr_scm_pdsm method starting index from 0x1 to
> 0x0
> >>   [ Dan Williams ]
> >> * Removed redundant license text from the papr_scm_psdm.h file.
> >>   [ Dan Williams ]
> >> * s/envelop/envelope/ at various places [ Dan Williams ]
> >> * Added '__packed' attribute to command package header to gaurd
> >>   against different compiler adding paddings between the fields.
> >>   [ Dan Williams]
> >> * Converted various pr_debug to dev_debug [ Dan Williams ]
> >>
> >> v4..v5 :
> >> * None
> >>
> >> v3..

RE: [ndctl PATCH v5 6/6] libndctl,papr_scm: Implement support for PAPR_PDSM_HEALTH

2020-06-03 Thread Williams, Dan J



> -Original Message-
> From: Vaibhav Jain 
> Sent: Friday, May 29, 2020 3:06 PM
> To: linux-nvdimm@lists.01.org
> Cc: Vaibhav Jain ; Williams, Dan J
> ; Verma, Vishal L ;
> Aneesh Kumar K . V ; Jeff Moyer
> ; Oliver O'Halloran ; Santosh
> Sivaraj ; Weiny, Ira 
> Subject: [ndctl PATCH v5 6/6] libndctl,papr_scm: Implement support for
> PAPR_PDSM_HEALTH
> 
> Add support for reporting DIMM health and shutdown state by issuing
> PAPR_PDSM_HEALTH request to papr_scm module. It returns an instance of
> 'struct nd_papr_pdsm_health' as defined in 'papr_pdsm.h'. The patch
> provides support for dimm-ops 'new_smart', 'smart_get_health' &
> 'smart_get_shutdown_state' as newly introduced functions
> papr_new_smart_health(), papr_smart_get_health() &
> papr_smart_get_shutdown_state() respectively. These callbacks should
> enable ndctl to report DIMM health.
> 
> Also a new member 'struct dimm_priv.health' is introduced which holds the
> current health status of the dimm. This member is set inside newly added
> function 'update_dimm_health_v1()' which parses the v1 payload returned
> by the kernel after servicing PAPR_PDSM_HEALTH. The function will also
> update dimm-flags viz 'struct ndctl_dimm.flags.f_*'
> based on the flags set in the returned payload.
> 
> Signed-off-by: Vaibhav Jain 
> ---
> Changelog:
> 
> v4..v5:
> * Updated patch description to reflect updated names of struct and
>   defines that have the term 'scm' removed.
> 
> v3..v4:
> * None
> 
> v2..v3:
> * None
> 
> v1..v2:
> * Squashed patch to report nvdimm bad shutdown state with this patch.
> * Switched to new structs/enums as defined in papr_scm_pdsm.h
> ---
>  ndctl/lib/papr.c | 90
> ++--
>  1 file changed, 87 insertions(+), 3 deletions(-)
> 
> diff --git a/ndctl/lib/papr.c b/ndctl/lib/papr.c index
> 1b7870beb631..cb7ff9e0d5bd 100644
> --- a/ndctl/lib/papr.c
> +++ b/ndctl/lib/papr.c
> @@ -42,7 +42,9 @@
> 
>  /* Per dimm data. Holds per-dimm data parsed from the cmd_pkgs */  struct
> dimm_priv {
> - /* Empty for now */
> +
> + /* Cache the dimm health status */
> + struct nd_papr_pdsm_health health;

I don't understand this. The kernel is caching this, why does libndctl need to 
cache it?
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


RE: [RESEND PATCH v9 4/5] ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific methods

2020-06-03 Thread Williams, Dan J
[ forgive formatting I'm temporarily stuck using Outlook this week... ]

> From: Vaibhav Jain 
[..]
> 
> Introduce support for PAPR NVDIMM Specific Methods (PDSM) in papr_scm
> module and add the command family NVDIMM_FAMILY_PAPR to the white
> list of NVDIMM command sets. Also advertise support for ND_CMD_CALL for
> the nvdimm command mask and implement necessary scaffolding in the
> module to handle ND_CMD_CALL ioctl and PDSM requests that we receive.
> 
> The layout of the PDSM request as we expect from libnvdimm/libndctl is
> described in newly introduced uapi header 'papr_pdsm.h' which defines a
> new 'struct nd_pdsm_cmd_pkg' header. This header is used to communicate
> the PDSM request via member 'nd_cmd_pkg.nd_command' and size of
> payload that need to be sent/received for servicing the PDSM.
> 
> A new function is_cmd_valid() is implemented that reads the args to
> papr_scm_ndctl() and performs sanity tests on them. A new function
> papr_scm_service_pdsm() is introduced and is called from
> papr_scm_ndctl() in case of a PDSM request is received via ND_CMD_CALL
> command from libnvdimm.
> 
> Cc: "Aneesh Kumar K . V" 
> Cc: Dan Williams 
> Cc: Michael Ellerman 
> Cc: Ira Weiny 
> Reviewed-by: Aneesh Kumar K.V 
> Signed-off-by: Vaibhav Jain 
> ---
> Changelog:
> 
> Resend:
> * Added ack from Aneesh.
> 
> v8..v9:
> * Reduced the usage of term SCM replacing it with appropriate
>   replacement [ Dan Williams, Aneesh ]
> * Renamed 'papr_scm_pdsm.h' to 'papr_pdsm.h'
> * s/PAPR_SCM_PDSM_*/PAPR_PDSM_*/g
> * s/NVDIMM_FAMILY_PAPR_SCM/NVDIMM_FAMILY_PAPR/g
> * Minor updates to 'papr_psdm.h' to replace usage of term 'SCM'.
> * Minor update to patch description.
> 
> v7..v8:
> * Removed the 'payload_offset' field from 'struct
>   nd_pdsm_cmd_pkg'. Instead command payload is always assumed to start
>   at 'nd_pdsm_cmd_pkg.payload'. [ Aneesh ]
> * To enable introducing new fields to 'struct nd_pdsm_cmd_pkg',
>   'reserved' field of 10-bytes is introduced. [ Aneesh ]
> * Fixed a typo in "Backward Compatibility" section of papr_scm_pdsm.h
>   [ Ira ]
> 
> Resend:
> * None
> 
> v6..v7 :
> * Removed the re-definitions of __packed macro from papr_scm_pdsm.h
>   [Mpe].
> * Removed the usage of __KERNEL__ macros in papr_scm_pdsm.h [Mpe].
> * Removed macros that were unused in papr_scm.c from papr_scm_pdsm.h
>   [Mpe].
> * Made functions defined in papr_scm_pdsm.h as static inline. [Mpe]
> 
> v5..v6 :
> * Changed the usage of the term DSM to PDSM to distinguish it from the
>   ACPI term [ Dan Williams ]
> * Renamed papr_scm_dsm.h to papr_scm_pdsm.h and updated various
> struct
>   to reflect the new terminology.
> * Updated the patch description and title to reflect the new terminology.
> * Squashed patch to introduce new command family in 'ndctl.h' with
>   this patch [ Dan Williams ]
> * Updated the papr_scm_pdsm method starting index from 0x1 to 0x0
>   [ Dan Williams ]
> * Removed redundant license text from the papr_scm_psdm.h file.
>   [ Dan Williams ]
> * s/envelop/envelope/ at various places [ Dan Williams ]
> * Added '__packed' attribute to command package header to gaurd
>   against different compiler adding paddings between the fields.
>   [ Dan Williams]
> * Converted various pr_debug to dev_debug [ Dan Williams ]
> 
> v4..v5 :
> * None
> 
> v3..v4 :
> * None
> 
> v2..v3 :
> * Updated the patch prefix to 'ndctl/uapi' [Aneesh]
> 
> v1..v2 :
> * None
> ---
>  arch/powerpc/include/uapi/asm/papr_pdsm.h | 136
> ++  arch/powerpc/platforms/pseries/papr_scm.c |
> 101 +++-
>  include/uapi/linux/ndctl.h|   1 +
>  3 files changed, 232 insertions(+), 6 deletions(-)  create mode 100644
> arch/powerpc/include/uapi/asm/papr_pdsm.h
> 
> diff --git a/arch/powerpc/include/uapi/asm/papr_pdsm.h
> b/arch/powerpc/include/uapi/asm/papr_pdsm.h
> new file mode 100644
> index ..6407fefcc007
> --- /dev/null
> +++ b/arch/powerpc/include/uapi/asm/papr_pdsm.h
> @@ -0,0 +1,136 @@
> +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
> +/*
> + * PAPR nvDimm Specific Methods (PDSM) and structs for libndctl
> + *
> + * (C) Copyright IBM 2020
> + *
> + * Author: Vaibhav Jain   */
> +
> +#ifndef _UAPI_ASM_POWERPC_PAPR_PDSM_H_
> +#define _UAPI_ASM_POWERPC_PAPR_PDSM_H_
> +
> +#include 
> +
> +/*
> + * PDSM Envelope:
> + *
> + * The ioctl ND_CMD_CALL transfers data between user-space and kernel
> +via
> + * envelope which consists of a header and user-defined payload sections.
> + * The header is described by 'struct nd_pdsm_cmd_pkg' which expects a
> + * payload following it and accessible via 'nd_pdsm_cmd_pkg.payload' field.
> + * There is reserved field that can used to introduce new fields to the
> + * structure in future. It also tries to ensure that
> 'nd_pdsm_cmd_pkg.payload'
> + * lies at a 8-byte boundary.
> + *
> + *  +-+-+---+
> + *  |   64-Bytes  |   16-Bytes  |   Max 176-Bytes   |
> + *  

RE: [RFC PATCH 1/2] libnvdimm: Add prctl control for disabling synchronous fault support.

2020-06-02 Thread Williams, Dan J
[ forgive formatting, a series of unfortunate events has me using Outlook for 
the moment ]

> From: Jan Kara 
> > > > These flags are device properties that affect the kernel and
> > > > userspace's handling of persistence.
> > > >
> > >
> > > That will not handle the scenario with multiple applications using
> > > the same fsdax mount point where one is updated to use the new
> > > instruction and the other is not.
> >
> > Right, it needs to be a global setting / flag day to switch from one
> > regime to another. Per-process control is a recipe for disaster.
> 
> First I'd like to mention that hopefully the concern is mostly theoretical 
> since
> as Aneesh wrote above, real persistent memory never shipped for PPC and
> so there are very few apps (if any) using the old way to ensure cache
> flushing.
> 
> But I'd like to understand why do you think per-process control is a recipe 
> for
> disaster? Because from my POV the sysfs interface you propose is actually
> difficult to use in practice. As a distributor, you have hard time picking the
> default because you have a choice between picking safe option which is
> going to confuse users because of failing MAP_SYNC and unsafe option
> where everyone will be happy until someone looses data because of some
> ancient application using wrong instructions to persist data. Poor experience
> for users in either way. And when distro defaults to "safe option", then the
> burden is on the sysadmin to toggle the switch but how is he supposed to
> decide when that is safe? First he has to understand what the problem
> actually is, then he has to audit all the applications using pmem whether they
> use the new instruction - which is IMO a lot of effort if you have a couple of
> applications and practically infeasible if you have more of them.
> So IMO the burden should be *on the application* to declare that it is aware
> of the new instructions to flush pmem on the platform and only to such
> application the kernel should give the trust to use MAP_SYNC mappings.

The "disaster" in my mind is this need to globally change the ABI for 
persistence semantics for all of Linux because one CPU wants a do over. What 
does a generic "MAP_SYNC_ENABLE" knob even mean to the existing deployed base 
of persistent memory applications? Yes, sysfs is awkward, but it's trying to 
provide some relief without imposing unexplainable semantics on everyone else. 
I think a comprehensive (overengineered) solution would involve not introducing 
another "I know what I'm doing" flag to the interface, but maybe requiring 
applications to call a pmem sync API in something like a vsyscall. Or, also 
overengineered, some binary translation / interpretation to actively detect and 
kill applications that deploy the old instructions. Something horrid like on 
first write fault to a MAP_SYNC try to look ahead in the binary for the correct 
sync sequence and kill the application otherwise. That would at least provide 
some enforcement and safety without requiring other architectures to co
 nsider what MAP_SYNC_ENABLE means to them.
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[GIT PULL] libnvdimm fixes for v5.0-rc4

2019-01-26 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-5.0-rc4

...to receive a fix for namespace label support for non-Intel NVDIMMs
that implement the ACPI standard label method. This has apparently
never worked and could wait for v5.1. However it has enough visibility
with hardware vendors [1] and distro bug trackers [2], and low enough
risk that I decided it should go in for -rc4. The other fixups target
the new, for v5.0, nvdimm security functionality. The larger init path
fixup closes a memory leak and a potential userspace lockup due to
missed notifications.

These have all soaked in -next for a week with no reported issues.

[1]: https://github.com/pmem/ndctl/issues/78
[2]: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1811785

---

The following changes since commit 49a57857aeea06ca831043acbb0fa5e0f50602fd:

  Linux 5.0-rc3 (2019-01-21 13:14:44 +1300)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-5.0-rc4

for you to fetch changes up to 11189c1089da413aa4b5fd6be4c4d47c78968819:

  acpi/nfit: Fix command-supported detection (2019-01-21 09:58:31 -0800)


libnvdimm v5.0-rc4

* Fix support for NVDIMMs that implement the ACPI standard label
  methods.
* Fix error handling for security overwrite (memory leak / userspace
  hang condition), and another one-line security cleanup


Dan Williams (3):
  libnvdimm/security: Require nvdimm_security_setup_events() to succeed
  acpi/nfit: Block function zero DSMs
  acpi/nfit: Fix command-supported detection

Dave Jiang (1):
  nfit_test: fix security state pull for nvdimm security nfit_test

 drivers/acpi/nfit/core.c | 66 
 drivers/nvdimm/dimm.c|  6 
 drivers/nvdimm/dimm_devs.c   | 22 +++---
 drivers/nvdimm/nd.h  |  1 +
 include/linux/libnvdimm.h|  1 -
 tools/testing/nvdimm/dimm_devs.c |  4 +--
 6 files changed, 73 insertions(+), 27 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


libnvdimm fixes 5.0-rc3

2019-01-19 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-5.0-rc3

...to receive a crash fix, a build warning fix, a miscellaneous small
cleanups.

In case anyone is looking for them, there was a regression caught by
testing that caused 2 patches to be dropped from this update. Those
patches [1] [2] have been reworked and will soak for another week / re-
target 5.0-rc4.

[1]: "acpi/nfit: Block function zero DSMs"
https://patchwork.kernel.org/patch/10765211/
[2]: "acpi/nfit: Fix command-supported detection" 
https://patchwork.kernel.org/patch/10772123/

Everything else has been in -next release with no reported issues.

---

The following changes since commit bfeffd155283772bbe78c6a05dec7c0128ee500c:

  Linux 5.0-rc1 (2019-01-06 17:08:20 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-5.0-rc3

for you to fetch changes up to faa8bd6e12e6aeea289d8e6ba74777b72a69434c:

  libnvdimm/security: Fix nvdimm_security_state() state request selection 
(2019-01-15 13:54:33 -0800)


libnvdimm v5.0-rc3

* Fix driver initialization crash due to the inability to report an
  'error' state for a DIMM's security capability.
* Build warning fix for little-endian ARM64 builds
* Fix a potential race between the EDAC driver's usage of the NFIT
  SMBIOS id for a DIMM and the driver shutdown path.
* A small collection of one-line benign cleanups for duplicate variable
  assignments, a duplicate header include and a mis-typed function
  argument.


Dan Williams (1):
  libnvdimm/dimm: Fix security capability detection for non-Intel NVDIMMs

Dave Jiang (1):
  libnvdimm/security: Fix nvdimm_security_state() state request selection

Nathan Chancellor (1):
  nfit: Mark some functions as __maybe_unused

Tony Luck (1):
  acpi/nfit: Fix race accessing memdev in nfit_get_smbios_id()

Wei Yang (1):
  acpi/nfit: Remove duplicate set nd_set in acpi_nfit_init_interleave_set()

Xiaochun Lee (2):
  ACPI/nfit: delete the redundant header file
  ACPI/nfit: delete the function to_acpi_nfit_desc

 drivers/acpi/nfit/core.c  | 20 +++-
 drivers/acpi/nfit/intel.c |  8 
 drivers/nvdimm/nd-core.h  |  4 ++--
 include/linux/libnvdimm.h |  1 +
 4 files changed, 14 insertions(+), 19 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] dax fix for 4.21

2018-12-29 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm tags/dax-fix-4.21

...to receive a single fix for an issue you identified on the last dax
fix pull request. While I feel a bit silly sending a single-commit
pull-request there is nothing else queued up for dax this cycle. This
change has shipped in -next for multiple releases.

---

The following changes since commit 7566ec393f4161572ba6f11ad5171fd5d59b0fbd:

  Linux 4.20-rc7 (2018-12-16 15:46:55 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm tags/dax-fix-4.21

for you to fetch changes up to d8a706414af4827fc0b4b1c0c631c607351938b9:

  dax: Use non-exclusive wait in wait_entry_unlocked() (2018-12-21 11:35:53 
-0800)


dax fix 4.21

* Clean up unnecessary usage of prepare_to_wait_exclusive()


Dan Williams (1):
  dax: Use non-exclusive wait in wait_entry_unlocked()

 fs/dax.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm for 4.21

2018-12-27 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.21

...to receive the libnvdimm update for 4.21.

The vast bulk of this update is the new support for the security
capabilities of some nvdimms. It was rebased at the end of last week to
remove randconfig breakage detected in -next. It has since appeared in
subsequent -next releases with no reported issues. The userspace
tooling for this capability is still a work in progress, but the
changes survive the existing libnvdimm unit tests. The changes also
pass manual checkout on hardware and the new nfit_test emulation of the
security capability.

The touches of the security/keys/ files have received the necessary
acks from Mimi and David. Those changes were necessary to allow for a
new generic encrypted-key type, and allow the nvdimm sub-system to
lookup key material referenced by the libnvdimm-sysfs interface.

---

The following changes since commit 40e020c129cfc991e8ab4736d2665351ffd1468d:

  Linux 4.20-rc6 (2018-12-09 15:31:00 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.21

for you to fetch changes up to 4b5f747e82b12b6d8ab815fc259827a615c7f2c3:

  Merge miscellaneous libnvdimm updates for 4.21 (2018-12-27 19:54:10 -0800)


libnvdimm for 4.21

* Add support for the security features of nvdimm devices that
  implement a security model similar to ATA hard drive security. The
  security model supports locking access to the media at
  device-power-loss, to be unlocked with a passphrase, and secure-erase
  (crypto-scramble).

  Unlike the ATA security case where the kernel expects device
  security to be managed in a pre-OS environment, the libnvdimm security
  implementation allows key provisioning and key-operations at OS
  runtime. Keys are managed with the kernel's encrypted-keys facility to
  provide data-at-rest security for the libnvdimm key material. The
  usage model mirrors fscrypt key management, but is driven via
  libnvdimm sysfs.

* Miscellaneous updates for api usage and comment fixes.


Andy Shevchenko (2):
  libnvdimm, label: Switch to bitmap_zalloc()
  libnvdimm, namespace: Replace kmemdup() with kstrndup()

Dan Williams (2):
  libnvdimm/security: Quiet security operations
  Merge miscellaneous libnvdimm updates for 4.21

Dave Jiang (16):
  acpi/nfit: Add support for Intel DSM 1.8 commands
  acpi/nfit, libnvdimm: Store dimm id as a member to struct nvdimm
  keys: Export lookup_user_key to external users
  keys-encrypted: add nvdimm key format type to encrypted keys
  acpi/nfit, libnvdimm: Introduce nvdimm_security_ops
  acpi/nfit, libnvdimm: Add freeze security support to Intel nvdimm
  acpi/nfit, libnvdimm: Add unlock of nvdimm support for Intel DIMMs
  acpi/nfit, libnvdimm: Add disable passphrase support to Intel nvdimm.
  acpi/nfit, libnvdimm: Add enable/update passphrase support for Intel 
nvdimms
  acpi/nfit, libnvdimm: Add support for issue secure erase DSM to Intel 
nvdimm
  acpi/nfit, libnvdimm/security: Add security DSM overwrite support
  acpi/nfit, libnvdimm/security: add Intel DSM 1.8 master passphrase support
  tools/testing/nvdimm: Add test support for Intel nvdimm security DSMs
  tools/testing/nvdimm: Add overwrite support for nfit_test
  tools/testing/nvdimm: add Intel DSM 1.8 support for nfit_test
  libnvdimm/security: Add documentation for nvdimm security support

Ocean He (2):
  libnvdimm, bus: Check id immediately following ida_simple_get
  ACPI/nfit: Adjust annotation for why return 0 if fail to find NFIT at 
start

 Documentation/nvdimm/security.txt | 141 +++
 Documentation/security/keys/trusted-encrypted.rst |   6 +-
 drivers/acpi/nfit/Kconfig |  11 +
 drivers/acpi/nfit/Makefile|   1 +
 drivers/acpi/nfit/core.c  | 103 -
 drivers/acpi/nfit/intel.c | 388 ++
 drivers/acpi/nfit/intel.h |  76 
 drivers/acpi/nfit/nfit.h  |  24 +-
 drivers/nvdimm/Kconfig|   5 +
 drivers/nvdimm/Makefile   |   1 +
 drivers/nvdimm/bus.c  |  33 +-
 drivers/nvdimm/dimm.c |  16 +-
 drivers/nvdimm/dimm_devs.c| 210 +-
 drivers/nvdimm/label.c|   7 +-
 drivers/nvdimm/namespace_devs.c   |   3 +-
 drivers/nvdimm/nd-core.h  |  57 +++
 drivers/nvdimm/nd.h   |   8 +
 drivers/nvdimm/region_devs.c  |   5 +
 drivers/nvdimm/security.c | 454 

[GIT PULL] dax fixes for 4.20-rc6

2018-12-08 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/dax-fixes-4.20-rc6

...to receive the last of the known regression fixes and fallout from
the Xarray conversion of the filesystem-dax implementation. On the path
to debugging why the dax memory-failure injection test started failing
after the Xarray conversion a couple more fixes for the
dax_lock_mapping_entry(), now called dax_lock_page(), surfaced. Those
plus the bug that started the hunt are now addressed. These patches
have appeared in a -next release with no issues reported.

Note the touches to mm/memory-failure.c are just the conversion to the
new function signature for dax_lock_page().

---

The following changes since commit 2e6e902d185027f8e3cb8b7305238f7e35d6a436:

  Linux 4.20-rc4 (2018-11-25 14:19:31 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/dax-fixes-4.20-rc6

for you to fetch changes up to 27359fd6e5f3c5db8fe544b63238b6170e8806d8:

  dax: Fix unlock mismatch with updated API (2018-12-04 21:32:00 -0800)


dax fixes 4.20-rc6

* Fix the Xarray conversion of fsdax to properly handle
dax_lock_mapping_entry() in the presense of pmd entries.

* Fix inode destruction racing a new lock request.


Matthew Wilcox (3):
  dax: Check page->mapping isn't NULL
  dax: Don't access a freed inode
  dax: Fix unlock mismatch with updated API

 fs/dax.c| 55 -
 include/linux/dax.h | 14 --
 mm/memory-failure.c |  6 --
 3 files changed, 50 insertions(+), 25 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm fixes for 4.20-rc6

2018-12-08 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-4.20-rc6

...to receive a regression fix for the Address Range Scrub
implementation, yes another one, and support for platforms that
misalign persistent memory relative to the Linux memory hotplug section
constraint. Longer term, support for sub-section memory hotplug would
alleviate alignment waste, but until then this hack allows a 'struct
page' memmap to be established for these misaligned memory regions.

These have all appeared in a -next release, and thanks to Patrick for
reporting and testing the alignment padding fix.

---

The following changes since commit 9ff01193a20d391e8dbce4403dd5ef87c7eaaca6:

  Linux 4.20-rc3 (2018-11-18 13:33:44 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-4.20-rc6

for you to fetch changes up to b5fd2e00a60248902315fb32210550ac3cb9f44c:

  acpi/nfit: Fix user-initiated ARS to be "ARS-long" rather than "ARS-short" 
(2018-12-05 14:16:13 -0800)


libnvdimm fixes 4.20-rc6

* Unless and until the core mm handles memory hotplug units smaller than
  a section (128M), persistent memory namespaces must be padded to
  section alignment. The libnvdimm core already handled section
  collision with "System RAM", but some configurations overlap
  independent "Persistent Memory" ranges within a section, so additional
  padding injection is added for that case.

* The recent reworks of the ARS (address range scrub) state machine to
  reduce the number of state flags inadvertantly missed a conversion of
  acpi_nfit_ars_rescan() call sites. Fix the regression whereby
  user-requested ARS results in a "short" scrub rather than a "long"
  scrub.

* Fixup the unit tests to handle / test the 128M section alignment of
  mocked test resources.


Dan Williams (3):
  tools/testing/nvdimm: Align test resources to 128M
  libnvdimm, pfn: Pad pfn namespaces relative to other regions
  acpi/nfit: Fix user-initiated ARS to be "ARS-long" rather than "ARS-short"

 drivers/acpi/nfit/core.c |  2 +-
 drivers/nvdimm/nd-core.h |  2 ++
 drivers/nvdimm/pfn_devs.c| 64 +++-
 drivers/nvdimm/region_devs.c | 41 +
 tools/testing/nvdimm/test/nfit.c | 35 --
 5 files changed, 114 insertions(+), 30 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm fixes for 4.20-rc3

2018-11-17 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-4.20-rc3

...to receive a small batch of fixes for v4.20-rc3.

These have soaked in -next for a few releases. The overflow
continuation fix addresses something that has been broken for several
releases. Arguably it could wait even longer, but it's a one line fix
and this finishes the last of the known address range scrub bug
reports. The revert addresses a lockdep regression. The unit tests are
not critical to fix, but no reason to hold this fix back.

---

The following changes since commit 651022382c7f8da46cb4872a545ee1da6d097d2a:

  Linux 4.20-rc1 (2018-11-04 15:37:52 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-4.20-rc3

for you to fetch changes up to 2121db09630113e67b51ae78c18115f1858f648a:

  Revert "acpi, nfit: Further restrict userspace ARS start requests" 
(2018-11-10 09:54:28 -0800)


libnvdimm 4.20-rc3

- Address Range Scrub overflow continuation handling has been broken
  since it was initially merged. It was only recently that error injection
  and platform-BIOS support enabled this corner case to be exercised.

- The recent attempt to provide more isolation for the kernel Address
  Range Scrub state machine from userapace initiated sessions triggers a
  lockdep report. Revert and try again at the next merge window.

- Fix a kasan reported buffer overflow in libnvdimm unit test
  infrastrucutre (nfit_test)


Dan Williams (2):
  acpi, nfit: Fix ARS overflow continuation
  Revert "acpi, nfit: Further restrict userspace ARS start requests"

Masayoshi Mizuma (1):
  tools/testing/nvdimm: Fix the array size for dimm devices.

 drivers/acpi/nfit/core.c | 19 +--
 tools/testing/nvdimm/test/nfit.c |  8 
 2 files changed, 9 insertions(+), 18 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: fsdax memory error handling regression

2018-11-06 Thread Williams, Dan J
On Tue, 2018-11-06 at 06:48 -0800, Matthew Wilcox wrote:
> On Tue, Nov 06, 2018 at 03:44:47AM +0000, Williams, Dan J wrote:
> > Hi Willy,
> > 
> > I'm seeing the following warning with v4.20-rc1 and the "dax.sh"
> > test
> > from the ndctl repository:
> 
> I'll try to run this myself later today.
> 
> > I tried to get this test going on -next before the merge window,
> > but
> > -next was not bootable for me. Bisection points to:
> > 
> > 9f32d221301c dax: Convert dax_lock_mapping_entry to XArray
> > 
> > At first glance I think we need the old "always retry if we slept"
> > behavior. Otherwise this failure seems similar to the issue fixed
> > by
> > Ross' change to always retry on any potential collision:
> > 
> > b1f382178d15 ext4: close race between direct IO and
> > ext4_break_layouts()
> > 
> > I'll take a closer look tomorrow to see if that guess is plausible.
> 
> If your thought is correct, then this should be all that's needed:
> 
> diff --git a/fs/dax.c b/fs/dax.c
> index 616e36ea6aaa..529ac9d7c10a 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -383,11 +383,8 @@ bool dax_lock_mapping_entry(struct page *page)
>   entry = xas_load();
>   if (dax_is_locked(entry)) {
>   entry = get_unlocked_entry();
> - /* Did the page move while we slept? */
> - if (dax_to_pfn(entry) != page_to_pfn(page)) {
> - xas_unlock_irq();
> - continue;
> - }
> + xas_unlock_irq();
> + continue;
>   }
>   dax_lock_entry(, entry);
>   xas_unlock_irq();

No, that doesn't work.

> 
> I don't quite understand how we'd find a PFN for this page in the
> tree
> after the page has had page->mapping removed.  However, the more I
> look
> at this path, the more I don't like it -- it doesn't handle returning
> NULL explicitly, nor does it handle the situation where a PMD is
> split
> to form multiple PTEs explicitly, it just kind of relies on those bit
> patterns not matching.
> 
> So I kind of like the "just retry without doing anything clever"
> situation
> that the above patch takes us to.

I've been hacking at this today and am starting to lean towards
"revert" over "fix" for the amount of changes needed to get this back
on its feet. I've been able to get the test passing again with the
below changes directly on top of commit 9f32d221301c "dax: Convert
dax_lock_mapping_entry to XArray". That said, I have thus far been
unable to rebase this patch on top of v4.20-rc1 and yield a functional
result.

My concerns are:
- I can't determine if dax_unlock_entry() wants an unlocked entry
parameter, or locked. The dax_insert_pfn_mkwrite() and
dax_unlock_mapping_entry() usages seem to disagree.

- The multi-order use case of Xarray is a mystery to me. It seems to
want to know the order of entries a-priori with a choice to use
XA_STATE_ORDER() vs XA_STATE(). This falls over in
dax_unlock_mapping_entry() and other places where the only source of
the order of the entry is determined from dax_is_pmd_entry() i.e. the
Xarray itself. PageHead() does not work for DAX pages because
PageHead() is only established by the page allocator and DAX pages
never participate in the page allocator.

- The usage of rcu_read_lock() in dax_lock_mapping_entry() is needed
for inode lifetime synchronization, not just for walking the radix.
That lock needs to be dropped before sleeping, and if we slept the
inode may no longer exist.

- I could not see how the pattern:
entry = xas_load();
if (dax_is_locked(entry)) {
entry = get_unlocked_entry();
...was safe given that get_unlock_entry() turns around and does
validation that the entry is !xa_internal_entry() and !NULL.

- The usage of internal entries in grab_mapping_entry() seems to need
auditing. Previously we would compare the entry size against
@size_flag, but it now if index hits a multi-order entry in
get_unlocked_entry() afaics it could be internal and we need to convert
it to the actual entry before aborting... at least to match the v4.19
behavior.

This all seems to merit a rethink of the dax integration of Xarray.

diff --git a/fs/dax.c b/fs/dax.c
index fc2745ca3308..2b3bd4a4cc48 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -99,17 +99,6 @@ static void *dax_make_locked(unsigned long pfn, unsigned 
long flags)
DAX_LOCKED);
 }
 
-static void *dax_make_entry(pfn_t pfn, unsigned long flags)
-{
-   return xa_mk_value(flags | (pfn_t_to_pfn(pfn) << DAX_SHIFT));
-}
-
-static void *dax_make_page_entry(struct page *page)
-{
-  

fsdax memory error handling regression

2018-11-05 Thread Williams, Dan J
Hi Willy,

I'm seeing the following warning with v4.20-rc1 and the "dax.sh" test
from the ndctl repository:

[   69.962873] EXT4-fs (pmem0): DAX enabled. Warning: EXPERIMENTAL, use at your 
own risk
[   69.969522] EXT4-fs (pmem0): mounted filesystem with ordered data mode. 
Opts: dax
[   70.028571] Injecting memory failure for pfn 0x208900 at process virtual 
address 0x7efe87b0
[   70.032384] Memory failure: 0x208900: Killing dax-pmd:7066 due to hardware 
memory corruption
[   70.034420] Memory failure: 0x208900: recovery action for dax page: Recovered
[   70.038878] WARNING: CPU: 37 PID: 7066 at fs/dax.c:464 
dax_insert_entry+0x30b/0x330
[   70.040675] Modules linked in: ebtable_nat(E) ebtable_broute(E) bridge(E) 
stp(E) llc(E) ip6table_mangle(E) ip6table_raw(E) ip6table_security(E) 
iptable_mangle(E) iptable_raw(E) iptable_security(E) nf_conntrack(E) 
nf_defrag_ipv6(E) nf_defrag_ipv4(E) ebtable_filter(E) ebtables(E) 
ip6table_filter(E) ip6_tables(E) crct10dif_pclmul(E) crc32_pclmul(E) 
dax_pmem(OE) crc32c_intel(E) device_dax(OE) ghash_clmulni_intel(E) nd_pmem(OE) 
nd_btt(OE) serio_raw(E) nd_e820(OE) nfit(OE) libnvdimm(OE) nfit_test_iomap(OE)
[   70.049936] CPU: 37 PID: 7066 Comm: dax-pmd Tainted: G   OE 
4.19.0-rc5+ #2589
[   70.051726] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
rel-1.11.1-0-g0551a4be2c-prebuilt.qemu-project.org 04/01/2014
[   70.055215] RIP: 0010:dax_insert_entry+0x30b/0x330
[   70.056769] Code: 84 b7 fe ff ff 48 81 e6 00 00 e0 ff e9 b2 fe ff ff 48 8b 
3c 24 48 89 ee 31 d2 e8 10 eb ff ff 49 8b 7d 00 31 f6 e9 99 fe ff ff <0f> 0b e9 
f8 fe ff ff 0f 0b e9 e2 fd ff ff e8 82 f1 f4 ff e9 9c fe
[   70.062086] RSP: :c900086bfb20 EFLAGS: 00010082
[   70.063726] RAX:  RBX:  RCX: ea000822
[   70.065755] RDX:  RSI: 00208800 RDI: 00208800
[   70.067784] RBP: 880327870bb0 R08: 00208801 R09: 00208a00
[   70.069813] R10: 00208801 R11: 0001 R12: 880327870bb8
[   70.071837] R13:  R14: 04110003 R15: 0009
[   70.073867] FS:  7efe8859d540() GS:88033ea8() 
knlGS:
[   70.076547] CS:  0010 DS:  ES:  CR0: 80050033
[   70.078294] CR2: 7efe87a0 CR3: 000334564003 CR4: 00160ee0
[   70.080326] Call Trace:
[   70.081404]  ? dax_iomap_pfn+0xb4/0x100
[   70.082770]  dax_iomap_pte_fault+0x648/0xd60
[   70.084222]  dax_iomap_fault+0x230/0xba0
[   70.085596]  ? lock_acquire+0x9e/0x1a0
[   70.086940]  ? ext4_dax_huge_fault+0x5e/0x200
[   70.088406]  ext4_dax_huge_fault+0x78/0x200
[   70.089840]  ? up_read+0x1c/0x70
[   70.091071]  __do_fault+0x1f/0x136
[   70.092344]  __handle_mm_fault+0xd2b/0x11c0
[   70.093790]  handle_mm_fault+0x198/0x3a0
[   70.095166]  __do_page_fault+0x279/0x510
[   70.096546]  do_page_fault+0x32/0x200
[   70.097884]  ? async_page_fault+0x8/0x30
[   70.099256]  async_page_fault+0x1e/0x30

I tried to get this test going on -next before the merge window, but
-next was not bootable for me. Bisection points to:

9f32d221301c dax: Convert dax_lock_mapping_entry to XArray

At first glance I think we need the old "always retry if we slept"
behavior. Otherwise this failure seems similar to the issue fixed by
Ross' change to always retry on any potential collision:

b1f382178d15 ext4: close race between direct IO and ext4_break_layouts()

I'll take a closer look tomorrow to see if that guess is plausible.
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm for 4.20

2018-10-24 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.20

...to receive the libnvdimm updates for this cycle. No interactions
with other trees this time around. There are updates to the core to
improve driver initialization time, and updates to the 'nfit' driver
for fixing ARS corner cases and exposing some more hardware attributes
to userspace. It has all been in -next for a few releases now with no
reported issues.

---

The following changes since commit 7876320f88802b22d4e2daf7eb027dd14175a0f8:

  Linux 4.19-rc4 (2018-09-16 11:52:37 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.20

for you to fetch changes up to 594861215c834e4b59a30d4b794f6372717bc197:

  acpi, nfit: Further restrict userspace ARS start requests (2018-10-17 
14:02:32 -0700)


libnvdimm for 4.20

* Improve the efficiency and performance of reading nvdimm-namespace
  labels. Reduce the amount of label data read at driver load time by a
  few orders of magnitude. Reduce heavyweight call-outs to
  platform-firmware routines.

* Handle media errors located in the 'struct page' array stored on a
  persistent memory namespace. Let the kernel clear these errors rather
  than an awkward userspace workaround.

* Fix Address Range Scrub (ARS) completion tracking. Correct occasions
  where the kernel indicates completion of ARS before submission.

* Fix asynchronous device registration reference counting.

* Add support for reporting an nvdimm dirty-shutdown-count via sysfs.

* Fix various small libnvdimm core and uapi issues.


Alexander Duyck (7):
  libnvdimm: Hold reference on parent while scheduling async init
  libnvdimm: Set device node in nd_device_register
  nvdimm: Sanity check labeloff
  nvdimm: Clarify comment in sizeof_namespace_index
  nvdimm: Remove empty if statement
  nvdimm: Split label init out from the logic for getting config data
  nvdimm: Use namespace index data to reduce number of label reads needed

Dan Williams (9):
  libnvdimm, region: Fail badblocks listing for inactive regions
  libnvdimm, pmem: Fix badblocks population for 'raw' namespaces
  libnvdimm, dimm: Maximize label transfer size
  libnvdimm, label: Fix sparse warning
  acpi, nfit: Introduce nfit_mem flags
  acpi, nfit: Collect shutdown status
  tools/testing/nvdimm: Populate dirty shutdown data
  acpi, nfit: Fix Address Range Scrub completion tracking
  acpi, nfit: Further restrict userspace ARS start requests

David Howells (2):
  UAPI: ndctl: Fix g++-unsupported initialisation in headers
  UAPI: ndctl: Remove use of PAGE_SIZE

GuangZhe Fu (1):
  libnvdimm, namespace: Drop the repeat assignment for variable dev->parent

Pankaj Gupta (1):
  libnvdimm: remove duplicate include

Vishal Verma (1):
  libnvdimm, pfn: during init, clear errors in the metadata area

 drivers/acpi/nfit/core.c  | 297 +++---
 drivers/acpi/nfit/intel.h |  38 +
 drivers/acpi/nfit/nfit.h  |  21 ++-
 drivers/nvdimm/bus.c  |  20 ++-
 drivers/nvdimm/dimm.c |   6 +-
 drivers/nvdimm/dimm_devs.c|  60 +++
 drivers/nvdimm/label.c| 144 -
 drivers/nvdimm/label.h|   4 +-
 drivers/nvdimm/namespace_devs.c   |   1 -
 drivers/nvdimm/nd-core.h  |   1 -
 drivers/nvdimm/nd.h   |   2 +
 drivers/nvdimm/pfn_devs.c |  61 ++-
 drivers/nvdimm/pmem.c |   4 +-
 drivers/nvdimm/region_devs.c  |  11 +-
 include/linux/ndctl.h |  22 +++
 include/uapi/linux/ndctl.h|  52 +++---
 tools/testing/nvdimm/Kbuild   |   1 +
 tools/testing/nvdimm/acpi_nfit_test.c |   8 +
 tools/testing/nvdimm/test/nfit.c  |   4 +-
 tools/testing/nvdimm/test/nfit_test.h |  24 ---
 20 files changed, 564 insertions(+), 217 deletions(-)
 create mode 100644 drivers/acpi/nfit/intel.h
 create mode 100644 include/linux/ndctl.h
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] dax fixes for 4.19-rc8

2018-10-13 Thread Williams, Dan J
Hi Greg, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-4.19-rc8

...to receive (2) urgent dax fixes for 4.19-rc8. They have appeared in
a -next release.

However, note that commit d7782145e1ad ("filesystem-dax: Fix
dax_layout_busy_page() livelock") is immediately replaced with the
Xarray conversion targeting 4.20, so d7782145e1ad is the backport
suitable fix for the livelock for v4.19 and earlier.

Please pull, thanks!

---

The following changes since commit 17b57b1883c1285f3d0dc2266e8f79286a7bef38:

  Linux 4.19-rc6 (2018-09-30 07:15:35 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-4.19-rc8

for you to fetch changes up to 4628a64591e6cee181237060961e98c615c33966:

  mm: Preserve _PAGE_DEVMAP across mprotect() calls (2018-10-09 11:44:58 -0700)


libnvdimm/dax 4.19-rc8

* Fix a livelock in dax_layout_busy_page() present since v4.18. The
  lockup triggers when truncating an actively mapped huge page out of a
  mapping pinned for direct-I/O.

* Fix mprotect() clobbers of _PAGE_DEVMAP. Broken since v4.5 mprotect()
  clears this flag that is needed to communicate the liveness of device
  pages to the get_user_pages() path.


Dan Williams (1):
  filesystem-dax: Fix dax_layout_busy_page() livelock

Jan Kara (1):
  mm: Preserve _PAGE_DEVMAP across mprotect() calls

 arch/powerpc/include/asm/book3s/64/pgtable.h |  4 ++--
 arch/x86/include/asm/pgtable_types.h |  2 +-
 fs/dax.c | 13 +++--
 3 files changed, 14 insertions(+), 5 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH v12 00/12] Adding security support for nvdimm

2018-10-09 Thread Williams, Dan J
On Mon, 2018-10-08 at 16:55 -0700, Dave Jiang wrote:
> The following series implements security support for nvdimm. Mostly
> adding
> new security DSM support from the Intel NVDIMM DSM spec v1.7, but
> also
> adding generic support libnvdimm for other vendors. The most
> important
> security features are unlocking locked nvdimms, and updating/setting
> security
> passphrase to nvdimms.
> 
> v12:
> - Add a mutex for the cached key and remove key_get/key_put messiness
> (Dan)
> - Move security code to its own C file and wrap under
> CONFIG_NVDIMM_SECURITY
>   in order to fix issue reported by 0-day build without CONFIG_KEYS.

Going over this a bit more closely here is some proposed cleanups /
fixes:

* remove nvdimm_get_key() and just rely on nvdimm->key being not NULL
under the key_mutex

* open code nvdimm_check_key_len() checks

* make all the security op function signatures take an nvdimm rather
than a dev

* move the release of nvdimm->key to nvdimm_remove() rather than
nvdimm_release(), i.e. driver unload vs nvdimm_bus de-registration.

* rename nvdimm_replace_key to make_kernel_key

* clean up nvdimm_security_change_key() to a be bit more readable and
fix a missing key_put()


Let me know if these look acceptable and I can fold them into the patch
set.

diff --git a/drivers/nvdimm/dimm.c b/drivers/nvdimm/dimm.c
index b6381ddbd6c1..429c544e7ac5 100644
--- a/drivers/nvdimm/dimm.c
+++ b/drivers/nvdimm/dimm.c
@@ -23,6 +23,7 @@
 
 static int nvdimm_probe(struct device *dev)
 {
+   struct nvdimm *nvdimm = to_nvdimm(dev);
struct nvdimm_drvdata *ndd;
int rc;
 
@@ -51,10 +52,10 @@ static int nvdimm_probe(struct device *dev)
get_device(dev);
kref_init(>kref);
 
-   nvdimm_security_get_state(dev);
+   nvdimm_security_get_state(nvdimm);
 
/* unlock DIMM here before touch label */
-   rc = nvdimm_security_unlock_dimm(dev);
+   rc = nvdimm_security_unlock_dimm(nvdimm);
if (rc < 0)
dev_warn(dev, "failed to unlock dimm %s\n", dev_name(dev));
 
@@ -115,6 +116,9 @@ static int nvdimm_probe(struct device *dev)
 static int nvdimm_remove(struct device *dev)
 {
struct nvdimm_drvdata *ndd = dev_get_drvdata(dev);
+   struct nvdimm *nvdimm = to_nvdimm(dev);
+
+   nvdimm_security_release(nvdimm);
 
if (!ndd)
return 0;
diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
index 2d9915378bbc..84bec3bb025e 100644
--- a/drivers/nvdimm/dimm_devs.c
+++ b/drivers/nvdimm/dimm_devs.c
@@ -213,13 +213,7 @@ void nvdimm_clear_locked(struct device *dev)
 static void nvdimm_release(struct device *dev)
 {
struct nvdimm *nvdimm = to_nvdimm(dev);
-   struct key *key;
 
-   mutex_lock(>key_mutex);
-   key = nvdimm_get_key(dev);
-   if (key)
-   key_put(key);
-   mutex_unlock(>key_mutex);
ida_simple_remove(_ida, nvdimm->id);
kfree(nvdimm);
 }
@@ -436,20 +430,20 @@ static ssize_t security_store(struct device *dev,
if (rc != 3)
return -EINVAL;
dev_dbg(dev, "update %#x %#x\n", old_key, new_key);
-   rc = nvdimm_security_change_key(dev, old_key, new_key);
+   rc = nvdimm_security_change_key(nvdimm, old_key, new_key);
} else if (sysfs_streq(cmd, "disable")) {
if (rc != 2)
return -EINVAL;
dev_dbg(dev, "disable %#x\n", old_key);
-   rc = nvdimm_security_disable(dev, old_key);
+   rc = nvdimm_security_disable(nvdimm, old_key);
} else if (sysfs_streq(buf, "freeze")) {
dev_dbg(dev, "freeze\n");
-   rc = nvdimm_security_freeze_lock(dev);
+   rc = nvdimm_security_freeze_lock(nvdimm);
} else if (sysfs_streq(cmd, "erase")) {
if (rc != 2)
return -EINVAL;
dev_dbg(dev, "erase %#x\n", old_key);
-   rc = nvdimm_security_erase(dev, old_key);
+   rc = nvdimm_security_erase(nvdimm, old_key);
} else
return -EINVAL;
 
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 08e442632a2d..45fcaf45ba2c 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -425,48 +425,47 @@ const u8 *nd_dev_to_uuid(struct device *dev);
 bool pmem_should_map_pages(struct device *dev);
 
 #ifdef CONFIG_NVDIMM_SECURITY
-struct key *nvdimm_get_key(struct device *dev);
-int nvdimm_security_unlock_dimm(struct device *dev);
-int nvdimm_security_get_state(struct device *dev);
-int nvdimm_security_change_key(struct device *dev, unsigned int old_keyid,
+int nvdimm_security_unlock_dimm(struct nvdimm *nvdimm);
+void nvdimm_security_release(struct nvdimm *nvdimm);
+int nvdimm_security_get_state(struct nvdimm *nvdimm);
+int nvdimm_security_change_key(struct nvdimm *nvdimm, unsigned int old_keyid,
unsigned int new_keyid);
-int nvdimm_security_disable(struct 

Re: [ndctl PATCH 1/2] ndctl, monitor: fix the severity of the "daemon started" message

2018-10-04 Thread Williams, Dan J
On Thu, 2018-10-04 at 18:00 -0600, Vishal Verma wrote:
> The above message was printed as an error, but it is just an
> informational message. Change it to dbg().
> 
> Cc: QI Fuli 
> Cc: Dan Williams 

Reviewed-by: Dan Williams 

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [ndctl PATCH 2/2] ndctl, monitor: in daemon mode, exit successfully if no DIMMs are found

2018-10-04 Thread Williams, Dan J
On Thu, 2018-10-04 at 18:00 -0600, Vishal Verma wrote:
> When we are running as a daemon, it is preferred to exit successfully
> when no DIMMs are found. When running in the foreground, retain an
> error
> return so that the user can be notified that nothing was found to
> monitor.
> 
> In the longer term, replace this with a libudev uevent monitor that
> will
> look for DIMM addition/removal events, and update the running
> monitor(s)
> if the DIMMs match the active filter spec.
> 
> Link: https://bugs.launchpad.net/ubuntu/+source/ndctl/+bug/1781268
> Reported-by: Andreas Hasenack 
> Cc: Dan Williams 

Looks good to me, if no one is sticking around to reap the error might
as well claim success.

Reviewed-by: Dan Williams 

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [ndctl PATCH v2] libndctl: set errno for routines that don't return an error status

2018-10-04 Thread Williams, Dan J
On Thu, 2018-10-04 at 17:17 -0600, Vishal Verma wrote:
> For routines that return a UINT_MAX or UL{L}ONG_MAX, there isn't a
> way
> to get any information as to what went wrong. Set errno in such
> routines
> so that the callers can get some additional context about the error.
> 
> Reported-by: Lukasz Dorau 
> Cc: Dan Williams 

Reviewed-by: Dan Williams 

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [ndctl PATCH] libndctl: set errno for routines that don't return an error status

2018-10-04 Thread Williams, Dan J
On Thu, 2018-10-04 at 16:01 -0700, Verma, Vishal L wrote:
> On Thu, 2018-10-04 at 15:54 -0700, Williams, Dan J wrote:
> > On Thu, 2018-10-04 at 16:34 -0600, Vishal Verma wrote:
> > > For routines that return a UINT_MAX or UL{L}ONG_MAX, there isn't
> > > a
> > > way
> > > to get any information as to what went wrong. Set errno in such
> > > routines
> > > so that the callers can get some additional context about the
> > > error.
> > 
> > Looks ok, but why EOVERFLOW and not ENOMEM for the out of resource
> > conditions?
> 
> I debated between that and also ENOSPC, but nothing seemed like an
> exact fit for a buffer too small.. Mainly not ENOMEM because we
> aren't
> actually trying to allocate memory as a part of this?

That's true, but the effect is the same, couldn't get enough resource
to complete the operation. I would expect EOVERFLOW for trying to store
a 64-bit quantity in a 32-bit field.

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [ndctl PATCH] libndctl: set errno for routines that don't return an error status

2018-10-04 Thread Williams, Dan J
On Thu, 2018-10-04 at 16:34 -0600, Vishal Verma wrote:
> For routines that return a UINT_MAX or UL{L}ONG_MAX, there isn't a
> way
> to get any information as to what went wrong. Set errno in such
> routines
> so that the callers can get some additional context about the error.

Looks ok, but why EOVERFLOW and not ENOMEM for the out of resource
conditions?
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [ndctl PATCH v2 4/5] util/json: Add comments around re-checking the UTIL_JSON_MEDIA_ERRORS flag

2018-10-03 Thread Williams, Dan J
On Wed, 2018-10-03 at 12:15 -0600, Vishal Verma wrote:
> Add comments to clarify that in the various ndctl_*_babdlock_foreach
> loops where we compose the json output, the additional check for
> UTIL_JSON_MEDIA_ERRORS is valid because even if we're not printing
> media errors, we still want the badblock_count to be updated, which
> requires a full badblocks traversal.
> 
> Cc: Dan Williams 
> Suggested-by: Dan Williams 

Reviewed-by: Dan Williams 

...and everything else looks good too in this series.
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] filesystem-dax fix for 4.19-rc6

2018-09-29 Thread Williams, Dan J
Hi Greg, please pull from...

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes2-4.19-rc6

...to receive one more urgent fix for 4.19-rc6.

---

The following changes since commit 6bf4ca7fbc85d80446ac01c0d1d77db4d91a6d84:

  Linux 4.19-rc5 (2018-09-23 19:15:18 +0200)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes2-4.19-rc6

for you to fetch changes up to f52afc93cd018fe6910133a05d44671192d1aeb0:

  dax: Fix deadlock in dax_lock_mapping_entry() (2018-09-27 10:56:15 -0700)


filesystem-dax for 4.19-rc6

Fix a deadlock in the new for 4.19 dax_lock_mapping_entry() routine.


Jan Kara (1):
  dax: Fix deadlock in dax_lock_mapping_entry()

 fs/dax.c | 1 +
 1 file changed, 1 insertion(+)

commit f52afc93cd018fe6910133a05d44671192d1aeb0
Author: Jan Kara 
Date:   Thu Sep 27 13:23:32 2018 +0200

dax: Fix deadlock in dax_lock_mapping_entry()

When dax_lock_mapping_entry() has to sleep to obtain entry lock, it will
fail to unlock mapping->i_pages spinlock and thus immediately deadlock
against itself when retrying to grab the entry lock again. Fix the
problem by unlocking mapping->i_pages before retrying.

Fixes: c2a7d2a11552 ("filesystem-dax: Introduce dax_lock_mapping_entry()")
Reported-by: Barret Rhoden 
Signed-off-by: Jan Kara 
Signed-off-by: Dan Williams 

diff --git a/fs/dax.c b/fs/dax.c
index f32d7125ad0f..e4ef8af31aa6 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -447,6 +447,7 @@ bool dax_lock_mapping_entry(struct page *page)
xa_unlock_irq(>i_pages);
break;
} else if (IS_ERR(entry)) {
+   xa_unlock_irq(>i_pages);
WARN_ON_ONCE(PTR_ERR(entry) != -EAGAIN);
continue;
}
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH 2/2] nvdimm: Set device node in nd_device_register

2018-09-25 Thread Williams, Dan J
On Tue, 2018-09-25 at 14:35 -0700, Alexander Duyck wrote:
[..]
> Yeah, I kind of gathered that. If you want to move it feel free to.

Thanks for the flexibility, applied.

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL v2] libnvdimm/dax fixes for 4.19-rc6

2018-09-25 Thread Williams, Dan J
Hi Greg, please pull from...

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-4.19-rc6

...to receive a regression fix and 2 other fixes. Details are in the
tag message. Arguably only the 'address_space_operations' fix is urgent
for -rc6, the others can reasonably wait, but I see no reason to hold
them back. This has all appeared in -next with no reported issues.

---

The following changes since commit 11da3a7f84f19c26da6f86af878298694ede0804:

  Linux 4.19-rc3 (2018-09-09 17:26:43 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-4.19-rc6

for you to fetch changes up to 41c9b1be335b5afc3b5fb71c5d16f9d5939cd13f:

  device-dax: Add missing address_space_operations (2018-09-22 09:07:33 -0700)


libnvdimm/dax for 4.19-rc6

* (2) fixes for the dax error handling updates that were merged for
v4.19-rc1. My mails to Al have been bouncing recently, so I do not have
his ack but the uaccess change is of the trivial / obviously correct
variety. The address_space_operations fixes a regression.

* A filesystem-dax fix to correct the zero page lookup to be compatible
 with non-x86 (mips and s390) architectures.


Dave Jiang (2):
  uaccess: Fix is_source param for check_copy_size() in 
copy_to_iter_mcsafe()
  device-dax: Add missing address_space_operations

Matthew Wilcox (1):
  filesystem-dax: Fix use of zero page

 drivers/dax/device.c |  6 ++
 fs/dax.c | 13 ++---
 include/linux/uio.h  |  2 +-
 3 files changed, 9 insertions(+), 12 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm/dax fixes for 4.19-rc6

2018-09-24 Thread Williams, Dan J
Hi Greg, please pull from...

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive:

* (2) fixes for the dax error handling updates that were merged for
v4.19-rc1. My mails to Al have been bouncing recently, so I do not have
his ack but the uaccess change is of the trivial / obviously correct
variety. The address_space_operations fixes a regression.

* A filesystem-dax fix to correct the zero page lookup to be compatible
 with non-x86 (mips and s390) architectures.

Arguably only the address_space_operations fix is urgent for -rc6, the
others can reasonably wait, but I see no reason to hold them back. This
has all appeared in -next with no reported issues. The full diff is
small and included below.

---

The following changes since commit 11da3a7f84f19c26da6f86af878298694ede0804:

  Linux 4.19-rc3 (2018-09-09 17:26:43 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 41c9b1be335b5afc3b5fb71c5d16f9d5939cd13f:

  device-dax: Add missing address_space_operations (2018-09-22 09:07:33 -0700)


Dave Jiang (2):
  uaccess: Fix is_source param for check_copy_size() in 
copy_to_iter_mcsafe()
  device-dax: Add missing address_space_operations

Matthew Wilcox (1):
  filesystem-dax: Fix use of zero page

 drivers/dax/device.c |  6 ++
 fs/dax.c | 13 ++---
 include/linux/uio.h  |  2 +-
 3 files changed, 9 insertions(+), 12 deletions(-)

---

diff --git a/drivers/dax/device.c b/drivers/dax/device.c
index bbe4d72ca105..948806e57cee 100644
--- a/drivers/dax/device.c
+++ b/drivers/dax/device.c
@@ -535,6 +535,11 @@ static unsigned long dax_get_unmapped_area(struct file 
*filp,
return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
 }
 
+static const struct address_space_operations dev_dax_aops = {
+   .set_page_dirty = noop_set_page_dirty,
+   .invalidatepage = noop_invalidatepage,
+};
+
 static int dax_open(struct inode *inode, struct file *filp)
 {
struct dax_device *dax_dev = inode_dax(inode);
@@ -544,6 +549,7 @@ static int dax_open(struct inode *inode, struct file *filp)
dev_dbg(_dax->dev, "trace\n");
inode->i_mapping = __dax_inode->i_mapping;
inode->i_mapping->host = __dax_inode;
+   inode->i_mapping->a_ops = _dax_aops;
filp->f_mapping = inode->i_mapping;
filp->f_wb_err = filemap_sample_wb_err(filp->f_mapping);
filp->private_data = dev_dax;
diff --git a/fs/dax.c b/fs/dax.c
index f32d7125ad0f..b68ce484e1be 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1120,21 +1120,12 @@ static vm_fault_t dax_load_hole(struct address_space 
*mapping, void *entry,
 {
struct inode *inode = mapping->host;
unsigned long vaddr = vmf->address;
-   vm_fault_t ret = VM_FAULT_NOPAGE;
-   struct page *zero_page;
-   pfn_t pfn;
-
-   zero_page = ZERO_PAGE(0);
-   if (unlikely(!zero_page)) {
-   ret = VM_FAULT_OOM;
-   goto out;
-   }
+   pfn_t pfn = pfn_to_pfn_t(my_zero_pfn(vaddr));
+   vm_fault_t ret;
 
-   pfn = page_to_pfn_t(zero_page);
dax_insert_mapping_entry(mapping, vmf, entry, pfn, RADIX_DAX_ZERO_PAGE,
false);
ret = vmf_insert_mixed(vmf->vma, vaddr, pfn);
-out:
trace_dax_load_hole(inode, vmf, ret);
return ret;
 }
diff --git a/include/linux/uio.h b/include/linux/uio.h
index 409c845d4cd3..422b1c01ee0d 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -172,7 +172,7 @@ size_t copy_from_iter_flushcache(void *addr, size_t bytes, 
struct iov_iter *i)
 static __always_inline __must_check
 size_t copy_to_iter_mcsafe(void *addr, size_t bytes, struct iov_iter *i)
 {
-   if (unlikely(!check_copy_size(addr, bytes, false)))
+   if (unlikely(!check_copy_size(addr, bytes, true)))
return 0;
else
return _copy_to_iter_mcsafe(addr, bytes, i);
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm for 4.18

2018-06-08 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.18

...to receive the first part of the libnvdimm / persistent memory
support update for 4.18. These patches have all been in -next for
several releases. The 'DAX DMA vs Truncate' work has had extra soak
time as it nearly missed 4.17.

This pull request adds a user for the new 'bytes-remaining' updates to
memcpy_mcsafe() that you already received through Ingo via the x86-dax-
for-linus pull. There is a minor collision with bdev_dax_supported()
reworks that you pulled from xfs, and another minor collision of the
vm_fault_t conversion you received from Andrew. A potential merge
resolution is here: https://git.kernel.org/pub/scm/linux/kernel/git/nvd
imm/nvdimm.git/log/?h=libnvdimm-for-4.18-merge

Not included in this pull, but still targeting this cycle, is support
for handling memory media errors (poison) consumed via userspace dax
mappings.

---

The following changes since commit b04e217704b7f879c6b91222b066983a44a7a09f:

  Linux 4.17-rc7 (2018-05-27 13:01:47 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.18

for you to fetch changes up to 930218affeadd1325ea17e053f0dcecf218f5a4f:

  Merge branch 'for-4.18/mcsafe' into libnvdimm-for-next (2018-06-08 15:16:44 
-0700)


libnvdimm for 4.18

* DAX broke a fundamental assumption of truncate of file mapped pages.
  The truncate path assumed that it is safe to disconnect a pinned page
  from a file and let the filesystem reclaim the physical block. With DAX
  the page is equivalent to the filesystem block. Introduce
  dax_layout_busy_page() to enable filesystems to wait for pinned DAX
  pages to be released. Without this wait a filesystem could allocate
  blocks under active device-DMA to a new file.

* DAX arranges for the block layer to be bypassed and uses
  dax_direct_access() + copy_to_iter() to satisfy read(2) calls.
  However, the memcpy_mcsafe() facility is available through the pmem
  block driver. In order to safely handle media errors, via the DAX
  block-layer bypass, introduce copy_to_iter_mcsafe().

* Fix cache management policy relative to the ACPI NFIT Platform
  Capabilities Structure to properly elide cache flushes when they are not
  necessary. The table indicates whether CPU caches are power-fail
  protected. Clarify that a deep flush is always performed on
  REQ_{FUA,PREFLUSH} requests.


Dan Williams (17):
  memremap: split devm_memremap_pages() and memremap() infrastructure
  mm: introduce MEMORY_DEVICE_FS_DAX and CONFIG_DEV_PAGEMAP_OPS
  mm: fix __gup_device_huge vs unmap
  mm, fs, dax: handle layout changes to pinned dax mappings
  xfs: prepare xfs_break_layouts() to be called with XFS_MMAPLOCK_EXCL
  xfs: prepare xfs_break_layouts() for another layout type
  xfs, dax: introduce xfs_break_dax_layouts()
  uio, lib: Fix CONFIG_ARCH_HAS_UACCESS_MCSAFE compilation
  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: Add unit test for memcpy_mcsafe()
  libnvdimm: Debug probe times
  libnvdimm, e820: Register all pmem resources
  acpi, nfit: Remove ecc_unit_size
  Merge branch 'for-4.18/dax' into libnvdimm-for-next
  Merge branch 'for-4.18/mcsafe' into libnvdimm-for-next

Matthew Wilcox (1):
  dax: dax_insert_mapping_entry always succeeds

Robert Elliott (1):
  linvdimm, pmem: Preserve read-only setting for pmem devices

Ross Zwisler (4):
  libnvdimm, pmem: Complete REQ_FLUSH => REQ_PREFLUSH
  libnvdimm, pmem: Unconditionally deep flush on *sync
  libnvdimm, pmem: Do not flush power-fail protected CPU caches
  dax: Use dax_write_cache* helpers

 Documentation/ABI/removed/sysfs-bus-nfit |  17 +++
 Documentation/ABI/testing/sysfs-bus-nfit |  19 ---
 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/acpi/nfit/core.c |  11 --
 drivers/dax/super.c  |  33 +++--
 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/bus.c |  19 ++-
 drivers/nvdimm/claim.c   |   3 +-
 drivers/nvdimm/e820.c|  41 +++---
 drivers/nvdimm/pfn_devs.c|   

[GIT PULL] libnvdimm fixes for 4.17-rc2

2018-04-21 Thread Williams, Dan J
Hi Linus, please pull from

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive, a regression fix, new unit test infrastructure and a
build fix.

* The regression fix addresses support for the new NVDIMM label storage
area access commands (_LSI, _LSR, and _LSW). The Intel specific version
of these commands communicated the "Device Locked" status on the label-
storage-information command. However, these new commands (standardized
in ACPI 6.2) communicate the "Device Locked" status on the label-
storage-read command, and the driver was missing the indication.
Reading from locked persistent memory is similar to reading unmapped
PCI memory space, returns all 1's.

* Unit test infrastructure is added to regression test the "Device
Locked" detection failure.

* A build fix is included to allow the "of_pmem" driver to be built as
a module and translate an Open Firmware described device to its local
numa node.

---

The following changes since commit 60cc43fc888428bb2f18f08997432d426a243338:

  Linux 4.17-rc1 (2018-04-15 18:24:20 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to c5794510d7b5f210f05531ff9e82432cf7244367:

  MAINTAINERS: Add backup maintainers for libnvdimm and DAX (2018-04-19 
15:22:50 -0700)


Dan Williams (6):
  libnvdimm, dimm: handle EACCES failures from label reads
  tools/testing/nvdimm: allow custom error code injection
  tools/testing/nvdimm: support nfit_test_dimm attributes under nfit_test.1
  tools/testing/nvdimm: fix missing newline in nfit_test_dimm 'handle' 
attribute
  tools/testing/nvdimm: enable labels for nfit_test.1 dimms
  Revert "libnvdimm, of_pmem: workaround OF_NUMA=n build error"

Dave Jiang (2):
  device-dax: allow MAP_SYNC to succeed
  MAINTAINERS: Add backup maintainers for libnvdimm and DAX

Rob Herring (1):
  libnvdimm, of_pmem: use dev_to_node() instead of of_node_to_nid()

 MAINTAINERS  | 15 +++
 drivers/dax/device.c |  2 +
 drivers/nvdimm/Kconfig   |  3 +-
 drivers/nvdimm/dimm_devs.c   | 22 ++-
 drivers/nvdimm/of_pmem.c |  2 +-
 tools/testing/nvdimm/test/nfit.c | 84 +++-
 6 files changed, 96 insertions(+), 32 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm fixes for 4.16-rc7

2018-03-22 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive 2 regression fixes, 2 bug fixes for older issues, 2
fixes for new functionality added this cycle that have userspace ABI
concerns, and a small cleanup. These have appeared in a linux-next
release and have a build success report from the 0day robot.

* The 4.16 rework of altmap handling led to some configurations leaking
page table allocations due to freeing from the altmap reservation
rather than the page allocator. The impact without the fix is leaked
memory and a WARN() message when tearing down libnvdimm namespaces. The
rework also missed a place where error handling code needed to be
removed that can lead to a crash if devm_memremap_pages() fails.

* acpi_map_pxm_to_node() had a latent bug whereby it could misidentify
the closest online node to a given proximity domain.

* Block integrity handling was reworked several kernels back to allow
calling add_disk() after setting up the integrity profile. The nd_btt
and nd_blk drivers are just now catching up to fix automatic partition
detection at driver load time.

* The new peristence_domain attribute, a platform indicator of whether
cpu caches are powerfail protected for example, is meant to be a single
value enum and not a set of flags. This oversight was caught while
reviewing new userspace code in libndctl to communicate the attribute.
Fix this new enabling up so that we are not stuck with an unwanted
userspace ABI.

The following changes since commit 661e50bc853209e41a5c14a290ca4decc43cbfd1:

  Linux 4.16-rc4 (2018-03-04 14:54:11 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to fe9a552e715dfe5167d52deb74ea16335896bdaf:

  libnvdimm, nfit: fix persistence domain reporting (2018-03-21 15:12:07 -0700)


Colin Ian King (1):
  libnvdimm: remove redundant assignment to pointer 'dev'

Dan Williams (4):
  x86, memremap: fix altmap accounting at free
  acpi, numa: fix pxm to online numa node associations
  libnvdimm, region: hide persistence_domain when unknown
  libnvdimm, nfit: fix persistence domain reporting

Oliver O'Halloran (1):
  kernel/memremap: Remove stale devres_free() call

Vishal Verma (1):
  libnvdimm, {btt, blk}: do integrity setup before add_disk()

 arch/x86/mm/init_64.c| 60 +---
 drivers/acpi/nfit/core.c | 10 +---
 drivers/acpi/numa.c  | 10 +---
 drivers/nvdimm/blk.c |  3 +--
 drivers/nvdimm/btt.c |  3 +--
 drivers/nvdimm/pfn_devs.c|  2 +-
 drivers/nvdimm/region_devs.c | 17 ++---
 kernel/memremap.c|  1 -
 8 files changed, 57 insertions(+), 49 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm fixes for 4.16-rc4

2018-03-03 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive a 4.16 regression fix, 3 fixes for -stable, and a cleanup
fix.

* During the merge window support for the new ACPI NVDIMM Platform
Capabilities structure disabled support for "deep flush", a force-unit-
access like mechanism for persistent memory. Restore that mechanism.

* VFIO like RDMA is yet one more memory registration / pinning
interface that is incompatible with Filesystem-DAX. Disable long term
pins of Filesystem-DAX mappings via VFIO.

* The Filesystem-DAX detection to prevent long terms pins mistakenly
also disabled Device-DAX pins which are not subject to the same block-
map collision concerns.

* Similar to the setup path, softlockup warnings can trigger in the
shutdown path for large persistent memory namespaces. Teach
for_each_device_pfn() to perform cond_resched() in all cases.

* Boaz noticed that the might_sleep() in dax_direct_access() is stale
as of the v4.15 kernel.

These have received a build success notification from the 0day robot,
and the longterm pin fixes have appeared in -next. However, I recently
rebased the tree to remove some other fixes that need to be reworked
after review feedback.

---

The following changes since commit 91ab883eb21325ad80f3473633f794c78ac87f51:

  Linux 4.16-rc2 (2018-02-18 17:29:42 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 949b93250a566cc7a578b4f829cf76b70d19a62c:

  memremap: fix softlockup reports at teardown (2018-03-02 19:34:50 -0800)


Boaz Harrosh (1):
  dax: ->direct_access does not sleep anymore

Dan Williams (3):
  dax: fix vma_is_fsdax() helper
  vfio: disable filesystem-dax page pinning
  memremap: fix softlockup reports at teardown

Dave Jiang (1):
  libnvdimm: re-enable deep flush for pmem devices via fsync()

 drivers/dax/super.c |  6 --
 drivers/nvdimm/pmem.c   |  3 +--
 drivers/vfio/vfio_iommu_type1.c | 18 +++---
 include/linux/fs.h  |  2 +-
 kernel/memremap.c   | 15 ++-
 5 files changed, 27 insertions(+), 17 deletions(-)

---

commit 9d4949b4935831be10534d5432bf611285a572a5
Author: Boaz Harrosh 
Date:   Mon Feb 26 18:50:35 2018 +0200

dax: ->direct_access does not sleep anymore

In Patch:
[7a862fb] brd: remove dax support

  Dan Williams has removed the only might_sleep
  implementation of ->direct_access.
  So we no longer need to check for it.

CC: Dan Williams 
Signed-off-by: Boaz Harrosh 
Signed-off-by: Dan Williams 

commit 230f5a8969d8345fc9bbe3683f068246cf1be4b8
Author: Dan Williams 
Date:   Wed Feb 21 17:08:01 2018 -0800

dax: fix vma_is_fsdax() helper

Gerd reports that ->i_mode may contain other bits besides S_IFCHR. Use
S_ISCHR() instead. Otherwise, get_user_pages_longterm() may fail on
device-dax instances when those are meant to be explicitly allowed.

Fixes: 2bb6d2837083 ("mm: introduce get_user_pages_longterm")
Cc: 
Reported-by: Gerd Rausch 
Acked-by: Jane Chu 
Reported-by: Haozhong Zhang 
Reviewed-by: Jan Kara 
Signed-off-by: Dan Williams 

commit 94db151dc89262bfa82922c44e8320cea2334667
Author: Dan Williams 
Date:   Sun Feb 4 10:34:02 2018 -0800

vfio: disable filesystem-dax page pinning

Filesystem-DAX is incompatible with 'longterm' page pinning. Without
page cache indirection a DAX mapping maps filesystem blocks directly.
This means that the filesystem must not modify a file's block map while
any page in a mapping is pinned. In order to prevent the situation of
userspace holding of filesystem operations indefinitely, disallow
'longterm' Filesystem-DAX mappings.

RDMA has the same conflict and the plan there is to add a 'with lease'
mechanism to allow the kernel to notify userspace that the mapping is
being torn down for block-map maintenance. Perhaps something similar can
be put in place for vfio.

Note that xfs and ext4 still report:

   "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"

...at mount time, and resolving the dax-dma-vs-truncate problem is one
of the last hurdles to remove that designation.

Acked-by: Alex Williamson 
Cc: Michal Hocko 
Cc: k...@vger.kernel.org
Cc: 
Reported-by: Haozhong Zhang 
Tested-by: Haozhong Zhang 

[GIT PULL] libnvdimm fixes for 4.15-rc5

2017-12-23 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive:

* NVDIMM namespaces, configured to enforce 1GB alignment, fail to
initialize on platforms that mis-align the start or end of the physical
address range.

* The Linux implementation of the BTT (Block Translation Table) is
incompatible with the UEFI 2.7 definition of the BTT format. The BTT
layers a software atomic sector semantic on top of an NVDIMM namespace.
Linux needs to be compatible with the UEFI definition to enable boot
support or any pre-OS access of data on a BTT enabled namespace.

* A fix for ACPI SMART notification events, this allows a userspace
monitor to register for health events rather than poll. This has been
broken since it was initially merged as the unit test inadvertently
worked around the problem. The urgency for fixing this during the -rc
series is driven by how expensive it is to poll for this data (System
Management Mode entry).

These fixes are all tagged for -stable and have received a build
success notification from the kbuild robot. Full changelogs below:

---

The following changes since commit ae64f9bd1d3621b5e60d7363bc20afb46aede215:

  Linux 4.15-rc2 (2017-12-03 11:01:47 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 24e3a7fb60a9187e5df90e5fa655ffc94b9c4f77:

  libnvdimm, btt: Fix an incompatibility in the log layout (2017-12-21 14:59:27 
-0800)


Dan Williams (3):
  acpi, nfit: fix health event notification
  libnvdimm, pfn: fix start_pad handling for aligned namespaces
  libnvdimm, dax: fix 1GB-aligned namespaces vs physical misalignment

Vishal Verma (2):
  libnvdimm, btt: add a couple of missing kernel-doc lines
  libnvdimm, btt: Fix an incompatibility in the log layout

 drivers/acpi/nfit/core.c  |   9 ++-
 drivers/nvdimm/btt.c  | 201 ++
 drivers/nvdimm/btt.h  |  47 ++-
 drivers/nvdimm/pfn_devs.c |  20 +++--
 4 files changed, 236 insertions(+), 41 deletions(-)


commit adf6895754e2503d994a765535fd1813f8834674
Author: Dan Williams 
Date:   Thu Nov 30 19:42:52 2017 -0800

acpi, nfit: fix health event notification

Integration testing with a BIOS that generates injected health event
notifications fails to communicate those events to userspace. The nfit
driver neglects to link the ACPI DIMM device with the necessary driver
data so acpi_nvdimm_notify() fails this lookup:

nfit_mem = dev_get_drvdata(dev);
if (nfit_mem && nfit_mem->flags_attr)
sysfs_notify_dirent(nfit_mem->flags_attr);

Add the necessary linkage when installing the notification handler and
clean it up when the nfit driver instance is torn down.

Cc: 
Cc: Toshi Kani 
Cc: Vishal Verma 
Fixes: ba9c8dd3c222 ("acpi, nfit: add dimm device notification support")
Reported-by: Daniel Osawa 
Tested-by: Daniel Osawa 
Signed-off-by: Dan Williams 

commit 19deaa217bc04e83b59b5e8c8229eb0e53ad9efc
Author: Dan Williams 
Date:   Tue Dec 19 15:07:10 2017 -0800

libnvdimm, pfn: fix start_pad handling for aligned namespaces

The alignment checks at pfn driver startup fail to properly account for
the 'start_pad' in the case where the namespace is misaligned relative
to its internal alignment. This is typically triggered in 1G aligned
namespace, but could theoretically trigger with small namespace
alignments. When this triggers the kernel reports messages of the form:

dax2.1: bad offset: 0x3c00 dax disabled align: 0x4000

Cc: 
Fixes: 1ee6667cd8d1 ("libnvdimm, pfn, dax: fix initialization vs 
autodetect...")
Reported-by: Jane Chu 
Signed-off-by: Dan Williams 

commit 41fce90f26333c4fa82e8e43b9ace86c4e8a0120
Author: Dan Williams 
Date:   Mon Dec 4 14:07:43 2017 -0800

libnvdimm, dax: fix 1GB-aligned namespaces vs physical misalignment

The following namespace configuration attempt:

# ndctl create-namespace -e namespace0.0 -m devdax -a 1G -f
libndctl: ndctl_dax_enable: dax0.1: failed to enable
  Error: namespace0.0: failed to enable

failed to reconfigure namespace: No such device or address

...fails when the backing memory range is not physically aligned to 1G:

# cat /proc/iomem | grep Persistent
21000-30fff : Persistent Memory (legacy)

In the above example the 4G persistent memory range 

Re: revamp vmem_altmap / dev_pagemap handling

2017-12-07 Thread Williams, Dan J
On Thu, 2017-12-07 at 07:08 -0800, Christoph Hellwig wrote:
> Hi all,
> 
> this series started with two patches from Logan that now are in the
> middle of the series to kill the memremap-internal pgmap structure
> and to redo the dev_memreamp_pages interface to be better suitable
> for future PCI P2P uses.  I reviewed them and noticed that there
> isn't really any good reason to keep struct vmem_altmap either,
> and that a lot of these alternative device page map access should
> be better abstracted out instead of being sprinkled all over the
> mm code.
> 
> Please review carefully, this has only been tested with my legacy
> e820 NVDIMM system.

I get this lockdep report booting it on my test-VM. I'll take a closer
look next week... the fsdax-vs-hole-punch-vs-dma fix is on the top of
my queue.

[7.631431] =
[7.632668] WARNING: suspicious RCU usage
[7.633494] 4.15.0-rc2+ #942 Tainted: G   O
[7.635262] -
[7.636764] ./include/linux/rcupdate.h:302 Illegal context switch in RCU 
read-side critical section!
[7.640139] 
[7.640139] other info that might help us debug this:
[7.640139] 
[7.643382] 
[7.643382] rcu_scheduler_active = 2, debug_locks = 1
[7.645814] 5 locks held by systemd-udevd/835:
[7.647546]  #0:  (>mutex){}, at: [<64217991>] 
__driver_attach+0x58/0xe0
[7.650171]  #1:  (>mutex){}, at: [<527f6e1a>] 
__driver_attach+0x66/0xe0
[7.652779]  #2:  (cpu_hotplug_lock.rw_sem){}, at: [] 
mem_hotplug_begin+0xa/0x20
[7.655677]  #3:  (mem_hotplug_lock.rw_sem){}, at: [<3d83cb2a>] 
percpu_down_write+0x27/0x120
[7.658649]  #4:  (rcu_read_lock){}, at: [] 
vmemmap_populate+0x0/0x373
[7.661133] 
[7.661133] stack backtrace:
[7.662650] CPU: 22 PID: 835 Comm: systemd-udevd Tainted: G   O 
4.15.0-rc2+ #942
[7.665264] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
[7.668873] Call Trace:
[7.668879]  dump_stack+0x7d/0xbe
[7.668885]  ___might_sleep+0xe2/0x250
[7.668890]  __alloc_pages_nodemask+0x107/0x3b0
[7.668901]  vmemmap_alloc_block+0x5a/0xc1
[7.668904]  vmemmap_populate+0x16c/0x373
[7.668915]  sparse_mem_map_populate+0x23/0x33
[7.668917]  sparse_add_one_section+0x45/0x179
[7.668924]  __add_pages+0xc4/0x1f0
[7.668935]  add_pages+0x15/0x70
[7.668939]  devm_memremap_pages+0x293/0x440
[7.668954]  pmem_attach_disk+0x4f4/0x620 [nd_pmem]
[7.668966]  ? nd_dax_probe+0x105/0x140 [libnvdimm]
[7.668971]  ? nd_dax_probe+0x105/0x140 [libnvdimm]
[7.668981]  nvdimm_bus_probe+0x63/0x100 [libnvdimm]
[7.668988]  driver_probe_device+0x2a8/0x490
[7.668993]  __driver_attach+0xde/0xe0
[7.668997]  ? driver_probe_device+0x490/0x490
[7.668998]  bus_for_each_dev+0x6a/0xb0
[7.669002]  bus_add_driver+0x16d/0x260
[7.669005]  driver_register+0x57/0xc0
[7.669007]  ? 0xa0083000
[7.669009]  do_one_initcall+0x4e/0x18f
[7.669012]  ? rcu_read_lock_sched_held+0x3f/0x70
[7.669014]  ? kmem_cache_alloc_trace+0x2a0/0x310
[7.669020]  do_init_module+0x5b/0x213
[7.669023]  load_module+0x1873/0x1f10
[7.669029]  ? show_coresize+0x30/0x30
[7.669035]  ? vfs_read+0x131/0x150
[7.669052]  ? SYSC_finit_module+0xd2/0x100
[7.669053]  SYSC_finit_module+0xd2/0x100
[7.669067]  do_syscall_64+0x66/0x230
[7.669070]  entry_SYSCALL64_slow_path+0x25/0x25
[7.669072] RIP: 0033:0x7fc493dd8229
[7.669073] RSP: 002b:7ffcaab453d8 EFLAGS: 0246 ORIG_RAX: 
0139
[7.669074] RAX: ffda RBX: 5643cb407bb0 RCX: 7fc493dd8229
[7.669075] RDX:  RSI: 7fc4949189c5 RDI: 000f
[7.669076] RBP: 7fc4949189c5 R08:  R09: 7ffcaab454f0
[7.669076] R10: 000f R11: 0246 R12: 
[7.669077] R13: 5643cb408010 R14: 0002 R15: 5643c97c8dec
[7.669112] BUG: sleeping function called from invalid context at 
mm/page_alloc.c:4174
[7.669113] in_atomic(): 1, irqs_disabled(): 0, pid: 835, name: systemd-udevd
[7.669115] 5 locks held by systemd-udevd/835:
[7.669115]  #0:  (>mutex){}, at: [<64217991>] 
__driver_attach+0x58/0xe0
[7.669120]  #1:  (>mutex){}, at: [<527f6e1a>] 
__driver_attach+0x66/0xe0
[7.669123]  #2:  (cpu_hotplug_lock.rw_sem){}, at: [] 
mem_hotplug_begin+0xa/0x20
[7.669126]  #3:  (mem_hotplug_lock.rw_sem){}, at: [<3d83cb2a>] 
percpu_down_write+0x27/0x120
[7.669130]  #4:  (rcu_read_lock){}, at: [] 
vmemmap_populate+0x0/0x373
[7.669135] CPU: 22 PID: 835 Comm: systemd-udevd Tainted: G   O 
4.15.0-rc2+ #942
[7.669136] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 

[GIT PULL] libnvdimm for 4.15

2017-11-16 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.15

...to receive the libnvdimm and dax update for 4.15.

Save for a few late fixes, all of these commits have shipped in -next
releases since before the merge window opened, and 0day has given a
build success notification. The MAP_SYNC work included some re-
factoring of dax_insert_mapping(), to break out a common
dax_iomap_pfn() helper, that collided with other small changes in
fs/dax.c. A suggested merge resolution for that collision and a few
other minor collisions is included below after the diffstat.

The ext4 touches came from Jan, and the xfs touches have Darrick's
reviewed-by. An xfstest for the MAP_SYNC feature [1] has been through a
few round of reviews and is on track to be merged. The final policy of
how MAP_SHARED_VALIDATE and MAP_SYNC flags behave was discussed by you
and Jan here: [2].

[1]: https://lists.01.org/pipermail/linux-nvdimm/2017-October/012974.ht
ml
[2]: https://lists.01.org/pipermail/linux-nvdimm/2017-October/012894.ht
ml

---

The following changes since commit 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f:

  Linux 4.14-rc4 (2017-10-08 20:53:29 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.15

for you to fetch changes up to 4247f24c23589bcc3bc3490515ef8c9497e9ae55:

  Merge branch 'for-4.15/dax' into libnvdimm-for-next (2017-11-15 16:56:11 
-0800)


libnvdimm for 4.15

* Introduce MAP_SYNC and MAP_SHARED_VALIDATE, a mechanism to enable
 'userspace flush' of persistent memory updates via filesystem-dax
  mappings. It arranges for any filesystem metadata updates that may be
  required to satisfy a write fault to also be flushed ("on disk") before
  the kernel returns to userspace from the fault handler. Effectively
  every write-fault that dirties metadata completes an fsync() before
  returning from the fault handler. The new MAP_SHARED_VALIDATE mapping
  type guarantees that the MAP_SYNC flag is validated as supported by the
  filesystem's ->mmap() file operation.

* Add support for the standard ACPI 6.2 label access methods that
  replace the NVDIMM_FAMILY_INTEL (vendor specific) label methods. This
  enables interoperability with environments that only implement the
  standardized methods.

* Add support for the ACPI 6.2 NVDIMM media error injection methods.

* Add support for the NVDIMM_FAMILY_INTEL v1.6 DIMM commands for latch
  last shutdown status, firmware update, SMART error injection, and
  SMART alarm threshold control.

* Cleanup physical address information disclosures to be root-only.

* Fix revalidation of the DIMM "locked label area" status to support
  dynamic unlock of the label area.

* Expand unit test infrastructure to mock the ACPI 6.2 Translate SPA
  (system-physical-address) command and error injection commands.

Acknowledgements that came after the commits were pushed to -next:

957ac8c421ad dax: fix PMD faults on zero-length files
Reviewed-by: Ross Zwisler 

a39e596baa07 xfs: support for synchronous DAX faults
Reviewed-by: Darrick J. Wong 

7b565c9f965b xfs: Implement xfs_filemap_pfn_mkwrite() using 
__xfs_filemap_fault()
Reviewed-by: Darrick J. Wong 


Arvind Yadav (1):
  dax: pr_err() strings should end with newlines

Christoph Hellwig (1):
  xfs: support for synchronous DAX faults

Colin Ian King (1):
  libnvdimm, namespace: make a couple of functions static

Dan Williams (18):
  libnvdimm, dimm: clear 'locked' status on successful DIMM enable
  libnvdimm, region : make 'resource' attribute only readable by root
  libnvdimm, namespace: make 'resource' attribute only readable by root
  libnvdimm, pfn: make 'resource' attribute only readable by root
  libnvdimm, namespace: fix label initialization to use valid seq numbers
  acpi, nfit: add support for the _LSI, _LSR, and _LSW label methods
  libnvdimm: introduce 'flags' attribute for DIMM 'lock' and 'alias' status
  acpi, nfit: hide unknown commands from nmemX/commands
  acpi, nfit: add support for NVDIMM_FAMILY_INTEL v1.6 DSMs
  mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap 
flags
  acpi, nfit: validate commands against the device type
  tools/testing/nvdimm: unit test clear-error commands
  fs, dax: unify IOMAP_F_DIRTY read vs write handling policy in the dax core
  dax: quiet bdev_dax_supported()
  brd: remove dax support
  dax: stop requiring a live device for dax_flush()
  acpi, nfit: add 'Enable Latch System Shutdown Status' command support
  Merge branch 'for-4.15/dax' into libnvdimm-for-next

Dave Jiang (2):
  libnvdimm: move poison list functions to a new 'badrange' file
  

Re: [PATCH v3 00/13] dax: fix dma vs truncate and remove 'page-less' support

2017-10-26 Thread Williams, Dan J
On Thu, 2017-10-26 at 12:58 +0200, Jan Kara wrote:
> On Fri 20-10-17 11:31:48, Christoph Hellwig wrote:
> > On Fri, Oct 20, 2017 at 09:47:50AM +0200, Christoph Hellwig wrote:
> > > I'd like to brainstorm how we can do something better.
> > > 
> > > How about:
> > > 
> > > If we hit a page with an elevated refcount in truncate / hole puch
> > > etc for a DAX file system we do not free the blocks in the file system,
> > > but add it to the extent busy list.  We mark the page as delayed
> > > free (e.g. page flag?) so that when it finally hits refcount zero we
> > > call back into the file system to remove it from the busy list.
> > 
> > Brainstorming some more:
> > 
> > Given that on a DAX file there shouldn't be any long-term page
> > references after we unmap it from the page table and don't allow
> > get_user_pages calls why not wait for the references for all
> > DAX pages to go away first?  E.g. if we find a DAX page in
> > truncate_inode_pages_range that has an elevated refcount we set
> > a new flag to prevent new references from showing up, and then
> > simply wait for it to go away.  Instead of a busy way we can
> > do this through a few hashed waitqueued in dev_pagemap.  And in
> > fact put_zone_device_page already gets called when putting the
> > last page so we can handle the wakeup from there.
> > 
> > In fact if we can't find a page flag for the stop new callers
> > things we could probably come up with a way to do that through
> > dev_pagemap somehow, but I'm not sure how efficient that would
> > be.
> 
> We were talking about this yesterday with Dan so some more brainstorming
> from us. We can implement the solution with extent busy list in ext4
> relatively easily - we already have such list currently similarly to XFS.
> There would be some modifications needed but nothing too complex. The
> biggest downside of this solution I see is that it requires per-filesystem
> solution for busy extents - ext4 and XFS are reasonably fine, however btrfs
> may have problems and ext2 definitely will need some modifications.
> Invisible used blocks may be surprising to users at times although given
> page refs should be relatively short term, that should not be a big issue.
> But are we guaranteed page refs are short term? E.g. if someone creates
> v4l2 videobuf in MAP_SHARED mapping of a file on DAX filesystem, page refs
> can be rather long-term similarly as in RDMA case. Also freeing of blocks
> on page reference drop is another async entry point into the filesystem
> which could unpleasantly surprise us but I guess workqueues would solve
> that reasonably fine.
> 
> WRT waiting for page refs to be dropped before proceeding with truncate (or
> punch hole for that matter - that case is even nastier since we don't have
> i_size to guard us). What I like about this solution is that it is very
> visible there's something unusual going on with the file being truncated /
> punched and so problems are easier to diagnose / fix from the admin side.
> So far we have guarded hole punching from concurrent faults (and
> get_user_pages() does fault once you do unmap_mapping_range()) with
> I_MMAP_LOCK (or its equivalent in ext4). We cannot easily wait for page
> refs to be dropped under I_MMAP_LOCK as that could deadlock - the most
> obvious case Dan came up with is when GUP obtains ref to page A, then hole
> punch comes grabbing I_MMAP_LOCK and waiting for page ref on A to be
> dropped, and then GUP blocks on trying to fault in another page.
> 
> I think we cannot easily prevent new page references to be grabbed as you
> write above since nobody expects stuff like get_page() to fail. But I 
> think that unmapping relevant pages and then preventing them to be faulted
> in again is workable and stops GUP as well. The problem with that is though
> what to do with page faults to such pages - you cannot just fail them for
> hole punch, and you cannot easily allocate new blocks either. So we are
> back at a situation where we need to detach blocks from the inode and then
> wait for page refs to be dropped - so some form of busy extents. Am I
> missing something?
> 

No, that's a good summary of what we talked about. However, I did go
back and give the new lock approach a try and was able to get my test
to pass. The new locking is not pretty especially since you need to
drop and reacquire the lock so that get_user_pages() can finish
grabbing all the pages it needs. Here are the two primary patches in
the series, do you think the extent-busy approach would be cleaner?

---

commit 5023d20a0aa795ddafd43655be1bfb2cbc7f4445
Author: Dan Williams 
Date:   Wed Oct 25 05:14:54 2017 -0700

mm, dax: handle truncate of dma-busy pages

get_user_pages() pins file backed memory pages for access by dma
devices. However, it only pins the memory pages not the page-to-file
offset association. If a file is truncated the pages are mapped out of
the file and dma may continue indefinitely into 

[GIT PULL] MAP_SHARED_VALIDATE for 4.14

2017-09-14 Thread Williams, Dan J
Hi Linus, please consider pulling:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/map-shared-validate-for-4.14

...for 4.14 as a pre-requisite for the proposed mmap flags (MAP_SYNC
and MAP_DIRECT) being developed for 4.15 consideration. As I
highlighted in the last posting [1] these patches are based on a random
point in the merge window (state of the tree 2 days ago). They have not
been in -next. However, they have been exposed to the 0day kbuild robot
with all reports fixed. A test merge with the state of the tree today
finds no conflicts, nor new mmap handlers for the coccinelle script to
convert.

The only change since the last posting was clarifying in commit
4aac0d08f6d1 "mm: introduce MAP_SHARED_VALIDATE..." that
MAP_SHARED_VALIDATE is just MAP_SHARED+validate, not a bitmap to be
added to new flag values, and that it is a unique MAP_TYPE number not
necessarily (MAP_SHARED|MAP_PRIVATE) (from Jan's review).

Now, we could wait until 4.15 and do the same rebase, run coccinelle
script, rinse, and repeat process for 4.15. I.e wait until we also have
the MAP_SYNC and/or MAP_DIRECT to merge at the same time, but I think
it is preferable to base that development on early 4.14-rc and get it
some soak time in -next.

Another alternative is to just get patch1, commit 403fee48224c "vfs:
add flags...", in for 4.14 and save MAP_SHARED_VALIDATE to arrive in
the next merge window coincident with the new flags implementation.

Lastly, the alternative to all this thrash is carrying the flags in the
vma. That bloats vm_area_struct everywhere and complicates vma
splitting / merging for the handful of mmap implementations that will
ever care about the new flags.

[1]: https://lwn.net/Articles/733281/

---

The following changes since commit 8fac2f96ab86b0e14ec4e42851e21e9b518bdc55:

  Merge branch 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm 
(2017-09-12 06:10:44 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/map-shared-validate-for-4.14

for you to fetch changes up to 4aac0d08f6d1ae4475bbfe761b943d105e11b82a:

  mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap 
flags (2017-09-12 10:12:34 -0700)


MAP_SHARED_VALIDATE for 4.14

Preparation infrastructure for introducing new mmap flags:

* Introduce MAP_SHARED_VALIDATE as an mmap(2) flag that in addition to
  creating a MAP_SHARED mapping also arranges for the @flags parameter
  of mmap(2) to be validated by the endpoint mmap-file-operation. I.e.
  new mmap flags require per mmap implementation opt-in and run time
  validation.

* Make the @flags parameter available to all mmap implementations, both
  top-level 'struct file_operations' and sub-level leaf implementations.


Dan Williams (2):
  vfs: add flags parameter to all ->mmap() handlers
  mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap 
flags

 arch/alpha/include/uapi/asm/mman.h |  1 +
 arch/arc/kernel/arc_hostlink.c |  3 +-
 arch/mips/include/uapi/asm/mman.h  |  1 +
 arch/mips/kernel/vdso.c|  2 +-
 arch/parisc/include/uapi/asm/mman.h|  1 +
 arch/powerpc/kernel/proc_powerpc.c |  3 +-
 arch/powerpc/kvm/book3s_64_vio.c   |  3 +-
 arch/powerpc/platforms/cell/spufs/file.c   | 21 +++
 arch/powerpc/platforms/powernv/memtrace.c  |  3 +-
 arch/powerpc/platforms/powernv/opal-prd.c  |  3 +-
 arch/tile/mm/elf.c |  3 +-
 arch/um/drivers/mmapper_kern.c |  3 +-
 arch/xtensa/include/uapi/asm/mman.h|  1 +
 drivers/android/binder.c   |  3 +-
 drivers/auxdisplay/cfag12864bfb.c  |  3 +-
 drivers/auxdisplay/ht16k33.c   |  3 +-
 drivers/char/agp/frontend.c|  3 +-
 drivers/char/bsr.c |  3 +-
 drivers/char/hpet.c|  6 ++-
 drivers/char/mbcs.c|  3 +-
 drivers/char/mbcs.h|  3 +-
 drivers/char/mem.c | 11 --
 drivers/char/mspec.c   |  9 +++--
 drivers/char/uv_mmtimer.c  |  6 ++-
 drivers/dax/device.c   |  3 +-
 drivers/dma-buf/dma-buf.c  | 11 --
 drivers/firewire/core-cdev.c   |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h|  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c   |  5 ++-
 drivers/gpu/drm/armada/armada_gem.c|  3 +-
 drivers/gpu/drm/ast/ast_drv.h   

[GIT PULL] libnvdimm for 4.14

2017-09-11 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.14

...to receive:

A rework of media error handling in the BTT driver and other updates.
It has appeared in a few -next releases and collected some late-
breaking build-error and warning fixups as a result. There are no known
merge conflicts, and the touches to fs/ have reviewed-by tags.

---

The following changes since commit 14ccee78fc82f5512908f4424f541549a5705b89:

  Linux 4.13-rc6 (2017-08-20 14:13:52 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.14

for you to fetch changes up to 04c3c982fcc0151ed3574d7ae4f1e62278054d72:

  libnvdimm, btt: fix format string warnings (2017-09-09 11:31:39 -0700)


libnvdimm for 4.14

* Media error handling support in the Block Translation Table (BTT)
  driver is reworked to address sleeping-while-atomic locking and
  memory-allocation-context conflicts.

* The dax_device lookup overhead for xfs and ext4 is moved out of the
  iomap hot-path to a mount-time lookup.

* A new 'ecc_unit_size' sysfs attribute is added to advertise the
  read-modify-write boundary property of a persistent memory range.

* Preparatory fix-ups for arm and powerpc pmem support are included
  along with other miscellaneous fixes.


Christophe Jaillet (1):
  libnvdimm, btt: check memory allocation failure

Colin Ian King (1):
  ext4: fix null pointer dereference on sbi

Dan Williams (13):
  nfit, libnvdimm, region: export 'position' in mapping info
  nfit: cleanup long de-reference chains in acpi_nfit_init_interleave_set
  libnvdimm: rename nd_sector_size_{show,store} to 
nd_size_select_{show,store}
  libnvdimm, pfn, dax: limit namespace alignments to the supported set
  libnvdimm, label: fix index block size calculation
  dax: introduce a fs_dax_get_by_bdev() helper
  xfs: perform dax_device lookup at mount
  ext2: perform dax_device lookup at mount
  ext4: perform dax_device lookup at mount
  libnvdimm, nfit: export an 'ecc_unit_size' sysfs attribute
  libnvdimm: fix integer overflow static analysis warning
  Merge branch 'for-4.14/fs' into libnvdimm-for-next
  dax: fix FS_DAX=n BLOCK=y compilation

Meng Xu (1):
  libnvdimm, nfit: move the check on nd_reserved2 to the endpoint

Oliver O'Halloran (2):
  libnvdimm: Stop using HPAGE_SIZE
  libnvdimm, pfn, dax: show supported dax/pfn region alignments in sysfs

Randy Dunlap (1):
  libnvdimm, btt: fix format string warnings

Robin Murphy (1):
  libnvdimm, nd_blk: remove mmio_flush_range()

Vishal Verma (7):
  libnvdimm, btt: fix a missed NVDIMM_IO_ATOMIC case in the write path
  libnvdimm, btt: refactor map entry operations with macros
  libnvdimm, btt: ensure that flags were also unchanged during a map_read
  libnvdimm, btt: cache sector_size in arena_info
  libnvdimm: fix potential deadlock while clearing errors
  libnvdimm, btt: rework error clearing
  libnvdimm, btt: clean up warning and error messages

 arch/x86/Kconfig  |   1 -
 arch/x86/include/asm/cacheflush.h |   2 -
 drivers/acpi/nfit/Kconfig |   2 +-
 drivers/acpi/nfit/core.c  |  50 --
 drivers/dax/super.c   |  12 +++
 drivers/nvdimm/btt.c  | 197 ++
 drivers/nvdimm/btt.h  |  11 +++
 drivers/nvdimm/btt_devs.c |   4 +-
 drivers/nvdimm/bus.c  |  27 +++---
 drivers/nvdimm/claim.c|   9 +-
 drivers/nvdimm/core.c |  10 +-
 drivers/nvdimm/label.c|  30 +++---
 drivers/nvdimm/namespace_devs.c   |   6 +-
 drivers/nvdimm/nd.h   |  16 +++-
 drivers/nvdimm/pfn_devs.c |  53 ++
 drivers/nvdimm/pmem.h |  14 ---
 drivers/nvdimm/region_devs.c  |   6 +-
 fs/ext2/ext2.h|   1 +
 fs/ext2/inode.c   |  11 +--
 fs/ext2/super.c   |   4 +
 fs/ext4/ext4.h|   1 +
 fs/ext4/inode.c   |  11 +--
 fs/ext4/super.c   |   4 +
 fs/xfs/xfs_aops.c |  13 +++
 fs/xfs/xfs_aops.h |   1 +
 fs/xfs/xfs_buf.c  |   4 +-
 fs/xfs/xfs_buf.h  |   3 +-
 fs/xfs/xfs_iomap.c|  10 +-
 fs/xfs/xfs_super.c|  25 -
 include/linux/dax.h   |   6 ++
 include/linux/libnvdimm.h |  16 
 lib/Kconfig   |   3 -
 tools/testing/nvdimm/test/nfit.c  |   4 +-
 33 files changed, 397 insertions(+), 170 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm fix for 4.13-final

2017-08-30 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive a single patch removing some structure definitions from a
uapi header file. These payloads are never processed directly by the
kernel they are simply passed through an ioctl as opaque blobs to the
ACPI _DSM (Device Specific Method) interface.

Userspace should not be depending on the kernel to define these
payloads. We will instead provide these definitions via the existing
libndctl (https://github.com/pmem/ndctl) project that has NVDIMM
command helpers and other definitions.

---

The following changes since commit cc4a41fe5541a73019a864883297bd5043aa6d98:

  Linux 4.13-rc7 (2017-08-27 17:20:40 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 7a14724f54bf9889fcb1a9f1d4aa4e1d2e969d93:

  libnvdimm: clean up command definitions (2017-08-28 08:33:20 -0700)


Dan Williams (1):
  libnvdimm: clean up command definitions

 include/uapi/linux/ndctl.h | 37 -
 1 file changed, 37 deletions(-)

commit 7a14724f54bf9889fcb1a9f1d4aa4e1d2e969d93
Author: Dan Williams 
Date:   Mon Aug 28 08:33:20 2017 -0700

libnvdimm: clean up command definitions

Remove the command payloads that do not have an associated libnvdimm
ioctl. I.e. remove the payloads that would only ever be carried in the
ND_CMD_CALL envelope. This prevents userspace from growing unnecessary
dependencies on this kernel header when userspace already has everything
it needs to craft and send these commands.

Cc: Jerry Hoemann 
Reported-by: Yasunori Goto 
Signed-off-by: Dan Williams 

diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 6d3c54264d8e..3f03567631cb 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -145,43 +145,6 @@ struct nd_cmd_clear_error {
__u64 cleared;
 } __packed;
 
-struct nd_cmd_trans_spa {
-   __u64 spa;
-   __u32 status;
-   __u8  flags;
-   __u8  _reserved[3];
-   __u64 trans_length;
-   __u32 num_nvdimms;
-   struct nd_nvdimm_device {
-   __u32 nfit_device_handle;
-   __u32 _reserved;
-   __u64 dpa;
-   } __packed devices[0];
-
-} __packed;
-
-struct nd_cmd_ars_err_inj {
-   __u64 err_inj_spa_range_base;
-   __u64 err_inj_spa_range_length;
-   __u8  err_inj_options;
-   __u32 status;
-} __packed;
-
-struct nd_cmd_ars_err_inj_clr {
-   __u64 err_inj_clr_spa_range_base;
-   __u64 err_inj_clr_spa_range_length;
-   __u32 status;
-} __packed;
-
-struct nd_cmd_ars_err_inj_stat {
-   __u32 status;
-   __u32 inj_err_rec_count;
-   struct nd_error_stat_query_record {
-   __u64 err_inj_stat_spa_range_base;
-   __u64 err_inj_stat_spa_range_length;
-   } __packed record[0];
-} __packed;
-
 enum {
ND_CMD_IMPLEMENTED = 0,
 
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm fixes for 4.13-rc2

2017-07-20 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-4.13-rc2

...to receive a handful of small fixes for 4.13-rc2. 3 of these fixes
are tagged for -stable. They have all appeared in at least one -next
release with no reported issues. Full commit log below:

---

The following changes since commit 5771a8c08880cdca3bfb4a3fc6d309d6bba20877:

  Linux v4.13-rc1 (2017-07-15 15:22:10 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-fixes-4.13-rc2

for you to fetch changes up to bbb3be170ac2891526ad07b18af7db226879a8e7:

  device-dax: fix sysfs duplicate warnings (2017-07-18 17:49:14 -0700)


libnvdimm for 4.13-rc2

* Fix handling of media errors that span a sector

* Fix support of multiple namespaces in a libnvdimm region being in
  device-dax mode

* Clean up the machine check notifier properly when the nfit driver
  fails to register

* Address a static analysis (smatch) report in device-dax


Dan Williams (3):
  device-dax: fix 'passing zero to ERR_PTR()' warning
  MAINTAINERS: list drivers/acpi/nfit/ files for libnvdimm sub-system
  device-dax: fix sysfs duplicate warnings

Prarit Bhargava (1):
  acpi/nfit: Fix memory corruption/Unregister mce decoder on failure

Toshi Kani (1):
  libnvdimm: fix badblock range handling of ARS range

 MAINTAINERS  |  2 +-
 drivers/acpi/nfit/core.c | 10 +-
 drivers/dax/device-dax.h |  2 +-
 drivers/dax/device.c | 33 +++--
 drivers/dax/pmem.c   | 12 +++-
 drivers/nvdimm/core.c|  7 ---
 6 files changed, 45 insertions(+), 21 deletions(-)

---

commit 4e3f0701f25ab194c5362576b1146a1e6cc6c2e7
Author: Toshi Kani 
Date:   Fri Jul 7 17:44:26 2017 -0600

libnvdimm: fix badblock range handling of ARS range

__add_badblock_range() does not account sector alignment when
it sets 'num_sectors'.  Therefore, an ARS error record range
spanning across two sectors is set to a single sector length,
which leaves the 2nd sector unprotected.

Change __add_badblock_range() to set 'num_sectors' properly.

Cc: 
Fixes: 0caeef63e6d2 ("libnvdimm: Add a poison list and export badblocks")
Signed-off-by: Toshi Kani 
Reviewed-by: Vishal Verma 
Signed-off-by: Dan Williams 

commit 43fe51e11c194a6576634585f81ba33e104194a5
Author: Dan Williams 
Date:   Wed Jul 12 13:42:37 2017 -0700

device-dax: fix 'passing zero to ERR_PTR()' warning

Dan Carpenter reports:

The patch 7b6be8444e0f: "dax: refactor dax-fs into a generic provider
of 'struct dax_device' instances" from Apr 11, 2017, leads to the
following static checker warning:

drivers/dax/device.c:643 devm_create_dev_dax()
warn: passing zero to 'ERR_PTR'

Fix the case where we inadvertently leak 0 to ERR_PTR() by setting at
every error case, and make it clear that 'count' is never 0.

Reported-by: Dan Carpenter 
Signed-off-by: Dan Williams 

commit 7e700d2c59e5853c9126642976b4f5768f64c9b3
Author: Prarit Bhargava 
Date:   Wed May 31 13:32:00 2017 -0400

acpi/nfit: Fix memory corruption/Unregister mce decoder on failure

nfit_init() calls nfit_mce_register() on module load.  When the module
load fails the nfit mce decoder is not unregistered.  The module's
memory is freed leaving the decoder chain referencing junk.  This will
cause panics as future registrations will reference the free'd memory.

Unregister the nfit mce decoder on module init failure.

[v2]: register and then unregister mce handler to avoid losing mce events
[v3]: also cleanup nfit workqueue

Fixes: 6839a6d96f4e ("nfit: do an ARS scrub on hitting a latent media 
error")
Cc: 
Cc: "Rafael J. Wysocki" 
Cc: Len Brown 
Cc: Vishal Verma 
Cc: "Lee, Chun-Yi" 
Cc: Linda Knippers 
Cc: lszub...@redhat.com
Acked-by: Jeff Moyer 
Signed-off-by: Prarit Bhargava 
Reviewed-by: Vishal Verma 
Signed-off-by: Dan Williams 

commit 23b9babb50ff5ac8eb9208b978b2a630e99bf90b
Author: Dan Williams 
Date:   Mon Jul 17 09:58:51 2017 -0700

MAINTAINERS: list drivers/acpi/nfit/ files for libnvdimm sub-system

Patches that update the drivers/acpi/nfit/ directory need 

[GIT PULL] libnvdimm for 4.13

2017-07-06 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.13

to receive, libnvdimm updates for the latest ACPI and UEFI
specifications. This pull request also includes new 'struct
dax_operations' enabling to undo the abuse [1] of copy_user_nocache()
for copy operations to pmem. The dax work originally missed 4.12 to
address concerns raised by Al.

[1]: https://lists.01.org/pipermail/linux-nvdimm/2017-January/008364.html

All of the commits in this pull request have appeared in one or more
-next releases with no errors reported, however, Stephen did report a
late merge conflict between nvdimm.git and the vfs.git tree. Stephen's
merge resolution is here: http://marc.info/?l=linux-kernel=1499064115
07301=2, but to match Al's changes we appear to also need the
incremental change below.

Please pull, I believe any straggling _flushcache() feedback at this
point can be fixed up post -rc1. I include commit 0aed55af8834 "x86,
uaccess: introduce copy_from_iter_flushcache for pmem / cache-bypass
operations" at the end of this message for reference.

---

diff --git a/include/linux/uio.h b/include/linux/uio.h
index 2f46f8d4b508..073bb1feb0d0 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -97,6 +97,7 @@ size_t _copy_to_iter(const void *addr, size_t bytes, struct 
iov_iter *i);
 size_t _copy_from_iter(void *addr, size_t bytes, struct iov_iter *i);
 bool _copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i);
 size_t _copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i);
+size_t _copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter 
*i);
 bool _copy_from_iter_full_nocache(void *addr, size_t bytes, struct iov_iter 
*i);
 
 static __always_inline __must_check
@@ -151,7 +152,14 @@ bool copy_from_iter_full_nocache(void *addr, size_t bytes, 
struct iov_iter *i)
  * IS_ENABLED(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) before assuming that the
  * destination is flushed from the cache on return.
  */
-size_t copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i);
+static __always_inline __must_check
+size_t copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i)
+{
+   if (unlikely(!check_copy_size(addr, bytes, false)))
+   return bytes;
+   else
+   return _copy_from_iter_flushcache(addr, bytes, i);
+}
 #else
 static inline size_t copy_from_iter_flushcache(void *addr, size_t bytes,
   struct iov_iter *i)
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index ee82300d98b9..0d18ede56a36 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -642,7 +642,7 @@ size_t _copy_from_iter_nocache(void *addr, size_t bytes, 
struct iov_iter *i)
 EXPORT_SYMBOL(_copy_from_iter_nocache);
 
 #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
-size_t copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i)
+size_t _copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i)
 {
char *to = addr;
if (unlikely(i->type & ITER_PIPE)) {
@@ -660,7 +660,7 @@ size_t copy_from_iter_flushcache(void *addr, size_t bytes, 
struct iov_iter *i)
 
return bytes;
 }
-EXPORT_SYMBOL_GPL(copy_from_iter_flushcache);
+EXPORT_SYMBOL_GPL(_copy_from_iter_flushcache);
 #endif
 
 bool _copy_from_iter_full_nocache(void *addr, size_t bytes, struct iov_iter *i)

---

The following changes since commit 87085ff2e90ecfa91f8bb0cb0ce19ea661bd6f83:

  thermal: int340x_thermal: fix compile after the UUID API switch (2017-06-09 
16:37:31 +0200)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.13

for you to fetch changes up to 9d92573fff3ec70785ef1815cc80573f70e7a921:

  Merge branch 'for-4.13/dax' into libnvdimm-for-next (2017-07-03 16:54:58 
-0700)


libnvdimm for 4.13

* Introduce the _flushcache() family of memory copy helpers and use them
  for persistent memory write operations on x86. The _flushcache()
  semantic indicates that the cache is either bypassed for the copy
  operation (movnt) or any lines dirtied by the copy operation are
  written back (clwb, clflushopt, or clflush).

* Extend dax_operations with ->copy_from_iter() and ->flush()
  operations. These operations and other infrastructure updates allow
  all persistent memory specific dax functionality to be pushed into
  libnvdimm and the pmem driver directly. It also allows dax-specific
  sysfs attributes to be linked to a host device, for example:
  /sys/block/pmem0/dax/write_cache

* Add support for the new NVDIMM platform/firmware mechanisms introduced
  in ACPI 6.2 and UEFI 2.7. This support includes the v1.2 namespace
  label format, extensions to the address-range-scrub command set, new
  error injection commands, and a new BTT (block-translation-table)
  layout. These updates support inter-OS and pre-OS compatibility.

* Fix a 

[GIT PULL] libnvdimm fix for 4.12-rc5

2017-06-10 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive a fix for an oversight spotted by Sasha.

We expanded the device-dax fs type in 4.12 to be a generic provider of
a struct dax_device with an embedded inode. However, Sasha found some
basic negative testing was not run to verify that this fs cleanly
handles being mounted directly. Note that the fresh rebase was done to
remove an unnecessary Cc:  tag, but this commit otherwise had a
build success notification from the 0day robot.

---

The following changes since commit 3c2993b8c6143d8a5793746a54eba8f86f95240f:

  Linux 4.12-rc4 (2017-06-04 16:47:43 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to b9d39d17e4819ca2e69ad1f14acaad12240a1de5:

  device-dax: fix 'dax' device filesystem inode destruction crash (2017-06-09 
08:50:49 -0700)


Dan Williams (1):
  device-dax: fix 'dax' device filesystem inode destruction crash

 drivers/dax/super.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

commit b9d39d17e4819ca2e69ad1f14acaad12240a1de5
Author: Dan Williams 
Date:   Fri Jun 9 08:50:49 2017 -0700

device-dax: fix 'dax' device filesystem inode destruction crash

The inode destruction path for the 'dax' device filesystem incorrectly
assumes that the inode was initialized through 'alloc_dax()'. However,
if someone attempts to directly mount the dax filesystem with 'mount -t
dax dax mnt' that will bypass 'alloc_dax()' and the following failure
signatures may occur as a result:

 kill_dax() must be called before final iput()
 WARNING: CPU: 2 PID: 1188 at drivers/dax/super.c:243 
dax_destroy_inode+0x48/0x50
 RIP: 0010:dax_destroy_inode+0x48/0x50
 Call Trace:
  destroy_inode+0x3b/0x60
  evict+0x139/0x1c0
  iput+0x1f9/0x2d0
  dentry_unlink_inode+0xc3/0x160
  __dentry_kill+0xcf/0x180
  ? dput+0x37/0x3b0
  dput+0x3a3/0x3b0
  do_one_tree+0x36/0x40
  shrink_dcache_for_umount+0x2d/0x90
  generic_shutdown_super+0x1f/0x120
  kill_anon_super+0x12/0x20
  deactivate_locked_super+0x43/0x70
  deactivate_super+0x4e/0x60

 general protection fault:  [#1] SMP DEBUG_PAGEALLOC
 RIP: 0010:kfree+0x6d/0x290
 Call Trace:
  
  dax_i_callback+0x22/0x60
  ? dax_destroy_inode+0x50/0x50
  rcu_process_callbacks+0x298/0x740

 ida_remove called for id=0 which is not allocated.
 WARNING: CPU: 0 PID: 0 at lib/idr.c:383 ida_remove+0x110/0x120
 [..]
 Call Trace:
  
  ida_simple_remove+0x2b/0x50
  ? dax_destroy_inode+0x50/0x50
  dax_i_callback+0x3c/0x60
  rcu_process_callbacks+0x298/0x740

Add missing initialization of the 'struct dax_device' and inode so that
the destruction path does not kfree() or ida_simple_remove()
uninitialized data.

Fixes: 7b6be8444e0f ("dax: refactor dax-fs into a generic provider of 
'struct dax_device' instances")
Reported-by: Sasha Levin 
Signed-off-by: Dan Williams 
---
 drivers/dax/super.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 6ed32aac8bbe..922d0823f8ec 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -210,9 +210,12 @@ EXPORT_SYMBOL_GPL(kill_dax);
 static struct inode *dax_alloc_inode(struct super_block *sb)
 {
struct dax_device *dax_dev;
+   struct inode *inode;
 
dax_dev = kmem_cache_alloc(dax_cache, GFP_KERNEL);
-   return _dev->inode;
+   inode = _dev->inode;
+   inode->i_rdev = 0;
+   return inode;
 }
 
 static struct dax_device *to_dax_dev(struct inode *inode)
@@ -227,7 +230,8 @@ static void dax_i_callback(struct rcu_head *head)
 
kfree(dax_dev->host);
dax_dev->host = NULL;
-   ida_simple_remove(_minor_ida, MINOR(inode->i_rdev));
+   if (inode->i_rdev)
+   ida_simple_remove(_minor_ida, MINOR(inode->i_rdev));
kmem_cache_free(dax_cache, dax_dev);
 }
 
@@ -423,6 +427,7 @@ static void init_once(void *_dax_dev)
struct dax_device *dax_dev = _dax_dev;
struct inode *inode = _dev->inode;
 
+   memset(dax_dev, 0, sizeof(*dax_dev));
inode_init_once(inode);
 }
 
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm fixes for 4.12-rc2

2017-05-19 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-for-next

...to receive a couple compile fixes for 4.12-rc2.

With the removal of the ->direct_access() method from
block_device_operations in favor of a new dax_device + dax_operations
we broke 2 configurations. The CONFIG_BLOCK=n case is fixed by
compiling out the block+dax helpers in the dax core. Configurations
with FS_DAX=n EXT4=y / XFS=y and DAX=m fail due to the helpers the
builtin filesystem needs being in a module, so we stub out the helpers
in the FS_DAX=n case.

The following changes since commit 2ea659a9ef488125eb46da6eb571de5eae5c43f6:

  Linux 4.12-rc1 (2017-05-13 13:19:49 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-for-next

for you to fetch changes up to f5705aa8cfed142d980ecac12bee0d81b756479e:

  dax, xfs, ext4: compile out iomap-dax paths in the FS_DAX=n case (2017-05-13 
17:52:16 -0700)


Dan Williams (2):
  dax: fix false CONFIG_BLOCK dependency
  dax, xfs, ext4: compile out iomap-dax paths in the FS_DAX=n case

 drivers/dax/super.c |  2 ++
 fs/ext2/inode.c |  4 ++--
 fs/ext4/inode.c |  4 ++--
 fs/xfs/xfs_iomap.c  |  4 ++--
 include/linux/dax.h | 34 +++---
 5 files changed, 35 insertions(+), 13 deletions(-)

commit 9d109081c261d87fc84e0cce245796796ae4c460
Author: Dan Williams 
Date:   Sat May 13 16:18:21 2017 -0700

dax: fix false CONFIG_BLOCK dependency

In the BLOCK=n case the dax core does not need to / must not emit the
block-device-dax helpers. Otherwise it leads to compile errors.

Cc: Arnd Bergmann 
Reported-by: Fabian Frederick 
Fixes: ef51042472f5 ("block, dax: move 'select DAX' from BLOCK to FS_DAX")
Signed-off-by: Dan Williams 

commit f5705aa8cfed142d980ecac12bee0d81b756479e
Author: Dan Williams 
Date:   Sat May 13 16:31:05 2017 -0700

dax, xfs, ext4: compile out iomap-dax paths in the FS_DAX=n case

Tetsuo reports:

  fs/built-in.o: In function `xfs_file_iomap_end':
  xfs_iomap.c:(.text+0xe0ef9): undefined reference to `put_dax'
  fs/built-in.o: In function `xfs_file_iomap_begin':
  xfs_iomap.c:(.text+0xe1a7f): undefined reference to `dax_get_by_host'
  make: *** [vmlinux] Error 1
  $ grep DAX .config
  CONFIG_DAX=m
  # CONFIG_DEV_DAX is not set
  # CONFIG_FS_DAX is not set

When FS_DAX=n we can/must throw away the dax code in filesystems.
Implement 'fs_' versions of dax_get_by_host() and put_dax() that are
nops in the FS_DAX=n case.

Cc: 
Cc: 
Cc: Jan Kara 
Cc: "Theodore Ts'o" 
Cc: "Darrick J. Wong" 
Cc: Ross Zwisler 
Tested-by: Tony Luck 
Fixes: ef51042472f5 ("block, dax: move 'select DAX' from BLOCK to FS_DAX")
Reported-by: Tetsuo Handa 
Signed-off-by: Dan Williams 

diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index ebf43f531ada..6ed32aac8bbe 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -44,6 +44,7 @@ void dax_read_unlock(int id)
 }
 EXPORT_SYMBOL_GPL(dax_read_unlock);
 
+#ifdef CONFIG_BLOCK
 int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size,
pgoff_t *pgoff)
 {
@@ -112,6 +113,7 @@ int __bdev_dax_supported(struct super_block *sb, int 
blocksize)
return 0;
 }
 EXPORT_SYMBOL_GPL(__bdev_dax_supported);
+#endif
 
 /**
  * struct dax_device - anchor object for dax services
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 26d77f9f8c12..2dcbd5698884 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -817,7 +817,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t 
offset, loff_t length,
iomap->bdev = bdev;
iomap->offset = (u64)first_block << blkbits;
if (blk_queue_dax(bdev->bd_queue))
-   iomap->dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
+   iomap->dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name);
else
iomap->dax_dev = NULL;
 
@@ -841,7 +841,7 @@ static int
 ext2_iomap_end(struct inode *inode, loff_t offset, loff_t length,
ssize_t written, unsigned flags, struct iomap *iomap)
 {
-   put_dax(iomap->dax_dev);
+   fs_put_dax(iomap->dax_dev);
if (iomap->type == IOMAP_MAPPED &&
written < length &&
(flags & IOMAP_WRITE))
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 5834c4d76be8..1bd0bfa547f6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3412,7 +3412,7 @@ static int 

[GIT PULL] libnvdimm fixes for 4.12-rc1

2017-05-12 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive some incremental fixes and a small feature addition
relative to the libnvdimm 4.12 pull request.

* Geert noticed that tinyconfig was bloated by BLOCK selecting DAX. The
size regression is fixed by moving all dax helpers into the dax-core
and only specifying "select DAX" for FS_DAX and dax-capable drivers. He
also asked for clarification of the NR_DEV_DAX config option which, on
closer look, does not need to be a config option at all. Mike also
throws in a DEV_DAX_PMEM fixup for good measure.

* Ben's attention to detail on -stable patch submissions caught a case
where the recent fixes to arch_copy_from_iter_pmem() missed a condition
where we strand dirty data in the cache. This is tagged for -stable and
will also be included in the rework of the pmem api to a proposed
{memcpy,copy_user}_flushcache() interface for 4.13.

* Vishal adds a feature that missed the initial pull due to pending
review feedback. It allows the kernel to clear media errors when
initializing a BTT (atomic sector update driver) instance on a pmem
namespace.

* Ross noticed that the dax_device + dax_operations conversion broke
__dax_zero_page_range(). The nvdimm unit tests fail to check this path,
but xfstests immediately trips over it. No excuse for missing this
before submitting the 4.12 pull request.

These all pass the nvdimm unit tests and an xfstests spot check. The
set has received a build success notification from the kbuild robot.

---

The following changes since commit 736163671bcb163fc82600b46c83dfa89d532d95:

  Merge branch 'for-4.12/dax' into libnvdimm-for-next (2017-05-04 23:38:43 
-0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to e84b83b9ee2187817cf895471675f1ccdf64cd53:

  filesystem-dax: fix broken __dax_zero_page_range() conversion (2017-05-10 
21:46:55 -0700)


Ben Hutchings (1):
  x86, pmem: Fix cache flushing for iovec write < 8 bytes

Dan Williams (3):
  block, dax: move "select DAX" from BLOCK to FS_DAX
  device-dax: kill NR_DEV_DAX
  filesystem-dax: fix broken __dax_zero_page_range() conversion

Mike Galbraith (1):
  device-dax: Tell kbuild DEV_DAX_PMEM depends on DEV_DAX

Vishal Verma (2):
  libnvdimm: add an atomic vs process context flag to rw_bytes
  libnvdimm, btt: ensure that initializing metadata clears poison

 arch/x86/include/asm/pmem.h |   2 +-
 block/Kconfig   |   1 -
 drivers/dax/Kconfig |   7 +--
 drivers/dax/super.c |  81 +++---
 drivers/nvdimm/blk.c|   3 +-
 drivers/nvdimm/btt.c| 119 ++--
 drivers/nvdimm/btt_devs.c   |   2 +-
 drivers/nvdimm/claim.c  |   6 ++-
 drivers/nvdimm/nd.h |   1 +
 drivers/nvdimm/pfn_devs.c   |   4 +-
 fs/Kconfig  |   1 +
 fs/block_dev.c  |  66 
 fs/dax.c|   4 +-
 fs/ext2/super.c |   1 +
 fs/ext4/super.c |   1 +
 fs/xfs/xfs_super.c  |   1 +
 include/linux/blkdev.h  |   2 -
 include/linux/dax.h |  30 ++-
 include/linux/nd.h  |  12 +++--
 19 files changed, 208 insertions(+), 136 deletions(-)

commit 74d71a01abef37f71d914f2105a4cb8712a2beb8
Author: Mike Galbraith 
Date:   Sat May 6 06:14:43 2017 +0200

device-dax: Tell kbuild DEV_DAX_PMEM depends on DEV_DAX

ERROR: "devm_create_dev_dax" [drivers/dax/dax_pmem.ko] undefined!
ERROR: "alloc_dax_region" [drivers/dax/dax_pmem.ko] undefined!
ERROR: "dax_region_put" [drivers/dax/dax_pmem.ko] undefined!

Signed-off-by: Mike Galbraith 
Signed-off-by: Dan Williams 

commit ef51042472f55b325fd7f2b26a2e29fd89757234
Author: Dan Williams 
Date:   Mon May 8 10:55:27 2017 -0700

block, dax: move "select DAX" from BLOCK to FS_DAX

For configurations that do not enable DAX filesystems or drivers, do not
require the DAX core to be built.

Given that the 'direct_access' method has been removed from
'block_device_operations', we can also go ahead and remove the
block-related dax helper functions from fs/block_dev.c to
drivers/dax/super.c. This keeps dax details out of the block layer and
lets the DAX core be built as a module in the FS_DAX=n case.

Filesystems need to include dax.h to call bdev_dax_supported().

Cc: linux-...@vger.kernel.org
Cc: Jens Axboe 
Cc: "Theodore Ts'o" 
Cc: Matthew Wilcox 
Cc: Alexander Viro 
Cc: "Darrick J. Wong" 
Cc: Ross Zwisler 

[GIT PULL] libnvdimm for 4.12

2017-05-05 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.12

...to receive the libnvdimm update for 4.12. The bulk of this has been
in multiple -next releases. There were a few late breaking fixes and
small features that got added in the last couple days, but the whole
set has received a build success notification from the kbuild robot. 

Another late change that was merged through the x86/mm tree causes a
conflict with this branch. The proposed merge resolution below matches
what Stephen Rothwell came up with as well.

Lastly the default diffstat from git request-pull shows some changes
from Greg's char-misc tree because I based the for-4.12/dax work on the
new cdev_device_add() helper and related fallout in drivers/dax/. A
cleaner diffstat is also included below starting from commit
bfca9acf1a5d "Merge branch 'for-4.11/libnvdimm' into for-4.12/dax".

Please pull, thanks!

diff --cc drivers/nvdimm/pmem.c
index fbc640bf06b0,58db813e7b7b..c544d466ea51
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@@ -232,15 -243,14 +244,19 @@@ static void pmem_release_queue(void *q
blk_cleanup_queue(q);
  }
  
 +static void pmem_freeze_queue(void *q)
 +{
 +  blk_freeze_queue_start(q);
 +}
 +
- static void pmem_release_disk(void *disk)
+ static void pmem_release_disk(void *__pmem)
  {
-   del_gendisk(disk);
-   put_disk(disk);
+   struct pmem_device *pmem = __pmem;
+ 
+   kill_dax(pmem->dax_dev);
+   put_dax(pmem->dax_dev);
+   del_gendisk(pmem->disk);
+   put_disk(pmem->disk);
  }
  
  static int pmem_attach_disk(struct device *dev,
diff --cc fs/dax.c
index 6433650be833,ce9dc9c3e829..43bbd6d1037d
--- a/fs/dax.c
+++ b/fs/dax.c
@@@ -979,24 -956,34 +965,34 @@@ static bool dax_range_is_aligned(struc
return true;
  }
  
- int __dax_zero_page_range(struct block_device *bdev, sector_t sector,
-   unsigned int offset, unsigned int length)
+ int __dax_zero_page_range(struct block_device *bdev,
+   struct dax_device *dax_dev, sector_t sector,
+   unsigned int offset, unsigned int size)
  {
-   struct blk_dax_ctl dax = {
-   .sector = sector,
-   .size   = PAGE_SIZE,
-   };
- 
-   if (dax_range_is_aligned(bdev, offset, length)) {
-   sector_t start_sector = dax.sector + (offset >> 9);
+   if (dax_range_is_aligned(bdev, offset, size)) {
+   sector_t start_sector = sector + (offset >> 9);
  
return blkdev_issue_zeroout(bdev, start_sector,
-   length >> 9, GFP_NOFS, 0);
 -  size >> 9, GFP_NOFS, true);
++  size >> 9, GFP_NOFS, 0);
} else {
-   if (dax_map_atomic(bdev, ) < 0)
-   return PTR_ERR(dax.addr);
-   clear_pmem(dax.addr + offset, length);
-   dax_unmap_atomic(bdev, );
+   pgoff_t pgoff;
+   long rc, id;
+   void *kaddr;
+   pfn_t pfn;
+ 
+   rc = bdev_dax_pgoff(bdev, sector, size, );
+   if (rc)
+   return rc;
+ 
+   id = dax_read_lock();
+   rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), ,
+   );
+   if (rc < 0) {
+   dax_read_unlock(id);
+   return rc;
+   }
+   clear_pmem(kaddr + offset, size);
+   dax_read_unlock(id);
}
return 0;
  }


The following changes since commit 11e63f6d920d6f2dfd3cd421e939a4aec9a58dcd:

  x86, pmem: fix broken __copy_user_nocache cache-bypass assumptions 
(2017-04-12 13:45:18 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm 
tags/libnvdimm-for-4.12

for you to fetch changes up to 736163671bcb163fc82600b46c83dfa89d532d95:

  Merge branch 'for-4.12/dax' into libnvdimm-for-next (2017-05-04 23:38:43 
-0700)


libnvdimm for 4.12

* Region media error reporting: A libnvdimm region device is the parent
to one or more namespaces. To date, media errors have been reported via
the "badblocks" attribute attached to pmem block devices for namespaces
in "raw" or "memory" mode. Given that namespaces can be in "device-dax"
or "btt-sector" mode this new interface reports media errors
generically, i.e. independent of namespace modes or state. This
subsequently allows userspace tooling to craft "ACPI 6.1 Section
9.20.7.6 Function Index 4 - Clear Uncorrectable Error" requests and
submit them via the ioctl path for NVDIMM root bus devices.

* Introduce 'struct dax_device' and 'struct dax_operations': Prompted by
a request from Linus and feedback from Christoph this allows for dax
capable drivers to publish their own custom dax operations. This fixes
the 

[GIT PULL] libnvdimm fixes for 4.9-final

2016-12-09 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive several fixes to the DSM (ACPI device specific method)
marshaling implementation.

I consider these urgent enough to send for 4.9 consideration since they
fix the kernel's handling of ARS (Address Range Scrub) commands.
Especially for platforms without machine-check-recovery capabilities,
successful execution of ARS commands enables the platform to
potentially break out of an infinite reboot problem if a media error is
present in the boot path. There is also a one line fix for a device-dax 
read-only mapping regression.

"acpi, nfit: fix extended status translations for ACPI DSMs" and
"device-dax: fix private mapping restriction, permit read-only" are
true regression fixes for changes introduced this cycle. "acpi, nfit,
libnvdimm: fix / harden ars_status output length handling" fixes the
kernel's handling of zero-length results, this never would have worked
in the past, but we only just recently discovered a BIOS implementation
that emits this arguably spec non-compliant result. The remaining two
commits are additional fall out from thinking through the implications
of a zero / truncated length result of the ARS Status command.

In order to mitigate the risk that these changes introduce yet more
regressions they are backstopped by a new unit test in
"tools/testing/nvdimm: unit test acpi_nfit_ctl()" that mocks inputs to
acpi_nfit_ctl().

Please consider pulling for 4.9, it has appeared in a -next release
with no reported issues.

The following changes since commit 3e5de27e940d00d8d504dfb96625fb654f641509:

  Linux 4.9-rc8 (2016-12-04 12:50:51 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 325896ffdf90f7cbd59fb873b7ba20d60d1ddf3c:

  device-dax: fix private mapping restriction, permit read-only (2016-12-06 
17:42:37 -0800)


Dan Williams (5):
  acpi, nfit, libnvdimm: fix / harden ars_status output length handling
  acpi, nfit: validate ars_status output buffer size
  acpi, nfit: fix bus vs dimm confusion in xlat_status
  tools/testing/nvdimm: unit test acpi_nfit_ctl()
  device-dax: fix private mapping restriction, permit read-only

Vishal Verma (1):
  acpi, nfit: fix extended status translations for ACPI DSMs

 drivers/acpi/nfit/core.c  |  55 +---
 drivers/acpi/nfit/nfit.h  |   2 +
 drivers/dax/dax.c |   2 +-
 drivers/nvdimm/bus.c  |  25 +++-
 include/linux/libnvdimm.h |   2 +-
 tools/testing/nvdimm/Kbuild   |   1 +
 tools/testing/nvdimm/test/iomap.c |  23 +++-
 tools/testing/nvdimm/test/nfit.c  | 236 +-
 tools/testing/nvdimm/test/nfit_test.h |   8 +-
 9 files changed, 326 insertions(+), 28 deletions(-)

commit 9a901f5495e26e691c7d0ea7b6057a2f3e6330ed
Author: Vishal Verma 
Date:   Mon Dec 5 17:00:37 2016 -0700

acpi, nfit: fix extended status translations for ACPI DSMs

ACPI DSMs can have an 'extended' status which can be non-zero to convey
additional information about the command. In the xlat_status routine,
where we translate the command statuses, we were returning an error for
a non-zero extended status, even if the primary status indicated success.

Return from each command's 'case' once we have verified both its status
and extend status are good.

Cc: 
Fixes: 11294d63ac91 ("nfit: fail DSMs that return non-zero status by 
default")
Signed-off-by: Vishal Verma 
Signed-off-by: Dan Williams 

commit efda1b5d87cbc3d8816f94a3815b413f1868e10d
Author: Dan Williams 
Date:   Tue Dec 6 09:10:12 2016 -0800

acpi, nfit, libnvdimm: fix / harden ars_status output length handling

Given ambiguities in the ACPI 6.1 definition of the "Output (Size)"
field of the ARS (Address Range Scrub) Status command, a firmware
implementation may in practice return 0, 4, or 8 to indicate that there
is no output payload to process.

The specification states "Size of Output Buffer in bytes, including this
field.". However, 'Output Buffer' is also the name of the entire
payload, and earlier in the specification it states "Max Query ARS
Status Output Buffer Size: Maximum size of buffer (including the Status
and Extended Status fields)".

Without this fix if the BIOS happens to return 0 it causes memory
corruption as evidenced by this result from the acpi_nfit_ctl() unit
test.

 ars_status: 0002 
 BUG: stack guard page was hit at c9000175 (stack is 
c9000174c000..c9000174)
 

[GIT PULL] libnvdimm fixes for 4.9-rc7

2016-11-26 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive:

* Fix a crash that occurs at driver initialization if the memory region
is already busy (request_mem_region() fails).

* Fix a vma validation check that mistakenly allows a private device-
dax mapping to be established.  Device-dax explicitly forbids private
mappings so it can guarantee a given fault granularity and backing
memory type.

Both of these fixes have soaked in -next and are tagged for -stable.

---

The following changes since commit ed99d3673e082b78b20208f346d2cd375483a779:

  Merge branch 'libnvdimm-fixes' of 
git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm (2016-10-28 
11:47:45 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 4cb19355ea19995941ccaad115dbfac6b75215ca:

  device-dax: fail all private mapping attempts (2016-11-16 09:00:38 -0800)


Dan Williams (2):
  device-dax: check devm_nsio_enable() return value
  device-dax: fail all private mapping attempts

 drivers/dax/dax.c  | 4 ++--
 drivers/dax/pmem.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[GIT PULL] libnvdimm fixes for 4.9-rc3

2016-10-28 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive:

A compilation fix, a NULL de-reference found by static analysis, a
misuse of the percpu_ref_exit() (tagged for -stable), and notification
of failed attempts to clear media errors.

These patches have received a build success notification from the 0day-
kbuild-robot and appeared in next-20161028.

---

The following changes since commit 1001354ca34179f3db924eb66672442a173147dc:

  Linux 4.9-rc1 (2016-10-15 12:17:50 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 52e73eb2872c9af6f382b2b22954ca8214397a4e:

  device-dax: fix percpu_ref_exit ordering (2016-10-27 17:04:05 -0700)


Arnd Bergmann (1):
  nvdimm: make CONFIG_NVDIMM_DAX 'bool'

Dan Carpenter (1):
  libnvdimm, namespace: potential NULL deref on allocation error

Dan Williams (1):
  device-dax: fix percpu_ref_exit ordering

Toshi Kani (1):
  pmem: report error on clear poison failure

 drivers/dax/Kconfig |  2 +-
 drivers/dax/pmem.c  |  2 +-
 drivers/nvdimm/Kconfig  |  2 +-
 drivers/nvdimm/namespace_devs.c | 14 --
 drivers/nvdimm/pmem.c   |  8 ++--
 5 files changed, 17 insertions(+), 11 deletions(-)

---

commit 75d29713b792da4782cadfaa87e802183440694e
Author: Dan Carpenter 
Date:   Wed Oct 12 09:34:29 2016 +0300

libnvdimm, namespace: potential NULL deref on allocation error

If the kcalloc() fails then "devs" can be NULL and we dereference it
checking "devs[i]".

Fixes: 1b40e09a1232 ('libnvdimm: blk labels and namespace instantiation')
Signed-off-by: Dan Carpenter 
Signed-off-by: Dan Williams 

commit 3115bb02b5c23d960df5f1bf551ec394a9bb10ec
Author: Toshi Kani 
Date:   Thu Oct 13 09:54:21 2016 -0600

pmem: report error on clear poison failure

ACPI Clear Uncorrectable Error DSM function may fail or may be
unsupported on a platform.  pmem_clear_poison() returns without clearing
badblocks in such cases.  This failure is detected at the next read
(-EIO).

This behavior can lead to an issue when user keeps writing but does not
read immediately.  For instance, flight recorder file may be only read
when it is necessary for troubleshooting.

Change pmem_do_bvec() and pmem_clear_poison() to return -EIO so that
filesystem can log an error message on a write error.

Cc: Vishal Verma 
Signed-off-by: Toshi Kani 
Signed-off-by: Dan Williams 

commit 867dfe342118b1ea0256a85f7c0d9ceb0ead032a
Author: Arnd Bergmann 
Date:   Tue Oct 25 17:52:04 2016 +0200

nvdimm: make CONFIG_NVDIMM_DAX 'bool'

A bugfix just tried to address a randconfig build problem and introduced
a variant of the same problem: with CONFIG_LIBNVDIMM=y and
CONFIG_NVDIMM_DAX=m, the nvdimm module now fails to link:

drivers/nvdimm/built-in.o: In function `to_nd_device_type':
bus.c:(.text+0x1b5d): undefined reference to `is_nd_dax'
drivers/nvdimm/built-in.o: In function 
`nd_region_notify_driver_action.constprop.2':
region_devs.c:(.text+0x6b6c): undefined reference to `is_nd_dax'
region_devs.c:(.text+0x6b8c): undefined reference to `to_nd_dax'
drivers/nvdimm/built-in.o: In function `nd_region_probe':
region.c:(.text+0x70f3): undefined reference to `nd_dax_create'
drivers/nvdimm/built-in.o: In function `mode_show':
namespace_devs.c:(.text+0xa196): undefined reference to `is_nd_dax'
drivers/nvdimm/built-in.o: In function `nvdimm_namespace_common_probe':
(.text+0xa55f): undefined reference to `is_nd_dax'
drivers/nvdimm/built-in.o: In function `nvdimm_namespace_common_probe':
(.text+0xa56e): undefined reference to `to_nd_dax'

This reverts the earlier fix, making NVDIMM_DAX a 'bool' option again
as it should be (it gets linked into the libnvdimm module). To fix
the original problem, I'm adding a dependency on LIBNVDIMM to
DEV_DAX_PMEM, which ensures we can't have that one built-in if the
rest is a module.

Fixes: 4e65e9381c7a ("/dev/dax: fix Kconfig dependency build breakage")
Signed-off-by: Arnd Bergmann 
Reviewed-by: Ross Zwisler 
Signed-off-by: Dan Williams 

commit 52e73eb2872c9af6f382b2b22954ca8214397a4e
Author: Dan Williams 
Date:   Thu Oct 27 17:04:05 2016 -0700

device-dax: fix percpu_ref_exit ordering

We need to wait until the percpu_ref is released before exit. Otherwise,
we sometimes lose the race and trigger this new 

[GIT PULL] libnvdimm fixes for 4.8

2016-09-29 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive the following:

- (4) fixes for "flush hint" support.  Flush hints are addresses
advertised by the ACPI 6+ NFIT (NVDIMM Firmware Interface Table) that
when written and fenced guarantee that writes pending in platform write
buffers (outside the cpu) have been flushed to media.  They might also
be used by hypervisors as a trigger condition to flush guest-persistent 
memory ranges to storage.

Fix a potential data corruption issue, a broken definition of the hint
array, a wrong allocation size for the unit test implementation of the
flush hint table, and missing NULL check in an error path.  The unit
test, while it did not prevent these bugs from being merged, at least
triggered occasional crashes in advance of production usages.

- Fix handling of ACPI DSM error status results.  The DSM mechanism
allows communication with platform and memory device firmware.  We
correctly parse known errors, but were silently ignoring others.  Fix
it to consistently fail any command with a non-zero status return that
we otherwise do not interpret / handle.

These changes have a build success notification from the 0day robot and
have appeared in a -next release over the past week.

The following changes since commit 3be7988674ab33565700a37b210f502563d932e6:

  Linux 4.8-rc7 (2016-09-18 17:27:41 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 595c73071e6641e59b83911fbb4026e767471000:

  libnvdimm, region: fix flush hint table thinko (2016-09-24 11:45:38 -0700)


Dan Williams (4):
  tools/testing/nvdimm: fix allocation range for mock flush hint tables
  libnvdimm: fix devm_nvdimm_memremap() error path
  nfit: fail DSMs that return non-zero status by default
  libnvdimm, region: fix flush hint table thinko

Oliver O'Halloran (1):
  nvdimm: fix PHYS_PFN/PFN_PHYS mixup

 drivers/acpi/nfit/core.c | 48 +++-
 drivers/nvdimm/core.c|  8 ++-
 drivers/nvdimm/nd.h  | 22 --
 drivers/nvdimm/region_devs.c | 22 ++
 tools/testing/nvdimm/test/nfit.c |  3 ++-
 5 files changed, 70 insertions(+), 33 deletions(-)


commit 480b6837aa579991c6acc113bccf838e6a90843c
Author: Oliver O'Halloran 
Date:   Mon Sep 19 20:19:00 2016 +1000

nvdimm: fix PHYS_PFN/PFN_PHYS mixup

nd_activate_region() iomaps any hint addresses required when activating
a region. To prevent duplicate mappings it checks the PFN of the hint to
be mapped against the PFNs of the already mapped hints. Unfortunately it
doesn't convert the PFN back into a physical address before passing it
to devm_nvdimm_ioremap(). Instead it applies PHYS_PFN a second time
which ends about as well as you would imagine.

Signed-off-by: Oliver O'Halloran 
Signed-off-by: Dan Williams 

commit 9d15ce9caaf9ecbec74e3be156a4a57451ed16c2
Author: Dan Williams 
Date:   Mon Sep 19 13:49:48 2016 -0700

tools/testing/nvdimm: fix allocation range for mock flush hint tables

Commit 480b6837aa57 "nvdimm: fix PHYS_PFN/PFN_PHYS mixup" identified
that we were passing an invalid address to devm_nvdimm_ioremap(). With
that fixed it exposed a bug in the memory reservation size for flush
hint tables.  Since we map a full page we need to mock a full page of
memory to back the flush hint table entries.

Cc: Oliver O'Halloran 
Signed-off-by: Dan Williams 

commit ecfb6d8a041cc2ca80bc69ffc20c00067d190df5
Author: Dan Williams 
Date:   Wed Sep 21 09:22:33 2016 -0700

libnvdimm: fix devm_nvdimm_memremap() error path

The internal alloc_nvdimm_map() helper might fail, particularly if the
memory region is already busy.  Report request_mem_region() failures and
check for the failure.

Reported-by: Ryan Chen 
Signed-off-by: Dan Williams 

commit 11294d63ac915230a36b0603c62134ef7b173d0a
Author: Dan Williams 
Date:   Wed Sep 21 09:21:26 2016 -0700

nfit: fail DSMs that return non-zero status by default

For the DSMs where the kernel knows the format of the output buffer and
originates those DSMs from within the kernel, return -EIO for any
non-zero status.  If the BIOS is indicating a status that we do not know
how to handle, fail the DSM.

Cc: 
Signed-off-by: Dan Williams 

commit 595c73071e6641e59b83911fbb4026e767471000
Author: Dan Williams 
Date:   Fri Sep 23 17:53:52 

[GIT PULL] libnvdimm fixes for 4.8-rc6

2016-09-10 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive nvdimm fixes for v4.8, two of them are tagged for
-stable:

- Fix devm_memremap_pages() to use track_pfn_insert(). Otherwise, DAX
pmd mappings end up with an uncached pgprot, and unusable performance
for the device-dax interface.  The device-dax interface appeared in 4.7
so this is tagged for -stable.

- Fix a couple VM_BUG_ON() checks in the show_smaps() path to
understand DAX pmd entries.  This fix is tagged for -stable.

- Fix a mis-merge of the nfit machine-check handler to flip the
polarity of an if() to match the final version of the patch that Vishal
sent for 4.8-rc1.  Without this the nfit machine check handler never
detects / inserts new 'badblocks' entries which applications use to
identify lost portions of files.

- For test purposes, fix the nvdimm_clear_poison() path to operate on
legacy / simulated nvdimm memory ranges.  Without this fix a test can
set badblocks, but never clear them on these ranges.

- Fix the range checking done by dax_dev_pmd_fault().  This is not
tagged for -stable since this problem is mitigated by specifying
aligned resources at device-dax setup time.

These patches have appeared in a next release over the past week.  The
recent rebase you can see in the timestamps was to drop an invalid fix
as identified by the updated device-dax unit tests [1].  The -mm
touches have an ack from Andrew.

[1]: "[ndctl PATCH 0/3] device-dax test for recent kernel bugs"
https://lists.01.org/pipermail/linux-nvdimm/2016-September/006855.html

The following changes since commit 3eab887a55424fc2c27553b7bfe32330df83f7b8:

  Linux 4.8-rc4 (2016-08-28 15:04:33 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 1e8b8d9619f9476e94f32eb20cab000d50d236aa:

  libnvdimm: allow legacy (e820) pmem region to clear bad blocks (2016-09-09 
17:34:46 -0700)


Dan Williams (3):
  dax: fix mapping size check
  mm: fix show_smap() for zone_device-pmd ranges
  mm: fix cache mode of dax pmd mappings

Dave Jiang (1):
  libnvdimm: allow legacy (e820) pmem region to clear bad blocks

Vishal Verma (1):
  nfit, mce: Fix SPA matching logic in MCE handler

 arch/x86/mm/pat.c   | 17 ++---
 drivers/acpi/nfit/mce.c |  2 +-
 drivers/dax/dax.c   |  2 +-
 drivers/nvdimm/bus.c|  6 +-
 fs/proc/task_mmu.c  |  2 ++
 kernel/memremap.c   |  9 +
 mm/huge_memory.c|  4 ++--
 7 files changed, 30 insertions(+), 12 deletions(-)

commit 4c3cb6e9a9d94d1553807854a565cd27ff4c22aa
Author: Dan Williams 
Date:   Sat Sep 3 10:36:00 2016 -0700

dax: fix mapping size check

pgoff_to_phys() validates that both the starting address and the length
of the mapping against the resource list.  We need to check for a
mapping size of PMD_SIZE not PAGE_SIZE in the pmd fault path.

Signed-off-by: Dan Williams 

commit ca120cf688874f4423e579e7cc5ddf7244aeca45
Author: Dan Williams 
Date:   Sat Sep 3 10:38:03 2016 -0700

mm: fix show_smap() for zone_device-pmd ranges

Attempting to dump /proc//smaps for a process with pmd dax mappings
currently results in the following VM_BUG_ONs:

 kernel BUG at mm/huge_memory.c:1105!
 task: 88045f16b140 task.stack: 88045be14000
 RIP: 0010:[]  [] 
follow_trans_huge_pmd+0x2cb/0x340
 [..]
 Call Trace:
  [] smaps_pte_range+0xa0/0x4b0
  [] ? vsnprintf+0x255/0x4c0
  [] __walk_page_range+0x1fe/0x4d0
  [] walk_page_vma+0x62/0x80
  [] show_smap+0xa6/0x2b0

 kernel BUG at fs/proc/task_mmu.c:585!
 RIP: 0010:[]  [] 
smaps_pte_range+0x499/0x4b0
 Call Trace:
  [] ? vsnprintf+0x255/0x4c0
  [] __walk_page_range+0x1fe/0x4d0
  [] walk_page_vma+0x62/0x80
  [] show_smap+0xa6/0x2b0

These locations are sanity checking page flags that must be set for an
anonymous transparent huge page, but are not set for the zone_device
pages associated with dax mappings.

Cc: Ross Zwisler 
Cc: Kirill A. Shutemov 
Acked-by: Andrew Morton 
Signed-off-by: Dan Williams 

commit 9049771f7d5490a302589976984810064c83ab40
Author: Dan Williams 
Date:   Wed Sep 7 08:51:21 2016 -0700

mm: fix cache mode of dax pmd mappings

track_pfn_insert() in vmf_insert_pfn_pmd() is marking dax mappings as
uncacheable rendering them impractical for application usage.  DAX-pte
mappings are cached and the goal of establishing DAX-pmd mappings is to
attain more performance, not dramatically less (3 orders of magnitude).


[GIT PULL] libnvdimm regression fix for 4.7-final

2016-07-22 Thread Williams, Dan J
Hi Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive a regression fix for a problem that was introduced in
v4.7-rc6.

In 4.7-rc1 we introduced auto-probing for the ACPI DSM (device-
specific-method) format that the platform firmware implements for
nvdimm devices. We initially fixed a regression in probing the QEMU DSM
implementation by making acpi_check_dsm() tolerant of the way QEMU
reports the "0 DSMs supported" condition. However, that broke HPE
platforms since that tolerance caused the driver to mistakenly match
the 1-zero-byte response those platforms give to "unknown" commands.
Instead, we simply make the driver tolerant of not finding any
supported DSMs.  This has been tested to work with both QEMU and HPE
platforms.

This commit has appeared in a -next release with no reported issues.

The following changes since commit a99cde438de0c4c0cecc1d1af1a55a75b10bfdef:

  Linux 4.7-rc6 (2016-07-03 23:01:00 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to a72255983f12f31f0c8d8275fb1a781546cfacb7:

  nfit: make DIMM DSMs optional (2016-07-19 12:32:39 -0700)


Dan Williams (1):
  nfit: make DIMM DSMs optional

 drivers/acpi/nfit.c  | 11 ++-
 drivers/acpi/utils.c |  6 +++---
 2 files changed, 9 insertions(+), 8 deletions(-)

commit a72255983f12f31f0c8d8275fb1a781546cfacb7
Author: Dan Williams 
Date:   Tue Jul 19 12:32:39 2016 -0700

nfit: make DIMM DSMs optional

Commit 4995734e973a "acpi, nfit: fix acpi_check_dsm() vs zero functions
implemented" attempted to fix a QEMU regression by supporting its usage
of a zero-mask as a valid response to a DSM-family probe request.
However, this behavior breaks HP platforms that return a zero-mask by
default causing the probe to misidentify the DSM-family.

Instead, the QEMU regression can be fixed by simply not requiring the DSM
family to be identified.

This effectively reverts commit 4995734e973a, and removes the DSM
requirement from the init path.

Cc: "Rafael J. Wysocki" 
Cc: Xiao Guangrong 
Cc: Linda Knippers 
Fixes: 4995734e973a ("acpi, nfit: fix acpi_check_dsm() vs zero functions 
implemented")
Reported-by: Jerry Hoemann 
Tested-by: Jerry Hoemann 
Signed-off-by: Dan Williams 

diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index ac6ddcc080d4..1f0e06065ae6 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -1131,11 +1131,11 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc 
*acpi_desc,
 
    /*
     * Until standardization materializes we need to consider up to 3
-    * different command sets.  Note, that checking for zero functions
-    * tells us if any commands might be reachable through this uuid.
+    * different command sets.  Note, that checking for function0 (bit0)
+    * tells us if any commands are reachable through this uuid.
     */
    for (i = NVDIMM_FAMILY_INTEL; i <= NVDIMM_FAMILY_HPE2; i++)
-   if (acpi_check_dsm(adev_dimm->handle, to_nfit_uuid(i), 1, 0))
+   if (acpi_check_dsm(adev_dimm->handle, to_nfit_uuid(i), 1, 1))
    break;
 
    /* limit the supported commands to those that are publicly documented */
@@ -1151,9 +1151,10 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc 
*acpi_desc,
    if (disable_vendor_specific)
    dsm_mask &= ~(1 << 8);
    } else {
-   dev_err(dev, "unknown dimm command family\n");
+   dev_dbg(dev, "unknown dimm command family\n");
    nfit_mem->family = -1;
-   return force_enable_dimms ? 0 : -ENODEV;
+   /* DSMs are optional, continue loading the driver... */
+   return 0;
    }
 
    uuid = to_nfit_uuid(nfit_mem->family);
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index b4de130f2d57..22c09952e177 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -680,6 +680,9 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, u64 
rev, u64 funcs)
    u64 mask = 0;
    union acpi_object *obj;
 
+   if (funcs == 0)
+   return false;
+
    obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL);
    if (!obj)
    return false;
@@ -692,9 +695,6 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, u64 
rev, u64 funcs)
    mask |= (((u64)obj->buffer.pointer[i]) << (i * 8));
    ACPI_FREE(obj);
 
-   if (funcs == 0)
-   return true;
-
    /*
     * Bit 0 indicates whether there's support 

[GIT PULL] ->driverfs_dev removal for 4.8

2016-07-08 Thread Williams, Dan J
Hi Jens, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm for-4.8/block

...to receive:

The removal of ->driverfs_dev in favor of just passing the parent
device in as a parameter to add_disk().  See below, it has received a
"Reviewed-by" from Christoph, Bart, and Johannes.

It is also a pre-requisite for Fam Zheng's work to cleanup gendisk
uevents vs attribute visibility [1].  We would extend device_add_disk()
to take an attribute_group list.

This is based off a branch of block.git/for-4.8/drivers and has
received a positive build success notification from the kbuild robot
across several configs.

[1]: "gendisk: Generate uevent after attribute available"
http://marc.info/?l=linux-virtualization=146725201522201=2

---

The following changes since commit 1b57e66384e2d21150301e68078526fac5680a16:

  drbd: correctly handle failed crypto_alloc_hash (2016-06-13 21:43:08 -0600)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm for-4.8/block

for you to fetch changes up to 52c44d93c26f5a76068c0a8cc83bb8f56f38043d:

  block: remove ->driverfs_dev (2016-06-27 12:26:08 -0700)


Dan Williams (5):
  block: introduce device_add_disk()
  mmc: move 'parent' tracking to mmc_blk_data
  um: track 'parent' device in a local variable
  block: convert to device_add_disk()
  block: remove ->driverfs_dev

 arch/powerpc/sysdev/axonram.c   |  3 +--
 arch/um/drivers/ubd_kern.c  |  5 +++--
 block/genhd.c   | 18 +-
 drivers/block/cciss.c   |  3 +--
 drivers/block/floppy.c  |  3 +--
 drivers/block/mtip32xx/mtip32xx.c   |  5 ++---
 drivers/block/ps3disk.c |  3 +--
 drivers/block/ps3vram.c |  3 +--
 drivers/block/rsxx/dev.c|  4 +---
 drivers/block/skd_main.c|  8 +++-
 drivers/block/sunvdc.c  |  3 +--
 drivers/block/virtio_blk.c  |  3 +--
 drivers/block/xen-blkfront.c|  3 +--
 drivers/ide/ide-cd.c|  3 +--
 drivers/ide/ide-gd.c|  3 +--
 drivers/memstick/core/ms_block.c|  3 +--
 drivers/memstick/core/mspro_block.c |  3 +--
 drivers/mmc/card/block.c|  5 +++--
 drivers/mtd/mtd_blkdevs.c   |  4 +---
 drivers/nvdimm/blk.c|  3 +--
 drivers/nvdimm/btt.c|  3 +--
 drivers/nvdimm/bus.c|  2 +-
 drivers/nvdimm/pmem.c   |  3 +--
 drivers/nvme/host/core.c|  3 +--
 drivers/s390/block/dasd_genhd.c |  3 +--
 drivers/s390/block/dcssblk.c|  3 +--
 drivers/s390/block/scm_blk.c|  3 +--
 drivers/scsi/sd.c   |  3 +--
 drivers/scsi/sr.c   |  3 +--
 include/linux/genhd.h   |  8 ++--
 30 files changed, 50 insertions(+), 72 deletions(-)


commit e63a46bef01ff3064f44dba145833284fb6adeec
Author: Dan Williams 
Date:   Wed Jun 15 18:17:27 2016 -0700

block: introduce device_add_disk()

In preparation for removing the ->driverfs_dev member of a gendisk, add
an api that takes the parent device as a parameter to add_disk().  For
now this maintains the status quo of WARN()ing on failure, but not
return a error code.

Reviewed-by: Christoph Hellwig 
Reviewed-by: Johannes Thumshirn 
Reviewed-by: Bart Van Assche 
Signed-off-by: Dan Williams 

commit 307d8e6f248558b184a2513593dbbeb08406a4fa
Author: Dan Williams 
Date:   Mon Jun 20 10:40:44 2016 -0700

mmc: move 'parent' tracking to mmc_blk_data

In preparation for the removal of 'driverfs_dev' from 'struct gendisk',
carry this data in mmc_blk_data. It is used for registration of parent
disks and partitions.

Cc: Ulf Hansson 
Cc: Bart Van Assche 
Signed-off-by: Dan Williams 

commit d72a57835c92f6d51863b0ad6d7d45e3859e24d4
Author: Dan Williams 
Date:   Mon Jun 20 10:44:32 2016 -0700

um: track 'parent' device in a local variable

In preparation for the removal of 'driverfs_dev' from 'struct gendisk'
use a local variable to track the parented vs un-parented case in
ubd_disk_register().

Cc: Jeff Dike 
Cc: Richard Weinberger 
Cc: Bart Van Assche 
Signed-off-by: Dan Williams 

commit 0d52c756a665adc032c791307bc55e392b0186b3
Author: Dan Williams 
Date:   Wed Jun 15 19:44:20 2016 -0700

block: convert to device_add_disk()

For block drivers that specify a parent device, convert them to use
device_add_disk().

This conversion was