Update Trustonic TEE driver module to version 410a-V108

Update the Trustonic TEE driver module with the version available in
kinibi drop 410a-V108.

Kinibi version t-base-QC8996-Android-410a-V108-20211010_233907_31049_105441

Change-Id: I58908bf3c0ea22cc7c19f8e70696e5b7eb1b2a22
Reviewed-on: https://gerrit.mot.com/2084881
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Joel Voss <jvoss@motorola.com>
Reviewed-by: Zhenxin Xi <xizx@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Jefferson Capovilla 2021-10-07 17:22:43 -03:00 • committed by Jefferson Rodrigo Capovilla
commit 67a7f42cc3
7 changed files with 85 additions and 22 deletions

View file

@ -14,5 +14,5 @@
*/
#ifndef MOBICORE_COMPONENT_BUILD_TAG
#define MOBICORE_COMPONENT_BUILD_TAG \
"t-base-QC8996-Android-410a-V107-20200907_110712_11106_104337"
"t-base-QC8996-Android-410a-V108-20211010_233907_31049_105441"
#endif

View file

@ -17,7 +17,7 @@
#include "platform.h"
/** @name MobiCore FastCall Defines
/** @name MobiCore FastCall Definition
* Defines for the two different FastCall's.
*/
/**/
@ -49,7 +49,7 @@
/** @} */
/** @name MobiCore SMC Defines
/** @name MobiCore SMC Definition
* Defines the different secure monitor calls (SMC) for world switching.
*/
/**< Yield to switch from NWd to SWd. */

View file

