All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2nd try] RTC/i.MX/DryICE: add recovery routines to the driver
@ 2015-04-14  9:11 ` Juergen Borleis
  0 siblings, 0 replies; 42+ messages in thread
From: Juergen Borleis @ 2015-04-14  9:11 UTC (permalink / raw)
  To: linux-kernel; +Cc: rtc-linux, kernel, Alessandro Zummo, linux-arm-kernel

2nd try, this time with a cover letter... m(

The built-in RTC unit on some i.MX SoCs isn't an RTC only. It is also a tamper
monitor unit which can keep some keys. When it does its tamper detection job
and a tamper violation is detected, this RTC unit locks completely including
the real-time counter. In this state the unit is completely useless. The only
way to bring it out of this locked state is a power on reset. At the next boot
time some flags signals the tamper violation and a specific register access
sequence must be done to finaly bring this unit into life again. Until this is
done, there is no way to use it again as an RTC.
But also without any enabled tamper detection sometimes this unit tends to
lock. And in this case the same steps must be done to bring it into life
again.
The current implementation of the DryIce driver isn't able to unlock the
device successfully in the case it is locked somehow. Only a full power cycle
including *battery power* can help in this case.

The attached change set adds the required routines to be able to unlock the
DryIce unit in the case the driver detects a locked unit. This includes
unlocking it if it is locked by accident or malfunction and not by a real
tamper violation.

The last patch of this series is for reference only and should not be part
of the kernel. It just adds some code to force a locked DryIce unit to check
if the new routines are able to unlock it again. This code was required
because I had no hardware which really uses the tamper detection features of
this unit.

Comments are welcome.

jbe


^ permalink raw reply	[flat|nested] 42+ messages in thread
* [PATCH 1/5] RTC/i.MX/DryIce: add some background info about the states the machine can be in
@ 2015-04-14  9:08 Juergen Borleis
  2015-04-14  9:08 ` [rtc-linux] [PATCH 2/5] RTC/i.MX/DryIce: add the unit recovery code Juergen Borleis
  0 siblings, 1 reply; 42+ messages in thread
From: Juergen Borleis @ 2015-04-14  9:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: rtc-linux, Alessandro Zummo, linux-arm-kernel, Robert Schwebel

Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
Signed-off-by: Robert Schwebel <rsc@pengutronix.de>
[rsc: got NDA clearance from Freescale]
---
 drivers/rtc/rtc-imxdi.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index c666eab..8750477 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -129,6 +129,49 @@ struct imxdi_dev {
 	struct work_struct work;
 };
 
