@@ -328,4 +328,38 @@
.size \name , . - \name
.endm
+/*
+ * Virtualisation instruction macros for tools which are too old to support
+ * them directly.
+ *
+ * Supporting Thumb-2 conditional forms via macros is tricky, so these are
+ * unconditional only. Code which will only be built using newer tools won't
+ * get these macros however, and should not need to worry about this
+ * restriction.
+ */
+#ifdef AS_NEEDS_HVC
+ .macro hvc i16
+ ARM( .inst 0xE1400070 | (((\i16 )<<4)&0xFFF00) | ((\i16 )&0xF) )
+ THUMB( .inst.w 0xF7E08000 | (((\i16 )<<4)&0xF0000) | ((\i16 )&0xFFF) )
+ .endm
+
+ .macro eret
+ ARM( .inst 0xE160006E ) /* for ARM, there is a separate encoding */
+ THUMB( subs pc, lr, #0 ) /* for Thumb, this architecturally = ERET */
+ .endm
+
+/*
+ * Note: to reduce the scariness of these macro definitions, regnum is the
+ * source register _number_ (e.g., specify 0, not r0).
+ */
+ .macro msr_elr_hyp regnum:req
+ ARM( .inst 0xE12EF300 | (\regnum ) )
+ THUMB( .inst 0xF3808A30 | (\regnum )<<16 )
+ .endm
+#else
+ .macro msr_elr_hyp regnum:req
+ msr elr_hyp, r\regnum
+ .endm
+#endif
+
#endif /* __ASM_ASSEMBLER_H__ */
In order to support booting in hyp mode as standard, it is useful to beable to compile the hyp stub installation code into all kernels, even if no hypervisor wlil actually be installed. If the version of gas in use doesn't support, this will fail. This patch defines some helper macros to emit the affected instructions if the tools don't support them natively. Note that there is no way to magically detect that this is necessary. Makefile rules can be used to define AS_NEEDS_HVC as appropriate: it probably does not make sense to define this everywhere. Signed-off-by: Dave Martin <dave.martin@linaro.org> --- arch/arm/include/asm/assembler.h | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-)