mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-24 02:01:36 +03:00
misc: mods: Add ioctl to pass messages to tz app
Summary: This change adds support in mods kernel driver to send messages to Trusty in order to run tests trust zone side Signed-off-by: Ellis Roberts <ellisr@nvidia.com> Change-Id: I5cd0a1dcc4d1ac5543df5fb3ebec4427c1145e10 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2567469 Tested-by: Rohith Talluri <sitalluri@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: Chris Dragan <kdragan@nvidia.com> Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com> Reviewed-by: Stephen Wolfe <swolfe@nvidia.com> Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
@@ -2,6 +2,7 @@ obj-$(CONFIG_MODS) := mods.o
|
||||
mods-y := mods_krnl.o
|
||||
mods-y += mods_mem.o
|
||||
mods-y += mods_irq.o
|
||||
mods-$(CONFIG_ARCH_TEGRA) += mods_tz.o
|
||||
mods-$(CONFIG_COMMON_CLK) += mods_clock.o
|
||||
mods-$(CONFIG_ARCH_TEGRA) += mods_tegraprod.o
|
||||
mods-$(CONFIG_ARCH_TEGRA_19x_SOC) += mods_ras.o
|
||||
|
||||
@@ -693,6 +693,9 @@ int esc_mods_tegra_prod_set_prod_by_name(struct mods_client *client,
|
||||
int esc_mods_tegra_prod_set_prod_exact(struct mods_client *client,
|
||||
struct MODS_TEGRA_PROD_SET_TUPLE *tuple);
|
||||
|
||||
/* trustzone app call */
|
||||
int esc_mods_send_trustzone_msg(struct mods_client *client,
|
||||
struct MODS_TZ_PARAMS *p);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
|
||||
@@ -2541,6 +2541,11 @@ static long mods_krnl_ioctl(struct file *fp,
|
||||
esc_mods_tegra_prod_iterate_dt,
|
||||
MODS_TEGRA_PROD_ITERATOR);
|
||||
break;
|
||||
|
||||
case MODS_ESC_SEND_TZ_MSG:
|
||||
MODS_IOCTL(MODS_ESC_SEND_TZ_MSG,
|
||||
esc_mods_send_trustzone_msg, MODS_TZ_PARAMS);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MODS_ESC_ACQUIRE_ACCESS_TOKEN:
|
||||
|
||||
45
drivers/misc/mods/mods_tz.c
Normal file
45
drivers/misc/mods/mods_tz.c
Normal file
@@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*/
|
||||
|
||||
#include "mods_internal.h"
|
||||
|
||||
#include <linux/trusty/trusty_ipc.h>
|
||||
|
||||
#define MODS_PORT "com.nvidia.srv.mods"
|
||||
|
||||
int esc_mods_send_trustzone_msg(struct mods_client *client,
|
||||
struct MODS_TZ_PARAMS *p)
|
||||
{
|
||||
int ret;
|
||||
void *chan_ctx = NULL;
|
||||
|
||||
ret = te_open_trusted_session(MODS_PORT, &chan_ctx);
|
||||
if (ret < 0) {
|
||||
cl_error("Couldn't open connection mods service\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = te_launch_trusted_oper(p->buf, p->buf_size, p->cmd, chan_ctx);
|
||||
if (ret < 0) {
|
||||
cl_error("Trusted operation failed\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
error:
|
||||
p->status = ret;
|
||||
if (chan_ctx)
|
||||
te_close_trusted_session(chan_ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1780,6 +1780,21 @@ struct MODS_IOMMU_DMA_MAP_MEMORY {
|
||||
__u64 physical_address;
|
||||
};
|
||||
|
||||
#define MAX_TZ_BUFFER_SIZE 512
|
||||
/* Used by MODS_ESC_SEND_TZ_MSG.
|
||||
*
|
||||
* Available only on Tegra.
|
||||
*/
|
||||
struct MODS_TZ_PARAMS {
|
||||
/* IN */
|
||||
__u8 buf[MAX_TZ_BUFFER_SIZE];
|
||||
__u32 buf_size;
|
||||
__u32 cmd;
|
||||
|
||||
/* OUT */
|
||||
int status;
|
||||
};
|
||||
|
||||
#define MODS_IOMMU_MAP_CONTIGUOUS 1
|
||||
|
||||
#pragma pack(pop)
|
||||
@@ -1979,5 +1994,6 @@ struct MODS_IOMMU_DMA_MAP_MEMORY {
|
||||
#define MODS_ESC_MODS_GET_DRIVER_STATS MODSIO(R, 135, MODS_GET_DRIVER_STATS)
|
||||
#define MODS_ESC_BPMP_SET_PCIE_STATE MODSIO(W, 136, MODS_SET_PCIE_STATE)
|
||||
#define MODS_ESC_BPMP_INIT_PCIE_EP_PLL MODSIO(W, 137, MODS_INIT_PCIE_EP_PLL)
|
||||
#define MODS_ESC_SEND_TZ_MSG MODSIO(WR, 139, MODS_TZ_PARAMS)
|
||||
|
||||
#endif /* _UAPI_MODS_H_ */
|
||||
|
||||
Reference in New Issue
Block a user