Commit c73088c4 authored by hanliyang's avatar hanliyang
Browse files

crypto: ccp: Print Hygon CSV API version when CSV support is detected

hygon inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I98NP1


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: default avatarhanliyang <hanliyang@hygon.cn>
parent 12643565
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -17,6 +17,26 @@

#include "psp-dev.h"

/*
 * Hygon CSV build info:
 *    Hygon CSV build info is 32-bit in length other than 8-bit as that
 *    in AMD SEV.
 */
u32 hygon_csv_build;

/*
 * csv_update_api_version used to update the api version of HYGON CSV
 * firmwareat driver side.
 * Currently, we only need to update @hygon_csv_build.
 */
void csv_update_api_version(struct sev_user_data_status *status)
{
	if (status) {
		hygon_csv_build = (status->flags >> 9) |
				   ((u32)status->build << 23);
	}
}

int csv_cmd_buffer_len(int cmd)
{
	switch (cmd) {
+2 −0
Original line number Diff line number Diff line
@@ -12,8 +12,10 @@

#include <linux/fs.h>

extern u32 hygon_csv_build;
extern const struct file_operations csv_fops;

void csv_update_api_version(struct sev_user_data_status *status);
int csv_cmd_buffer_len(int cmd);

#endif	/* __CCP_HYGON_CSV_DEV_H__ */
+13 −2
Original line number Diff line number Diff line
@@ -515,6 +515,10 @@ static int __sev_platform_init_locked(int *error)

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

	if (is_vendor_hygon())
		dev_info(sev->dev, "CSV API:%d.%d build:%d\n", sev->api_major,
			 sev->api_minor, hygon_csv_build);
	else
		dev_info(sev->dev, "SEV API:%d.%d build:%d\n", sev->api_major,
			 sev->api_minor, sev->build);

@@ -738,6 +742,13 @@ static int sev_get_api_version(void)
	sev->build = status.build;
	sev->state = status.state;

	/*
	 * The api version fields of HYGON CSV firmware are not consistent
	 * with AMD SEV firmware.
	 */
	if (is_vendor_hygon())
		csv_update_api_version(&status);

	return 0;
}