File tree Expand file tree Collapse file tree 8 files changed +182
-2
lines changed Expand file tree Collapse file tree 8 files changed +182
-2
lines changed Original file line number Diff line number Diff line change @@ -7,12 +7,14 @@ ccp-$(CONFIG_CRYPTO_DEV_SP_CCP) += ccp-dev.o \
7
7
ccp-dev-v5.o \
8
8
ccp-dmaengine.o
9
9
ccp-$(CONFIG_CRYPTO_DEV_CCP_DEBUGFS) += ccp-debugfs.o
10
- ccp-$(CONFIG_PCI) += sp-pci.o
10
+ ccp-$(CONFIG_PCI) += sp-pci.o \
11
+ hygon/sp-pci.o
11
12
ccp-$(CONFIG_CRYPTO_DEV_SP_PSP) += psp-dev.o \
12
13
sev-dev.o \
13
14
tee-dev.o \
14
15
platform-access.o \
15
- dbc.o
16
+ dbc.o \
17
+ hygon/psp-dev.o
16
18
17
19
obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o
18
20
ccp-crypto-objs := ccp-crypto-main.o \
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0-only
2
+ /*
3
+ * HYGON Platform Security Processor (PSP) interface
4
+ *
5
+ * Copyright (C) 2024 Hygon Info Technologies Ltd.
6
+ *
7
+ * Author: Liyang Han <[email protected] >
8
+ *
9
+ * This program is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License version 2 as
11
+ * published by the Free Software Foundation.
12
+ */
13
+
14
+ #include <linux/psp-hygon.h>
15
+
16
+ #include "psp-dev.h"
17
+
18
+ /* Function and variable pointers for hooks */
19
+ struct hygon_psp_hooks_table hygon_psp_hooks ;
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0-only */
2
+ /*
3
+ * HYGON Platform Security Processor (PSP) driver interface
4
+ *
5
+ * Copyright (C) 2024 Hygon Info Technologies Ltd.
6
+ *
7
+ * Author: Liyang Han <[email protected] >
8
+ */
9
+
10
+ #ifndef __CCP_HYGON_PSP_DEV_H__
11
+ #define __CCP_HYGON_PSP_DEV_H__
12
+
13
+ #include <linux/mutex.h>
14
+
15
+ #include "sp-dev.h"
16
+
17
+ #include "../psp-dev.h"
18
+ #include "../sev-dev.h"
19
+
20
+ /*
21
+ * Hooks table: a table of function and variable pointers filled in
22
+ * when psp init.
23
+ */
24
+ extern struct hygon_psp_hooks_table {
25
+ bool sev_dev_hooks_installed ;
26
+ struct mutex * sev_cmd_mutex ;
27
+ int (* __sev_do_cmd_locked )(int cmd , void * data , int * psp_ret );
28
+ } hygon_psp_hooks ;
29
+
30
+ #endif /* __CCP_HYGON_PSP_DEV_H__ */
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0-only */
2
+ /*
3
+ * HYGON Secure Processor interface
4
+ *
5
+ * Copyright (C) 2024 Hygon Info Technologies Ltd.
6
+ *
7
+ * Author: Liyang Han <[email protected] >
8
+ */
9
+
10
+ #ifndef __CCP_HYGON_SP_DEV_H__
11
+ #define __CCP_HYGON_SP_DEV_H__
12
+
13
+ #include <linux/processor.h>
14
+ #include <linux/ccp.h>
15
+
16
+ #include "../ccp-dev.h"
17
+ #include "../sp-dev.h"
18
+
19
+ #ifdef CONFIG_X86_64
20
+ static inline bool is_vendor_hygon (void )
21
+ {
22
+ return boot_cpu_data .x86_vendor == X86_VENDOR_HYGON ;
23
+ }
24
+ #else
25
+ static inline bool is_vendor_hygon (void ) { return false; }
26
+ #endif
27
+
28
+ extern const struct sp_dev_vdata hygon_dev_vdata [];
29
+
30
+ #endif /* __CCP_HYGON_SP_DEV_H__ */
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0-only
2
+ /*
3
+ * HYGON Secure Processor interface driver
4
+ *
5
+ * Copyright (C) 2024 Hygon Info Technologies Ltd.
6
+ *
7
+ * Author: Liyang Han <[email protected] >
8
+ *
9
+ * This program is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License version 2 as
11
+ * published by the Free Software Foundation.
12
+ */
13
+
14
+ #include "sp-dev.h"
15
+
16
+ #ifdef CONFIG_CRYPTO_DEV_SP_PSP
17
+ static const struct sev_vdata csvv1 = {
18
+ .cmdresp_reg = 0x10580 , /* C2PMSG_32 */
19
+ .cmdbuff_addr_lo_reg = 0x105e0 , /* C2PMSG_56 */
20
+ .cmdbuff_addr_hi_reg = 0x105e4 , /* C2PMSG_57 */
21
+ };
22
+
23
+ static const struct psp_vdata pspv1 = {
24
+ .sev = & csvv1 ,
25
+ .bootloader_info_reg = 0x105ec , /* C2PMSG_59 */
26
+ .feature_reg = 0x105fc , /* C2PMSG_63 */
27
+ .inten_reg = 0x10610 , /* P2CMSG_INTEN */
28
+ .intsts_reg = 0x10614 , /* P2CMSG_INTSTS */
29
+ };
30
+
31
+ #endif
32
+
33
+ const struct sp_dev_vdata hygon_dev_vdata [] = {
34
+ { /* 0 */
35
+ .bar = 2 ,
36
+ #ifdef CONFIG_CRYPTO_DEV_SP_CCP
37
+ .ccp_vdata = & ccpv5a ,
38
+ #endif
39
+ #ifdef CONFIG_CRYPTO_DEV_SP_PSP
40
+ .psp_vdata = & pspv1 ,
41
+ #endif
42
+ },
43
+ { /* 1 */
44
+ .bar = 2 ,
45
+ #ifdef CONFIG_CRYPTO_DEV_SP_CCP
46
+ .ccp_vdata = & ccpv5b ,
47
+ #endif
48
+ },
49
+ };
Original file line number Diff line number Diff line change 33
33
#include "psp-dev.h"
34
34
#include "sev-dev.h"
35
35
36
+ #include "hygon/psp-dev.h"
37
+
36
38
#define DEVICE_NAME "sev"
37
39
#define SEV_FW_FILE "amd/sev.fw"
38
40
#define SEV_FW_NAME_SIZE 64
@@ -1216,12 +1218,29 @@ static int sev_misc_init(struct sev_device *sev)
1216
1218
return 0 ;
1217
1219
}
1218
1220
1221
+ /* Code to set all of the function and variable pointers */
1222
+ static void sev_dev_install_hooks (void )
1223
+ {
1224
+ hygon_psp_hooks .sev_cmd_mutex = & sev_cmd_mutex ;
1225
+ hygon_psp_hooks .__sev_do_cmd_locked = __sev_do_cmd_locked ;
1226
+
1227
+ hygon_psp_hooks .sev_dev_hooks_installed = true;
1228
+ }
1229
+
1219
1230
int sev_dev_init (struct psp_device * psp )
1220
1231
{
1221
1232
struct device * dev = psp -> dev ;
1222
1233
struct sev_device * sev ;
1223
1234
int ret = - ENOMEM ;
1224
1235
1236
+ /*
1237
+ * Install sev-dev related function and variable pointers hooks only
1238
+ * for Hygon vendor, install these hooks here, even though the
1239
+ * following initialization fails.
1240
+ */
1241
+ if (is_vendor_hygon ())
1242
+ sev_dev_install_hooks ();
1243
+
1225
1244
if (!boot_cpu_has (X86_FEATURE_SEV )) {
1226
1245
dev_info_once (dev , "SEV: memory encryption not enabled by BIOS\n" );
1227
1246
return 0 ;
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0-only */
2
+ /*
3
+ * HYGON Platform Security Processor (PSP) driver interface
4
+ *
5
+ * Copyright (C) 2024 Hygon Info Technologies Ltd.
6
+ *
7
+ * Author: Liyang Han <[email protected] >
8
+ */
9
+
10
+ #ifndef __PSP_HYGON_H__
11
+ #define __PSP_HYGON_H__
12
+
13
+ #ifdef CONFIG_CRYPTO_DEV_SP_PSP
14
+ #else /* !CONFIG_CRYPTO_DEV_SP_PSP */
15
+ #endif /* CONFIG_CRYPTO_DEV_SP_PSP */
16
+
17
+ #endif /* __PSP_HYGON_H__ */
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
2
+ /*
3
+ * Userspace interface for HYGON Platform Security Processor (PSP)
4
+ * commands.
5
+ *
6
+ * Copyright (C) 2024 Hygon Info Technologies Ltd.
7
+ *
8
+ * Author: Liyang Han <[email protected] >
9
+ */
10
+
11
+ #ifndef __PSP_HYGON_USER_H__
12
+ #define __PSP_HYGON_USER_H__
13
+
14
+ #endif /* __PSP_HYGON_USER_H__ */
You can’t perform that action at this time.
0 commit comments