passthrough my gtx 1660 to kvm virtual machine on fedora 36.

Enable IOMMU

Open the /etc/default/grub file in a text editor with root privileges.

sudo vim /etc/default/grub

Find the line that starts with GRUB_CMDLINE_LINUX=

GRUB_CMDLINE_LINUX="rhgb quiet intel_iommu=on iommu=pt rd.driver.pre=vfio-pci video=efifb:off pcie_aspm=off"
  • nomodeset After making this change, GRUB will use the nomodeset parameter when booting the system, which tells the kernel not to load any video drivers or attempt to initialize the graphics hardware. This can be useful if you are experiencing issues with the graphics driver or if you want to use the integrated GPU instead of the discrete GPU.
  • intel_iommu=on or amd_iommu=on intel_iommu=on is a kernel parameter that enables Intel I/O Memory Management Unit (IOMMU) support in the Linux kernel. IOMMU is a hardware component that provides virtual memory mapping and device isolation capabilities for input/output (I/O) devices. With IOMMU enabled, a virtual machine can have direct access to a physical device, such as a graphics card, without interfering with other virtual machines or the host operating system. This allows for better performance and security isolation in virtualized environments.
  • splash: this parameter in the GRUB configuration file is used to display a graphical boot splash screen during system startup.
  • iommu=pt: This parameter enables IOMMU (Input-Output Memory Management Unit) in “pass-through” mode. IOMMU is a feature of modern computer systems that provides memory address translation for devices, improving security and performance. Setting it to “pt” indicates that the IOMMU is configured to operate in pass-through mode, allowing direct access to hardware devices by bypassing the IOMMU translation.
  • rd.driver.pre=vfio-pci: This parameter instructs the Linux kernel to load the vfio-pci driver as an early module during the boot process. The vfio-pci driver is used to bind PCI devices to the VFIO (Virtual Function I/O) driver framework, which allows for device passthrough to virtual machines.
  • video=efifb:off: This parameter disables the efifb (EFI framebuffer) driver. The efifb driver provides a basic graphics console for EFI systems. By turning it off, the system will not attempt to use the EFI framebuffer for graphics output during the boot process.
  • pcie_aspm=off: This parameter disables ASPM (Active State Power Management) for PCI Express (PCIe) devices. ASPM is a power-saving feature for PCIe devices that allows them to enter lower power states when idle. Disabling ASPM can sometimes resolve compatibility issues or improve stability with certain hardware configurations
  • kvm.ignore_msrs=1 MSRs (Model Specific Registers) are processor registers that are used to control various hardware features and performance optimizations. However, some hardware platforms may have issues with certain MSRs when used with KVM virtualization, which can cause crashes or other problems.

Update the GRUB configuration by running the following command:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Reboot the system to apply the changes.

After enabling IOMMU in GRUB, you can verify that it is working by checking the output of the dmesg | grep -e DMAR -e IOMMU command. This command should show information about the IOMMU and DMA remapping on your system.

Add GPU to Vitual Machine

Show virutual hardware details –> Add Hardware –> PCI host device –> Add all part of gpu