2019-11-30 21:40:14 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# halt on any error for safety and proper pipe handling
|
|
|
|
set -euo pipefail ; # <- this semicolon and comment make options apply
|
|
|
|
# even when script is corrupt by CRLF line terminators (issue #75)
|
|
|
|
# empty line must follow this comment for immediate fail with CRLF newlines
|
|
|
|
|
2024-11-23 15:01:44 +00:00
|
|
|
# root check
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
|
|
echo
|
|
|
|
echo -e "Please run as root!"
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2019-11-30 21:40:14 +00:00
|
|
|
backup_path="/opt/nvidia/libnvidia-fbc-backup"
|
|
|
|
silent_flag=''
|
2020-11-01 22:50:29 +00:00
|
|
|
manual_driver_version=''
|
2021-09-28 19:46:43 +00:00
|
|
|
flatpak_flag=''
|
|
|
|
backup_suffix=''
|
2019-11-30 21:40:14 +00:00
|
|
|
|
|
|
|
print_usage() { printf '
|
|
|
|
SYNOPSIS
|
2021-09-28 19:46:43 +00:00
|
|
|
patch-fbc.sh [-s] [-r|-h|-c VERSION|-l|-f]
|
2019-11-30 21:40:14 +00:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
The patch for Nvidia drivers to allow FBC on consumer devices
|
|
|
|
|
|
|
|
-s Silent mode (No output)
|
|
|
|
-r Rollback to original (Restore lib from backup)
|
|
|
|
-h Print this help message
|
|
|
|
-c VERSION Check if version VERSION supported by this patch.
|
|
|
|
Returns true exit code (0) if version is supported.
|
|
|
|
-l List supported driver versions
|
2020-11-01 22:50:29 +00:00
|
|
|
-d VERSION Use VERSION driver version when looking for libraries
|
|
|
|
instead of using nvidia-smi to detect it.
|
2021-09-28 19:46:43 +00:00
|
|
|
-f Enable support for Flatpak NVIDIA drivers.
|
2024-04-05 09:16:30 +00:00
|
|
|
-j Output the patch list to stdout as JSON
|
2019-11-30 21:40:14 +00:00
|
|
|
'
|
|
|
|
}
|
|
|
|
|
|
|
|
# shellcheck disable=SC2209
|
|
|
|
opmode="patch"
|
|
|
|
|
2024-04-05 09:16:30 +00:00
|
|
|
while getopts 'rshjc:ld:f' flag; do
|
2019-11-30 21:40:14 +00:00
|
|
|
case "${flag}" in
|
|
|
|
r) opmode="${opmode}rollback" ;;
|
|
|
|
s) silent_flag='true' ;;
|
|
|
|
h) opmode="${opmode}help" ;;
|
|
|
|
c) opmode="${opmode}checkversion" ; checked_version="$OPTARG" ;;
|
|
|
|
l) opmode="${opmode}listversions" ;;
|
2020-11-01 22:50:29 +00:00
|
|
|
d) manual_driver_version="$OPTARG" ;;
|
2021-09-28 19:46:43 +00:00
|
|
|
f) flatpak_flag='true' ;;
|
2024-04-05 09:16:30 +00:00
|
|
|
j) opmode="dump" ;;
|
2019-11-30 21:40:14 +00:00
|
|
|
*) echo "Incorrect option specified in command line" ; exit 2 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $silent_flag ]]; then
|
|
|
|
exec 1> /dev/null
|
|
|
|
fi
|
|
|
|
|
2021-09-28 19:46:43 +00:00
|
|
|
if [[ $flatpak_flag ]]; then
|
|
|
|
backup_suffix='.flatpak'
|
|
|
|
echo "WARNING: Flatpak flag enabled (-f), modifying ONLY the Flatpak driver."
|
|
|
|
fi
|
|
|
|
|
2019-11-30 21:40:14 +00:00
|
|
|
declare -A patch_list=(
|
2019-12-01 18:05:20 +00:00
|
|
|
["440.26"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
|
|
|
["440.31"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
|
|
|
["440.33.01"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2019-11-30 21:40:14 +00:00
|
|
|
["440.36"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2019-12-15 09:24:48 +00:00
|
|
|
["440.43.01"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2019-12-11 21:02:25 +00:00
|
|
|
["440.44"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-01-17 20:18:03 +00:00
|
|
|
["440.48.02"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-02-16 09:13:30 +00:00
|
|
|
["440.58.01"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-02-20 07:03:36 +00:00
|
|
|
["440.58.02"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-02-03 15:59:09 +00:00
|
|
|
["440.59"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-02-28 15:13:00 +00:00
|
|
|
["440.64"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-03-10 16:02:02 +00:00
|
|
|
["440.64.00"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-03-18 13:10:17 +00:00
|
|
|
["440.66.02"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-03-19 12:33:37 +00:00
|
|
|
["440.66.03"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-03-24 18:48:59 +00:00
|
|
|
["440.66.04"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-04-03 19:37:37 +00:00
|
|
|
["440.66.08"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-04-18 15:51:02 +00:00
|
|
|
["440.66.09"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-04-24 16:20:29 +00:00
|
|
|
["440.66.11"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-05-04 19:52:41 +00:00
|
|
|
["440.66.12"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-05-11 16:22:23 +00:00
|
|
|
["440.66.14"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-05-26 20:50:58 +00:00
|
|
|
["440.66.15"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-06-23 18:12:47 +00:00
|
|
|
["440.66.17"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-04-07 13:56:13 +00:00
|
|
|
["440.82"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-06-26 13:30:46 +00:00
|
|
|
["440.95.01"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
|
|
|
["440.100"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-10-28 18:48:05 +00:00
|
|
|
["440.118.02"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-06-06 09:06:54 +00:00
|
|
|
["450.36.06"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-06-24 17:33:38 +00:00
|
|
|
["450.51"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-07-07 22:33:02 +00:00
|
|
|
["450.51.05"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-07-25 10:00:58 +00:00
|
|
|
["450.51.06"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-07-16 15:03:50 +00:00
|
|
|
["450.56.01"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-07-20 18:01:58 +00:00
|
|
|
["450.56.02"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-08-07 19:11:08 +00:00
|
|
|
["450.56.06"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-08-17 15:51:54 +00:00
|
|
|
["450.56.11"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-07-09 13:32:25 +00:00
|
|
|
["450.57"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-09-22 05:43:18 +00:00
|
|
|
["450.66"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-10-04 18:02:17 +00:00
|
|
|
["450.80.02"]='s/\x85\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/\x31\xc0\x89\xc3\x0f\x85\xa9\xfa\xff\xff/'
|
2020-09-22 05:43:18 +00:00
|
|
|
["455.23.04"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2020-09-23 20:13:03 +00:00
|
|
|
["455.23.05"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2020-10-10 12:34:58 +00:00
|
|
|
["455.26.01"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2020-10-20 20:52:02 +00:00
|
|
|
["455.26.02"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2020-10-08 19:50:12 +00:00
|
|
|
["455.28"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2020-10-29 20:55:59 +00:00
|
|
|
["455.32.00"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2020-10-29 20:23:38 +00:00
|
|
|
["455.38"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2020-11-17 18:42:05 +00:00
|
|
|
["455.45.01"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2020-11-17 19:15:28 +00:00
|
|
|
["455.46.01"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2020-12-14 22:54:46 +00:00
|
|
|
["455.46.02"]='s/\x83\xf8\x01\x0f\x84\x83/\x83\xf8\x69\x0f\x84\x83/'
|
2021-01-22 01:08:56 +00:00
|
|
|
["455.46.04"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
|
|
|
["455.50.02"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2021-01-26 20:05:14 +00:00
|
|
|
["455.50.03"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2021-01-28 02:33:07 +00:00
|
|
|
["455.50.04"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2021-02-03 02:27:57 +00:00
|
|
|
["455.50.05"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2021-02-15 21:22:26 +00:00
|
|
|
["455.50.07"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2021-03-05 23:29:01 +00:00
|
|
|
["455.50.10"]='s/\x83\xf8\x01\x0f\x84\x85/\x83\xf8\x69\x0f\x84\x85/'
|
2021-01-16 11:14:13 +00:00
|
|
|
["460.27.04"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
|
|
|
["460.32.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-01-26 20:05:14 +00:00
|
|
|
["460.39"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-02-25 20:15:49 +00:00
|
|
|
["460.56"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-03-18 14:41:30 +00:00
|
|
|
["460.67"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-04-14 21:00:23 +00:00
|
|
|
["460.73.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-05-11 13:43:09 +00:00
|
|
|
["460.80"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-06-04 07:48:58 +00:00
|
|
|
["460.84"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-07-21 23:55:33 +00:00
|
|
|
["460.91.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-03-30 16:01:11 +00:00
|
|
|
["465.19.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-04-14 21:00:23 +00:00
|
|
|
["465.24.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-04-29 14:39:06 +00:00
|
|
|
["465.27"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-05-18 13:53:38 +00:00
|
|
|
["465.31"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-06-22 17:55:55 +00:00
|
|
|
["470.42.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-07-19 13:55:16 +00:00
|
|
|
["470.57.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-09-20 13:50:53 +00:00
|
|
|
["470.62.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-10-19 23:03:08 +00:00
|
|
|
["470.62.05"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-08-10 21:07:18 +00:00
|
|
|
["470.63.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-09-20 19:20:32 +00:00
|
|
|
["470.74"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-11-09 12:39:13 +00:00
|
|
|
["470.82.00"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-12-23 08:55:54 +00:00
|
|
|
["470.82.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-11-18 12:38:19 +00:00
|
|
|
["470.86"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-12-23 09:04:51 +00:00
|
|
|
["470.94"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-02-05 21:11:20 +00:00
|
|
|
["470.103.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-05-18 03:55:25 +00:00
|
|
|
["470.129.06"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-08-03 16:47:06 +00:00
|
|
|
["470.141.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-11-24 12:27:38 +00:00
|
|
|
["470.161.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-03-30 17:55:40 +00:00
|
|
|
["470.182.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-06-26 21:33:13 +00:00
|
|
|
["470.199.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-11-05 09:17:18 +00:00
|
|
|
["470.223.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2024-02-22 21:12:34 +00:00
|
|
|
["470.239.06"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2024-06-14 10:43:04 +00:00
|
|
|
["470.256.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-10-28 21:25:48 +00:00
|
|
|
["495.29.05"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-11-08 12:57:10 +00:00
|
|
|
["495.44"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2021-12-14 15:02:30 +00:00
|
|
|
["495.46"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-01-18 20:14:47 +00:00
|
|
|
["510.39.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-02-05 17:24:28 +00:00
|
|
|
["510.47.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-02-15 18:06:11 +00:00
|
|
|
["510.54"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-03-23 13:01:04 +00:00
|
|
|
["510.60.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-04-30 04:59:18 +00:00
|
|
|
["510.68.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-05-18 16:01:38 +00:00
|
|
|
["510.73.05"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-06-28 16:38:05 +00:00
|
|
|
["510.73.08"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-08-03 16:51:30 +00:00
|
|
|
["510.85.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-12-13 18:32:06 +00:00
|
|
|
["510.108.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-05-12 12:40:22 +00:00
|
|
|
["515.43.04"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-05-31 20:59:42 +00:00
|
|
|
["515.48.07"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-06-28 16:38:05 +00:00
|
|
|
["515.57"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-08-02 16:44:48 +00:00
|
|
|
["515.65.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-09-21 07:03:17 +00:00
|
|
|
["515.76"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-12-05 16:21:45 +00:00
|
|
|
["515.86.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-04-21 13:55:18 +00:00
|
|
|
["515.105.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-10-15 07:55:38 +00:00
|
|
|
["520.56.06"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-10-15 12:15:02 +00:00
|
|
|
["520.61.05"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-11-29 17:04:04 +00:00
|
|
|
["525.60.11"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2022-12-10 15:54:31 +00:00
|
|
|
["525.60.13"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-01-06 08:36:52 +00:00
|
|
|
["525.78.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-01-23 07:27:28 +00:00
|
|
|
["525.85.05"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-02-04 22:20:19 +00:00
|
|
|
["525.85.12"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-02-11 10:35:53 +00:00
|
|
|
["525.89.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-04-16 08:08:09 +00:00
|
|
|
["525.105.17"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-05-03 08:00:14 +00:00
|
|
|
["525.116.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-06-03 15:42:18 +00:00
|
|
|
["525.116.04"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-07-02 13:01:53 +00:00
|
|
|
["525.125.06"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-11-02 03:41:53 +00:00
|
|
|
["525.147.05"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-03-01 08:15:10 +00:00
|
|
|
["530.30.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-03-24 17:01:35 +00:00
|
|
|
["530.41.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-06-02 09:32:07 +00:00
|
|
|
["535.43.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2024-02-03 10:16:41 +00:00
|
|
|
["535.43.25"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-06-16 19:39:47 +00:00
|
|
|
["535.54.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x00\x72\x08\x48/'
|
2023-07-20 04:13:50 +00:00
|
|
|
["535.86.05"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2023-08-10 09:31:59 +00:00
|
|
|
["535.86.10"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
|
|
|
["535.98"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2023-08-24 10:19:22 +00:00
|
|
|
["535.104.05"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2023-09-27 10:12:26 +00:00
|
|
|
["535.104.12"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2023-09-26 10:03:42 +00:00
|
|
|
["535.113.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2023-11-01 14:52:45 +00:00
|
|
|
["535.129.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2023-12-08 10:10:41 +00:00
|
|
|
["535.146.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-01-17 02:32:29 +00:00
|
|
|
["535.154.05"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-02-24 15:39:37 +00:00
|
|
|
["535.161.07"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-04-15 05:27:11 +00:00
|
|
|
["535.161.08"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-04-16 16:11:50 +00:00
|
|
|
["535.171.04"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-06-24 05:09:58 +00:00
|
|
|
["535.183.01"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-09-09 17:36:14 +00:00
|
|
|
["535.183.06"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-12-01 16:19:11 +00:00
|
|
|
["535.216.03"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2023-10-18 16:37:34 +00:00
|
|
|
["545.23.06"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2023-11-21 09:41:19 +00:00
|
|
|
["545.23.08"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2023-11-01 18:14:24 +00:00
|
|
|
["545.29.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2023-11-23 04:07:58 +00:00
|
|
|
["545.29.06"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-01-25 04:12:03 +00:00
|
|
|
["550.40.07"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-02-24 15:36:10 +00:00
|
|
|
["550.54.14"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-03-25 10:20:39 +00:00
|
|
|
["550.54.15"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-03-25 10:21:47 +00:00
|
|
|
["550.67"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-04-20 19:33:53 +00:00
|
|
|
["550.76"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-04-29 16:58:03 +00:00
|
|
|
["550.78"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-06-14 10:47:47 +00:00
|
|
|
["550.90.07"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-07-18 11:40:39 +00:00
|
|
|
["550.100"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-08-10 06:47:15 +00:00
|
|
|
["550.107.02"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-10-04 16:38:52 +00:00
|
|
|
["550.120"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-10-31 12:46:04 +00:00
|
|
|
["550.127.05"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-12-01 16:20:00 +00:00
|
|
|
["550.135"]='s/\x83\xfe\x01\x73\x08\x48/\x83\xfe\x01\x90\x90\x48/'
|
2024-06-06 00:48:36 +00:00
|
|
|
["555.42.02"]='s/\x85\xc0\x0f\x85\x9b\x00\x00\x00\x48/\x85\xc0\x90\x90\x90\x90\x90\x90\x48/g'
|
|
|
|
["555.52.04"]='s/\x85\xc0\x0f\x85\x9b\x00\x00\x00\x48/\x85\xc0\x90\x90\x90\x90\x90\x90\x48/g'
|
2024-06-27 18:39:57 +00:00
|
|
|
["555.58"]='s/\x85\xc0\x0f\x85\x9b\x00\x00\x00\x48/\x85\xc0\x90\x90\x90\x90\x90\x90\x48/g'
|
2024-07-03 23:05:41 +00:00
|
|
|
["555.58.02"]='s/\x85\xc0\x0f\x85\x9b\x00\x00\x00\x48/\x85\xc0\x90\x90\x90\x90\x90\x90\x48/g'
|
2024-08-31 01:05:25 +00:00
|
|
|
["560.28.03"]='s/\x85\xc0\x0f\x84\x9b\x00\x00\x00\x48/\x85\xc0\x90\x90\x90\x90\x90\x90\x48/g'
|
2024-08-24 01:58:10 +00:00
|
|
|
["560.35.03"]='s/\x85\xc0\x0f\x84\x9b\x00\x00\x00\x48/\x85\xc0\x90\x90\x90\x90\x90\x90\x48/g'
|
2024-10-24 16:46:09 +00:00
|
|
|
["565.57.01"]='s/\x85\xc0\x0f\x84\x9b\x00\x00\x00\x48/\x85\xc0\x90\x90\x90\x90\x90\x90\x48/g'
|
2019-11-30 21:40:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
check_version_supported () {
|
|
|
|
local ver="$1"
|
2023-11-01 17:25:16 +00:00
|
|
|
[[ "${patch_list[$ver]+isset}" ]]
|
2019-11-30 21:40:14 +00:00
|
|
|
}
|
|
|
|
|
2021-09-28 19:46:43 +00:00
|
|
|
get_flatpak_driver_path () {
|
|
|
|
# Flatpak's package versioning replaces '.' by '-'
|
|
|
|
version="$(echo "$1" | tr '.' '-')"
|
2023-08-26 00:15:06 +00:00
|
|
|
# Attempts to patch system flatpak
|
2021-09-28 19:46:43 +00:00
|
|
|
if path=$(flatpak info --show-location "org.freedesktop.Platform.GL.nvidia-${version}" 2>/dev/null); then
|
|
|
|
echo "$path/files/lib"
|
2023-08-26 00:15:06 +00:00
|
|
|
# If it isn't found will login as the user that envoked sudo & patch this version
|
|
|
|
elif path=$(su -c - ${SUDO_USER} 'flatpak info --show-location "org.freedesktop.Platform.GL.nvidia-'${version}'"'); then
|
|
|
|
echo "$path/files/lib"
|
2021-09-28 19:46:43 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-11-30 21:40:14 +00:00
|
|
|
get_supported_versions () {
|
|
|
|
for drv in "${!patch_list[@]}"; do
|
2023-11-01 17:25:16 +00:00
|
|
|
echo "$drv"
|
2019-11-30 21:40:14 +00:00
|
|
|
done | sort -t. -n
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
patch_common () {
|
|
|
|
NVIDIA_SMI="$(command -v nvidia-smi || true)"
|
|
|
|
if [[ ! "$NVIDIA_SMI" ]] ; then
|
|
|
|
echo 'nvidia-smi utility not found. Probably driver is not installed.'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-11-01 22:50:29 +00:00
|
|
|
if [[ "$manual_driver_version" ]]; then
|
|
|
|
driver_version="$manual_driver_version"
|
|
|
|
|
|
|
|
echo "Using manually entered nvidia driver version: $driver_version"
|
|
|
|
else
|
|
|
|
cmd="$NVIDIA_SMI --query-gpu=driver_version --format=csv,noheader,nounits"
|
2021-01-02 01:47:31 +00:00
|
|
|
driver_versions_list=$($cmd) || (
|
|
|
|
ret_code=$?
|
2020-11-01 22:50:29 +00:00
|
|
|
echo "Can not detect nvidia driver version."
|
|
|
|
echo "CMD: \"$cmd\""
|
|
|
|
echo "Result: \"$driver_versions_list\""
|
|
|
|
echo "nvidia-smi retcode: $ret_code"
|
|
|
|
exit 1
|
2021-01-02 01:47:31 +00:00
|
|
|
)
|
|
|
|
driver_version=$(echo "$driver_versions_list" | head -n 1)
|
2020-11-01 22:50:29 +00:00
|
|
|
|
|
|
|
echo "Detected nvidia driver version: $driver_version"
|
2019-11-30 21:40:14 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if ! check_version_supported "$driver_version" ; then
|
|
|
|
echo "Patch for this ($driver_version) nvidia driver not found."
|
|
|
|
echo "Patch is available for versions: "
|
|
|
|
get_supported_versions
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
patch="${patch_list[$driver_version]}"
|
2023-11-01 17:25:16 +00:00
|
|
|
object='libnvidia-fbc.so'
|
2019-11-30 21:40:14 +00:00
|
|
|
|
2021-09-28 19:46:43 +00:00
|
|
|
if [[ $flatpak_flag ]]; then
|
|
|
|
driver_dir=$(get_flatpak_driver_path "$driver_version")
|
|
|
|
if [ -z "$driver_dir" ]; then
|
|
|
|
echo "ERROR: Flatpak package for driver $driver_version does not appear to be installed."
|
|
|
|
echo "Try rebooting your computer and/or running 'flatpak update'."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# return early because the code below is out of scope for the Flatpak driver
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2019-11-30 21:40:14 +00:00
|
|
|
declare -a driver_locations=(
|
|
|
|
'/usr/lib/x86_64-linux-gnu'
|
|
|
|
'/usr/lib/x86_64-linux-gnu/nvidia/current/'
|
2023-07-07 04:31:35 +00:00
|
|
|
'/usr/lib/x86_64-linux-gnu/nvidia/tesla/'
|
|
|
|
"/usr/lib/x86_64-linux-gnu/nvidia/tesla-${driver_version%%.*}/"
|
2019-11-30 21:40:14 +00:00
|
|
|
'/usr/lib64'
|
2022-09-27 14:02:37 +00:00
|
|
|
'/usr/lib'
|
2019-11-30 21:40:14 +00:00
|
|
|
"/usr/lib/nvidia-${driver_version%%.*}"
|
|
|
|
)
|
|
|
|
|
|
|
|
dir_found=''
|
|
|
|
for driver_dir in "${driver_locations[@]}" ; do
|
|
|
|
if [[ -e "$driver_dir/$object.$driver_version" ]]; then
|
|
|
|
dir_found='true'
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
[[ "$dir_found" ]] || { echo "ERROR: cannot detect driver directory"; exit 1; }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-06-26 22:18:06 +00:00
|
|
|
ensure_bytes_are_valid () {
|
|
|
|
driver_file="$driver_dir/$object.$driver_version"
|
|
|
|
original_bytes=$(awk -F / '$2 { print $2 }' <<< "$patch")
|
|
|
|
patched_bytes=$(awk -F / '$3 { print $3 }' <<< "$patch")
|
|
|
|
if LC_ALL=C grep -qaP "$original_bytes" "$driver_file"; then
|
|
|
|
return 0 # file is ready to be patched
|
|
|
|
fi
|
|
|
|
if LC_ALL=C grep -qaP "$patched_bytes" "$driver_file"; then
|
|
|
|
return 0 # file is likely patched already
|
|
|
|
fi
|
|
|
|
echo "Error: Could not find bytes '$original_bytes' to patch in '$driver_file'."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2019-11-30 21:40:14 +00:00
|
|
|
rollback () {
|
|
|
|
patch_common
|
2021-09-28 19:46:43 +00:00
|
|
|
if [[ -f "$backup_path/$object.$driver_version$backup_suffix" ]]; then
|
|
|
|
cp -p "$backup_path/$object.$driver_version$backup_suffix" \
|
2019-11-30 21:40:14 +00:00
|
|
|
"$driver_dir/$object.$driver_version"
|
2021-09-28 19:46:43 +00:00
|
|
|
echo "Restore from backup $object.$driver_version$backup_suffix"
|
2019-11-30 21:40:14 +00:00
|
|
|
else
|
|
|
|
echo "Backup not found. Try to patch first."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
patch () {
|
|
|
|
patch_common
|
2023-06-26 22:18:06 +00:00
|
|
|
ensure_bytes_are_valid
|
2021-09-28 19:46:43 +00:00
|
|
|
if [[ -f "$backup_path/$object.$driver_version$backup_suffix" ]]; then
|
|
|
|
bkp_hash="$(sha1sum "$backup_path/$object.$driver_version$backup_suffix" | cut -f1 -d\ )"
|
2019-11-30 21:40:14 +00:00
|
|
|
drv_hash="$(sha1sum "$driver_dir/$object.$driver_version" | cut -f1 -d\ )"
|
|
|
|
if [[ "$bkp_hash" != "$drv_hash" ]] ; then
|
|
|
|
echo "Backup exists and driver file differ from backup. Skipping patch."
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Attention! Backup not found. Copying current $object to backup."
|
|
|
|
mkdir -p "$backup_path"
|
|
|
|
cp -p "$driver_dir/$object.$driver_version" \
|
2021-09-28 19:46:43 +00:00
|
|
|
"$backup_path/$object.$driver_version$backup_suffix"
|
2019-11-30 21:40:14 +00:00
|
|
|
fi
|
2021-09-28 19:46:43 +00:00
|
|
|
sha1sum "$backup_path/$object.$driver_version$backup_suffix"
|
|
|
|
sed "$patch" "$backup_path/$object.$driver_version$backup_suffix" > \
|
2019-11-30 21:40:14 +00:00
|
|
|
"${PATCH_OUTPUT_DIR-$driver_dir}/$object.$driver_version"
|
|
|
|
sha1sum "${PATCH_OUTPUT_DIR-$driver_dir}/$object.$driver_version"
|
|
|
|
ldconfig
|
|
|
|
echo "Patched!"
|
|
|
|
}
|
|
|
|
|
|
|
|
query_version_support () {
|
|
|
|
if check_version_supported "$checked_version" ; then
|
|
|
|
echo "SUPPORTED"
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "NOT SUPPORTED"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
list_supported_versions () {
|
|
|
|
get_supported_versions
|
|
|
|
}
|
|
|
|
|
2024-04-05 09:16:30 +00:00
|
|
|
dump_patches () {
|
|
|
|
for i in "${!patch_list[@]}"
|
|
|
|
do
|
|
|
|
echo "$i"
|
|
|
|
echo "${patch_list[$i]}"
|
|
|
|
done |
|
|
|
|
jq --sort-keys -n -R 'reduce inputs as $i ({}; . + { ($i): (input|(tonumber? // .)) })'
|
|
|
|
}
|
|
|
|
|
2019-11-30 21:40:14 +00:00
|
|
|
case "${opmode}" in
|
|
|
|
patch) patch ;;
|
|
|
|
patchrollback) rollback ;;
|
|
|
|
patchhelp) print_usage ; exit 2 ;;
|
|
|
|
patchcheckversion) query_version_support ;;
|
|
|
|
patchlistversions) list_supported_versions ;;
|
2024-04-05 09:16:30 +00:00
|
|
|
dump) dump_patches ;;
|
2019-11-30 21:40:14 +00:00
|
|
|
*) echo "Incorrect combination of flags. Use option -h to get help."
|
|
|
|
exit 2 ;;
|
|
|
|
esac
|