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
     

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
     

22 Jan, 2019

1 commit

  • 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
     

23 Dec, 2018

1 commit

  • The security implementation is too chatty. For example, the common case
    is that security is not enabled / setup, and booting a qemu
    configuration currently yields:

    nvdimm nmem0: request_key() found no key
    nvdimm nmem0: failed to unlock dimm: -126
    nvdimm nmem1: request_key() found no key
    nvdimm nmem1: failed to unlock dimm: -126

    Convert all security related log messages to debug level.

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

    Dan Williams
     

14 Dec, 2018

1 commit

  • Add support to unlock the dimm via the kernel key management APIs. The
    passphrase is expected to be pulled from userspace through keyutils.
    The key management and sysfs attributes are libnvdimm generic.

    Encrypted keys are used to protect the nvdimm passphrase at rest. The
    master key can be a trusted-key sealed in a TPM, preferred, or an
    encrypted-key, more flexible, but more exposure to a potential attacker.

    Signed-off-by: Dave Jiang
    Co-developed-by: Dan Williams
    Reported-by: Randy Dunlap
    Signed-off-by: Dan Williams

    Dave Jiang
     

12 Oct, 2018

2 commits

  • This patch adds logic that is meant to make use of the namespace index data
    to reduce the number of reads that are needed to initialize a given
    namespace. The general idea is that once we have enough data to validate
    the namespace index we do so and then proceed to fetch only those labels
    that are not listed as being "free". By doing this I am seeing a total time
    reduction from about 4-5 seconds to 2-3 seconds for 24 NVDIMM modules each
    with 128K of label config area.

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

    Alexander Duyck
     
  • This patch splits the initialization of the label data into two functions.
    One for doing the init, and another for reading the actual configuration
    data. The idea behind this is that by doing this we create a symmetry
    between the getting and setting of config data in that we have a function
    for both. In addition it will make it easier for us to identify the bits
    that are related to init versus the pieces that are a wrapper for reading
    data from the ACPI interface.

    So for example by splitting things out like this it becomes much more
    obvious that we were performing checks that weren't necessarily related to
    the set/get operations such as relying on ndd->data being present when the
    set and get ops should not care about a locally cached copy of the label
    area.

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

    Alexander Duyck
     

15 Jul, 2018

1 commit


07 Apr, 2018

1 commit

  • At initialization time the 'dimm' driver caches a copy of the memory
    device's label area and reserves address space for each of the
    namespaces defined.

    However, as can be seen below, the reservation occurs even when the
    index blocks are invalid:

    nvdimm nmem0: nvdimm_init_config_data: len: 131072 rc: 0
    nvdimm nmem0: config data size: 131072
    nvdimm nmem0: __nd_label_validate: nsindex0 labelsize 1 invalid
    nvdimm nmem0: __nd_label_validate: nsindex1 labelsize 1 invalid
    nvdimm nmem0: : pmem-6025e505: 0x1000000000 @ 0xf50000000 reserve
    Fixes: 4a826c83db4e ("libnvdimm: namespace indices: read and validate")
    Reported-by: Krzysztof Rusocki
    Signed-off-by: Dan Williams

    Dan Williams
     

08 Oct, 2017

1 commit

  • ACPI 6.2 adds support for named methods to access the label storage area
    of an NVDIMM. We prefer these new methods if available and otherwise
    fallback to the NVDIMM_FAMILY_INTEL _DSMs. The kernel ioctls,
    ND_IOCTL_{GET,SET}_CONFIG_{SIZE,DATA}, remain generic and the driver
    translates the 'package' payloads into the NVDIMM_FAMILY_INTEL 'buffer'
    format to maintain compatibility with existing userspace and keep the
    output buffer parsing code in the driver common.

    The output payloads are mostly compatible save for the 'label area
    locked' status that moves from the 'config_size' (_LSI) command to the
    'config_read' (_LSR) command status.

    Cc: Jeff Moyer
    Cc: Johannes Thumshirn
    Signed-off-by: Dan Williams

    Dan Williams
     

29 Sep, 2017

1 commit

  • If we successfully enable a DIMM then it must not be locked and we can
    clear the label-read failure condition. Otherwise, we need to reload the
    entire bus provider driver to achieve the same effect, and that can
    disrupt unrelated DIMMs and namespaces.

    Fixes: 9d62ed965118 ("libnvdimm: handle locked label storage areas")
    Cc:
    Signed-off-by: Dan Williams

    Dan Williams
     

05 May, 2017

1 commit

  • Per the latest version of the "NVDIMM DSM Interface Example" [1], the
    label data retrieval routine can report a "locked" status. In this case
    all regions associated with that DIMM are disabled until the label area
    is unlocked. Provide generic libnvdimm enabling for NVDIMMs with label
    data area locking capabilities.

    [1]: http://pmem.io/documents/

    Signed-off-by: Dan Williams

    Dan Williams
     

