Add 'qcom/opensource/securemsm-kernel/' from commit 'a6005ceed271246683596608e4c56b4d921fb363'

git-subtree-dir: qcom/opensource/securemsm-kernel
git-subtree-mainline: 46e9caf0d0
git-subtree-split: a6005ceed2
Change-Id:
repo: https://git.codelinaro.org/clo/la/platform/vendor/qcom/opensource/securemsm-kernel
tag: LA.VENDOR.14.3.0.r1-17300-lanai.QSSI15.0
This commit is contained in:
David Wronek
2024-10-06 16:45:20 +02:00
92 changed files with 45193 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include "smcinvoke_object.h"
#define CTrustedCameraDriver_UID 283

View File

@@ -0,0 +1,159 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
*
* Copyright (c) 2021 The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#define IClientEnv_OP_open 0
#define IClientEnv_OP_registerLegacy 1
#define IClientEnv_OP_register 2
#define IClientEnv_OP_registerWithWhitelist 3
#define IClientEnv_OP_notifyDomainChange 4
#define IClientEnv_OP_registerWithCredentials 5
#define IClientEnv_OP_loadCmnlibFromBuffer 6
#define IClientEnv_OP_configTaRegion 7
#define IClientEnv_OP_adciAccept 8
#define IClientEnv_OP_adciShutdown 9
#include "smcinvoke_object.h"
static inline int32_t
IClientEnv_release(struct Object self)
{
return Object_invoke(self, Object_OP_release, 0, 0);
}
static inline int32_t
IClientEnv_retain(struct Object self)
{
return Object_invoke(self, Object_OP_retain, 0, 0);
}
static inline int32_t
IClientEnv_open(struct Object self, uint32_t uid_val, struct Object *obj_ptr)
{
union ObjectArg a[2];
int32_t result;
a[0].b = (struct ObjectBuf) { &uid_val, sizeof(uint32_t) };
result = Object_invoke(self, IClientEnv_OP_open, a, ObjectCounts_pack(1, 0, 0, 1));
*obj_ptr = a[1].o;
return result;
}
static inline int32_t
IClientEnv_registerLegacy(struct Object self, const void *credentials_ptr, size_t credentials_len,
struct Object *clientEnv_ptr)
{
union ObjectArg a[2];
int32_t result;
a[0].bi = (struct ObjectBufIn) { credentials_ptr, credentials_len * 1 };
result = Object_invoke(self, IClientEnv_OP_registerLegacy, a,
ObjectCounts_pack(1, 0, 0, 1));
*clientEnv_ptr = a[1].o;
return result;
}
static inline int32_t
IClientEnv_register(struct Object self, struct Object credentials_val,
struct Object *clientEnv_ptr)
{
union ObjectArg a[2];
int32_t result;
a[0].o = credentials_val;
result = Object_invoke(self, IClientEnv_OP_register, a,
ObjectCounts_pack(0, 0, 1, 1));
*clientEnv_ptr = a[1].o;
return result;
}
static inline int32_t
IClientEnv_registerWithWhitelist(struct Object self,
struct Object credentials_val, const uint32_t *uids_ptr,
size_t uids_len, struct Object *clientEnv_ptr)
{
union ObjectArg a[3];
int32_t result;
a[1].o = credentials_val;
a[0].bi = (struct ObjectBufIn) { uids_ptr, uids_len *
sizeof(uint32_t) };
result = Object_invoke(self, IClientEnv_OP_registerWithWhitelist, a,
ObjectCounts_pack(1, 0, 1, 1));
*clientEnv_ptr = a[2].o;
return result;
}
static inline int32_t
IClientEnv_notifyDomainChange(struct Object self)
{
return Object_invoke(self, IClientEnv_OP_notifyDomainChange, 0, 0);
}
static inline int32_t
IClientEnv_registerWithCredentials(struct Object self, struct Object
credentials_val, struct Object *clientEnv_ptr)
{
union ObjectArg a[2]={{{0,0}}};
int32_t result;
a[0].o = credentials_val;
result = Object_invoke(self, IClientEnv_OP_registerWithCredentials, a,
ObjectCounts_pack(0, 0, 1, 1));
*clientEnv_ptr = a[1].o;
return result;
}
static inline int32_t
IClientEnv_loadCmnlibFromBuffer(struct Object self, const void *cmnlibElf_ptr, size_t cmnlibElf_len)
{
union ObjectArg a[1]={{{0,0}}};
a[0].bi = (struct ObjectBufIn) { cmnlibElf_ptr, cmnlibElf_len * 1 };
return Object_invoke(self, IClientEnv_OP_loadCmnlibFromBuffer, a, ObjectCounts_pack(1, 0, 0, 0));
}
static inline int32_t
IClientEnv_configTaRegion(struct Object self, uint64_t appRgnAddr_val, uint32_t appRgnSize_val)
{
union ObjectArg a[1]={{{0,0}}};
struct {
uint64_t m_appRgnAddr;
uint32_t m_appRgnSize;
} i;
a[0].b = (struct ObjectBuf) { &i, 12 };
i.m_appRgnAddr = appRgnAddr_val;
i.m_appRgnSize = appRgnSize_val;
return Object_invoke(self, IClientEnv_OP_configTaRegion, a, ObjectCounts_pack(1, 0, 0, 0));
}
static inline int32_t
IClientEnv_adciAccept(struct Object self)
{
return Object_invoke(self, IClientEnv_OP_adciAccept, 0, 0);
}
static inline int32_t
IClientEnv_adciShutdown(struct Object self)
{
return Object_invoke(self, IClientEnv_OP_adciShutdown, 0, 0);
}

View File

@@ -0,0 +1,130 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include "smcinvoke_object.h"
/**
* Struct containing values for programming of domain ID
*
* @version: Version info
* @protect: To protect or reset the lanes
* @csid_hw_idx_mask: Bit position denoting CSID in use
* @cdm_hw_idx_mask: Bit position denoting CDM in use
* @vc_mask: VC mask for identifying domain
* @phy_lane_sel_mask: PHY lane info - contains CPHY, DPHY and PHY ID values
* 0-15 bits -- PHY index
* 16-23 bits -- CPHY lanes
* 24-31 bits -- DPHY lanes
* @reserved: Reserved bit
*/
typedef struct {
uint32_t version;
uint32_t protect;
uint32_t csid_hw_idx_mask;
uint32_t cdm_hw_idx_mask;
uint64_t vc_mask;
uint64_t phy_lane_sel_mask;
uint64_t reserved;
} ITCDriverSensorInfo;
#define ITrustedCameraDriver_ERROR_NOT_ALLOWED 10
#define ITrustedCameraDriver_OP_dynamicProtectSensor 0
#define ITrustedCameraDriver_OP_getVersion 1
#define ITrustedCameraDriver_OP_dynamicConfigureFDPort 3
static inline int32_t
ITrustedCameraDriver_release(struct Object self)
{
return Object_invoke(self, Object_OP_release, 0, 0);
}
static inline int32_t
ITrustedCameraDriver_retain(struct Object self)
{
return Object_invoke(self, Object_OP_retain, 0, 0);
}
/*
* Description: This method allows protecting a camera sensor based on the sensor
* information provided.
*
* In: this - ITrustedCameraDriver object
* In: phy_info_ptr - Camera HW settings required for securing the usecase
* Out: void
* Return: Object_OK on success
* secure camera error codes from seccam_def on failure
*/
static inline int32_t
ITrustedCameraDriver_dynamicProtectSensor(struct Object self,
const ITCDriverSensorInfo *phy_info_ptr)
{
union ObjectArg a[1] = {{{0, 0}}};
a[0].bi = (struct ObjectBufIn) { phy_info_ptr, sizeof(ITCDriverSensorInfo) };
return Object_invoke(self, ITrustedCameraDriver_OP_dynamicProtectSensor, a,
ObjectCounts_pack(1, 0, 0, 0));
}
/*
* Description: Get the current version info
*
* In: this - ITrustedCameraDriver object
* Out: arch_ver_ptr - the pointer of arch version number.
* Out: max_ver_ptr - the pointer of the second part of the version number
* Out: min_ver_ptr - the pointer of the third part of the version number
* Return: Object_OK on success
*/
static inline int32_t
ITrustedCameraDriver_getVersion(struct Object self, uint32_t *arch_ver_ptr,
uint32_t *max_ver_ptr, uint32_t *min_ver_ptr)
{
union ObjectArg a[1] = {{{0, 0}}};
int32_t result;
struct {
uint32_t m_arch_ver;
uint32_t m_max_ver;
uint32_t m_min_ver;
} o = {0};
a[0].b = (struct ObjectBuf) { &o, 12 };
result = Object_invoke(self, ITrustedCameraDriver_OP_getVersion, a,
ObjectCounts_pack(0, 1, 0, 0));
*arch_ver_ptr = o.m_arch_ver;
*max_ver_ptr = o.m_max_ver;
*min_ver_ptr = o.m_min_ver;
return result;
}
/*
* Description: Dynamic configuration to allow secure/non-secure FD port
* on all the CSIDs
*
* In: this - ITrustedCameraDriver object
* In: protect - to secure or non-secure the port
* Out: void
* Return: Object_OK on success
* Object_ERROR on failure
* ITrustedCameraDriver_ERROR_NOT_ALLOWED on request to
* configure FD port even when disabled by OEM
*/
static inline int32_t
ITrustedCameraDriver_dynamicConfigureFDPort(struct Object self, uint32_t protect)
{
union ObjectArg a[1] = {{{0, 0}}};
a[0].b = (struct ObjectBuf) { &protect, sizeof(uint32_t) };
return Object_invoke(self, ITrustedCameraDriver_OP_dynamicConfigureFDPort, a,
ObjectCounts_pack(1, 0, 0, 0));
}

View File

@@ -0,0 +1,108 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef __SMCI_CLIENTENV_H
#define __SMCI_CLIENTENV_H
#include "smci_object.h"
#include "IClientEnv.h"
#define SMCI_CLIENTENV_OP_OPEN 0
#define SMCI_CLIENTENV_OP_REGISTERLEGACY 1
#define SMCI_CLIENTENV_OP_REGISTER 2
#define SMCI_CLIENTENV_OP_REGISTERWITHWHITELIST 3
#define SMCI_CLIENTENV_OP_NOTIFYDOMAINCHANGE 4
#define SMCI_CLIENTENV_OP_REGISTERWITHCREDENTIALS 5
#define SMCI_CLIENTENV_OP_LOADCMNLIBFROMBUFFER 6
#define SMCI_CLIENTENV_OP_CONFIGTAREGION 7
#define SMCI_CLIENTENV_OP_ADCIACCEPT 8
#define SMCI_CLIENTENV_OP_ADCISUTDOWN 9
static inline int32_t
smci_clientenv_release(struct smci_object self)
{
return IClientEnv_release(self);
}
static inline int32_t
smci_clientenv_retain(struct smci_object self)
{
return IClientEnv_retain(self);
}
static inline int32_t
smci_clientenv_open(struct smci_object self, uint32_t uid_val, struct smci_object *obj_ptr)
{
return IClientEnv_open(self, uid_val, obj_ptr);
}
static inline int32_t
smci_clientenv_registerlegacy(struct smci_object self, const void *credentials_ptr,
size_t credentials_len, struct smci_object *clientenv_ptr)
{
return IClientEnv_registerLegacy(self, credentials_ptr,
credentials_len, clientenv_ptr);
}
static inline int32_t
smci_clientenv_register(struct smci_object self, struct smci_object credentials_val,
struct smci_object *clientenv_ptr)
{
return IClientEnv_register(self, credentials_val,
clientenv_ptr);
}
static inline int32_t
smci_clientenv_registerwithwhitelist(struct smci_object self,
struct smci_object credentials_val, const uint32_t *uids_ptr,
size_t uids_len, struct smci_object *clientenv_ptr)
{
return IClientEnv_registerWithWhitelist(self,
credentials_val, uids_ptr,
uids_len, clientenv_ptr);
}
static inline int32_t
smc_clientenv_notifydomainchange(struct smci_object self)
{
return IClientEnv_notifyDomainChange(self);
}
static inline int32_t
smci_clientenv_registerwithcredentials(struct smci_object self, struct smci_object
credentials_val, struct smci_object *clientenv_ptr)
{
return IClientEnv_registerWithCredentials(self,
credentials_val, clientenv_ptr);
}
static inline int32_t
smci_clientenv_loadcmnlibfrombuffer(struct smci_object self, const void *cmnlibelf_ptr,
size_t cmnlibelf_len)
{
return IClientEnv_loadCmnlibFromBuffer(self, cmnlibelf_ptr, cmnlibelf_len);
}
static inline int32_t
smci_clientenv_configtaregion(struct smci_object self, uint64_t apprgnaddr_val,
uint32_t apprgnsize_val)
{
return IClientEnv_configTaRegion(self, apprgnaddr_val, apprgnsize_val);
}
static inline int32_t
smci_clientenv_adciaccept(struct smci_object self)
{
return IClientEnv_adciAccept(self);
}
static inline int32_t
smci_clientenv_adcishutdown(struct smci_object self)
{
return IClientEnv_adciShutdown(self);
}
#endif /* __SMCI_CLIENTENV_H */

