For an arm64 CPU, when an exception is taken, the PC of the
CPU is copied in the ELR_ELx. This is useful for debugging which
code path caused the exception.

Modify fill_trap_context to populate ELR_EL2 and dump it as part
of the dump_regs

Signed-off-by: Nikhil Devshatwar <nikhil...@ti.com>
---
 hypervisor/arch/arm64/include/asm/traps.h | 1 +
 hypervisor/arch/arm64/traps.c             | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hypervisor/arch/arm64/include/asm/traps.h 
b/hypervisor/arch/arm64/include/asm/traps.h
index 59cb137c..a7c07624 100644
--- a/hypervisor/arch/arm64/include/asm/traps.h
+++ b/hypervisor/arch/arm64/include/asm/traps.h
@@ -17,6 +17,7 @@
 
 struct trap_context {
        unsigned long *regs;
+       u64 elr;
        u64 esr;
        u64 spsr;
        u64 sp;
diff --git a/hypervisor/arch/arm64/traps.c b/hypervisor/arch/arm64/traps.c
index 26a58f4d..a9086c79 100644
--- a/hypervisor/arch/arm64/traps.c
+++ b/hypervisor/arch/arm64/traps.c
@@ -88,9 +88,9 @@ static void dump_regs(struct trap_context *ctx)
 
        arm_read_sysreg(ELR_EL2, pc);
        panic_printk(" pc: %016llx   lr: %016lx spsr: %08llx     EL%lld\n"
-                    " sp: %016llx  esr: %02llx %01llx %07llx\n",
+                    " sp: %016llx  elr: %016llx  esr: %02llx %01llx %07llx\n",
                     pc, ctx->regs[30], ctx->spsr, SPSR_EL(ctx->spsr),
-                    ctx->sp, ESR_EC(ctx->esr), ESR_IL(ctx->esr),
+                    ctx->sp, ctx->elr, ESR_EC(ctx->esr), ESR_IL(ctx->esr),
                     ESR_ISS(ctx->esr));
        for (i = 0; i < NUM_USR_REGS - 1; i++)
                panic_printk("%sx%d: %016lx%s", i < 10 ? " " : "", i,
@@ -147,6 +147,7 @@ static void fill_trap_context(struct trap_context *ctx, 
union registers *regs)
                ctx->sp = 0; break;     /* should never happen */
        }
        arm_read_sysreg(ESR_EL2, ctx->esr);
+       arm_read_sysreg(ELR_EL2, ctx->elr);
        ctx->regs = regs->usr;
 }
 
-- 
2.17.1

-- 
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 jailhouse-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/20201103061334.21256-1-nikhil.nd%40ti.com.

Reply via email to