Skip to content

Commit

Permalink
tee: Refactor TEE subsystem header files
Browse files Browse the repository at this point in the history
Since commit 25559c2 ("tee: add kernel internal client interface"),
it has been a common include/linux/tee_drv.h header file which is shared
to hold TEE subsystem internal bits along with the APIs exposed to the
TEE client drivers. However, this practice is prone to TEE subsystem
internal APIs abuse and especially so with the new TEE implementation
drivers being added to reuse existing functionality.

In order to address this split TEE subsystem internal bits as a separate
header file: include/linux/tee_core.h which should be the one used by
TEE implementation drivers. With that include/linux/tee_drv.h lists only
APIs exposed by TEE subsystem to the TEE client drivers.

Signed-off-by: Sumit Garg <[email protected]>
Signed-off-by: Balint Dobszay <[email protected]>
Signed-off-by: Jens Wiklander <[email protected]>
  • Loading branch information
b49020 authored and jenswi-linaro committed Apr 3, 2024
1 parent 4cece76 commit 0439fcf
Show file tree
Hide file tree
Showing 19 changed files with 343 additions and 305 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -21684,6 +21684,7 @@ F: Documentation/driver-api/tee.rst
F: Documentation/tee/
F: Documentation/userspace-api/tee.rst
F: drivers/tee/
F: include/linux/tee_core.h
F: include/linux/tee_drv.h
F: include/uapi/linux/tee.h

Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/amdtee/amdtee_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/kref.h>
#include <linux/types.h>
#include "amdtee_if.h"
Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/amdtee/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <linux/device.h>
#include <linux/tee.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/psp-tee.h>
#include <linux/slab.h>
#include <linux/psp.h>
Expand Down
3 changes: 1 addition & 2 deletions drivers/tee/amdtee/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/device.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/uaccess.h>
#include <linux/firmware.h>
#include "amdtee_private.h"
#include "../tee_private.h"
#include <linux/psp-tee.h>

static struct amdtee_driver_data *drv_data;
Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/amdtee/shm_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

#include <linux/slab.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/psp.h>
#include "amdtee_private.h"

Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/optee/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <linux/errno.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/types.h>
#include "optee_private.h"

Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/optee/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/types.h>
#include "optee_private.h"

Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/optee/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/uuid.h>
#include "optee_private.h"

Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/optee/ffa_abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/types.h>
#include "optee_private.h"
#include "optee_ffa.h"
Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/optee/notif.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include "optee_private.h"

struct notif_entry {
Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/optee/optee_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <linux/arm-smccc.h>
#include <linux/rhashtable.h>
#include <linux/semaphore.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/types.h>
#include "optee_msg.h"

Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/optee/rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include "optee_private.h"
#include "optee_rpc_cmd.h"

Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/optee/smc_abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/types.h>
#include <linux/workqueue.h>
#include "optee_private.h"
Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/tee_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <linux/idr.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/uaccess.h>
#include <crypto/hash.h>
#include <crypto/sha1.h>
Expand Down
35 changes: 0 additions & 35 deletions drivers/tee/tee_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,6 @@
#include <linux/mutex.h>
#include <linux/types.h>

#define TEE_DEVICE_FLAG_REGISTERED 0x1
#define TEE_MAX_DEV_NAME_LEN 32

/**
* struct tee_device - TEE Device representation
* @name: name of device
* @desc: description of device
* @id: unique id of device
* @flags: represented by TEE_DEVICE_FLAG_REGISTERED above
* @dev: embedded basic device structure
* @cdev: embedded cdev
* @num_users: number of active users of this device
* @c_no_user: completion used when unregistering the device
* @mutex: mutex protecting @num_users and @idr
* @idr: register of user space shared memory objects allocated or
* registered on this device
* @pool: shared memory pool
*/
struct tee_device {
char name[TEE_MAX_DEV_NAME_LEN];
const struct tee_desc *desc;
int id;
unsigned int flags;

struct device dev;
struct cdev cdev;

size_t num_users;
struct completion c_no_users;
struct mutex mutex; /* protects num_users and idr */

struct idr idr;
struct tee_shm_pool *pool;
};

int tee_shm_get_fd(struct tee_shm *shm);

bool tee_device_get(struct tee_device *teedev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/tee_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include <linux/uaccess.h>
#include <linux/uio.h>
#include <linux/highmem.h>
Expand Down
2 changes: 1 addition & 1 deletion drivers/tee/tee_shm_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <linux/dma-buf.h>
#include <linux/genalloc.h>
#include <linux/slab.h>
#include <linux/tee_drv.h>
#include <linux/tee_core.h>
#include "tee_private.h"

static int pool_op_gen_alloc(struct tee_shm_pool *pool, struct tee_shm *shm,
Expand Down
Loading

0 comments on commit 0439fcf

Please sign in to comment.