diff options
author | Dave Jiang <dave.jiang@intel.com> | 2022-11-30 20:22:16 +0100 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2022-12-01 21:42:35 +0100 |
commit | 410926e9d79b4aba516a6677f88e0c35cbbd5b04 (patch) | |
tree | 38b1ad55740f327067391c06e0a1041c3bf3e12d /tools/testing/cxl/test | |
parent | cxl/pmem: Add "Freeze Security State" security command support (diff) | |
download | linux-410926e9d79b4aba516a6677f88e0c35cbbd5b04.tar.xz linux-410926e9d79b4aba516a6677f88e0c35cbbd5b04.zip |
tools/testing/cxl: Add "Freeze Security State" security opcode support
Add support to emulate a CXL mem device support the "Freeze Security State"
operation.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/166983613604.2734609.1960672960407811362.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'tools/testing/cxl/test')
-rw-r--r-- | tools/testing/cxl/test/mem.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c index 77774a951a81..45c6e6d3cfbb 100644 --- a/tools/testing/cxl/test/mem.c +++ b/tools/testing/cxl/test/mem.c @@ -314,6 +314,23 @@ static int mock_disable_passphrase(struct cxl_dev_state *cxlds, struct cxl_mbox_ return 0; } +static int mock_freeze_security(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) +{ + struct cxl_mock_mem_pdata *mdata = dev_get_platdata(cxlds->dev); + + if (cmd->size_in != 0) + return -EINVAL; + + if (cmd->size_out != 0) + return -EINVAL; + + if (mdata->security_state & CXL_PMEM_SEC_STATE_FROZEN) + return 0; + + mdata->security_state |= CXL_PMEM_SEC_STATE_FROZEN; + return 0; +} + static int mock_get_lsa(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) { struct cxl_mbox_get_lsa *get_lsa = cmd->payload_in; @@ -418,6 +435,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd * case CXL_MBOX_OP_DISABLE_PASSPHRASE: rc = mock_disable_passphrase(cxlds, cmd); break; + case CXL_MBOX_OP_FREEZE_SECURITY: + rc = mock_freeze_security(cxlds, cmd); + break; default: break; } |