From 9ae390046164e8b62fbdc48d2c6de8ee6fbd3cdc Mon Sep 17 00:00:00 2001 From: Klaus Jensen Date: Tue, 26 Jan 2021 12:32:29 +0100 Subject: hw/block/nvme: add missing mor/mar constraint checks Firstly, if zoned.max_active is non-zero, zoned.max_open must be less than or equal to zoned.max_active. Secondly, if only zones.max_active is set, we have to explicitly set zones.max_open or we end up with an invalid MAR/MOR configuration. This is an artifact of the parameters not being zeroes-based like in the spec. Cc: Dmitry Fomichev Reported-by: Gollu Appalanaidu Signed-off-by: Klaus Jensen Reviewed-by: Dmitry Fomichev --- hw/block/nvme-ns.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'hw/block') diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c index fd73d03211..0e87600204 100644 --- a/hw/block/nvme-ns.c +++ b/hw/block/nvme-ns.c @@ -163,6 +163,18 @@ static int nvme_ns_zoned_check_calc_geometry(NvmeNamespace *ns, Error **errp) return -1; } + if (ns->params.max_active_zones) { + if (ns->params.max_open_zones > ns->params.max_active_zones) { + error_setg(errp, "max_open_zones (%u) exceeds max_active_zones (%u)", + ns->params.max_open_zones, ns->params.max_active_zones); + return -1; + } + + if (!ns->params.max_open_zones) { + ns->params.max_open_zones = ns->params.max_active_zones; + } + } + if (ns->params.zd_extension_size) { if (ns->params.zd_extension_size & 0x3f) { error_setg(errp, -- cgit v1.2.3-55-g7522