Skip to content

Commit 7c9cc6b

Browse files
mingqiangchilijinxia
authored andcommitted
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>
1 parent d88b968 commit 7c9cc6b

File tree

3 files changed

+20
-42
lines changed

3 files changed

+20
-42
lines changed

hypervisor/arch/x86/irq.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ void dispatch_exception(struct intr_excp_ctx *ctx)
434434
/* Obtain lock to ensure exception dump doesn't get corrupted */
435435
spinlock_obtain(&exception_spinlock);
436436

437+
/* Dump exception context */
437438
dump_exception(ctx, cpu_id);
438439

439440
/* Release lock to let other CPUs handle exception */

hypervisor/debug/dump.c

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static void show_host_call_trace(uint64_t rsp, uint64_t rbp, uint32_t cpu_id)
235235
int cb_hierarchy = 0;
236236
uint64_t *sp = (uint64_t *)rsp;
237237

238-
printf("\r\nHost Stack: \r\n");
238+
printf("\r\nHost Stack: CPU_ID = %d\r\n", cpu_id);
239239
for (i = 0; i < DUMP_STACK_SIZE/32; i++) {
240240
printf("addr(0x%llx) 0x%016llx 0x%016llx 0x%016llx "
241241
"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)
293293
} while (1);
294294
}
295295

296-
void dump_exception(struct intr_excp_ctx *ctx, uint32_t cpu_id)
296+
void dump_intr_excp_frame(struct intr_excp_ctx *ctx)
297297
{
298298
const char *name = "Not defined";
299299

300-
if (ctx->vector < 0x20)
301-
name = excp_names[ctx->vector];
302-
303300
printf("\n\n================================================");
304301
printf("================================\n=\n");
305-
printf("= Unhandled exception: %d (%s)\n", ctx->vector, name);
306-
printf("= CPU ID = %d", cpu_id);
302+
if (ctx->vector < 0x20) {
303+
name = excp_names[ctx->vector];
304+
printf("= Unhandled exception: %d (%s)\n", ctx->vector, name);
305+
}
307306

308307
/* Dump host register*/
309308
printf("\r\nHost Registers:\r\n");
@@ -325,39 +324,17 @@ void dump_exception(struct intr_excp_ctx *ctx, uint32_t cpu_id)
325324
ctx->error_code, ctx->cs, ctx->ss);
326325
printf("\r\n");
327326

328-
/* Dump host stack */
329-
show_host_call_trace(ctx->rsp, ctx->rbp, cpu_id);
330-
331-
/* Dump guest context */
332-
dump_guest_context(cpu_id);
333-
printf("= System halted\n");
334327
printf("=====================================================");
335328
printf("===========================\n");
336329
}
337330

338-
void dump_interrupt(struct intr_excp_ctx *ctx)
331+
void dump_exception(struct intr_excp_ctx *ctx, uint32_t cpu_id)
339332
{
340-
printf("\n\n==========================================");
341-
printf("======================================\n=\n");
342-
printf("\n=\n");
343-
printf("= Vector=0x%016llX RIP=0x%016llX\n",
344-
ctx->vector, ctx->rip);
345-
printf("= RAX=0x%016llX RBX=0x%016llX RCX=0x%016llX\n",
346-
ctx->rax, ctx->rbx, ctx->rcx);
347-
printf("= RDX=0x%016llX RDI=0x%016llX RSI=0x%016llX\n",
348-
ctx->rdx, ctx->rdi, ctx->rsi);
349-
printf("= RSP=0x%016llX RBP=0x%016llX RBX=0x%016llX\n",
350-
ctx->rsp, ctx->rbp, ctx->rbx);
351-
printf("= R8=0x%016llX R9=0x%016llX R10=0x%016llX\n",
352-
ctx->r8, ctx->r9, ctx->r10);
353-
printf("= R11=0x%016llX R12=0x%016llX R13=0x%016llX\n",
354-
ctx->r11, ctx->r12, ctx->r13);
355-
printf("= RFLAGS=0x%016llX R14=0x%016llX R15=0x%016llX\n",
356-
ctx->rflags, ctx->r14, ctx->r15);
357-
printf("= ERRCODE=0x%016llX CS=0x%016llX SS=0x%016llX\n",
358-
ctx->error_code, ctx->cs, ctx->ss);
359-
printf("=\n");
360-
printf("= system halted\n");
361-
printf("===============================================");
362-
printf("=================================\n");
333+
/* Dump host context */
334+
dump_intr_excp_frame(ctx);
335+
/* Show host stack */
336+
show_host_call_trace(ctx->rsp, ctx->rbp, cpu_id);
337+
/* Dump guest context */
338+
dump_guest_context(cpu_id);
339+
363340
}

hypervisor/include/debug/dump.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ struct intr_excp_ctx;
3737
#define CALL_TRACE_HIERARCHY_MAX 20
3838
#define DUMP_STACK_SIZE 0x200
3939

40+
void dump_intr_excp_frame(struct intr_excp_ctx *ctx);
4041
void dump_exception(struct intr_excp_ctx *ctx, uint32_t cpu_id);
41-
void dump_interrupt(struct intr_excp_ctx *ctx);
4242

4343
#else
44-
45-
static inline void dump_exception(__unused struct intr_excp_ctx *ctx,
46-
__unused uint32_t cpu_id)
44+
static inline void dump_intr_excp_frame(__unused struct intr_excp_ctx *ctx)
4745
{
4846
}
4947

50-
static inline void dump_interrupt(__unused struct intr_excp_ctx *ctx)
48+
static inline void dump_exception(__unused struct intr_excp_ctx *ctx,
49+
__unused uint32_t cpu_id)
5150
{
5251
}
52+
5353
#endif
5454

5555
#endif /* DUMP_H */

0 commit comments

Comments
 (0)