diff --git a/0001-support-clang-compile.patch b/0001-support-clang-compile.patch deleted file mode 100644 index c083990..0000000 --- a/0001-support-clang-compile.patch +++ /dev/null @@ -1,223 +0,0 @@ -From 566d703c6739cf3a854cfd6321d1b367aacf5ff4 Mon Sep 17 00:00:00 2001 -From: 15859157387 <977713017@qq.com> -Date: Tue, 24 Oct 2023 14:50:37 +0800 -Subject: [PATCH] support clang compile - ---- - test/wd_mempool_test.c | 4 +--- - v1/wd_rsa.c | 18 ++++++++++-------- - wd_mempool.c | 7 +------ - wd_rsa.c | 22 ++++++++++++---------- - 4 files changed, 24 insertions(+), 27 deletions(-) - -diff --git a/test/wd_mempool_test.c b/test/wd_mempool_test.c -index ad04636..7d18752 100644 ---- a/test/wd_mempool_test.c -+++ b/test/wd_mempool_test.c -@@ -644,7 +644,7 @@ static void *sva_sec_cipher_async(void *arg) - int cnt = g_times; - handle_t h_sess; - int ret; -- int j, i; -+ int j; - - setup->alg = WD_CIPHER_AES; - setup->mode = WD_CIPHER_CBC; -@@ -658,7 +658,6 @@ static void *sva_sec_cipher_async(void *arg) - SEC_TST_PRT("test sec cipher set key is failed!\n"); - goto out;; - } -- i = cnt; - /* run task */ - do { - try_do_again: -@@ -666,7 +665,6 @@ try_do_again: - req->src = pdata->bd_pool->bds[j].src; - req->dst = pdata->bd_pool->bds[j].dst; - ret = wd_do_cipher_async(h_sess, req); -- i--; - if (ret == -EBUSY) { // busy - usleep(100); - goto try_do_again; -diff --git a/v1/wd_rsa.c b/v1/wd_rsa.c -index 61de3cc..49249b4 100644 ---- a/v1/wd_rsa.c -+++ b/v1/wd_rsa.c -@@ -105,8 +105,10 @@ struct wcrypto_rsa_prikey2 { - }; - - struct wcrypto_rsa_prikey { -- struct wcrypto_rsa_prikey1 pkey1; -- struct wcrypto_rsa_prikey2 pkey2; -+ union { -+ struct wcrypto_rsa_prikey1 pkey1; -+ struct wcrypto_rsa_prikey2 pkey2; -+ } pkey; - }; - - /* RSA CRT private key parameter types */ -@@ -444,7 +446,7 @@ static int create_ctx_key(struct wcrypto_rsa_ctx_setup *setup, - WD_ERR("alloc prikey2 fail!\n"); - return -WD_ENOMEM; - } -- pkey2 = &ctx->prikey->pkey2; -+ pkey2 = &ctx->prikey->pkey.pkey2; - memset(ctx->prikey, 0, len); - init_pkey2(pkey2, ctx->key_size); - } else { -@@ -459,7 +461,7 @@ static int create_ctx_key(struct wcrypto_rsa_ctx_setup *setup, - WD_ERR("alloc prikey1 fail!\n"); - return -WD_ENOMEM; - } -- pkey1 = &ctx->prikey->pkey1; -+ pkey1 = &ctx->prikey->pkey.pkey1; - memset(ctx->prikey, 0, len); - init_pkey1(pkey1, ctx->key_size); - } -@@ -713,7 +715,7 @@ int wcrypto_set_rsa_prikey_params(void *ctx, struct wd_dtb *d, struct wd_dtb *n) - WD_ERR("ctx err in set rsa private key1!\n"); - return -WD_EINVAL; - } -- pkey1 = &c->prikey->pkey1; -+ pkey1 = &c->prikey->pkey.pkey1; - if (d) { - if (d->dsize > pkey1->key_size || !d->data) { - WD_ERR("d err in set rsa private key1!\n"); -@@ -747,7 +749,7 @@ void wcrypto_get_rsa_prikey_params(struct wcrypto_rsa_prikey *pvk, struct wd_dtb - return; - } - -- pkey1 = &pvk->pkey1; -+ pkey1 = &pvk->pkey.pkey1; - - if (d) - *d = &pkey1->d; -@@ -819,7 +821,7 @@ int wcrypto_set_rsa_crt_prikey_params(void *ctx, struct wd_dtb *dq, - return ret; - } - -- pkey2 = &c->prikey->pkey2; -+ pkey2 = &c->prikey->pkey.pkey2; - ret = rsa_prikey2_param_set(pkey2, dq, WD_CRT_PRIKEY_DQ); - if (ret) { - WD_ERR("dq err in set rsa private key2!\n"); -@@ -865,7 +867,7 @@ void wcrypto_get_rsa_crt_prikey_params(struct wcrypto_rsa_prikey *pvk, - return; - } - -- pkey2 = &pvk->pkey2; -+ pkey2 = &pvk->pkey.pkey2; - - if (dq) - *dq = &pkey2->dq; -diff --git a/wd_mempool.c b/wd_mempool.c -index cb8c80b..864ba13 100644 ---- a/wd_mempool.c -+++ b/wd_mempool.c -@@ -71,7 +71,7 @@ static inline int wd_atomic_test_add(struct wd_ref *ref, int a, int u) - c = __atomic_load_n(&ref->ref, __ATOMIC_RELAXED); - if (c == u) - break; -- } while (! __atomic_compare_exchange_n(&ref->ref, &c, c + a, true, -+ } while (! __atomic_compare_exchange_n(&ref->ref, (__u32 *)&c, c + a, true, - __ATOMIC_RELAXED, __ATOMIC_RELAXED)); - - return c; -@@ -299,11 +299,6 @@ static int test_bit(struct bitmap *bm, unsigned int nr) - return !(*p & mask); - } - --inline static size_t wd_get_page_size(void) --{ -- return sysconf(_SC_PAGESIZE); --} -- - void *wd_block_alloc(handle_t blkpool) - { - struct blkpool *bp = (struct blkpool*)blkpool; -diff --git a/wd_rsa.c b/wd_rsa.c -index 4bd1d30..8301d57 100644 ---- a/wd_rsa.c -+++ b/wd_rsa.c -@@ -48,8 +48,10 @@ struct wd_rsa_prikey2 { - }; - - struct wd_rsa_prikey { -- struct wd_rsa_prikey1 pkey1; -- struct wd_rsa_prikey2 pkey2; -+ union { -+ struct wd_rsa_prikey1 pkey1; -+ struct wd_rsa_prikey2 pkey2; -+ } pkey; - }; - - /* RSA private key parameter types */ -@@ -844,7 +846,7 @@ static int create_sess_key(struct wd_rsa_sess_setup *setup, - WD_ERR("failed to alloc sess prikey2!\n"); - return -WD_ENOMEM; - } -- pkey2 = &sess->prikey->pkey2; -+ pkey2 = &sess->prikey->pkey.pkey2; - memset(sess->prikey, 0, len); - init_pkey2(pkey2, sess->key_size); - } else { -@@ -855,7 +857,7 @@ static int create_sess_key(struct wd_rsa_sess_setup *setup, - WD_ERR("failed to alloc sess prikey1!\n"); - return -WD_ENOMEM; - } -- pkey1 = &sess->prikey->pkey1; -+ pkey1 = &sess->prikey->pkey.pkey1; - memset(sess->prikey, 0, len); - init_pkey1(pkey1, sess->key_size); - } -@@ -886,9 +888,9 @@ static void del_sess_key(struct wd_rsa_sess *sess) - } - - if (sess->setup.is_crt) -- wd_memset_zero(prk->pkey2.data, CRT_PARAMS_SZ(sess->key_size)); -+ wd_memset_zero(prk->pkey.pkey2.data, CRT_PARAMS_SZ(sess->key_size)); - else -- wd_memset_zero(prk->pkey1.data, GEN_PARAMS_SZ(sess->key_size)); -+ wd_memset_zero(prk->pkey.pkey1.data, GEN_PARAMS_SZ(sess->key_size)); - free(sess->prikey); - free(sess->pubkey); - } -@@ -1041,7 +1043,7 @@ int wd_rsa_set_prikey_params(handle_t sess, struct wd_dtb *d, struct wd_dtb *n) - WD_ERR("invalid: sess err in set rsa private key1!\n"); - return -WD_EINVAL; - } -- pkey1 = &c->prikey->pkey1; -+ pkey1 = &c->prikey->pkey.pkey1; - if (d) { - if (!d->dsize || !d->data || d->dsize > pkey1->key_size) { - WD_ERR("invalid: d err in set rsa private key1!\n"); -@@ -1076,7 +1078,7 @@ void wd_rsa_get_prikey_params(struct wd_rsa_prikey *pvk, struct wd_dtb **d, - return; - } - -- pkey1 = &pvk->pkey1; -+ pkey1 = &pvk->pkey.pkey1; - - if (d) - *d = &pkey1->d; -@@ -1148,7 +1150,7 @@ int wd_rsa_set_crt_prikey_params(handle_t sess, struct wd_dtb *dq, - return ret; - } - -- pkey2 = &c->prikey->pkey2; -+ pkey2 = &c->prikey->pkey.pkey2; - ret = rsa_prikey2_param_set(pkey2, dq, WD_CRT_PRIKEY_DQ); - if (ret) { - WD_ERR("failed to set dq for rsa private key2!\n"); -@@ -1194,7 +1196,7 @@ void wd_rsa_get_crt_prikey_params(struct wd_rsa_prikey *pvk, - return; - } - -- pkey2 = &pvk->pkey2; -+ pkey2 = &pvk->pkey.pkey2; - - if (dq) - *dq = &pkey2->dq; --- -2.27.0 - diff --git a/0001-uadk-fix-build-issue-of-pthread_atfork.patch b/0001-uadk-fix-build-issue-of-pthread_atfork.patch new file mode 100644 index 0000000..5e1931d --- /dev/null +++ b/0001-uadk-fix-build-issue-of-pthread_atfork.patch @@ -0,0 +1,39 @@ +From 7ef31a9e64706d8312f7137b771c47e1658d4f6d Mon Sep 17 00:00:00 2001 +From: Zhangfei Gao +Date: Wed, 10 Jan 2024 10:24:19 +0000 +Subject: [PATCH 1/8] uadk: fix build issue of pthread_atfork + +In ubuntu 16.04 and 18.04, build uadk fail +log: +/bin/bash ../libtool --tag=CC --mode=link aarch64-linux-gnu-gcc -Wall -O0 -Werror -fno-strict-aliasing -I../include -I.. -g -O2 -Wl,-rpath,'/usr/local/lib' -pthread -o wd_mempool_test wd_mempool_test.o -L../.libs -lwd -ldl -lwd_crypto -lnuma +libtool: link: aarch64-linux-gnu-gcc -Wall -O0 -Werror -fno-strict-aliasing -I../include -I.. -g -O2 -Wl,-rpath -Wl,/usr/local/lib -pthread -o .libs/wd_mempool_test wd_mempool_test.o -L../.libs /mnt/uadk/.libs/libwd.so -ldl /mnt/uadk/.libs/libwd_crypto.so -lnuma -lpthread +/usr/bin/ld: .libs/wd_mempool_test: hidden symbol `pthread_atfork' in /usr/lib/aarch64-linux-gnu/libpthread_nonshared.a(pthread_atfork.oS) is referenced by DSO + +Reason is pthread_atfork in wd_xxx.c, missing -lpthread. + +Signed-off-by: Zhangfei Gao +--- + Makefile.am | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index d81e8cc..a369b7e 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -114,11 +114,11 @@ libwd_la_LDFLAGS=$(UADK_VERSION) $(UADK_WD_SYMBOL) $(UADK_V1_SYMBOL) + libwd_la_LIBADD= -ldl -lnuma + + libwd_comp_la_LIBADD= -lwd -ldl -lnuma +-libwd_comp_la_LDFLAGS=$(UADK_VERSION) $(UADK_COMP_SYMBOL) ++libwd_comp_la_LDFLAGS=$(UADK_VERSION) $(UADK_COMP_SYMBOL) -lpthread + libwd_comp_la_DEPENDENCIES= libwd.la + + libwd_crypto_la_LIBADD= -lwd -ldl -lnuma +-libwd_crypto_la_LDFLAGS=$(UADK_VERSION) $(UADK_CRYPTO_SYMBOL) ++libwd_crypto_la_LDFLAGS=$(UADK_VERSION) $(UADK_CRYPTO_SYMBOL) -lpthread + libwd_crypto_la_DEPENDENCIES= libwd.la + + libhisi_zip_la_LIBADD= -lwd -ldl -lwd_comp +-- +2.25.1 + diff --git a/0002-uadk-fix-static-build-error.patch b/0002-uadk-fix-static-build-error.patch new file mode 100644 index 0000000..e455b9e --- /dev/null +++ b/0002-uadk-fix-static-build-error.patch @@ -0,0 +1,36 @@ +From e50c7b8ab28696c904afa86741a4b6951c90b0b3 Mon Sep 17 00:00:00 2001 +From: Zhangfei Gao +Date: Wed, 10 Jan 2024 13:33:18 +0000 +Subject: [PATCH 2/8] uadk: fix static build error + +static build fail on both ubuntu and openEuler +/usr/bin/ld: ../.libs/libwd_comp.a(wd_comp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `stderr@@GLIBC_2.17' which may bind externally can not be used when making a shared object; recompile with -fPIC +/usr/bin/ld: ../.libs/libwd_comp.a(wd_comp.o)(.text+0x84): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `stderr@@GLIBC_2.17' + +Solved by adding -fPIC + +The -fPIC option in GCC stands for "Position Independent Code." +When this option is used, the generated machine code is not dependent +on being located at a specific address in order to work + +Signed-off-by: Zhangfei Gao +--- + Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.am b/Makefile.am +index a369b7e..51691cb 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -86,7 +86,7 @@ libhisi_sec_la_SOURCES=drv/hisi_sec.c drv/hisi_qm_udrv.c \ + libhisi_hpre_la_SOURCES=drv/hisi_hpre.c drv/hisi_qm_udrv.c \ + hisi_qm_udrv.h wd_hpre_drv.h + if WD_STATIC_DRV +-AM_CFLAGS += -DWD_STATIC_DRV ++AM_CFLAGS += -DWD_STATIC_DRV -fPIC + AM_CFLAGS += -DWD_NO_LOG + + libwd_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma +-- +2.25.1 + diff --git a/0003-uadk-add-secure-compilation-option.patch b/0003-uadk-add-secure-compilation-option.patch new file mode 100644 index 0000000..71c2903 --- /dev/null +++ b/0003-uadk-add-secure-compilation-option.patch @@ -0,0 +1,70 @@ +From 4cd0b3e82205767ac151835e69736c61aca4eda8 Mon Sep 17 00:00:00 2001 +From: Qi Tao +Date: Thu, 18 Jan 2024 21:07:26 +0800 +Subject: [PATCH 3/8] uadk: add secure compilation option +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add PIE, PIC, BIND_NOW, SP, NO Rpath/RunPath, FS, +Ftrapv and Strip compilation options. + +PIC(-fPIC): + Generate position-Independent-Code and andomly + load dynamic libraries. +PIE(-fPIE -pie): + Generate location-independent executables,which + reduces the probability of fixed address attacks + and buffer overflow attacks. +BIND_NOW(-Wl,-z,relro,-z,now): + GOT table redirects all read-only,which defends + against ret2plt attacks. +SP(-fstack-protector-strong/all): + Determine whether an overflow attack occurs. +Strip(-Wl,-s): + Deleting symbol tables defends against hacker + attacks and reduces the file size. +FS(-D_FORTIFY_SOURCE=2 -O2): + Provides access checks for fixed-size buffers + at compile time and at run time. +Ftrapv(-ftrapv): + Detects integer overflow. +NO Rpath/RunPath(hardcode_into_libs=no): + Eliminates dynamic library search paths, + which defense against attacks by replacing + dynamic libraries with the same name. + +Signed-off-by: Qi Tao +--- + Makefile.am | 2 ++ + configure.ac | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/Makefile.am b/Makefile.am +index 51691cb..64cfa44 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -1,6 +1,8 @@ + ACLOCAL_AMFLAGS = -I m4 -I./include + AUTOMAKE_OPTIONS = foreign subdir-objects + AM_CFLAGS=-Wall -Werror -fno-strict-aliasing -I$(top_srcdir)/include ++AM_CFLAGS+=-fPIC -fPIE -pie -fstack-protector-strong -D_FORTIFY_SOURCE=2 \ ++ -O2 -ftrapv -Wl,-z,relro,-z,now -Wl,-s + CLEANFILES = + + if WITH_LOG_FILE +diff --git a/configure.ac b/configure.ac +index 2692175..b198417 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -18,6 +18,7 @@ AM_PROG_AR + AC_PROG_LIBTOOL + AM_PROG_LIBTOOL + LT_INIT ++AC_SUBST([hardcode_into_libs], [no]) + AM_PROG_CC_C_O + + AC_ARG_ENABLE([debug-log], +-- +2.25.1 + diff --git a/0004-uadk_tool-fix-build-error.patch b/0004-uadk_tool-fix-build-error.patch new file mode 100644 index 0000000..7214660 --- /dev/null +++ b/0004-uadk_tool-fix-build-error.patch @@ -0,0 +1,153 @@ +From 797031c0562786591f9837650c1521573dee356c Mon Sep 17 00:00:00 2001 +From: Zhangfei Gao +Date: Wed, 24 Jan 2024 04:00:50 +0000 +Subject: [PATCH 4/8] uadk_tool: fix build error + +Fix build errors, like +"overlapping comparisons always evaluate to true", +"used uninitialized" etc. + +Signed-off-by: Zhangfei Gao +Signed-off-by: 15859157387 <977713017@qq.com> +--- + uadk_tool/benchmark/hpre_uadk_benchmark.c | 4 ++-- + uadk_tool/benchmark/hpre_wd_benchmark.c | 4 ++-- + uadk_tool/benchmark/sec_uadk_benchmark.c | 8 ++++---- + uadk_tool/benchmark/sec_wd_benchmark.c | 8 ++++---- + uadk_tool/benchmark/uadk_benchmark.c | 12 ------------ + uadk_tool/benchmark/uadk_benchmark.h | 1 - + uadk_tool/test/test_sec.c | 1 - + 7 files changed, 12 insertions(+), 26 deletions(-) + +diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c +index 028e102..0cbbdf2 100644 +--- a/uadk_tool/benchmark/hpre_uadk_benchmark.c ++++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c +@@ -2130,7 +2130,7 @@ static void *ecc_uadk_sync_run(void *arg) + memset(&req, 0, sizeof(req)); + + memset(&setup, 0, sizeof(setup)); +- if (subtype != X448_TYPE || subtype != X25519_TYPE) { ++ if (subtype != X448_TYPE && subtype != X25519_TYPE) { + ret = get_ecc_curve(&setup, cid); + if (ret) + return NULL; +@@ -2289,7 +2289,7 @@ static void *ecc_uadk_async_run(void *arg) + memset(&req, 0, sizeof(req)); + + memset(&setup, 0, sizeof(setup)); +- if (subtype != X448_TYPE || subtype != X25519_TYPE) { ++ if (subtype != X448_TYPE && subtype != X25519_TYPE) { + ret = get_ecc_curve(&setup, cid); + if (ret) + return NULL; +diff --git a/uadk_tool/benchmark/hpre_wd_benchmark.c b/uadk_tool/benchmark/hpre_wd_benchmark.c +index 67d57c6..2873ffd 100644 +--- a/uadk_tool/benchmark/hpre_wd_benchmark.c ++++ b/uadk_tool/benchmark/hpre_wd_benchmark.c +@@ -2090,7 +2090,7 @@ static void *ecc_wd_sync_run(void *arg) + queue = g_thread_queue.bd_res[pdata->td_id].queue; + + memset(&setup, 0, sizeof(setup)); +- if (subtype != X448_TYPE || subtype != X25519_TYPE) { ++ if (subtype != X448_TYPE && subtype != X25519_TYPE) { + ret = get_ecc_curve(&setup, cid); + if (ret) + return NULL; +@@ -2248,7 +2248,7 @@ static void *ecc_wd_async_run(void *arg) + queue = g_thread_queue.bd_res[pdata->td_id].queue; + + memset(&setup, 0, sizeof(setup)); +- if (subtype != X448_TYPE || subtype != X25519_TYPE) { ++ if (subtype != X448_TYPE && subtype != X25519_TYPE) { + ret = get_ecc_curve(&setup, cid); + if (ret) + return NULL; +diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c +index f1ae18b..c99ae89 100644 +--- a/uadk_tool/benchmark/sec_uadk_benchmark.c ++++ b/uadk_tool/benchmark/sec_uadk_benchmark.c +@@ -148,10 +148,10 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options) + bool is_union = false; + u8 keysize = 0; + u8 ivsize = 0; +- u8 dmode; +- u8 dalg; +- u8 mode; +- u8 alg; ++ u8 dmode = 0; ++ u8 dalg = 0; ++ u8 mode = 0; ++ u8 alg = 0; + + switch(algtype) { + case AES_128_ECB: +diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c +index 6e5c8a0..aa03db8 100644 +--- a/uadk_tool/benchmark/sec_wd_benchmark.c ++++ b/uadk_tool/benchmark/sec_wd_benchmark.c +@@ -214,10 +214,10 @@ static int sec_wd_param_parse(thread_data *tddata, struct acc_option *options) + bool is_union = false; + u8 keysize = 0; + u8 ivsize = 0; +- u8 dmode; +- u8 dalg; +- u8 mode; +- u8 alg; ++ u8 dmode = 0; ++ u8 dalg = 0; ++ u8 mode = 0; ++ u8 alg = 0; + + switch(algtype) { + case AES_128_ECB: +diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c +index 6d5d009..cf3a93c 100644 +--- a/uadk_tool/benchmark/uadk_benchmark.c ++++ b/uadk_tool/benchmark/uadk_benchmark.c +@@ -364,18 +364,6 @@ int get_pid_cpu_time(u32 *ptime) + return 0; + } + +-void mdelay(u32 ms) +-{ +- int clock_tcy = 2600000000; // 2.6Ghz CPU; +- int i; +- +- while(ms) { +- i++; +- if (i == clock_tcy) +- ms--; +- } +-} +- + static void alarm_end(int sig) + { + if (sig == SIGALRM) { +diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h +index 1cce63d..1752948 100644 +--- a/uadk_tool/benchmark/uadk_benchmark.h ++++ b/uadk_tool/benchmark/uadk_benchmark.h +@@ -198,7 +198,6 @@ enum test_alg { + ALG_MAX, + }; + +-extern void mdelay(u32 ms); + extern int get_pid_cpu_time(u32 *ptime); + extern void cal_perfermance_data(struct acc_option *option, u32 sttime); + extern void time_start(u32 seconds); +diff --git a/uadk_tool/test/test_sec.c b/uadk_tool/test/test_sec.c +index b00a933..16feaf0 100644 +--- a/uadk_tool/test/test_sec.c ++++ b/uadk_tool/test/test_sec.c +@@ -60,7 +60,6 @@ static unsigned int g_ctxnum; + static unsigned int g_data_fmt = WD_FLAT_BUF; + static unsigned int g_sgl_num = 0; + static unsigned int g_init; +-static pthread_spinlock_t lock = 0; + + static struct hash_testvec g_long_hash_tv; + +-- +2.25.1 + diff --git a/0005-v1-fix-build-error.patch b/0005-v1-fix-build-error.patch new file mode 100644 index 0000000..50db7ea --- /dev/null +++ b/0005-v1-fix-build-error.patch @@ -0,0 +1,134 @@ +From cb909f390823ec007cfe62aae9cf0dc750c0de2b Mon Sep 17 00:00:00 2001 +From: Zhangfei Gao +Date: Wed, 24 Jan 2024 04:06:04 +0000 +Subject: [PATCH 5/8] v1: fix build error + +Fix build errors, like +"'struct wcrypto_rsa_prikey1' not at the end of a struct or class", +"__TEST_WD_MEM_H not match" etc. + +Signed-off-by: Zhangfei Gao +Signed-off-by: 15859157387 <977713017@qq.com> +--- + v1/test/hisi_zip_test_sgl/zip_alg_sgl.h | 2 +- + v1/test/test_mm/test_wd_mem.c | 5 ----- + v1/test/test_mm/test_wd_mem.h | 2 +- + v1/wd_rsa.c | 18 ++++++++++-------- + 4 files changed, 12 insertions(+), 15 deletions(-) + +diff --git a/v1/test/hisi_zip_test_sgl/zip_alg_sgl.h b/v1/test/hisi_zip_test_sgl/zip_alg_sgl.h +index 0baa35b..1e35069 100644 +--- a/v1/test/hisi_zip_test_sgl/zip_alg_sgl.h ++++ b/v1/test/hisi_zip_test_sgl/zip_alg_sgl.h +@@ -14,7 +14,7 @@ + * limitations under the License. + */ + +-#ifndef __WD_ZIP_ALG_SGL__H__ ++#ifndef __WD_ZIP_ALG_SGL_H__ + #define __WD_ZIP_ALG_SGL_H__ + + #include +diff --git a/v1/test/test_mm/test_wd_mem.c b/v1/test/test_mm/test_wd_mem.c +index ba873f9..09824b9 100644 +--- a/v1/test/test_mm/test_wd_mem.c ++++ b/v1/test/test_mm/test_wd_mem.c +@@ -75,11 +75,6 @@ static inline unsigned long long va_to_pa(struct wd_queue *q, void *va) + return (unsigned long long)wd_iova_map(q, va, 0); + } + +-static inline void *pa_to_va(struct wd_queue *q, unsigned long long pa) +-{ +- return wd_dma_to_va(q, (void *)pa); +-} +- + struct mmt_queue_mempool *mmt_test_mempool_create(struct wd_queue *q, + unsigned int block_size, unsigned int block_num) + { +diff --git a/v1/test/test_mm/test_wd_mem.h b/v1/test/test_mm/test_wd_mem.h +index 8a7f561..0962b44 100644 +--- a/v1/test/test_mm/test_wd_mem.h ++++ b/v1/test/test_mm/test_wd_mem.h +@@ -15,7 +15,7 @@ + */ + + #ifndef __TEST_WD_MEM_H +-#define ___TEST_WD_MEM_H ++#define __TEST_WD_MEM_H + + #include + #include +diff --git a/v1/wd_rsa.c b/v1/wd_rsa.c +index bda8d31..2c8692b 100644 +--- a/v1/wd_rsa.c ++++ b/v1/wd_rsa.c +@@ -105,8 +105,10 @@ struct wcrypto_rsa_prikey2 { + }; + + struct wcrypto_rsa_prikey { +- struct wcrypto_rsa_prikey1 pkey1; +- struct wcrypto_rsa_prikey2 pkey2; ++ union { ++ struct wcrypto_rsa_prikey1 pkey1; ++ struct wcrypto_rsa_prikey2 pkey2; ++ } pkey; + }; + + /* RSA CRT private key parameter types */ +@@ -444,7 +446,7 @@ static int create_ctx_key(struct wcrypto_rsa_ctx_setup *setup, + WD_ERR("alloc prikey2 fail!\n"); + return -WD_ENOMEM; + } +- pkey2 = &ctx->prikey->pkey2; ++ pkey2 = &ctx->prikey->pkey.pkey2; + memset(ctx->prikey, 0, len); + init_pkey2(pkey2, ctx->key_size); + } else { +@@ -459,7 +461,7 @@ static int create_ctx_key(struct wcrypto_rsa_ctx_setup *setup, + WD_ERR("alloc prikey1 fail!\n"); + return -WD_ENOMEM; + } +- pkey1 = &ctx->prikey->pkey1; ++ pkey1 = &ctx->prikey->pkey.pkey1; + memset(ctx->prikey, 0, len); + init_pkey1(pkey1, ctx->key_size); + } +@@ -716,7 +718,7 @@ int wcrypto_set_rsa_prikey_params(void *ctx, struct wd_dtb *d, struct wd_dtb *n) + WD_ERR("ctx err in set rsa private key1!\n"); + return -WD_EINVAL; + } +- pkey1 = &c->prikey->pkey1; ++ pkey1 = &c->prikey->pkey.pkey1; + if (d) { + if (d->dsize > pkey1->key_size || !d->data) { + WD_ERR("d err in set rsa private key1!\n"); +@@ -750,7 +752,7 @@ void wcrypto_get_rsa_prikey_params(struct wcrypto_rsa_prikey *pvk, struct wd_dtb + return; + } + +- pkey1 = &pvk->pkey1; ++ pkey1 = &pvk->pkey.pkey1; + + if (d) + *d = &pkey1->d; +@@ -825,7 +827,7 @@ int wcrypto_set_rsa_crt_prikey_params(void *ctx, struct wd_dtb *dq, + return ret; + } + +- pkey2 = &c->prikey->pkey2; ++ pkey2 = &c->prikey->pkey.pkey2; + ret = rsa_prikey2_param_set(pkey2, dq, WD_CRT_PRIKEY_DQ); + if (ret) { + WD_ERR("dq err in set rsa private key2!\n"); +@@ -871,7 +873,7 @@ void wcrypto_get_rsa_crt_prikey_params(struct wcrypto_rsa_prikey *pvk, + return; + } + +- pkey2 = &pvk->pkey2; ++ pkey2 = &pvk->pkey.pkey2; + + if (dq) + *dq = &pkey2->dq; +-- +2.25.1 + diff --git a/0006-wd_mempool-fix-build-error.patch b/0006-wd_mempool-fix-build-error.patch new file mode 100644 index 0000000..6d5e71b --- /dev/null +++ b/0006-wd_mempool-fix-build-error.patch @@ -0,0 +1,43 @@ +From d335549b1d076a22735bb7211823c2f4140c62af Mon Sep 17 00:00:00 2001 +From: Zhangfei Gao +Date: Wed, 24 Jan 2024 04:15:46 +0000 +Subject: [PATCH 6/8] wd_mempool: fix build error + +Fix build errors like +"passing 'int *' to parameter of type '__u32 *' (aka 'unsigned int *') +converts between pointers to integer types with different sign" + +Signed-off-by: Zhangfei Gao +Signed-off-by: 15859157387 <977713017@qq.com> +--- + wd_mempool.c | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +diff --git a/wd_mempool.c b/wd_mempool.c +index ed107d1..47ad36b 100644 +--- a/wd_mempool.c ++++ b/wd_mempool.c +@@ -71,7 +71,7 @@ static inline int wd_atomic_test_add(struct wd_ref *ref, int a, int u) + c = __atomic_load_n(&ref->ref, __ATOMIC_RELAXED); + if (c == u) + break; +- } while (! __atomic_compare_exchange_n(&ref->ref, &c, c + a, true, ++ } while (!__atomic_compare_exchange_n(&ref->ref, (__u32 *)&c, c + a, true, + __ATOMIC_RELAXED, __ATOMIC_RELAXED)); + + return c; +@@ -299,11 +299,6 @@ static int test_bit(struct bitmap *bm, unsigned int nr) + return !(*p & mask); + } + +-inline static size_t wd_get_page_size(void) +-{ +- return sysconf(_SC_PAGESIZE); +-} +- + void *wd_block_alloc(handle_t blkpool) + { + struct blkpool *bp = (struct blkpool*)blkpool; +-- +2.25.1 + diff --git a/0007-wd_rsa-fix-build-error.patch b/0007-wd_rsa-fix-build-error.patch new file mode 100644 index 0000000..4de8d82 --- /dev/null +++ b/0007-wd_rsa-fix-build-error.patch @@ -0,0 +1,101 @@ +From 6077f4317961f8e308ecad2f02c3cdbb09aa707a Mon Sep 17 00:00:00 2001 +From: Zhangfei Gao +Date: Wed, 24 Jan 2024 04:18:57 +0000 +Subject: [PATCH 7/8] wd_rsa: fix build error + +Fix build errors, like +"field 'pkey1' with variable sized type 'struct wd_rsa_prikey1' +not at the end of a struct or class is a GNU extension" + +Signed-off-by: Zhangfei Gao +Signed-off-by: 15859157387 <977713017@qq.com> +--- + wd_rsa.c | 22 ++++++++++++---------- + 1 file changed, 12 insertions(+), 10 deletions(-) + +diff --git a/wd_rsa.c b/wd_rsa.c +index a27f061..de0b796 100644 +--- a/wd_rsa.c ++++ b/wd_rsa.c +@@ -45,8 +45,10 @@ struct wd_rsa_prikey2 { + }; + + struct wd_rsa_prikey { +- struct wd_rsa_prikey1 pkey1; +- struct wd_rsa_prikey2 pkey2; ++ union { ++ struct wd_rsa_prikey1 pkey1; ++ struct wd_rsa_prikey2 pkey2; ++ } pkey; + }; + + /* RSA private key parameter types */ +@@ -830,7 +832,7 @@ static int create_sess_key(struct wd_rsa_sess_setup *setup, + WD_ERR("failed to alloc sess prikey2!\n"); + return -WD_ENOMEM; + } +- pkey2 = &sess->prikey->pkey2; ++ pkey2 = &sess->prikey->pkey.pkey2; + memset(sess->prikey, 0, len); + init_pkey2(pkey2, sess->key_size); + } else { +@@ -841,7 +843,7 @@ static int create_sess_key(struct wd_rsa_sess_setup *setup, + WD_ERR("failed to alloc sess prikey1!\n"); + return -WD_ENOMEM; + } +- pkey1 = &sess->prikey->pkey1; ++ pkey1 = &sess->prikey->pkey.pkey1; + memset(sess->prikey, 0, len); + init_pkey1(pkey1, sess->key_size); + } +@@ -872,9 +874,9 @@ static void del_sess_key(struct wd_rsa_sess *sess) + } + + if (sess->setup.is_crt) +- wd_memset_zero(prk->pkey2.data, CRT_PARAMS_SZ(sess->key_size)); ++ wd_memset_zero(prk->pkey.pkey2.data, CRT_PARAMS_SZ(sess->key_size)); + else +- wd_memset_zero(prk->pkey1.data, GEN_PARAMS_SZ(sess->key_size)); ++ wd_memset_zero(prk->pkey.pkey1.data, GEN_PARAMS_SZ(sess->key_size)); + free(sess->prikey); + free(sess->pubkey); + } +@@ -1027,7 +1029,7 @@ int wd_rsa_set_prikey_params(handle_t sess, struct wd_dtb *d, struct wd_dtb *n) + WD_ERR("invalid: sess err in set rsa private key1!\n"); + return -WD_EINVAL; + } +- pkey1 = &c->prikey->pkey1; ++ pkey1 = &c->prikey->pkey.pkey1; + if (d) { + if (!d->dsize || !d->data || d->dsize > pkey1->key_size) { + WD_ERR("invalid: d err in set rsa private key1!\n"); +@@ -1062,7 +1064,7 @@ void wd_rsa_get_prikey_params(struct wd_rsa_prikey *pvk, struct wd_dtb **d, + return; + } + +- pkey1 = &pvk->pkey1; ++ pkey1 = &pvk->pkey.pkey1; + + if (d) + *d = &pkey1->d; +@@ -1134,7 +1136,7 @@ int wd_rsa_set_crt_prikey_params(handle_t sess, struct wd_dtb *dq, + return ret; + } + +- pkey2 = &c->prikey->pkey2; ++ pkey2 = &c->prikey->pkey.pkey2; + ret = rsa_prikey2_param_set(pkey2, dq, WD_CRT_PRIKEY_DQ); + if (ret) { + WD_ERR("failed to set dq for rsa private key2!\n"); +@@ -1180,7 +1182,7 @@ void wd_rsa_get_crt_prikey_params(struct wd_rsa_prikey *pvk, + return; + } + +- pkey2 = &pvk->pkey2; ++ pkey2 = &pvk->pkey.pkey2; + + if (dq) + *dq = &pkey2->dq; +-- +2.25.1 + diff --git a/0008-test-fix-build-error.patch b/0008-test-fix-build-error.patch new file mode 100644 index 0000000..7bc0986 --- /dev/null +++ b/0008-test-fix-build-error.patch @@ -0,0 +1,45 @@ +From 4a451be8acc77467d6ffec9506b8f89ef92def8a Mon Sep 17 00:00:00 2001 +From: Zhangfei Gao +Date: Wed, 24 Jan 2024 04:34:16 +0000 +Subject: [PATCH 8/8] test: fix build error + +Fix build errors like "unused variable" + +Signed-off-by: Zhangfei Gao +Signed-off-by: 15859157387 <977713017@qq.com> +--- + test/wd_mempool_test.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/test/wd_mempool_test.c b/test/wd_mempool_test.c +index ad04636..6e28b46 100644 +--- a/test/wd_mempool_test.c ++++ b/test/wd_mempool_test.c +@@ -644,7 +644,7 @@ static void *sva_sec_cipher_async(void *arg) + int cnt = g_times; + handle_t h_sess; + int ret; +- int j, i; ++ int j; + + setup->alg = WD_CIPHER_AES; + setup->mode = WD_CIPHER_CBC; +@@ -658,7 +658,6 @@ static void *sva_sec_cipher_async(void *arg) + SEC_TST_PRT("test sec cipher set key is failed!\n"); + goto out;; + } +- i = cnt; + /* run task */ + do { + try_do_again: +@@ -666,7 +665,6 @@ try_do_again: + req->src = pdata->bd_pool->bds[j].src; + req->dst = pdata->bd_pool->bds[j].dst; + ret = wd_do_cipher_async(h_sess, req); +- i--; + if (ret == -EBUSY) { // busy + usleep(100); + goto try_do_again; +-- +2.25.1 + diff --git a/libwd-2.5.0.tar.gz b/libwd-2.5.0.tar.gz deleted file mode 100644 index 38da270..0000000 Binary files a/libwd-2.5.0.tar.gz and /dev/null differ diff --git a/libwd-2.6.0.tar.gz b/libwd-2.6.0.tar.gz new file mode 100644 index 0000000..d531d16 Binary files /dev/null and b/libwd-2.6.0.tar.gz differ diff --git a/warpdrive.spec b/warpdrive.spec index f19ad40..8701067 100644 --- a/warpdrive.spec +++ b/warpdrive.spec @@ -1,11 +1,18 @@ Name: libwd Summary: User Space Accelerator Development Kit -Version: 2.5.0 -Release: 4 +Version: 2.6.0 +Release: 1 License: Apache-2.0 Source: %{name}-%{version}.tar.gz -Patch01: 0001-support-clang-compile.patch +Patch01: 0001-uadk-fix-build-issue-of-pthread_atfork.patch +Patch02: 0002-uadk-fix-static-build-error.patch +Patch03: 0003-uadk-add-secure-compilation-option.patch +Patch04: 0004-uadk_tool-fix-build-error.patch +Patch05: 0005-v1-fix-build-error.patch +Patch06: 0006-wd_mempool-fix-build-error.patch +Patch07: 0007-wd_rsa-fix-build-error.patch +Patch08: 0008-test-fix-build-error.patch Vendor: Huawei Corporation ExclusiveOS: linux @@ -13,7 +20,7 @@ URL: https://support.huawei.com BuildRoot: %{_tmppath}/%{name}-%{version}-root Conflicts: %{name} < %{version}-%{release} Provides: %{name} = %{version}-%{release} -BuildRequires: numactl-devel, openssl-devel, zlib-devel +BuildRequires: numactl-devel, compat-openssl11-devel, zlib-devel BuildRequires: automake, autoconf, libtool, chrpath BuildRequires: gcc, make ExclusiveArch: aarch64 @@ -23,6 +30,7 @@ This package contains the User Space Accelerator Library for hardware accelerator, compress, symmetric encryption and decryption, asymmetric encryption and decryption. +%global debug_package %{nil} %prep %autosetup -n %{name}-%{version} -p1 @@ -190,6 +198,9 @@ fi /sbin/ldconfig %changelog +* Mon Jan 22 2024 Zhangfei Gao 2.6.0-1 +- libwd: update to 2.6.0 + * Mon Sep 18 2023 renyi <977713017@qq.com> 2.5.0-4 - support clang compile