+/* Some background:
+ *
+ * The DryIce unit is a complex security/tamper monitor device. To be able do
+ * its job in a useful manner it runs a bigger statemachine to bring it into
+ * security/tamper failure state and once again to bring it out of this state.
+ *
+ * This unit can be in one of three states:
+ *
+ * - "NON-VALID STATE"
+ *   always after the battery power was removed
+ * - "FAILURE STATE"
+ *   if one of the enabled security events have happend
+ * - "VALID STATE"
+ *   if the unit works as expected
+ *
+ * Everything stops when the unit enters the failure state including the RTC
+ * counter (to be able to detect the time the security event happend).
+ *
+ * The following events (when enabled) let the DryIce unit enter the failure
+ * state:
+ *
+ * - wire-mesh-tamper detect
+ * - external tamper B detect
+ * - external tamper A detect
+ * - temperature tamper detect
+ * - clock tamper detect
+ * - voltage tamper detect
+ * - RTC counter overflow
+ * - monotonic counter overflow
+ * - external boot
+ *
+ * If we find the DryIce unit in "FAILURE STATE" and the TDCHL cleared, we
+ * can only detect this state. In this case the unit is completely locked and
+ * must force a second "SYSTEM POR" to bring the DryIce into the
+ * "NON-VALID STATE" + "FAILURE STATE" where a recovery is possible.
+ * If the TDCHL is set in the "FAILURE STATE" we are out of luck. In this case
+ * a battery power cycle is required.
+ *
+ * In the "NON-VALID STATE" + "FAILURE STATE" we can clear the "FAILURE STATE"
+ * and recover the DryIce unit. By clearing the "NON-VALID STATE" as the last
+ * task, we bring back this unit into life.
+ */
+
 /*
  * enable a dryice interrupt
  */
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2015-04-24 10:32 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-14  9:11 [PATCH 2nd try] RTC/i.MX/DryICE: add recovery routines to the driver Juergen Borleis
2015-04-14  9:11 ` Juergen Borleis
2015-04-14  9:11 ` [rtc-linux] " Juergen Borleis
2015-04-14  9:11 ` [PATCH 1/5] RTC/i.MX/DryIce: add some background info about the states the machine can be in Juergen Borleis
2015-04-14  9:11   ` Juergen Borleis
2015-04-14  9:11   ` [rtc-linux] " Juergen Borleis
2015-04-21 22:09   ` Alexandre Belloni
2015-04-21 22:09     ` Alexandre Belloni
2015-04-24 10:10     ` Juergen Borleis
2015-04-24 10:10       ` Juergen Borleis
2015-04-24 10:10       ` Juergen Borleis
2015-04-14  9:11 ` [PATCH 2/5] RTC/i.MX/DryIce: add the unit recovery code Juergen Borleis
2015-04-14  9:11   ` Juergen Borleis
2015-04-14  9:11   ` [rtc-linux] " Juergen Borleis
2015-04-21 23:14   ` Alexandre Belloni
2015-04-21 23:14     ` Alexandre Belloni
2015-04-21 23:14     ` Alexandre Belloni
2015-04-21 23:46     ` Alexandre Belloni
2015-04-21 23:46       ` Alexandre Belloni
2015-04-21 23:46       ` Alexandre Belloni
2015-04-24 10:24     ` Juergen Borleis
2015-04-24 10:24       ` Juergen Borleis
2015-04-24 10:24       ` Juergen Borleis
2015-04-14  9:11 ` [PATCH 3/5] RTC/i.MX/DryIce: monitor a security violation at runtime Juergen Borleis
2015-04-14  9:11   ` Juergen Borleis
2015-04-14  9:11   ` [rtc-linux] " Juergen Borleis
2015-04-14  9:11 ` [PATCH 4/5] RTC/i.MX/DryIce: when locked, do not fail silently Juergen Borleis
2015-04-14  9:11   ` Juergen Borleis
2015-04-14  9:11   ` [rtc-linux] " Juergen Borleis
2015-04-21 23:30   ` Alexandre Belloni
2015-04-21 23:30     ` Alexandre Belloni
2015-04-21 23:30     ` Alexandre Belloni
2015-04-14  9:11 ` [PATCH 5/5] RTC/i.MX/DryIce: prepare to force a security violation Juergen Borleis
2015-04-14  9:11   ` Juergen Borleis
2015-04-14  9:11   ` [rtc-linux] " Juergen Borleis
2015-04-21 23:26 ` [rtc-linux] [PATCH 2nd try] RTC/i.MX/DryICE: add recovery routines to the driver Alexandre Belloni
2015-04-21 23:26   ` Alexandre Belloni
2015-04-21 23:26   ` Alexandre Belloni
2015-04-24 10:32   ` Juergen Borleis
2015-04-24 10:32     ` Juergen Borleis
2015-04-24 10:32     ` Juergen Borleis
  -- strict thread matches above, loose matches on Subject: below --
2015-04-14  9:08 [PATCH 1/5] RTC/i.MX/DryIce: add some background info about the states the machine can be in Juergen Borleis
2015-04-14  9:08 ` [rtc-linux] [PATCH 2/5] RTC/i.MX/DryIce: add the unit recovery code Juergen Borleis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.