Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753751AbbDNJMT (ORCPT ); Tue, 14 Apr 2015 05:12:19 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:48929 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753376AbbDNJMB (ORCPT ); Tue, 14 Apr 2015 05:12:01 -0400 From: Juergen Borleis To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, kernel@pengutronix.de, Alessandro Zummo , linux-arm-kernel@lists.infradead.org, Robert Schwebel Subject: [PATCH 3/5] RTC/i.MX/DryIce: monitor a security violation at runtime Date: Tue, 14 Apr 2015 11:11:54 +0200 Message-Id: <1429002716-19821-4-git-send-email-jbe@pengutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429002716-19821-1-git-send-email-jbe@pengutronix.de> References: <1429002716-19821-1-git-send-email-jbe@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: jbe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2146 Lines: 64 Maybe the unit enters the hardware related state at runtime and not at system boot time (after a power cycle). Signed-off-by: Juergen Borleis Signed-off-by: Robert Schwebel [rsc: got NDA clearance from Freescale] --- drivers/rtc/rtc-imxdi.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c index f8abf2b..b04c64f 100644 --- a/drivers/rtc/rtc-imxdi.c +++ b/drivers/rtc/rtc-imxdi.c @@ -680,6 +680,25 @@ static irqreturn_t dryice_norm_irq(int irq, void *dev_id) irqreturn_t rc = IRQ_NONE; dier = __raw_readl(imxdi->ioaddr + DIER); + dsr = __raw_readl(imxdi->ioaddr + DSR); + + /* handle the security violation event */ + if (dier & DIER_SVIE) { + if (dsr & DSR_SVF) { + /* + * Disable the interrupt when this kind of event has + * happened. + * There cannot be more than one event of this type, + * because it needs a complex state change + * including a main power cycle to get again out of + * this state. + */ + di_int_disable(imxdi, DIER_SVIE); + /* report the violation */ + di_report_tamper_info(imxdi, dsr); + rc = IRQ_HANDLED; + } + } /* handle write complete and write error cases */ if (dier & DIER_WCIE) { @@ -690,7 +709,6 @@ static irqreturn_t dryice_norm_irq(int irq, void *dev_id) return rc; /* DSR_WCF clears itself on DSR read */ - dsr = __raw_readl(imxdi->ioaddr + DSR); if (dsr & (DSR_WCF | DSR_WEF)) { /* mask the interrupt */ di_int_disable(imxdi, DIER_WCIE); @@ -706,7 +724,6 @@ static irqreturn_t dryice_norm_irq(int irq, void *dev_id) /* handle the alarm case */ if (dier & DIER_CAIE) { /* DSR_WCF clears itself on DSR read */ - dsr = __raw_readl(imxdi->ioaddr + DSR); if (dsr & DSR_CAF) { /* mask the interrupt */ di_int_disable(imxdi, DIER_CAIE); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/