From 32dac4decce37be30907e6c6250c5d42969edf17 Mon Sep 17 00:00:00 2001 From: Kumar Harsh <harkumar@codeaurora.org> Date: Wed, 24 Oct 2018 12:09:33 +0530 Subject: [PATCH] ldrp_V2 : Core context extraction if kernel executing at EL2 These changes add a new option --kernel-exception-level which can be passed from command line to specify the current exception level of kernel. This is to handle a case where backtrace should get generated if kernel is executing at EL2 instead of EL1. Change-Id: If0d61119a6cc27e263d73ce9921a63cab4bdee45 Signed-off-by: Kumar Harsh <harkumar@codeaurora.org> --- linux-ramdump-parser-v2/ramdump.py | 1 + linux-ramdump-parser-v2/ramparse.py | 2 ++ linux-ramdump-parser-v2/scandump_reader.py | 7 +++++-- linux-ramdump-parser-v2/watchdog_v2.py | 7 +++++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/linux-ramdump-parser-v2/ramdump.py b/linux-ramdump-parser-v2/ramdump.py index f4db068..34bb0a0 100644 --- a/linux-ramdump-parser-v2/ramdump.py +++ b/linux-ramdump-parser-v2/ramdump.py @@ -543,6 +543,7 @@ class RamDump(): self.autodump = options.autodump self.module_table = module_table.module_table_class() self.module_table.setup_sym_path(options.sym_path) + self.currentEL = options.currentEL or None if self.minidump: try: mod = import_module('elftools.elf.elffile') diff --git a/linux-ramdump-parser-v2/ramparse.py b/linux-ramdump-parser-v2/ramparse.py index 7864502..9223dc2 100644 --- a/linux-ramdump-parser-v2/ramparse.py +++ b/linux-ramdump-parser-v2/ramparse.py @@ -120,6 +120,8 @@ if __name__ == '__main__': parser.add_option( '', '--force-version', type='int', dest='force_hardware_version', help='Force the hardware detection to a specific hardware version') + parser.add_option('-l', '--kernel-exception-level', type='int', + dest='currentEL', help='Current exception level for kernel') parser.add_option('', '--parse-qdss', action='store_true', dest='qdss', help='Parse QDSS (deprecated)') parser.add_option('', '--shell', action='store_true', diff --git a/linux-ramdump-parser-v2/scandump_reader.py b/linux-ramdump-parser-v2/scandump_reader.py index 36e7a2c..e91a011 100644 --- a/linux-ramdump-parser-v2/scandump_reader.py +++ b/linux-ramdump-parser-v2/scandump_reader.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. +# Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 and @@ -243,7 +243,10 @@ class Scandump_v2(): pc = self.regs['pc'] if ram_dump.arm64: lr = self.regs['x30'] - bt = self.regs['sp_el1'] + if ram_dump.currentEL == 0x2: + bt = self.regs['sp_el2'] + else: + bt = self.regs['sp_el1'] fp = self.regs['x29'] else: lr = self.regs['r14_svc'] diff --git a/linux-ramdump-parser-v2/watchdog_v2.py b/linux-ramdump-parser-v2/watchdog_v2.py index 76fc99a..0e70ddc 100644 --- a/linux-ramdump-parser-v2/watchdog_v2.py +++ b/linux-ramdump-parser-v2/watchdog_v2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. +# Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 and @@ -724,7 +724,10 @@ class TZRegDump_v2(): pc = self.core_regs.regs['pc'] if ram_dump.arm64: lr = self.core_regs.regs['x30'] - bt = self.core_regs.regs['sp_el1'] + if ram_dump.currentEL == 0x2: + bt = self.core_regs.regs['sp_el2'] + else: + bt = self.core_regs.regs['sp_el1'] fp = self.core_regs.regs['x29'] else: lr = self.core_regs.regs['r14_svc'] -- GitLab