From 862d6c7593583adcc689a396dac74100e3cefc4d Mon Sep 17 00:00:00 2001 From: HikariKnight <2557889+HikariKnight@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:05:56 +0200 Subject: [PATCH] Tell user the iommu arguments for their system if IOMMU is disabled --- internal/utiil_ls-iommu.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/internal/utiil_ls-iommu.go b/internal/utiil_ls-iommu.go index 71e65d2..48709ed 100644 --- a/internal/utiil_ls-iommu.go +++ b/internal/utiil_ls-iommu.go @@ -12,6 +12,7 @@ import ( "github.com/HikariKnight/ls-iommu/pkg/errorcheck" "github.com/HikariKnight/quickpassthrough/internal/logger" "github.com/charmbracelet/bubbles/list" + "github.com/klauspost/cpuid/v2" ) func getIOMMU(args ...string) []string { @@ -27,8 +28,26 @@ func getIOMMU(args ...string) []string { // Execute the command err := cmd.Run() + // Generate the correct iommu string for the system + var iommu_args string + cpuinfo := cpuid.CPU + // Write the argument based on which cpu the user got + switch cpuinfo.VendorString { + case "AuthenticAMD": + iommu_args = "iommu=pt amd_iommu=on" + case "GenuineIntel": + iommu_args = "iommu=pt intel_iommu=on" + } + // If ls-iommu returns an error then IOMMU is disabled - errorcheck.ErrorCheck(err, "IOMMU disabled in either UEFI/BIOS or in bootloader!") + errorcheck.ErrorCheck(err, + fmt.Sprintf( + "IOMMU disabled in either UEFI/BIOS or in bootloader!\n"+ + "For your bootloader, make sure you have added the kernel arguments:\n"+ + "%s", + iommu_args, + ), + ) // Read the output var items []string