aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Jensen <k.jensen@samsung.com>2021-06-07 11:47:57 +0200
committerMichael Roth <michael.roth@amd.com>2021-10-14 17:05:22 -0500
commitbef905cd8a3eb0753262703ecebf2fae0658154b (patch)
treeb0d4e04de8244309ecffc54b371639995fd974e7
parentaa99651295cf13aafa8db030c3cc1a0c1b64427d (diff)
downloadqemu-bef905cd8a3eb0753262703ecebf2fae0658154b.zip
qemu-bef905cd8a3eb0753262703ecebf2fae0658154b.tar.gz
qemu-bef905cd8a3eb0753262703ecebf2fae0658154b.tar.bz2
hw/nvme: fix missing check for PMR capability
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>
-rw-r--r--hw/block/nvme.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 2c7ca58..8f4e1fc 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -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);