Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GM Driver Support for Hygon platform Cryptographic Coprocessor #384

Merged
merged 20 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
996b43f
crypto: ccp: Support SM2 algorithm for hygon ccp.
liyabin27 May 7, 2022
3714e9e
crypto: ccp: Support SM3 algorithm for hygon ccp.
liyabin27 May 7, 2022
8fd275a
crypto: ccp: Support SM4 algorithm for hygon ccp.
liyabin27 May 7, 2022
612c734
crypto: ccp: fix sm2 not return due to wrong complete callback parameter
Mar 19, 2024
3b38d46
crypto: ccp: It prompt ILLEGAL_MEM_ADDR when using PSPCCP.
liyabin27 May 7, 2022
92a2b33
crypto: ccp: Only handle interrupts by completion.
liyabin27 May 7, 2022
4b806cd
crypto: ccp: Fix a problem that vq thread may stuck when do multi pro…
Aug 22, 2022
a45b536
crypto: ccp: fix sm2 test failed in testmgr because of missing DER co…
Nov 17, 2023
2b0ea44
crypto: ccp: fix bug that SM2 encryption of long data causes kernel c…
Mar 18, 2024
0a7fe71
crypto: ccp: Modify value of COMMANDS_PER_QUEUE from 16 to 8192.
liyabin27 May 8, 2022
9a2b118
crypto: ccp: Process multiple VQ commands once for SM3 ccp.
liyabin27 May 8, 2022
25d338a
crypto: ccp: Process multiple VQ commands once for SM4/SM4-CTR ccp.
liyabin27 May 8, 2022
b60e4d6
crypto: ccp: remove repeated sm4-hs mode
Apr 8, 2024
755cdb0
crypto: ccp: support sm2 on Hygon generation 4th CPU
Apr 16, 2024
e73221f
hct: add mediated ccp driver support for hygon crypto technology.
liyabin27 Apr 25, 2024
8abf7d5
hct: supporting memory encryption in host and wb set in vm
liyabin27 Apr 25, 2024
c9237d9
hct: fix build issue when the module mdev is disabled.
liyabin27 Apr 25, 2024
cd3f856
hct: change the maximum number of supported ccps from 16 to 48.
liyabin27 Apr 25, 2024
7b1d268
hct: support 1024 processes simutaneously in the hct-mdev mode.
liyabin27 May 6, 2024
3b6cd0a
hct: fix fork issue when use hct in virtual machine
Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions arch/x86/configs/deepin_x86_desktop_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5518,6 +5518,8 @@ CONFIG_CRYPTO_DEV_VIRTIO=m
CONFIG_CRYPTO_DEV_SAFEXCEL=m
CONFIG_CRYPTO_DEV_AMLOGIC_GXL=m
CONFIG_CRYPTO_DEV_TSSE=m
CONFIG_CRYPTO_DEV_HCT=m
CONFIG_HYGON_GM=y
CONFIG_PKCS8_PRIVATE_KEY_PARSER=m
CONFIG_SIGNED_PE_FILE_VERIFICATION=y
CONFIG_SYSTEM_EXTRA_CERTIFICATE=y
Expand Down
20 changes: 20 additions & 0 deletions drivers/crypto/ccp/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ config CRYPTO_DEV_SP_PSP
along with software-based Trusted Execution Environment (TEE) to
enable third-party trusted applications.

config HYGON_GM
bool "Hygon GM (sm2/sm3/sm4) Interface"
default y
depends on CRYPTO_DEV_CCP_CRYPTO && X86_64
select CRYPTO_SM3_GENERIC
help
Hygon GM ccp driver

config CRYPTO_DEV_CCP_DEBUGFS
bool "Enable CCP Internals in DebugFS"
default n
Expand Down Expand Up @@ -79,3 +87,15 @@ config TDM_KERNEL_GUARD
The key part of kernel is protected by TDM technology, SCT and IDT
are protected by default, and others are added later according to the
requirements.

config CRYPTO_DEV_HCT
tristate "HCT CCP device"
default m
depends on X86_64
select VFIO_MDEV
help
Provides hygon crypto technology ccp device driver.
Support virtualize ccp devices based on mediated devices.
Support multi-process and virtual machines.
Support host-noiommu mode memory encryption function.
If you choose 'M' here, this module will be called hct ccp.
14 changes: 13 additions & 1 deletion drivers/crypto/ccp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ ccp-$(CONFIG_CRYPTO_DEV_SP_CCP) += ccp-dev.o \
ccp-ops.o \
ccp-dev-v3.o \
ccp-dev-v5.o \
ccp-dmaengine.o
ccp-dmaengine.o \
hygon/ccp-dev-v5.o
ccp-$(CONFIG_CRYPTO_DEV_CCP_DEBUGFS) += ccp-debugfs.o
ccp-$(CONFIG_PCI) += sp-pci.o \
hygon/sp-pci.o
Expand All @@ -20,6 +21,8 @@ ccp-$(CONFIG_CRYPTO_DEV_SP_PSP) += psp-dev.o \

ccp-$(CONFIG_TDM_DEV_HYGON) += hygon/tdm-dev.o

obj-$(CONFIG_CRYPTO_DEV_HCT) += hygon/hct.o

obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o
ccp-crypto-objs := ccp-crypto-main.o \
ccp-crypto-aes.o \
Expand All @@ -29,4 +32,13 @@ ccp-crypto-objs := ccp-crypto-main.o \
ccp-crypto-des3.o \
ccp-crypto-rsa.o \
ccp-crypto-sha.o

obj-$(CONFIG_TDM_KERNEL_GUARD) += hygon/tdm-kernel-guard.o

$(obj)/ccp_sm2_sign.asn1.o: $(obj)/ccp_sm2_sign.asn1.c $(obj)/ccp_sm2_sign.asn1.h
$(obj)/ccp-crypto-sm2-hygon.o: $(obj)/ccp_sm2_sign.asn1.h

ccp-crypto-$(CONFIG_HYGON_GM) += ccp-crypto-sm2-hygon.o \
ccp-crypto-sm3-hygon.o \
ccp-crypto-sm4-hygon.o \
ccp_sm2_sign.asn1.o
23 changes: 23 additions & 0 deletions drivers/crypto/ccp/ccp-crypto-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ static unsigned int rsa_disable;
module_param(rsa_disable, uint, 0444);
MODULE_PARM_DESC(rsa_disable, "Disable use of RSA - any non-zero value");

static unsigned int sm_disable;
module_param(sm_disable, uint, 0444);
MODULE_PARM_DESC(sm_disable, "Disable use of SM2/SM3/SM4 - any non-zero value");

/* List heads for the supported algorithms */
static LIST_HEAD(hash_algs);
static LIST_HEAD(skcipher_algs);
Expand Down Expand Up @@ -322,6 +326,25 @@ static int ccp_register_algs(void)
{
int ret;

#ifdef CONFIG_HYGON_GM
if (!sm_disable && boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
ret = ccp_register_sm2_hygon_algs(&akcipher_algs);
if (ret)
return ret;

ret = ccp_register_sm3_hygon_algs(&hash_algs);
if (ret)
return ret;

ret = ccp_register_sm4_hygon_algs(&skcipher_algs);
if (ret)
return ret;

/* Return on hygon platform */
return 0;
}
#endif

if (!aes_disable) {
ret = ccp_register_aes_algs(&skcipher_algs);
if (ret)
Expand Down
Loading
Loading