03 Apr, 2020

2 commits


26 Mar, 2020

1 commit

  • The current codebase makes use of the zero-length array language
    extension to the C90 standard, but the preferred mechanism to declare
    variable-length types such as these ones is a flexible array member[1][2],
    introduced in C99:

    struct foo {
    int stuff;
    struct boo array[];
    };

    By making use of the mechanism above, we will get a compiler warning
    in case the flexible array does not occur last in the structure, which
    will help us prevent some kind of undefined behavior bugs from being
    inadvertently introduced[3] to the codebase from now on.

    Also, notice that, dynamic memory allocations won't be affected by
    this change:

    "Flexible array members have incomplete type, and so the sizeof operator
    may not be applied. As a quirk of the original implementation of
    zero-length arrays, sizeof evaluates to zero."[1]

    This issue was found with the help of Coccinelle.

    [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
    [2] https://github.com/KSPP/linux/issues/21
    [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

    Signed-off-by: Gustavo A. R. Silva
    Link: https://lore.kernel.org/r/20200319195046.GA452@embeddedor.com
    Signed-off-by: Dan Williams

    Gustavo A. R. Silva
     

18 Mar, 2020

1 commit

  • The NDD_ALIASING flag is used to indicate where pmem capacity might
    alias with blk capacity and require labeling. It is also used to
    indicate whether the DIMM supports labeling. Separate this latter
    capability into its own flag so that the NDD_ALIASING flag is scoped to
    true aliased configurations.

    To my knowledge aliased configurations only exist in the ACPI spec,
    there are no known platforms that ship this support in production.

    This clarity allows namespace-capacity alignment constraints around
    interleave-ways to be relaxed.

    Cc: Vishal Verma
    Cc: Oliver O'Halloran
    Reviewed-by: Jeff Moyer
    Reviewed-by: Aneesh Kumar K.V
    Link: https://lore.kernel.org/r/158041477856.3889308.4212605617834097674.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Dan Williams

    Dan Williams
     

29 Feb, 2020

1 commit

  • The 'func' variable can come from the user in the __nd_ioctl(). If it's
    too high then the (1 << func) shift in acpi_nfit_clear_to_send() is
    undefined. In acpi_nfit_ctl() we pass 'func' to test_bit(func, &dsm_mask)
    which could result in an out of bounds access.

    To fix these issues, I introduced the NVDIMM_CMD_MAX (31) define and
    updated nfit_dsm_revid() to use that define as well instead of magic
    numbers.

    Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
    Signed-off-by: Dan Carpenter
    Reviewed-by: Dan Williams
    Link: https://lore.kernel.org/r/20200225161927.hvftuq7kjn547fyj@kili.mountain
    Signed-off-by: Dan Williams

    Dan Carpenter
     

20 Nov, 2019

5 commits

  • A 'struct device_type' instance can carry default attributes for the
    device. Use this facility to remove the export of
    nvdimm_bus_attribute_group and put the responsibility on the core rather
    than leaf implementations to define this attribute.

    Cc: Ira Weiny
    Cc: Michael Ellerman
    Cc: "Oliver O'Halloran"
    Cc: Vishal Verma
    Cc: Aneesh Kumar K.V
    Signed-off-by: Dan Williams
    Reviewed-by: Aneesh Kumar K.V
    Link: https://lore.kernel.org/r/157309903815.1582359.6418211876315050283.stgit@dwillia2-desk3.amr.corp.intel.com

    Dan Williams
     
  • A 'struct device_type' instance can carry default attributes for the
    device. Use this facility to remove the export of
    nvdimm_attribute_group and put the responsibility on the core rather
    than leaf implementations to define this attribute.

    Cc: Ira Weiny
    Cc: Michael Ellerman
    Cc: "Oliver O'Halloran"
    Cc: Vishal Verma
    Cc: Aneesh Kumar K.V
    Signed-off-by: Dan Williams
    Reviewed-by: Aneesh Kumar K.V
    Link: https://lore.kernel.org/r/157309903201.1582359.10966209746585062329.stgit@dwillia2-desk3.amr.corp.intel.com

    Dan Williams
     
  • A 'struct device_type' instance can carry default attributes for the
    device. Use this facility to remove the export of
    nd_mapping_attribute_group and put the responsibility on the core rather
    than leaf implementations to define this attribute.

    Cc: Ira Weiny
    Cc: Michael Ellerman
    Cc: "Oliver O'Halloran"
    Cc: Vishal Verma
    Cc: Aneesh Kumar K.V
    Signed-off-by: Dan Williams
    Reviewed-by: Aneesh Kumar K.V
    Link: https://lore.kernel.org/r/157309902686.1582359.6749533709859492704.stgit@dwillia2-desk3.amr.corp.intel.com

    Dan Williams
     
  • A 'struct device_type' instance can carry default attributes for the
    device. Use this facility to remove the export of
    nd_region_attribute_group and put the responsibility on the core rather
    than leaf implementations to define this attribute.

    Cc: Ira Weiny
    Cc: Michael Ellerman
    Cc: "Oliver O'Halloran"
    Cc: Vishal Verma
    Cc: Aneesh Kumar K.V
    Signed-off-by: Dan Williams
    Reviewed-by: Aneesh Kumar K.V
    Link: https://lore.kernel.org/r/157309902169.1582359.16828508538444551337.stgit@dwillia2-desk3.amr.corp.intel.com

    Dan Williams
     
  • A 'struct device_type' instance can carry default attributes for the
    device. Use this facility to remove the export of
    nd_numa_attribute_group and put the responsibility on the core rather
    than leaf implementations to define this attribute.

    Cc: Ira Weiny
    Cc: Michael Ellerman
    Cc: "Oliver O'Halloran"
    Cc: Vishal Verma
    Cc: Aneesh Kumar K.V
    Reviewed-by: Aneesh Kumar K.V
    Link: https://lore.kernel.org/r/157401269537.43284.14411189404186877352.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Dan Williams

    Dan Williams
     

18 Nov, 2019

1 commit

  • A 'struct device_type' instance can carry default attributes for the
    device. Use this facility to remove the export of
    nd_device_attribute_group and put the responsibility on the core rather
    than leaf implementations to define this attribute.

    For regions this creates a new nd_region_attribute_groups[] added to the
    per-region device-type instances.

    Cc: Ira Weiny
    Cc: Michael Ellerman
    Cc: "Oliver O'Halloran"
    Cc: Vishal Verma
    Cc: Aneesh Kumar K.V
    Reviewed-by: Aneesh Kumar K.V
    Link: https://lore.kernel.org/r/157309901138.1582359.12909354140826530394.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Dan Williams

    Dan Williams
     

22 Oct, 2019

1 commit

  • We change the locking in this function and forgot to update this error
    path so we are accidentally still holding the "dev->lockdep_mutex".

    Fixes: 87a30e1f05d7 ("driver-core, libnvdimm: Let device subsystems add local lockdep coverage")
    Signed-off-by: Dan Carpenter
    Reviewed-by: Ira Weiny
    Acked-by: Dan Williams
    Cc: 5.3+ # 5.3+
    Signed-off-by: Rafael J. Wysocki

    Dan Carpenter
     

30 Aug, 2019

1 commit

  • In the process of debugging a system with an NVDIMM that was failing to
    unlock it was found that the kernel is reporting 'locked' while the DIMM
    security interface is 'frozen'. Unfortunately the security state is
    tracked internally as an enum which prevents it from communicating the
    difference between 'locked' and 'locked + frozen'. It follows that the
    enum also prevents the kernel from communicating 'unlocked + frozen'
    which would be useful for debugging why security operations like 'change
    passphrase' are disabled.

    Ditch the security state enum for a set of flags and introduce a new
    sysfs attribute explicitly for the 'frozen' state. The regression risk
    is low because the 'frozen' state was already blocked behind the
    'locked' state, but will need to revisit if there were cases where
    applications need 'frozen' to show up in the primary 'security'
    attribute. The expectation is that communicating 'frozen' is mostly a
    helper for debug and status monitoring.

    Reviewed-by: Dave Jiang
    Reported-by: Jeff Moyer
    Reviewed-by: Jeff Moyer
    Link: https://lore.kernel.org/r/156686729474.184120.5835135644278860826.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Dan Williams

    Dan Williams
     

27 Jul, 2019

1 commit

  • Pull libnvdimm fixes from Dan Williams:
    "A collection of locking and async operations fixes for v5.3-rc2. These
    had been soaking in a branch targeting the merge window, but missed
    due to a regression hunt. This fixed up version has otherwise been in
    -next this past week with no reported issues.

    In order to gain confidence in the locking changes the pull also
    includes a debug / instrumentation patch to enable lockdep coverage
    for libnvdimm subsystem operations that depend on the device_lock for
    exclusion. As mentioned in the changelog it is a hack, but it works
    and documents the locking expectations of the sub-system in a way that
    others can use lockdep to verify. The driver core touches got an ack
    from Greg.

    Summary:

    - Fix duplicate device_unregister() calls (multiple threads competing
    to do unregister work when scheduling device removal from a sysfs
    attribute of the self-same device).

    - Fix badblocks registration order bug. Ensure region badblocks are
    initialized in advance of namespace registration.

    - Fix a deadlock between the bus lock and probe operations.

    - Export device-core infrastructure to coordinate async operations
    via the device ->dead state.

    - Add device-core infrastructure to validate device_lock() usage with
    lockdep"

    * tag 'libnvdimm-fixes-5.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
    driver-core, libnvdimm: Let device subsystems add local lockdep coverage
    libnvdimm/bus: Fix wait_nvdimm_bus_probe_idle() ABBA deadlock
    libnvdimm/bus: Stop holding nvdimm_bus_list_mutex over __nd_ioctl()
    libnvdimm/bus: Prepare the nd_ioctl() path to be re-entrant
    libnvdimm/region: Register badblocks before namespaces
    libnvdimm/bus: Prevent duplicate device_unregister() calls
    drivers/base: Introduce kill_device()

    Linus Torvalds
     

19 Jul, 2019

1 commit

  • For good reason, the standard device_lock() is marked
    lockdep_set_novalidate_class() because there is simply no sane way to
    describe the myriad ways the device_lock() ordered with other locks.
    However, that leaves subsystems that know their own local device_lock()
    ordering rules to find lock ordering mistakes manually. Instead,
    introduce an optional / additional lockdep-enabled lock that a subsystem
    can acquire in all the same paths that the device_lock() is acquired.

    A conversion of the NFIT driver and NVDIMM subsystem to a
    lockdep-validate device_lock() scheme is included. The
    debug_nvdimm_lock() implementation implements the correct lock-class and
    stacking order for the libnvdimm device topology hierarchy.

    Yes, this is a hack, but hopefully it is a useful hack for other
    subsystems device_lock() debug sessions. Quoting Greg:

    "Yeah, it feels a bit hacky but it's really up to a subsystem to mess up
    using it as much as anything else, so user beware :)

    I don't object to it if it makes things easier for you to debug."

    Cc: Ingo Molnar
    Cc: Ira Weiny
    Cc: Will Deacon
    Cc: Dave Jiang
    Cc: Keith Busch
    Cc: Peter Zijlstra
    Cc: Vishal Verma
    Cc: "Rafael J. Wysocki"
    Cc: Greg Kroah-Hartman
    Signed-off-by: Dan Williams
    Acked-by: Greg Kroah-Hartman
    Reviewed-by: Ira Weiny
    Link: https://lore.kernel.org/r/156341210661.292348.7014034644265455704.stgit@dwillia2-desk3.amr.corp.intel.com

    Dan Williams
     

06 Jul, 2019

1 commit

  • This patch adds functionality to perform flush from guest
    to host over VIRTIO. We are registering a callback based
    on 'nd_region' type. virtio_pmem driver requires this special
    flush function. For rest of the region types we are registering
    existing flush function. Report error returned by host fsync
    failure to userspace.

    Signed-off-by: Pankaj Gupta
    Signed-off-by: Dan Williams

    Pankaj Gupta
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of version 2 of the gnu general public license as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 64 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Alexios Zavras
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190529141901.894819585@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


30 Mar, 2019

1 commit

  • With zero-key defined, we can remove previous detection of key id 0 or null
    key in order to deal with a zero-key situation. Syncing all security
    commands to use the zero-key. Helper functions are introduced to return the
    data that points to the actual key payload or the zero_key. This helps
    uniformly handle the key material even with zero_key.

    Signed-off-by: Dave Jiang
    Signed-off-by: Dan Williams

    Dave Jiang
     

23 Mar, 2019

1 commit

  • The dynamic-debug statements for command payload output only get emitted
    when the command is not ND_CMD_CALL. Move the output payload dumping
    ahead of the early return path for ND_CMD_CALL.

    Fixes: 31eca76ba2fc9 ("...whitelisted dimm command marshaling mechanism")
    Reported-by: Vishal Verma
    Signed-off-by: Dan Williams

    Dan Williams
     

17 Mar, 2019

1 commit

  • Pull device-dax updates from Dan Williams:
    "New device-dax infrastructure to allow persistent memory and other
    "reserved" / performance differentiated memories, to be assigned to
    the core-mm as "System RAM".

    Some users want to use persistent memory as additional volatile
    memory. They are willing to cope with potential performance
    differences, for example between DRAM and 3D Xpoint, and want to use
    typical Linux memory management apis rather than a userspace memory
    allocator layered over an mmap() of a dax file. The administration
    model is to decide how much Persistent Memory (pmem) to use as System
    RAM, create a device-dax-mode namespace of that size, and then assign
    it to the core-mm. The rationale for device-dax is that it is a
    generic memory-mapping driver that can be layered over any "special
    purpose" memory, not just pmem. On subsequent boots udev rules can be
    used to restore the memory assignment.

    One implication of using pmem as RAM is that mlock() no longer keeps
    data off persistent media. For this reason it is recommended to enable
    NVDIMM Security (previously merged for 5.0) to encrypt pmem contents
    at rest. We considered making this recommendation an actively enforced
    requirement, but in the end decided to leave it as a distribution /
    administrator policy to allow for emulation and test environments that
    lack security capable NVDIMMs.

    Summary:

    - Replace the /sys/class/dax device model with /sys/bus/dax, and
    include a compat driver so distributions can opt-in to the new ABI.

    - Allow for an alternative driver for the device-dax address-range

    - Introduce the 'kmem' driver to hotplug / assign a device-dax
    address-range to the core-mm.

    - Arrange for the device-dax target-node to be onlined so that the
    newly added memory range can be uniquely referenced by numa apis"

    NOTE! I'm not entirely happy with the whole "PMEM as RAM" model because
    we currently have special - and very annoying rules in the kernel about
    accessing PMEM only with the "MC safe" accessors, because machine checks
    inside the regular repeat string copy functions can be fatal in some
    (not described) circumstances.

    And apparently the PMEM modules can cause that a lot more than regular
    RAM. The argument is that this happens because PMEM doesn't necessarily
    get scrubbed at boot like RAM does, but that is planned to be added for
    the user space tooling.

    Quoting Dan from another email:
    "The exposure can be reduced in the volatile-RAM case by scanning for
    and clearing errors before it is onlined as RAM. The userspace tooling
    for that can be in place before v5.1-final. There's also runtime
    notifications of errors via acpi_nfit_uc_error_notify() from
    background scrubbers on the DIMM devices. With that mechanism the
    kernel could proactively clear newly discovered poison in the volatile
    case, but that would be additional development more suitable for v5.2.

    I understand the concern, and the need to highlight this issue by
    tapping the brakes on feature development, but I don't see PMEM as RAM
    making the situation worse when the exposure is also there via DAX in
    the PMEM case. Volatile-RAM is arguably a safer use case since it's
    possible to repair pages where the persistent case needs active
    application coordination"

    * tag 'devdax-for-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
    device-dax: "Hotplug" persistent memory for use like normal RAM
    mm/resource: Let walk_system_ram_range() search child resources
    mm/memory-hotplug: Allow memory resources to be children
    mm/resource: Move HMM pr_debug() deeper into resource code
    mm/resource: Return real error codes from walk failures
    device-dax: Add a 'modalias' attribute to DAX 'bus' devices
    device-dax: Add a 'target_node' attribute
    device-dax: Auto-bind device after successful new_id
    acpi/nfit, device-dax: Identify differentiated memory with a unique numa-node
    device-dax: Add /sys/class/dax backwards compatibility
    device-dax: Add support for a dax override driver
    device-dax: Move resource pinning+mapping into the common driver
    device-dax: Introduce bus + driver model
    device-dax: Start defining a dax bus model
    device-dax: Remove multi-resource infrastructure
    device-dax: Kill dax_region base
    device-dax: Kill dax_region ida

    Linus Torvalds
     

12 Mar, 2019

2 commits

  • Merge several updates to the ARS implementation. Highlights include:

    * Support retrieval of short-ARS results if the ARS state is "requires
    continuation", and even if the "no_init_ars" module parameter is
    specified.
    * Allow busy-polling of the kernel ARS state by allowing root to reset
    the exponential back-off timer.
    * Filter potentially stale ARS results by tracking query-ARS relative to
    the previous start-ARS.

    Dan Williams
     
  • Merge miscellaneous libnvdimm sub-system updates for v5.1. Highlights
    include:

    * Support for the Hyper-V family of device-specific-methods (DSMs)
    * Several fixes and workarounds for Hyper-V compatibility.
    * Fix for the support to cache the dirty-shutdown-count at init.

    Dan Williams
     

02 Mar, 2019

1 commit

  • ACPI NFIT flags field reports major errors on NVDIMM, which need
    user's attention.

    Update the current log to a proper error message with dev_err().
    The current message string is kept for grep-compatibility.

    Signed-off-by: Toshi Kani
    Cc: Dan Williams
    Cc: "Rafael J. Wysocki"
    Cc: Robert Elliott
    Signed-off-by: Dan Williams

    Toshi Kani
     

21 Feb, 2019

5 commits

  • Gate ARS result consumption on whether the OS issued start-ARS since the
    previous consumption. The BIOS may only clear its result buffers after a
    successful start-ARS.

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

    Dan Williams
     
  • The ARS implementation implements exponential back-off on the poll
    interval to prevent high-frequency access to the DIMM / platform
    interface. Depending on when the ARS completes the poll interval may
    exceed the completion event by minutes. Allow root to reset the timeout
    each time it probes the status. A one-second timeout is still enforced,
    but root can otherwise can control the poll interval.

    Fixes: bc6ba8085842 ("nfit, address-range-scrub: rework and simplify ARS...")
    Cc:
    Reported-by: Erwin Tsaur
    Reviewed-by: Toshi Kani
    Signed-off-by: Dan Williams

    Dan Williams
     
  • In preparation for introducing new flags to gate whether ARS results are
    stale, or poll the completion state, convert the existing flags to an
    unsigned long with enumerated values. This conversion allows the flags
    to be atomically updated outside of ->init_mutex.

    Reviewed-by: Toshi Kani
    Signed-off-by: Dan Williams

    Dan Williams
     
  • The ars_start_flags property of 'struct acpi_nfit_desc' is no longer
    used since ARS_REQ_SHORT and ARS_REQ_LONG were added.

    Reviewed-by: Toshi Kani
    Signed-off-by: Dan Williams

    Dan Williams
     
  • The no_init_ars option is meant to prevent long-ARS, but short-ARS
    should be allowed to grab any immediate results.

    Fixes: bc6ba8085842 ("nfit, address-range-scrub: rework and simplify ARS...")
    Cc:
    Reported-by: Erwin Tsaur
    Reviewed-by: Toshi Kani
    Signed-off-by: Dan Williams

    Dan Williams
     

14 Feb, 2019

1 commit


13 Feb, 2019

1 commit

  • Recent fixes to command handling enabled Linux to read label
    configurations that it could not before. Unfortunately that means that
    configurations that were operating in label-less mode will be broken as
    the kernel ignores the existing namespace configuration and tries to
    honor the new found labels.

    Fortunately this seems limited to a case where Linux can quirk the
    behavior and maintain the existing label-less semantics by default.
    When the platform does not emit an _LSW method, disable all label access
    methods. Provide a 'force_labels' module parameter to allow read-only
    label operation.

    Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
    Reported-by: Dexuan Cui
    Reviewed-by: Dexuan Cui
    Signed-off-by: Dan Williams

    Dan Williams
     

08 Feb, 2019

1 commit

  • Commit 11189c1089da "acpi/nfit: Fix command-supported detection" broke
    ND_CMD_CALL for bus-level commands. The "func = cmd" assumption is only
    valid for:

    ND_CMD_ARS_CAP
    ND_CMD_ARS_START
    ND_CMD_ARS_STATUS
    ND_CMD_CLEAR_ERROR

    The function number otherwise needs to be pulled from the command
    payload for:

    NFIT_CMD_TRANSLATE_SPA
    NFIT_CMD_ARS_INJECT_SET
    NFIT_CMD_ARS_INJECT_CLEAR
    NFIT_CMD_ARS_INJECT_GET

    Update cmd_to_func() for the bus case and call it in the common path.

    Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
    Cc:
    Reviewed-by: Vishal Verma
    Reported-by: Grzegorz Burzynski
    Tested-by: Jeff Moyer
    Signed-off-by: Dan Williams

    Dan Williams
     

03 Feb, 2019

1 commit

  • As Dexuan reports the NVDIMM_FAMILY_HYPERV platform is incompatible with
    the existing Linux namespace implementation because it uses
    NSLABEL_FLAG_LOCAL for x1-width PMEM interleave sets. Quirk it as an
    platform / DIMM that does not provide BLK-aperture access. Allow the
    libnvdimm core to assume no potential for aliasing. In case other
    implementations make the same mistake, provide a "noblk" module
    parameter to force-enable the quirk.

    Link: https://lkml.kernel.org/r/PU1P153MB0169977604493B82B662A01CBF920@PU1P153MB0169.APCP153.PROD.OUTLOOK.COM
    Reported-by: Dexuan Cui
    Tested-by: Dexuan Cui
    Signed-off-by: Dan Williams

    Dan Williams
     

30 Jan, 2019

3 commits

  • Add the Hyper-V _DSM command set to the white list of NVDIMM command
    sets.

    This command set is documented at http://www.uefi.org/RFIC_LIST
    (see "Virtual NVDIMM 0x1901").

    Signed-off-by: Dexuan Cui
    Reviewed-by: Michael Kelley
    Signed-off-by: Dan Williams

    Dexuan Cui
     
  • In the case of ND_CMD_CALL, we should also check out_obj->type.

    The patch uses out_obj->type, which is a short alias to
    out_obj->package.type.

    Fixes: 31eca76ba2fc ("nfit, libnvdimm: limited/whitelisted dimm command marshaling mechanism")
    Cc:
    Signed-off-by: Dexuan Cui
    Signed-off-by: Dan Williams

    Dexuan Cui
     
  • The implementation is broken in all the ways the unit test did not touch:

    1/ The local definition of in_buf and in_obj violated C99 initializer
    expectations for zeroing. By only initializing 2 out of the three
    struct members the compiler was free to zero-initialize the remaining
    entry even though the aliased location in the union was initialized.

    2/ The implementation made assumptions about the state of the 'smart'
    payload after command execution that are satisfied by
    acpi_nfit_ctl(), but not acpi_evaluate_dsm().

    3/ populate_shutdown_status() is skipped on Intel NVDIMMs due to the early
    return for skipping the common _LS{I,R,W} enabling.

    4/ The input length should be zero.

    This breakage was missed due to the unit test implementation only
    testing the case where nfit_intel_shutdown_status() returns a valid
    payload.

    Much of this complexity would be saved if acpi_nfit_ctl() could be used, but
    that currently requires a 'struct nvdimm *' argument and one is not created
    until later in the init process. The health result is needed before the device
    is created because the payload gates whether the nmemX/nfit/dirty_shutdown
    property is visible in sysfs.

    Cc:
    Fixes: 0ead11181fe0 ("acpi, nfit: Collect shutdown status")
    Reported-by: Dexuan Cui
    Reviewed-by: Dexuan Cui
    Signed-off-by: Dan Williams

    Dan Williams
     

22 Jan, 2019

3 commits

  • The _DSM function number validation only happens to succeed when the
    generic Linux command number translation corresponds with a
    DSM-family-specific function number. This breaks NVDIMM-N
    implementations that correctly implement _LSR, _LSW, and _LSI, but do
    not happen to publish support for DSM function numbers 4, 5, and 6.

    Recall that the support for _LS{I,R,W} family of methods results in the
    DIMM being marked as supporting those command numbers at
    acpi_nfit_register_dimms() time. The DSM function mask is only used for
    ND_CMD_CALL support of non-NVDIMM_FAMILY_INTEL devices.

    Fixes: 31eca76ba2fc ("nfit, libnvdimm: limited/whitelisted dimm command...")
    Cc:
    Link: https://github.com/pmem/ndctl/issues/78
    Reported-by: Sujith Pandel
    Tested-by: Sujith Pandel
    Reviewed-by: Vishal Verma
    Reviewed-by: Jeff Moyer
    Signed-off-by: Dan Williams

    Dan Williams
     
  • In preparation for using function number 0 as an error value, prevent it
    from being considered a valid function value by acpi_nfit_ctl().

    Cc:
    Cc: stuart hayes
    Fixes: e02fb7264d8a ("nfit: add Microsoft NVDIMM DSM command set...")
    Reported-by: Jeff Moyer
    Reviewed-by: Jeff Moyer
    Signed-off-by: Dan Williams

    Dan Williams
     
  • The following warning:

    ACPI0012:00: security event setup failed: -19

    ...is meant to capture exceptional failures of sysfs_get_dirent(),
    however it will also fail in the common case when security support is
    disabled. A few issues:

    1/ A dev_warn() report for a common case is too chatty
    2/ The setup of this notifier is generic, no need for it to be driven
    from the nfit driver, it can exist completely in the core.
    3/ If it fails for any reason besides security support being disabled,
    that's fatal and should abort DIMM activation. Userspace may hang if
    it never gets overwrite notifications.
    4/ The dirent needs to be released.

    Move the call to the core 'dimm' driver, make it conditional on security
    support being active, make it fatal for the exceptional case, add the
    missing sysfs_put() at device disable time.

    Fixes: 7d988097c546 ("...Add security DSM overwrite support")
    Reviewed-by: Dave Jiang
    Signed-off-by: Dan Williams

    Dan Williams
     

15 Jan, 2019

1 commit