From 2c36feec6f7cb81160915a76733f6a934c741a89 Mon Sep 17 00:00:00 2001 From: kat witch Date: Thu, 5 Aug 2021 16:31:01 +0100 Subject: [PATCH] VFIO Profile Update --- config/hosts/samhain/nixos.nix | 14 +++++++++++++ config/profiles/base/profiles.nix | 2 ++ config/profiles/vfio/default.nix | 34 ++++++++++--------------------- config/trusted | 2 +- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/config/hosts/samhain/nixos.nix b/config/hosts/samhain/nixos.nix index ffd3e8a6..75eaac81 100644 --- a/config/hosts/samhain/nixos.nix +++ b/config/hosts/samhain/nixos.nix @@ -66,11 +66,25 @@ in { # Hardware + deploy.profile.hardware.acs-override = true; + hardware.openrazer = { enable = true; }; environment.systemPackages = [ pkgs.razergenie ]; + boot.modprobe.modules = { + vfio-pci = let + vfio-pci-ids = [ + "1002:67df" "1002:aaf0" # RX 580 + "1921:0014" # Renesas USB 3 + "1022:149c" # CPU USB 3 + ]; + in mkIf (vfio-pci-ids != [ ]) { + options.ids = concatStringsSep "," vfio-pci-ids; + }; + }; + # Networking networking = { diff --git a/config/profiles/base/profiles.nix b/config/profiles/base/profiles.nix index b82655d9..7e367895 100644 --- a/config/profiles/base/profiles.nix +++ b/config/profiles/base/profiles.nix @@ -10,6 +10,7 @@ with lib; vfio = mkEnableOption "VFIO"; trusted = mkEnableOption "Trusted Submodule"; hardware = { + acs-override = mkEnableOption "ACS IOMMU Override"; amdgpu = mkEnableOption "AMD GPU"; hcloud-imperative = mkEnableOption "Imperative Hetzner Cloud Setup"; intel = mkEnableOption "Intel CPU"; @@ -29,6 +30,7 @@ with lib; vfio = mkEnableOption "VFIO"; trusted = mkEnableOption "Trusted Submodule"; hardware = { + acs-override = mkEnableOption "ACS IOMMU Override"; amdgpu = mkEnableOption "AMD GPU"; hcloud-imperative = mkEnableOption "Imperative Hetzner Cloud Setup"; intel = mkEnableOption "Intel CPU"; diff --git a/config/profiles/vfio/default.nix b/config/profiles/vfio/default.nix index 6ae0eb05..5c5d5446 100644 --- a/config/profiles/vfio/default.nix +++ b/config/profiles/vfio/default.nix @@ -11,26 +11,22 @@ with lib; ddcutil ]; - boot.extraModulePackages = [ - (pkgs.linuxPackagesFor config.boot.kernelPackages.kernel).vendor-reset - ]; users.users.kat.extraGroups = [ "vfio" "input" "uinput" ]; users.groups = { uinput = { }; vfio = { }; }; boot = { - modprobe.modules = mkIf (config.deploy.profile.hardware.ms-7b86) { - vfio-pci = let - vfio-pci-ids = [ - "1002:67df" "1002:aaf0" # RX 580 - "1921:0014" # Renesas USB 3 - "1022:149c" # CPU USB 3 - ]; - in mkIf (vfio-pci-ids != [ ]) { - options.ids = concatStringsSep "," vfio-pci-ids; - }; - }; - kernelPatches = mkIf (config.deploy.profile.hardware.ms-7b86) [ + initrd.kernelModules = ["vfio" "vfio_iommu_type1" "vfio_pci" "vfio_virqfd"]; + kernelModules = [ "i2c-dev" ]; # i2c-dev is required for DDC/CI for screenstub + } // mkIf (config.deploy.profile.hardware.amdgpu) { + kernelParams = [ + "video=efifb:off" + ]; + extraModulePackages = [ + (pkgs.linuxPackagesFor config.boot.kernelPackages.kernel).vendor-reset + ]; + } // mkIf (config.deploy.profile.hardware.acs-override) { + kernelPatches = [ { name = "acs-patch.patch"; patch = (pkgs.fetchpatch { @@ -40,12 +36,8 @@ with lib; }); } ]; - initrd.kernelModules = ["vfio" "vfio_iommu_type1" "vfio_pci" "vfio_virqfd"]; - kernelModules = [ "i2c-dev" ]; # i2c-dev is required for DDC/CI for screenstub kernelParams = [ - "amd_iommu=on" "pci=noats" - "video=efifb:off" "pcie_acs_override=downstream,multifunction" ]; }; @@ -77,8 +69,4 @@ with lib; }]; systemd.extraConfig = "DefaultLimitMEMLOCK=infinity"; - services.xserver.deviceSection = lib.mkDefault '' - Option "TearFree" "true" - BusID "PCI:37:0:0" - ''; } diff --git a/config/trusted b/config/trusted index bf8af6c6..70c8d6bf 160000 --- a/config/trusted +++ b/config/trusted @@ -1 +1 @@ -Subproject commit bf8af6c682b0e0813e6faf6fe9412fc1a1f80b80 +Subproject commit 70c8d6bfd3e825db5edfd039d9ef75cee18ab462