19 Oct, 2016

1 commit

  • Platforms like QEMU-KVM implement an NFIT table and label DSMs.
    However, since that environment does not define an aliased
    configuration, the labels are currently ignored and the kernel registers
    a single full-sized pmem-namespace per region. Now that the kernel
    supports sub-divisions of pmem regions the labels have a purpose.
    Arrange for the labels to be honored when we find an existing / valid
    namespace index block.

    Cc:
    Cc: Haozhong Zhang
    Cc: Xiao Guangrong
    Signed-off-by: Dan Williams

    Dan Williams
     

02 Sep, 2016

1 commit

  • 'ndctl list --buses --dimms' does not list any NVDIMM-Ns since
    they are considered as idle. ndctl checks if any driver is
    attached to nmem device. nvdimm_probe() always fails in
    nvdimm_init_nsarea() since NVDIMM-Ns do not implement optinal
    ND_CMD_GET_CONFIG_DATA command.

    Change nvdimm_probe() to accept the case that the CONFIG_DATA
    command is not implemented for NVDIMM-Ns. The driver attaches
    without ndd, which keeps it no-op to the device.

    Reported-by: Brian Boylston
    Signed-off-by: Toshi Kani
    Cc: Dan Williams
    Tested-by: Johannes Thumshirn
    Acked-by: Johannes Thumshirn
    Signed-off-by: Dan Williams

    Toshi Kani
     

25 Jun, 2015

4 commits

  • A complete label set is a PMEM-label per-dimm per-interleave-set where
    all the UUIDs match and the interleave set cookie matches the hosting
    interleave set.

    Present sysfs attributes for manipulation of a PMEM-namespace's
    'alt_name', 'uuid', and 'size' attributes. A later patch will make
    these settings persistent by writing back the label.

    Note that PMEM allocations grow forwards from the start of an interleave
    set (lowest dimm-physical-address (DPA)). BLK-namespaces that alias
    with a PMEM interleave set will grow allocations backward from the
    highest DPA.

    Cc: Greg KH
    Cc: Neil Brown
    Acked-by: Christoph Hellwig
    Signed-off-by: Dan Williams

    Dan Williams
     
  • This on media label format [1] consists of two index blocks followed by
    an array of labels. None of these structures are ever updated in place.
    A sequence number tracks the current active index and the next one to
    write, while labels are written to free slots.

    +------------+
    | |
    | nsindex0 |
    | |
    +------------+
    | |
    | nsindex1 |
    | |
    +------------+
    | label0 |
    +------------+
    | label1 |
    +------------+
    | |
    ....nslot...
    | |
    +------------+
    | labelN |
    +------------+

    After reading valid labels, store the dpa ranges they claim into
    per-dimm resource trees.

    [1]: http://pmem.io/documents/NVDIMM_Namespace_Spec.pdf

    Cc: Neil Brown
    Acked-by: Christoph Hellwig
    Signed-off-by: Dan Williams

    Dan Williams
     
  • The libnvdimm region driver is an intermediary driver that translates
    non-volatile "region"s into "namespace" sub-devices that are surfaced by
    persistent memory block-device drivers (PMEM and BLK).

    ACPI 6 introduces the concept that a given nvdimm may simultaneously
    offer multiple access modes to its media through direct PMEM load/store
    access, or windowed BLK mode. Existing nvdimms mostly implement a PMEM
    interface, some offer a BLK-like mode, but never both as ACPI 6 defines.
    If an nvdimm is single interfaced, then there is no need for dimm
    metadata labels. For these devices we can take the region boundaries
    directly to create a child namespace device (nd_namespace_io).

    Acked-by: Christoph Hellwig
    Tested-by: Toshi Kani
    Signed-off-by: Dan Williams

    Dan Williams
     
  • * Implement the device-model infrastructure for loading modules and
    attaching drivers to nvdimm devices. This is a simple association of a
    nd-device-type number with a driver that has a bitmask of supported
    device types. To facilitate userspace bind/unbind operations 'modalias'
    and 'devtype', that also appear in the uevent, are added as generic
    sysfs attributes for all nvdimm devices. The reason for the device-type
    number is to support sub-types within a given parent devtype, be it a
    vendor-specific sub-type or otherwise.

    * The first consumer of this infrastructure is the driver
    for dimm devices. It simply uses control messages to retrieve and
    store the configuration-data image (label set) from each dimm.

    Note: nd_device_register() arranges for asynchronous registration of
    nvdimm bus devices by default.

    Cc: Greg KH
    Cc: Neil Brown
    Acked-by: Christoph Hellwig
    Tested-by: Toshi Kani
    Signed-off-by: Dan Williams

    Dan Williams