Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752295AbbFRF1k (ORCPT ); Thu, 18 Jun 2015 01:27:40 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:54258 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752079AbbFRF1c (ORCPT ); Thu, 18 Jun 2015 01:27:32 -0400 X-AuditID: cbfee68d-f79106d00000728c-a9-558256c28723 From: Maninder Singh To: catalin.marinas@arm.com, will.deacon@arm.com, sungjinn.chung@samsung.com, jays.lee@samsung.com, kgene.kim@samsung.com, behanw@converseincode.com, punit.agrawal@arm.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: pankaj.m@samsung.com, Rohit Thapliyal , Maninder Singh Subject: [RFC][PATCH] arm64:Modify the dump mem for 64 bit addresses Date: Thu, 18 Jun 2015 10:57:06 +0530 Message-id: <1434605226-17084-1-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 2.1.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRmVeSWpSXmKPExsWyRsSkTvdQWFOowb0jPBanzuRYvF/Ww2hx /+p3RoveBVfZLDY9vsZqcXnXHDaLw/PbWCyWXr/IZHHvzVYmi+fvTzNZbLyXbfFhxkpGi5cf T7A48HqsmbeG0WNn23xWj81L6j36tqxi9Pi8SS6ANYrLJiU1J7MstUjfLoEr49jH76wF+9Ur Lp46ztzA+EChi5GTQ0LARGL2riYmCFtM4sK99WxdjFwcQgJLGSWW/13NCFPUO/sDC0RiEaPE yrt9jBDOJCaJjmaQFk4ONgE9iVW79oBViQh0M0n0XPzNCpJgFsiXmHZnD9gOYQEXiTUbLoE1 sAioSvxd/xZoEgcHr4C7xM+J/BDb5CTOH//JDDJHQmAVu8TCWYeYIOoFJL5NPsQCUi8hICux 6QAzRL2kxMEVN1gmMAouYGRYxSiaWpBcUJyUXmSoV5yYW1yal66XnJ+7iREY7qf/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YrV01qTQ/2ke4znPrsYUh+glTbDqmJbyXbZWZYftD6+DYr3fcP+9KTSnZ38fn4eVyIP s4jd426aPekXw/rah78ez5p3vOZ1WJSAG/NHzgzXvKgdqq+mn4xZKqU5iTNGiaU4I9FQi7mo OBEA+Bk18bwCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5171 Lines: 134 From: Rohit Thapliyal On 64bit kernel, the dump_mem gives 32 bit addresses on the stack dump. This gives unorganized information regarding the 64bit values on the stack. Hence, modified to get a complete 64bit memory dump. With patch: Process insmod (pid: 1587, stack limit = 0xffffffc976be4058) Stack: (0xffffffc976be7cf0 to 0xffffffc976be8000) 7ce0: ffffffc976be7d00 ffffffc00008163c 7d00: ffffffc976be7d40 ffffffc0000f8a44 ffffffc00098ef38 ffffffbffc000088 7d20: ffffffc00098ef50 ffffffbffc0000c0 0000000000000001 ffffffbffc000070 7d40: ffffffc976be7e40 ffffffc0000f935c 0000000000000000 000000002b424090 7d60: 000000002b424010 0000007facc555f4 0000000080000000 0000000000000015 7d80: 0000000000000116 0000000000000069 ffffffc00097b000 ffffffc976be4000 7da0: 0000000000000064 0000000000000072 000000000000006e 000000000000003f 7dc0: 000000000000feff 000000000000fff1 ffffffbffc002028 0000000000000124 7de0: ffffffc976be7e10 0000000000000001 ffffff8000000000 ffffffbbffff0000 7e00: ffffffc976be7e60 0000000000000000 0000000000000000 0000000000000000 7e20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7e40: 0000007fcc474550 ffffffc0000841ec 000000002b424010 0000007facda0710 7e60: ffffffffffffffff ffffffc0000be6dc ffffff80007d2000 000000000001c010 7e80: ffffff80007e0ae0 ffffff80007e09d0 ffffff80007edf70 0000000000000288 7ea0: 00000000000002e8 0000000000000000 0000000000000000 0000001c0000001b 7ec0: 0000000000000009 0000000000000007 000000002b424090 000000000001c010 7ee0: 000000002b424010 0000007faccd3a48 0000000000000000 0000000000000000 7f00: 0000007fcc4743f8 0000007fcc4743f8 0000000000000069 0000000000000003 7f20: 0101010101010101 0000000000000004 0000000000000020 00000000000003f3 7f40: 0000007facb95664 0000007facda7030 0000007facc555d0 0000000000498378 7f60: 0000000000000000 000000002b424010 0000007facda0710 000000002b424090 7f80: 0000007fcc474698 0000000000498000 0000007fcc474ebb 0000000000474f58 7fa0: 0000000000498000 0000000000000000 0000000000000000 0000007fcc474550 7fc0: 00000000004104bc 0000007fcc474430 0000007facc555f4 0000000080000000 7fe0: 000000002b424090 0000000000000069 0950020128000244 4104000008000004 Call trace: The above output makes a debugger life a lot more easier. Signed-off-by: Rohit Thapliyal Signed-off-by: Maninder Singh Reviewed-by: Akhilesh Kumar --- arch/arm64/kernel/traps.c | 62 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 1ef2940..6e9f19b 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -51,6 +51,48 @@ int show_unhandled_signals = 1; /* * Dump out the contents of some memory nicely... */ + +static void dump_mem64(const char *lvl, const char *str, unsigned long bottom, + unsigned long top) +{ + unsigned long first; + mm_segment_t fs; + int i; + + /* + * We need to switch to kernel mode so that we can use __get_user + * to safely read from kernel space. Note that we now dump the + * code first, just in case the backtrace kills us. + */ + fs = get_fs(); + set_fs(KERNEL_DS); + + pr_alert("%s%s(0x%016lx to 0x%016lx)\n", lvl, str, bottom, top); + + for (first = bottom & ~31; first < top; first += 32) { + unsigned long p; + char str[sizeof(" 1234567812345678") * 8 + 1]; + + memset(str, ' ', sizeof(str)); + str[sizeof(str) - 1] = '\0'; + + for (p = first, i = 0; i < 4 && p < top; i++, p += 8) { + if (p >= bottom && p < top) { + unsigned long val; + + if (__get_user(val, (unsigned long *)p) == 0) + sprintf(str + i * 17, " %016lx", val); + else + sprintf(str + i * 17, + " ????????????????"); + } + } + pr_alert("%s%04lx:%s\n", lvl, first & 0xffff, str); + } + + set_fs(fs); +} + static void dump_mem(const char *lvl, const char *str, unsigned long bottom, unsigned long top) { @@ -206,8 +248,24 @@ static int __die(const char *str, int err, struct thread_info *thread, TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1); if (!user_mode(regs) || in_interrupt()) { - dump_mem(KERN_EMERG, "Stack: ", regs->sp, - THREAD_SIZE + (unsigned long)task_stack_page(tsk)); + + if (regs->sp > (unsigned long)task_stack_page(tsk)) { + dump_mem64(KERN_EMERG, "Stack: ", regs->sp, + THREAD_SIZE + + (unsigned long)task_stack_page(tsk)); + } else { + if (compat_user_mode(regs)) { + dump_mem(KERN_EMERG, "Stack: ", + (unsigned long)task_stack_page(tsk), + THREAD_SIZE + + (unsigned long)task_stack_page(tsk)); + } else { + dump_mem64(KERN_EMERG, "Stack: ", + (unsigned long)task_stack_page(tsk), + THREAD_SIZE + + (unsigned long)task_stack_page(tsk)); + } + } dump_backtrace(regs, tsk); dump_instr(KERN_EMERG, regs); } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/