]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/nvme: fix missing check for PMR capability
authorKlaus Jensen <k.jensen@samsung.com>
Mon, 7 Jun 2021 09:47:57 +0000 (11:47 +0200)
committerMichael Roth <michael.roth@amd.com>
Thu, 14 Oct 2021 22:05:22 +0000 (17:05 -0500)
Qiang Liu reported that an access on an unknown address is triggered in
memory_region_set_enabled because a check on CAP.PMRS is missing for the
PMRCTL register write when no PMR is configured.

Cc: qemu-stable@nongnu.org
Fixes: 75c3c9de961d ("hw/block/nvme: disable PMR at boot up")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/362
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
(cherry picked from commit 2b02aabc9d02f9e95946cf639f546bb61f1721b7)
Signed-off-by: Michael Roth <michael.roth@amd.com>
hw/block/nvme.c

index 2c7ca587c59712c4a34259d380c813e1a010fcbc..8f4e1fc3ac24a57e60a95d395fca46f5bcaa9002 100644 (file)
@@ -5589,6 +5589,10 @@ static void nvme_write_bar(NvmeCtrl *n, hwaddr offset, uint64_t data,
                        "invalid write to PMRCAP register, ignored");
         return;
     case 0xe04: /* PMRCTL */
+        if (!NVME_CAP_PMRS(n->bar.cap)) {
+            return;
+        }
+
         n->bar.pmrctl = data;
         if (NVME_PMRCTL_EN(data)) {
             memory_region_set_enabled(&n->pmr.dev->mr, true);