From 8753a22aebe2bcb98095ca321dce869b03364ccc Mon Sep 17 00:00:00 2001 From: suwanghw Date: Wed, 12 Jul 2023 18:20:57 +0800 Subject: [PATCH] adapte to chcore kernel Signed-off-by: suwanghw --- build/clean_framework.sh | 0 config/debug_config/oh_64_debug_config | 4 ++++ config/release_config/oh_64_release_config | 4 ++++ framework/gtask/src/gtask_config.c | 8 +++++--- framework/gtask/src/include/gtask_inner.h | 2 +- framework/gtask/src/manager/session_manager.c | 2 +- framework/tarunner/Makefile | 2 +- framework/tarunner/src/main.c | 1 - framework/teesmcmgr/Makefile | 2 +- framework/teesmcmgr/src/idle.c | 2 -- framework/teesmcmgr/src/teesmcmgr.h | 2 +- .../libdynconfmgr/src/dyn_conf_dispatch_inf.c | 7 +++++-- ...OpenSSL-customized-modification-unify.patch | 18 +++++++++++++++++- lib/teelib/libopenssl/build_openssl.sh | 1 + lib/teelib/libopenssl/clean_openssl.sh | 4 +++- lib/teelib/libteeos/include/tee/tee_log.h | 2 +- lib/teelib/libteeos/src/log/tee_log.c | 1 + lib/teelib/libteeos/src/log/tee_tag.h | 6 ------ services/permission_service/Makefile | 2 +- 19 files changed, 47 insertions(+), 23 deletions(-) mode change 100644 => 100755 build/clean_framework.sh diff --git a/build/clean_framework.sh b/build/clean_framework.sh old mode 100644 new mode 100755 diff --git a/config/debug_config/oh_64_debug_config b/config/debug_config/oh_64_debug_config index dd014c3f..7233eaac 100644 --- a/config/debug_config/oh_64_debug_config +++ b/config/debug_config/oh_64_debug_config @@ -88,3 +88,7 @@ CONFIG_ARCH_ARM=y CONFIG_ARCH_AARCH64=y CONFIG_ARM_CORTEX_A53=y CONFIG_CC_STACKPROTECTOR_STRONG=y +# +# Log +# +TLOG_USE_TEE_PRINT=y diff --git a/config/release_config/oh_64_release_config b/config/release_config/oh_64_release_config index 34392608..14a60aad 100644 --- a/config/release_config/oh_64_release_config +++ b/config/release_config/oh_64_release_config @@ -89,3 +89,7 @@ CONFIG_ARCH_ARM=y CONFIG_ARCH_AARCH64=y CONFIG_ARM_CORTEX_A53=y CONFIG_CC_STACKPROTECTOR_STRONG=y +# +# Log +# +TLOG_USE_TEE_PRINT=y diff --git a/framework/gtask/src/gtask_config.c b/framework/gtask/src/gtask_config.c index cb733591..e400f065 100644 --- a/framework/gtask/src/gtask_config.c +++ b/framework/gtask/src/gtask_config.c @@ -52,8 +52,10 @@ const struct task_info_st *get_teeos_builtin_task_infos(void) #define RPMB_HUK_HEAP_DIV 2 #define SSA_DEFAULT_HEAP_HEAPMGR_MUL 24 #define HUK_DEFAULT_HEAP_HEAPMGR_MUL 24 -#define PERM_SRV_STACK_SIZE (DEFAULT_STACK_SIZE * 8) -#define PERM_SRV_HEAP_SIZE (DEFAULT_HEAP_SIZE * 3) +#define HUk_SRV_STACK_SIZE (DEFAULT_STACK_SIZE * 2) +#define HUK_SRV_HEAP_SIZE (DEFAULT_HEAP_SIZE * 2) +#define PERM_SRV_STACK_SIZE (DEFAULT_STACK_SIZE * 16) +#define PERM_SRV_HEAP_SIZE (DEFAULT_HEAP_SIZE * 8) #define PERM_SRV_DEFAULT_HEAP_HEAPMGR_MUL (DEFAULT_HEAP_SIZE * 24) /* build in service propertys for teeos */ @@ -65,7 +67,7 @@ const struct ta_property g_teeos_service_property[] = { true, false, false, false, NULL, 0 }, #endif #if (defined TEE_SUPPORT_HUK_SERVICE_32BIT || defined TEE_SUPPORT_HUK_SERVICE_64BIT) - { TEE_SERVICE_HUK, DEFAULT_STACK_SIZE / RPMB_HUK_STACK_DIV, DEFAULT_HEAP_SIZE / RPMB_HUK_HEAP_DIV, + { TEE_SERVICE_HUK, HUk_SRV_STACK_SIZE, HUK_SRV_HEAP_SIZE, true, false, false, false, NULL, 0 }, #endif #if (defined TEE_SUPPORT_PERM_64BIT || defined TEE_SUPPORT_PERM_32BIT) diff --git a/framework/gtask/src/include/gtask_inner.h b/framework/gtask/src/include/gtask_inner.h index f9808198..2a48578f 100644 --- a/framework/gtask/src/include/gtask_inner.h +++ b/framework/gtask/src/include/gtask_inner.h @@ -133,7 +133,7 @@ struct ta2ta_info_t { #define session_id_of_context(context) (context & 0x0000ffff) #define GLOBAL_TSK_ID 0 -#define SMCMGR_PID 1 +#define SMCMGR_PID 6 #define REET_TSK_ID SMCMGR_PID #define TASK_ID_NULL 0xFFFFFFFF diff --git a/framework/gtask/src/manager/session_manager.c b/framework/gtask/src/manager/session_manager.c index 3e4c4eda..80c83e13 100644 --- a/framework/gtask/src/manager/session_manager.c +++ b/framework/gtask/src/manager/session_manager.c @@ -53,7 +53,7 @@ struct service_struct *get_cur_service(void) return g_cur_service; } -static TEE_Result call_ta_invoke_close_session(const smc_cmd_t *cmd, uint32_t cmd_type, uint32_t cmd_id, +static TEE_Result __attribute__((noinline)) call_ta_invoke_close_session(const smc_cmd_t *cmd, uint32_t cmd_type, uint32_t cmd_id, global_to_ta_msg *entry_msg) { TEE_Result ret; diff --git a/framework/tarunner/Makefile b/framework/tarunner/Makefile index de1e256f..b8c37873 100644 --- a/framework/tarunner/Makefile +++ b/framework/tarunner/Makefile @@ -17,7 +17,7 @@ include $(BUILD_CONFIG)/var.mk tarunner_c_files := $(wildcard src/*.c) # Libraries -LIBS := c_shared${TARG} +LIBS := c_shared$(TARG) tee_shared$(TARG) inc-flags += -I$(SYSLIB)/libspawn_common/include/ inc-flags += -I$(DRVLIB)/libdrv_shared/src/ diff --git a/framework/tarunner/src/main.c b/framework/tarunner/src/main.c index 1dc9bf24..f0670418 100644 --- a/framework/tarunner/src/main.c +++ b/framework/tarunner/src/main.c @@ -48,7 +48,6 @@ static const char *g_tarunner_path = "/tarunner_a32.elf"; static const char *g_drv_so_path = "libdrv_shared_a32.so"; static const char *g_tee_share_so_path = "libtee_shared_a32.so"; #endif -const char *g_debug_prefix = "tarunner"; static int32_t param_check(int32_t argc, const char * const * argv) { diff --git a/framework/teesmcmgr/Makefile b/framework/teesmcmgr/Makefile index 1bf62054..8ca16492 100644 --- a/framework/teesmcmgr/Makefile +++ b/framework/teesmcmgr/Makefile @@ -30,7 +30,7 @@ $(BUILD_DIR)/$(TA_NAME): $(BUILD_DIR)/$(TARGETS) cp $< $@ # Libraries -LIBS := c_shared$(TARG) +LIBS := c_shared$(TARG) tee_shared$(TARG) LDFLAGS += --dynamic-linker=libc_shared$(TARG).so include $(BUILD_SERVICE)/svc-common.mk diff --git a/framework/teesmcmgr/src/idle.c b/framework/teesmcmgr/src/idle.c index 989fbd1c..ee5eaa49 100644 --- a/framework/teesmcmgr/src/idle.c +++ b/framework/teesmcmgr/src/idle.c @@ -80,9 +80,7 @@ __attribute__((noreturn)) void *tee_idle_thread(void *arg) error("StartTZ done\n"); while (1) { - debug("calling smc_switch_req\n"); err = smc_switch_req(CAP_TEESMC_REQ_IDLE); - debug("smc_switch_req return err=%x\n", err); if (err != 0) panic("something wrong"); } diff --git a/framework/teesmcmgr/src/teesmcmgr.h b/framework/teesmcmgr/src/teesmcmgr.h index 749ae4e2..8e00ca4f 100644 --- a/framework/teesmcmgr/src/teesmcmgr.h +++ b/framework/teesmcmgr/src/teesmcmgr.h @@ -17,7 +17,7 @@ #include #include #include -#define SMCMGR_STACK_SIZE 0x2000 +#define SMCMGR_STACK_SIZE 0x8000 #define PAY_LOAD_SIZE 24 #define MAGIC_MSG "IDLE_0xDEADBEEF" diff --git a/lib/syslib/libdynconfmgr/src/dyn_conf_dispatch_inf.c b/lib/syslib/libdynconfmgr/src/dyn_conf_dispatch_inf.c index 08ecc667..c0851f5e 100644 --- a/lib/syslib/libdynconfmgr/src/dyn_conf_dispatch_inf.c +++ b/lib/syslib/libdynconfmgr/src/dyn_conf_dispatch_inf.c @@ -333,8 +333,11 @@ int32_t tlv_to_uuid(const char *uuid_buff, uint32_t size, struct tee_uuid *uuid) } uint32_t i; - uint64_t data[UUID_STRUCT_LEN] = { 0 }; - + //TODO + uint64_t data[UUID_STRUCT_LEN]; + for (i = 0; i < UUID_STRUCT_LEN; i++) { + data[i] = 0; + } const char *ptr = uuid_buff; uint8_t flag = 0; flag |= (uint8_t)(trans_str_to_int(ptr, UUID_TIMELOW_LEN, BASE_OF_HEX, &data[DATA_TIMELOW_IDX]) != 0); diff --git a/lib/teelib/libopenssl/OpenSSL-customized-modification-unify.patch b/lib/teelib/libopenssl/OpenSSL-customized-modification-unify.patch index 6c2d34a7..f14a0440 100644 --- a/lib/teelib/libopenssl/OpenSSL-customized-modification-unify.patch +++ b/lib/teelib/libopenssl/OpenSSL-customized-modification-unify.patch @@ -622,6 +622,22 @@ index 53516a06c6..e14c9c638f 100644 #define SN_hmac "HMAC" #define LN_hmac "hmac" #define NID_hmac 855 +diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c +index 1774a2b2a..870fd3892 100644 +--- a/crypto/threads_pthread.c ++++ b/crypto/threads_pthread.c +@@ -131,6 +131,12 @@ int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *)) + + void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key) + { ++ if (key == NULL) ++ return NULL; ++ ++ if (*key == 0) ++ pthread_key_create(key, NULL); ++ + return pthread_getspecific(*key); + } + -- 2.17.1 - diff --git a/lib/teelib/libopenssl/build_openssl.sh b/lib/teelib/libopenssl/build_openssl.sh index e4325349..51de4786 100755 --- a/lib/teelib/libopenssl/build_openssl.sh +++ b/lib/teelib/libopenssl/build_openssl.sh @@ -17,6 +17,7 @@ cd $opensslpath # config and generate dso_conf.h echo "before ./config " +chmod +x ./config ./config make include/crypto/dso_conf.h cp "$2"/lib/teelib/libopenssl/include/opensslconf.h $opensslpath/include/openssl/ diff --git a/lib/teelib/libopenssl/clean_openssl.sh b/lib/teelib/libopenssl/clean_openssl.sh index 573dbe29..88ed3010 100755 --- a/lib/teelib/libopenssl/clean_openssl.sh +++ b/lib/teelib/libopenssl/clean_openssl.sh @@ -14,4 +14,6 @@ cd "$1"/openssl git checkout . git clean -df -rm -rf $2"/lib/teelib/libopenssl/openssl +if [ -d "$2"/lib/teelib/libopenssl/openssl ]; then + rm -rf "$2"/lib/teelib/libopenssl/openssl +fi diff --git a/lib/teelib/libteeos/include/tee/tee_log.h b/lib/teelib/libteeos/include/tee/tee_log.h index aab436f4..0d26f1f2 100644 --- a/lib/teelib/libteeos/include/tee/tee_log.h +++ b/lib/teelib/libteeos/include/tee/tee_log.h @@ -54,7 +54,7 @@ extern const char *g_debug_prefix; #ifdef TLOG_USE_TEE_PRINT #define tlogv(fmt, args...) tee_print(LOG_LEVEL_VERBO, "%s %d:" fmt "", TAG_VERB, __LINE__, ##args) #else -#define tlogd(fmt, args...) printf("[%s] %s %d:" fmt " ", g_debug_prefix, TAG_VERB, __LINE__, ##args) +#define tlogv(fmt, args...) printf("[%s] %s %d:" fmt " ", g_debug_prefix, TAG_VERB, __LINE__, ##args) #endif /* TLOG_USE_TEE_PRINT */ #else #define tlogv(fmt, args...) \ diff --git a/lib/teelib/libteeos/src/log/tee_log.c b/lib/teelib/libteeos/src/log/tee_log.c index 00a99985..d9cb668d 100644 --- a/lib/teelib/libteeos/src/log/tee_log.c +++ b/lib/teelib/libteeos/src/log/tee_log.c @@ -17,6 +17,7 @@ #include "tee_init.h" #include "timer_export.h" #include "tee_tag.h" +#include "teecall.h" enum log_source_type { COMMON_SOURCE = 0, diff --git a/lib/teelib/libteeos/src/log/tee_tag.h b/lib/teelib/libteeos/src/log/tee_tag.h index 5ec6258a..fb933639 100644 --- a/lib/teelib/libteeos/src/log/tee_tag.h +++ b/lib/teelib/libteeos/src/log/tee_tag.h @@ -14,12 +14,6 @@ #include #include -static inline int debug_rdr_logitem(char *str, size_t str_len) -{ - (void)str; - (void)str_len; - return 0; -} uint8_t get_log_source(const char *driver_tag); char *get_log_tag(const char *driver_tag, const char *debug_prefix); diff --git a/services/permission_service/Makefile b/services/permission_service/Makefile index e9014297..afdd7735 100644 --- a/services/permission_service/Makefile +++ b/services/permission_service/Makefile @@ -97,7 +97,7 @@ CPPFLAGS += -DDYN_IMPORT_CERT=1 CFILES := $(filter-out , $(CFILES)) endif -CFLAGS += -fvisibility=hidden +CFLAGS += -fvisibility=hidden -Wno-pointer-to-int-cast ifeq ($(CONFIG_CRYPTO_SOFT_ENGINE),openssl) CFLAGS += -DOPENSSL_ENABLE endif