Skip to contentSkip to conversation

xen/arm: Clean-up traps.c

PATCH In review Julien Grall 2 participants 8 messages Sep 14, 2017

lore
Share & tools
lore
#0 lore raw

v3 cover xen/arm: Clean-up traps.c

Hi all,

xen/arch/arm/traps.c is beginning to get very big. This series is moving out the co-processor and sysreg emulation in separate files. This will avoid to grow traps.c when adding more registers emulation (coming soon).

A branch with this series has been pushed:

https://xenbits.xen.org/git-http/people/julieng/xen-unstable.git
branch cleanup-traps-v3

Cheers,

Julien Grall (5):
xen/arm: traps: Export a bunch of helpers to handle emulation xen/arm: Move sysreg emulation outside of traps.c xen/arm: Move co-processor emulation outside of traps.c xen/arm: Move sysregs.h in arm64 sub-directory xen/arm: Limit the scope of cpregs.h

 xen/arch/arm/Makefile                     |   1 +
 xen/arch/arm/arm64/Makefile               |   1 +
 xen/arch/arm/arm64/vsysreg.c              | 229 +++++++++++
 xen/arch/arm/smp.c                        |   1 -
 xen/arch/arm/traps.c                      | 662 +-----------------------------
 xen/arch/arm/vcpreg.c                     | 452 ++++++++++++++++++++
 xen/arch/arm/vgic-v3.c                    |   1 +
 xen/arch/arm/vtimer.c                     |   2 +
 xen/include/asm-arm/arm32/processor.h     |   2 +
 xen/include/asm-arm/arm32/traps.h         |  13 +
 xen/include/asm-arm/arm64/processor.h     |   2 +
 xen/include/asm-arm/{ => arm64}/sysregs.h |  10 +-
 xen/include/asm-arm/arm64/traps.h         |  18 +
 xen/include/asm-arm/percpu.h              |   1 -
 xen/include/asm-arm/processor.h           |   2 -
 xen/include/asm-arm/traps.h               |  47 +++
 16 files changed, 792 insertions(+), 652 deletions(-)
 create mode 100644 xen/arch/arm/arm64/vsysreg.c
 create mode 100644 xen/arch/arm/vcpreg.c
 create mode 100644 xen/include/asm-arm/arm32/traps.h
 rename xen/include/asm-arm/{ => arm64}/sysregs.h (98%)
 create mode 100644 xen/include/asm-arm/arm64/traps.h
 create mode 100644 xen/include/asm-arm/traps.h
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH v3 1/5 xen/arm: traps: Export a bunch of helpers to handle emulation

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.

---

Changes in v3:
- Replicate comment on top of each prototypes when useful

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       | 39 +++++++++++++++++++++++++++++++++++
 4 files changed, 88 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
xen/arch/arm/traps.c +21 -22
index 6f32f700e5..1c334a7b99 100644
@@ -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));
 
xen/include/asm-arm/arm32/traps.h new file +13 -0
new file mode 100644
index 0000000000..e3c4a8b473
@@ -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:
+ */
+
xen/include/asm-arm/arm64/traps.h new file +15 -0
new file mode 100644
index 0000000000..e5e5a4a036
@@ -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:
+ */
+
xen/include/asm-arm/traps.h new file +39 -0
new file mode 100644
index 0000000000..22ad070679
@@ -0,0 +1,39 @@
+#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);
+
+/* read as zero and write ignore */
+void handle_raz_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);
+
+/* read only as read as zero */
+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:
+ */
+
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v3 1/5
#2 lore raw

Re: [PATCH v3 1/5] xen/arm: traps: Export a bunch of helpers to handle emulation

Quoted 11 lines · Julien Grall

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

Quoted 4 lines

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

Quoted 211 lines

---

Changes in v3:
- Replicate comment on top of each prototypes when useful

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       | 39 +++++++++++++++++++++++++++++++++++
 4 files changed, 88 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
xen/arch/arm/traps.c +21 -22
index 6f32f700e5..1c334a7b99 100644
@@ -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));
 
xen/include/asm-arm/arm32/traps.h new file +13 -0
new file mode 100644
index 0000000000..e3c4a8b473
@@ -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:
+ */
+
xen/include/asm-arm/arm64/traps.h new file +15 -0
new file mode 100644
index 0000000000..e5e5a4a036
@@ -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:
+ */
+
xen/include/asm-arm/traps.h new file +39 -0
new file mode 100644
index 0000000000..22ad070679
@@ -0,0 +1,39 @@
+#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);
+
+/* read as zero and write ignore */
+void handle_raz_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);
+
+/* read only as read as zero */
+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:
+ */
+
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw

