[FOSS_TLK]security: tlk_driver: Add restore keyslot event smc
Aaron Gamble [Tue, 9 Dec 2014 17:54:03 +0000 (09:54 -0800)]
To be used by nvavp and nvdec drivers to signal tlk to restore their
keys. Appropriate clocks should be enabled before/after calling.

Change-Id: I45c7ce17e198acff042d27d5d17aa07a8428ad79
Signed-off-by: Aaron Gamble <jgamble@nvidia.com>
Reviewed-on: http://git-master/r/755012
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>
Tested-by: Varun Wadekar <vwadekar@nvidia.com>

include/linux/ote_protocol.h [new file with mode: 0644]
security/tlk_driver/ote_comms.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..47b93c2
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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);
+void te_restore_keyslots(void);
+
+#endif
index 1c1ee2e..cb7e155 100644 (file)
@@ -415,6 +415,23 @@ int te_set_vpr_params(void *vpr_base, size_t vpr_size)
 }
 EXPORT_SYMBOL(te_set_vpr_params);
 
+void te_restore_keyslots(void)
+{
+       uint32_t retval;
+
+       /* Share the same lock used when request is send from user side */
+       mutex_lock(&smc_lock);
+
+       retval = send_smc(TE_SMC_TA_EVENT, TA_EVENT_RESTORE_KEYS, 0);
+
+       mutex_unlock(&smc_lock);
+
+       if (retval != OTE_SUCCESS) {
+               pr_err("%s: smc failed err (0x%x)\n", __func__, retval);
+       }
+}
+EXPORT_SYMBOL(te_restore_keyslots);
+
 /*
  * Open session SMC (supporting client-based te_open_session() calls)
  */
index 9d13bf5..06afc6f 100644 (file)
@@ -117,6 +117,7 @@ enum {
        TE_SMC_OPEN_SESSION             = 0x70000001,
        TE_SMC_CLOSE_SESSION            = 0x70000002,
        TE_SMC_LAUNCH_OPERATION         = 0x70000003,
+       TE_SMC_TA_EVENT                 = 0x70000004,
 
        /* Trusted OS (64-bit) calls */
        TE_SMC_REGISTER_REQ_BUF         = 0x72000001,
@@ -237,6 +238,12 @@ struct te_ss_op {
        uint8_t         data[SS_OP_MAX_DATA_SIZE];
 };
 
+enum ta_event_id {
+       TA_EVENT_RESTORE_KEYS = 0,
+
+       TA_EVENT_MASK = (1 << TA_EVENT_RESTORE_KEYS),
+};
+
 int te_handle_ss_ioctl(struct file *file, unsigned int ioctl_num,
                unsigned long ioctl_param);
 void ote_print_logs(void);