From ed3e8f1c56a47f32d228d225a178f98acd6acc74 Mon Sep 17 00:00:00 2001 From: "minjie.yu" Date: Tue, 2 Jul 2024 09:19:51 +0800 Subject: [PATCH] feat: common modules compatible with linux-6.6 Signed-off-by: minjie.yu --- tzdriver/Makefile | 2 +- tzdriver/agent_rpmb/Makefile | 2 +- tzdriver/auth/Makefile | 2 +- tzdriver/core/Makefile | 2 +- tzdriver/core/tc_client_driver.c | 4 ++++ tzdriver/core/tz_spi_notify.c | 4 ++++ tzdriver/core/tzdebug.c | 5 +++++ tzdriver/ion/dynamic_ion_mem.c | 5 +++++ tzdriver/tlogger/Makefile | 2 +- tzdriver/tlogger/tlogger.c | 9 ++++++++- tzdriver/tui/Makefile | 2 +- tzdriver/whitelist/Makefile | 2 +- 12 files changed, 33 insertions(+), 8 deletions(-) mode change 100755 => 100644 tzdriver/agent_rpmb/Makefile diff --git a/tzdriver/Makefile b/tzdriver/Makefile index 3f9ef62..a6621ae 100644 --- a/tzdriver/Makefile +++ b/tzdriver/Makefile @@ -1,7 +1,7 @@ ifeq ($(CONFIG_TZDRIVER),y) KERNEL_DIR := $(srctree) -EXTRA_CFLAGS += -I$(KERNEL_DIR)/../../../../third_party/bounds_checking_function/include/ +EXTRA_CFLAGS += -I$(KERNEL_DIR)/bounds_checking_function/include/ obj-$(CONFIG_TZDRIVER) += agent_rpmb/ obj-$(CONFIG_TZDRIVER) += auth/ diff --git a/tzdriver/agent_rpmb/Makefile b/tzdriver/agent_rpmb/Makefile old mode 100755 new mode 100644 index 3cbd7b7..df4e0f8 --- a/tzdriver/agent_rpmb/Makefile +++ b/tzdriver/agent_rpmb/Makefile @@ -6,7 +6,7 @@ endif EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/platform_drivers/tzdriver EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/platform_drivers/tzdriver/core -EXTRA_CFLAGS += -I$(KERNEL_DIR)/../../../../third_party/bounds_checking_function/include +EXTRA_CFLAGS += -I$(KERNEL_DIR)/bounds_checking_function/include ifeq ($(CONFIG_MEDIATEK_SOLUTION),y) MTK_PLATFORM := $(subst ",,$(CONFIG_MTK_PLATFORM)) diff --git a/tzdriver/auth/Makefile b/tzdriver/auth/Makefile index 0e68fe8..c929587 100644 --- a/tzdriver/auth/Makefile +++ b/tzdriver/auth/Makefile @@ -3,7 +3,7 @@ KERNEL_DIR :=$(srctree) EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver/core EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver/tlogger -EXTRA_CFLAGS += -I$(KERNEL_DIR)/../../../../third_party/bounds_checking_function/include +EXTRA_CFLAGS += -I$(KERNEL_DIR)/bounds_checking_function/include EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver/include EXTRA_CFLAGS += -I$(KERNEL_DIR)/../../../../base/security/selinux/include EXTRA_CFLAGS += -I$(KERNEL_DIR)/../../../../base/security/selinux diff --git a/tzdriver/core/Makefile b/tzdriver/core/Makefile index 6edab43..326399f 100644 --- a/tzdriver/core/Makefile +++ b/tzdriver/core/Makefile @@ -4,7 +4,7 @@ ifneq ($(TARGET_BUILD_VARIANT), user) ccflags-y += -DDEF_ENG endif -EXTRA_CFLAGS += -I$(KERNEL_DIR)/../../../../third_party/bounds_checking_function/include +EXTRA_CFLAGS += -I$(KERNEL_DIR)/bounds_checking_function/include EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver/agent_rpmb/core EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver/auth diff --git a/tzdriver/core/tc_client_driver.c b/tzdriver/core/tc_client_driver.c index 5d3c2b8..76bf1f9 100644 --- a/tzdriver/core/tc_client_driver.c +++ b/tzdriver/core/tc_client_driver.c @@ -1263,7 +1263,11 @@ static int tc_ns_client_init(void) ret = load_tz_shared_mem(g_dev_node); if (ret != 0) goto unmap_res_mem; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) g_driver_class = class_create(THIS_MODULE, TC_NS_CLIENT_DEV); +#else + g_driver_class = class_create(TC_NS_CLIENT_DEV); +#endif if (IS_ERR_OR_NULL(g_driver_class)) { tloge("class create failed"); ret = -ENOMEM; diff --git a/tzdriver/core/tz_spi_notify.c b/tzdriver/core/tz_spi_notify.c index 1f5f33f..9051ea3 100644 --- a/tzdriver/core/tz_spi_notify.c +++ b/tzdriver/core/tz_spi_notify.c @@ -447,7 +447,11 @@ static void spi_broadcast_notifications(void) return; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) + missed = (uint32_t)__arch_xchg(0, &g_notify_data->meta.context.meta.missed, MISSED_COUNT); +#else missed = (uint32_t)__xchg(0, &g_notify_data->meta.context.meta.missed, MISSED_COUNT); +#endif if (missed == 0) return; if ((missed & (1U << NOTIFY_DATA_ENTRY_WAKEUP)) != 0) { diff --git a/tzdriver/core/tzdebug.c b/tzdriver/core/tzdebug.c index f57562e..4c4b833 100644 --- a/tzdriver/core/tzdebug.c +++ b/tzdriver/core/tzdebug.c @@ -24,7 +24,12 @@ #include #include #include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) #include +#else +#include +#endif #include #include #include diff --git a/tzdriver/ion/dynamic_ion_mem.c b/tzdriver/ion/dynamic_ion_mem.c index dce1516..feb38d0 100644 --- a/tzdriver/ion/dynamic_ion_mem.c +++ b/tzdriver/ion/dynamic_ion_mem.c @@ -13,7 +13,12 @@ */ #include "dynamic_ion_mem.h" +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) #include +#else +#include +#endif #include #include #include diff --git a/tzdriver/tlogger/Makefile b/tzdriver/tlogger/Makefile index 00c3f02..8a909ab 100644 --- a/tzdriver/tlogger/Makefile +++ b/tzdriver/tlogger/Makefile @@ -4,7 +4,7 @@ ifneq ($(TARGET_BUILD_VARIANT), user) ccflags-y += -DDEF_ENG endif -EXTRA_CFLAGS += -I$(KERNEL_DIR)/../../../../third_party/bounds_checking_function/include +EXTRA_CFLAGS += -I$(KERNEL_DIR)/bounds_checking_function/include EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver/core EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver/include diff --git a/tzdriver/tlogger/tlogger.c b/tzdriver/tlogger/tlogger.c index 81fd888..dcfc50b 100644 --- a/tzdriver/tlogger/tlogger.c +++ b/tzdriver/tlogger/tlogger.c @@ -1030,16 +1030,19 @@ static int tlogger_chown(const char *file_path, uint32_t file_path_len) uid_t user = ROOT_UID; gid_t group = ROOT_GID; int ret; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)) mm_segment_t old_fs; - +#endif get_log_chown(&user, &group); /* not need modify chown attr */ if (group == ROOT_GID && user == ROOT_UID) return 0; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)) old_fs = get_fs(); set_fs(KERNEL_DS); +#endif #if (KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE) ret = (int)ksys_chown((const char __user *)file_path, user, group); #else @@ -1047,11 +1050,15 @@ static int tlogger_chown(const char *file_path, uint32_t file_path_len) #endif if (ret != 0) { tloge("sys chown for last teemsg file error\n"); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)) set_fs(old_fs); +#endif return -1; } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)) set_fs(old_fs); +#endif return 0; } #endif diff --git a/tzdriver/tui/Makefile b/tzdriver/tui/Makefile index ad0d6d9..2ed000a 100644 --- a/tzdriver/tui/Makefile +++ b/tzdriver/tui/Makefile @@ -12,7 +12,7 @@ ifeq ($(CONFIG_TEE_TUI_MTK), y) EXTRA_CFLAGS += -Idrivers/tzdriver EXTRA_CFLAGS += -Idrivers/tzdriver/core -EXTRA_CFLAGS += -I$(KERNEL_DIR)/../../../../third_party/bounds_checking_function/include +EXTRA_CFLAGS += -I$(KERNEL_DIR)/bounds_checking_function/include EXTRA_CFLAGS += -Idrivers/gpu/drm/mediatek EXTRA_CFLAGS += -Idrivers/misc/mediatek/memory-ssmr EXTRA_CFLAGS += -Idrivers/devkit/lcdkit/lcdkit3.0/kernel/mtk/include diff --git a/tzdriver/whitelist/Makefile b/tzdriver/whitelist/Makefile index 730246c..7044f25 100644 --- a/tzdriver/whitelist/Makefile +++ b/tzdriver/whitelist/Makefile @@ -4,7 +4,7 @@ ifneq ($(TARGET_BUILD_VARIANT), user) ccflags-y += -DDEF_ENG endif -EXTRA_CFLAGS += -I$(KERNEL_DIR)/../../../../third_party/bounds_checking_function/include +EXTRA_CFLAGS += -I$(KERNEL_DIR)/bounds_checking_function/include EXTRA_CFLAGS += -I$(KERNEL_DIR)/drivers/tzdriver/include EXTRA_CFLAGS += -include internal_functions.h -- Gitee