PATCH v3 2/5 xen/arm: Move sysreg emulation outside of traps.c

In reply to Julien Grall

The sysreg emulation is 64-bit specific and surrounded by #ifdef. Move them in a separate file arm/arm64/vsysreg.c to shrink down a bit traps.c

No functional change.

---

Changes in v3:
- Add Stefano's reviewed-by

---
 xen/arch/arm/arm64/Makefile       |   1 +
 xen/arch/arm/arm64/vsysreg.c      | 229 ++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/traps.c              | 198 --------------------------------
 xen/include/asm-arm/arm64/traps.h |   3 +
 4 files changed, 233 insertions(+), 198 deletions(-)
 create mode 100644 xen/arch/arm/arm64/vsysreg.c
xen/arch/arm/arm64/Makefile +1 -0
index 149b6b3901..718fe44455 100644
@@ -10,3 +10,4 @@ obj-$(CONFIG_LIVEPATCH) += livepatch.o
 obj-y += smpboot.o
 obj-y += traps.o
 obj-y += vfp.o
+obj-y += vsysreg.o
xen/arch/arm/arm64/vsysreg.c new file +229 -0

229 lines not on this page · raw message

xen/arch/arm/traps.c +0 -198

204 lines not on this page · raw message

xen/include/asm-arm/arm64/traps.h +3 -0
index e5e5a4a036..2379b578cb 100644
@@ -3,6 +3,9 @@
 
 void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len);
 
+void do_sysreg(struct cpu_user_regs *regs,
+               const union hsr hsr);
+
 #endif /* __ASM_ARM64_TRAPS__ */
 /*
  * Local variables:
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#4 lore raw

PATCH v3 3/5 xen/arm: Move co-processor emulation outside of traps.c

In reply to Julien Grall

The co-processor emulation is quite big and pretty much standalone. Move it in a separate file to shrink down the size of traps.c.

At the same time remove unused cpregs.h.

No functional change.

---

Changes in v3:
- Add Stefano's reviewed-by

---
 xen/arch/arm/Makefile       |   1 +
 xen/arch/arm/traps.c        | 421 -----------------------------------------
 xen/arch/arm/vcpreg.c       | 451 ++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/traps.h |   8 +
 4 files changed, 460 insertions(+), 421 deletions(-)
 create mode 100644 xen/arch/arm/vcpreg.c
xen/arch/arm/Makefile +1 -0
index 282d2c2949..17bff98033 100644
@@ -45,6 +45,7 @@ obj-y += smpboot.o
 obj-y += sysctl.o
 obj-y += time.o
 obj-y += traps.o
+obj-y += vcpreg.o
 obj-y += vgic.o
 obj-y += vgic-v2.o
 obj-$(CONFIG_HAS_GICV3) += vgic-v3.o
xen/arch/arm/traps.c +0 -421

433 lines not on this page · raw message

xen/arch/arm/vcpreg.c new file +451 -0

451 lines not on this page · raw message

xen/include/asm-arm/traps.h +8 -0
index 22ad070679..7508af80c7 100644
@@ -27,6 +27,14 @@ void handle_wo_wi(struct cpu_user_regs *regs, int regidx, bool read,
 void handle_ro_raz(struct cpu_user_regs *regs, int regidx, bool read,
                    const union hsr hsr, int min_el);
 
+/* Co-processor registers emulation (see arch/arm/vcpreg.c). */
+void do_cp15_32(struct cpu_user_regs *regs, const union hsr hsr);
+void do_cp15_64(struct cpu_user_regs *regs, const union hsr hsr);
+void do_cp14_32(struct cpu_user_regs *regs, const union hsr hsr);
+void do_cp14_64(struct cpu_user_regs *regs, const union hsr hsr);
+void do_cp14_dbg(struct cpu_user_regs *regs, const union hsr hsr);
+void do_cp(struct cpu_user_regs *regs, const union hsr hsr);
+
 #endif /* __ASM_ARM_TRAPS__ */
 /*
  * Local variables:
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#5 lore raw

PATCH v3 4/5 xen/arm: Move sysregs.h in arm64 sub-directory

In reply to Julien Grall

sysregs.h contains only code protected by #ifdef CONFIG_ARM_64. Move it in arm64 sub-directory to reflect that and remove the #ifdef.

At the same time, fixup the guards.

---

Changes in v3:
- Add Stefano's reviewed-by

---
 xen/include/asm-arm/arm64/processor.h     |  2 ++
 xen/include/asm-arm/{ => arm64}/sysregs.h | 10 +++-------
 xen/include/asm-arm/processor.h           |  1 -
 3 files changed, 5 insertions(+), 8 deletions(-)
 rename xen/include/asm-arm/{ => arm64}/sysregs.h (98%)
xen/include/asm-arm/arm64/processor.h +2 -0
index 24f836b023..c18ab7203d 100644
@@ -3,6 +3,8 @@
 
 #include <xen/stringify.h>
 
+#include <asm/arm64/sysregs.h>
+
 #ifndef __ASSEMBLY__
 
 /* Anonymous union includes both 32- and 64-bit names (e.g., r0/x0). */
