Signed-off-by: Andrej Utz <[email protected]>
---
pyjailhouse/config_parser.py | 14 ++++++++++++--
tools/jailhouse-config-check | 34 +++++++++++++++++++++++++++++++---
2 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/pyjailhouse/config_parser.py b/pyjailhouse/config_parser.py
index 2b47d9b6..2a0e6ec9 100644
--- a/pyjailhouse/config_parser.py
+++ b/pyjailhouse/config_parser.py
@@ -192,17 +192,19 @@ class PIORegion(CStruct):
class CellConfig(CStruct):
# slots with a '_' prefix in name are private
- __slots__ = 'name', '_flags', '_cpu_sets', \
+ __slots__ = 'name', '_flags', 'cpu_set', \
'memory_regions', 'cache_regions', 'irqchips', 'pio_regions', \
'_pci_devices', '_pci_caps', '_stream_ids', \
'vpci_irq_base', 'cpu_reset_address',
_BIN_FIELD_NUM = len(__slots__)
_BIN_FMT = struct.Struct('=32s4xIIIIIIIIIIQ8x32x')
_BIN_FMT_HDR = struct.Struct('=6sH')
+ _BIN_FMT_CPU = struct.Struct('=Q')
_BIN_SIGNATURE = b'JHCELL'
def __init__(self):
self.name = ""
+ self.cpu_set = set()
self.memory_regions = []
self.irqchips = []
self.pio_regions = []
@@ -213,7 +215,15 @@ class CellConfig(CStruct):
def parse(cls, stream):
self = cls.parse_class(cls, stream)
self.name = self.name.decode().strip('\0')
- stream.seek(self._cpu_sets, io.SEEK_CUR) # skip CPU set
+
+ cpu_fmt = cls._BIN_FMT_CPU
+ cpu_set_num = int(self.cpu_set / cpu_fmt.size)
+ self.cpu_set = set()
+ for set_idx in range(cpu_set_num):
+ cpu_bits = cpu_fmt.unpack_from(stream.read(cpu_fmt.size))
+ for bit in range(cpu_fmt.size * 8):
+ if cpu_bits[0] & (1 << bit) > 0:
+ self.cpu_set.add(bit)
self.memory_regions = \
cls.parse_array(MemRegion, self.memory_regions, stream)
diff --git a/tools/jailhouse-config-check b/tools/jailhouse-config-check
index 380f4a77..d7f405fd 100755
--- a/tools/jailhouse-config-check
+++ b/tools/jailhouse-config-check
@@ -66,6 +66,7 @@ for cfg in args.cellcfgs:
ret=0
+# Memory checks
print("Overlapping memory regions inside cell:", end='')
found=False
for cell in cells:
@@ -79,10 +80,10 @@ for cell in cells:
if (mem.virt_overlaps(mem2)):
overlaps.append("virtually")
if overlaps:
- print("\n\nIn cell '%s', region %d" % (cell.name, idx))
+ print("\nIn cell '%s', region %d" % (cell.name, idx))
print(str(mem))
- print(" and ".join(overlaps) + \
- " overlaps with region %d\n" % idx2 + str(mem2), end='')
+ print(" and ".join(overlaps) +
+ " overlaps with region %d\n" % idx2 + str(mem2), end='')
found=True
ret=1
print("\n" if found else " None")
@@ -100,4 +101,31 @@ for cell in cells:
ret=1
print("\n" if found else " None")
+# CPU checks
+print("Overlapping CPUs between cells:", end='')
+found = False
+for cell in non_root_cells:
+ cell_idx = cells.index(cell)
+ for cell2 in cells[cell_idx + 1:]:
+ overlap = cell.cpu_set & cell2.cpu_set
+ if overlap:
+ print("\nIn cell '%s' and '%s' following CPUs overlap: %s" %
+ (cell.name, cell2.name, str(overlap)), end='')
+ found = True
+ ret = 1
+print("\n" if found else " None")
+
+print("CPUs not in root cell CPU set:", end='')
+found = False
+for cell in non_root_cells:
+ diff = cell.cpu_set - root_cell.cpu_set
+ if diff:
+ print("\nIn cell '%s': %s" % (cell.name, str(diff)), end='')
+ found = True
+ ret = 1
+if found:
+ print("\nNote: root cell CPU set: %s\n" % str(root_cell.cpu_set))
+else:
+ print(" None")
+
exit(ret)
--
2.27.0
--
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/20200715212119.48052-8-andrej.utz%40st.oth-regensburg.de.