From c1f67ce52e6323cfad73dd00e98822052a7714b4 Mon Sep 17 00:00:00 2001
From: Sarangdhar Joshi <spjoshi@codeaurora.org>
Date: Mon, 10 Aug 2015 19:27:41 -0700
Subject: [PATCH] lrdpv2: Fix an issue with unwinding stack for NON HLOS

Ram dump parser does not support unwinding the stack for NON
HLOS images. In certain cases, we get below exception when
parser tries to dump the context for NON HLOS address. Check
for NON HLOS address and return from the function without
unwinding the frame pointer.

Exception: Invalid stage 1 first- or second-level translation
descriptor: (value: 0x0 {dtype[1:0]=>0x0})
addr: (value: 0x21812010 {base[47:12]=>0x21812, offset[11:3]=>0x2})

Change-Id: I6cacec18574737d0e8261ba1f39dfe2b9b302304
---
 linux-ramdump-parser-v2/ramdump.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/linux-ramdump-parser-v2/ramdump.py b/linux-ramdump-parser-v2/ramdump.py
index d452fbc..e1b779f 100644
--- a/linux-ramdump-parser-v2/ramdump.py
+++ b/linux-ramdump-parser-v2/ramdump.py
@@ -115,7 +115,12 @@ class RamDump():
             mask = (self.ramdump.thread_size) - 1
             high = (low + mask) & (~mask)
 
-            if (fp < low or fp > high or fp & 0xf):
+            # Ignore NON HLOS addresses and return from the function without
+            # unwinding the frame pointer. HLOS addresses are expected to be
+            # greater than or equal to page_offset. NON HLOS addresses have 1-1
+            # virtual to physical mapping and may not have physical addresses
+            # equal to or greater than page_offset anytime soon.
+            if (fp < low or fp > high or fp & 0xf or fp < self.ramdump.page_offset):
                 return
 
             frame.sp = fp + 0x10
-- 
GitLab