Am Mon, 6 May 2019 12:26:42 -0700
schrieb Hakkı Kurumahmut <[email protected]>:

> Hi Henning,
> 
> I have write new patch but I have not test it more. But it is more
> suitable for your advices.
> 

That one looks very good and you can propose it with "git format-patch
--subject prefix PATCHv2" after a few more things. Again comments inline

> diff --git a/pyjailhouse/sysfs_parser.py b/pyjailhouse/sysfs_parser.py
> index 46c95fc2..985c1129 100644
> --- a/pyjailhouse/sysfs_parser.py
> +++ b/pyjailhouse/sysfs_parser.py
> @@ -22,6 +22,7 @@ import struct
>  import os
>  import fnmatch
>  
> +# root_dir = "/home/ubuntu/repos/siemens/jailhouse/data/"
>  root_dir = "/"

Do you already know about "jailhouse-config-collect" and the "-r"
switch for the config creator?

Needless to say that this should not become part of the patch. The same
applies to some whitespace diff and the debug prints.

>  def set_root_dir(dir):
> @@ -58,6 +59,7 @@
> inputs['files_intel'].add('/sys/firmware/acpi/tables/DMAR')
> inputs['files_amd'].add('/sys/firmware/acpi/tables/IVRS') 
>  
> +
>  def check_input_listed(name, optional=False):
>      set = inputs['files_opt']
>      if optional is False:
> @@ -94,14 +96,15 @@ def input_listdir(dir, wildcards):
>  
>  
>  def parse_iomem(pcidevices):
> -    regions = IOMemRegionTree.parse_iomem_tree(
> +    dmar_regions = []

this is already done inside the function and can be skipped

> +    (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
> @@ -249,9 +252,14 @@ def parse_dmar(pcidevices, ioapics,
> dmar_regions): if d.iommu is None:
>                          d.iommu = len(units) - 1
>              offset += 16 - offset
> +            print('DRHD: struct_len: %d offset: %2d -> flags: %d
> segment: %d base: 0x%x ' % (struct_len, offset, flags, segment,
> base)) + while offset < struct_len:
>                  (scope_type, scope_len, id, bus, dev, fn) =\
>                      parse_dmar_devscope(f)
> +
> +                print('DevScope: offset: %2d ->  scope_type: %d
> scope_len: %d id: %d bus: %d dev: %d fn: %d' % (offset, scope_type,
> scope_len, id, bus, dev, fn)) + # PCI Endpoint Device
>                  if scope_type == 1:
>                      assert not (flags & 1)
> @@ -290,11 +298,15 @@ def parse_dmar(pcidevices, ioapics,
> dmar_regions): offset += 8 - offset
>              (base, limit) = struct.unpack('<QQ', f.read(16))
>              offset += 16
> +            print('RMRR: struct_len: %d offset: %2d ->  base: 0x%x
> limit: %d ' % (struct_len, offset, base, limit)) 
>              comments = []
>              while offset < struct_len:
>                  (scope_type, scope_len, id, bus, dev, fn) =\
>                      parse_dmar_devscope(f)
> +                
> +                print('DevScope: offset: %2d ->  scope_type: %d
> scope_len: %d id: %d bus: %d dev: %d fn: %d' % (offset, scope_type,
> scope_len, id, bus, dev, fn)) + if scope_type == 1:
>                      comments.append('PCI device: %02x:%02x.%x' %
>                                      (bus, dev, fn))
> @@ -860,21 +872,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 +894,7 @@ class IOMemRegionTree:
>      @staticmethod
>      def parse_iomem_tree(tree):
>          regions = []
> +        dmar_regions = []
>  
>          for tree in tree.children:
>              r = tree.region
> @@ -901,20 +914,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)

Exactly the pattern i was about to suggest when i saw one previous
mail ;)

Looks all good to me and should be turned into a v2.

Henning

>                  continue
>  
>              # add all remaining leaves
>              regions.append(r)
>  
> -        return regions
> +        return regions, dmar_regions
>  
>  
>  class IOMMUConfig:
> 
> 

-- 
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/20190507170634.7f1c97fb%40md1za8fc.ad001.siemens.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to