Unverified Commit 63fb4139 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!5453 Add GM Driver Support for Hygon platform(Cryptographic Coprocessor,OLK-6.6)

Merge Pull Request from: @partycoder 
 
Support GM kernel driver for hygon C86-2G C86-3G C86-4G CPU.
Support Hygon CCP used via mdev module and support CCP virtualization

issue:
https://gitee.com/openeuler/kernel/issues/I99ZNA

the Cryptographic Co-Processor in hygon CCP has implement SM2,SM3,SM4 algo,to use these feature,The corresponding driver needs to be implemented in the kernel.

we has finish the Cryptographic Co-Processor driver for previous version, now we are porting to OLK-6.6 branch,So user can call hygon GM ability via linux crypto framwork easliy.

Test:
the test result has been shown in issue link. 
 
Link:https://gitee.com/openeuler/kernel/pulls/5453

 

Reviewed-by: default avatarJason Zeng <jason.zeng@intel.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 45123fed 20bbea2d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8811,6 +8811,7 @@ CONFIG_CRYPTO_DEV_ZHAOXIN_AES=m
CONFIG_CRYPTO_DEV_ZHAOXIN_SHA=m
# CONFIG_CRYPTO_DEV_ATMEL_ECC is not set
# CONFIG_CRYPTO_DEV_ATMEL_SHA204A is not set
CONFIG_HYGON_GM=y
CONFIG_CRYPTO_DEV_CCP=y
CONFIG_CRYPTO_DEV_CCP_DD=m
CONFIG_CRYPTO_DEV_SP_CCP=y
@@ -8821,6 +8822,7 @@ CONFIG_TCG_HYGON=m
CONFIG_TCM_HYGON=m
CONFIG_TDM_DEV_HYGON=y
CONFIG_TDM_KERNEL_GUARD=m
CONFIG_CRYPTO_DEV_HCT=m
# CONFIG_CRYPTO_DEV_CCP_DEBUGFS is not set
CONFIG_CRYPTO_DEV_NITROX=m
CONFIG_CRYPTO_DEV_NITROX_CNN55XX=m
+20 −0
Original line number Diff line number Diff line
@@ -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
@@ -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.
+13 −1
Original line number Diff line number Diff line
@@ -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
@@ -21,6 +22,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 \
@@ -30,4 +33,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 −0
Original line number Diff line number Diff line
@@ -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);
@@ -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)
+1156 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading