From: Jan Kiszka <[email protected]>

The kernel tends to report regions that are not page-aligned but
directly adjacent. Adding them as-is into the config will make accesses
fail because the regions will end up as incompletely configured sub-page
regions. Detect such cases and merge the regions.

Signed-off-by: Jan Kiszka <[email protected]>
---
 pyjailhouse/sysfs_parser.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pyjailhouse/sysfs_parser.py b/pyjailhouse/sysfs_parser.py
index 7067f779..19bc16c5 100644
--- a/pyjailhouse/sysfs_parser.py
+++ b/pyjailhouse/sysfs_parser.py
@@ -207,6 +207,12 @@ def parse_iomem(pcidevices):
         # filter out AMD IOMMU regions
         if r.typestr.find('amd_iommu') >= 0:
             append_r = False
+        # merge adjacent RAM regions
+        if append_r and len(ret) > 0:
+            prev = ret[-1]
+            if prev.is_ram() and r.is_ram() and prev.stop + 1 == r.start:
+                prev.stop = r.stop
+                append_r = False
         if append_r:
             ret.append(r)
 
-- 
2.26.2

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/3e1ae553f995e2b23867e5f58633beabf0760583.1599473999.git.jan.kiszka%40siemens.com.

Reply via email to