[PATCH v4 5/6] inmates, arm64: provide own sysregs.h

0 views
Skip to first unread message

Ralf Ramsauer

unread,
Dec 12, 2017, 3:40:52 PM12/12/17
to jailho...@googlegroups.com, Jan Kiszka, Antonios Motakis, Ralf Ramsauer, Lokesh Vutla, Nikhil Devshatwar
ARM inmates make use of hypervisor's sysregs accessors and helpers. In
order to entirely decouple the hypervisor code from inmate code, let's
duplicate accessors.

And that's it, we just need to define accessors, compiler makes the
rest.

Signed-off-by: Ralf Ramsauer <ralf.r...@oth-regensburg.de>
Signed-off-by: Lokesh Vutla <lokes...@ti.com>
Signed-off-by: Nikhil Devshatwar <nikh...@ti.com>
Signed-off-by: Antonios Motakis <antonios...@huawei.com>
Reviewed-by: Lokesh Vutla <lokes...@ti.com>
Cc: Antonios Motakis <antonios...@huawei.com>
Cc: Nikhil Devshatwar <nikh...@ti.com>
Cc: Lokesh Vutla <lokes...@ti.com>
Cc: Jan Kiszka <jan.k...@siemens.com>
---
inmates/lib/arm64/include/asm/sysregs.h | 55 +++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
create mode 100644 inmates/lib/arm64/include/asm/sysregs.h

diff --git a/inmates/lib/arm64/include/asm/sysregs.h b/inmates/lib/arm64/include/asm/sysregs.h
new file mode 100644
index 00000000..0caea891
--- /dev/null
+++ b/inmates/lib/arm64/include/asm/sysregs.h
@@ -0,0 +1,55 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) OTH Regensburg, 2017
+ *
+ * Authors:
+ * Ralf Ramsauer <ralf.r...@oth-regensburg.de>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ *
+ * Alternatively, you can use or redistribute this file under the following
+ * BSD license:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* The following definitions are inspired by
+ * hypervisor/arch/arm64/include/asm/sysregs.h */
+
+#ifndef __ASSEMBLY__
+
+#define __stringify_1(x...) #x
+#define __stringify(x...) __stringify_1(x)
+
+#define SYSREG_32(op1, crn, crm, op2) s3_##op1 ##_##crn ##_##crm ##_##op2
+
+#define arm_write_sysreg(sysreg, val) \
+ asm volatile ("msr "__stringify(sysreg)", %0\n" : : "r"((u64)(val)))
+
+#define arm_read_sysreg(sysreg, val) \
+ asm volatile ("mrs %0, "__stringify(sysreg)"\n" : "=r"((val)))
+
+#endif /* __ASSEMBLY__ */
--
2.15.1

Reply all
Reply to author
Forward
0 new messages