On 07.05.19 18:44, Hakkı Kurumahmut wrote:
FINAL PATCH:

It is committed for jailhouse/next branch.


 From aa9e7f0e25317d2f516da68b4163f9f08fc6c76d Mon Sep 17 00:00:00 2001
From: HAKKI KURUMAHMUT <[email protected]>
Date: Tue, 7 May 2019 19:37:59 +0300
Subject: [PATCHv2] Scripts: Fix for Parsing DMAR Region under Reserved Section

  While kernel command parameters are intel_iommu=on  intremap=on at
  some machines, cat /proc/iomem shows DMAR region under reserved section.
  This patch must be done for config creation to complete because of
  generating DMAR region not found error although it exist. If this patch is
  not apply, an error is throw by "config create" command whether
  intel_iommu On or Off because "reserved" regions are currently excluded from
  the generated config although DMAR region exists. Thus, DMAR under reserved
  section must be parsed by parser.

Signed-off-by: HAKKI KURUMAHMUT <[email protected]>
---
  pyjailhouse/sysfs_parser.py | 23 +++++++++++++----------
  1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/pyjailhouse/sysfs_parser.py b/pyjailhouse/sysfs_parser.py
index 46c95fc2..4f5da12e 100644
--- a/pyjailhouse/sysfs_parser.py
+++ b/pyjailhouse/sysfs_parser.py
@@ -94,14 +94,13 @@ def input_listdir(dir, wildcards):


  def parse_iomem(pcidevices):
-    regions = IOMemRegionTree.parse_iomem_tree(
+    (regions, dmar_regions) = IOMemRegionTree.parse_iomem_tree(
          IOMemRegionTree.parse_iomem_file())

      rom_region = MemRegion(0xc0000, 0xdffff, 'ROMs')
      add_rom_region = False

      ret = []
-    dmar_regions = []
      for r in regions:
          append_r = True
          # filter the list for MSI-X pages
@@ -860,21 +859,21 @@ class IOMemRegionTree:

          return root

-    # find HPET regions in tree
+    # find specific regions in tree
      @staticmethod
-    def find_hpet_regions(tree):
+    def find_regions_by_name(tree, string):
          regions = []

          for tree in tree.children:
              r = tree.region
              s = r.typestr

-            if (s.find('HPET') >= 0):
+            if (s.find(string) >= 0):
                  regions.append(r)

              # if the tree continues recurse further down ...
              if (len(tree.children) > 0):
-                regions.extend(IOMemRegionTree.find_hpet_regions(tree))
+                regions.extend(IOMemRegionTree.find_regions_by_name(tree, 
string))

          return regions

@@ -882,6 +881,7 @@ class IOMemRegionTree:
      @staticmethod
      def parse_iomem_tree(tree):
          regions = []
+        dmar_regions = []

          for tree in tree.children:
              r = tree.region
@@ -901,20 +901,23 @@ class IOMemRegionTree:
              ):
                  continue

-            # generally blacklisted, unless we find an HPET behind it
+            # generally blacklisted, with a few exceptions
              if (s.lower() == 'reserved'):
-                regions.extend(IOMemRegionTree.find_hpet_regions(tree))
+                regions.extend(IOMemRegionTree.find_regions_by_name(tree, 
'HPET'))
+                dmar_regions.extend(IOMemRegionTree.find_regions_by_name(tree, 
'dmar'))
                  continue

              # if the tree continues recurse further down ...
              if (len(tree.children) > 0):
-                regions.extend(IOMemRegionTree.parse_iomem_tree(tree))
+                (temp_regions, temp_dmar_regions) = 
IOMemRegionTree.parse_iomem_tree(tree)
+                regions.extend(temp_regions)
+                dmar_regions.extend(temp_dmar_regions)
                  continue

              # add all remaining leaves
              regions.append(r)

-        return regions
+        return regions, dmar_regions


  class IOMMUConfig:


Thanks, applied with style adjustments (pep8).

To avoid that your patch get's lost in a thread, at least make sure that the
subject is the one of the patch. Again, git send-email will likely work better
than manually copying into an email client (unless you know exactly what needs
to be set).

Jan

--
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/99d010c0-a646-2109-e575-51daf26d53b9%40web.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to