]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: extend help message when mmap regs fails
authorDaniel Wagner <dwagner@suse.de>
Thu, 1 Aug 2024 11:23:28 +0000 (13:23 +0200)
committerDaniel Wagner <wagi@monom.org>
Thu, 1 Aug 2024 11:40:52 +0000 (13:40 +0200)
Newer kernels enable the lockdown feature when secure boot is enabled.
This feature also prevents the register mapping into userspace. Thus it
is not enough to have CONFIG_IO_STRICT_DEVMEM disabled. Extend the
message with the hint also to disable secure boot.

While at it, also lower the reporting level to INFO, so that one single
'-v' is enough to get this information.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme.c

diff --git a/nvme.c b/nvme.c
index e33a048df4936b64d7cbebf157ac0458ed5c1846..3c144698f41e36d0df0375415d24070a64025c06 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -5353,7 +5353,7 @@ static void *mmap_registers(struct nvme_dev *dev, bool writable)
        sprintf(path, "/sys/class/nvme/%s/device/resource0", dev->name);
        fd = open(path, writable ? O_RDWR : O_RDONLY);
        if (fd < 0) {
-               if (log_level >= LOG_DEBUG)
+               if (log_level >= LOG_INFO)
                        nvme_show_error("%s did not find a pci resource, open failed %s",
                                        dev->name, strerror(errno));
                return NULL;
@@ -5361,9 +5361,12 @@ static void *mmap_registers(struct nvme_dev *dev, bool writable)
 
        membase = mmap(NULL, getpagesize(), prot, MAP_SHARED, fd, 0);
        if (membase == MAP_FAILED) {
-               if (log_level >= LOG_DEBUG) {
-                       fprintf(stderr, "%s failed to map. ", dev->name);
-                       fprintf(stderr, "Did your kernel enable CONFIG_IO_STRICT_DEVMEM?\n");
+               if (log_level >= LOG_INFO) {
+                       fprintf(stderr, "Failed to map registers to userspace.\n\n"
+                               "Did your kernel enable CONFIG_IO_STRICT_DEVMEM?\n"
+                               "You can disable this feature with command line argument\n\n"
+                               "\tio_memory=relaxed\n\n"
+                               "Also ensure secure boot is disabled.\n\n");
                }
                membase = NULL;
        }