All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xen.org
Cc: bhupinder.thakur@linaro.org, Julien Grall <julien.grall@arm.com>,
	sstabellini@kernel.org, volodymyr_babchuk@epam.com
Subject: [PATCH v2 3/7] xen/arm: traps: Export a bunch of helpers to handle emulation
Date: Tue, 12 Sep 2017 11:36:18 +0100	[thread overview]
Message-ID: <20170912103622.18562-4-julien.grall@arm.com> (raw)
In-Reply-To: <20170912103622.18562-1-julien.grall@arm.com>

A follow-up patch will move some parts of traps.c in separate files.
The will require to use helpers that are currently statically defined.
Export the following helpers:
    - inject_undef64_exception
    - inject_undef_exception
    - check_conditional_instr
    - advance_pc
    - handle_raz_wi
    - handle_wo_wi
    - handle_ro_raz

Note that asm-arm/arm32/traps.h is empty but it is to keep parity with
the arm64 counterpart.

Signed-off-by: Julien Grall <julien.grall@arm.com>

---

Cc: volodymyr_babchuk@epam.com

    Changes in v2:
        - Fixup guards
        - Add newline for clarity
---
 xen/arch/arm/traps.c              | 43 +++++++++++++++++++--------------------
 xen/include/asm-arm/arm32/traps.h | 13 ++++++++++++
 xen/include/asm-arm/arm64/traps.h | 15 ++++++++++++++
 xen/include/asm-arm/traps.h       | 36 ++++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+), 22 deletions(-)
 create mode 100644 xen/include/asm-arm/arm32/traps.h
 create mode 100644 xen/include/asm-arm/arm64/traps.h
 create mode 100644 xen/include/asm-arm/traps.h

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 6f32f700e5..1c334a7b99 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -49,6 +49,7 @@
 #include <asm/monitor.h>
 #include <asm/psci.h>
 #include <asm/regs.h>
+#include <asm/traps.h>
 #include <asm/vgic.h>
 #include <asm/vtimer.h>
 
@@ -547,7 +548,7 @@ static vaddr_t exception_handler64(struct cpu_user_regs *regs, vaddr_t offset)
 }
 
 /* Inject an undefined exception into a 64 bit guest */
