Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Guixin Liu <kanie@linux.alibaba.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Nilay Shroff <nilay@linux.ibm.com>,
	Daniel Wagner <dwagner@suse.de>, Hannes Reinecke <hare@suse.de>
Cc: linux-nvme@lists.infradead.org
Subject: [PATCH 2/4] nvme: trace the Set Features Save bit from the right position
Date: Tue,  1 Dec 2026 19:53:43 +0800	[thread overview]
Message-ID: <20261201115345.2349875-3-kanie@linux.alibaba.com> (raw)
In-Reply-To: <20261201115345.2349875-1-kanie@linux.alibaba.com>

The Save (SV) bit of Set Features is CDW10 bit 31. The trace parser
masks byte 3 of CDW10 with 0x8, which selects the reserved bit 27
instead, so the trace shows sv=0 for commands that save the feature
and a nonzero sv when a reserved bit is set.

Mask with 0x80 instead.

Fixes: a7b5e8d864b3 ("nvme: add set feature tracing support")
Cc: stable@vger.kernel.org
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---

Reproduced in a QEMU/KVM guest with nvmet-tcp loopback: send Set
Features (fid 0x0b) via NVME_IOCTL_ADMIN_CMD with CDW10 0x8000000b,
0x0000000b and 0x0800000b, and read the nvme_setup_cmd tracepoint.
Unpatched: sv=0x0 for the SV-set command and sv=0x8 for the
reserved-bit command. Patched: sv=0x80 and sv=0x0; the plain command
stays sv=0x0. fid 0x07 is rejected unconditionally by
nvme_admin_cmd_allowed(), so the test uses 0x0b.
 drivers/nvme/host/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/trace.c b/drivers/nvme/host/trace.c
index ad25ad1e40412..699c577818925 100644
--- a/drivers/nvme/host/trace.c
+++ b/drivers/nvme/host/trace.c
@@ -77,7 +77,7 @@ static const char *nvme_trace_admin_set_features(struct trace_seq *p,
 {
 	const char *ret = trace_seq_buffer_ptr(p);
 	u8 fid = cdw10[0];
-	u8 sv = cdw10[3] & 0x8;
+	u8 sv = cdw10[3] & 0x80;
 	u32 cdw11 = get_unaligned_le32(cdw10 + 4);
 
 	trace_seq_printf(p, "fid=0x%x, sv=0x%x, cdw11=0x%x", fid, sv, cdw11);
-- 
2.43.7



  parent reply	other threads:[~2026-12-01 11:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 11:53 [PATCH 0/4] nvme: small fixes from a drivers/nvme audit Guixin Liu
2026-12-01 11:53 ` [PATCH 1/4] nvme: guard nvme_strlen() against all-space strings Guixin Liu
2026-12-02  6:32   ` Christoph Hellwig
2026-12-01 11:53 ` Guixin Liu [this message]
2026-12-02  6:32   ` [PATCH 2/4] nvme: trace the Set Features Save bit from the right position Christoph Hellwig
2026-12-01 11:53 ` [PATCH 3/4] nvmet-fc: clear the DMA address of the fod that failed mapping Guixin Liu
2026-12-02  6:32   ` Christoph Hellwig
2026-12-01 11:53 ` [PATCH 4/4] nvme-fcloop: initialize port structures before publishing them Guixin Liu
2026-12-02  6:33   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201115345.2349875-3-kanie@linux.alibaba.com \
    --to=kanie@linux.alibaba.com \
    --cc=axboe@kernel.dk \
    --cc=dwagner@suse.de \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=nilay@linux.ibm.com \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox