* [PATCH v2 0/2] nvme: ZNS append limit and FDP feature decoding
@ 2026-11-22 14:48 shao.mingyin
2026-11-22 14:48 ` [PATCH v2 1/2] nvme: zns: reject an out-of-range zone append size limit shao.mingyin
2026-11-22 14:48 ` [PATCH v2 2/2] nvme: decode the FDP Get Features result as a dword shao.mingyin
0 siblings, 2 replies; 5+ messages in thread
From: shao.mingyin @ 2026-11-22 14:48 UTC (permalink / raw)
To: kbusch, hch; +Cc: axboe, sagi, linux-nvme, linux-kernel, stable
Two fixes from the [PATCH 0/5] nvme series posted on November 15 are
resent as a second revision. The other members of that series are
settled: 3/5 "nvmet: validate the LBA format count of a passthrough
namespace" was applied as e52b8562e2ad, 5/5 "nvme: bound the reservation
report retry loop" as b80093c7d0aa, and 2/5 "nvme: map passthrough data
when the length is nonzero" is withdrawn, because reusing a command
structure for a no-data command regressed from success to EFAULT.
Shao Mingyin (2):
nvme: zns: reject an out-of-range zone append size limit
nvme: decode the FDP Get Features result as a dword
drivers/nvme/host/core.c | 6 +++---
drivers/nvme/host/zns.c | 4 ++--
include/linux/nvme.h | 6 +-----
3 files changed, 6 insertions(+), 10 deletions(-)
Changes in v2:
- 1/2: drop the dev_warn() for ZASL values that are valid but do not fit
in max_zone_append, as Christoph asked. Such values fall back to
max_hw_sectors, and the changelog describes the representable range
instead of calling the value invalid.
- 2/2: drop the structure that became unused, as Christoph asked. I also
looked into the Sashiko report on hdr.sze: the buffer is on the stack,
so blk_rq_map_kern() copies through zero-filled pages and copies the
full length back, which means there is no uninitialized read and no
separate patch.
v1: https://lore.kernel.org/all/202611150127512368BGQ07ZNIRAIwClkam-8u@zte.com.cn/
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] nvme: zns: reject an out-of-range zone append size limit
2026-11-22 14:48 [PATCH v2 0/2] nvme: ZNS append limit and FDP feature decoding shao.mingyin
@ 2026-11-22 14:48 ` shao.mingyin
2026-11-25 5:24 ` Christoph Hellwig
2026-11-22 14:48 ` [PATCH v2 2/2] nvme: decode the FDP Get Features result as a dword shao.mingyin
1 sibling, 1 reply; 5+ messages in thread
From: shao.mingyin @ 2026-11-22 14:48 UTC (permalink / raw)
To: kbusch, hch; +Cc: axboe, sagi, linux-nvme, linux-kernel, stable
From: Shao Mingyin <shao.mingyin@zte.com.cn>
nvme_set_max_append() derives a sector limit by shifting 1 by ZASL + 3.
ZASL is a byte from the Identify Controller ZNS data. Values of 29 or
larger require a shift of at least 32 bits, which is undefined for the
32-bit operand. ZASL = 28 shifts into bit 31, which a signed operand
cannot express either.
Use an unsigned shift for representable values. If the reported limit
exceeds the range of max_zone_append, use max_hw_sectors, the same
limit used when ZASL is zero. The hardware transfer limit is smaller
than any append limit that requires a shift of at least 32 bits.
Fixes: 240e6ee272c0 ("nvme: support for zoned namespaces")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
Changes in v2:
- Drop the warning for values the driver cannot represent (Christoph).
- Clarify that such a value can be valid and why the fallback is safe.
v1: https://lore.kernel.org/r/20261115012752774qFGtgUXwZKwN-2LDj0D80@zte.com.cn
drivers/nvme/host/zns.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index e31ec6f4f94fbe872d346516b02dd1e6a2223872..a93f3b152faaad34199e0d6276536be0c0ae8767 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -27,8 +27,8 @@ static int nvme_set_max_append(struct nvme_ctrl *ctrl)
return status;
}
- if (id->zasl)
- ctrl->max_zone_append = 1 << (id->zasl + 3);
+ if (id->zasl && id->zasl + 3 < 32)
+ ctrl->max_zone_append = 1U << (id->zasl + 3);
else
ctrl->max_zone_append = ctrl->max_hw_sectors;
kfree(id);
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2 2/2] nvme: decode the FDP Get Features result as a dword
2026-11-22 14:48 [PATCH v2 0/2] nvme: ZNS append limit and FDP feature decoding shao.mingyin
2026-11-22 14:48 ` [PATCH v2 1/2] nvme: zns: reject an out-of-range zone append size limit shao.mingyin
@ 2026-11-22 14:48 ` shao.mingyin
2026-11-25 5:24 ` Christoph Hellwig
1 sibling, 1 reply; 5+ messages in thread
From: shao.mingyin @ 2026-11-22 14:48 UTC (permalink / raw)
To: kbusch, hch; +Cc: axboe, sagi, linux-nvme, linux-kernel, stable
From: Shao Mingyin <shao.mingyin@zte.com.cn>
nvme_get_features() returns completion dword 0 as a CPU-endian u32.
nvme_query_fdp_info() reads the result through a byte-ordered structure.
On a big-endian host it reads the high byte for the FDP enable bit and
the wrong byte for the configuration index, so FDP can be skipped or
configured using the wrong descriptor.
Read the result into a u32 and extract the enable bit and configuration
index from the dword. Remove the now-unused result structure.
Fixes: 30b5f20bb2dd ("nvme: register fdp parameters with the block layer")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
Changes in v2:
- Remove struct nvme_fdp_config now that its only user is gone (Christoph).
The v1 QEMU test used an emulated FDP target over nvme-loop. On s390x
the namespace gained one write stream after the fix. On x86_64 it had
one stream with and without the fix. The core.c change is unchanged.
v1: https://lore.kernel.org/r/202611150127572887TC7vHzVUFLZ6nyW1NuhU@zte.com.cn
drivers/nvme/host/core.c | 6 +++---
include/linux/nvme.h | 6 +-----
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f43582e5f6c4a989669f8a92343467932a80b820..eddad69a4abee0322111fd8784898a658cb42bf6 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2339,8 +2339,8 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
struct nvme_ns_head *head = ns->head;
struct nvme_ctrl *ctrl = ns->ctrl;
struct nvme_fdp_ruh_status *ruhs;
- struct nvme_fdp_config fdp;
struct nvme_command c = {};
+ u32 fdp;
size_t size;
int i, ret;
@@ -2351,10 +2351,10 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
return ret;
}
- if (!(fdp.flags & FDPCFG_FDPE))
+ if (!(fdp & FDPCFG_FDPE))
return 0;
- ret = nvme_query_fdp_granularity(ctrl, info, fdp.fdpcidx);
+ ret = nvme_query_fdp_granularity(ctrl, info, (fdp >> 8) & 0xff);
if (!info->runs)
return ret;
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 6248711784b37030e82c8a1ff8579c2d669da0ba..a75f3e5f6210792348d34bdba38b20a24e54202e 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -701,12 +701,8 @@ struct nvme_rotational_media_log {
__u8 rsvd24[488];
};
-struct nvme_fdp_config {
- __u8 flags;
+/* FDP Get Features result (completion dword 0). */
#define FDPCFG_FDPE (1U << 0)
- __u8 fdpcidx;
- __le16 reserved;
-};
struct nvme_fdp_ruh_desc {
__u8 ruht;
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-25 5:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 14:48 [PATCH v2 0/2] nvme: ZNS append limit and FDP feature decoding shao.mingyin
2026-11-22 14:48 ` [PATCH v2 1/2] nvme: zns: reject an out-of-range zone append size limit shao.mingyin
2026-11-25 5:24 ` Christoph Hellwig
2026-11-22 14:48 ` [PATCH v2 2/2] nvme: decode the FDP Get Features result as a dword shao.mingyin
2026-11-25 5:24 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox