From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A0B0C77B7F for ; Thu, 11 May 2023 15:11:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237939AbjEKPK7 (ORCPT ); Thu, 11 May 2023 11:10:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238220AbjEKPK6 (ORCPT ); Thu, 11 May 2023 11:10:58 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E6E52105 for ; Thu, 11 May 2023 08:10:55 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4QHFgg2CQqz6D8f3; Thu, 11 May 2023 23:10:07 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 11 May 2023 16:10:52 +0100 Date: Thu, 11 May 2023 16:10:52 +0100 From: Jonathan Cameron To: Davidlohr Bueso CC: , , , , , , , Subject: Re: [PATCH 7/7] cxl/test: Add Secure Erase opcode support Message-ID: <20230511161052.000003fb@Huawei.com> In-Reply-To: <20230421092321.12741-8-dave@stgolabs.net> References: <20230421092321.12741-1-dave@stgolabs.net> <20230421092321.12741-8-dave@stgolabs.net> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml500001.china.huawei.com (7.191.163.213) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org On Fri, 21 Apr 2023 02:23:21 -0700 Davidlohr Bueso wrote: > Add support to emulate the CXL the "Secure Erase" operation. > > Reviewed-by: Dave Jiang > Signed-off-by: Davidlohr Bueso LGTM Reviewed-by: Jonathan Cameron > --- > tools/testing/cxl/test/mem.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c > index d4466cb27947..8a22a4e592c6 100644 > --- a/tools/testing/cxl/test/mem.c > +++ b/tools/testing/cxl/test/mem.c > @@ -519,6 +519,30 @@ static int mock_sanitize(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) > return 0; /* assume less than 2 secs, no bg */ > } > > +static int mock_secure_erase(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; > +} > + > static int mock_get_security_state(struct cxl_dev_state *cxlds, > struct cxl_mbox_cmd *cmd) > { > @@ -949,6 +973,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd * > case CXL_MBOX_OP_SANITIZE: > rc = mock_sanitize(cxlds, cmd); > break; > + case CXL_MBOX_OP_SECURE_ERASE: > + rc = mock_secure_erase(cxlds, cmd); > + break; > case CXL_MBOX_OP_GET_SECURITY_STATE: > rc = mock_get_security_state(cxlds, cmd); > break;