From: Mario Limonciello <mario.limonciello@amd.com>
To: Tom Lendacky <thomas.lendacky@amd.com>,
John Allen <john.allen@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S . Miller" <davem@davemloft.net>
Cc: open list <linux-kernel@vger.kernel.org>,
"open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER"
<linux-crypto@vger.kernel.org>,
Kerneis Gabriel <Gabriel.Kerneis@ssi.gouv.fr>,
Richard Hughes <hughsient@gmail.com>,
"Mario Limonciello" <mario.limonciello@amd.com>
Subject: [PATCH v3 1/4] crypto: ccp: cache capability into psp device
Date: Thu, 31 Mar 2022 16:12:10 -0500 [thread overview]
Message-ID: <20220331211213.2844-2-mario.limonciello@amd.com> (raw)
In-Reply-To: <20220331211213.2844-1-mario.limonciello@amd.com>
The results of the capability register will be used by future
code at runtime rather than just initialization.
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v2->v3:
* Add Tom's tag
---
drivers/crypto/ccp/psp-dev.c | 37 +++++++++++++++++-------------------
drivers/crypto/ccp/psp-dev.h | 5 +++++
2 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
index ae7b44599914..8cd404121cd5 100644
--- a/drivers/crypto/ccp/psp-dev.c
+++ b/drivers/crypto/ccp/psp-dev.c
@@ -70,17 +70,17 @@ static unsigned int psp_get_capability(struct psp_device *psp)
*/
if (val == 0xffffffff) {
dev_notice(psp->dev, "psp: unable to access the device: you might be running a broken BIOS.\n");
- return 0;
+ return -ENODEV;
}
+ psp->capability = val;
- return val;
+ return 0;
}
-static int psp_check_sev_support(struct psp_device *psp,
- unsigned int capability)
+static int psp_check_sev_support(struct psp_device *psp)
{
/* Check if device supports SEV feature */
- if (!(capability & 1)) {
+ if (!(psp->capability & PSP_CAPABILITY_SEV)) {
dev_dbg(psp->dev, "psp does not support SEV\n");
return -ENODEV;
}
@@ -88,11 +88,10 @@ static int psp_check_sev_support(struct psp_device *psp,
return 0;
}
-static int psp_check_tee_support(struct psp_device *psp,
- unsigned int capability)
+static int psp_check_tee_support(struct psp_device *psp)
{
/* Check if device supports TEE feature */
- if (!(capability & 2)) {
+ if (!(psp->capability & PSP_CAPABILITY_TEE)) {
dev_dbg(psp->dev, "psp does not support TEE\n");
return -ENODEV;
}
@@ -100,11 +99,10 @@ static int psp_check_tee_support(struct psp_device *psp,
return 0;
}
-static int psp_check_support(struct psp_device *psp,
- unsigned int capability)
+static int psp_check_support(struct psp_device *psp)
{
- int sev_support = psp_check_sev_support(psp, capability);
- int tee_support = psp_check_tee_support(psp, capability);
+ int sev_support = psp_check_sev_support(psp);
+ int tee_support = psp_check_tee_support(psp);
/* Return error if device neither supports SEV nor TEE */
if (sev_support && tee_support)
@@ -113,17 +111,17 @@ static int psp_check_support(struct psp_device *psp,
return 0;
}
-static int psp_init(struct psp_device *psp, unsigned int capability)
+static int psp_init(struct psp_device *psp)
{
int ret;
- if (!psp_check_sev_support(psp, capability)) {
+ if (!psp_check_sev_support(psp)) {
ret = sev_dev_init(psp);
if (ret)
return ret;
}
- if (!psp_check_tee_support(psp, capability)) {
+ if (!psp_check_tee_support(psp)) {
ret = tee_dev_init(psp);
if (ret)
return ret;
@@ -136,7 +134,6 @@ int psp_dev_init(struct sp_device *sp)
{
struct device *dev = sp->dev;
struct psp_device *psp;
- unsigned int capability;
int ret;
ret = -ENOMEM;
@@ -155,11 +152,11 @@ int psp_dev_init(struct sp_device *sp)
psp->io_regs = sp->io_map;
- capability = psp_get_capability(psp);
- if (!capability)
+ ret = psp_get_capability(psp);
+ if (ret)
goto e_disable;
- ret = psp_check_support(psp, capability);
+ ret = psp_check_support(psp);
if (ret)
goto e_disable;
@@ -174,7 +171,7 @@ int psp_dev_init(struct sp_device *sp)
goto e_err;
}
- ret = psp_init(psp, capability);
+ ret = psp_init(psp);
if (ret)
goto e_irq;
diff --git a/drivers/crypto/ccp/psp-dev.h b/drivers/crypto/ccp/psp-dev.h
index ef38e4135d81..d811da28cce6 100644
--- a/drivers/crypto/ccp/psp-dev.h
+++ b/drivers/crypto/ccp/psp-dev.h
@@ -45,6 +45,8 @@ struct psp_device {
void *sev_data;
void *tee_data;
+
+ unsigned int capability;
};
void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler,
@@ -57,4 +59,7 @@ void psp_clear_tee_irq_handler(struct psp_device *psp);
struct psp_device *psp_get_master_device(void);
+#define PSP_CAPABILITY_SEV BIT(0)
+#define PSP_CAPABILITY_TEE BIT(1)
+
#endif /* __PSP_DEV_H */
--
2.34.1
next prev parent reply other threads:[~2022-03-31 21:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-31 21:12 [PATCH v3 0/4] Export PSP security attributes Mario Limonciello
2022-03-31 21:12 ` Mario Limonciello [this message]
2022-03-31 21:12 ` [PATCH v3 2/4] crypto: ccp: Export PSP security bits to userspace Mario Limonciello
2022-03-31 21:12 ` [PATCH v3 3/4] crypto: ccp: Allow PSP driver to load without SEV/TEE support Mario Limonciello
2022-04-05 21:05 ` Tom Lendacky
2022-03-31 21:12 ` [PATCH v3 4/4] crypto: ccp: When TSME and SME both detected notify user Mario Limonciello
2022-04-05 21:06 ` Tom Lendacky
2022-04-08 8:32 ` [PATCH v3 0/4] Export PSP security attributes 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=20220331211213.2844-2-mario.limonciello@amd.com \
--to=mario.limonciello@amd.com \
--cc=Gabriel.Kerneis@ssi.gouv.fr \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=hughsient@gmail.com \
--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
all inboxes | Powered by JetHome®