-static void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len)
+void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len)
 {
     vaddr_t handler;
     const union hsr esr = {
@@ -620,8 +621,7 @@ static void inject_iabt64_exception(struct cpu_user_regs *regs,
 
 #endif
 
-static void inject_undef_exception(struct cpu_user_regs *regs,
-                                   const union hsr hsr)
+void inject_undef_exception(struct cpu_user_regs *regs, const union hsr hsr)
 {
         if ( is_32bit_domain(current->domain) )
             inject_undef32_exception(regs);
@@ -1714,8 +1714,7 @@ static const unsigned short cc_map[16] = {
         0                       /* NV                     */
 };
 
-static int check_conditional_instr(struct cpu_user_regs *regs,
-                                   const union hsr hsr)
+int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr)
 {
     unsigned long cpsr, cpsr_cond;
     int cond;
@@ -1777,7 +1776,7 @@ static int check_conditional_instr(struct cpu_user_regs *regs,
     return 1;
 }
 
-static void advance_pc(struct cpu_user_regs *regs, const union hsr hsr)
+void advance_pc(struct cpu_user_regs *regs, const union hsr hsr)
 {
     unsigned long itbits, cond, cpsr = regs->cpsr;
 
@@ -1818,11 +1817,11 @@ static void advance_pc(struct cpu_user_regs *regs, const union hsr hsr)
 }
 
 /* Read as zero and write ignore */
-static void handle_raz_wi(struct cpu_user_regs *regs,
-                          int regidx,
-                          bool read,
-                          const union hsr hsr,
-                          int min_el)
+void handle_raz_wi(struct cpu_user_regs *regs,
+                   int regidx,
+                   bool read,
+                   const union hsr hsr,
+                   int min_el)
 {
     ASSERT((min_el == 0) || (min_el == 1));
 
@@ -1836,12 +1835,12 @@ static void handle_raz_wi(struct cpu_user_regs *regs,
     advance_pc(regs, hsr);
 }
 
-/* Write only as write ignore */
-static void handle_wo_wi(struct cpu_user_regs *regs,
-                         int regidx,
-                         bool read,
-                         const union hsr hsr,
-                         int min_el)
+/* write only as write ignore */
+void handle_wo_wi(struct cpu_user_regs *regs,
+                  int regidx,
+                  bool read,
+                  const union hsr hsr,
+                  int min_el)
 {
     ASSERT((min_el == 0) || (min_el == 1));
 
@@ -1856,11 +1855,11 @@ static void handle_wo_wi(struct cpu_user_regs *regs,
 }
 
 /* Read only as read as zero */
-static void handle_ro_raz(struct cpu_user_regs *regs,
-                          int regidx,
-                          bool read,
-                          const union hsr hsr,
-                          int min_el)
+void handle_ro_raz(struct cpu_user_regs *regs,
+                   int regidx,
+                   bool read,
+                   const union hsr hsr,
+                   int min_el)
 {
     ASSERT((min_el == 0) || (min_el == 1));
 
diff --git a/xen/include/asm-arm/arm32/traps.h b/xen/include/asm-arm/arm32/traps.h
new file mode 100644
index 0000000000..e3c4a8b473
--- /dev/null
+++ b/xen/include/asm-arm/arm32/traps.h
@@ -0,0 +1,13 @@
+#ifndef __ASM_ARM32_TRAPS__
+#define __ASM_ARM32_TRAPS__
+
+#endif /* __ASM_ARM32_TRAPS__ */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+
diff --git a/xen/include/asm-arm/arm64/traps.h b/xen/include/asm-arm/arm64/traps.h
new file mode 100644
index 0000000000..e5e5a4a036
--- /dev/null
+++ b/xen/include/asm-arm/arm64/traps.h
@@ -0,0 +1,15 @@
+#ifndef __ASM_ARM64_TRAPS__
+#define __ASM_ARM64_TRAPS__
+
+void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len);
+
+#endif /* __ASM_ARM64_TRAPS__ */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+
diff --git a/xen/include/asm-arm/traps.h b/xen/include/asm-arm/traps.h
new file mode 100644
index 0000000000..6d99d228e8
--- /dev/null
+++ b/xen/include/asm-arm/traps.h
@@ -0,0 +1,36 @@
+#ifndef __ASM_ARM_TRAPS__
+#define __ASM_ARM_TRAPS__
+
+#include <asm/processor.h>
+
+#if defined(CONFIG_ARM_32)
+# include <asm/arm32/traps.h>
+#elif defined(CONFIG_ARM_64)
+# include <asm/arm64/traps.h>
+#endif
+
+int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr);
+
+void advance_pc(struct cpu_user_regs *regs, const union hsr hsr);
+
+void inject_undef_exception(struct cpu_user_regs *regs, const union hsr hsr);
+
+void handle_raz_wi(struct cpu_user_regs *regs, int regidx, bool read,
+                   const union hsr hsr, int min_el);
+
+void handle_wo_wi(struct cpu_user_regs *regs, int regidx, bool read,
+                  const union hsr hsr, int min_el);
+
+void handle_ro_raz(struct cpu_user_regs *regs, int regidx, bool read,
+                   const union hsr hsr, int min_el);
+
+#endif /* __ASM_ARM_TRAPS__ */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+
-- 
2.11.0


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

  parent reply	other threads:[~2017-09-12 10:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-12 10:36 [PATCH v2 0/7] xen/arm: Clean-up traps.c Julien Grall
2017-09-12 10:36 ` [PATCH v2 1/7] xen/arm: traps: Re-order the includes alphabetically Julien Grall
2017-09-12 20:59   ` Stefano Stabellini
2017-09-12 10:36 ` [PATCH v2 2/7] xen/arm: Move arch/arm/vtimer.h to include/asm-arm/vtimer.h Julien Grall
2017-09-12 21:02   ` Stefano Stabellini
2017-09-12 10:36 ` Julien Grall [this message]
2017-09-12 21:26   ` [PATCH v2 3/7] xen/arm: traps: Export a bunch of helpers to handle emulation Stefano Stabellini
2017-09-13  8:52     ` Julien Grall
2017-09-12 10:36 ` [PATCH v2 4/7] xen/arm: Move sysreg emulation outside of traps.c Julien Grall
2017-09-12 21:40   ` Stefano Stabellini
2017-09-12 10:36 ` [PATCH v2 5/7] xen/arm: Move co-processor " Julien Grall
2017-09-12 21:43   ` Stefano Stabellini
2017-09-12 10:36 ` [PATCH v2 6/7] xen/arm: Move sysregs.h in arm64 sub-directory Julien Grall
2017-09-12 21:49   ` Stefano Stabellini
2017-09-12 10:36 ` [PATCH v2 7/7] xen/arm: Limit the scope of cpregs.h Julien Grall
2017-09-12 21:53   ` Stefano Stabellini
2017-09-13  9:11     ` Julien Grall
2017-09-13 21:13       ` Stefano Stabellini
2017-09-14 16:58         ` Julien Grall
2017-09-12 21:57 ` [PATCH v2 0/7] xen/arm: Clean-up traps.c 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=20170912103622.18562-4-julien.grall@arm.com \
    --to=julien.grall@arm.com \
    --cc=bhupinder.thakur@linaro.org \
    --cc=sstabellini@kernel.org \
    --cc=volodymyr_babchuk@epam.com \
    --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 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.