View File

@@ -0,0 +1,151 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef __SMCI_OBJECT_H
#define __SMCI_OBJECT_H
#include <linux/types.h>
#include <linux/firmware.h>
#include <linux/qtee_shmbridge.h>
#include "smcinvoke.h"
#include "smcinvoke_object.h"
/*
* Method bits are not modified by transport layers. These describe the
* method (member function) being requested by the client.
*/
#define SMCI_OBJECT_OP_METHOD_MASK (0x0000FFFFu)
#define SMCI_OBJECT_OP_METHODID(op) ((op) & SMCI_OBJECT_OP_METHOD_MASK)
#define SMCI_OBJECT_OP_RELEASE (SMCI_OBJECT_OP_METHOD_MASK - 0)
#define SMCI_OBJECT_OP_RETAIN (SMCI_OBJECT_OP_METHOD_MASK - 1)
#define SMCI_OBJECT_OP_MAP_REGION 0
#define SMCI_OBJECT_OP_YIELD 1
#define SMCI_OBJECT_OP_SLEEP 2
#define SMCI_OBJECT_COUNTS_MAX_BI 0xF
#define SMCI_OBJECT_COUNTS_MAX_BO 0xF
#define SMCI_OBJECT_COUNTS_MAX_OI 0xF
#define SMCI_OBJECT_COUNTS_MAX_OO 0xF
/* unpack counts */
#define SMCI_OBJECT_COUNTS_NUM_BI(k) ((size_t) (((k) >> 0) & SMCI_OBJECT_COUNTS_MAX_BI))
#define SMCI_OBJECT_COUNTS_NUM_BO(k) ((size_t) (((k) >> 4) & SMCI_OBJECT_COUNTS_MAX_BO))
#define SMCI_OBJECT_COUNTS_NUM_OI(k) ((size_t) (((k) >> 8) & SMCI_OBJECT_COUNTS_MAX_OI))
#define SMCI_OBJECT_COUNTS_NUM_OO(k) ((size_t) (((k) >> 12) & SMCI_OBJECT_COUNTS_MAX_OO))
#define SMCI_OBJECT_COUNTS_NUM_BUFFERS(k) \
(SMCI_OBJECT_COUNTS_NUM_BI(k) + SMCI_OBJECT_COUNTS_NUM_BO(k))
#define SMCI_OBJECT_COUNTS_NUM_OBJECTS(k) \
(SMCI_OBJECT_COUNTS_NUM_OI(k) + SMCI_OBJECT_COUNTS_NUM_OO(k))
/* Indices into args[] */
#define SMCI_OBJECT_COUNTS_INDEX_BI(k) 0
#define SMCI_OBJECT_COUNTS_INDEX_BO(k) \
(SMCI_OBJECT_COUNTS_INDEX_BI(k) + SMCI_OBJECT_COUNTS_NUM_BI(k))
#define SMCI_OBJECT_COUNTS_INDEX_OI(k) \
(SMCI_OBJECT_COUNTS_INDEX_BO(k) + SMCI_OBJECT_COUNTS_NUM_BO(k))
#define SMCI_OBJECT_COUNTS_INDEX_OO(k) \
(SMCI_OBJECT_COUNTS_INDEX_OI(k) + SMCI_OBJECT_COUNTS_NUM_OI(k))
#define SMCI_OBJECT_COUNTS_TOTAL(k) \
(SMCI_OBJECT_COUNTS_INDEX_OO(k) + SMCI_OBJECT_COUNTS_NUM_OO(k))
#define SMCI_OBJECT_COUNTS_PACK(in_bufs, out_bufs, in_objs, out_objs) \
((uint32_t) ((in_bufs) | ((out_bufs) << 4) | \
((in_objs) << 8) | ((out_objs) << 12)))
#define SMCI_OBJECT_COUNTS_INDEX_BUFFERS(k) SMCI_OBJECT_COUNTS_INDEX_BI(k)
/* Object_invoke return codes */
#define SMCI_OBJECT_IS_OK(err) ((err) == 0)
#define SMCI_OBJECT_IS_ERROR(err) ((err) != 0)
/* Generic error codes */
#define SMCI_OBJECT_OK 0 /* non-specific success code */
#define SMCI_OBJECT_ERROR 1 /* non-specific error */
#define SMCI_OBJECT_ERROR_INVALID 2 /* unsupported/unrecognized request */
#define SMCI_OBJECT_ERROR_SIZE_IN 3 /* supplied buffer/string too large */
#define SMCI_OBJECT_ERROR_SIZE_OUT 4 /* supplied output buffer too small */
#define SMCI_OBJECT_ERROR_USERBASE 10 /* start of user-defined error range */
/* Transport layer error codes */
#define SMCI_OBJECT_ERROR_DEFUNCT -90 /* smci_object no longer exists */
#define SMCI_OBJECT_ERROR_ABORT -91 /* calling thread must exit */
#define SMCI_OBJECT_ERROR_BADOBJ -92 /* invalid smci_object context */
#define SMCI_OBJECT_ERROR_NOSLOTS -93 /* caller's smci_object table full */
#define SMCI_OBJECT_ERROR_MAXARGS -94 /* too many args */
#define SMCI_OBJECT_ERROR_MAXDATA -95 /* buffers too large */
#define SMCI_OBJECT_ERROR_UNAVAIL -96 /* the request could not be processed */
#define SMCI_OBJECT_ERROR_KMEM -97 /* kernel out of memory */
#define SMCI_OBJECT_ERROR_REMOTE -98 /* local method sent to remote smci_object */
#define SMCI_OBJECT_ERROR_BUSY -99 /* smci_object is busy */
#define SMCI_OBJECT_ERROR_TIMEOUT -103 /* Call Back smci_object invocation timed out. */
/* smci_objectop */
#define SMCI_OBJECT_OP_LOCAL ((uint32_t) 0x00008000U)
#define SMCI_OBJECT_OP_IS_LOCAL(op) (((op) & SMCI_OBJECT_OP_LOCAL) != 0)
/* smci_object */
#define SMCI_OBJECTCOUNTS_PACK(nbuffersin, nbuffersout, nobjectsin, nobjectsout) \
((uint32_t) ((nbuffersin) | \
((nbuffersout) << 4) | \
((nobjectsin) << 8) | \
((nobjectsout) << 12)))
#define smci_object_arg ObjectArg
#define smci_objectinvoke ObjectInvoke
#define smci_object Object
#define smci_object_buf ObjectBuf
#define smci_object_buf_in ObjectBufIn
static inline int32_t smci_object_invoke(struct smci_object o, uint32_t op,
union smci_object_arg *args, uint32_t k)
{
return Object_invoke(o, op, args, k);
}
#define SMCI_OBJECT_NULL ((struct smci_object){NULL, NULL})
#define SMCI_OBJECT_NOT_RETAINED
#define SMCI_OBJECT_CONSUMED
static inline int32_t smci_object_release(SMCI_OBJECT_CONSUMED struct smci_object o)
{
return Object_release(o);
}
static inline int32_t smci_object_retain(struct smci_object o)
{
return Object_retain(o);
}
#define SMCI_OBJECT_IS_NULL(o) ((o).invoke == NULL)
#define SMCI_OBJECT_RELEASE_IF(o) \
do { \
struct smci_object o_ = (o); \
if (!SMCI_OBJECT_IS_NULL(o_)) \
(void) smci_object_release(o_); \
} while (0)
static inline void smci_object_replace(struct smci_object *loc, struct smci_object obj_new)
{
Object_replace(loc, obj_new);
}
#define SMCI_OBJECT_ASSIGN_NULL(loc) smci_object_replace(&(loc), SMCI_OBJECT_NULL)
#endif /* __SMCI_OBJECT_H */

View File

@@ -0,0 +1,110 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _UAPI_SMCINVOKE_H_
#define _UAPI_SMCINVOKE_H_
#include <linux/types.h>
#include <linux/ioctl.h>
#define SMCINVOKE_USERSPACE_OBJ_NULL -1
#define DEFAULT_CB_OBJ_THREAD_CNT 4
#define SMCINVOKE_TZ_MIN_BUF_SIZE 4096
struct smcinvoke_buf {
__u64 addr;
__u64 size;
};
struct smcinvoke_obj {
__s64 fd;
__s64 cb_server_fd;
__s64 reserved;
};
union smcinvoke_arg {
struct smcinvoke_buf b;
struct smcinvoke_obj o;
};
/*
* struct smcinvoke_cmd_req: This structure is transparently sent to TEE
* @op - Operation to be performed
* @counts - number of aruments passed
* @result - result of invoke operation
* @argsize - size of each of arguments
* @args - args is pointer to buffer having all arguments
* @reserved: IN/OUT: Usage is not defined but should be set to 0
*/
struct smcinvoke_cmd_req {
__u32 op;
__u32 counts;
__s32 result;
__u32 argsize;
__u64 args;
__s64 reserved;
};
/*
* struct smcinvoke_accept: structure to process CB req from TEE
* @has_resp: IN: Whether IOCTL is carrying response data
* @result: IN: Outcome of operation op
* @op: OUT: Operation to be performed on target object
* @counts: OUT: Number of arguments, embedded in buffer pointed by
* buf_addr, to complete operation
* @reserved: IN/OUT: Usage is not defined but should be set to 0.
* @argsize: IN: Size of any argument, all of equal size, embedded
* in buffer pointed by buf_addr
* @txn_id: OUT: An id that should be passed as it is for response
* @cbobj_id: OUT: Callback object which is target of operation op
* @buf_len: IN: Len of buffer pointed by buf_addr
* @buf_addr: IN: Buffer containing all arguments which are needed
* to complete operation op
*/
struct smcinvoke_accept {
__u32 has_resp;
__s32 result;
__u32 op;
__u32 counts;
__s32 reserved;
__u32 argsize;
__u64 txn_id;
__s64 cbobj_id;
__u64 buf_len;
__u64 buf_addr;
};
/*
* @cb_buf_size: IN: Max buffer size for any callback obj implemented by client
* @reserved: IN/OUT: Usage is not defined but should be set to 0
*/
struct smcinvoke_server {
__u64 cb_buf_size;
__s64 reserved;
};
#define SMCINVOKE_IOC_MAGIC 0x98
#define SMCINVOKE_IOCTL_INVOKE_REQ \
_IOWR(SMCINVOKE_IOC_MAGIC, 1, struct smcinvoke_cmd_req)
#define SMCINVOKE_IOCTL_ACCEPT_REQ \
_IOWR(SMCINVOKE_IOC_MAGIC, 2, struct smcinvoke_accept)
#define SMCINVOKE_IOCTL_SERVER_REQ \
_IOWR(SMCINVOKE_IOC_MAGIC, 3, struct smcinvoke_server)
#define SMCINVOKE_IOCTL_ACK_LOCAL_OBJ \
_IOWR(SMCINVOKE_IOC_MAGIC, 4, __s64)
/*
* smcinvoke logging buffer is for communicating with the smcinvoke driver additional
* info for debugging to be included in driver's log (if any)
*/
#define SMCINVOKE_LOG_BUF_SIZE 100
#define SMCINVOKE_IOCTL_LOG \
_IOC(_IOC_READ|_IOC_WRITE, SMCINVOKE_IOC_MAGIC, 255, SMCINVOKE_LOG_BUF_SIZE)
#endif /* _UAPI_SMCINVOKE_H_ */

