By making it specific for access_cell_reg, it becomes obvious that there
are not other cases than r13 and r14.

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/arm/include/asm/traps.h | 14 --------------
 hypervisor/arch/arm/traps.c             | 20 ++++++++++++++------
 2 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/hypervisor/arch/arm/include/asm/traps.h 
b/hypervisor/arch/arm/include/asm/traps.h
index a6d103b..1a6f576 100644
--- a/hypervisor/arch/arm/include/asm/traps.h
+++ b/hypervisor/arch/arm/include/asm/traps.h
@@ -33,20 +33,6 @@ struct trap_context {
 
 typedef int (*trap_handler)(struct trap_context *ctx);
 
-#define access_banked_reg(mode, reg, val, is_read)                     \
-       do {                                                            \
-               switch (reg) {                                          \
-               case 13:                                                \
-                       arm_rw_banked_reg(SP_##mode, *val, is_read);    \
-                       break;                                          \
-               case 14:                                                \
-                       arm_rw_banked_reg(LR_##mode, *val, is_read);    \
-                       break;                                          \
-               default:                                                \
-                       printk("ERROR: access r%d in "#mode"\n", reg);  \
-               }                                                       \
-       } while (0)
-
 void access_cell_reg(struct trap_context *ctx, u8 reg, unsigned long *val,
                     bool is_read);
 void arch_skip_instruction(struct trap_context *ctx);
diff --git a/hypervisor/arch/arm/traps.c b/hypervisor/arch/arm/traps.c
index 47c7e15..d1dfc92 100644
--- a/hypervisor/arch/arm/traps.c
+++ b/hypervisor/arch/arm/traps.c
@@ -138,6 +138,14 @@ static inline void access_usr_reg(struct trap_context 
*ctx, u8 reg,
                ctx->regs[reg] = *val;
 }
 
+#define access_banked_r13_r14(mode, reg, val, is_read)                 \
+       do {                                                            \
+               if (reg == 13)                                          \
+                       arm_rw_banked_reg(SP_##mode, *val, is_read);    \
+               else                                                    \
+                       arm_rw_banked_reg(LR_##mode, *val, is_read);    \
+       } while (0)
+
 void access_cell_reg(struct trap_context *ctx, u8 reg, unsigned long *val,
                     bool is_read)
 {
@@ -179,24 +187,24 @@ void access_cell_reg(struct trap_context *ctx, u8 reg, 
unsigned long *val,
                         * regs.
                         */
                        if (reg == 13)
-                               access_banked_reg(usr, reg, val, is_read);
+                               access_banked_r13_r14(usr, reg, val, is_read);
                        else
                                access_usr_reg(ctx, 13, val, is_read);
                        break;
                case PSR_SVC_MODE:
-                       access_banked_reg(svc, reg, val, is_read);
+                       access_banked_r13_r14(svc, reg, val, is_read);
                        break;
                case PSR_UND_MODE:
-                       access_banked_reg(und, reg, val, is_read);
+                       access_banked_r13_r14(und, reg, val, is_read);
                        break;
                case PSR_ABT_MODE:
-                       access_banked_reg(abt, reg, val, is_read);
+                       access_banked_r13_r14(abt, reg, val, is_read);
                        break;
                case PSR_IRQ_MODE:
-                       access_banked_reg(irq, reg, val, is_read);
+                       access_banked_r13_r14(irq, reg, val, is_read);
                        break;
                case PSR_FIQ_MODE:
-                       access_banked_reg(fiq, reg, val, is_read);
+                       access_banked_r13_r14(fiq, reg, val, is_read);
                        break;
                }
                break;
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to