From 80e4789c11c7659d738193333551a335bbb9a56b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 24 Nov 2021 22:59:06 +0100 Subject: [statistics] Support IOMMU for AMD --- modules-available/statistics/inc/hardwareinfo.inc.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules-available/statistics/inc/hardwareinfo.inc.php b/modules-available/statistics/inc/hardwareinfo.inc.php index 586b8124..ac92dd61 100644 --- a/modules-available/statistics/inc/hardwareinfo.inc.php +++ b/modules-available/statistics/inc/hardwareinfo.inc.php @@ -29,7 +29,7 @@ class HardwareInfo $mac = Request::get('mac', '', 'string'); $mac = str_replace(':', '-', $mac); } - $res = Database::simpleQuery("SELECT machineuuid, lastseen FROM machine + $res = Database::simpleQuery("SELECT machineuuid, lastseen, cpumodel FROM machine WHERE machineuuid = :uuid OR macaddr = :mac", ['uuid' => $uuid, 'mac' => $mac]); $best = null; foreach ($res as $row) { @@ -60,7 +60,14 @@ class HardwareInfo } $kcl = ''; if ($gvt || !empty($passthrough)) { - $kcl = '-iommu -intel_iommu iommu=pt intel_iommu=on'; // TODO AMD + if (strpos($best['cpumodel'], 'Intel') !== false) { + $kcl = '-iommu -intel_iommu iommu=pt intel_iommu=on'; + } elseif (strpos($best['cpumodel'], 'AMD') !== false) { + $kcl = '-iommu -amd_iommu iommu=pt amd_iommu=on'; + } else { + error_log("Cannot determine CPU manufacturer from " . $best['cpumodel']); + $kcl = '-iommu -intel_iommu iommu=pt intel_iommu=on -amd_iommu amd_iommu=on'; + } } if (!empty($passthrough)) { foreach (array_keys($slots) as $slot) { -- cgit v1.2.3-55-g7522