View File

@@ -0,0 +1,202 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef __SMCINVOKE_OBJECT_H
#define __SMCINVOKE_OBJECT_H
#include <linux/types.h>
#include <linux/firmware.h>
#include <linux/qtee_shmbridge.h>
#include "smcinvoke.h"
/*
* Method bits are not modified by transport layers. These describe the
* method (member function) being requested by the client.
*/
#define OBJECT_OP_METHOD_MASK (0x0000FFFFu)
#define OBJECT_OP_METHODID(op) ((op) & OBJECT_OP_METHOD_MASK)
#define OBJECT_OP_RELEASE (OBJECT_OP_METHOD_MASK - 0)
#define OBJECT_OP_RETAIN (OBJECT_OP_METHOD_MASK - 1)
#define OBJECT_OP_MAP_REGION 0
#define OBJECT_OP_YIELD 1
#define OBJECT_OP_SLEEP 2
#define OBJECT_COUNTS_MAX_BI 0xF
#define OBJECT_COUNTS_MAX_BO 0xF
#define OBJECT_COUNTS_MAX_OI 0xF
#define OBJECT_COUNTS_MAX_OO 0xF
/* unpack counts */
#define OBJECT_COUNTS_NUM_BI(k) ((size_t) (((k) >> 0) & OBJECT_COUNTS_MAX_BI))
#define OBJECT_COUNTS_NUM_BO(k) ((size_t) (((k) >> 4) & OBJECT_COUNTS_MAX_BO))
#define OBJECT_COUNTS_NUM_OI(k) ((size_t) (((k) >> 8) & OBJECT_COUNTS_MAX_OI))
#define OBJECT_COUNTS_NUM_OO(k) ((size_t) (((k) >> 12) & OBJECT_COUNTS_MAX_OO))
#define OBJECT_COUNTS_NUM_buffers(k) \
(OBJECT_COUNTS_NUM_BI(k) + OBJECT_COUNTS_NUM_BO(k))
#define OBJECT_COUNTS_NUM_objects(k) \
(OBJECT_COUNTS_NUM_OI(k) + OBJECT_COUNTS_NUM_OO(k))
/* Indices into args[] */
#define OBJECT_COUNTS_INDEX_BI(k) 0
#define OBJECT_COUNTS_INDEX_BO(k) \
(OBJECT_COUNTS_INDEX_BI(k) + OBJECT_COUNTS_NUM_BI(k))
#define OBJECT_COUNTS_INDEX_OI(k) \
(OBJECT_COUNTS_INDEX_BO(k) + OBJECT_COUNTS_NUM_BO(k))
#define OBJECT_COUNTS_INDEX_OO(k) \
(OBJECT_COUNTS_INDEX_OI(k) + OBJECT_COUNTS_NUM_OI(k))
#define OBJECT_COUNTS_TOTAL(k) \
(OBJECT_COUNTS_INDEX_OO(k) + OBJECT_COUNTS_NUM_OO(k))
#define OBJECT_COUNTS_PACK(in_bufs, out_bufs, in_objs, out_objs) \
((uint32_t) ((in_bufs) | ((out_bufs) << 4) | \
((in_objs) << 8) | ((out_objs) << 12)))
#define OBJECT_COUNTS_INDEX_buffers(k) OBJECT_COUNTS_INDEX_BI(k)
/* Object_invoke return codes */
#define OBJECT_isOK(err) ((err) == 0)
#define OBJECT_isERROR(err) ((err) != 0)
/* Generic error codes */
#define OBJECT_OK 0 /* non-specific success code */
#define OBJECT_ERROR 1 /* non-specific error */
#define OBJECT_ERROR_INVALID 2 /* unsupported/unrecognized request */
#define OBJECT_ERROR_SIZE_IN 3 /* supplied buffer/string too large */
#define OBJECT_ERROR_SIZE_OUT 4 /* supplied output buffer too small */
#define OBJECT_ERROR_USERBASE 10 /* start of user-defined error range */
/* Transport layer error codes */
#define OBJECT_ERROR_DEFUNCT -90 /* object no longer exists */
#define OBJECT_ERROR_ABORT -91 /* calling thread must exit */
#define OBJECT_ERROR_BADOBJ -92 /* invalid object context */
#define OBJECT_ERROR_NOSLOTS -93 /* caller's object table full */
#define OBJECT_ERROR_MAXARGS -94 /* too many args */
#define OBJECT_ERROR_MAXDATA -95 /* buffers too large */
#define OBJECT_ERROR_UNAVAIL -96 /* the request could not be processed */
#define OBJECT_ERROR_KMEM -97 /* kernel out of memory */
#define OBJECT_ERROR_REMOTE -98 /* local method sent to remote object */
#define OBJECT_ERROR_BUSY -99 /* Object is busy */
#define Object_ERROR_TIMEOUT -103 /* Call Back Object invocation timed out. */
#define FOR_ARGS(ndxvar, counts, section) \
for (ndxvar = OBJECT_COUNTS_INDEX_##section(counts); \
ndxvar < (OBJECT_COUNTS_INDEX_##section(counts) \
+ OBJECT_COUNTS_NUM_##section(counts)); \
++ndxvar)
/* ObjectOp */
#define ObjectOp_METHOD_MASK ((uint32_t) 0x0000FFFFu)
#define ObjectOp_methodID(op) ((op) & ObjectOp_METHOD_MASK)
#define ObjectOp_LOCAL ((uint32_t) 0x00008000U)
#define ObjectOp_isLocal(op) (((op) & ObjectOp_LOCAL) != 0)
#define Object_OP_release (ObjectOp_METHOD_MASK - 0)
#define Object_OP_retain (ObjectOp_METHOD_MASK - 1)
/* Object */
#define ObjectCounts_pack(nBuffersIn, nBuffersOut, nObjectsIn, nObjectsOut) \
((uint32_t) ((nBuffersIn) | \
((nBuffersOut) << 4) | \
((nObjectsIn) << 8) | \
((nObjectsOut) << 12)))
union ObjectArg;
struct smcinvoke_cmd_req;
typedef int32_t (*ObjectInvoke)(void *h,
uint32_t op,
union ObjectArg *args,
uint32_t counts);
struct Object {
ObjectInvoke invoke;
void *context;
};
struct ObjectBuf {
void *ptr;
size_t size;
};
struct ObjectBufIn {
const void *ptr;
size_t size;
};
union ObjectArg {
struct ObjectBuf b;
struct ObjectBufIn bi;
struct Object o;
};
static inline int32_t Object_invoke(struct Object o, uint32_t op,
union ObjectArg *args, uint32_t k)
{
return o.invoke(o.context, op, args, k);
}
#define Object_NULL ((struct Object){NULL, NULL})
#define OBJECT_NOT_RETAINED
#define OBJECT_CONSUMED
static inline int32_t Object_release(OBJECT_CONSUMED struct Object o)
{
return Object_invoke((o), Object_OP_release, 0, 0);
}
static inline int32_t Object_retain(struct Object o)
{
return Object_invoke((o), Object_OP_retain, 0, 0);
}
#define Object_isNull(o) ((o).invoke == NULL)
#define Object_RELEASE_IF(o) \
do { \
struct Object o_ = (o); \
if (!Object_isNull(o_)) \
(void) Object_release(o_); \
} while (0)
static inline void Object_replace(struct Object *loc, struct Object objNew)
{
if (!Object_isNull(*loc))
Object_release(*loc);
if (!Object_isNull(objNew))
Object_retain(objNew);
*loc = objNew;
}
#define Object_ASSIGN_NULL(loc) Object_replace(&(loc), Object_NULL)
#define SMCINVOKE_INTERFACE_MAX_RETRY 5
#define SMCINVOKE_INTERFACE_BUSY_WAIT_MS 5
int smcinvoke_release_from_kernel_client(int fd);
int get_root_fd(int *root_fd);
int process_invoke_request_from_kernel_client(
int fd, struct smcinvoke_cmd_req *req);
char *firmware_request_from_smcinvoke(const char *appname, size_t *fw_size, struct qtee_shm *shm);
int32_t get_client_env_object(struct Object *clientEnvObj);
#endif /* __SMCINVOKE_OBJECT_H */

View File

@@ -0,0 +1,48 @@
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
/** @cond */
#pragma once
#include "smcinvoke_object.h"
#define IAppClient_ERROR_APP_NOT_FOUND INT32_C(10)
#define IAppClient_ERROR_APP_RESTART_FAILED INT32_C(11)
#define IAppClient_ERROR_APP_UNTRUSTED_CLIENT INT32_C(12)
#define IAppClient_ERROR_CLIENT_CRED_PARSING_FAILURE INT32_C(13)
#define IAppClient_ERROR_APP_LOAD_FAILED INT32_C(14)
#define IAppClient_OP_getAppObject 0
static inline int32_t
IAppClient_release(struct Object self)
{
return Object_invoke(self, Object_OP_release, 0, 0);
}
static inline int32_t
IAppClient_retain(struct Object self)
{
return Object_invoke(self, Object_OP_retain, 0, 0);
}
static inline int32_t
IAppClient_getAppObject(struct Object self, const void *appDistName_ptr, size_t appDistName_len,struct Object *obj_ptr)
{
int32_t result;
union ObjectArg a[2];
a[0].bi = (struct ObjectBufIn) { appDistName_ptr, appDistName_len * 1 };
result = Object_invoke(self, IAppClient_OP_getAppObject, a, ObjectCounts_pack(1, 0, 0, 1));
*obj_ptr = a[1].o;
return result;
}

View File

@@ -0,0 +1,143 @@
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
/** @cond */
#pragma once
#include "smcinvoke_object.h"
#define IAppController_CBO_INTERFACE_WAIT UINT32_C(1)
#define IAppController_ERROR_APP_SUSPENDED INT32_C(10)
#define IAppController_ERROR_APP_BLOCKED_ON_LISTENER INT32_C(11)
#define IAppController_ERROR_APP_UNLOADED INT32_C(12)
#define IAppController_ERROR_APP_IN_USE INT32_C(13)
#define IAppController_ERROR_NOT_SUPPORTED INT32_C(14)
#define IAppController_ERROR_CBO_UNKNOWN INT32_C(15)
#define IAppController_ERROR_APP_UNLOAD_NOT_ALLOWED INT32_C(16)
#define IAppController_ERROR_APP_DISCONNECTED INT32_C(17)
#define IAppController_ERROR_USER_DISCONNECT_REJECTED INT32_C(18)
#define IAppController_ERROR_STILL_RUNNING INT32_C(19)
#define IAppController_OP_openSession 0
#define IAppController_OP_unload 1
#define IAppController_OP_getAppObject 2
#define IAppController_OP_installCBO 3
#define IAppController_OP_disconnect 4
#define IAppController_OP_restart 5
static inline int32_t
IAppController_release(struct Object self)
{
return Object_invoke(self, Object_OP_release, 0, 0);
}
static inline int32_t
IAppController_retain(struct Object self)
{
return Object_invoke(self, Object_OP_retain, 0, 0);
}
static inline int32_t
IAppController_openSession(struct Object self, uint32_t cancelCode_val, uint32_t connectionMethod_val, uint32_t connectionData_val, uint32_t paramTypes_val, uint32_t exParamTypes_val, const void *i1_ptr, size_t i1_len, const void *i2_ptr, size_t i2_len, const void *i3_ptr, size_t i3_len, const void *i4_ptr, size_t i4_len, void *o1_ptr, size_t o1_len, size_t *o1_lenout, void *o2_ptr, size_t o2_len, size_t *o2_lenout, void *o3_ptr, size_t o3_len, size_t *o3_lenout, void *o4_ptr, size_t o4_len, size_t *o4_lenout,struct Object imem1_val,struct Object imem2_val,struct Object imem3_val,struct Object imem4_val, uint32_t *memrefOutSz1_ptr, uint32_t *memrefOutSz2_ptr, uint32_t *memrefOutSz3_ptr, uint32_t *memrefOutSz4_ptr,struct Object *session_ptr, uint32_t *retValue_ptr, uint32_t *retOrigin_ptr)
{
union ObjectArg a[15];
struct {
uint32_t m_cancelCode;
uint32_t m_connectionMethod;
uint32_t m_connectionData;
uint32_t m_paramTypes;
uint32_t m_exParamTypes;
} i;
struct {
uint32_t m_memrefOutSz1;
uint32_t m_memrefOutSz2;
uint32_t m_memrefOutSz3;
uint32_t m_memrefOutSz4;
uint32_t m_retValue;
uint32_t m_retOrigin;
} o;
int32_t result;
a[0].b = (struct ObjectBuf) { &i, 20 };
a[5].b = (struct ObjectBuf) { &o, 24 };
i.m_cancelCode = cancelCode_val;
i.m_connectionMethod = connectionMethod_val;
i.m_connectionData = connectionData_val;
i.m_paramTypes = paramTypes_val;
i.m_exParamTypes = exParamTypes_val;
a[1].bi = (struct ObjectBufIn) { i1_ptr, i1_len * 1 };
a[2].bi = (struct ObjectBufIn) { i2_ptr, i2_len * 1 };
a[3].bi = (struct ObjectBufIn) { i3_ptr, i3_len * 1 };
a[4].bi = (struct ObjectBufIn) { i4_ptr, i4_len * 1 };
a[6].b = (struct ObjectBuf) { o1_ptr, o1_len * 1 };
a[7].b = (struct ObjectBuf) { o2_ptr, o2_len * 1 };
a[8].b = (struct ObjectBuf) { o3_ptr, o3_len * 1 };
a[9].b = (struct ObjectBuf) { o4_ptr, o4_len * 1 };
a[10].o = imem1_val;
a[11].o = imem2_val;
a[12].o = imem3_val;
a[13].o = imem4_val;
result = Object_invoke(self, IAppController_OP_openSession, a, ObjectCounts_pack(5, 5, 4, 1));
*o1_lenout = a[6].b.size / 1;
*o2_lenout = a[7].b.size / 1;
*o3_lenout = a[8].b.size / 1;
*o4_lenout = a[9].b.size / 1;
*memrefOutSz1_ptr = o.m_memrefOutSz1;
*memrefOutSz2_ptr = o.m_memrefOutSz2;
*memrefOutSz3_ptr = o.m_memrefOutSz3;
*memrefOutSz4_ptr = o.m_memrefOutSz4;
*session_ptr = a[14].o;
*retValue_ptr = o.m_retValue;
*retOrigin_ptr = o.m_retOrigin;
return result;
}
static inline int32_t
IAppController_unload(struct Object self)
{
return Object_invoke(self, IAppController_OP_unload, 0, 0);
}
static inline int32_t
IAppController_getAppObject(struct Object self,struct Object *obj_ptr)
{
union ObjectArg a[1];
int32_t result = Object_invoke(self, IAppController_OP_getAppObject, a, ObjectCounts_pack(0, 0, 0, 1));
*obj_ptr = a[0].o;
return result;
}
static inline int32_t
IAppController_installCBO(struct Object self, uint32_t uid_val,struct Object obj_val)
{
union ObjectArg a[2];
a[0].b = (struct ObjectBuf) { &uid_val, sizeof(uint32_t) };
a[1].o = obj_val;
return Object_invoke(self, IAppController_OP_installCBO, a, ObjectCounts_pack(1, 0, 1, 0));
}
static inline int32_t
IAppController_disconnect(struct Object self)
{
return Object_invoke(self, IAppController_OP_disconnect, 0, 0);
}
static inline int32_t
IAppController_restart(struct Object self)
{
return Object_invoke(self, IAppController_OP_restart, 0, 0);
}

View File

@@ -0,0 +1,105 @@
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#pragma once
#include "smcinvoke_object.h"
#include "IAppController.h"
#define IAppLoader_ERROR_INVALID_BUFFER INT32_C(10)
#define IAppLoader_ERROR_PIL_ROLLBACK_FAILURE INT32_C(11)
#define IAppLoader_ERROR_ELF_SIGNATURE_ERROR INT32_C(12)
#define IAppLoader_ERROR_METADATA_INVALID INT32_C(13)
#define IAppLoader_ERROR_MAX_NUM_APPS INT32_C(14)
#define IAppLoader_ERROR_NO_NAME_IN_METADATA INT32_C(15)
#define IAppLoader_ERROR_ALREADY_LOADED INT32_C(16)
#define IAppLoader_ERROR_EMBEDDED_IMAGE_NOT_FOUND INT32_C(17)
#define IAppLoader_ERROR_TZ_HEAP_MALLOC_FAILURE INT32_C(18)
#define IAppLoader_ERROR_TA_APP_REGION_MALLOC_FAILURE INT32_C(19)
#define IAppLoader_ERROR_CLIENT_CRED_PARSING_FAILURE INT32_C(20)
#define IAppLoader_ERROR_APP_UNTRUSTED_CLIENT INT32_C(21)
#define IAppLoader_ERROR_APP_NOT_LOADED INT32_C(22)
#define IAppLoader_ERROR_APP_MAX_CLIENT_CONNECTIONS INT32_C(23)
#define IAppLoader_ERROR_APP_BLACKLISTED INT32_C(24)
#define IAppLoader_OP_loadFromBuffer 0
#define IAppLoader_OP_loadFromRegion 1
#define IAppLoader_OP_loadEmbedded 2
#define IAppLoader_OP_connect 3
static inline int32_t
IAppLoader_release(struct Object self)
{
return Object_invoke(self, Object_OP_release, 0, 0);
}
static inline int32_t
IAppLoader_retain(struct Object self)
{
return Object_invoke(self, Object_OP_retain, 0, 0);
}
static inline int32_t
IAppLoader_loadFromBuffer(struct Object self, const void *appElf_ptr, size_t appElf_len,struct Object *appController_ptr)
{
union ObjectArg a[2];
int32_t result;
a[0].bi = (struct ObjectBufIn) { appElf_ptr, appElf_len * 1 };
result = Object_invoke(self, IAppLoader_OP_loadFromBuffer, a, ObjectCounts_pack(1, 0, 0, 1));
*appController_ptr = a[1].o;
return result;
}
static inline int32_t
IAppLoader_loadFromRegion(struct Object self,struct Object appElf_val,struct Object *appController_ptr)
{
union ObjectArg a[2];
int32_t result;
a[0].o = appElf_val;
result = Object_invoke(self, IAppLoader_OP_loadFromRegion, a, ObjectCounts_pack(0, 0, 1, 1));
*appController_ptr = a[1].o;
return result;
}
static inline int32_t
IAppLoader_loadEmbedded(struct Object self, const void *appName_ptr, size_t appName_len,struct Object *appController_ptr)
{
union ObjectArg a[2];
int32_t result;
a[0].bi = (struct ObjectBufIn) { appName_ptr, appName_len * 1 };
result = Object_invoke(self, IAppLoader_OP_loadEmbedded, a, ObjectCounts_pack(1, 0, 0, 1));
*appController_ptr = a[1].o;
return result;
}
static inline int32_t
IAppLoader_connect(struct Object self, const void *appName_ptr, size_t appName_len,struct Object *appController_ptr)
{
union ObjectArg a[2];
int32_t result;
a[0].bi = (struct ObjectBufIn) { appName_ptr, appName_len * 1 };
result = Object_invoke(self, IAppLoader_OP_connect, a, ObjectCounts_pack(1, 0, 0, 1));
*appController_ptr = a[1].o;
return result;
}

View File

@@ -0,0 +1,48 @@
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
/** @cond */
#pragma once
#include "smcinvoke_object.h"
/** 0 is not a valid service ID. */
#define IOpener_INVALID_ID UINT32_C(0)
#define IOpener_ERROR_NOT_FOUND INT32_C(10)
#define IOpener_ERROR_PRIVILEGE INT32_C(11)
#define IOpener_ERROR_NOT_SUPPORTED INT32_C(12)
#define IOpener_OP_open 0
static inline int32_t
IOpener_release(struct Object self)
{
return Object_invoke(self, Object_OP_release, 0, 0);
}
static inline int32_t
IOpener_retain(struct Object self)
{
return Object_invoke(self, Object_OP_retain, 0, 0);
}
static inline int32_t
IOpener_open(struct Object self, uint32_t id_val,struct Object *obj_ptr)
{
union ObjectArg a[2];
int32_t result;
a[0].b = (struct ObjectBuf) { &id_val, sizeof(uint32_t) };
result = Object_invoke(self, IOpener_OP_open, a, ObjectCounts_pack(1, 0, 0, 1));
*obj_ptr = a[1].o;
return result;
}

View File

@@ -0,0 +1,41 @@
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef __SMCI_APPCLIENT_H
#define __SMCI_APPCLIENT_H
#include "smci_object.h"
#include "IAppClient.h"
#define SMCI_APPCLIENT_ERROR_APP_NOT_FOUND INT32_C(10)
#define SMCI_APPCLIENT_ERROR_APP_RESTART_FAILED INT32_C(11)
#define SMCI_APPCLIENT_ERROR_APP_UNTRUSTED_CLIENT INT32_C(12)
#define SMCI_APPCLIENT_ERROR_CLIENT_CRED_PARSING_FAILURE INT32_C(13)
#define SMCI_APPCLIENT_ERROR_APP_LOAD_FAILED INT32_C(14)
#define SMCI_APPCLIENT_UID (0x97)
#define SMCI_APPCLIENT_OP_GETAPPOBJECT 0
static inline int32_t
smci_appclient_release(struct smci_object self)
{
return IAppClient_release(self);
}
static inline int32_t
smci_appclient_retain(struct smci_object self)
{
return IAppClient_retain(self);
}
static inline int32_t
smci_appclient_getappobject(struct smci_object self, const void *app_dist_name_ptr,
size_t app_dist_name_len, struct smci_object *obj_ptr)
{
return IAppClient_getAppObject(self, app_dist_name_ptr,
app_dist_name_len, obj_ptr);
}
#endif /* __SMCI_APPCLIENT_H */

View File

@@ -0,0 +1,100 @@
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef __SMCI_APPCONTROLLER_H
#define __SMCI_APPCONTROLLER_H
#include "smci_object.h"
#include "IAppController.h"
#define SMCI_APPCONTROLLER_CBO_INTERFACE_WAIT UINT32_C(1)
#define SMCI_APPCONTROLLER_ERROR_APP_SUSPENDED INT32_C(10)
#define SMCI_APPCONTROLLER_ERROR_APP_BLOCKED_ON_LISTENER INT32_C(11)
#define SMCI_APPCONTROLLER_ERROR_APP_UNLOADED INT32_C(12)
#define SMCI_APPCONTROLLER_ERROR_APP_IN_USE INT32_C(13)
#define SMCI_APPCONTROLLER_ERROR_NOT_SUPPORTED INT32_C(14)
#define SMCI_APPCONTROLLER_ERROR_CBO_UNKNOWN INT32_C(15)
#define SMCI_APPCONTROLLER_ERROR_APP_UNLOAD_NOT_ALLOWED INT32_C(16)
#define SMCI_APPCONTROLLER_ERROR_APP_DISCONNECTED INT32_C(17)
#define SMCI_APPCONTROLLER_ERROR_USER_DISCONNECT_REJECTED INT32_C(18)
#define SMCI_APPCONTROLLER_ERROR_STILL_RUNNING INT32_C(19)
#define SMCI_APPCONTROLLER_OP_OPENSESSION 0
#define SMCI_APPCONTROLLER_OP_UNLOAD 1
#define SMCI_APPCONTROLLER_OP_GETAPPOBJECT 2
#define SMCI_APPCONTROLLER_OP_INSTALLCBO 3
#define SMCI_APPCONTROLLER_OP_DISCONNECT 4
#define SMCI_APPCONTROLLER_OP_RESTART 5
static inline int32_t
smci_appcontroller_release(struct smci_object self)
{
return IAppController_release(self);
}
static inline int32_t
smci_appcontroller_retain(struct smci_object self)
{
return IAppController_retain(self);
}
static inline int32_t
smci_appcontroller_opensession(struct smci_object self, uint32_t cancel_code_val,
uint32_t connection_method_val, uint32_t connection_data_val, uint32_t param_types_val,
uint32_t ex_param_types_val, const void *i1_ptr, size_t i1_len, const void *i2_ptr,
size_t i2_len, const void *i3_ptr, size_t i3_len, const void *i4_ptr, size_t i4_len,
void *o1_ptr, size_t o1_len, size_t *o1_lenout, void *o2_ptr, size_t o2_len,
size_t *o2_lenout, void *o3_ptr, size_t o3_len, size_t *o3_lenout, void *o4_ptr,
size_t o4_len, size_t *o4_lenout, struct smci_object imem1_val,
struct smci_object imem2_val, struct smci_object imem3_val, struct smci_object imem4_val,
uint32_t *memref_out_sz1_ptr, uint32_t *memref_out_sz2_ptr, uint32_t *memref_out_sz3_ptr,
uint32_t *memref_out_sz4_ptr, struct smci_object *session_ptr, uint32_t *ret_value_ptr,
uint32_t *ret_origin_ptr)
{
return IAppController_openSession(self, cancel_code_val,
connection_method_val, connection_data_val, param_types_val,
ex_param_types_val, i1_ptr, i1_len, i2_ptr,
i2_len, i3_ptr, i3_len, i4_ptr, i4_len,
o1_ptr, o1_len, o1_lenout, o2_ptr, o2_len,
o2_lenout, o3_ptr, o3_len, o3_lenout, o4_ptr,
o4_len, o4_lenout, imem1_val,
imem2_val, imem3_val, imem4_val,
memref_out_sz1_ptr, memref_out_sz2_ptr, memref_out_sz3_ptr,
memref_out_sz4_ptr, session_ptr, ret_value_ptr,
ret_origin_ptr);
}
static inline int32_t
smci_appcontroller_unload(struct smci_object self)
{
return IAppController_unload(self);
}
static inline int32_t
smci_appcontroller_getappobject(struct smci_object self, struct smci_object *obj_ptr)
{
return IAppController_getAppObject(self, obj_ptr);
}
static inline int32_t
smci_appcontroller_installcbo(struct smci_object self, uint32_t uid_val, struct smci_object obj_val)
{
return IAppController_installCBO(self, uid_val, obj_val);
}
static inline int32_t
smci_appcontroller_disconnect(struct smci_object self)
{
return IAppController_disconnect(self);
}
static inline int32_t
smci_appcontroller_restart(struct smci_object self)
{
return IAppController_restart(self);
}
#endif /* __SMCI_APPCONTROLLER_H */

View File

@@ -0,0 +1,79 @@
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef __SMCI_APPLOADER_H
#define __SMCI_APPLOADER_H
#include "smci_object.h"
#include "smci_appcontroller.h"
#include "IAppLoader.h"
#define SMCI_APPLOADER_ERROR_INVALID_BUFFER INT32_C(10)
#define SMCI_APPLOADER_ERROR_PIL_ROLLBACK_FAILURE INT32_C(11)
#define SMCI_APPLOADER_ERROR_ELF_SIGNATURE_ERROR INT32_C(12)
#define SMCI_APPLOADER_ERROR_METADATA_INVALID INT32_C(13)
#define SMCI_APPLOADER_ERROR_MAX_NUM_APPS INT32_C(14)
#define SMCI_APPLOADER_ERROR_NO_NAME_IN_METADATA INT32_C(15)
#define SMCI_APPLOADER_ERROR_ALREADY_LOADED INT32_C(16)
#define SMCI_APPLOADER_ERROR_EMBEDDED_IMAGE_NOT_FOUND INT32_C(17)
#define SMCI_APPLOADER_ERROR_TZ_HEAP_MALLOC_FAILURE INT32_C(18)
#define SMCI_APPLOADER_ERROR_TA_APP_REGION_MALLOC_FAILURE INT32_C(19)
#define SMCI_APPLOADER_ERROR_CLIENT_CRED_PARSING_FAILURE INT32_C(20)
#define SMCI_APPLOADER_ERROR_APP_UNTRUSTED_CLIENT INT32_C(21)
#define SMCI_APPLOADER_ERROR_APP_NOT_LOADED INT32_C(22)
#define SMCI_APPLOADER_ERROR_APP_MAX_CLIENT_CONNECTIONS INT32_C(23)
#define SMCI_APPLOADER_ERROR_APP_BLACKLISTED INT32_C(24)
#define SMCI_APPLOADER_OP_LOADFROMBUFFER 0
#define SMCI_APPLOADER_OP_LOADFROMREGION 1
#define SMCI_APPLOADER_OP_LOADEMBEDDED 2
#define SMCI_APPLOADER_OP_CONNECT 3
#define SMCI_APPLOADER_UID (0x3)
static inline int32_t
smci_apploader_release(struct smci_object self)
{
return IAppLoader_release(self);
}
static inline int32_t
smci_apploader_retain(struct smci_object self)
{
return IAppLoader_retain(self);
}
static inline int32_t
smci_apploader_loadfrombuffer(struct smci_object self, const void *appelf_ptr, size_t appelf_len,
struct smci_object *appcontroller_ptr)
{
return IAppLoader_loadFromBuffer(self, appelf_ptr, appelf_len,
appcontroller_ptr);
}
static inline int32_t
smci_apploader_loadfromregion(struct smci_object self, struct smci_object appelf_val,
struct smci_object *appcontroller_ptr)
{
return IAppLoader_loadFromRegion(self, appelf_val,
appcontroller_ptr);
}
static inline int32_t
smci_apploader_loadembedded(struct smci_object self, const void *appname_ptr, size_t appname_len,
struct smci_object *appcontroller_ptr)
{
return IAppLoader_loadEmbedded(self, appname_ptr, appname_len,
appcontroller_ptr);
}
static inline int32_t
smci_apploader_connect(struct smci_object self, const void *appname_ptr, size_t appname_len,
struct smci_object *appcontroller_ptr)
{
return IAppLoader_connect(self, appname_ptr, appname_len,
appcontroller_ptr);
}
#endif /* __SMCI_APPLOADER_H */

View File

@@ -0,0 +1,40 @@
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef __SMCI_OPENER_H
#define __SMCI_OPENER_H
#include "smci_object.h"
#include "IOpener.h"
/** 0 is not a valid service ID. */
#define SMCI_OPENER_INVALID_ID UINT32_C(0)
#define SMCI_OPENER_ERROR_NOT_FOUND INT32_C(10)
#define SMCI_OPENER_ERROR_PRIVILEGE INT32_C(11)
#define SMCI_OPENER_ERROR_NOT_SUPPORTED INT32_C(12)
#define SMCI_OPENER_OP_OPEN 0
static inline int32_t
smci_opener_release(struct smci_object self)
{
return IOpener_release(self);
}
static inline int32_t
smci_opener_retain(struct smci_object self)
{
return IOpener_retain(self);
}
static inline int32_t
smci_opener_open(struct smci_object self, uint32_t id_val, struct smci_object *obj_ptr)
{
return IOpener_open(self, id_val, obj_ptr);
}
#endif /* __SMCI_OPENER_H */

View File

@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
/**
* @addtogroup CAppClient
* @{
Class CAppClient implements \link IAppClient \endlink interface.
This class provides an interface to obtain app-provided functionalities.
The class ID `AppClient` is not included in the default privilege set.
*/
#pragma once
#include <smcinvoke_object.h>
#define CAppClient_UID (0x97)

View File

@@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#pragma once
#include <include/linux/smcinvoke_object.h>
// This class provides an interface to load Secure Applications in QSEE
#define CAppLoader_UID (3)

View File

@@ -0,0 +1,390 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _UAPI_QCEDEV__H
#define _UAPI_QCEDEV__H
#include <linux/types.h>
#include <linux/ioctl.h>
#define QCEDEV_MAX_SHA_BLOCK_SIZE 64
#define QCEDEV_MAX_BEARER 31
#define QCEDEV_MAX_KEY_SIZE 64
#define QCEDEV_MAX_IV_SIZE 32
#define QCEDEV_MAX_BUFFERS 16
#define QCEDEV_MAX_SHA_DIGEST 32
#define QCEDEV_USE_PMEM 1
#define QCEDEV_NO_PMEM 0
#define QCEDEV_AES_KEY_128 16
#define QCEDEV_AES_KEY_192 24
#define QCEDEV_AES_KEY_256 32
/**
*qcedev_oper_enum: Operation types
* @QCEDEV_OPER_ENC: Encrypt
* @QCEDEV_OPER_DEC: Decrypt
* @QCEDEV_OPER_ENC_NO_KEY: Encrypt. Do not need key to be specified by
* user. Key already set by an external processor.
* @QCEDEV_OPER_DEC_NO_KEY: Decrypt. Do not need the key to be specified by
* user. Key already set by an external processor.
*/
enum qcedev_oper_enum {
QCEDEV_OPER_DEC = 0,
QCEDEV_OPER_ENC = 1,
QCEDEV_OPER_DEC_NO_KEY = 2,
QCEDEV_OPER_ENC_NO_KEY = 3,
QCEDEV_OPER_LAST
};
/**
*qcedev_offload_oper_enum: Offload operation types (uses pipe keys)
* @QCEDEV_OFFLOAD_HLOS_HLOS: Non-secure to non-secure (eg. audio dec).
* @QCEDEV_OFFLOAD_HLOS_CPB: Non-secure to secure (eg. video dec).
* @QCEDEV_OFFLOAD_CPB_HLOS: Secure to non-secure (eg. hdcp video enc).
*/
enum qcedev_offload_oper_enum {
QCEDEV_OFFLOAD_HLOS_HLOS = 1,
QCEDEV_OFFLOAD_HLOS_HLOS_1 = 2,
QCEDEV_OFFLOAD_HLOS_CPB = 3,
QCEDEV_OFFLOAD_HLOS_CPB_1 = 4,
QCEDEV_OFFLOAD_CPB_HLOS = 5,
QCEDEV_OFFLOAD_OPER_LAST
};
/**
*qcedev_offload_err_enum: Offload error conditions
* @QCEDEV_OFFLOAD_NO_ERROR: Successful crypto operation.
* @QCEDEV_OFFLOAD_GENERIC_ERROR: Generic error in crypto status.
* @QCEDEV_OFFLOAD_TIMER_EXPIRED_ERROR: Pipe key timer expired.
* @QCEDEV_OFFLOAD_KEY_PAUSE_ERROR: Pipe key pause (means GPCE is paused).
*/
enum qcedev_offload_err_enum {
QCEDEV_OFFLOAD_NO_ERROR = 0,
QCEDEV_OFFLOAD_GENERIC_ERROR = 1,
QCEDEV_OFFLOAD_KEY_TIMER_EXPIRED_ERROR = 2,
QCEDEV_OFFLOAD_KEY_PAUSE_ERROR = 3
};
/**
*qcedev_oper_enum: Cipher algorithm types
* @QCEDEV_ALG_DES: DES
* @QCEDEV_ALG_3DES: 3DES
* @QCEDEV_ALG_AES: AES
*/
enum qcedev_cipher_alg_enum {
QCEDEV_ALG_DES = 0,
QCEDEV_ALG_3DES = 1,
QCEDEV_ALG_AES = 2,
QCEDEV_ALG_LAST
};
/**
*qcedev_cipher_mode_enum : AES mode
* @QCEDEV_AES_MODE_CBC: CBC
* @QCEDEV_AES_MODE_ECB: ECB
* @QCEDEV_AES_MODE_CTR: CTR
* @QCEDEV_AES_MODE_XTS: XTS
* @QCEDEV_AES_MODE_CCM: CCM
* @QCEDEV_DES_MODE_CBC: CBC
* @QCEDEV_DES_MODE_ECB: ECB
*/
enum qcedev_cipher_mode_enum {
QCEDEV_AES_MODE_CBC = 0,
QCEDEV_AES_MODE_ECB = 1,
QCEDEV_AES_MODE_CTR = 2,
QCEDEV_AES_MODE_XTS = 3,
QCEDEV_AES_MODE_CCM = 4,
QCEDEV_DES_MODE_CBC = 5,
QCEDEV_DES_MODE_ECB = 6,
QCEDEV_AES_DES_MODE_LAST
};
/**
*enum qcedev_sha_alg_enum : Secure Hashing Algorithm
* @QCEDEV_ALG_SHA1: Digest returned: 20 bytes (160 bits)
* @QCEDEV_ALG_SHA256: Digest returned: 32 bytes (256 bit)
* @QCEDEV_ALG_SHA1_HMAC: HMAC returned 20 bytes (160 bits)
* @QCEDEV_ALG_SHA256_HMAC: HMAC returned 32 bytes (256 bit)
* @QCEDEV_ALG_AES_CMAC: Configurable MAC size
*/
enum qcedev_sha_alg_enum {
QCEDEV_ALG_SHA1 = 0,
QCEDEV_ALG_SHA256 = 1,
QCEDEV_ALG_SHA1_HMAC = 2,
QCEDEV_ALG_SHA256_HMAC = 3,
QCEDEV_ALG_AES_CMAC = 4,
QCEDEV_ALG_SHA_ALG_LAST
};
/**
* struct buf_info - Buffer information
* @offset: Offset from the base address of the buffer
* (Used when buffer is allocated using PMEM)
* @vaddr: Virtual buffer address pointer
* @len: Size of the buffer
*/
struct buf_info {
union {
__u32 offset;
__u8 *vaddr;
};
__u32 len;
};
/**
* struct qcedev_vbuf_info - Source and destination Buffer information
* @src: Array of buf_info for input/source
* @dst: Array of buf_info for output/destination
*/
struct qcedev_vbuf_info {
struct buf_info src[QCEDEV_MAX_BUFFERS];
struct buf_info dst[QCEDEV_MAX_BUFFERS];
};
/**
* struct qcedev_pmem_info - Stores PMEM buffer information
* @fd_src: Handle to /dev/adsp_pmem used to allocate
* memory for input/src buffer
* @src: Array of buf_info for input/source
* @fd_dst: Handle to /dev/adsp_pmem used to allocate
* memory for output/dst buffer
* @dst: Array of buf_info for output/destination
* @pmem_src_offset: The offset from input/src buffer
* (allocated by PMEM)
*/
struct qcedev_pmem_info {
int fd_src;
struct buf_info src[QCEDEV_MAX_BUFFERS];
int fd_dst;
struct buf_info dst[QCEDEV_MAX_BUFFERS];
};
/**
* struct qcedev_cipher_op_req - Holds the ciphering request information
* @use_pmem (IN): Flag to indicate if buffer source is PMEM
* QCEDEV_USE_PMEM/QCEDEV_NO_PMEM
* @pmem (IN): Stores PMEM buffer information.
* Refer struct qcedev_pmem_info
* @vbuf (IN/OUT): Stores Source and destination Buffer information
* Refer to struct qcedev_vbuf_info
* @data_len (IN): Total Length of input/src and output/dst in bytes
* @in_place_op (IN): Indicates whether the operation is inplace where
* source == destination
* When using PMEM allocated memory, must set this to 1
* @enckey (IN): 128 bits of confidentiality key
* enckey[0] bit 127-120, enckey[1] bit 119-112,..
* enckey[15] bit 7-0
* @encklen (IN): Length of the encryption key(set to 128 bits/16
* bytes in the driver)
* @iv (IN/OUT): Initialisation vector data
* This is updated by the driver, incremented by
* number of blocks encrypted/decrypted.
* @ivlen (IN): Length of the IV
* @byteoffset (IN): Offset in the Cipher BLOCK (applicable and to be set
* for AES-128 CTR mode only)
* @alg (IN): Type of ciphering algorithm: AES/DES/3DES
* @mode (IN): Mode use when using AES algorithm: ECB/CBC/CTR
* Apllicabel when using AES algorithm only
* @op (IN): Type of operation: QCEDEV_OPER_DEC/QCEDEV_OPER_ENC or
* QCEDEV_OPER_ENC_NO_KEY/QCEDEV_OPER_DEC_NO_KEY
*
*If use_pmem is set to 0, the driver assumes that memory was not allocated
* via PMEM, and kernel will need to allocate memory and copy data from user
* space buffer (data_src/dta_dst) and process accordingly and copy data back
* to the user space buffer
*
* If use_pmem is set to 1, the driver assumes that memory was allocated via
* PMEM.
* The kernel driver will use the fd_src to determine the kernel virtual address
* base that maps to the user space virtual address base for the buffer
* allocated in user space.
* The final input/src and output/dst buffer pointer will be determined
* by adding the offsets to the kernel virtual addr.
*
* If use of hardware key is supported in the target, user can configure the
* key parameters (encklen, enckey) to use the hardware key.
* In order to use the hardware key, set encklen to 0 and set the enckey
* data array to 0.
*/
struct qcedev_cipher_op_req {
__u8 use_pmem;
union {
struct qcedev_pmem_info pmem;
struct qcedev_vbuf_info vbuf;
};
__u32 entries;
__u32 data_len;
__u8 in_place_op;
__u8 enckey[QCEDEV_MAX_KEY_SIZE];
__u32 encklen;
__u8 iv[QCEDEV_MAX_IV_SIZE];
__u32 ivlen;
__u32 byteoffset;
enum qcedev_cipher_alg_enum alg;
enum qcedev_cipher_mode_enum mode;
enum qcedev_oper_enum op;
};
/**
* struct qcedev_sha_op_req - Holds the hashing request information
* @data (IN): Array of pointers to the data to be hashed
* @entries (IN): Number of buf_info entries in the data array
* @data_len (IN): Length of data to be hashed
* @digest (IN/OUT): Returns the hashed data information
* @diglen (OUT): Size of the hashed/digest data
* @authkey (IN): Pointer to authentication key for HMAC
* @authklen (IN): Size of the authentication key
* @alg (IN): Secure Hash algorithm
*/
struct qcedev_sha_op_req {
struct buf_info data[QCEDEV_MAX_BUFFERS];
__u32 entries;
__u32 data_len;
__u8 digest[QCEDEV_MAX_SHA_DIGEST];
__u32 diglen;
__u8 *authkey;
__u32 authklen;
enum qcedev_sha_alg_enum alg;
};
/**
* struct pattern_info - Holds pattern information for pattern-based
* decryption/encryption for AES ECB, counter, and CBC modes.
* @patt_sz (IN): Total number of blocks.
* @proc_data_sz (IN): Number of blocks to be processed.
* @patt_offset (IN): Start of the segment.
*/
struct pattern_info {
__u8 patt_sz;
__u8 proc_data_sz;
__u8 patt_offset;
};
/**
* struct qcedev_offload_cipher_op_req - Holds the offload request information
* @vbuf (IN/OUT): Stores Source and destination Buffer information.
* Refer to struct qcedev_vbuf_info.
* @entries (IN): Number of entries to be processed as part of request.
* @data_len (IN): Total Length of input/src and output/dst in bytes
* @in_place_op (IN): Indicates whether the operation is inplace where
* source == destination.
* @encklen (IN): Length of the encryption key(set to 128 bits/16
* bytes in the driver).
* @iv (IN/OUT): Initialisation vector data
* This is updated by the driver, incremented by
* number of blocks encrypted/decrypted.
* @ivlen (IN): Length of the IV.
* @iv_ctr_size (IN): IV counter increment mask size.
* Driver sets the mask value based on this size.
* @byteoffset (IN): Offset in the Cipher BLOCK (applicable and to be set
* for AES-128 CTR mode only).
* @block_offset (IN): Offset in the block that needs a skip of encrypt/
* decrypt.
* @pattern_valid (IN): Indicates the request contains a valid pattern.
* @pattern_info (IN): The pattern to be used for the offload request.
* @is_copy_op (IN): Offload operations sometimes requires a copy between
* secure and non-secure buffers without any encrypt/
* decrypt operations.
* @alg (IN): Type of ciphering algorithm: AES/DES/3DES.
* @mode (IN): Mode use when using AES algorithm: ECB/CBC/CTR.
* Applicable when using AES algorithm only.
* @op (IN): Type of operation.
* Refer to qcedev_offload_oper_enum.
* @err (OUT): Error in crypto status.
* Refer to qcedev_offload_err_enum.
*/
struct qcedev_offload_cipher_op_req {
struct qcedev_vbuf_info vbuf;
__u32 entries;
__u32 data_len;
__u32 in_place_op;
__u32 encklen;
__u8 iv[QCEDEV_MAX_IV_SIZE];
__u32 ivlen;
__u32 iv_ctr_size;
__u32 byteoffset;
__u8 block_offset;
__u8 is_pattern_valid;
__u8 is_copy_op;
__u8 encrypt;
struct pattern_info pattern_info;
enum qcedev_cipher_alg_enum alg;
enum qcedev_cipher_mode_enum mode;
enum qcedev_offload_oper_enum op;
enum qcedev_offload_err_enum err;
};
/**
* struct qfips_verify_t - Holds data for FIPS Integrity test
* @kernel_size (IN): Size of kernel Image
* @kernel (IN): pointer to buffer containing the kernel Image
*/
struct qfips_verify_t {
unsigned int kernel_size;
void *kernel;
};
/**
* struct qcedev_map_buf_req - Holds the mapping request information
* fd (IN): Array of fds.
* num_fds (IN): Number of fds in fd[].
* fd_size (IN): Array of sizes corresponding to each fd in fd[].
* fd_offset (IN): Array of offset corresponding to each fd in fd[].
* vaddr (OUT): Array of mapped virtual address corresponding to
* each fd in fd[].
*/
struct qcedev_map_buf_req {
__s32 fd[QCEDEV_MAX_BUFFERS];
__u32 num_fds;
__u32 fd_size[QCEDEV_MAX_BUFFERS];
__u32 fd_offset[QCEDEV_MAX_BUFFERS];
__u64 buf_vaddr[QCEDEV_MAX_BUFFERS];
};
/**
* struct qcedev_unmap_buf_req - Holds the hashing request information
* fd (IN): Array of fds to unmap
* num_fds (IN): Number of fds in fd[].
*/
struct qcedev_unmap_buf_req {
__s32 fd[QCEDEV_MAX_BUFFERS];
__u32 num_fds;
};
struct file;
long qcedev_ioctl(struct file *file,
unsigned int cmd, unsigned long arg);
#define QCEDEV_IOC_MAGIC 0x87
#define QCEDEV_IOCTL_ENC_REQ \
_IOWR(QCEDEV_IOC_MAGIC, 1, struct qcedev_cipher_op_req)
#define QCEDEV_IOCTL_DEC_REQ \
_IOWR(QCEDEV_IOC_MAGIC, 2, struct qcedev_cipher_op_req)
#define QCEDEV_IOCTL_SHA_INIT_REQ \
_IOWR(QCEDEV_IOC_MAGIC, 3, struct qcedev_sha_op_req)
#define QCEDEV_IOCTL_SHA_UPDATE_REQ \
_IOWR(QCEDEV_IOC_MAGIC, 4, struct qcedev_sha_op_req)
#define QCEDEV_IOCTL_SHA_FINAL_REQ \
_IOWR(QCEDEV_IOC_MAGIC, 5, struct qcedev_sha_op_req)
#define QCEDEV_IOCTL_GET_SHA_REQ \
_IOWR(QCEDEV_IOC_MAGIC, 6, struct qcedev_sha_op_req)
#define QCEDEV_IOCTL_LOCK_CE \
_IO(QCEDEV_IOC_MAGIC, 7)
#define QCEDEV_IOCTL_UNLOCK_CE \
_IO(QCEDEV_IOC_MAGIC, 8)
#define QCEDEV_IOCTL_GET_CMAC_REQ \
_IOWR(QCEDEV_IOC_MAGIC, 9, struct qcedev_sha_op_req)
#define QCEDEV_IOCTL_MAP_BUF_REQ \
_IOWR(QCEDEV_IOC_MAGIC, 10, struct qcedev_map_buf_req)
#define QCEDEV_IOCTL_UNMAP_BUF_REQ \
_IOWR(QCEDEV_IOC_MAGIC, 11, struct qcedev_unmap_buf_req)
#define QCEDEV_IOCTL_OFFLOAD_OP_REQ \
_IOWR(QCEDEV_IOC_MAGIC, 12, struct qcedev_offload_cipher_op_req)
#endif /* _UAPI_QCEDEV__H */

View File

@@ -0,0 +1,218 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _UAPI_QCOTA_H
#define _UAPI_QCOTA_H
#include <linux/types.h>
#include <linux/ioctl.h>
#define QCE_OTA_MAX_BEARER 31
#define OTA_KEY_SIZE 16 /* 128 bits of keys. */
enum qce_ota_dir_enum {
QCE_OTA_DIR_UPLINK = 0,
QCE_OTA_DIR_DOWNLINK = 1,
QCE_OTA_DIR_LAST
};
enum qce_ota_algo_enum {
QCE_OTA_ALGO_KASUMI = 0,
QCE_OTA_ALGO_SNOW3G = 1,
QCE_OTA_ALGO_LAST
};
/**
* struct qce_f8_req - qce f8 request
* @data_in: packets input data stream to be ciphered.
* If NULL, streaming mode operation.
* @data_out: ciphered packets output data.
* @data_len: length of data_in and data_out in bytes.
* @count_c: count-C, ciphering sequence number, 32 bit
* @bearer: 5 bit of radio bearer identifier.
* @ckey: 128 bits of confidentiality key,
* ckey[0] bit 127-120, ckey[1] bit 119-112,.., ckey[15] bit 7-0.
* @direction: uplink or donwlink.
* @algorithm: Kasumi, or Snow3G.
*
* If data_in is NULL, the engine will run in a special mode called
* key stream mode. In this special mode, the engine will generate
* key stream output for the number of bytes specified in the
* data_len, based on the input parameters of direction, algorithm,
* ckey, bearer, and count_c. The data_len is restricted to
* the length of multiple of 16 bytes. Application can then take the
* output stream, do a exclusive or to the input data stream, and
* generate the final cipher data stream.
*/
struct qce_f8_req {
__u8 *data_in;
__u8 *data_out;
__u16 data_len;
__u32 count_c;
__u8 bearer;
__u8 ckey[OTA_KEY_SIZE];
enum qce_ota_dir_enum direction;
enum qce_ota_algo_enum algorithm;
int current_req_info;
};
/**
* struct qce_f8_multi_pkt_req - qce f8 multiple packet request
* Muliptle packets with uniform size, and
* F8 ciphering parameters can be ciphered in a
* single request.
*
* @num_pkt: number of packets.
*
* @cipher_start: ciphering starts offset within a packet.
*
* @cipher_size: number of bytes to be ciphered within a packet.
*
* @qce_f8_req: description of the packet and F8 parameters.
* The following fields have special meaning for
* multiple packet operation,
*
* @data_len: data_len indicates the length of a packet.
*
* @data_in: packets are concatenated together in a byte
* stream started at data_in.
*
* @data_out: The returned ciphered output for multiple
* packets.
* Each packet ciphered output are concatenated
* together into a byte stream started at data_out.
* Note, each ciphered packet output area from
* offset 0 to cipher_start-1, and from offset
* cipher_size to data_len -1 are remained
* unaltered from packet input area.
* @count_c: count-C of the first packet, 32 bit.
*
*
* In one request, multiple packets can be ciphered, and output to the
* data_out stream.
*
* Packet data are laid out contiguously in sequence in data_in,
* and data_out area. Every packet is identical size.
* If the PDU is not byte aligned, set the data_len value of
* to the rounded up value of the packet size. Eg, PDU size of
* 253 bits, set the packet size to 32 bytes. Next packet starts on
* the next byte boundary.
*
* For each packet, data from offset 0 to cipher_start
* will be left unchanged and output to the data_out area.
* This area of the packet can be for the RLC header, which is not
* to be ciphered.
*
* The ciphering of a packet starts from offset cipher_start, for
* cipher_size bytes of data. Data starting from
* offset cipher_start + cipher_size to the end of packet will be left
* unchanged and output to the dataOut area.
*
* For each packet the input arguments of bearer, direction,
* ckey, algorithm have to be the same. count_c is the ciphering sequence
* number of the first packet. The 2nd packet's ciphering sequence
* number is assumed to be count_c + 1. The 3rd packet's ciphering sequence
* number is count_c + 2.....
*
*/
struct qce_f8_multi_pkt_req {
__u16 num_pkt;
__u16 cipher_start;
__u16 cipher_size;
struct qce_f8_req qce_f8_req;
};
/**
* struct qce_f8_variable_multi_pkt_req - qce f8 multiple packet request
* Muliptle packets with variable size, and
* F8 ciphering parameters can be ciphered in a
* single request.
*
* @num_pkt: number of packets.
*
* @cipher_iov[]: array of iov of packets to be ciphered.
*
*
* @qce_f8_req: description of the packet and F8 parameters.
* The following fields have special meaning for
* multiple packet operation,
*
* @data_len: ignored.
*
* @data_in: ignored.
*
* @data_out: ignored.
*
* @count_c: count-C of the first packet, 32 bit.
*
*
* In one request, multiple packets can be ciphered.
*
* The i-th packet are defined in cipher_iov[i-1].
* The ciphering of i-th packet starts from offset 0 of the PDU specified
* by cipher_iov[i-1].addr, for cipher_iov[i-1].size bytes of data.
* If the PDU is not byte aligned, set the cipher_iov[i-1].size value
* to the rounded up value of the packet size. Eg, PDU size of
* 253 bits, set the packet size to 32 bytes.
*
* Ciphering are done in place. That is, the ciphering
* input and output data are both in cipher_iov[i-1].addr for the i-th
* packet.
*
* For each packet the input arguments of bearer, direction,
* ckey, algorithm have to be the same. count_c is the ciphering sequence
* number of the first packet. The 2nd packet's ciphering sequence
* number is assumed to be count_c + 1. The 3rd packet's ciphering sequence
* number is count_c + 2.....
*/
#define MAX_NUM_V_MULTI_PKT 20
struct cipher_iov {
unsigned char *addr;
unsigned short size;
};
struct qce_f8_variable_multi_pkt_req {
unsigned short num_pkt;
struct cipher_iov cipher_iov[MAX_NUM_V_MULTI_PKT];
struct qce_f8_req qce_f8_req;
};
/**
* struct qce_f9_req - qce f9 request
* @message: message
* @msize: message size in bytes (include the last partial byte).
* @last_bits: valid bits in the last byte of message.
* @mac_i: 32 bit message authentication code, to be returned.
* @fresh: random 32 bit number, one per user.
* @count_i: 32 bit count-I integrity sequence number.
* @direction: uplink or donwlink.
* @ikey: 128 bits of integrity key,
* ikey[0] bit 127-120, ikey[1] bit 119-112,.., ikey[15] bit 7-0.
* @algorithm: Kasumi, or Snow3G.
*/
struct qce_f9_req {
__u8 *message;
__u16 msize;
__u8 last_bits;
__u32 mac_i;
__u32 fresh;
__u32 count_i;
enum qce_ota_dir_enum direction;
__u8 ikey[OTA_KEY_SIZE];
enum qce_ota_algo_enum algorithm;
int current_req_info;
};
#define QCOTA_IOC_MAGIC 0x85
#define QCOTA_F8_REQ _IOWR(QCOTA_IOC_MAGIC, 1, struct qce_f8_req)
#define QCOTA_F8_MPKT_REQ _IOWR(QCOTA_IOC_MAGIC, 2, struct qce_f8_multi_pkt_req)
#define QCOTA_F9_REQ _IOWR(QCOTA_IOC_MAGIC, 3, struct qce_f9_req)
#define QCOTA_F8_V_MPKT_REQ _IOWR(QCOTA_IOC_MAGIC, 4,\
struct qce_f8_variable_multi_pkt_req)
#endif /* _UAPI_QCOTA_H */

