[Xen-devel,v2,02/21] xen/arm: regs: Convert guest_mode to a static inline helper

Message ID 20181031181313.8028-3-julien.grall@arm.com
State Accepted
Commit ce4cd9ab7cef8c7ed01a719e8aadb9d091b2fd4b
Headers show
Series
  • xen/arm: Bunch of clean-ups
Related show

Commit Message

Julien Grall Oct. 31, 2018, 6:12 p.m.
At the same time, switch the parameter guest_mode from int to bool

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andrii Anisov <andrii_anisov@epam.com>

---
    Changes in v2:
        - Add andrii's reviewed-by
---
 xen/arch/arm/traps.c       |  6 +++---
 xen/include/asm-arm/regs.h | 22 ++++++++++++----------
 2 files changed, 15 insertions(+), 13 deletions(-)

Patch

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index e8fa760607..b9323672fc 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -789,7 +789,7 @@  static const char *mode_string(uint32_t cpsr)
 
 static void show_registers_32(const struct cpu_user_regs *regs,
                               const struct reg_ctxt *ctxt,
-                              int guest_mode,
+                              bool guest_mode,
                               const struct vcpu *v)
 {
 
@@ -866,7 +866,7 @@  static void show_registers_32(const struct cpu_user_regs *regs,
 #ifdef CONFIG_ARM_64
 static void show_registers_64(const struct cpu_user_regs *regs,
                               const struct reg_ctxt *ctxt,
-                              int guest_mode,
+                              bool guest_mode,
                               const struct vcpu *v)
 {
 
@@ -927,7 +927,7 @@  static void show_registers_64(const struct cpu_user_regs *regs,
 
 static void _show_registers(const struct cpu_user_regs *regs,
                             const struct reg_ctxt *ctxt,
-                            int guest_mode,
+                            bool guest_mode,
                             const struct vcpu *v)
 {
     print_xen_info();
diff --git a/xen/include/asm-arm/regs.h b/xen/include/asm-arm/regs.h
index 2440edb29a..ddc6eba9ce 100644
--- a/xen/include/asm-arm/regs.h
+++ b/xen/include/asm-arm/regs.h
@@ -5,8 +5,10 @@ 
 
 #ifndef __ASSEMBLY__
 
+#include <xen/lib.h>
 #include <xen/types.h>
 #include <public/xen.h>
+#include <asm/current.h>
 #include <asm/processor.h>
 
 #define psr_mode(psr,m) (((psr) & PSR_MODE_MASK) == m)
@@ -37,16 +39,16 @@ 
     (psr_mode((r)->cpsr,PSR_MODE_EL0t) || usr_mode(r))
 #endif
 
-#define guest_mode(r)                                                         \
-({                                                                            \
-    unsigned long diff = (char *)guest_cpu_user_regs() - (char *)(r);         \
-    /* Frame pointer must point into current CPU stack. */                    \
-    ASSERT(diff < STACK_SIZE);                                                \
-    /* If not a guest frame, it must be a hypervisor frame. */                \
-    ASSERT((diff == 0) || hyp_mode(r));                                       \
-    /* Return TRUE if it's a guest frame. */                                  \
-    (diff == 0);                                                              \
-})
+static inline bool guest_mode(const struct cpu_user_regs *r)
+{
+    unsigned long diff = (char *)guest_cpu_user_regs() - (char *)(r);
+    /* Frame pointer must point into current CPU stack. */
+    ASSERT(diff < STACK_SIZE);
+    /* If not a guest frame, it must be a hypervisor frame. */
+    ASSERT((diff == 0) || hyp_mode(r));
+    /* Return TRUE if it's a guest frame. */
+    return (diff == 0);
+}
 
 #define return_reg(v) ((v)->arch.cpu_info->guest_cpu_user_regs.r0)