[ndctl PATCH] daxctl: Add bash-completion
by Vishal Verma
Add bash completion helpers to contrib/ndctl to also allow for daxctl
completion. This makes it so we have a single bash-completion script
that is installed, and it provides completions for both ndctl and
daxctl. As a bonus, some of the common functions can also get reused by
both.
Cc: Dan Williams <dan.j.williams(a)intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma(a)intel.com>
---
contrib/ndctl | 155 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 128 insertions(+), 27 deletions(-)
diff --git a/contrib/ndctl b/contrib/ndctl
index 515494d..629d6a8 100755
--- a/contrib/ndctl
+++ b/contrib/ndctl
@@ -2,6 +2,8 @@
# Taken from perf's completion script.
+### common helpers between ndctl and daxctl
+
__my_reassemble_comp_words_by_ref()
{
local exclude i j first
@@ -49,7 +51,7 @@ __my_reassemble_comp_words_by_ref()
}
# Define preload_get_comp_words_by_ref="false", if the function
-# __ndctl_get_comp_words_by_ref() is required instead.
+# __nd_common_get_comp_words_by_ref() is required instead.
preload_get_comp_words_by_ref="true"
if [ $preload_get_comp_words_by_ref = "true" ]; then
@@ -57,7 +59,7 @@ if [ $preload_get_comp_words_by_ref = "true" ]; then
preload_get_comp_words_by_ref="false"
fi
[ $preload_get_comp_words_by_ref = "true" ] ||
-__ndctl_get_comp_words_by_ref()
+__nd_common_get_comp_words_by_ref()
{
local exclude cur_ words_ cword_
if [ "$1" = "-n" ]; then
@@ -85,6 +87,29 @@ __ndctl_get_comp_words_by_ref()
done
}
+__nd_common_prev_skip_opts ()
+{
+ local i cmd_ cmds_
+
+ let i=cword-1
+ cmds_=$($cmd $1 --list-cmds)
+ prev_skip_opts=()
+ while [ $i -ge 0 ]; do
+ if [[ ${words[i]} == $1 ]]; then
+ return
+ fi
+ for cmd_ in $cmds_; do
+ if [[ ${words[i]} == $cmd_ ]]; then
+ prev_skip_opts=${words[i]}
+ return
+ fi
+ done
+ ((i--))
+ done
+}
+
+### ndctl
+
__ndctlcomp()
{
local i=0
@@ -351,27 +376,6 @@ __ndctl_add_special_opts()
esac
}
-__ndctl_prev_skip_opts ()
-{
- local i cmd_ cmds_
-
- let i=cword-1
- cmds_=$($cmd $1 --list-cmds)
- prev_skip_opts=()
- while [ $i -ge 0 ]; do
- if [[ ${words[i]} == $1 ]]; then
- return
- fi
- for cmd_ in $cmds_; do
- if [[ ${words[i]} == $cmd_ ]]; then
- prev_skip_opts=${words[i]}
- return
- fi
- done
- ((i--))
- done
-}
-
__ndctl_init_filters()
{
bus_filter=''
@@ -430,7 +434,7 @@ __ndctl_main()
__ndctl_init_filters
# Skip options backward and find the last ndctl command
- __ndctl_prev_skip_opts
+ __nd_common_prev_skip_opts
subcmd=$prev_skip_opts
# List ndctl subcommands or long options
if [ -z $subcmd ]; then
@@ -498,9 +502,106 @@ _ndctl()
if [ $preload_get_comp_words_by_ref = "true" ]; then
_get_comp_words_by_ref -n =: cur words cword prev
else
- __ndctl_get_comp_words_by_ref -n =: cur words cword prev
+ __nd_common_get_comp_words_by_ref -n =: cur words cword prev
fi
__ndctl_main
-} &&
+}
+
+### daxctl ###
+
+__daxctl_get_devs()
+{
+ local opts="--devices $*"
+ echo "$(daxctl list $opts | grep -E "^\s*\"chardev\":" | cut -d\" -f4)"
+}
+
+__daxctlcomp()
+{
+ local i=0
+
+ COMPREPLY=( $( compgen -W "$1" -- "$2" ) )
+ for cword in "${COMPREPLY[@]}"; do
+ if [[ "$cword" == @(--region|--dev) ]]; then
+ COMPREPLY[$i]="${cword}="
+ else
+ COMPREPLY[$i]="${cword} "
+ fi
+ ((i++))
+ done
+}
+
+__daxctl_comp_options()
+{
+
+ local cur=$1
+ local opts
+
+ if [[ "$cur" == *=* ]]; then
+ local cur_subopt=${cur%%=*}
+ local cur_arg=${cur##*=}
+ case $cur_subopt in
+ --region)
+ opts=$(__ndctl_get_regions -i)
+ ;;
+ --dev)
+ opts=$(__daxctl_get_devs -i)
+ ;;
+ *)
+ return
+ ;;
+ esac
+ __daxctlcomp "$opts" "$cur_arg"
+ fi
+}
+
+__daxctl_comp_non_option_args()
+{
+ # there aren't any commands that accept non option arguments yet
+ return
+}
+
+__daxctl_main()
+{
+ local cmd subcmd
+
+ cmd=${words[0]}
+ COMPREPLY=()
+
+ # Skip options backward and find the last daxctl command
+ __nd_common_prev_skip_opts
+ subcmd=$prev_skip_opts
+ # List daxctl subcommands or long options
+ if [ -z $subcmd ]; then
+ if [[ $cur == --* ]]; then
+ cmds="--version --help --list-cmds"
+ else
+ cmds=$($cmd --list-cmds)
+ fi
+ __daxctlcomp "$cmds" "$cur"
+ else
+ # List long option names
+ if [[ $cur == --* ]]; then
+ opts=$($cmd $subcmd --list-opts)
+ __daxctlcomp "$opts" "$cur"
+ __daxctl_comp_options "$cur"
+ else
+ [ -z "$subcmd" ] && return
+ __daxctl_comp_non_option_args "$subcmd" "$cur"
+ fi
+ fi
+}
+
+type daxctl &>/dev/null &&
+_daxctl()
+{
+ local cur words cword prev
+ if [ $preload_get_comp_words_by_ref = "true" ]; then
+ _get_comp_words_by_ref -n =: cur words cword prev
+ else
+ __nd_common_get_comp_words_by_ref -n =: cur words cword prev
+ fi
+ __daxctl_main
+}
-complete -o nospace -F _ndctl ndctl 2>/dev/null
+complete -o nospace -F _ndctl ndctl
+complete -o nospace -F _daxctl daxctl
--
2.20.1
3 years, 3 months
your mail subject
by Avraham F
Your email client cannot read this email. To view it online, please go here: http://track.yoganews.info/campaigns/webversion/Nzk1Nw==/MzQ0NTA0OA==/MjU5<br /> Have we gotten to the wrong address? If so, we apologize and you can easily press the Unsubscribe me from this list<br />Dear colleagues, <br /><br />Following our Movement and Cognition conferences at Oxford University and at Harvard Medical School, we have the honor to invite you to the 2019 world conference on Movement and Cognition at Tel-Aviv University.<br /><br />The purpose of the conference is to share knowledge on the relation of human movement to cognitive function. Among the focus areas of the conference include applications for: Rehabilitation and therapeutics, sport, motor learning, brain-behavior relationships, gait and cognition, and dance. We are also focusing this time on female cognitive movement interaction, the aging brain and gerontology, treatment of traumatic brain injury, neonatal, infant and child development and ergonomics all in the context of movement and cognition.<br /><br />The conference will be held on the campus of the University in the vibrant and fascinating city of Tel-Aviv between 22-24 July 2019. Besides the academic, scientific and clinical presentations, tours will also be available. <br /><br />We welcome your participation in this conference. Should you, in addition, desire to present your research, unique technique or clinical experiences, kindly send us your abstract. This can be done by sending to the attention of the secretary of the scientific committee at: jmerrick@zahav.net.il. The abstracts of the conference will be published in the Conference Proceedings as well as selected papers published in volume 9 of the journal Functional Neurology, Rehabilitation, and Ergonomics.<br /><br />The conference is a collaborative venture of the following institutions: the Harvard Medical School affiliated hospitals, McLean, and Beth Israel-Deaconess, Tel-Aviv University, the Computational Neurosciences Laboratory at the Nuffield Department of Surgical Sciences, University of Oxford, the Synthetic Intelligence Laboratory, Massachusetts Institute for Technology, Bielefeld University in Germany, the School of Medicine of the Hebrew University of Jerusalem, La Sorbonne (University of Paris) France, the Jerusalem Academy of Dance, the Faculty of Health Sciences of University of Haifa, the Wingate Institute for Sports and Exercise Science, the National Institute for Brain and Rehabilitation Sciences, Nazareth, Israel, the Institute for Neurology and Neurosurgery, Havana and the University of the Medical Sciences Havana.<br /><br />Please check out the conference website at (link): http://bit.ly/2Q7n0Qs<br /><br />We hope to meet you in July 2019 in Tel-Aviv and welcome you personally to the Holy Land.<br /><br />Wish very best wishes,<br /><br /> <br /><br />Gerry Leisman <br /><br />Chair, Scientific Committee<br /><br />MOVEMENT-2018<br /><br />Professor, Neuro- and Rehabilitation Sciences<br /><br />University of Haifa Faculty of Social Welfare<br /><br />and Health Sciences.<br /> Director, The National<br />Institute of Brain & Rehabilitation Sciences,<br /><br />Nazareth, Israel. <br />Professor Neurologíca Restaurativa <br /> Universidad de Ciencias Médicas<br />
3 years, 3 months
[PATCH] device-dax: Auto-bind device after successful new_id
by Dan Williams
The typical 'new_id' attribute behavior is to immediately attach a
device to its driver after a new device-id is added. Implement this
behavior for the dax bus.
Reported-by: Alexander Duyck <alexander.h.duyck(a)linux.intel.com>
Cc: Dave Hansen <dave.hansen(a)linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams(a)intel.com>
---
drivers/dax/bus.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index c620ad52d7e5..7053ab6419db 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -92,7 +92,10 @@ static ssize_t do_id_store(struct device_driver *drv, const char *buf,
} else
/* dax_id already added */;
mutex_unlock(&dax_bus_lock);
- return rc;
+
+ if (rc < 0)
+ return rc;
+ return driver_attach(drv);
}
static ssize_t new_id_store(struct device_driver *drv, const char *buf,
3 years, 3 months
[PATCH v1] libnvdimm, namespace: Drop uuid_t implementation detail
by Andy Shevchenko
There is no need for caller to know how uuid_t type is constructed. Thus,
whenever we use it the implementation details are not needed. Drop it for good.
Signed-off-by: Andy Shevchenko <andriy.shevchenko(a)linux.intel.com>
---
drivers/nvdimm/namespace_devs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 4b077555ac70..47485373c5cd 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -1811,8 +1811,8 @@ static bool has_uuid_at_pos(struct nd_region *nd_region, u8 *uuid,
&& !guid_equal(&nd_set->type_guid,
&nd_label->type_guid)) {
dev_dbg(ndd->dev, "expect type_guid %pUb got %pUb\n",
- nd_set->type_guid.b,
- nd_label->type_guid.b);
+ &nd_set->type_guid,
+ &nd_label->type_guid);
continue;
}
@@ -2216,8 +2216,8 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
if (namespace_label_has(ndd, type_guid)) {
if (!guid_equal(&nd_set->type_guid, &nd_label->type_guid)) {
dev_dbg(ndd->dev, "expect type_guid %pUb got %pUb\n",
- nd_set->type_guid.b,
- nd_label->type_guid.b);
+ &nd_set->type_guid,
+ &nd_label->type_guid);
return ERR_PTR(-EAGAIN);
}
--
2.20.1
3 years, 3 months
[PATCH v9 00/13] ndctl: add security support
by Dave Jiang
The following series implements mechanisms that utilize the sysfs knobs
provided by the kernel in order to support the Intel DSM v1.8 spec
that provides security to NVDIMM. The following abilities are added:
1. display security state
2. enable/update passphrase
3. disable passphrase
4. freeze security
5. secure erase
6. overwrite
7. master passphrase enable/update
v9:
- Add install-encrypt-key command. (Dan)
- Change enable-passphrase to setup-passphrase. (Dan)
- Change disable-passphrase to remove-passphrase. (Dan)
- Change ndctl_dimm_get_security() to return state directly and remove
ndctl_dimm_security_supported(). (Dan)
- Remove ND_SECURITY_UNSUPPORTED state
- change ND_SECURITY_* to NDCTL_SECURITY_*
- Fix man page issues (Dan, Jane)
- Define NDCTL_KEYSDIR in config.h (Dan)
- Break check_key_run_and_discard() to 3 helper functions. (Dan)
- Remove key path input parameter. (Dan)
- Remove master key input parameter. (Dan)
- Fixup various issues in security unit test script. (Vishal)
v8:
- Additional cleanup on test script. (Vishal)
- Change load-keys script into internal command for ndctl. (Dan)
v7:
- Added option to provide path to key directory. (Vishal)
- Cleaned up shell scripts. (Vishal)
- Cleaned up documentation. (Vishal)
- Addressed various comments from Vishal.
v6:
- Fix spelling and grammar errors for documentation. (Jing)
- Change bool for indicate master passphrase and old passphrase to enum.
- Fix key load script master key name.
- Update to match v15 of kernel patch series.
v5:
- Updated to match latest kernel interface (encrypted keys)
- Added overwrite support
- Added support for DSM v1.8 master passphrase operations
- Removed upcall related code
- Moved security state to enum (Dan)
- Change security output "security_state" to just "security". (Dan)
- Break out enable and update passphrase operation. (Dan)
- Security build can be compiled out when keyutils does not exist. (Dan)
- Move all keyutils related operations to libndctl. (Dan)
v4:
- Updated to match latest kernel interface.
- Added unit test for all security calls
v3:
- Added support to inject keys in order to update nvdimm security.
v2:
- Fixup the upcall util to match recent kernel updates for nvdimm security.
---
Dave Jiang (13):
ndctl: add support for display security state
ndctl: add command for ndctl to receive the key encryption key (master)
ndctl: add passphrase update to ndctl
ndctl: add disable security support
ndctl: add support for freeze security
ndctl: add support for sanitize dimm
ndctl: add unit test for security ops (minus overwrite)
ndctl: add modprobe conf file and load-keys ndctl command
ndctl: add overwrite operation support
ndctl: add wait-overwrite support
ndctl: master phassphrase management support
ndctl: add master secure erase support
ndctl: documentation for security and key management
Documentation/ndctl/Makefile.am | 10
Documentation/ndctl/intel-nvdimm-security.txt | 139 +++++
Documentation/ndctl/ndctl-freeze-security.txt | 60 ++
Documentation/ndctl/ndctl-install-encrypt-key.txt | 31 +
Documentation/ndctl/ndctl-list.txt | 8
Documentation/ndctl/ndctl-load-keys.txt | 43 ++
Documentation/ndctl/ndctl-remove-passphrase.txt | 28 +
Documentation/ndctl/ndctl-sanitize-dimm.txt | 48 ++
Documentation/ndctl/ndctl-setup-passphrase.txt | 41 +
Documentation/ndctl/ndctl-update-passphrase.txt | 43 ++
Documentation/ndctl/ndctl-wait-overwrite.txt | 31 +
Makefile.am | 4
configure.ac | 17 +
contrib/nvdimm-security.conf | 1
ndctl.spec.in | 3
ndctl/Makefile.am | 5
ndctl/builtin.h | 8
ndctl/dimm.c | 232 ++++++++
ndctl/kek.c | 133 +++++
ndctl/lib/Makefile.am | 8
ndctl/lib/dimm.c | 183 +++++++
ndctl/lib/keys.c | 581 +++++++++++++++++++++
ndctl/lib/libndctl.c | 31 +
ndctl/lib/libndctl.sym | 16 +
ndctl/lib/private.h | 1
ndctl/libndctl.h | 79 +++
ndctl/load-keys.c | 257 +++++++++
ndctl/ndctl.c | 8
test/Makefile.am | 4
test/security.sh | 223 ++++++++
util/json.c | 17 +
31 files changed, 2280 insertions(+), 13 deletions(-)
create mode 100644 Documentation/ndctl/intel-nvdimm-security.txt
create mode 100644 Documentation/ndctl/ndctl-freeze-security.txt
create mode 100644 Documentation/ndctl/ndctl-install-encrypt-key.txt
create mode 100644 Documentation/ndctl/ndctl-load-keys.txt
create mode 100644 Documentation/ndctl/ndctl-remove-passphrase.txt
create mode 100644 Documentation/ndctl/ndctl-sanitize-dimm.txt
create mode 100644 Documentation/ndctl/ndctl-setup-passphrase.txt
create mode 100644 Documentation/ndctl/ndctl-update-passphrase.txt
create mode 100644 Documentation/ndctl/ndctl-wait-overwrite.txt
create mode 100644 contrib/nvdimm-security.conf
create mode 100644 ndctl/kek.c
create mode 100644 ndctl/lib/keys.c
create mode 100644 ndctl/load-keys.c
create mode 100755 test/security.sh
--
3 years, 4 months
How can we better support vender specific _DSM commands in ndctl?
by Dexuan Cui
Hi all,
Hyper-V implements virtualized NVDIMM for guests running on it [1]. The
command set is documented on the RFIC_LIST page on uefi.org [2].
After Linux guest boots up, I can see these dev files:
/dev/ndctl0 /dev/nmem0 /dev/pmem0
and I can create an xfs file system on /dev/pmem0, mount it and use it.
Everything works just fine except for one thing: I can't call the Hyper-V
specific _DSM methods. So I wrote a patch [3] to allow the methods to
be called (I Cc'd you when posting the patch. Please review it.).
And then I found it looks ndctl doesn't allow me to easily call *all* the
_DSM methods, and I can't easily use ndctl to interpret the output in a
way I prefer.
My understanding is that: it looks when the kernel nvdimm driver and ndctl
were originally implemented, the code was mainly for Intel NVDIMM. Later
people introduced the support for NVDIMM_FAMILY_{HPE1, HPE2, MSFT},
and introduced the kernel ND_CMD_CALL ioctl to allow ndctl to call
vender-specific methods, but up to now, it looks the majority of the cmds
(if not all of the cmds) shown by "ndctl --list-cmds" are not very useful to
call vender specific methods, especially for NVDIMM_FAMILY_MSFT:
e.g.: for NVDIMM_FAMILY_MSFT, only Function 11 is used, and the
only useful info from "ndctl list --dimms --health" is:
"health":{
"health_state":"ok",
"temperature_celsius":27.000000,
"life_used_percentage":3
}
And, in msft_cmd_smart_get_health(), we only count the number of error bits,
and we drop the detailed info about the errors, and we lose some info
from the struct ndn_msft_smart_data, e.g. err_thresh_stat, warn_thresh_stat,
count_dram_uncorr_err and count_dram_corr_err, which IMO could be useful.
(See "libndctl: add support for the MSFT family of DSM functions" [4])
And, NVDIMM_FAMILY_MSFT has 32 methods [5], but except Function 11, it
looks the other methods can not be mapped to the existing ndctl commands.
Now, the new NVDIMM type NVDIMM_FAMILY_HYPERV has 4 Hyper-V specific
_DSM methods [2]:
Get Health Information (Function Index 1)
Get Unsafe Shutdown Count (Function Index 2)
Inject Error (Function Index 3)
Query Injected Errors (Function Index 4)
For Function 1, I made a patch
"libndctl: add support for the HYPER-V family of DSM functions" (please see [6],
especially hyperv_cmd_smart_get_health() in the patch) to use it, but the
existing ndctl interface, i.e. util_dimm_health_to_json(), only allows me to
return to the user a string of "fatal", "critical", "non-critical" or "ok", while
I would like to return more details about the errors to the user.
Function 3 can not be mapped to ndctl/inject-smart.c: smart_inject(), because
it's incompatible with Intel NVDIMM.
Function 2 and 4 can't be mapped to the existing ndctl commands either.
I'm wondering how I should use the 4 Hyper-V specific methods in ndctl.
I appreciate your insights. Thank you!
--Dexuan
[1] https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/ma...
[2] http://www.uefi.org/RFIC_LIST, see the link to "Virtual NVDIMM 0x1901" on the page.
[3] https://www.lkml.org/lkml/2019/1/23/761
[4] https://github.com/pmem/ndctl/commit/2cf2acca0288389a39ac823a42a5e048575d...
[5] https://docs.microsoft.com/en-us/windows-hardware/drivers/storage/-dsm-in...
[6] https://github.com/dcui/ndctl/commit/12feb081c881b24fee9f6cf088037c2e3024...
3 years, 4 months
[PATCH 0/4] Allow persistent memory to be used like normal RAM
by Dave Hansen
I would like to get this queued up to get merged. Since most of the
churn is in the nvdimm code, and it also depends on some refactoring
that only exists in the nvdimm tree, it seems like putting it in *via*
the nvdimm tree is the best path.
But, this series makes non-trivial changes to the "resource" code and
memory hotplug. I'd really like to get some acks from folks on the
first three patches which affect those areas.
Borislav and Bjorn, you seem to be the most active in the resource code.
Michal, I'd really appreciate at look at all of this from a mem hotplug
perspective.
Note: these are based on commit d2f33c19644 in:
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git libnvdimm-pending
Changes since v1:
* Now based on git://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git
* Use binding/unbinding from "dax bus" code
* Move over to a "dax bus" driver from being an nvdimm driver
--
Persistent memory is cool. But, currently, you have to rewrite
your applications to use it. Wouldn't it be cool if you could
just have it show up in your system like normal RAM and get to
it like a slow blob of memory? Well... have I got the patch
series for you!
This series adds a new "driver" to which pmem devices can be
attached. Once attached, the memory "owned" by the device is
hot-added to the kernel and managed like any other memory. On
systems with an HMAT (a new ACPI table), each socket (roughly)
will have a separate NUMA node for its persistent memory so
this newly-added memory can be selected by its unique NUMA
node.
Here's how I set up a system to test this thing:
1. Boot qemu with lots of memory: "-m 4096", for instance
2. Reserve 512MB of physical memory. Reserving a spot a 2GB
physical seems to work: memmap=512M!0x0000000080000000
This will end up looking like a pmem device at boot.
3. When booted, convert fsdax device to "device dax":
ndctl create-namespace -fe namespace0.0 -m dax
4. See patch 4 for instructions on binding the kmem driver
to a device.
5. Now, online the new memory sections. Perhaps:
grep ^MemTotal /proc/meminfo
for f in `grep -vl online /sys/devices/system/memory/*/state`; do
echo $f: `cat $f`
echo online_movable > $f
grep ^MemTotal /proc/meminfo
done
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: Dave Jiang <dave.jiang(a)intel.com>
Cc: Ross Zwisler <zwisler(a)kernel.org>
Cc: Vishal Verma <vishal.l.verma(a)intel.com>
Cc: Tom Lendacky <thomas.lendacky(a)amd.com>
Cc: Andrew Morton <akpm(a)linux-foundation.org>
Cc: Michal Hocko <mhocko(a)suse.com>
Cc: linux-nvdimm(a)lists.01.org
Cc: linux-kernel(a)vger.kernel.org
Cc: linux-mm(a)kvack.org
Cc: Huang Ying <ying.huang(a)intel.com>
Cc: Fengguang Wu <fengguang.wu(a)intel.com>
Cc: Borislav Petkov <bp(a)suse.de>
Cc: Bjorn Helgaas <bhelgaas(a)google.com>
Cc: Yaowei Bai <baiyaowei(a)cmss.chinamobile.com>
Cc: Takashi Iwai <tiwai(a)suse.de>
3 years, 4 months
[PATCH] libnvdimm: normalize dev_debug failed and succeeded wording
by Robert Elliott
Make dev_dbg prints use consistent wording for failed and succeeded, and
include the return code when reporting something failed.
Signed-off-by: Robert Elliott <elliott(a)hpe.com>
---
drivers/nvdimm/dimm.c | 2 +-
drivers/nvdimm/label.c | 7 ++++---
drivers/nvdimm/security.c | 53 ++++++++++++++++++++++++++++++++++-------------
3 files changed, 44 insertions(+), 18 deletions(-)
diff --git a/drivers/nvdimm/dimm.c b/drivers/nvdimm/dimm.c
index 0cf58cabc9ed..3ff104f7ccaa 100644
--- a/drivers/nvdimm/dimm.c
+++ b/drivers/nvdimm/dimm.c
@@ -62,7 +62,7 @@ static int nvdimm_probe(struct device *dev)
*/
rc = nvdimm_security_unlock(dev);
if (rc < 0)
- dev_dbg(dev, "failed to unlock dimm: %d\n", rc);
+ dev_dbg(dev, "unlock failed: %d\n", rc);
/*
diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
index a11bf4e6b451..235833a4881b 100644
--- a/drivers/nvdimm/label.c
+++ b/drivers/nvdimm/label.c
@@ -149,7 +149,7 @@ static int __nd_label_validate(struct nvdimm_drvdata *ndd)
labelsize = 128;
if (labelsize != sizeof_namespace_label(ndd)) {
- dev_dbg(dev, "nsindex%d labelsize %d invalid\n",
+ dev_dbg(dev, "nsindex%d labelsize: %d invalid\n",
i, nsindex[i]->labelsize);
continue;
}
@@ -373,7 +373,8 @@ static bool slot_valid(struct nvdimm_drvdata *ndd,
sum = nd_fletcher64(nd_label, sizeof_namespace_label(ndd), 1);
nd_label->checksum = __cpu_to_le64(sum_save);
if (sum != sum_save) {
- dev_dbg(ndd->dev, "fail checksum. slot: %d expect: %#llx\n",
+ dev_dbg(ndd->dev,
+ "checksum failed. slot: %d expected: %#llx\n",
slot, sum);
return false;
}
@@ -535,7 +536,7 @@ int nd_label_data_init(struct nvdimm_drvdata *ndd)
read_size += label_read_size;
}
- dev_dbg(ndd->dev, "len: %zu rc: %d\n", offset, rc);
+ dev_dbg(ndd->dev, "init config data area len: %zu succeeded\n", offset);
out_err:
return rc;
}
diff --git a/drivers/nvdimm/security.c b/drivers/nvdimm/security.c
index f8bb746a549f..b7f86846015a 100644
--- a/drivers/nvdimm/security.c
+++ b/drivers/nvdimm/security.c
@@ -58,7 +58,8 @@ static struct key *nvdimm_request_key(struct nvdimm *nvdimm)
if (PTR_ERR(key) == -ENOKEY)
dev_dbg(dev, "request_key() found no key\n");
else
- dev_dbg(dev, "request_key() upcall failed\n");
+ dev_dbg(dev, "request_key() upcall failed: %ld\n",
+ PTR_ERR(key));
key = NULL;
} else {
struct encrypted_key_payload *epayload;
@@ -107,6 +108,7 @@ static struct key *nvdimm_lookup_user_key(struct nvdimm *nvdimm,
static struct key *nvdimm_key_revalidate(struct nvdimm *nvdimm)
{
+ struct device *dev = &nvdimm->dev;
struct key *key;
int rc;
@@ -126,7 +128,11 @@ static struct key *nvdimm_key_revalidate(struct nvdimm *nvdimm)
if (rc < 0) {
nvdimm_put_key(key);
key = NULL;
- }
+ dev_dbg(dev, "key: %d revalidation failed: %d\n",
+ key_serial(key), rc);
+ } else
+ dev_dbg(dev, "key: %d revalidation succeeded\n",
+ key_serial(key));
return key;
}
@@ -170,8 +176,11 @@ static int __nvdimm_security_unlock(struct nvdimm *nvdimm)
return -ENOKEY;
rc = nvdimm->sec.ops->unlock(nvdimm, key_data(key));
- dev_dbg(dev, "key: %d unlock: %s\n", key_serial(key),
- rc == 0 ? "success" : "fail");
+ if (rc)
+ dev_dbg(dev, "key: %d unlock failed: %d\n",
+ key_serial(key), rc);
+ else
+ dev_dbg(dev, "key: %d unlock succeeded\n", key_serial(key));
nvdimm_put_key(key);
nvdimm->sec.state = nvdimm_security_state(nvdimm, NVDIMM_USER);
@@ -219,8 +228,11 @@ int nvdimm_security_disable(struct nvdimm *nvdimm, unsigned int keyid)
return -ENOKEY;
rc = nvdimm->sec.ops->disable(nvdimm, key_data(key));
- dev_dbg(dev, "key: %d disable: %s\n", key_serial(key),
- rc == 0 ? "success" : "fail");
+ if (rc)
+ dev_dbg(dev, "key: %d disable failed: %d\n",
+ key_serial(key), rc);
+ else
+ dev_dbg(dev, "key: %d disable succeeded\n", key_serial(key));
nvdimm_put_key(key);
nvdimm->sec.state = nvdimm_security_state(nvdimm, NVDIMM_USER);
@@ -265,10 +277,15 @@ int nvdimm_security_update(struct nvdimm *nvdimm, unsigned int keyid,
rc = nvdimm->sec.ops->change_key(nvdimm, key ? key_data(key) : NULL,
key_data(newkey), pass_type);
- dev_dbg(dev, "key: %d %d update%s: %s\n",
+ if (rc)
+ dev_dbg(dev, "key: %d %d update%s failed: %d\n",
key_serial(key), key_serial(newkey),
pass_type == NVDIMM_MASTER ? "(master)" : "(user)",
- rc == 0 ? "success" : "fail");
+ rc);
+ else
+ dev_dbg(dev, "key: %d %d update%s succeeded\n",
+ key_serial(key), key_serial(newkey),
+ pass_type == NVDIMM_MASTER ? "(master)" : "(user)");
nvdimm_put_key(newkey);
nvdimm_put_key(key);
@@ -324,9 +341,13 @@ int nvdimm_security_erase(struct nvdimm *nvdimm, unsigned int keyid,
return -ENOKEY;
rc = nvdimm->sec.ops->erase(nvdimm, key_data(key), pass_type);
- dev_dbg(dev, "key: %d erase%s: %s\n", key_serial(key),
+ if (rc)
+ dev_dbg(dev, "key: %d erase%s failed: %d\n", key_serial(key),
pass_type == NVDIMM_MASTER ? "(master)" : "(user)",
- rc == 0 ? "success" : "fail");
+ rc);
+ else
+ dev_dbg(dev, "key: %d erase%s succeeded\n", key_serial(key),
+ pass_type == NVDIMM_MASTER ? "(master)" : "(user)");
nvdimm_put_key(key);
nvdimm->sec.state = nvdimm_security_state(nvdimm, NVDIMM_USER);
@@ -377,8 +398,12 @@ int nvdimm_security_overwrite(struct nvdimm *nvdimm, unsigned int keyid)
}
rc = nvdimm->sec.ops->overwrite(nvdimm, key ? key_data(key) : NULL);
- dev_dbg(dev, "key: %d overwrite submission: %s\n", key_serial(key),
- rc == 0 ? "success" : "fail");
+ if (rc)
+ dev_dbg(dev, "key: %d overwrite submission failed: %d\n",
+ key_serial(key), rc);
+ else
+ dev_dbg(dev, "key: %d overwrite submission succeeded\n",
+ key_serial(key));
nvdimm_put_key(key);
if (rc == 0) {
@@ -429,9 +454,9 @@ void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm)
}
if (rc < 0)
- dev_dbg(&nvdimm->dev, "overwrite failed\n");
+ dev_dbg(&nvdimm->dev, "overwrite completion failed: %d\n", rc);
else
- dev_dbg(&nvdimm->dev, "overwrite completed\n");
+ dev_dbg(&nvdimm->dev, "overwrite completion succeeded\n");
if (nvdimm->sec.overwrite_state)
sysfs_notify_dirent(nvdimm->sec.overwrite_state);
--
2.16.3
3 years, 4 months
[PATCH v4] acpi/nfit: Fix command-supported detection
by Dan Williams
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: <stable(a)vger.kernel.org>
Link: https://github.com/pmem/ndctl/issues/78
Reported-by: Sujith Pandel <sujith_pandel(a)dell.com>
Tested-by: Sujith Pandel <sujith_pandel(a)dell.com>
Reviewed-by: Vishal Verma <vishal.l.verma(a)intel.com>
Reviewed-by: Jeff Moyer <jmoyer(a)redhat.com>
Signed-off-by: Dan Williams <dan.j.williams(a)intel.com>
---
Changes since v3:
* Fix ND_CMD_CALL regression:
https://lists.01.org/pipermail/linux-nvdimm/2019-January/019644.html
drivers/acpi/nfit/core.c | 54 ++++++++++++++++++++++++++++++++++------------
1 file changed, 40 insertions(+), 14 deletions(-)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 73281b19d3dd..71d03a4004fb 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -409,6 +409,32 @@ static bool payload_dumpable(struct nvdimm *nvdimm, unsigned int func)
return true;
}
+static int cmd_to_func(struct nfit_mem *nfit_mem, unsigned int cmd,
+ struct nd_cmd_pkg *call_pkg)
+{
+ if (call_pkg) {
+ int i;
+
+ if (nfit_mem->family != call_pkg->nd_family)
+ return -ENOTTY;
+
+ for (i = 0; i < ARRAY_SIZE(call_pkg->nd_reserved2); i++)
+ if (call_pkg->nd_reserved2[i])
+ return -EINVAL;
+ return call_pkg->nd_command;
+ }
+
+ /* Linux ND commands == NVDIMM_FAMILY_INTEL function numbers */
+ if (nfit_mem->family == NVDIMM_FAMILY_INTEL)
+ return cmd;
+
+ /*
+ * Force function number validation to fail since 0 is never
+ * published as a valid function in dsm_mask.
+ */
+ return 0;
+}
+
int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc)
{
@@ -422,30 +448,23 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
unsigned long cmd_mask, dsm_mask;
u32 offset, fw_status = 0;
acpi_handle handle;
- unsigned int func;
const guid_t *guid;
- int rc, i;
+ int func, rc, i;
if (cmd_rc)
*cmd_rc = -EINVAL;
- func = cmd;
- if (cmd == ND_CMD_CALL) {
- call_pkg = buf;
- func = call_pkg->nd_command;
-
- for (i = 0; i < ARRAY_SIZE(call_pkg->nd_reserved2); i++)
- if (call_pkg->nd_reserved2[i])
- return -EINVAL;
- }
if (nvdimm) {
struct acpi_device *adev = nfit_mem->adev;
if (!adev)
return -ENOTTY;
- if (call_pkg && nfit_mem->family != call_pkg->nd_family)
- return -ENOTTY;
+ if (cmd == ND_CMD_CALL)
+ call_pkg = buf;
+ func = cmd_to_func(nfit_mem, cmd, call_pkg);
+ if (func < 0)
+ return func;
dimm_name = nvdimm_name(nvdimm);
cmd_name = nvdimm_cmd_name(cmd);
cmd_mask = nvdimm_cmd_mask(nvdimm);
@@ -456,6 +475,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
} else {
struct acpi_device *adev = to_acpi_dev(acpi_desc);
+ func = cmd;
cmd_name = nvdimm_bus_cmd_name(cmd);
cmd_mask = nd_desc->cmd_mask;
dsm_mask = cmd_mask;
@@ -470,7 +490,13 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
if (!desc || (cmd && (desc->out_num + desc->in_num == 0)))
return -ENOTTY;
- if (!test_bit(cmd, &cmd_mask) || !test_bit(func, &dsm_mask))
+ /*
+ * Check for a valid command. For ND_CMD_CALL, we also have to
+ * make sure that the DSM function is supported.
+ */
+ if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask))
+ return -ENOTTY;
+ else if (!test_bit(cmd, &cmd_mask))
return -ENOTTY;
in_obj.type = ACPI_TYPE_PACKAGE;
3 years, 4 months
[PATCH] libnvdimm: Clarify nd_pfn_init() flow
by Dan Williams
In recent days, 2 engineers, including the original author of
nd_pfn_init(), overlooked the internal call to nd_pfn_validate() and the
implications to memory allocation.
Clarify this situation to help anyone that reads through this code in
the future.
Reported-by: Wei Yang <richardw.yang(a)linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams(a)intel.com>
---
drivers/nvdimm/btt_devs.c | 5 +++++
drivers/nvdimm/dax_devs.c | 5 +++++
drivers/nvdimm/pfn_devs.c | 21 +++++++++++++++++++++
3 files changed, 31 insertions(+)
diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index 795ad4ff35ca..e0a6f2491e57 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -354,6 +354,11 @@ int nd_btt_probe(struct device *dev, struct nd_namespace_common *ndns)
put_device(btt_dev);
}
+ /*
+ * Successful probe indicates to the caller that an nd_btt
+ * personality device has been registered and the caller can
+ * fail the probe of the baseline namespace device.
+ */
return rc;
}
EXPORT_SYMBOL(nd_btt_probe);
diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c
index 0453f49dc708..65010d955fa7 100644
--- a/drivers/nvdimm/dax_devs.c
+++ b/drivers/nvdimm/dax_devs.c
@@ -136,6 +136,11 @@ int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns)
} else
__nd_device_register(dax_dev);
+ /*
+ * Successful probe indicates to the caller that a device-dax
+ * personality device has been registered and the caller can
+ * fail the probe of the baseline namespace device.
+ */
return rc;
}
EXPORT_SYMBOL(nd_dax_probe);
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 6f22272e8d80..a8783b5a76ba 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -576,6 +576,11 @@ int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns)
} else
__nd_device_register(pfn_dev);
+ /*
+ * Successful probe indicates to the caller that an nd_pfn
+ * personality device has been registered and the caller can
+ * fail the probe of the baseline namespace device.
+ */
return rc;
}
EXPORT_SYMBOL(nd_pfn_probe);
@@ -706,6 +711,22 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
sig = DAX_SIG;
else
sig = PFN_SIG;
+
+ /*
+ * Check for an existing 'pfn' superblock before writing a new
+ * one. The intended flow is that on the first probe of an
+ * nd_{pfn,dax} device the superblock is calculated and written
+ * to the namespace. In this case nd_pfn_validate() returns
+ * -ENODEV because no valid superblock exists currently.
+ *
+ * On subsequent probes nd_pfn_validate() will find a valid
+ * superblock and return 0.
+ *
+ * If an assumption of the superblock has been violated, like a
+ * change to the physical alignment of the namespace,
+ * nd_pfn_validate() will return an error other than -ENODEV to
+ * fail probing.
+ */
rc = nd_pfn_validate(nd_pfn, sig);
if (rc != -ENODEV)
return rc;
3 years, 4 months