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:
@@ -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
|
||||
|
||||
|
159
qcom/opensource/securemsm-kernel/include/linux/IClientEnv.h
Normal file
159
qcom/opensource/securemsm-kernel/include/linux/IClientEnv.h
Normal 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);
|
||||
}
|
@@ -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));
|
||||
}
|
108
qcom/opensource/securemsm-kernel/include/linux/smci_clientenv.h
Normal file
108
qcom/opensource/securemsm-kernel/include/linux/smci_clientenv.h
Normal 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 */
|
151
qcom/opensource/securemsm-kernel/include/linux/smci_object.h
Normal file
151
qcom/opensource/securemsm-kernel/include/linux/smci_object.h
Normal 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 */
|
110
qcom/opensource/securemsm-kernel/include/linux/smcinvoke.h
Normal file
110
qcom/opensource/securemsm-kernel/include/linux/smcinvoke.h
Normal 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_ */
|
@@ -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 */
|
Reference in New Issue
Block a user