Skip to content

Commit 17ed0b7

Browse files
hanliyangWangYuli
authored andcommitted
crypto: ccp: Implement CSV_PLATFORM_INIT ioctl command
hygon inclusion category: feature CVE: NA --------------------------- The CSV_PLATFORM_INIT command can be used by the platform owner to switch platform from PSTATE.UNINIT to PSTATE.INIT. In the upcoming patches, we'll support DOWNLOAD_FIRMWARE at userspace. Due to DOWNLOAD_FIRMWARE can only performed when platform is in the PSTATE.UNINIT, we need invoke PLATFORM_INIT following DOWNLOAD_FIRMWARE to switch platform back to PSTATE.INIT. Signed-off-by: hanliyang <hanliyang@hygon.cn>
1 parent fba194e commit 17ed0b7

4 files changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/crypto/ccp/hygon/csv-dev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ static long csv_ioctl(struct file *file, unsigned int ioctl, unsigned long arg)
118118
case CSV_HGSC_CERT_IMPORT:
119119
ret = csv_ioctl_do_hgsc_import(&input);
120120
break;
121+
case CSV_PLATFORM_INIT:
122+
ret = hygon_psp_hooks.__sev_platform_init_locked(&input.error);
123+
break;
121124
default:
122125
/*
123126
* If the command is compatible between CSV and SEV, the

drivers/crypto/ccp/hygon/psp-dev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern struct hygon_psp_hooks_table {
2525
bool sev_dev_hooks_installed;
2626
struct mutex *sev_cmd_mutex;
2727
int (*__sev_do_cmd_locked)(int cmd, void *data, int *psp_ret);
28+
int (*__sev_platform_init_locked)(int *error);
2829
long (*sev_ioctl)(struct file *file, unsigned int ioctl, unsigned long arg);
2930
} hygon_psp_hooks;
3031

drivers/crypto/ccp/sev-dev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,7 @@ static void sev_dev_install_hooks(void)
12631263
{
12641264
hygon_psp_hooks.sev_cmd_mutex = &sev_cmd_mutex;
12651265
hygon_psp_hooks.__sev_do_cmd_locked = __sev_do_cmd_locked;
1266+
hygon_psp_hooks.__sev_platform_init_locked = __sev_platform_init_locked;
12661267
hygon_psp_hooks.sev_ioctl = sev_ioctl;
12671268

12681269
hygon_psp_hooks.sev_dev_hooks_installed = true;

include/uapi/linux/psp-hygon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* CSV guest/platform commands
2222
*/
2323
enum {
24+
CSV_PLATFORM_INIT = 101,
2425
CSV_HGSC_CERT_IMPORT = 201,
2526

2627
CSV_MAX,

0 commit comments

Comments
 (0)