From e91b6468b34bf4049796e33b229a87f9676fa535 Mon Sep 17 00:00:00 2001 From: RootHost-Stormwind Date: Tue, 4 Nov 2025 21:53:55 +0100 Subject: [PATCH] fix second iommu --- hardware-configuration.nix | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/hardware-configuration.nix b/hardware-configuration.nix index cc00c49..0a0d26c 100644 --- a/hardware-configuration.nix +++ b/hardware-configuration.nix @@ -8,11 +8,11 @@ [ (modulesPath + "/installer/scan/not-detected.nix") ]; - # 1) Make sure vfio and vfio_pci are in the initrd - boot.initrd.kernelModules = [ "vfio" "vfio_pci" ]; + # 1) Make sure modules are available early so the probe can succeed + boot.initrd.kernelModules = [ "vfio" "vfio_pci" "vfio_iommu_type1" "ahci" ]; # 2) Also load them again in the running system - boot.kernelModules = [ "vfio" "vfio_pci" ]; + boot.kernelModules = [ "vfio" "vfio_pci" "vfio_iommu_typoe1" "ahci" ]; # 3) Kernel params to turn on IOMMU and bind your card to vfio-pci boot.kernelParams = lib.mkForce [ @@ -22,13 +22,23 @@ # helps isolate PCIe ports if your card shares groups "pci_acs_override=downstream,multifunction" - - # <<< the important bit: early vfio binding for 1b4b:9215 >>> - "vfio-pci.ids=1b4b:9215" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; + # Bind per-device via udev using driver_override and drivers_probe + services.udev.extraRules = '' + # Bind 0000:09:00.0 to vfio-pci + ACTION=="add", SUBSYSTEM=="pci", KERNEL=="0000:09:00.0", \ + ATTR{driver_override}="vfio-pci", \ + RUN+="/bin/sh -c 'modprobe vfio-pci; echo 0000:09:00.0 > /sys/bus/pci/drivers_probe'" + + # Bind 0000:08:00.0 to ahci (host) + ACTION=="add", SUBSYSTEM=="pci", KERNEL=="0000:08:00.0", \ + ATTR{driver_override}="ahci", \ + RUN+="/bin/sh -c 'modprobe ahci; echo 0000:08:00.0 > /sys/bus/pci/drivers_probe'" + ''; + boot.kernel.sysctl."net.ipv4.conf.all.forwarding" = true; swapDevices =