From 9b396979835426ef1e5a279d6336e0289e83c990 Mon Sep 17 00:00:00 2001
From: Laura Abbott <lauraa@codeaurora.org>
Date: Thu, 27 Mar 2014 18:43:15 -0700
Subject: [PATCH] linux-ramdump-parser-v2: Correct pfn_to_page with a pfn
 offset

When calculating pfn_to_page, the pfn needs to be offset before
indexing into the array. Account for this.

Change-Id: If207447a91537ab7670058fede65473d3ea93281
---
 linux-ramdump-parser-v2/mm.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-ramdump-parser-v2/mm.py b/linux-ramdump-parser-v2/mm.py
index 0cfc86e..7303992 100644
--- a/linux-ramdump-parser-v2/mm.py
+++ b/linux-ramdump-parser-v2/mm.py
@@ -135,7 +135,7 @@ def pfn_to_page_flat(ramdump, pfn):
     page_size = ramdump.sizeof('struct page')
     # XXX Needs to change for LPAE
     pfn_offset = ramdump.phys_offset >> 12
-    return mem_map + (pfn * page_size) - pfn_offset
+    return mem_map + ((pfn - pfn_offset) * page_size)
 
 
 def page_to_pfn(ramdump, page):
-- 
GitLab