View File

@@ -0,0 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _UAPI_QRNG_H_
#define _UAPI_QRNG_H_
#include <linux/types.h>
#include <linux/ioctl.h>
#define QRNG_IOC_MAGIC 0x100
#define QRNG_IOCTL_RESET_BUS_BANDWIDTH\
_IO(QRNG_IOC_MAGIC, 1)
#endif /* _UAPI_QRNG_H_ */

View File

@@ -0,0 +1,186 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2017, 2019, 2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _QSEECOM_H_
#define _QSEECOM_H_
#pragma message("Warning: This header file will be deprecated in future")
#include <linux/types.h>
#include <linux/ioctl.h>
#define MAX_ION_FD 4
#define MAX_APP_NAME_SIZE 64
#define QSEECOM_HASH_SIZE 32
#define ICE_KEY_SIZE 32
#define ICE_SALT_SIZE 32
/*
* struct qseecom_ion_fd_info - ion fd handle data information
* @fd - ion handle to some memory allocated in user space
* @cmd_buf_offset - command buffer offset
*/
struct qseecom_ion_fd_info {
__s32 fd;
__u32 cmd_buf_offset;
};
enum qseecom_key_management_usage_type {
QSEOS_KM_USAGE_DISK_ENCRYPTION = 0x01,
QSEOS_KM_USAGE_FILE_ENCRYPTION = 0x02,
QSEOS_KM_USAGE_UFS_ICE_DISK_ENCRYPTION = 0x03,
QSEOS_KM_USAGE_SDCC_ICE_DISK_ENCRYPTION = 0x04,
QSEOS_KM_USAGE_MAX
};
struct qseecom_create_key_req {
unsigned char hash32[QSEECOM_HASH_SIZE];
enum qseecom_key_management_usage_type usage;
};
struct qseecom_wipe_key_req {
enum qseecom_key_management_usage_type usage;
int wipe_key_flag;/* 1->remove key from storage(alone with clear key) */
/* 0->do not remove from storage (clear key) */
};
struct qseecom_update_key_userinfo_req {
unsigned char current_hash32[QSEECOM_HASH_SIZE];
unsigned char new_hash32[QSEECOM_HASH_SIZE];
enum qseecom_key_management_usage_type usage;
};
#define SHA256_DIGEST_LENGTH (256/8)
/*
* struct qseecom_save_partition_hash_req
* @partition_id - partition id.
* @hash[SHA256_DIGEST_LENGTH] - sha256 digest.
*/
struct qseecom_save_partition_hash_req {
int partition_id; /* in */
char digest[SHA256_DIGEST_LENGTH]; /* in */
};
/*
* struct qseecom_is_es_activated_req
* @is_activated - 1=true , 0=false
*/
struct qseecom_is_es_activated_req {
int is_activated; /* out */
};
/*
* struct qseecom_mdtp_cipher_dip_req
* @in_buf - input buffer
* @in_buf_size - input buffer size
* @out_buf - output buffer
* @out_buf_size - output buffer size
* @direction - 0=encrypt, 1=decrypt
*/
struct qseecom_mdtp_cipher_dip_req {
__u8 *in_buf;
__u32 in_buf_size;
__u8 *out_buf;
__u32 out_buf_size;
__u32 direction;
};
struct qseecom_qteec_req {
void *req_ptr;
__u32 req_len;
void *resp_ptr;
__u32 resp_len;
};
struct qseecom_qteec_modfd_req {
void *req_ptr;
__u32 req_len;
void *resp_ptr;
__u32 resp_len;
struct qseecom_ion_fd_info ifd_data[MAX_ION_FD];
};
#define MAX_CE_PIPE_PAIR_PER_UNIT 3
struct qseecom_ce_pipe_entry {
int valid;
unsigned int ce_num;
unsigned int ce_pipe_pair;
};
struct qseecom_ice_data_t {
int flag;
};
#define MAX_CE_INFO_HANDLE_SIZE 32
struct qseecom_ce_info_req {
unsigned char handle[MAX_CE_INFO_HANDLE_SIZE];
unsigned int usage;
unsigned int unit_num;
unsigned int num_ce_pipe_entries;
struct qseecom_ce_pipe_entry ce_pipe_entry[MAX_CE_PIPE_PAIR_PER_UNIT];
};
struct qseecom_ice_key_data_t {
__u8 key[ICE_KEY_SIZE];
__u32 key_len;
__u8 salt[ICE_SALT_SIZE];
__u32 salt_len;
};
struct file;
#define QSEECOM_IOC_MAGIC 0x97
#define QSEECOM_IOCTL_CREATE_KEY_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 17, struct qseecom_create_key_req)
#define QSEECOM_IOCTL_WIPE_KEY_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 18, struct qseecom_wipe_key_req)
#define QSEECOM_IOCTL_SAVE_PARTITION_HASH_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 19, struct qseecom_save_partition_hash_req)
#define QSEECOM_IOCTL_IS_ES_ACTIVATED_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 20, struct qseecom_is_es_activated_req)
#define QSEECOM_IOCTL_UPDATE_KEY_USER_INFO_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 24, struct qseecom_update_key_userinfo_req)
#define QSEECOM_QTEEC_IOCTL_OPEN_SESSION_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 30, struct qseecom_qteec_modfd_req)
#define QSEECOM_QTEEC_IOCTL_CLOSE_SESSION_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 31, struct qseecom_qteec_req)
#define QSEECOM_QTEEC_IOCTL_INVOKE_MODFD_CMD_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 32, struct qseecom_qteec_modfd_req)
#define QSEECOM_QTEEC_IOCTL_REQUEST_CANCELLATION_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 33, struct qseecom_qteec_modfd_req)
#define QSEECOM_IOCTL_MDTP_CIPHER_DIP_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 34, struct qseecom_mdtp_cipher_dip_req)
#define QSEECOM_IOCTL_GET_CE_PIPE_INFO \
_IOWR(QSEECOM_IOC_MAGIC, 40, struct qseecom_ce_info_req)
#define QSEECOM_IOCTL_FREE_CE_PIPE_INFO \
_IOWR(QSEECOM_IOC_MAGIC, 41, struct qseecom_ce_info_req)
#define QSEECOM_IOCTL_QUERY_CE_PIPE_INFO \
_IOWR(QSEECOM_IOC_MAGIC, 42, struct qseecom_ce_info_req)
#define QSEECOM_IOCTL_SET_ICE_INFO \
_IOWR(QSEECOM_IOC_MAGIC, 43, struct qseecom_ice_data_t)
#define QSEECOM_IOCTL_FBE_CLEAR_KEY \
_IOWR(QSEECOM_IOC_MAGIC, 44, struct qseecom_ice_key_data_t)
#endif /* _QSEECOM_H_ */

