xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xen.org
Cc: Julien Grall <julien.grall@arm.com>,
	sstabellini@kernel.org, andrii_anisov@epam.com
Subject: [PATCH v2 02/21] xen/arm: regs: Convert guest_mode to a static inline helper
Date: Wed, 31 Oct 2018 18:12:54 +0000	[thread overview]
Message-ID: <20181031181313.8028-3-julien.grall@arm.com> (raw)
In-Reply-To: <20181031181313.8028-1-julien.grall@arm.com>

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(-)

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)
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-10-31 18:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31 18:12 [PATCH v2 00/21] xen/arm: Bunch of clean-ups Julien Grall
2018-10-31 18:12 ` [PATCH v2 01/21] xen/arm: traps: Constify show_*, do_unexpected_trap and do_bug_frame parameters Julien Grall
2018-11-09 13:40   ` Andrii Anisov
2018-10-31 18:12 ` Julien Grall [this message]
2018-10-31 18:12 ` [PATCH v2 03/21] xen/arm: Remove __init from prototype Julien Grall
2018-11-09 13:43   ` Andrii Anisov
2018-10-31 18:12 ` [PATCH v2 04/21] xen/arm: bugs: Move do_bug_frame to traps.h Julien Grall
2018-10-31 18:12 ` [PATCH v2 05/21] xen/arm: Consolidate CPU identification in cpufeature.{c, h} Julien Grall
2018-10-31 18:12 ` [PATCH v2 06/21] xen/arm: Move VABORT_GEN_BY_GUEST to traps.h and turned into inline Julien Grall
2018-10-31 18:12 ` [PATCH v2 07/21] xen/arm: gic-3: Remove unused includes Julien Grall
2018-10-31 18:13 ` [PATCH v2 08/21] xen/arm: gic-v3: Re-order includes in alphabetical order Julien Grall
2018-10-31 18:13 ` [PATCH v2 09/21] xen/arm: Move HSR defines in a new header hsr.h Julien Grall
2018-10-31 18:13 ` [PATCH v2 10/21] xen/arm: Move SYSREG accessors in sysregs.h Julien Grall
2018-10-31 18:13 ` [PATCH v2 11/21] xen/arm: Move out of processor.h traps related variable/function Julien Grall
2018-10-31 18:13 ` [PATCH v2 12/21] xen/arm: Only include stringify.h when necessary Julien Grall
2018-10-31 18:13 ` [PATCH v2 13/21] xen/arm: Only include vreg.h " Julien Grall
2018-10-31 18:13 ` [PATCH v2 14/21] xen/arm: Remove unnecessary includes in asm/vgic.h Julien Grall
2018-10-31 18:13 ` [PATCH v2 15/21] xen/arm: Remove unnecessary includes in asm/mmio.h Julien Grall
2018-10-31 18:13 ` [PATCH v2 16/21] xen/arm: Remove unnecessary includes in traps.c Julien Grall
2018-10-31 18:13 ` [PATCH v2 17/21] xen/arm: Remove unnecessary includes in asm/p2m.h Julien Grall
2018-10-31 18:13 ` [PATCH v2 18/21] xen/arm: Remove unnecessary includes in asm-arm/acpi.h Julien Grall
2018-10-31 18:13 ` [PATCH v2 19/21] xen/arm: Remove unnecessary includes in asm/current.h Julien Grall
2018-10-31 18:13 ` [PATCH v2 20/21] xen/arm: platform: Don't include p2m.h in exynos5 and omap5 Julien Grall
2018-10-31 18:13 ` [PATCH v2 21/21] xen/arm: Move vgic_* helpers from gic.h to vgic.h Julien Grall
2018-11-09 18:15 ` [PATCH v2 00/21] xen/arm: Bunch of clean-ups Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181031181313.8028-3-julien.grall@arm.com \
    --to=julien.grall@arm.com \
    --cc=andrii_anisov@epam.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).