mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
crypto: ccp - Add support for getting security attributes on some older systems
Older systems will not populate the security attributes in the capabilities register. The PSP on these systems, however, does have a command to get the security attributes. Use this command during ccp startup to populate the attributes if they're missing. Closes: https://github.com/fwupd/fwupd/issues/5284 Closes: https://github.com/fwupd/fwupd/issues/5675 Closes: https://github.com/fwupd/fwupd/issues/6253 Closes: https://github.com/fwupd/fwupd/issues/7280 Closes: https://github.com/fwupd/fwupd/issues/6323 Closes: https://github.com/fwupd/fwupd/discussions/5433 Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
b4100947a8
commit
82f9327f77
@ -12,6 +12,13 @@
|
||||
#include "psp-dev.h"
|
||||
#include "hsti.h"
|
||||
|
||||
#define PSP_CAPABILITY_PSP_SECURITY_OFFSET 8
|
||||
|
||||
struct hsti_request {
|
||||
struct psp_req_buffer_hdr header;
|
||||
u32 hsti;
|
||||
} __packed;
|
||||
|
||||
#define security_attribute_show(name) \
|
||||
static ssize_t name##_show(struct device *d, struct device_attribute *attr, \
|
||||
char *buf) \
|
||||
@ -66,3 +73,51 @@ struct attribute_group psp_security_attr_group = {
|
||||
.attrs = psp_security_attrs,
|
||||
.is_visible = psp_security_is_visible,
|
||||
};
|
||||
|
||||
static int psp_poulate_hsti(struct psp_device *psp)
|
||||
{
|
||||
struct hsti_request *req;
|
||||
int ret;
|
||||
|
||||
/* Are the security attributes already reported? */
|
||||
if (psp->capability.security_reporting)
|
||||
return 0;
|
||||
|
||||
/* Allocate command-response buffer */
|
||||
req = kzalloc(sizeof(*req), GFP_KERNEL | __GFP_ZERO);
|
||||
if (!req)
|
||||
return -ENOMEM;
|
||||
|
||||
req->header.payload_size = sizeof(req);
|
||||
|
||||
ret = psp_send_platform_access_msg(PSP_CMD_HSTI_QUERY, (struct psp_request *)req);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (req->header.status != 0) {
|
||||
dev_dbg(psp->dev, "failed to populate HSTI state: %d\n", req->header.status);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
psp->capability.security_reporting = 1;
|
||||
psp->capability.raw |= req->hsti << PSP_CAPABILITY_PSP_SECURITY_OFFSET;
|
||||
|
||||
out:
|
||||
kfree(req);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int psp_init_hsti(struct psp_device *psp)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (PSP_FEATURE(psp, HSTI)) {
|
||||
ret = psp_poulate_hsti(psp);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,4 +12,6 @@
|
||||
|
||||
extern struct attribute_group psp_security_attr_group;
|
||||
|
||||
int psp_init_hsti(struct psp_device *psp);
|
||||
|
||||
#endif /* __HSTI_H */
|
||||
|
@ -220,6 +220,11 @@ static int psp_init(struct psp_device *psp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* HSTI uses platform access on some systems. */
|
||||
ret = psp_init_hsti(psp);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,6 @@ void psp_clear_sev_irq_handler(struct psp_device *psp);
|
||||
|
||||
struct psp_device *psp_get_master_device(void);
|
||||
|
||||
#define PSP_CAPABILITY_PSP_SECURITY_OFFSET 8
|
||||
|
||||
/**
|
||||
* enum psp_cmd - PSP mailbox commands
|
||||
* @PSP_CMD_TEE_RING_INIT: Initialize TEE ring buffer
|
||||
|
@ -29,6 +29,7 @@
|
||||
#define CACHE_WB_NO_ALLOC 0xb7
|
||||
|
||||
#define PLATFORM_FEATURE_DBC 0x1
|
||||
#define PLATFORM_FEATURE_HSTI 0x2
|
||||
|
||||
#define PSP_FEATURE(psp, feat) (psp->vdata && psp->vdata->platform_features & PLATFORM_FEATURE_##feat)
|
||||
|
||||
|
@ -397,10 +397,12 @@ static const struct psp_vdata pspv1 = {
|
||||
|
||||
static const struct psp_vdata pspv2 = {
|
||||
.sev = &sevv2,
|
||||
.platform_access = &pa_v1,
|
||||
.bootloader_info_reg = 0x109ec, /* C2PMSG_59 */
|
||||
.feature_reg = 0x109fc, /* C2PMSG_63 */
|
||||
.inten_reg = 0x10690, /* P2CMSG_INTEN */
|
||||
.intsts_reg = 0x10694, /* P2CMSG_INTSTS */
|
||||
.platform_features = PLATFORM_FEATURE_HSTI,
|
||||
};
|
||||
|
||||
static const struct psp_vdata pspv3 = {
|
||||
@ -413,7 +415,8 @@ static const struct psp_vdata pspv3 = {
|
||||
.feature_reg = 0x109fc, /* C2PMSG_63 */
|
||||
.inten_reg = 0x10690, /* P2CMSG_INTEN */
|
||||
.intsts_reg = 0x10694, /* P2CMSG_INTSTS */
|
||||
.platform_features = PLATFORM_FEATURE_DBC,
|
||||
.platform_features = PLATFORM_FEATURE_DBC |
|
||||
PLATFORM_FEATURE_HSTI,
|
||||
};
|
||||
|
||||
static const struct psp_vdata pspv4 = {
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
enum psp_platform_access_msg {
|
||||
PSP_CMD_NONE = 0x0,
|
||||
PSP_CMD_HSTI_QUERY = 0x14,
|
||||
PSP_I2C_REQ_BUS_CMD = 0x64,
|
||||
PSP_DYNAMIC_BOOST_GET_NONCE,
|
||||
PSP_DYNAMIC_BOOST_SET_UID,
|
||||
|
Loading…
Reference in New Issue
Block a user