Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1693882
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 13/16] ARM: Handle trapping of CNTVCT from userspace |
| Date | 2017-07-21 19:20 +0200 |
| Message-ID | <u5JKO-7DO-25@gated-at.bofh.it> (permalink) |
| References | <u5JKN-7DO-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
As we're about to enable trapping of some of the userspace-visible
timer registers, let's add a handler for CNTVCT.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
arch/arm/kernel/traps.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index b697e9234a07..bda12a243b40 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -30,6 +30,7 @@
#include <linux/irq.h>
#include <linux/atomic.h>
+#include <asm/arch_timer.h>
#include <asm/cacheflush.h>
#include <asm/exception.h>
#include <asm/unistd.h>
@@ -735,6 +736,34 @@ late_initcall(arm_mrc_hook_init);
#endif
+#ifdef CONFIG_ARM_ARCH_TIMER
+static int read_cntvct_trap(struct pt_regs *regs, unsigned int instr)
+{
+ int rt = (instr >> 12) & 15;
+ int rt2 = (instr >> 16) & 15;
+ u64 val = arch_counter_get_cntvct();
+
+ regs->uregs[rt] = lower_32_bits(val);
+ regs->uregs[rt2] = upper_32_bits(val);
+ regs->ARM_pc += 4;
+ return 0;
+}
+
+static struct undef_hook cntvct_hook = {
+ .instr_mask = 0x0ff00fff,
+ .instr_val = 0x0c500f1e,
+ .fn = read_cntvct_trap,
+};
+
+static int __init arch_timer_hook_init(void)
+{
+ register_undef_hook(&cntvct_hook);
+ return 0;
+}
+
+late_initcall(arch_timer_hook_init);
+#endif
+
/*
* A data abort trap was taken, but we did not handle the instruction.
* Try to abort the user program, or panic if it was the kernel.
--
2.11.0
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 13/16] ARM: Handle trapping of CNTVCT from userspace Marc Zyngier <marc.zyngier@arm.com> - 2017-07-21 19:20 +0200
csiph-web