Update project to use the improved ls-iommu
This commit is contained in:
parent
f3c4eea715
commit
0d53053332
8 changed files with 47 additions and 24 deletions
|
@ -8,7 +8,7 @@ does not belong to itself. Both cards must also have unique hardware ids [xxxx:y
|
|||
|
||||
"
|
||||
echo "#------------------------------------------#"
|
||||
exec "$SCRIPTDIR/utils/ls-iommu" | grep -i "vga" | cut -d " " -f 1-4,9-
|
||||
exec "$SCRIPTDIR/utils/ls-iommu" -g | cut -d " " -f 1-5,10-
|
||||
echo "#------------------------------------------#"
|
||||
|
||||
printf "
|
||||
|
|
|
@ -14,10 +14,11 @@ Optionally it may also include:
|
|||
* GPU USB Host Controller
|
||||
* GPU Serial Port
|
||||
* GPU USB Type-C UCSI Controller
|
||||
* PCI Bridge (if they are in their own IOMMU groups)
|
||||
|
||||
"
|
||||
echo "#------------------------------------------#"
|
||||
exec "$SCRIPTDIR/utils/ls-iommu" | grep -i "group $1" | cut -d " " -f 1-4,8- | perl -pe "s/\[[0-9a-f]{4}\]: //"
|
||||
exec "$SCRIPTDIR/utils/ls-iommu" -i "$1" -r | cut -d " " -f 1-5,6- | perl -pe "s/\[[0-9a-f]{4}\]: //"
|
||||
echo "#------------------------------------------#"
|
||||
|
||||
printf "
|
||||
|
@ -31,11 +32,11 @@ To return to the previous page just press ENTER without typing in anything.
|
|||
[Yy]*)
|
||||
# Get the hardware ids from the selected group
|
||||
local GPU_DEVID
|
||||
GPU_DEVID=$("$SCRIPTDIR/utils/ls-iommu" | grep -i "group $1" | perl -pe "s/.+\[([0-9a-f]{4}:[0-9a-f]{4})\].+/\1/" | perl -pe "s/\n/,/" | perl -pe "s/,$/\n/")
|
||||
GPU_DEVID=$("$SCRIPTDIR/utils/ls-iommu" -i "$1" -r --id | perl -pe "s/\n/,/" | perl -pe "s/,$/\n/")
|
||||
|
||||
# Get the PCI ids
|
||||
local PCI_ID
|
||||
PCI_ID=$("$SCRIPTDIR/utils/ls-iommu" | grep -i "group $1" | cut -d " " -f 4 | perl -pe "s/([0-9a-f]{2}:[0-9a-f]{2}.[0-9a-f]{1})\n/\"\1\" /" | perl -pe "s/\s$//")
|
||||
PCI_ID=$("$SCRIPTDIR/utils/ls-iommu" -i "$1" -r --pciaddr | perl -pe "s/([0-9a-f]{2}:[0-9a-f]{2}.[0-9a-f]{1})\n/\"\1\" /" | perl -pe "s/\s$//")
|
||||
|
||||
# Write the GPU_PCI_IDs to the config that quickemu might make use of in the future
|
||||
echo "GPU_PCI_ID=($PCI_ID)
|
||||
|
@ -43,7 +44,7 @@ USB_CTL_ID=()" > "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
|
|||
|
||||
# Get the rom PCI_ID
|
||||
local ROM_PCI_ID
|
||||
ROM_PCI_ID=$("$SCRIPTDIR/utils/ls-iommu" | grep -i "vga" | grep -i "group $1" | cut -d " " -f 4)
|
||||
ROM_PCI_ID=$("$SCRIPTDIR/utils/ls-iommu" -g | grep -iP "group\s+$1:" | cut -d " " -f 5)
|
||||
|
||||
# Get the GPU ROM
|
||||
"$SCRIPTDIR/lib/get_GPU_ROM.sh" "$ROM_PCI_ID"
|
||||
|
@ -62,10 +63,10 @@ USB_CTL_ID=()" > "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
|
|||
exec "$SCRIPTDIR/lib/set_MKINITCPIO.sh" "$GPU_DEVID"
|
||||
else
|
||||
# Bind GPU to VFIO
|
||||
"$SCRIPTDIR/lib/set_VFIO.sh" "$1"
|
||||
"$SCRIPTDIR/lib/set_VFIO.sh" "$GPU_DEVID"
|
||||
|
||||
# Configure modprobe
|
||||
"$SCRIPTDIR/lib/set_MODPROBE.sh" "$1"
|
||||
"$SCRIPTDIR/lib/set_MODPROBE.sh" "$GPU_DEVID"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
|
|
|
@ -9,7 +9,7 @@ is only needed if you intend to use other devices than just mouse and keyboard w
|
|||
|
||||
"
|
||||
echo "#------------------------------------------#"
|
||||
exec "$SCRIPTDIR/utils/ls-iommu" | grep -i "usb controller" | cut -d " " -f 1-4,8-
|
||||
exec "$SCRIPTDIR/utils/ls-iommu" | grep -i "usb controller" | cut -d " " -f 1-5,9-
|
||||
echo "#------------------------------------------#"
|
||||
printf "
|
||||
Press q to quit
|
||||
|
|
|
@ -13,7 +13,7 @@ if you do not know what you are doing.
|
|||
|
||||
"
|
||||
echo "#------------------------------------------#"
|
||||
exec "$SCRIPTDIR/utils/ls-iommu" | grep -i "group $1" | cut -d " " -f 1-4,8- | perl -pe "s/\[[0-9a-f]{4}\]: //"
|
||||
exec "$SCRIPTDIR/utils/ls-iommu" -i "$1" | cut -d " " -f 1-5,6- | perl -pe "s/ \[[0-9a-f]{4}\]: /: /"
|
||||
echo "#------------------------------------------#"
|
||||
|
||||
printf "
|
||||
|
@ -27,7 +27,7 @@ To return to the previous page just press ENTER.
|
|||
[Yy]*)
|
||||
# Get the PCI ids
|
||||
local PCI_ID
|
||||
PCI_ID=$("$SCRIPTDIR/utils/ls-iommu" | grep -i "group $1" | cut -d " " -f 4 | perl -pe "s/([0-9a-f]{2}:[0-9a-f]{2}.[0-9a-f]{1})\n/\"\1\" /" | perl -pe "s/\s$//")
|
||||
PCI_ID=$("$SCRIPTDIR/utils/ls-iommu" -i "$1" | cut -d " " -f 5 | perl -pe "s/([0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}.[0-9a-f]{1})\n/\"\1\" /" | perl -pe "s/\s$//")
|
||||
|
||||
# Replace the blank USB_CTL_ID with the PCI_ID for the usb controller the user wants to pass through
|
||||
perl -pi -e "s/USB_CTL_ID=\(\)/USB_CTL_ID=\($PCI_ID\)/" "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
|
||||
|
@ -42,7 +42,7 @@ To return to the previous page just press ENTER.
|
|||
function main () {
|
||||
SCRIPTDIR=$(dirname "$(realpath "$0")" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
|
||||
|
||||
get_USB_CTL_GROUP $1
|
||||
get_USB_CTL_GROUP "$1"
|
||||
}
|
||||
|
||||
main $1
|
||||
main "$1"
|
||||
|
|
|
@ -7,3 +7,12 @@ DEFAULT="config/etc/default"
|
|||
QUICKEMU="config/quickemu"
|
||||
DRACUT="config/etc/dracut.conf.d"
|
||||
MKINITCPIO="config/etc/mkinitcpio.conf"
|
||||
|
||||
READAPI="wget -O-"
|
||||
DOWNLOAD="wget -0 \"$SCRIPTDIR/utils/ls-iommu.tar.gz\""
|
||||
# Get the tool to use for downloading
|
||||
if [ -f "/usr/bin/curl" ];
|
||||
then
|
||||
READAPI="curl"
|
||||
DOWNLOAD="curl -JLo ls-iommu.tar.gz"
|
||||
fi
|
||||
|
|
|
@ -7,6 +7,7 @@ function set_VFIO () {
|
|||
|
||||
# Assign the GPU device ids to a variable
|
||||
GPU_DEVID="$1"
|
||||
echo $GPU_DEVID
|
||||
|
||||
# Get the kernel_args file content
|
||||
CMDLINE=$(cat "$SCRIPTDIR/config/kernel_args")
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Script from Wendell from Level1Tech
|
||||
# Originally from here: https://forum.level1techs.com/t/ubuntu-17-04-vfio-pcie-passthrough-kernel-update-4-14-rc1/119639
|
||||
for d in /sys/kernel/iommu_groups/*/devices/*; do
|
||||
n=${d#*/iommu_groups/*}; n=${n%%/*}
|
||||
printf 'IOMMU Group %s: ' "$n"
|
||||
lspci -nns "${d##*/}"
|
||||
done
|
26
vfio-setup
26
vfio-setup
|
@ -82,6 +82,26 @@ printf "
|
|||
############################################################
|
||||
"
|
||||
|
||||
if [ ! -d "$SCRIPTDIR/utils" ];
|
||||
then
|
||||
mkdir "$SCRIPTDIR/utils"
|
||||
fi
|
||||
|
||||
if [ ! -f "$SCRIPTDIR/utils/ls-iommu.tar.gz" ];
|
||||
then
|
||||
printf "Checking for newest version of ls-iommu\n"
|
||||
LS_IOMMU_VERSION=$($READAPI https://api.github.com/repos/hikariknight/ls-iommu/releases/latest | grep "tag_name" | perl -pe "s/.+\"tag_name\"\:\s+\"(\d+\.\d+\.\d+)\",/\1/")
|
||||
printf "Downloading required tool ls-iommu from https://github.com/hikariknight/ls-iommu\n"
|
||||
cd "$SCRIPTDIR/utils" || exit
|
||||
$DOWNLOAD https://github.com/HikariKnight/ls-iommu/releases/download/${LS_IOMMU_VERSION}/ls-iommu_${LS_IOMMU_VERSION}_Linux_x86_64.tar.gz
|
||||
tar -zxf "$SCRIPTDIR/utils/ls-iommu.tar.gz" --directory "$SCRIPTDIR/utils/"
|
||||
else
|
||||
if [ ! -f "$SCRIPTDIR/utils/ls-iommu" ];
|
||||
then
|
||||
tar -zxf "$SCRIPTDIR/utils/ls-iommu.tar.gz" --directory "$SCRIPTDIR/utils/"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d "$SCRIPTDIR/config" ];
|
||||
then
|
||||
rm -r "$SCRIPTDIR/config"
|
||||
|
@ -134,10 +154,10 @@ then
|
|||
fi
|
||||
|
||||
# Run ls-iommu so we can verify that IOMMU properly working
|
||||
LS_IOMMU=$("$SCRIPTDIR/utils/ls-iommu")
|
||||
LS_IOMMU=$($SCRIPTDIR/utils/ls-iommu)
|
||||
|
||||
# Detect if IOMMU is disabled (output will start with "IOMMU Group *:" if disabled)
|
||||
if [[ $LS_IOMMU =~ ^IOMMU[[:space:]]Group[[:space:]]+\*: ]];
|
||||
# Detect if IOMMU is disabled (output will be empty)
|
||||
if [[ "$LS_IOMMU" == "" ]];
|
||||
then
|
||||
# Tell user to enable IOMMU then try again
|
||||
echo "IOMMU IS NOT ENABLED!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue