mbox.c (48dcdbb16e5dc0947f949ce17bc2d09a625a0d5c) | mbox.c (180ffd338c35057c3e8521d55555ae3b36b67fa6) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* Copyright(c) 2020 Intel Corporation. All rights reserved. */ 3#include <linux/security.h> 4#include <linux/debugfs.h> 5#include <linux/ktime.h> 6#include <linux/mutex.h> 7#include <asm/unaligned.h> 8#include <cxlpci.h> --- 1088 unchanged lines hidden (view full) --- 1097 } out; 1098 struct cxl_mbox_cmd sec_cmd = { 1099 .opcode = CXL_MBOX_OP_GET_SECURITY_STATE, 1100 .payload_out = &out, 1101 .size_out = sizeof(out), 1102 }; 1103 struct cxl_mbox_cmd mbox_cmd = { .opcode = cmd }; 1104 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* Copyright(c) 2020 Intel Corporation. All rights reserved. */ 3#include <linux/security.h> 4#include <linux/debugfs.h> 5#include <linux/ktime.h> 6#include <linux/mutex.h> 7#include <asm/unaligned.h> 8#include <cxlpci.h> --- 1088 unchanged lines hidden (view full) --- 1097 } out; 1098 struct cxl_mbox_cmd sec_cmd = { 1099 .opcode = CXL_MBOX_OP_GET_SECURITY_STATE, 1100 .payload_out = &out, 1101 .size_out = sizeof(out), 1102 }; 1103 struct cxl_mbox_cmd mbox_cmd = { .opcode = cmd }; 1104 |
1105 if (cmd != CXL_MBOX_OP_SANITIZE) | 1105 if (cmd != CXL_MBOX_OP_SANITIZE && cmd != CXL_MBOX_OP_SECURE_ERASE) |
1106 return -EINVAL; 1107 1108 rc = cxl_internal_send_cmd(cxlds, &sec_cmd); 1109 if (rc < 0) { 1110 dev_err(cxlds->dev, "Failed to get security state : %d", rc); 1111 return rc; 1112 } 1113 1114 /* 1115 * Prior to using these commands, any security applied to 1116 * the user data areas of the device shall be DISABLED (or 1117 * UNLOCKED for secure erase case). 1118 */ 1119 sec_out = le32_to_cpu(out.flags); 1120 if (sec_out & CXL_PMEM_SEC_STATE_USER_PASS_SET) 1121 return -EINVAL; 1122 | 1106 return -EINVAL; 1107 1108 rc = cxl_internal_send_cmd(cxlds, &sec_cmd); 1109 if (rc < 0) { 1110 dev_err(cxlds->dev, "Failed to get security state : %d", rc); 1111 return rc; 1112 } 1113 1114 /* 1115 * Prior to using these commands, any security applied to 1116 * the user data areas of the device shall be DISABLED (or 1117 * UNLOCKED for secure erase case). 1118 */ 1119 sec_out = le32_to_cpu(out.flags); 1120 if (sec_out & CXL_PMEM_SEC_STATE_USER_PASS_SET) 1121 return -EINVAL; 1122 |
1123 if (cmd == CXL_MBOX_OP_SECURE_ERASE && 1124 sec_out & CXL_PMEM_SEC_STATE_LOCKED) 1125 return -EINVAL; 1126 |
|
1123 rc = cxl_internal_send_cmd(cxlds, &mbox_cmd); 1124 if (rc < 0) { 1125 dev_err(cxlds->dev, "Failed to sanitize device : %d", rc); 1126 return rc; 1127 } 1128 1129 return 0; 1130} --- 201 unchanged lines hidden --- | 1127 rc = cxl_internal_send_cmd(cxlds, &mbox_cmd); 1128 if (rc < 0) { 1129 dev_err(cxlds->dev, "Failed to sanitize device : %d", rc); 1130 return rc; 1131 } 1132 1133 return 0; 1134} --- 201 unchanged lines hidden --- |