aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jones <drjones@redhat.com>2020-04-03 09:13:15 +0200
committerAndrew Jones <drjones@redhat.com>2020-04-03 09:49:57 +0200
commitc7ca23ce3f571449a58dd8ef86c953e865f9c3f1 (patch)
tree9f3e44b0cbd2c157af0dae433b3f739f0c825f28
parent56145eb8f7f6aa66b26e1d1232a5f3dfa7cdd058 (diff)
downloadkvm-unit-tests-c7ca23ce3f571449a58dd8ef86c953e865f9c3f1.tar.gz
arm64: Provide read/write_sysreg_s
Sometimes we need to test access to system registers which are missing assembler mnemonics. Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
-rw-r--r--lib/arm64/asm/sysreg.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/arm64/asm/sysreg.h b/lib/arm64/asm/sysreg.h
index a03830b..a45eebd 100644
--- a/lib/arm64/asm/sysreg.h
+++ b/lib/arm64/asm/sysreg.h
@@ -38,6 +38,17 @@
asm volatile("msr " xstr(r) ", %x0" : : "rZ" (__val)); \
} while (0)
+#define read_sysreg_s(r) ({ \
+ u64 __val; \
+ asm volatile("mrs_s %0, " xstr(r) : "=r" (__val)); \
+ __val; \
+})
+
+#define write_sysreg_s(v, r) do { \
+ u64 __val = (u64)v; \
+ asm volatile("msr_s " xstr(r) ", %x0" : : "rZ" (__val));\
+} while (0)
+
asm(
" .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n"
" .equ .L__reg_num_x\\num, \\num\n"