[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170721171542.27639-15-marc.zyngier@arm.com>
Date: Fri, 21 Jul 2017 18:15:40 +0100
From: Marc Zyngier <marc.zyngier@....com>
To: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: Mark Rutland <mark.rutland@....com>,
Russell King <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Thomas Gleixner <tglx@...utronix.de>
Subject: [PATCH 14/16] ARM: Handle trapping of CNTFRQ from userspace
As we're about to enable trapping of some of the userspace-visible
timer registers, let's add a handler for CNTFRQ.
Signed-off-by: Marc Zyngier <marc.zyngier@....com>
---
arch/arm/kernel/traps.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index bda12a243b40..1c1b86af20e9 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -755,9 +755,26 @@ static struct undef_hook cntvct_hook = {
.fn = read_cntvct_trap,
};
+static int read_cntfrq_trap(struct pt_regs *regs, unsigned int instr)
+{
+ int reg = (instr >> 12) & 15;
+ if (reg == 15)
+ return 1;
+ regs->uregs[reg] = arch_timer_get_rate();
+ regs->ARM_pc += 4;
+ return 0;
+}
+
+static struct undef_hook cntfrq_hook = {
+ .instr_mask = 0x0fff0fff,
+ .instr_val = 0x0e1e0f10,
+ .fn = read_cntfrq_trap,
+};
+
static int __init arch_timer_hook_init(void)
{
register_undef_hook(&cntvct_hook);
+ register_undef_hook(&cntfrq_hook);
return 0;
}
--
2.11.0
Powered by blists - more mailing lists