xen/include/asm-arm/arm64/sysregs.h renamed from xen/include/asm-arm/sysregs.h +3 -7
similarity index 98%
rename from xen/include/asm-arm/sysregs.h
rename to xen/include/asm-arm/arm64/sysregs.h
index 887368e248..084d2a1e5d 100644
@@ -1,7 +1,5 @@
-#ifndef __ASM_ARM_SYSREGS_H
-#define __ASM_ARM_SYSREGS_H
-
-#ifdef CONFIG_ARM_64
+#ifndef __ASM_ARM_ARM64_SYSREGS_H
+#define __ASM_ARM_ARM64_SYSREGS_H
 
 #include <xen/stringify.h>
 
@@ -168,9 +166,7 @@
 #define ICH_AP1R2_EL2             __AP1Rx_EL2(2)
 #define ICH_AP1R3_EL2             __AP1Rx_EL2(3)
 
-#endif
-
-#endif
+#endif /* _ASM_ARM_ARM64_SYSREGS_H */
 
 /*
  * Local variables:
xen/include/asm-arm/processor.h +0 -1
index 9f7a42f86b..d791c12c9c 100644
@@ -2,7 +2,6 @@
 #define __ASM_ARM_PROCESSOR_H
 
 #include <asm/cpregs.h>
-#include <asm/sysregs.h>
 #ifndef __ASSEMBLY__
 #include <xen/types.h>
 #endif
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#6 lore raw

PATCH v3 5/5 xen/arm: Limit the scope of cpregs.h

In reply to Julien Grall

Currently, cpregs.h is indirectly included every files of the hypervisor even for arm64. However, the only use for arm64 is when emulating co-processors.

For arm32, all users of processor.h expect cpregs.h to be included in order to access co-processors. So move the inclusion in asm-arm/arm32/processor.h.

cpregs.h will also be directly included in the co-processors emulation to accommodate arm64.

This is drastically reducing the exposure of cpregs.h to any source file on arm64.

---
Changes in v3:
- Expand the rationale about this patch
- Add Stefano's acked-by

Changes in v2:
- Update commit message

---
 xen/arch/arm/smp.c                    | 1 -
 xen/arch/arm/vcpreg.c                 | 1 +
 xen/arch/arm/vgic-v3.c                | 1 +
 xen/arch/arm/vtimer.c                 | 2 ++
 xen/include/asm-arm/arm32/processor.h | 2 ++
 xen/include/asm-arm/percpu.h          | 1 -
 xen/include/asm-arm/processor.h       | 1 -
 7 files changed, 6 insertions(+), 3 deletions(-)
xen/arch/arm/smp.c +0 -1
index e7df0874d6..554f4992e6 100644
@@ -1,6 +1,5 @@
 #include <asm/system.h>
 #include <asm/smp.h>
-#include <asm/cpregs.h>
 #include <asm/page.h>
 #include <asm/gic.h>
 #include <asm/flushtlb.h>
xen/arch/arm/vcpreg.c +1 -0
index f3b08403fb..e363183ba8 100644
@@ -18,6 +18,7 @@
 
 #include <xen/sched.h>
 
+#include <asm/cpregs.h>
 #include <asm/current.h>
 #include <asm/regs.h>
 #include <asm/traps.h>
xen/arch/arm/vgic-v3.c +1 -0
index cbeac28b28..a0cf993d13 100644
@@ -26,6 +26,7 @@
 #include <xen/softirq.h>
 #include <xen/sizes.h>
 
+#include <asm/cpregs.h>
 #include <asm/current.h>
 #include <asm/gic_v3_defs.h>
 #include <asm/gic_v3_its.h>
xen/arch/arm/vtimer.c +2 -0
index 9c7e8f441c..0460962f08 100644
@@ -22,6 +22,7 @@
 #include <xen/sched.h>
 #include <xen/timer.h>
 
+#include <asm/cpregs.h>
 #include <asm/div64.h>
 #include <asm/gic.h>
 #include <asm/irq.h>
@@ -29,6 +30,7 @@
 #include <asm/time.h>
 #include <asm/vgic.h>
 #include <asm/vreg.h>
+#include <asm/regs.h>
 
 /*
  * Check if regs is allowed access, user_gate is tail end of a
xen/include/asm-arm/arm32/processor.h +2 -0
index 68cc82147e..fb330812af 100644
@@ -1,6 +1,8 @@
 #ifndef __ASM_ARM_ARM32_PROCESSOR_H
 #define __ASM_ARM_ARM32_PROCESSOR_H
 
+#include <asm/cpregs.h>
+
 #define ACTLR_CAXX_SMP      (1<<6)
 
 #ifndef __ASSEMBLY__
xen/include/asm-arm/percpu.h +0 -1
index 7968532462..cdf64e0f77 100644
@@ -4,7 +4,6 @@
 #ifndef __ASSEMBLY__
 
 #include <xen/types.h>
-#include <asm/cpregs.h>
 #if defined(CONFIG_ARM_32)
 # include <asm/arm32/processor.h>
 #elif defined(CONFIG_ARM_64)
xen/include/asm-arm/processor.h +0 -1
index d791c12c9c..cd45e5f48f 100644
@@ -1,7 +1,6 @@
 #ifndef __ASM_ARM_PROCESSOR_H
 #define __ASM_ARM_PROCESSOR_H
 
-#include <asm/cpregs.h>
 #ifndef __ASSEMBLY__
 #include <xen/types.h>
 #endif
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#7 lore raw
In reply to Julien Grall
Quoted 10 lines · Julien Grall

Hi all,

xen/arch/arm/traps.c is beginning to get very big. This series is moving out the co-processor and sysreg emulation in separate files. This will avoid to grow traps.c when adding more registers emulation (coming soon).

A branch with this series has been pushed:

https://xenbits.xen.org/git-http/people/julieng/xen-unstable.git
branch cleanup-traps-v3

committed

Quoted 26 lines

Cheers,

Julien Grall (5):
xen/arm: traps: Export a bunch of helpers to handle emulation xen/arm: Move sysreg emulation outside of traps.c xen/arm: Move co-processor emulation outside of traps.c xen/arm: Move sysregs.h in arm64 sub-directory xen/arm: Limit the scope of cpregs.h

 xen/arch/arm/Makefile                     |   1 +
 xen/arch/arm/arm64/Makefile               |   1 +
 xen/arch/arm/arm64/vsysreg.c              | 229 +++++++++++
 xen/arch/arm/smp.c                        |   1 -
 xen/arch/arm/traps.c                      | 662 +-----------------------------
 xen/arch/arm/vcpreg.c                     | 452 ++++++++++++++++++++
 xen/arch/arm/vgic-v3.c                    |   1 +
 xen/arch/arm/vtimer.c                     |   2 +
 xen/include/asm-arm/arm32/processor.h     |   2 +
 xen/include/asm-arm/arm32/traps.h         |  13 +
 xen/include/asm-arm/arm64/processor.h     |   2 +
 xen/include/asm-arm/{ => arm64}/sysregs.h |  10 +-
 xen/include/asm-arm/arm64/traps.h         |  18 +
 xen/include/asm-arm/percpu.h              |   1 -
 xen/include/asm-arm/processor.h           |   2 -
Quoted 12 lines
 xen/include/asm-arm/traps.h               |  47 +++
 16 files changed, 792 insertions(+), 652 deletions(-)
 create mode 100644 xen/arch/arm/arm64/vsysreg.c
 create mode 100644 xen/arch/arm/vcpreg.c
 create mode 100644 xen/include/asm-arm/arm32/traps.h
 rename xen/include/asm-arm/{ => arm64}/sysregs.h (98%)
 create mode 100644 xen/include/asm-arm/arm64/traps.h
 create mode 100644 xen/include/asm-arm/traps.h
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel