nvme/core: Check for Security send/recv support before issuing commands.
PATCH 1/1 nvme/core: Check for Security send/recv support before issuing commands.
We need to verify that the controller supports the security commands before actually trying to issue them.
--- drivers/nvme/host/core.c | 4 ++++ drivers/nvme/host/nvme.h | 1 + include/linux/nvme.h | 1 + 3 files changed, 6 insertions(+)
drivers/nvme/host/core.c +4 -0
@@ -1091,6 +1091,9 @@ int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,struct nvme_ctrl *ctrl = data;struct nvme_command cmd; +if (!(ctrl->oacs &NVME_CTRL_SEC_SEND_RECV_SUPP )) +return -EOPNOTSUPP ; +memset (&cmd,0 ,sizeof (cmd));if (send) cmd.common.opcode = nvme_admin_security_send;
@@ -1285,6 +1288,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)return -EIO ; } + ctrl->oacs =le16_to_cpu (id->oacs); ctrl->vid =le16_to_cpu (id->vid); ctrl->oncs =le16_to_cpup (&id->oncs);atomic_set (&ctrl->abort_limit, id->acl +1 );
drivers/nvme/host/nvme.h +1 -0
@@ -140,6 +140,7 @@ struct nvme_ctrl {u32 max_hw_sectors;u16 oncs;u16 vid; +u16 oacs;atomic_t abort_limit;u8 event_limit;u8 vwc;
include/linux/nvme.h +1 -0
@@ -244,6 +244,7 @@ enum {NVME_CTRL_ONCS_DSM =1 <<2 ,NVME_CTRL_ONCS_WRITE_ZEROES =1 <<3 ,NVME_CTRL_VWC_PRESENT =1 <<0 , + NVME_CTRL_SEC_SEND_RECV_SUPP = 1 << 0, }; struct nvme_lbaf {
Signature · 1 line
2.7.4
PATCH 1/1 nvme/core: Check for Security send/recv support before issuing commands.
Quoted 15 lines · Scott Bauer
We need to verify that the controller supports the security commands before actually trying to issue them.
Signed-off-by Scott Bauer <scott.bauer at intel.com>--- drivers/nvme/host/core.c | 4 ++++ drivers/nvme/host/nvme.h | 1 + include/linux/nvme.h | 1 + 3 files changed, 6 insertions(+)drivers/nvme/host/core.c +0
-0
drivers/nvme/host/core.c int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len, · line 1096
Quoted 6 lines
drivers/nvme/host/core.c +3
-0@@ -1091,6 +1091,9 @@ int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,struct nvme_ctrl *ctrl = data;struct nvme_command cmd; +if (!(ctrl->oacs &NVME_CTRL_SEC_SEND_RECV_SUPP )) +return -EOPNOTSUPP ; +
Can we move this to check_opal_support so it's not called every time?
Quoted 28 lines
drivers/nvme/host/core.c +1
-0memset (&cmd,0 ,sizeof (cmd));if (send) cmd.common.opcode = nvme_admin_security_send;@@ -1285,6 +1288,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)return -EIO ; } + ctrl->oacs =le16_to_cpu (id->oacs); ctrl->vid =le16_to_cpu (id->vid); ctrl->oncs =le16_to_cpup (&id->oncs);atomic_set (&ctrl->abort_limit, id->acl +1 );drivers/nvme/host/nvme.h +1
-0@@ -140,6 +140,7 @@ struct nvme_ctrl {u32 max_hw_sectors;u16 oncs;u16 vid; +u16 oacs;atomic_t abort_limit;u8 event_limit;u8 vwc;include/linux/nvme.h +0
-0
include/linux/nvme.h enum { · line 247
Quoted 4 lines
include/linux/nvme.h +1
-0@@ -244,6 +244,7 @@ enum {NVME_CTRL_ONCS_DSM =1 <<2 ,NVME_CTRL_ONCS_WRITE_ZEROES =1 <<3 ,NVME_CTRL_VWC_PRESENT =1 <<0 , + NVME_CTRL_SEC_SEND_RECV_SUPP = 1 << 0,
This should include the register alias, likeNVME_CTRL_OACS_SEC_SUPP or similar
Quoted 4 lines
include/linux/nvme.h +0
-0};struct nvme_lbaf {
PATCH 1/1 nvme/core: Check for Security send/recv support before issuing commands.
Quoted 19 lines · Jon Derrick
Quoted 18 lines · Scott Bauer
We need to verify that the controller supports the security commands before actually trying to issue them.
Signed-off-by Scott Bauer <scott.bauer at intel.com>--- drivers/nvme/host/core.c | 4 ++++ drivers/nvme/host/nvme.h | 1 + include/linux/nvme.h | 1 + 3 files changed, 6 insertions(+)drivers/nvme/host/core.c +0
-0@@ -1091,6 +1091,9 @@ int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,struct nvme_ctrl *ctrl = data;struct nvme_command cmd;
Quoted 4 lines
drivers/nvme/host/core.c int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len, · line 1096
Quoted 3 lines
drivers/nvme/host/core.c +3
-0+if (!(ctrl->oacs &NVME_CTRL_SEC_SEND_RECV_SUPP )) +return -EOPNOTSUPP ; +Can we move this to
check_opal_supportso it's not called every time?
Nevermind. Realized that is in generic code. This is fine
Quoted 44 lines
Quoted 30 lines
drivers/nvme/host/core.c +1
-0memset (&cmd,0 ,sizeof (cmd));if (send) cmd.common.opcode = nvme_admin_security_send;@@ -1285,6 +1288,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)return -EIO ; } + ctrl->oacs =le16_to_cpu (id->oacs); ctrl->vid =le16_to_cpu (id->vid); ctrl->oncs =le16_to_cpup (&id->oncs);atomic_set (&ctrl->abort_limit, id->acl +1 );drivers/nvme/host/nvme.h +1
-0@@ -140,6 +140,7 @@ struct nvme_ctrl {u32 max_hw_sectors;u16 oncs;u16 vid; +u16 oacs;atomic_t abort_limit;u8 event_limit;u8 vwc;include/linux/nvme.h +0
-0include/linux/nvme.h enum { · line 247
Quoted 4 lines
include/linux/nvme.h +1
-0@@ -244,6 +244,7 @@ enum {NVME_CTRL_ONCS_DSM =1 <<2 ,NVME_CTRL_ONCS_WRITE_ZEROES =1 <<3 ,NVME_CTRL_VWC_PRESENT =1 <<0 , + NVME_CTRL_SEC_SEND_RECV_SUPP = 1 << 0,This should include the register alias, like
NVME_CTRL_OACS_SEC_SUPPor similarQuoted 4 lines
include/linux/nvme.h +0
-0};struct nvme_lbaf {