All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>
Cc: Kanchan Joshi <joshi.k@samsung.com>, linux-nvme@lists.infradead.org
Subject: [PATCH 8/9] nvme: also return I/O command effects from nvme_command_effects
Date: Wed, 14 Dec 2022 17:13:46 +0100	[thread overview]
Message-ID: <20221214161347.764071-9-hch@lst.de> (raw)
In-Reply-To: <20221214161347.764071-1-hch@lst.de>

To be able to use the Commands Supported and Effects Log for allowing
unprivileged passtrough, it needs to be corretly reported for I/O
commands as well.  Return the I/O command effects from
nvme_command_effects, and also add a default list of effects for the
NVM command set.  For other command sets we do require the log page
to be present already.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 9529abe22c9cdb..c50678390def38 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1069,13 +1069,12 @@ u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode)
 		effects = le32_to_cpu(ns->head->effects->iocs[opcode]);
 		if (effects & ~(NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC))
 			dev_warn_once(ctrl->device,
-				"IO command:%02x has unhandled effects:%08x\n",
+				"IO command:%02x has unusual effects:%08x\n",
 				opcode, effects);
-		return 0;
+	} else {
+		effects = le32_to_cpu(ctrl->effects->acs[opcode]);
 	}
 
-	effects = le32_to_cpu(ctrl->effects->acs[opcode]);
-
 	/* only return actual command effects and not misc information */
 	return effects & (NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC |
 			  NVME_CMD_EFFECTS_NCC | NVME_CMD_EFFECTS_NIC |
@@ -3064,8 +3063,8 @@ static int nvme_init_effects(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 	}
 
 	/*
-	 * Initialize known admin command set effects for controllers don't
-	 * provide the log or are buggy enough to not correctly mark the
+	 * Initialize known admin and NVM command set effects for controllers
+	 * don't provide the log or are buggy enough to not correctly mark the
 	 * usual effects.
 	 */
 	ctrl->effects->acs[nvme_admin_format_nvm] |=
@@ -3073,6 +3072,13 @@ static int nvme_init_effects(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 			    NVME_CMD_EFFECTS_CSE_MASK);
 	ctrl->effects->acs[nvme_admin_sanitize_nvm] |=
 		cpu_to_le32(NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK);
+
+	ctrl->effects->iocs[nvme_cmd_write] |=
+		cpu_to_le32(NVME_CMD_EFFECTS_LBCC);
+	ctrl->effects->iocs[nvme_cmd_write_zeroes] |=
+		cpu_to_le32(NVME_CMD_EFFECTS_LBCC);
+	ctrl->effects->iocs[nvme_cmd_write_uncor] |=
+		cpu_to_le32(NVME_CMD_EFFECTS_LBCC);
 	return 0;
 }
 
-- 
2.35.1



  parent reply	other threads:[~2022-12-14 16:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 16:13 only allow unprivileged passthrough for commands without effects v2 Christoph Hellwig
2022-12-14 16:13 ` [PATCH 1/9] nvmet: use NVME_CMD_EFFECTS_CSUPP instead of open coding it Christoph Hellwig
2022-12-14 16:13 ` [PATCH 2/9] nvmet: set the LBCC bit for commands that modify data Christoph Hellwig
2022-12-14 16:13 ` [PATCH 3/9] nvme: remove nvme_execute_passthru_rq Christoph Hellwig
2022-12-14 16:13 ` [PATCH 4/9] nvmet: refactor passthru fixup code Christoph Hellwig
2022-12-14 16:13 ` [PATCH 5/9] nvmet: allow async passthrough of commands that change logical block contents Christoph Hellwig
2022-12-14 16:13 ` [PATCH 6/9] nvme: only return actual effects from nvme_command_effects Christoph Hellwig
2022-12-14 16:13 ` [PATCH 7/9] nvme: assign known effects at controller initialization time Christoph Hellwig
2022-12-14 16:34   ` Keith Busch
2022-12-15 13:15   ` Kanchan Joshi
2022-12-14 16:13 ` Christoph Hellwig [this message]
2022-12-14 16:13 ` [PATCH 9/9] nvme: don't allow unprivileged passthrough of commands that have effects Christoph Hellwig
2022-12-15  7:14   ` Kanchan Joshi
2022-12-15  8:18     ` Christoph Hellwig
2022-12-15  8:24       ` Kanchan Joshi
2022-12-15  8:37         ` Christoph Hellwig
2022-12-14 16:36 ` only allow unprivileged passthrough for commands without effects v2 Keith Busch

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=20221214161347.764071-9-hch@lst.de \
    --to=hch@lst.de \
    --cc=joshi.k@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=linux-nvme@lists.infradead.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.