@ -182,7 +182,7 @@ static inline bool mcp_session_isrunning(struct mcp_session *session)
*/
int mcp_wait(struct mcp_session *session, s32 timeout, int silent_expiry)
{
s32 err;
s32 err = 0;
int ret = 0;
mutex_lock(&session->notif_wait_lock);
@ -886,7 +886,7 @@ static int debug_sessions(struct kasnprintf_buf *buf)
list_for_each_entry(session, &l_ctx.sessions, list) {
const char *state_str;
u64 cpu_clk;
s32 err;
s32 err = 0;
state_str = nq_session_state(&session->nq_session, &cpu_clk);
mcp_get_err(session, &err);

View file

@ -23,16 +23,27 @@
#include <linux/pagemap.h>
#include <linux/device.h>
#include <linux/version.h>
#include <linux/dma-buf.h>
#ifdef CONFIG_DMA_SHARED_BUFFER
#include <linux/dma-buf.h>
#endif
#ifdef CONFIG_ION
#ifdef CONFIG_ION_SYSTEM_HEAP /* Android kernel only */
#if KERNEL_VERSION(5, 4, 0) < LINUX_VERSION_CODE
#include <linux/ion.h>
#elif KERNEL_VERSION(4, 11, 12) < LINUX_VERSION_CODE
#include "../../drivers/staging/android/ion/ion.h"
#elif KERNEL_VERSION(3, 14, 0) < LINUX_VERSION_CODE
#include "../../drivers/staging/android/ion/ion_priv.h"
#endif /* KERNEL_VERSION */
#else /* CONFIG_ION_SYSTEM_HEAP */
#if KERNEL_VERSION(5, 4, 0) < LINUX_VERSION_CODE
#include "../../drivers/staging/android/ion/ion.h"
#elif KERNEL_VERSION(3, 14, 0) < LINUX_VERSION_CODE
/* very old Android kernel without ION_SYSTEM_HEAP falls here */
#include "../../drivers/staging/android/ion/ion_priv.h"
#endif
#endif
#endif /* CONFIG_ION_SYSTEM_HEAP */
#endif /* CONFIG_ION */
#ifdef CONFIG_XEN
/* To get the MFN */
@ -142,7 +153,7 @@ static inline long gup_local(struct mm_struct *mm, uintptr_t start,
return get_user_pages_remote(NULL, mm, start, nr_pages, gup_flags,
pages, NULL, NULL);
}
#else
#elif KERNEL_VERSION(5, 10, 0) > LINUX_VERSION_CODE
static inline long gup_local(struct mm_struct *mm, uintptr_t start,
unsigned long nr_pages, int write,
struct page **pages)
@ -155,6 +166,19 @@ static inline long gup_local(struct mm_struct *mm, uintptr_t start,
return get_user_pages(start, nr_pages, gup_flags, pages, NULL);
}
#else
static inline long gup_local(struct mm_struct *mm, uintptr_t start,
unsigned long nr_pages, int write,
struct page **pages)
{
unsigned int gup_flags = 0;
gup_flags |= FOLL_LONGTERM;
if (write)
gup_flags |= FOLL_WRITE;
return pin_user_pages(start, nr_pages, gup_flags, pages, NULL);
}
#endif
static inline long gup_local_repeat(struct mm_struct *mm, uintptr_t start,
@ -277,7 +301,11 @@ static void tee_mmu_delete(struct tee_mmu *mmu)
#endif
/* pte_page() cannot return NULL */
#if KERNEL_VERSION(5, 10, 0) > LINUX_VERSION_CODE
put_page(pte_page(pte));
#else
unpin_user_page(pte_page(pte));
#endif
}
mmu->pages_locked -= nr_pages;
@ -506,7 +534,11 @@ struct tee_mmu *tee_mmu_create(struct mm_struct *mm,
long gup_ret;
/* Buffer was allocated in user space */
#if KERNEL_VERSION(5, 7, 19) < LINUX_VERSION_CODE
down_read(&mm->mmap_lock);
#else
down_read(&mm->mmap_sem);
#endif
/*
* Always try to map read/write from a Linux PoV, so
* Linux creates (page faults) the underlying pages if
@ -524,7 +556,11 @@ struct tee_mmu *tee_mmu_create(struct mm_struct *mm,
(uintptr_t)reader,
nr_pages, 0, pages);
}
#if KERNEL_VERSION(5, 7, 19) < LINUX_VERSION_CODE
up_read(&mm->mmap_lock);
#else
up_read(&mm->mmap_sem);
#endif
if (gup_ret < 0) {
ret = gup_ret;
mc_dev_err(ret, "failed to get user pages @%p",

View file

@ -26,6 +26,9 @@
#if KERNEL_VERSION(4, 11, 0) <= LINUX_VERSION_CODE
#include <linux/sched/clock.h> /* local_clock */
#endif
#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE
#include <linux/timekeeping.h>
#endif
#include "platform.h" /* CPU-related information */
@ -88,6 +91,8 @@ static struct {
struct kasnprintf_buf dump;
/* Time */
struct mcp_time *time;
/* Protects above shared MCP time */
struct mutex mcp_time_mutex;
/* Scheduler */
struct task_struct *tee_scheduler_thread;
@ -211,14 +216,26 @@ static int nq_scheduler_command(enum sched_command command)
static inline void nq_update_time(void)
{
struct timespec tm;
#if KERNEL_VERSION(5, 8, 0) <= LINUX_VERSION_CODE
struct timespec64 tm1, tm2;
getnstimeofday(&tm);
l_ctx.time->wall_clock_seconds = tm.tv_sec;
l_ctx.time->wall_clock_nsec = tm.tv_nsec;
getrawmonotonic(&tm);
l_ctx.time->monotonic_seconds = tm.tv_sec;
l_ctx.time->monotonic_nsec = tm.tv_nsec;
ktime_get_ts64(&tm1);
ktime_get_raw_ts64(&tm2);
#else
struct timespec tm1, tm2;
getnstimeofday(&tm1);
getrawmonotonic(&tm2);
#endif
mutex_lock(&l_ctx.mcp_time_mutex);
/* set for REE time (current time, may be affected by user timezone) */
l_ctx.time->wall_clock_seconds = tm1.tv_sec;
l_ctx.time->wall_clock_nsec = tm1.tv_nsec;
/* set for TEE time (absolute time, direct raw counter) */
l_ctx.time->monotonic_seconds = tm2.tv_sec;
l_ctx.time->monotonic_nsec = tm2.tv_nsec;
mutex_unlock(&l_ctx.mcp_time_mutex);
}
static inline void nq_notif_handler(u32 id, u32 payload)
@ -920,13 +937,13 @@ int nq_cpu_on(unsigned int cpu)
int nq_suspend(void)
{
mc_dev_devel("nq_suspend called");
mc_dev_devel("%s called", __func__);
return nq_cpu_off(get_cpu());
}
int nq_resume(void)
{
mc_dev_devel("nq_resume called");
mc_dev_devel("%s called", __func__);
return nq_cpu_on(get_cpu());
}

View file

@ -434,6 +434,7 @@ struct tee_session *session_create(struct tee_client *client,
struct tee_session *session;
struct identity mcp_identity;
memset(&mcp_identity, 0, sizeof(mcp_identity));
if (!IS_ERR_OR_NULL(identity)) {
/* Check identity method and data. */
int ret;
@ -441,8 +442,6 @@ struct tee_session *session_create(struct tee_client *client,
ret = check_prepare_identity(identity, &mcp_identity, current);
if (ret)
return ERR_PTR(ret);
} else {
memset(&mcp_identity, 0, sizeof(mcp_identity));
}
/* Allocate session object */
@ -973,7 +972,7 @@ int session_debug_structs(struct kasnprintf_buf *buf,
{
const char *type;
u32 session_id;
s32 err;
s32 err = 0;
int i, ret;
if (session->is_gp) {

View file

@ -1051,10 +1051,15 @@ static inline void frontend_attach(struct tee_xfe *xfe)
xfe->buffers[i].info = &xfe->ring->domu.buffers[i];
}
#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE
ret = bind_interdomain_evtchn_to_irqhandler_lateeoi(
xfe->xdev->otherend_id, xfe->evtchn_domu,
xen_be_irq_handler_domu_th, 0, "tee_be_domu", xfe);
#else
ret = bind_interdomain_evtchn_to_irqhandler(
xfe->xdev->otherend_id, xfe->evtchn_domu,
xen_be_irq_handler_domu_th, 0, "tee_be_domu", xfe);
#endif
if (ret < 0) {
xenbus_dev_fatal(xfe->xdev, ret,
"failed to bind event channel to DomU IRQ");
@ -1064,9 +1069,15 @@ static inline void frontend_attach(struct tee_xfe *xfe)
xfe->irq_domu = ret;
mc_dev_devel("bound DomU IRQ %d", xfe->irq_domu);
#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE
ret = bind_interdomain_evtchn_to_irqhandler_lateeoi(
xfe->xdev->otherend_id, xfe->evtchn_dom0,
xen_be_irq_handler_dom0_th, 0, "tee_be_dom0", xfe);
#else
ret = bind_interdomain_evtchn_to_irqhandler(
xfe->xdev->otherend_id, xfe->evtchn_dom0,
xen_be_irq_handler_dom0_th, 0, "tee_be_dom0", xfe);
#endif
if (ret < 0) {
xenbus_dev_fatal(xfe->xdev, ret,
"failed to bind event channel to Dom0 IRQ");