Commit c5c39217 authored by Davidlohr Bueso's avatar Davidlohr Bueso Committed by Dan Williams

cxl/test: Add Sanitize opcode support

Add support to emulate the "Sanitize" operation, without
incurring in the background.
Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarDavidlohr Bueso <dave@stgolabs.net>
Link: https://lore.kernel.org/r/20230612181038.14421-6-dave@stgolabs.netSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 48dcdbb1
...@@ -535,6 +535,28 @@ static int mock_partition_info(struct cxl_dev_state *cxlds, ...@@ -535,6 +535,28 @@ static int mock_partition_info(struct cxl_dev_state *cxlds,
return 0; return 0;
} }
static int mock_sanitize(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
{
struct cxl_mockmem_data *mdata = dev_get_drvdata(cxlds->dev);
if (cmd->size_in != 0)
return -EINVAL;
if (cmd->size_out != 0)
return -EINVAL;
if (mdata->security_state & CXL_PMEM_SEC_STATE_USER_PASS_SET) {
cmd->return_code = CXL_MBOX_CMD_RC_SECURITY;
return -ENXIO;
}
if (mdata->security_state & CXL_PMEM_SEC_STATE_LOCKED) {
cmd->return_code = CXL_MBOX_CMD_RC_SECURITY;
return -ENXIO;
}
return 0; /* assume less than 2 secs, no bg */
}
static int mock_get_security_state(struct cxl_dev_state *cxlds, static int mock_get_security_state(struct cxl_dev_state *cxlds,
struct cxl_mbox_cmd *cmd) struct cxl_mbox_cmd *cmd)
{ {
...@@ -1153,6 +1175,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd * ...@@ -1153,6 +1175,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *
case CXL_MBOX_OP_GET_HEALTH_INFO: case CXL_MBOX_OP_GET_HEALTH_INFO:
rc = mock_health_info(cxlds, cmd); rc = mock_health_info(cxlds, cmd);
break; break;
case CXL_MBOX_OP_SANITIZE:
rc = mock_sanitize(cxlds, cmd);
break;
case CXL_MBOX_OP_GET_SECURITY_STATE: case CXL_MBOX_OP_GET_SECURITY_STATE:
rc = mock_get_security_state(cxlds, cmd); rc = mock_get_security_state(cxlds, cmd);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment