From 37bb0d0fb30a3548173253b0f19861a7ee4f8fce Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Mon, 20 Jun 2016 14:39:49 +0100 Subject: kern, arm: Dump dmesg on kernel panic/oops Add helper functions to dump the guest kernel's dmesg buffer to a text file in m5out. This functionality is split into two parts. First, a dmesg dump function that can be used in other places: void Linux::dumpDmesg(ThreadContext *, std::ostream &) This function is used to implement two PCEvents: DmesgDumpEvent and KernelPanic event. The only difference between the two is that the latter produces a gem5 panic instead of a warning in addition to dumping the kernel log. Change-Id: I6d2af1d666ace57124089648ea906f6c787ac63c Signed-off-by: Andreas Sandberg Reviewed-by: Nikos Nikoleris Reviewed-by: Gabor Dozsa --- src/kern/linux/events.hh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/kern/linux/events.hh') diff --git a/src/kern/linux/events.hh b/src/kern/linux/events.hh index 3f5f2526f..b8aad9d79 100644 --- a/src/kern/linux/events.hh +++ b/src/kern/linux/events.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2016 ARM Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 2004-2006 The Regents of The University of Michigan * All rights reserved. * @@ -44,6 +56,46 @@ class DebugPrintkEvent : public SkipFuncEvent virtual void process(ThreadContext *xc); }; +/** + * Dump the guest kernel's dmesg buffer to a file in gem5's output + * directory and print a warning. + * + * @warn This event uses Linux::dumpDmesg() and comes with the same + * limitations. Most importantly, the kernel's address mappings must + * be available to the translating proxy. + */ +class DmesgDumpEvent : public PCEvent +{ + protected: + std::string fname; + + public: + DmesgDumpEvent(PCEventQueue *q, const std::string &desc, Addr addr, + const std::string &_fname) + : PCEvent(q, desc, addr), fname(_fname) {} + virtual void process(ThreadContext *xc); +}; + +/** + * Dump the guest kernel's dmesg buffer to a file in gem5's output + * directory and panic. + * + * @warn This event uses Linux::dumpDmesg() and comes with the same + * limitations. Most importantly, the kernel's address mappings must + * be available to the translating proxy. + */ +class KernelPanicEvent : public PCEvent +{ + protected: + std::string fname; + + public: + KernelPanicEvent(PCEventQueue *q, const std::string &desc, Addr addr, + const std::string &_fname) + : PCEvent(q, desc, addr), fname(_fname) {} + virtual void process(ThreadContext *xc); +}; + /** A class to skip udelay() and related calls in the kernel. * This class has two additional parameters that take the argument to udelay and * manipulated it to come up with ns and eventually ticks to quiesce for. -- cgit v1.2.3