security: tlk_driver: interface to program VPR base/len
James Zhao [Wed, 16 Oct 2013 22:05:53 +0000 (15:05 -0700)]
Add interface for the kernel to program vpr base
address through TLK.
Expect phys addr of vpr base, and vpr size.

bug 1279160

Change-Id: I0ff6ef9783ac2bb6438afa0552f57a84e84bf567
Signed-off-by: James Zhao <jamesz@nvidia.com>
Reviewed-on: http://git-master/r/302404
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>

include/linux/ote_protocol.h [new file with mode: 0644]
security/tlk_driver/ote_comms.c
security/tlk_driver/ote_device.c
security/tlk_driver/ote_protocol.h

diff --git a/include/linux/ote_protocol.h b/include/linux/ote_protocol.h
new file mode 100644 (file)
index 0000000..766e73e
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2013 NVIDIA Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#ifndef __OTE_PROTOCOL_H__
+#define __OTE_PROTOCOL_H__
+
+int te_set_vpr_params(void *vpr_base, size_t vpr_size);
+
+#endif
index 1e80049..f79753a 100644 (file)
@@ -297,6 +297,28 @@ static void do_smc(struct te_request *request, struct tlk_device *dev)
 }
 
 /*
+ * VPR programming SMC
+ */
+int te_set_vpr_params(void *vpr_base, size_t vpr_size)
+{
+       uint32_t retval;
+
+       /* Share the same lock used when request is send from user side */
+       mutex_lock(&smc_lock);
+
+       retval = TLK_GENERIC_SMC(TE_SMC_PROGRAM_VPR, vpr_base, vpr_size);
+
+       mutex_unlock(&smc_lock);
+
+       if (retval != OTE_SUCCESS) {
+               pr_err("te_set_vpr_params failed err (0x%x)\n", retval);
+               return -EINVAL;
+       }
+       return 0;
+}
+EXPORT_SYMBOL(te_set_vpr_params);
+
+/*
  * Open session SMC (supporting client-based te_open_session() calls)
  */
 void te_open_session(struct te_opensession *cmd,
index 21def6c..29b860a 100644 (file)
@@ -35,7 +35,7 @@
 #define SET_ANSWER(a, r, ro)   { a.result = r; a.result_origin = ro; }
 
 struct tlk_device tlk_dev;
-static DEFINE_MUTEX(smc_lock);
+DEFINE_MUTEX(smc_lock);
 
 static int te_create_free_cmd_list(struct tlk_device *dev)
 {
index 3da0349..f5d9639 100644 (file)
@@ -44,6 +44,8 @@
 
 #define MAX_EXT_SMC_ARGS       12
 
+extern struct mutex smc_lock;
+
 uint32_t tlk_generic_smc(uint32_t arg0, uint32_t arg1, uint32_t arg2);
 uint32_t tlk_extended_smc(uint32_t *args);
 void tlk_irq_handler(void);
@@ -121,6 +123,7 @@ enum {
        TE_SMC_NS_IRQ_DONE              = 0xFFFF1FF1,
        TE_SMC_REGISTER_FS_HANDLERS     = 0xFFFF1FF2,
        TE_SMC_REGISTER_REQ_BUF         = 0xFFFF1FF3,
+       TE_SMC_PROGRAM_VPR              = 0xFFFF1FF5,
        TE_SMC_FS_OP_DONE               = 0xFFFF1FFF,
        TE_SMC_INIT_LOGGER              = 0xFFFF1FF4,