From efc64d778fdbc8faed4ac051905f2575fd89ed21 Mon Sep 17 00:00:00 2001 From: Tw Date: Tue, 29 Jan 2019 21:30:15 +0800 Subject: [PATCH] hv: fix host call stack dump issue As scheduler uses its own stack for now, there is no need to check stack validity, so wipe it out. Tracked-On: #2455 Signed-off-by: Tw Reviewed-by: Jason Chen CJ Acked-by: Eddie Dong --- hypervisor/arch/x86/init.c | 2 +- hypervisor/debug/dump.c | 20 ++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/hypervisor/arch/x86/init.c b/hypervisor/arch/x86/init.c index 882cf109b..5a94b7874 100644 --- a/hypervisor/arch/x86/init.c +++ b/hypervisor/arch/x86/init.c @@ -13,7 +13,7 @@ { \ asm volatile ("movq %0, %%rsp\n" \ "pushq %1\n" \ - "call *%2\n" \ + "jmpq *%2\n" \ : \ : "r"(rsp), "rm"(SP_BOTTOM_MAGIC), "a"(to)); \ } diff --git a/hypervisor/debug/dump.c b/hypervisor/debug/dump.c index c450402ee..2e3b9f304 100644 --- a/hypervisor/debug/dump.c +++ b/hypervisor/debug/dump.c @@ -186,7 +186,7 @@ static void dump_guest_context(uint16_t pcpu_id) static void show_host_call_trace(uint64_t rsp, uint64_t rbp_arg, uint16_t pcpu_id) { - uint64_t rbp = rbp_arg; + uint64_t rbp = rbp_arg, return_address; uint32_t i = 0U; uint32_t cb_hierarchy = 0U; uint64_t *sp = (uint64_t *)rsp; @@ -201,11 +201,6 @@ static void show_host_call_trace(uint64_t rsp, uint64_t rbp_arg, uint16_t pcpu_i printf("\r\n"); printf("Host Call Trace:\r\n"); - if ((rsp > - (uint64_t)&per_cpu(stack, pcpu_id)[CONFIG_STACK_SIZE - 1]) - || (rsp < (uint64_t)&per_cpu(stack, pcpu_id)[0])) { - return; - } /* if enable compiler option(no-omit-frame-pointer) the stack layout * should be like this when call a function for x86_64 @@ -220,16 +215,13 @@ static void show_host_call_trace(uint64_t rsp, uint64_t rbp_arg, uint16_t pcpu_i * * if the address is invalid, it will cause hv page fault * then halt system */ - while ((rbp <= - (uint64_t)&per_cpu(stack, pcpu_id)[CONFIG_STACK_SIZE - 1]) - && (rbp >= (uint64_t)&per_cpu(stack, pcpu_id)[0]) - && (cb_hierarchy < CALL_TRACE_HIERARCHY_MAX)) { - printf("----> 0x%016llx\r\n", - *(uint64_t *)(rbp + sizeof(uint64_t))); - if (*(uint64_t *)(rbp + (2U*sizeof(uint64_t))) - == SP_BOTTOM_MAGIC) { + while (cb_hierarchy < CALL_TRACE_HIERARCHY_MAX) { + return_address = *(uint64_t *)(rbp + sizeof(uint64_t)); + if (return_address == SP_BOTTOM_MAGIC) { break; } + printf("----> 0x%016llx\r\n", + *(uint64_t *)(rbp + sizeof(uint64_t))); rbp = *(uint64_t *)rbp; cb_hierarchy++; }