aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2016-01-02 10:07:13 -0500
committerMarc Zyngier <marc.zyngier@arm.com>2016-02-29 13:34:13 -0500
commit3c29568768dfe6965ca51e1a78f9f31ebc0c500a (patch)
tree567bdc926a71611b929ee2d093e60d5928138ac1
parent08dcbfda0774d5550447835f20a647b7e4c94481 (diff)
ARM: KVM: Add system register accessor macros
In order to move system register (CP15, mostly) access to C code, add a few macros to facilitate this, and minimize the difference between 32 and 64bit CP15 registers. This will get heavily used in the following patches. Acked-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r--arch/arm/kvm/hyp/hyp.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/arm/kvm/hyp/hyp.h b/arch/arm/kvm/hyp/hyp.h
index c72387073b09..727089f0ddb6 100644
--- a/arch/arm/kvm/hyp/hyp.h
+++ b/arch/arm/kvm/hyp/hyp.h
@@ -27,4 +27,19 @@
27#define kern_hyp_va(v) (v) 27#define kern_hyp_va(v) (v)
28#define hyp_kern_va(v) (v) 28#define hyp_kern_va(v) (v)
29 29
30#define __ACCESS_CP15(CRn, Op1, CRm, Op2) \
31 "mrc", "mcr", __stringify(p15, Op1, %0, CRn, CRm, Op2), u32
32#define __ACCESS_CP15_64(Op1, CRm) \
33 "mrrc", "mcrr", __stringify(p15, Op1, %Q0, %R0, CRm), u64
34
35#define __write_sysreg(v, r, w, c, t) asm volatile(w " " c : : "r" ((t)(v)))
36#define write_sysreg(v, ...) __write_sysreg(v, __VA_ARGS__)
37
38#define __read_sysreg(r, w, c, t) ({ \
39 t __val; \
40 asm volatile(r " " c : "=r" (__val)); \
41 __val; \
42})
43#define read_sysreg(...) __read_sysreg(__VA_ARGS__)
44
30#endif /* __ARM_KVM_HYP_H__ */ 45#endif /* __ARM_KVM_HYP_H__ */