On 2018-08-30 02:55, Christopher Goldsworthy wrote:
Use helpers defined in pyjailhouse/sysfs_parsers.py to gather the information
needed to determine if a machine can run jailhouse from sysfs.  Make checking
sysfs the default action when running jailhouse-hardware-check (instead of
checking a compiled configuration file).

Minor changes to pyjailhouse import warning.

What do you mean with "import warning"? The comments below the pyjailhouse imports? Should be changed separately.


Signed-off-by: Chris Goldsworthy <[email protected]>
---
  Documentation/pyjailhouse.md   |  4 ++--
  tools/jailhouse-cell-linux     |  4 ++--
  tools/jailhouse-hardware-check | 50 +++++++++++++++++++++---------------------
  3 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/Documentation/pyjailhouse.md b/Documentation/pyjailhouse.md
index 14fcf7d..5ee8466 100644
--- a/Documentation/pyjailhouse.md
+++ b/Documentation/pyjailhouse.md
@@ -55,6 +55,6 @@ For the example, the following wouldn't work inside of boz.py:
  `
  sys.path[0] = os.path.dirname(os.path.abspath(__file__)) + ""
  from pyjailhouse import

BTW, this code seems incorrect: "... import *"?

-# Imports from directory containing this must be done above
-# import statement, see python documentation on sys.path[0]
+# Imports from directory containing this script must be done above the
+# line setting sys.path[0], see python documentation on sys.path[0]

When changing these, I would recommend putting the comments above the sys.path change. The link to the python doc is also not needed.

  `
\ No newline at end of file

We should add that new line.

diff --git a/tools/jailhouse-cell-linux b/tools/jailhouse-cell-linux
index c3cee12..b6c0c75 100755
--- a/tools/jailhouse-cell-linux
+++ b/tools/jailhouse-cell-linux
@@ -19,8 +19,8 @@ import sys
sys.path[0] = os.path.dirname(os.path.abspath(__file__)) + "/.."
  from pyjailhouse.cell import JailhouseCell
-# Imports from directory containing this must be done above
-# import statement, see python documentation on sys.path[0]
+# Imports from directory containing this script must be done above the
+# line setting sys.path[0], see python documentation on sys.path[0]
libexecdir = None diff --git a/tools/jailhouse-hardware-check b/tools/jailhouse-hardware-check
index 1c7d1b9..a3009b0 100755
--- a/tools/jailhouse-hardware-check
+++ b/tools/jailhouse-hardware-check
@@ -17,6 +17,11 @@ import os
  import struct
  import sys
+sys.path[0] = os.path.dirname(os.path.abspath(__file__)) + "/.."
+import pyjailhouse.sysfs_parsers as sysfs_parser
                            ^^^^^^^
Untested...? ;)

+# Imports from directory containing this script must be done above the
+# line setting sys.path[0], see python documentation on sys.path[0]
+
  # just a dummy to make python2 happy
  if sys.version_info[0] < 3:
      class PermissionError(OSError):
@@ -156,7 +161,7 @@ class Sysconfig:
                           Sysconfig.PCIISVIRT_SIZE + Sysconfig.PCIDOMAIN_SIZE +
                           Sysconfig.X86_PADDING)
- keys = 'base size amd_bdf amd_base_cap amd_features'
+        keys = 'base_addr mmio_size amd_bdf amd_base_cap amd_features'
          IOMMU = collections.namedtuple('IOMMU', keys)
iommus = []
@@ -167,23 +172,13 @@ class Sysconfig:
          return iommus
-def usage(exit_code):
-    prog = os.path.basename(sys.argv[0]).replace('-', ' ')
-    print('usage: %s SYSCONFIG' % prog)
-    sys.exit(exit_code)
-
-
-if len(sys.argv) != 2:
-    usage(1)
-if sys.argv[1] in ("--help", "-h"):
-    usage(0)
-
  if os.uname()[4] not in ('x86_64', 'i686'):
      print('Unsupported architecture', file=sys.stderr)
      sys.exit(1)
-config = Sysconfig(sys.argv[1])
-iommu = config.parse_iommus()
+
+ioapics = sysfs_parser.parse_madt()
+pci_devices, _, _ = sysfs_parser.parse_pcidevices()
(cpu_vendor, cpu_features, cpu_count) = parse_cpuinfo() @@ -199,6 +194,9 @@ check_feature('Number of CPUs > 1', cpu_count > 1)
  check_feature('Long mode', 'lm' in cpu_features)
if cpu_vendor == 'GenuineIntel':
+    _, dmar_regions = sysfs_parser.parse_iomem(pci_devices)
+    iommu, _ = sysfs_parser.parse_dmar(pci_devices, ioapics, dmar_regions)
+
      check_feature('x2APIC', 'x2apic' in cpu_features, True)
      print()
      check_feature('VT-x (VMX)', 'vmx' in cpu_features)
@@ -248,14 +246,14 @@ if cpu_vendor == 'GenuineIntel':
      check_feature('  Activity state HLT',
                    msr.read(MSR.IA32_VMX_MISC) & (1 << 6))
- for n in range(8):
-        if iommu[n].base == 0 and n > 0:
+    for n in range(len(iommu)):
+        if iommu[n].base_addr == 0 and n > 0:
              break
          print()
-        check_feature('VT-d (IOMMU #%d)' % n, iommu[n].base)
-        if iommu[n].base == 0:
+        check_feature('VT-d (IOMMU #%d)' % n, iommu[n].base_addr)
+        if iommu[n].base_addr == 0:
              break
-        mmio = MMIO(iommu[n].base, iommu[n].size)
+        mmio = MMIO(iommu[n].base_addr, iommu[n].mmio_size)
          cap = mmio.read64(0x08)
          if cap is None:
              continue
@@ -270,6 +268,8 @@ if cpu_vendor == 'GenuineIntel':
                        'x2apic' not in cpu_features)
elif cpu_vendor == 'AuthenticAMD':
+    iommu, _ = sysfs_parser.parse_ivrs(pci_devices, ioapics)
+
      print()
      check_feature('AMD-V (SVM)', 'svm' in cpu_features)
      check_feature('  NPT', 'npt' in cpu_features)
@@ -277,12 +277,12 @@ elif cpu_vendor == 'AuthenticAMD':
      check_feature('  AVIC', 'avic' in cpu_features, True)
      check_feature('  Flush by ASID', 'flushbyasid' in cpu_features, True)
- for n in range(8):
-        if iommu[n].base == 0 and n > 0:
+    for n in range(len(iommu)):
+        if iommu[n].base_addr == 0 and n > 0:
              break
          print()
-        check_feature('AMD-Vi (IOMMU #%d)' % n, iommu[n].base)
-        if iommu[n].base == 0:
+        check_feature('AMD-Vi (IOMMU #%d)' % n, iommu[n].base_addr)
+        if iommu[n].base_addr == 0:
              break
bdf = iommu[n].amd_bdf
@@ -295,9 +295,9 @@ elif cpu_vendor == 'AuthenticAMD':
          check_feature('  Extended feature register', caps & (1 << 27))
          check_feature('  Valid base register',
                        (base & (1 << 0)) == 0 or
-                      base == (iommu[n].base | (1 << 0)))
+                      base == (iommu[n].base_addr | (1 << 0)))
- mmio = MMIO(iommu[n].base, iommu[n].size)
+        mmio = MMIO(iommu[n].base_addr, iommu[n].mmio_size)
          efr = mmio.read64(0x30)
          if efr is None:
              continue


Thanks
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to