Skip to content

Commit c5c3921

Browse files
Davidlohr Buesodjbw
authored andcommitted
cxl/test: Add Sanitize opcode support
Add support to emulate the "Sanitize" operation, without incurring in the background. Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> Link: https://lore.kernel.org/r/20230612181038.14421-6-dave@stgolabs.net Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 48dcdbb commit c5c3921

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

  • tools/testing/cxl/test

tools/testing/cxl/test/mem.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,28 @@ static int mock_partition_info(struct cxl_dev_state *cxlds,
535535
return 0;
536536
}
537537

538+
static int mock_sanitize(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
539+
{
540+
struct cxl_mockmem_data *mdata = dev_get_drvdata(cxlds->dev);
541+
542+
if (cmd->size_in != 0)
543+
return -EINVAL;
544+
545+
if (cmd->size_out != 0)
546+
return -EINVAL;
547+
548+
if (mdata->security_state & CXL_PMEM_SEC_STATE_USER_PASS_SET) {
549+
cmd->return_code = CXL_MBOX_CMD_RC_SECURITY;
550+
return -ENXIO;
551+
}
552+
if (mdata->security_state & CXL_PMEM_SEC_STATE_LOCKED) {
553+
cmd->return_code = CXL_MBOX_CMD_RC_SECURITY;
554+
return -ENXIO;
555+
}
556+
557+
return 0; /* assume less than 2 secs, no bg */
558+
}
559+
538560
static int mock_get_security_state(struct cxl_dev_state *cxlds,
539561
struct cxl_mbox_cmd *cmd)
540562
{
@@ -1153,6 +1175,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *
11531175
case CXL_MBOX_OP_GET_HEALTH_INFO:
11541176
rc = mock_health_info(cxlds, cmd);
11551177
break;
1178+
case CXL_MBOX_OP_SANITIZE:
1179+
rc = mock_sanitize(cxlds, cmd);
1180+
break;
11561181
case CXL_MBOX_OP_GET_SECURITY_STATE:
11571182
rc = mock_get_security_state(cxlds, cmd);
11581183
break;

0 commit comments

Comments
 (0)