All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii_strashko@epam.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Anthony PERARD <anthony.perard@vates.tech>,
	Jan Beulich <jbeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>,
	Grygorii Strashko <grygorii_strashko@epam.com>
Subject: [XEN][PATCH 7/8] xen/arm: regs.h split subarch definitions between arm64/arm32
Date: Wed, 23 Jul 2025 07:58:40 +0000	[thread overview]
Message-ID: <20250723075835.3993182-8-grygorii_strashko@epam.com> (raw)
In-Reply-To: <20250723075835.3993182-1-grygorii_strashko@epam.com>

From: Grygorii Strashko <grygorii_strashko@epam.com>

Split subarch definitions between arm64/arm32:
hyp_mode()
regs_mode_is_user()
regs_mode_is_32bit()

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
---
 xen/arch/arm/include/asm/arm32/processor.h |  5 +++++
 xen/arch/arm/include/asm/arm64/processor.h | 15 ++++++++++++++
 xen/arch/arm/include/asm/regs.h            | 24 ----------------------
 3 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/xen/arch/arm/include/asm/arm32/processor.h b/xen/arch/arm/include/asm/arm32/processor.h
index 4e679f3273ab..10d5ff5c192e 100644
--- a/xen/arch/arm/include/asm/arm32/processor.h
+++ b/xen/arch/arm/include/asm/arm32/processor.h
@@ -56,6 +56,11 @@ struct cpu_user_regs
     uint32_t pad1; /* Doubleword-align the user half of the frame */
 };
 
+#define hyp_mode(r)          psr_mode((r)->cpsr, PSR_MODE_HYP)
+#define regs_mode_is_user(r) usr_mode(r)
+
+#define regs_mode_is_32bit(regs) (true)
+
 #endif
 
 #endif /* __ASM_ARM_ARM32_PROCESSOR_H */
diff --git a/xen/arch/arm/include/asm/arm64/processor.h b/xen/arch/arm/include/asm/arm64/processor.h
index c749f80ad91b..daf890708d87 100644
--- a/xen/arch/arm/include/asm/arm64/processor.h
+++ b/xen/arch/arm/include/asm/arm64/processor.h
@@ -86,6 +86,21 @@ struct cpu_user_regs
 
 #undef __DECL_REG
 
+#define hyp_mode(r)                                                            \
+        (psr_mode((r)->cpsr, PSR_MODE_EL2h) ||                                 \
+         psr_mode((r)->cpsr, PSR_MODE_EL2t))
+
+/*
+ * Trap may have been taken from EL0, which might be in AArch32 usr
+ * mode, or in AArch64 mode (PSR_MODE_EL0t).
+ */
+#define regs_mode_is_user(r) (psr_mode((r)->cpsr, PSR_MODE_EL0t) || usr_mode(r))
+
+static inline bool regs_mode_is_32bit(const struct cpu_user_regs *regs)
+{
+    return !!(regs->cpsr & PSR_MODE_BIT);
+}
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_ARM_ARM64_PROCESSOR_H */
diff --git a/xen/arch/arm/include/asm/regs.h b/xen/arch/arm/include/asm/regs.h
index 0d9f239a7782..22d3a1688876 100644
--- a/xen/arch/arm/include/asm/regs.h
+++ b/xen/arch/arm/include/asm/regs.h
@@ -13,15 +13,6 @@
 
 #define psr_mode(psr,m) (((psr) & PSR_MODE_MASK) == (m))
 
-static inline bool regs_mode_is_32bit(const struct cpu_user_regs *regs)
-{
-#ifdef CONFIG_ARM_32
-    return true;
-#else
-    return !!(regs->cpsr & PSR_MODE_BIT);
-#endif
-}
-
 #define usr_mode(r)     psr_mode((r)->cpsr,PSR_MODE_USR)
 #define fiq_mode(r)     psr_mode((r)->cpsr,PSR_MODE_FIQ)
 #define irq_mode(r)     psr_mode((r)->cpsr,PSR_MODE_IRQ)
@@ -31,21 +22,6 @@ static inline bool regs_mode_is_32bit(const struct cpu_user_regs *regs)
 #define und_mode(r)     psr_mode((r)->cpsr,PSR_MODE_UND)
 #define sys_mode(r)     psr_mode((r)->cpsr,PSR_MODE_SYS)
 
-#ifdef CONFIG_ARM_32
-#define hyp_mode(r)     psr_mode((r)->cpsr,PSR_MODE_HYP)
-#define regs_mode_is_user(r) usr_mode(r)
-#else
-#define hyp_mode(r)     (psr_mode((r)->cpsr,PSR_MODE_EL2h) || \
-                         psr_mode((r)->cpsr,PSR_MODE_EL2t))
-
-/*
- * Trap may have been taken from EL0, which might be in AArch32 usr
- * mode, or in AArch64 mode (PSR_MODE_EL0t).
- */
-#define regs_mode_is_user(r) \
-    (psr_mode((r)->cpsr,PSR_MODE_EL0t) || usr_mode(r))
-#endif
-
 static inline bool guest_mode(const struct cpu_user_regs *r)
 {
     unsigned long diff = (uintptr_t)guest_cpu_user_regs() - (uintptr_t)(r);
-- 
2.34.1


  parent reply	other threads:[~2025-07-23  7:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23  7:58 [XEN][PATCH 0/8] xen/arm64: make aarch32 support optional Grygorii Strashko
2025-07-23  7:58 ` [XEN][PATCH 2/8] xen/arm: move vcpu_switch_to_aarch64_mode() in arch_vcpu_create() Grygorii Strashko
2025-07-23  9:16   ` Julien Grall
2025-07-23 10:19     ` Grygorii Strashko
2025-07-23 11:09       ` Julien Grall
2025-07-24 13:54         ` Grygorii Strashko
2025-07-23 11:12       ` Andrew Cooper
2025-07-23  7:58 ` [XEN][PATCH 1/8] xen/arm: split set_domain_type() between arm64/arm32 Grygorii Strashko
2025-07-23  7:58 ` [XEN][PATCH 4/8] xen/arm: split is_32bit/64bit_domain() " Grygorii Strashko
2025-07-23  8:32   ` Andrew Cooper
2025-07-23  7:58 ` [XEN][PATCH 3/8] xen/arm: move vcpu_switch_to_aarch64_mode() in arm64 Grygorii Strashko
2025-07-23  9:22   ` Julien Grall
2025-07-23 10:45     ` Grygorii Strashko
2025-07-23  7:58 ` [XEN][PATCH 5/8] xen/arm64: make aarch32 support optional Grygorii Strashko
2025-07-23  7:58 ` [XEN][PATCH 6/8] xen/arm64: constify is_32/64bit_domain() macro for CONFIG_ARM64_AARCH32=n Grygorii Strashko
2025-07-23  8:37   ` Andrew Cooper
2025-07-23  7:58 ` [XEN][PATCH 8/8] xen/arm64: constify regs_mode_is_32bit " Grygorii Strashko
2025-07-23  7:58 ` Grygorii Strashko [this message]
2025-07-23  8:06 ` [XEN][PATCH 0/8] xen/arm64: make aarch32 support optional Julien Grall
2025-07-23 10:54   ` Orzel, Michal
2025-07-23 11:48     ` Grygorii Strashko
2025-07-23 12:02       ` Julien Grall
2025-07-23 12:12         ` Grygorii Strashko
2025-07-24 14:24           ` Grygorii Strashko

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=20250723075835.3993182-8-grygorii_strashko@epam.com \
    --to=grygorii_strashko@epam.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=bertrand.marquis@arm.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.