def run(self): if len(self.argv) < 3: print(IOMMUCommand.__doc__) return op = self.argv[2] t = time.time() try: _iommu = iommu.IOMMU(self.cs) except iommu.IOMMUError as msg: print(msg) return if ('list' == op): self.logger.log("[CHIPSEC] Enumerating supported IOMMU engines..") self.logger.log(iommu.IOMMU_ENGINES.keys()) elif ('config' == op or 'status' == op or 'enable' == op or 'disable' == op or 'pt' == op): if len(self.argv) > 3: if self.argv[3] in iommu.IOMMU_ENGINES.keys(): _iommu_engines = [self.argv[3]] else: self.logger.error( "IOMMU name {} not recognized. Run 'iommu list' command for supported IOMMU names" .format(self.argv[3])) return else: _iommu_engines = iommu.IOMMU_ENGINES.keys() if 'config' == op: try: _acpi = acpi.ACPI(self.cs) except acpi.AcpiRuntimeError as msg: print(msg) return if _acpi.is_ACPI_table_present(acpi.ACPI_TABLE_SIG_DMAR): self.logger.log( "[CHIPSEC] Dumping contents of DMAR ACPI table..\n") _acpi.dump_ACPI_table(acpi.ACPI_TABLE_SIG_DMAR) else: self.logger.log( "[CHIPSEC] Couldn't find DMAR ACPI table\n") for e in _iommu_engines: if 'config' == op: _iommu.dump_IOMMU_configuration(e) elif 'pt' == op: _iommu.dump_IOMMU_page_tables(e) elif 'status' == op: _iommu.dump_IOMMU_status(e) elif 'enable' == op: _iommu.set_IOMMU_Translation(e, 1) elif 'disable' == op: _iommu.set_IOMMU_Translation(e, 0) else: print(IOMMUCommand.__doc__) return self.logger.log( "[CHIPSEC] (iommu) time elapsed {:.3f}".format(time.time() - t))
def run(self): if len(self.argv) < 3: print IOMMUCommand.__doc__ return op = self.argv[2] t = time.time() try: _iommu = iommu.IOMMU(self.cs) except IOMMUError, msg: print msg return
def iommu_engine(self, cmd): try: _iommu = iommu.IOMMU(self.cs) except iommu.IOMMUError as msg: print(msg) return if self.engine: if self.engine in iommu.IOMMU_ENGINES.keys(): _iommu_engines = [self.engine] else: self.logger.error( "IOMMU name {} not recognized. Run 'iommu list' command for supported IOMMU names" .format(self.engine)) return else: _iommu_engines = iommu.IOMMU_ENGINES.keys() if 'config' == cmd: try: _acpi = acpi.ACPI(self.cs) except acpi.AcpiRuntimeError as msg: print(msg) return if _acpi.is_ACPI_table_present(acpi.ACPI_TABLE_SIG_DMAR): self.logger.log( "[CHIPSEC] Dumping contents of DMAR ACPI table..\n") _acpi.dump_ACPI_table(acpi.ACPI_TABLE_SIG_DMAR) else: self.logger.log("[CHIPSEC] Couldn't find DMAR ACPI table\n") for e in _iommu_engines: if (cmd == 'config'): _iommu.dump_IOMMU_configuration(e) elif (cmd == 'pt'): _iommu.dump_IOMMU_page_tables(e) elif (cmd == 'status'): _iommu.dump_IOMMU_status(e) elif (cmd == 'enable'): _iommu.set_IOMMU_Translation(e, 1) elif (cmd == 'disable'): _iommu.set_IOMMU_Translation(e, 0)