public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>
Cc: <thomas.lendacky@amd.com>, <john.allen@amd.com>,
	<linux-crypto@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<Rijo-john.Thomas@amd.com>,
	Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH 2/5] crypto: ccp: Add support for extended PSP mailbox commands
Date: Thu, 7 Sep 2023 13:48:43 -0500	[thread overview]
Message-ID: <20230907184846.47598-3-mario.limonciello@amd.com> (raw)
In-Reply-To: <20230907184846.47598-1-mario.limonciello@amd.com>

The PSP mailbox supports a number of extended sub-commands.  These
subcommands are placed in the header of the buffer sent to the mailbox.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/crypto/ccp/psp-dev.c | 24 ++++++++++++++++++++++++
 drivers/crypto/ccp/psp-dev.h | 21 +++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
index 3258c4612e14..f9f3b3404f87 100644
--- a/drivers/crypto/ccp/psp-dev.c
+++ b/drivers/crypto/ccp/psp-dev.c
@@ -78,6 +78,30 @@ int psp_mailbox_command(struct psp_device *psp, enum psp_cmd cmd, void *cmdbuff,
 	return ret;
 }
 
+int psp_extended_mailbox_cmd(struct psp_device *psp, unsigned int timeout_msecs,
+			     struct psp_ext_request *req)
+{
+	unsigned int reg;
+	int ret;
+
+	print_hex_dump_debug("->psp ", DUMP_PREFIX_OFFSET, 16, 2, req,
+			     req->header.payload_size, false);
+
+	ret = psp_mailbox_command(psp, PSP_CMD_TEE_EXTENDED_CMD, (void *)req,
+				  timeout_msecs, &reg);
+	if (ret) {
+		return ret;
+	} else if (FIELD_GET(PSP_CMDRESP_STS, reg)) {
+		req->header.status = FIELD_GET(PSP_CMDRESP_STS, reg);
+		return -EIO;
+	}
+
+	print_hex_dump_debug("<-psp ", DUMP_PREFIX_OFFSET, 16, 2, req,
+			     req->header.payload_size, false);
+
+	return 0;
+}
+
 static struct psp_device *psp_alloc_struct(struct sp_device *sp)
 {
 	struct device *dev = sp->dev;
diff --git a/drivers/crypto/ccp/psp-dev.h b/drivers/crypto/ccp/psp-dev.h
index d917657c6085..396a80d846c0 100644
--- a/drivers/crypto/ccp/psp-dev.h
+++ b/drivers/crypto/ccp/psp-dev.h
@@ -78,15 +78,36 @@ struct psp_device *psp_get_master_device(void);
  * enum psp_cmd - PSP mailbox commands
  * @PSP_CMD_TEE_RING_INIT:	Initialize TEE ring buffer
  * @PSP_CMD_TEE_RING_DESTROY:	Destroy TEE ring buffer
+ * @PSP_CMD_TEE_EXTENDED_CMD:	Extended command
  * @PSP_CMD_MAX:		Maximum command id
  */
 enum psp_cmd {
 	PSP_CMD_TEE_RING_INIT		= 1,
 	PSP_CMD_TEE_RING_DESTROY	= 2,
+	PSP_CMD_TEE_EXTENDED_CMD	= 14,
 	PSP_CMD_MAX			= 15,
 };
 
 int psp_mailbox_command(struct psp_device *psp, enum psp_cmd cmd, void *cmdbuff,
 			unsigned int timeout_msecs, unsigned int *cmdresp);
 
+/**
+ * struct psp_ext_req_buffer_hdr - Structure of the extended command header
+ * @payload_size: total payload size
+ * @sub_cmd_id: extended command ID
+ * @status: status of command execution (out)
+ */
+struct psp_ext_req_buffer_hdr {
+	u32 payload_size;
+	u32 sub_cmd_id;
+	u32 status;
+} __packed;
+
+struct psp_ext_request {
+	struct psp_ext_req_buffer_hdr header;
+	void *buf;
+} __packed;
+
+int psp_extended_mailbox_cmd(struct psp_device *psp, unsigned int timeout_msecs,
+			     struct psp_ext_request *req);
 #endif /* __PSP_DEV_H */
-- 
2.34.1


  parent reply	other threads:[~2023-09-07 18:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07 18:48 [PATCH 0/5] Add new platform support for DBC Mario Limonciello
2023-09-07 18:48 ` [PATCH 1/5] crypto: ccp: Move direct access to some PSP registers out of TEE Mario Limonciello
2023-09-14  7:18   ` Rijo Thomas
2023-09-07 18:48 ` Mario Limonciello [this message]
2023-09-07 18:48 ` [PATCH 3/5] crypto: ccp: Add a communication path abstraction for DBC Mario Limonciello
2023-09-07 18:48 ` [PATCH 4/5] crypto: ccp: Add a macro to check capabilities register Mario Limonciello
2023-09-07 18:48 ` [PATCH 5/5] crypto: ccp: Add support for DBC over PSP mailbox Mario Limonciello
2023-09-07 21:28 ` [PATCH 0/5] Add new platform support for DBC Tom Lendacky
2023-09-14  8:38   ` Rijo Thomas
2023-09-15 10:45 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230907184846.47598-3-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Rijo-john.Thomas@amd.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=john.allen@amd.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas.lendacky@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox