Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(just): fix configure-vfio recipe #2140

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 24 additions & 25 deletions just/bluefin-system.just
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ configure-vfio ACTION="":
This is only used for GPU passthrough of a secondary dGPU.
It will enable vfio and configure kvmfr for use with $(Urllink "https://looking-glass.io" "Looking Glass")
If you do not plan to use any of this then press ESC.
EOF
${bold}NOTE:${normal} Since this is a niche use case, support will be ${b}very limited${n}
EOF
OPTION=$(Choose \
"Enable VFIO drivers" \
"Disable VFIO drivers" \
Expand All @@ -156,32 +156,31 @@ configure-vfio ACTION="":
fi
if [[ "${OPTION,,}" =~ (^enable[[:space:]]vfio|vfio-on) ]]; then
echo "Enabling VFIO..."
VIRT_TEST=$(rpm-ostree kargs)
CPU_VENDOR=$(grep "vendor_id" "/proc/cpuinfo" | uniq | awk -F": " '{ print $2 }')
VENDOR_KARG="unset"
if [[ ${VIRT_TEST} == *kvm.report_ignored_msrs* ]]; then
echo 'add_drivers+=" vfio vfio_iommu_type1 vfio-pci "' | sudo tee /etc/dracut.conf.d/vfio.conf
rpm-ostree initramfs --enable
if [[ ${CPU_VENDOR} == "AuthenticAMD" ]]; then
VENDOR_KARG="amd_iommu=on"
elif [[ ${CPU_VENDOR} == "GenuineIntel" ]]; then
VENDOR_KARG="intel_iommu=on"
fi
if [[ ${VENDOR_KARG} == "unset" ]]; then
echo "Failed to get CPU vendor, exiting..."
exit 1
else
rpm-ostree kargs \
--append-if-missing="${VENDOR_KARG}" \
--append-if-missing="iommu=pt" \
--append-if-missing="rd.driver.pre=vfio_pci" \
--append-if-missing="vfio_pci.disable_vga=1"
echo "VFIO will be enabled on next boot, make sure you enable IOMMU, VT-d or AMD-v in your BIOS!"
echo "Please understand that since this is such a niche use case, support will be very limited!"
echo "To add your unused/second GPU device ids to the vfio driver by running"
echo 'rpm-ostree kargs --append-if-missing="vfio-pci.ids=xxxx:yyyy,xxxx:yyzz"'
echo "NOTE: Your second GPU will not be usable by the host after you do this!"
fi
echo 'add_drivers+=" vfio vfio_iommu_type1 vfio-pci "' | sudo tee /etc/dracut.conf.d/vfio.conf
rpm-ostree initramfs --enable
if [[ ${CPU_VENDOR} == "AuthenticAMD" ]]; then
VENDOR_KARG="amd_iommu=on"
elif [[ ${CPU_VENDOR} == "GenuineIntel" ]]; then
VENDOR_KARG="intel_iommu=on"
fi
if [[ ${VENDOR_KARG} == "unset" ]]; then
echo "Failed to get CPU vendor, exiting..."
exit 1
else
rpm-ostree kargs \
--append-if-missing="${VENDOR_KARG}" \
--append-if-missing="iommu=pt" \
--append-if-missing="rd.driver.pre=vfio_pci" \
--append-if-missing="vfio_pci.disable_vga=1" \
--append-if-missing="kvm.ignore_msrs=1" \
--append-if-missing="kvm.report_ignored_msrs=0"
echo "VFIO will be enabled on next boot, make sure you enable IOMMU, VT-d or AMD-v in your BIOS!"
echo "Please understand that since this is such a niche use case, support will be very limited!"
echo "To add your unused/second GPU device ids to the vfio driver by running"
echo 'rpm-ostree kargs --append-if-missing="vfio-pci.ids=xxxx:yyyy,xxxx:yyzz"'
echo "NOTE: Your second GPU will not be usable by the host after you do this!"
fi
elif [[ "${OPTION,,}" =~ (^disable[[:space:]]vfio|vfio-off) ]]; then
echo ""
Expand Down
Loading