Skip to content

Commit 648dbcc

Browse files
ashkalrabp3tk0v
authored andcommitted
crypto: ccp - Add AMD Seamless Firmware Servicing (SFS) driver
AMD Seamless Firmware Servicing (SFS) is a secure method to allow non-persistent updates to running firmware and settings without requiring BIOS reflash and/or system reset. SFS does not address anything that runs on the x86 processors and it can be used to update ASP firmware, modules, register settings and update firmware for other microprocessors like TMPM, etc. SFS driver support adds ioctl support to communicate the SFS commands to the ASP/PSP by using the TEE mailbox interface. The Seamless Firmware Servicing (SFS) driver is added as a PSP sub-device. For detailed information, please look at the SFS specifications: https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/specifications/58604.pdf Signed-off-by: Ashish Kalra <ashish.kalra@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Link: https://lore.kernel.org/cover.1758057691.git.ashish.kalra@amd.com
1 parent e09701d commit 648dbcc

7 files changed

Lines changed: 476 additions & 2 deletions

File tree

drivers/crypto/ccp/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ ccp-$(CONFIG_CRYPTO_DEV_SP_PSP) += psp-dev.o \
1313
tee-dev.o \
1414
platform-access.o \
1515
dbc.o \
16-
hsti.o
16+
hsti.o \
17+
sfs.o
1718

1819
obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o
1920
ccp-crypto-objs := ccp-crypto-main.o \

drivers/crypto/ccp/psp-dev.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "psp-dev.h"
1818
#include "sev-dev.h"
1919
#include "tee-dev.h"
20+
#include "sfs.h"
2021
#include "platform-access.h"
2122
#include "dbc.h"
2223
#include "hsti.h"
@@ -182,6 +183,17 @@ static int psp_check_tee_support(struct psp_device *psp)
182183
return 0;
183184
}
184185

186+
static int psp_check_sfs_support(struct psp_device *psp)
187+
{
188+
/* Check if device supports SFS feature */
189+
if (!psp->capability.sfs) {
190+
dev_dbg(psp->dev, "psp does not support SFS\n");
191+
return -ENODEV;
192+
}
193+
194+
return 0;
195+
}
196+
185197
static int psp_init(struct psp_device *psp)
186198
{
187199
int ret;
@@ -198,6 +210,12 @@ static int psp_init(struct psp_device *psp)
198210
return ret;
199211
}
200212

213+
if (!psp_check_sfs_support(psp)) {
214+
ret = sfs_dev_init(psp);
215+
if (ret)
216+
return ret;
217+
}
218+
201219
if (psp->vdata->platform_access) {
202220
ret = platform_access_dev_init(psp);
203221
if (ret)
@@ -302,6 +320,8 @@ void psp_dev_destroy(struct sp_device *sp)
302320

303321
tee_dev_destroy(psp);
304322

323+
sfs_dev_destroy(psp);
324+
305325
dbc_dev_destroy(psp);
306326

307327
platform_access_dev_destroy(psp);

drivers/crypto/ccp/psp-dev.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ union psp_cap_register {
3232
unsigned int sev :1,
3333
tee :1,
3434
dbc_thru_ext :1,
35-
rsvd1 :4,
35+
sfs :1,
36+
rsvd1 :3,
3637
security_reporting :1,
3738
fused_part :1,
3839
rsvd2 :1,
@@ -68,6 +69,7 @@ struct psp_device {
6869
void *tee_data;
6970
void *platform_access_data;
7071
void *dbc_data;
72+
void *sfs_data;
7173

7274
union psp_cap_register capability;
7375
};
@@ -118,12 +120,16 @@ struct psp_ext_request {
118120
* @PSP_SUB_CMD_DBC_SET_UID: Set UID for DBC
119121
* @PSP_SUB_CMD_DBC_GET_PARAMETER: Get parameter from DBC
120122
* @PSP_SUB_CMD_DBC_SET_PARAMETER: Set parameter for DBC
123+
* @PSP_SUB_CMD_SFS_GET_FW_VERS: Get firmware versions for ASP and other MP
124+
* @PSP_SUB_CMD_SFS_UPDATE: Command to load, verify and execute SFS package
121125
*/
122126
enum psp_sub_cmd {
123127
PSP_SUB_CMD_DBC_GET_NONCE = PSP_DYNAMIC_BOOST_GET_NONCE,
124128
PSP_SUB_CMD_DBC_SET_UID = PSP_DYNAMIC_BOOST_SET_UID,
125129
PSP_SUB_CMD_DBC_GET_PARAMETER = PSP_DYNAMIC_BOOST_GET_PARAMETER,
126130
PSP_SUB_CMD_DBC_SET_PARAMETER = PSP_DYNAMIC_BOOST_SET_PARAMETER,
131+
PSP_SUB_CMD_SFS_GET_FW_VERS = PSP_SFS_GET_FW_VERSIONS,
132+
PSP_SUB_CMD_SFS_UPDATE = PSP_SFS_UPDATE,
127133
};
128134

129135
int psp_extended_mailbox_cmd(struct psp_device *psp, unsigned int timeout_msecs,

0 commit comments

Comments
 (0)