Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1693889 > unrolled thread

[PATCH 14/16] ARM: Handle trapping of CNTFRQ from userspace

Started byMarc Zyngier <marc.zyngier@arm.com>
First post2017-07-21 19:20 +0200
Last post2017-07-21 19:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 14/16] ARM: Handle trapping of CNTFRQ from userspace Marc Zyngier <marc.zyngier@arm.com> - 2017-07-21 19:20 +0200

#1693889 — [PATCH 14/16] ARM: Handle trapping of CNTFRQ from userspace

FromMarc Zyngier <marc.zyngier@arm.com>
Date2017-07-21 19:20 +0200
Subject[PATCH 14/16] ARM: Handle trapping of CNTFRQ from userspace
Message-ID<u5JKO-7DO-39@gated-at.bofh.it>
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@arm.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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web