View File

@@ -0,0 +1,196 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2017, 2019, 2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _QSEECOM_API_H_
#define _QSEECOM_API_H_
#pragma message("Warning: This header file will be deprecated in future")
#include <linux/types.h>
#include <linux/ioctl.h>
#include "qseecom.h"
/*
* struct qseecom_register_listener_req -
* for register listener ioctl request
* @listener_id - service id (shared between userspace and QSE)
* @ifd_data_fd - ion handle
* @virt_sb_base - shared buffer base in user space
* @sb_size - shared buffer size
*/
struct qseecom_register_listener_req {
__u32 listener_id; /* in */
__s32 ifd_data_fd; /* in */
void *virt_sb_base; /* in */
__u32 sb_size; /* in */
};
/*
* struct qseecom_send_cmd_req - for send command ioctl request
* @cmd_req_len - command buffer length
* @cmd_req_buf - command buffer
* @resp_len - response buffer length
* @resp_buf - response buffer
*/
struct qseecom_send_cmd_req {
void *cmd_req_buf; /* in */
unsigned int cmd_req_len; /* in */
void *resp_buf; /* in/out */
unsigned int resp_len; /* in/out */
};
/*
* struct qseecom_send_modfd_cmd_req - for send command ioctl request
* @cmd_req_len - command buffer length
* @cmd_req_buf - command buffer
* @resp_len - response buffer length
* @resp_buf - response buffer
* @ifd_data_fd - ion handle to memory allocated in user space
* @cmd_buf_offset - command buffer offset
*/
struct qseecom_send_modfd_cmd_req {
void *cmd_req_buf; /* in */
unsigned int cmd_req_len; /* in */
void *resp_buf; /* in/out */
unsigned int resp_len; /* in/out */
struct qseecom_ion_fd_info ifd_data[MAX_ION_FD];
};
/*
* struct qseecom_load_img_data - for sending image length information and
* ion file descriptor to the qseecom driver. ion file descriptor is used
* for retrieving the ion file handle and in turn the physical address of
* the image location.
* @mdt_len - Length of the .mdt file in bytes.
* @img_len - Length of the .mdt + .b00 +..+.bxx images files in bytes
* @ion_fd - Ion file descriptor used when allocating memory.
* @img_name - Name of the image.
* @app_arch - Architecture of the image, i.e. 32bit or 64bit app
*/
struct qseecom_load_img_req {
__u32 mdt_len; /* in */
__u32 img_len; /* in */
__s32 ifd_data_fd; /* in */
char img_name[MAX_APP_NAME_SIZE]; /* in */
__u32 app_arch; /* in */
__u32 app_id; /* out*/
};
struct qseecom_set_sb_mem_param_req {
__s32 ifd_data_fd; /* in */
void *virt_sb_base; /* in */
__u32 sb_len; /* in */
};
/*
* struct qseecom_qseos_version_req - get qseos version
* @qseos_version - version number
*/
struct qseecom_qseos_version_req {
unsigned int qseos_version; /* in */
};
/*
* struct qseecom_qseos_app_load_query - verify if app is loaded in qsee
* @app_name[MAX_APP_NAME_SIZE]- name of the app.
* @app_id - app id.
*/
struct qseecom_qseos_app_load_query {
char app_name[MAX_APP_NAME_SIZE]; /* in */
__u32 app_id; /* out */
__u32 app_arch;
};
struct qseecom_send_svc_cmd_req {
__u32 cmd_id;
void *cmd_req_buf; /* in */
unsigned int cmd_req_len; /* in */
void *resp_buf; /* in/out */
unsigned int resp_len; /* in/out */
};
/*
* struct qseecom_send_modfd_resp - for send command ioctl request
* @req_len - command buffer length
* @req_buf - command buffer
* @ifd_data_fd - ion handle to memory allocated in user space
* @cmd_buf_offset - command buffer offset
*/
struct qseecom_send_modfd_listener_resp {
void *resp_buf_ptr; /* in */
unsigned int resp_len; /* in */
struct qseecom_ion_fd_info ifd_data[MAX_ION_FD]; /* in */
};
struct qseecom_sg_entry {
__u32 phys_addr;
__u32 len;
};
struct qseecom_sg_entry_64bit {
__u64 phys_addr;
__u32 len;
} __attribute__ ((packed));
struct file;
#define QSEECOM_IOC_MAGIC 0x97
#define QSEECOM_IOCTL_REGISTER_LISTENER_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 1, struct qseecom_register_listener_req)
#define QSEECOM_IOCTL_UNREGISTER_LISTENER_REQ \
_IO(QSEECOM_IOC_MAGIC, 2)
#define QSEECOM_IOCTL_SEND_CMD_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 3, struct qseecom_send_cmd_req)
#define QSEECOM_IOCTL_SEND_MODFD_CMD_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 4, struct qseecom_send_modfd_cmd_req)
#define QSEECOM_IOCTL_RECEIVE_REQ \
_IO(QSEECOM_IOC_MAGIC, 5)
#define QSEECOM_IOCTL_SEND_RESP_REQ \
_IO(QSEECOM_IOC_MAGIC, 6)
#define QSEECOM_IOCTL_LOAD_APP_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 7, struct qseecom_load_img_req)
#define QSEECOM_IOCTL_SET_MEM_PARAM_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 8, struct qseecom_set_sb_mem_param_req)
#define QSEECOM_IOCTL_UNLOAD_APP_REQ \
_IO(QSEECOM_IOC_MAGIC, 9)
#define QSEECOM_IOCTL_GET_QSEOS_VERSION_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 10, struct qseecom_qseos_version_req)
#define QSEECOM_IOCTL_LOAD_EXTERNAL_ELF_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 13, struct qseecom_load_img_req)
#define QSEECOM_IOCTL_UNLOAD_EXTERNAL_ELF_REQ \
_IO(QSEECOM_IOC_MAGIC, 14)
#define QSEECOM_IOCTL_APP_LOADED_QUERY_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 15, struct qseecom_qseos_app_load_query)
#define QSEECOM_IOCTL_SEND_CMD_SERVICE_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 16, struct qseecom_send_svc_cmd_req)
#define QSEECOM_IOCTL_SEND_MODFD_RESP \
_IOWR(QSEECOM_IOC_MAGIC, 21, struct qseecom_send_modfd_listener_resp)
#define QSEECOM_IOCTL_SEND_MODFD_CMD_64_REQ \
_IOWR(QSEECOM_IOC_MAGIC, 35, struct qseecom_send_modfd_cmd_req)
#define QSEECOM_IOCTL_SEND_MODFD_RESP_64 \
_IOWR(QSEECOM_IOC_MAGIC, 36, struct qseecom_send_modfd_listener_resp)
#endif /* _QSEECOM_API_H_ */

