clear-pkgs-linux-iot-lts2018/0877-trusty-Add-notifier-be...

99 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= <arve@android.com>
Date: Thu, 5 May 2016 15:43:44 -0700
Subject: [PATCH] trusty: Add notifier before and after every smc call.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Called with local interrupts disabled.
Change-Id: I5d2b15ce0fee29f067d8403a6f7127046fc185e9
Signed-off-by: Arve Hjønnevåg <arve@android.com>
---
drivers/trusty/trusty.c | 26 ++++++++++++++++++++++++++
include/linux/trusty/trusty.h | 10 ++++++++++
2 files changed, 36 insertions(+)
diff --git a/drivers/trusty/trusty.c b/drivers/trusty/trusty.c
index 59ecf60fc050..7efcff89610c 100644
--- a/drivers/trusty/trusty.c
+++ b/drivers/trusty/trusty.c
@@ -26,6 +26,7 @@
struct trusty_state {
struct mutex smc_lock;
+ struct atomic_notifier_head notifier;
};
#ifdef CONFIG_ARM64
@@ -123,7 +124,14 @@ static ulong trusty_std_call_helper(struct device *dev, ulong smcnr,
struct trusty_state *s = platform_get_drvdata(to_platform_device(dev));
while (true) {
+ local_irq_disable();
+ atomic_notifier_call_chain(&s->notifier, TRUSTY_CALL_PREPARE,
+ NULL);
ret = trusty_std_call_inner(dev, smcnr, a0, a1, a2);
+ atomic_notifier_call_chain(&s->notifier, TRUSTY_CALL_RETURNED,
+ NULL);
+ local_irq_enable();
+
if ((int)ret != SM_ERR_BUSY)
break;
@@ -178,6 +186,23 @@ s32 trusty_std_call32(struct device *dev, u32 smcnr, u32 a0, u32 a1, u32 a2)
}
EXPORT_SYMBOL(trusty_std_call32);
+int trusty_call_notifier_register(struct device *dev, struct notifier_block *n)
+{
+ struct trusty_state *s = platform_get_drvdata(to_platform_device(dev));
+
+ return atomic_notifier_chain_register(&s->notifier, n);
+}
+EXPORT_SYMBOL(trusty_call_notifier_register);
+
+int trusty_call_notifier_unregister(struct device *dev,
+ struct notifier_block *n)
+{
+ struct trusty_state *s = platform_get_drvdata(to_platform_device(dev));
+
+ return atomic_notifier_chain_unregister(&s->notifier, n);
+}
+EXPORT_SYMBOL(trusty_call_notifier_unregister);
+
static int trusty_remove_child(struct device *dev, void *data)
{
platform_device_unregister(to_platform_device(dev));
@@ -201,6 +226,7 @@ static int trusty_probe(struct platform_device *pdev)
goto err_allocate_state;
}
mutex_init(&s->smc_lock);
+ ATOMIC_INIT_NOTIFIER_HEAD(&s->notifier);
platform_set_drvdata(pdev, s);
ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
diff --git a/include/linux/trusty/trusty.h b/include/linux/trusty/trusty.h
index 30d4300ba301..ce00c1d46a5e 100644
--- a/include/linux/trusty/trusty.h
+++ b/include/linux/trusty/trusty.h
@@ -43,4 +43,14 @@ static inline s64 trusty_fast_call64(struct device *dev,
#endif
#endif
+struct notifier_block;
+enum {
+ TRUSTY_CALL_PREPARE,
+ TRUSTY_CALL_RETURNED,
+};
+int trusty_call_notifier_register(struct device *dev,
+ struct notifier_block *n);
+int trusty_call_notifier_unregister(struct device *dev,
+ struct notifier_block *n);
+
#endif
--
https://clearlinux.org