Commit e095e8baaa for qemu.org
commit e095e8baaa18673e1976f34cce08e4adde061e29
Author: Klaus Jensen <k.jensen@samsung.com>
Date: Fri Nov 13 10:58:38 2026 +0100
hw/nvme: reject fdp.runs smaller than the lba data size
The reclaim unit accounting in nvme_do_write_fdp spins forever if RUNS
is configured to be smaller than LBADS.
Reject such an invalid configuration upfront.
Cc: qemu-stable@nongnu.org
Link: https://gitlab.com/qemu-project/qemu/-/work_items/4520
Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation")
Reviewed-by: Jesper Wendel Devantier <foss@defmacro.it>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c
index 2ae26a9acb..37d45bb4d5 100644
--- a/hw/nvme/ns.c
+++ b/hw/nvme/ns.c
@@ -485,6 +485,12 @@ static bool nvme_ns_init_fdp(NvmeNamespace *ns, Error **errp)
char *r, *p;
uint16_t *ph;
+ if (endgrp->fdp.runs < nvme_l2b(ns, 1)) {
+ error_setg(errp, "fdp.runs must be greater than or equal to the "
+ "lba data size of the namespace");
+ return false;
+ }
+
if (!ns->params.fdp.ruhs) {
ns->fdp.nphs = 1;
ph = ns->fdp.phs = g_new(uint16_t, 1);