Skip to content

Commit 9d1c6b9

Browse files
hanliyangWangYuli
authored andcommitted
crypto: ccp: Print Hygon CSV API version when CSV support is detected
hygon inclusion category: feature CVE: NA --------------------------- The Cryptographic Co-Processor module will print 'SEV API' instead of 'CSV API' on Hygon CPU if CSV is supported. Fix this confused message here. Signed-off-by: hanliyang <hanliyang@hygon.cn>
1 parent 3a15cca commit 9d1c6b9

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@
1717

1818
#include "psp-dev.h"
1919

20+
/*
21+
* Hygon CSV build info:
22+
* Hygon CSV build info is 32-bit in length other than 8-bit as that
23+
* in AMD SEV.
24+
*/
25+
u32 hygon_csv_build;
26+
27+
/*
28+
* csv_update_api_version used to update the api version of HYGON CSV
29+
* firmwareat driver side.
30+
* Currently, we only need to update @hygon_csv_build.
31+
*/
32+
void csv_update_api_version(struct sev_user_data_status *status)
33+
{
34+
if (status) {
35+
hygon_csv_build = (status->flags >> 9) |
36+
((u32)status->build << 23);
37+
}
38+
}
39+
2040
int csv_cmd_buffer_len(int cmd)
2141
{
2242
switch (cmd) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212

1313
#include <linux/fs.h>
1414

15+
extern u32 hygon_csv_build;
1516
extern const struct file_operations csv_fops;
1617

18+
void csv_update_api_version(struct sev_user_data_status *status);
1719
int csv_cmd_buffer_len(int cmd);
1820

1921
#endif /* __CCP_HYGON_CSV_DEV_H__ */

drivers/crypto/ccp/sev-dev.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,12 @@ static int __sev_platform_init_locked(int *error)
515515

516516
dev_dbg(sev->dev, "SEV firmware initialized\n");
517517

518-
dev_info(sev->dev, "SEV API:%d.%d build:%d\n", sev->api_major,
519-
sev->api_minor, sev->build);
518+
if (is_vendor_hygon())
519+
dev_info(sev->dev, "CSV API:%d.%d build:%d\n", sev->api_major,
520+
sev->api_minor, hygon_csv_build);
521+
else
522+
dev_info(sev->dev, "SEV API:%d.%d build:%d\n", sev->api_major,
523+
sev->api_minor, sev->build);
520524

521525
return 0;
522526
}
@@ -738,6 +742,13 @@ static int sev_get_api_version(void)
738742
sev->build = status.build;
739743
sev->state = status.state;
740744

745+
/*
746+
* The api version fields of HYGON CSV firmware are not consistent
747+
* with AMD SEV firmware.
748+
*/
749+
if (is_vendor_hygon())
750+
csv_update_api_version(&status);
751+
741752
return 0;
742753
}
743754

0 commit comments

Comments
 (0)