From 54bd55d6365c9634807c35de6527f9842fe8ab25 Mon Sep 17 00:00:00 2001 From: Shiqing Gao Date: Fri, 6 Jul 2018 11:18:01 +0800 Subject: [PATCH] hv: fix 'Recursion in procedure calls found' Here is how the recursion might happen: when there is something wrong | sbuf_put -> memcpy_s -> pr_err -> do_logmsg | | ----------------------------------- Replace 'pr_err' with 'ASSERT' in 'memcpy_s' to break this kind of recursion. Signed-off-by: Shiqing Gao --- hypervisor/debug/dump.c | 2 +- hypervisor/include/debug/assert.h | 1 - hypervisor/lib/memory.c | 6 ++---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/hypervisor/debug/dump.c b/hypervisor/debug/dump.c index 75e4d8415..ea07fb366 100644 --- a/hypervisor/debug/dump.c +++ b/hypervisor/debug/dump.c @@ -234,7 +234,7 @@ void __assert(uint32_t line, const char *file, const char *txt) uint64_t rsp = cpu_rsp_get(); uint64_t rbp = cpu_rbp_get(); - pr_fatal("Assertion failed in file %s,line %u : %s", + printf("Assertion failed in file %s,line %u : %s", file, line, txt); show_host_call_trace(rsp, rbp, pcpu_id); dump_guest_context(pcpu_id); diff --git a/hypervisor/include/debug/assert.h b/hypervisor/include/debug/assert.h index 6b249b014..e075fc5d3 100644 --- a/hypervisor/include/debug/assert.h +++ b/hypervisor/include/debug/assert.h @@ -12,7 +12,6 @@ void __assert(uint32_t line, const char *file, const char *txt); #define ASSERT(x, ...) \ if (!(x)) {\ - pr_fatal(__VA_ARGS__);\ __assert(__LINE__, __FILE__, "fatal error");\ } #else diff --git a/hypervisor/lib/memory.c b/hypervisor/lib/memory.c index 023e3fd6b..825a9065a 100644 --- a/hypervisor/lib/memory.c +++ b/hypervisor/lib/memory.c @@ -344,14 +344,12 @@ void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen) uint8_t *src8; if (slen == 0U || dmax == 0U || dmax < slen) { - pr_err("%s: invalid src, dest buffer or length.", __func__); - return NULL; + ASSERT(false); } if ((d > s && d <= s + slen - 1) || (d < s && s <= d + dmax - 1)) { - pr_err("%s: overlap happened.", __func__); - return NULL; + ASSERT(false); } /*same memory block, no need to copy*/