View File

@@ -0,0 +1,110 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _UAPI_SMCINVOKE_H_
#define _UAPI_SMCINVOKE_H_
#include <linux/types.h>
#include <linux/ioctl.h>
#define SMCINVOKE_USERSPACE_OBJ_NULL -1
#define DEFAULT_CB_OBJ_THREAD_CNT 4
#define SMCINVOKE_TZ_MIN_BUF_SIZE 4096
struct smcinvoke_buf {
__u64 addr;
__u64 size;
};
struct smcinvoke_obj {
__s64 fd;
__s64 cb_server_fd;
__s64 reserved;
};
union smcinvoke_arg {
struct smcinvoke_buf b;
struct smcinvoke_obj o;
};
/*
* struct smcinvoke_cmd_req: This structure is transparently sent to TEE
* @op - Operation to be performed
* @counts - number of aruments passed
* @result - result of invoke operation
* @argsize - size of each of arguments
* @args - args is pointer to buffer having all arguments
* @reserved: IN/OUT: Usage is not defined but should be set to 0
*/
struct smcinvoke_cmd_req {
__u32 op;
__u32 counts;
__s32 result;
__u32 argsize;
__u64 args;
__s64 reserved;
};
/*
* struct smcinvoke_accept: structure to process CB req from TEE
* @has_resp: IN: Whether IOCTL is carrying response data
* @result: IN: Outcome of operation op
* @op: OUT: Operation to be performed on target object
* @counts: OUT: Number of arguments, embedded in buffer pointed by
* buf_addr, to complete operation
* @reserved: IN/OUT: Usage is not defined but should be set to 0.
* @argsize: IN: Size of any argument, all of equal size, embedded
* in buffer pointed by buf_addr
* @txn_id: OUT: An id that should be passed as it is for response
* @cbobj_id: OUT: Callback object which is target of operation op
* @buf_len: IN: Len of buffer pointed by buf_addr
* @buf_addr: IN: Buffer containing all arguments which are needed
* to complete operation op
*/
struct smcinvoke_accept {
__u32 has_resp;
__s32 result;
__u32 op;
__u32 counts;
__s32 reserved;
__u32 argsize;
__u64 txn_id;
__s64 cbobj_id;
__u64 buf_len;
__u64 buf_addr;
};
/*
* @cb_buf_size: IN: Max buffer size for any callback obj implemented by client
* @reserved: IN/OUT: Usage is not defined but should be set to 0
*/
struct smcinvoke_server {
__u64 cb_buf_size;
__s64 reserved;
};
#define SMCINVOKE_IOC_MAGIC 0x98
#define SMCINVOKE_IOCTL_INVOKE_REQ \
_IOWR(SMCINVOKE_IOC_MAGIC, 1, struct smcinvoke_cmd_req)
#define SMCINVOKE_IOCTL_ACCEPT_REQ \
_IOWR(SMCINVOKE_IOC_MAGIC, 2, struct smcinvoke_accept)
#define SMCINVOKE_IOCTL_SERVER_REQ \
_IOWR(SMCINVOKE_IOC_MAGIC, 3, struct smcinvoke_server)
#define SMCINVOKE_IOCTL_ACK_LOCAL_OBJ \
_IOWR(SMCINVOKE_IOC_MAGIC, 4, __s64)
/*
* smcinvoke logging buffer is for communicating with the smcinvoke driver additional
* info for debugging to be included in driver's log (if any)
*/
#define SMCINVOKE_LOG_BUF_SIZE 100
#define SMCINVOKE_IOCTL_LOG \
_IOC(_IOC_READ|_IOC_WRITE, SMCINVOKE_IOC_MAGIC, 255, SMCINVOKE_LOG_BUF_SIZE)
#endif /* _UAPI_SMCINVOKE_H_ */