hv:Merge dump_interrupt and dump_exception to a commond API

merge these two APIs to 'dump_intr_excp_frame'

Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Mingqiang Chi 2018-05-21 18:02:51 +08:00 committed by lijinxia
parent d88b968305
commit 7c9cc6bcd4
3 changed files with 20 additions and 42 deletions

View File

@ -434,6 +434,7 @@ void dispatch_exception(struct intr_excp_ctx *ctx)
/* Obtain lock to ensure exception dump doesn't get corrupted */
spinlock_obtain(&exception_spinlock);
/* Dump exception context */
dump_exception(ctx, cpu_id);
/* Release lock to let other CPUs handle exception */

View File

@ -235,7 +235,7 @@ static void show_host_call_trace(uint64_t rsp, uint64_t rbp, uint32_t cpu_id)
int cb_hierarchy = 0;
uint64_t *sp = (uint64_t *)rsp;
printf("\r\nHost Stack: \r\n");
printf("\r\nHost Stack: CPU_ID = %d\r\n", cpu_id);
for (i = 0; i < DUMP_STACK_SIZE/32; i++) {
printf("addr(0x%llx) 0x%016llx 0x%016llx 0x%016llx "
"0x%016llx\r\n", (rsp+i*32), sp[i*4], sp[i*4+1],
@ -293,17 +293,16 @@ void __assert(uint32_t line, const char *file, char *txt)
} while (1);
}
void dump_exception(struct intr_excp_ctx *ctx, uint32_t cpu_id)
void dump_intr_excp_frame(struct intr_excp_ctx *ctx)
{
const char *name = "Not defined";
if (ctx->vector < 0x20)
name = excp_names[ctx->vector];
printf("\n\n================================================");
printf("================================\n=\n");
printf("= Unhandled exception: %d (%s)\n", ctx->vector, name);
printf("= CPU ID = %d", cpu_id);
if (ctx->vector < 0x20) {
name = excp_names[ctx->vector];
printf("= Unhandled exception: %d (%s)\n", ctx->vector, name);
}
/* Dump host register*/
printf("\r\nHost Registers:\r\n");
@ -325,39 +324,17 @@ void dump_exception(struct intr_excp_ctx *ctx, uint32_t cpu_id)
ctx->error_code, ctx->cs, ctx->ss);
printf("\r\n");
/* Dump host stack */
show_host_call_trace(ctx->rsp, ctx->rbp, cpu_id);
/* Dump guest context */
dump_guest_context(cpu_id);
printf("= System halted\n");
printf("=====================================================");
printf("===========================\n");
}
void dump_interrupt(struct intr_excp_ctx *ctx)
void dump_exception(struct intr_excp_ctx *ctx, uint32_t cpu_id)
{
printf("\n\n==========================================");
printf("======================================\n=\n");
printf("\n=\n");
printf("= Vector=0x%016llX RIP=0x%016llX\n",
ctx->vector, ctx->rip);
printf("= RAX=0x%016llX RBX=0x%016llX RCX=0x%016llX\n",
ctx->rax, ctx->rbx, ctx->rcx);
printf("= RDX=0x%016llX RDI=0x%016llX RSI=0x%016llX\n",
ctx->rdx, ctx->rdi, ctx->rsi);
printf("= RSP=0x%016llX RBP=0x%016llX RBX=0x%016llX\n",
ctx->rsp, ctx->rbp, ctx->rbx);
printf("= R8=0x%016llX R9=0x%016llX R10=0x%016llX\n",
ctx->r8, ctx->r9, ctx->r10);
printf("= R11=0x%016llX R12=0x%016llX R13=0x%016llX\n",
ctx->r11, ctx->r12, ctx->r13);
printf("= RFLAGS=0x%016llX R14=0x%016llX R15=0x%016llX\n",
ctx->rflags, ctx->r14, ctx->r15);
printf("= ERRCODE=0x%016llX CS=0x%016llX SS=0x%016llX\n",
ctx->error_code, ctx->cs, ctx->ss);
printf("=\n");
printf("= system halted\n");
printf("===============================================");
printf("=================================\n");
/* Dump host context */
dump_intr_excp_frame(ctx);
/* Show host stack */
show_host_call_trace(ctx->rsp, ctx->rbp, cpu_id);
/* Dump guest context */
dump_guest_context(cpu_id);
}

View File

@ -37,19 +37,19 @@ struct intr_excp_ctx;
#define CALL_TRACE_HIERARCHY_MAX 20
#define DUMP_STACK_SIZE 0x200
void dump_intr_excp_frame(struct intr_excp_ctx *ctx);
void dump_exception(struct intr_excp_ctx *ctx, uint32_t cpu_id);
void dump_interrupt(struct intr_excp_ctx *ctx);
#else
static inline void dump_intr_excp_frame(__unused struct intr_excp_ctx *ctx)
{
}
static inline void dump_exception(__unused struct intr_excp_ctx *ctx,
__unused uint32_t cpu_id)
__unused uint32_t cpu_id)
{
}
static inline void dump_interrupt(__unused struct intr_excp_ctx *ctx)
{
}
#endif
#endif /* DUMP_H */