initial working tree

a bit messy, but it works without me having to play around with it now.
This commit is contained in:
Lily Tsuru 2024-09-29 22:10:55 -04:00
commit 7108916b9e
14 changed files with 679 additions and 0 deletions

99
.SRCINFO Normal file
View file

@ -0,0 +1,99 @@
pkgbase = nvidia-merged
pkgver = 510.85.02
pkgrel = 1
url = https://krutavshah.github.io/GPU_Virtualization-Wiki/
arch = x86_64
groups = nvidia-merged
license = custom
makedepends = git
makedepends = rust
options = !strip
source = nvidia-drm-outputclass.conf
source = nvidia-smi
source = nvidia-vgpu.conf
source = vgpu_unlock-rs.conf
source = nvidia.rules
source = nvidia-utils.sysusers
source = https://us.download.nvidia.com/XFree86/Linux-x86_64/510.85.02/NVIDIA-Linux-x86_64-510.85.02.run
source = file://NVIDIA-Linux-x86_64-510.85.03-vgpu-kvm.run
source = git+https://github.com/VGPU-Community-Drivers/vGPU-Unlock-patcher.git#commit=a163379
source = git+https://github.com/mbilker/vgpu_unlock-rs.git#commit=6deede6
sha256sums = be99ff3def641bb900c2486cce96530394c5dc60548fc4642f19d3a4c784134d
sha256sums = 20676096714ac00d9fc993901ab275e4b0fa3f2eddc937dae395c8f4e8cb543e
sha256sums = 5ea0d9edfcf282cea9b204291716a9a4d6d522ba3a6bc28d78edf505b6dc7949
sha256sums = c85ae100a6c87c12906fd0057b77c0c4190f68434de4bc3bc89348ffc19aed61
sha256sums = 4fbfd461f939f18786e79f8dba5fdb48be9f00f2ff4b1bb2f184dbce42dd6fc3
sha256sums = d8d1caa5d72c71c6430c2a0d9ce1a674787e9272ccce28b9d5898ca24e60a167
sha256sums = 372427e633f32cff6dd76020e8ed471ef825d38878bd9655308b6efea1051090
sha256sums = 773d3a215cedf5349eff00a9b052bc961f51ce971933f154f2d2997ed68aa59a
sha256sums = SKIP
sha256sums = SKIP
pkgname = lib32-nvidia-merged-utils
pkgdesc = NVIDIA drivers utilities; patched for vGPU support w/ Rust unlock & host DRM output (32-bit)
depends = lib32-zlib
depends = lib32-gcc-libs
depends = lib32-libglvnd
depends = nvidia-merged-utils=510.85.02
optdepends = lib32-opencl-nvidia=510.85.02
provides = lib32-vulkan-driver
provides = lib32-opengl-driver
provides = lib32-nvidia-libgl
provides = lib32-nvidia-utils
conflicts = lib32-nvidia-utils
replaces = lib32-nvidia-libgl
pkgname = lib32-opencl-nvidia-merged
pkgdesc = OpenCL implemention for NVIDIA (32-bit)
depends = lib32-zlib
depends = lib32-gcc-libs
optdepends = opencl-headers: headers necessary for OpenCL development
provides = lib32-opencl-driver
provides = lib32-opencl-nvidia
conflicts = lib32-opencl-nvidia
pkgname = nvidia-merged-dkms
pkgdesc = NVIDIA drivers - module sources; patched for vGPU support w/ Rust unlock & host DRM output
depends = dkms
depends = nvidia-merged-utils=510.85.02
depends = libglvnd
provides = NVIDIA-MODULE
provides = nvidia-dkms
conflicts = nvidia-dkms
pkgname = nvidia-merged-settings
pkgdesc = Tool for configuring the NVIDIA graphics driver
depends = jansson
depends = gtk3
depends = libxv
depends = libvdpau
depends = nvidia-merged-utils=510.85.02
provides = nvidia-settings
conflicts = nvidia-settings
pkgname = nvidia-merged-utils
pkgdesc = NVIDIA drivers utilities; patched for vGPU support w/ Rust unlock & host DRM output
depends = xorg-server
depends = libglvnd
depends = egl-wayland
optdepends = nvidia-merged-settings=510.85.02: configuration tool
optdepends = xorg-server-devel: nvidia-xconfig
optdepends = opencl-nvidia-merged=510.85.02: OpenCL support
optdepends = mdevctl: mediated device configuration tool
optdepends = libvirt: virtualization engine control interface
provides = vulkan-driver
provides = opengl-driver
provides = nvidia-libgl
provides = nvidia-utils
provides = vgpu_unlock
conflicts = nvidia-libgl
conflicts = nvidia-utils
replaces = vgpu_unlock
pkgname = opencl-nvidia-merged
pkgdesc = OpenCL implemention for NVIDIA
depends = zlib
optdepends = opencl-headers: headers necessary for OpenCL development
provides = opencl-driver
provides = opencl-nvidia
conflicts = opencl-nvidia

8
.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
pkg
src
pkgs/
vgpu_unlock-rs
vGPU-Unlock-patcher
*.run
*.tar.zst
*.tar.gz

View file

@ -0,0 +1,27 @@
From 4352df1deaa6dffceed7b8088682cec2f2a158e9 Mon Sep 17 00:00:00 2001
From: modeco80 <lily.modeco80@protonmail.ch>
Date: Sun, 29 Sep 2024 21:51:38 -0400
Subject: [PATCH] Fix NVIDIA blob patch not using BASEDIR
---
patch.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/patch.sh b/patch.sh
index b57d736..d2ef8b3 100755
--- a/patch.sh
+++ b/patch.sh
@@ -508,8 +508,8 @@ echo 'OBJECT_FILES_NON_STANDARD_nv_hooks.o := y' >> ${TARGET}/kernel/nvidia/nvid
sed -i ${TARGET}/.manifest -e '/^kernel\/nvidia\/i2c_nvswitch.c / a \
kernel/unlock/nv_hooks.c 0644 KERNEL_MODULE_SRC INHERIT_PATH_DEPTH:1 MODULE:vgpu'
echo
-if [ -e patches/blob-${VER_BLOB}.diff ]; then
- blobpatch ${TARGET}/kernel/nvidia/nv-kernel.o_binary patches/blob-${VER_BLOB}.diff || exit 1
+if [ -e $BASEDIR/patches/blob-${VER_BLOB}.diff ]; then
+ blobpatch ${TARGET}/kernel/nvidia/nv-kernel.o_binary $BASEDIR/patches/blob-${VER_BLOB}.diff || exit 1
fi
applypatch ${TARGET} setup-vup-hooks.patch
applypatch ${TARGET} filter-for-nvrm-logs.patch
--
2.46.1

View file

@ -0,0 +1,34 @@
From 8b5327e6fcfb68257fe432dd9f90201ae044d900 Mon Sep 17 00:00:00 2001
From: modeco80 <lily.modeco80@protonmail.ch>
Date: Sun, 29 Sep 2024 20:09:11 -0400
Subject: [PATCH] vGPU and Desktop in harmony
---
patches/blob-535.129.03.diff | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/patches/blob-535.129.03.diff b/patches/blob-535.129.03.diff
index 7b4d0c5..3789260 100644
--- a/patches/blob-535.129.03.diff
+++ b/patches/blob-535.129.03.diff
@@ -1,11 +1,7 @@
edbc8b765436d98ec9f380fe5876f9deae57d74995667d7805148785c6b0c811
-00447270: 41 8B
-00447271: BD 8F
-00447272: 40 54
-00447273: 00 02
-031406E8: 63 25
-031406E9: 6F 64
-031406EA: 75 20
-031406EB: 6E 25
-031406EC: 74 64
-ab66c4a02251e74aca4bb7f6d9e78eb0debdc538d8cbec586866bd8568e6abd3
+004471CC: 44 41
+004471CD: 8B C7
+004471CE: AF C5
+004471CF: 58 00
+004471D0: 02 00
+2c44a70686390b29259fdefad1f344cc9b4f019114afaee9f04483e1e55c70dd
--
2.46.1

418
PKGBUILD Normal file
View file

@ -0,0 +1,418 @@
# Maintainer: Lily Tsuru <lily.modeco80@protonmail.ch>
pkgbase='nvidia-merged'
pkgname=('lib32-nvidia-merged-utils' 'lib32-opencl-nvidia-merged' 'nvidia-merged-dkms' 'nvidia-merged-settings' 'nvidia-merged-utils' 'opencl-nvidia-merged' 'vgpu-unlock-rs')
pkgrel=1
arch=('x86_64')
makedepends=('git' 'rust')
url='https://krutavshah.github.io/GPU_Virtualization-Wiki/'
license=('custom')
options=('!strip')
groups=('nvidia-merged')
# version
pkgver=535.129.03
_vgpupkgver=535.129.03
# FIXME: Do we really need to use ${CARCH}? As far as I'm aware
# the vGPU suite is x86_64 only.
_generalpkg="NVIDIA-Linux-${CARCH}-535.129.03"
_vgpupkg="NVIDIA-Linux-${CARCH}-${pkgver}-vgpu-kvm"
_patchedpkg="NVIDIA-Linux-${CARCH}-${pkgver}-merged-vgpu-kvm-patched"
# revs for git repos
_patcher_rev="3765eee908858d069e7b31842f3486095b0846b5"
_vgpu_unlock_rev="ba66a6c6eeb16eb8e2d2ec368d6605b974070d4b"
source=(
'0001-Fix-NVIDIA-blob-patch-not-using-BASEDIR.patch'
'0002-vGPU-and-Desktop-in-harmony.patch'
'nvidia-smi'
'nvidia-vgpu.conf'
'vgpu_unlock-rs.conf'
'nvidia-drm-outputclass.conf'
'nvidia-utils.sysusers'
'nvidia.rules'
'nvidia-conftest-iosys-fix.patch'
"https://us.download.nvidia.com/XFree86/Linux-${CARCH}/${pkgver}/${_generalpkg}.run"
"file://${_vgpupkg}.run"
"git+https://github.com/VGPU-Community-Drivers/vGPU-Unlock-patcher.git#commit=${_patcher_rev}"
"git+https://github.com/mbilker/vgpu_unlock-rs.git#commit=${_vgpu_unlock_rev}")
sha256sums=('ae6b1cf5cc5e177e5502ebed4b64f058524bf5514e1d6cda911e2966b2749b16'
'a66368ac6e409d002238dc6f5b1833bee1573e65386b0537bbcca9cc130b9d2a'
'eb51808257e7898d37d4575f40ada424cabf5dcad61017dd677ff5a0b25dead4'
'5ea0d9edfcf282cea9b204291716a9a4d6d522ba3a6bc28d78edf505b6dc7949'
'eafb28461fbe8a37cef3121f4b0ad53ad459ba389d9afb91e79c6c8d93ba5ea9'
'be99ff3def641bb900c2486cce96530394c5dc60548fc4642f19d3a4c784134d'
'd8d1caa5d72c71c6430c2a0d9ce1a674787e9272ccce28b9d5898ca24e60a167'
'0e54249a7754b668b436f0f7aa7e95fff68edbb12a93dbee4660e09a8c695f84'
'594339458c2208936ee12e51de515173801566256983e524d67e1da1081e2260'
'e6dca5626a2608c6bb2a046cfcb7c1af338b9e961a7dd90ac09bb8a126ff002e'
'2a53940da16c7c8bf001e5da0f53983192f4d09ec84cab713fbb424ac11df743'
'f3363d6cfef99147017329d08bedb81e473af91e7cda06d59576768a5a27b62f'
'5ac78e9c1cd940917c41db74fab893f1181559e9993ab041b07cc82d2c020b60')
create_links() {
# create soname links
find "$pkgdir" -type f -name '*.so*' ! -path '*xorg/*' -print0 | while read -d $'\0' _lib; do
_soname=$(dirname "${_lib}")/$(readelf -d "${_lib}" | grep -Po 'SONAME.*: \[\K[^]]*' || true)
_base=$(echo ${_soname} | sed -r 's/(.*)\.so.*/\1.so/')
[[ -e "${_soname}" ]] || ln -s $(basename "${_lib}") "${_soname}"
[[ -e "${_base}" ]] || ln -s $(basename "${_soname}") "${_base}"
done
}
prepare() {
pushd 'vGPU-Unlock-patcher'
git submodule init
git submodule update
#sed -e 's/if $DO_VGPU; then/if false; then/' -i patch.sh
# apply patches to the patcher (ironic)
git am ${srcdir}/0001-Fix-NVIDIA-blob-patch-not-using-BASEDIR.patch
git am ${srcdir}/0002-vGPU-and-Desktop-in-harmony.patch
popd
vGPU-Unlock-patcher/patch.sh --force-nvidia-gpl-I-know-it-is-wrong --enable-nvidia-gpl-for-experimenting general-merge
cd "${_patchedpkg}"
# patch kernel driver
patch -p1 < ../nvidia-conftest-iosys-fix.patch
# sed \
# -e 's|__UTILS_PATH__|/usr/bin|' \
# -e 's|Icon=.*|Icon=nvidia-settings|' \
# -i nvidia-settings.desktop
bsdtar -xf nvidia-persistenced-init.tar.bz2
#gunzip nvidia-{cuda-mps-control,modprobe,persistenced,settings,smi,xconfig}.1.gz
sed \
-e "s/__VERSION_STRING/${pkgver}/" \
-e 's/__JOBS/`nproc`/' \
-e 's/__DKMS_MODULES//' \
-e '$iBUILT_MODULE_NAME[0]="nvidia"\
DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\
BUILT_MODULE_NAME[1]="nvidia-uvm"\
DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\
BUILT_MODULE_NAME[2]="nvidia-modeset"\
DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\
BUILT_MODULE_NAME[3]="nvidia-drm"\
DEST_MODULE_LOCATION[3]="/kernel/drivers/video"\
BUILT_MODULE_NAME[4]="nvidia-vgpu-vfio"\
DEST_MODULE_LOCATION[4]="/kernel/drivers/video" \
BUILT_MODULE_NAME[5]="nvidia-peermem"\
DEST_MODULE_LOCATION[5]="/kernel/drivers/video"' \
-e 's/NV_EXCLUDE_BUILD_MODULES/IGNORE_PREEMPT_RT_PRESENCE=1 NV_EXCLUDE_BUILD_MODULES/' \
-i kernel/dkms.conf
}
build() {
cd "${srcdir}/vgpu_unlock-rs"
cargo build -j `nproc` --release
}
package_nvidia-merged-dkms() {
pkgdesc="NVIDIA drivers - module sources; patched for vGPU support w/ Rust unlock & host DRM output"
depends=('dkms' "nvidia-merged-utils=${pkgver}" 'libglvnd')
provides=('NVIDIA-MODULE' 'nvidia-dkms')
conflicts=('nvidia-dkms')
install -d -m755 "${pkgdir}/usr/src"
cp -dr --no-preserve='ownership' "${_patchedpkg}/kernel" "${pkgdir}/usr/src/nvidia-${pkgver}"
echo "blacklist nouveau" | install -D -m644 /dev/stdin "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf"
echo "nvidia-uvm" | install -D -m644 /dev/stdin "${pkgdir}/usr/lib/modules-load.d/${pkgname}.conf"
install -D -m644 "${_patchedpkg}/LICENSE" "${pkgdir}/usr/share/licenses/$pkgname/LICENSE"
}
package_nvidia-merged-utils() {
pkgdesc="NVIDIA drivers utilities; patched for vGPU support w/ Rust unlock & host DRM output"
depends=('xorg-server' 'libglvnd' 'egl-wayland')
optdepends=("nvidia-merged-settings=${pkgver}: configuration tool"
'xorg-server-devel: nvidia-xconfig'
"opencl-nvidia-merged=${pkgver}: OpenCL support"
'mdevctl: mediated device configuration tool'
'libvirt: virtualization engine control interface')
conflicts=('nvidia-libgl' 'nvidia-utils')
provides=('vulkan-driver' 'opengl-driver' 'nvidia-libgl' 'nvidia-utils' 'vgpu_unlock')
replaces=('vgpu_unlock')
pushd ${_patchedpkg}
# X driver
install -Dm755 nvidia_drv.so "${pkgdir}/usr/lib/xorg/modules/drivers/nvidia_drv.so"
# Wayland/GBM
install -Dm755 libnvidia-egl-gbm.so.1* -t "${pkgdir}/usr/lib/"
install -Dm644 15_nvidia_gbm.json "${pkgdir}/usr/share/egl/egl_external_platform.d/15_nvidia_gbm.json"
mkdir -p "${pkgdir}/usr/lib/gbm"
ln -sr "${pkgdir}/usr/lib/libnvidia-allocator.so.${pkgver}" "${pkgdir}/usr/lib/gbm/nvidia-drm_gbm.so"
# firmware
install -Dm644 -t "${pkgdir}/usr/lib/firmware/nvidia/${pkgver}/" firmware/*.bin
# GLX extension module for X
install -Dm755 "libglxserver_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/libglxserver_nvidia.so.${pkgver}"
# Ensure that X finds glx
ln -s "libglxserver_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/libglxserver_nvidia.so.1"
ln -s "libglxserver_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/libglxserver_nvidia.so"
install -Dm755 "libGLX_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/libGLX_nvidia.so.${pkgver}"
# OpenGL libraries
install -Dm755 "libEGL_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/libEGL_nvidia.so.${pkgver}"
install -Dm755 "libGLESv1_CM_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/libGLESv1_CM_nvidia.so.${pkgver}"
install -Dm755 "libGLESv2_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/libGLESv2_nvidia.so.${pkgver}"
install -Dm644 "10_nvidia.json" "${pkgdir}/usr/share/glvnd/egl_vendor.d/10_nvidia.json"
# OpenGL core library
install -Dm755 "libnvidia-glcore.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-glcore.so.${pkgver}"
install -Dm755 "libnvidia-eglcore.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-eglcore.so.${pkgver}"
install -Dm755 "libnvidia-glsi.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-glsi.so.${pkgver}"
# misc
install -Dm755 "libnvidia-api.so.1" "${pkgdir}/usr/lib/libnvidia-api.so.1"
install -Dm755 "libnvidia-fbc.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-fbc.so.${pkgver}"
install -Dm755 "libnvidia-encode.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-encode.so.${pkgver}"
install -Dm755 "libnvidia-cfg.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-cfg.so.${pkgver}"
install -Dm755 "libnvidia-ml.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-ml.so.${pkgver}"
install -Dm755 "libnvidia-glvkspirv.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-glvkspirv.so.${pkgver}"
install -Dm755 "libnvidia-allocator.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-allocator.so.${pkgver}"
install -Dm755 "libnvidia-vulkan-producer.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-vulkan-producer.so.${pkgver}"
# Sigh libnvidia-vulkan-producer.so has no SONAME set so create_links doesn't catch it. NVIDIA please fix!
patchelf --set-soname "libnvidia-vulkan-producer.so.1" "${pkgdir}/usr/lib/libnvidia-vulkan-producer.so.${pkgver}"
# Vulkan ICD
install -Dm644 "nvidia_icd.json" "${pkgdir}/usr/share/vulkan/icd.d/nvidia_icd.json"
install -Dm644 "nvidia_layers.json" "${pkgdir}/usr/share/vulkan/implicit_layer.d/nvidia_layers.json"
# VDPAU
install -Dm755 "libvdpau_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/vdpau/libvdpau_nvidia.so.${pkgver}"
# nvidia-tls library
install -Dm755 "libnvidia-tls.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-tls.so.${pkgver}"
# CUDA
install -Dm755 "libcuda.so.${pkgver}" "${pkgdir}/usr/lib/libcuda.so.${pkgver}"
install -Dm755 "libnvcuvid.so.${pkgver}" "${pkgdir}/usr/lib/libnvcuvid.so.${pkgver}"
install -Dm755 "libcudadebugger.so.${pkgver}" "${pkgdir}/usr/lib/libcudadebugger.so.${pkgver}"
# NVVM Compiler library loaded by the CUDA driver to do JIT link-time-optimization
install -Dm644 "libnvidia-nvvm.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-nvvm.so.${pkgver}"
# PTX JIT Compiler (Parallel Thread Execution (PTX) is a pseudo-assembly language for CUDA)
install -Dm755 "libnvidia-ptxjitcompiler.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-ptxjitcompiler.so.${pkgver}"
# raytracing
install -Dm755 "nvoptix.bin" "${pkgdir}/usr/share/nvidia/nvoptix.bin"
install -Dm755 "libnvoptix.so.${pkgver}" "${pkgdir}/usr/lib/libnvoptix.so.${pkgver}"
install -Dm755 "libnvidia-rtcore.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-rtcore.so.${pkgver}"
# NGX
install -Dm755 nvidia-ngx-updater "${pkgdir}/usr/bin/nvidia-ngx-updater"
install -Dm755 "libnvidia-ngx.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-ngx.so.${pkgver}"
install -Dm755 _nvngx.dll "${pkgdir}/usr/lib/nvidia/wine/_nvngx.dll"
install -Dm755 nvngx.dll "${pkgdir}/usr/lib/nvidia/wine/nvngx.dll"
# Optical flow
install -Dm755 "libnvidia-opticalflow.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-opticalflow.so.${pkgver}"
# Cryptography library wrapper
ls libnvidia-pkcs*
ls *openssl*
install -Dm755 "libnvidia-pkcs11.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-pkcs11.so.${pkgver}"
install -Dm755 "libnvidia-pkcs11-openssl3.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-pkcs11-openssl3.so.${pkgver}"
# Debug
install -Dm755 nvidia-debugdump "${pkgdir}/usr/bin/nvidia-debugdump"
# nvidia-xconfig
install -Dm755 nvidia-xconfig "${pkgdir}/usr/bin/nvidia-xconfig"
install -Dm644 nvidia-xconfig.1.gz "${pkgdir}/usr/share/man/man1/nvidia-xconfig.1.gz"
# nvidia-bug-report
install -Dm755 nvidia-bug-report.sh "${pkgdir}/usr/bin/nvidia-bug-report.sh"
# nvidia-smi
install -Dm644 nvidia-smi.1.gz "${pkgdir}/usr/share/man/man1/nvidia-smi.1.gz"
# nvidia-cuda-mps
install -Dm755 nvidia-cuda-mps-server "${pkgdir}/usr/bin/nvidia-cuda-mps-server"
install -Dm755 nvidia-cuda-mps-control "${pkgdir}/usr/bin/nvidia-cuda-mps-control"
install -Dm644 nvidia-cuda-mps-control.1.gz "${pkgdir}/usr/share/man/man1/nvidia-cuda-mps-control.1.gz"
# nvidia-modprobe
# This should be removed if nvidia fixed their uvm module!
install -Dm4755 nvidia-modprobe "${pkgdir}/usr/bin/nvidia-modprobe"
install -Dm644 nvidia-modprobe.1.gz "${pkgdir}/usr/share/man/man1/nvidia-modprobe.1.gz"
# nvidia-persistenced
install -Dm755 nvidia-persistenced "${pkgdir}/usr/bin/nvidia-persistenced"
install -Dm644 nvidia-persistenced.1.gz "${pkgdir}/usr/share/man/man1/nvidia-persistenced.1.gz"
install -Dm644 nvidia-persistenced-init/systemd/nvidia-persistenced.service.template "${pkgdir}/usr/lib/systemd/system/nvidia-persistenced.service"
sed -i 's/__USER__/nvidia-persistenced/' "${pkgdir}/usr/lib/systemd/system/nvidia-persistenced.service"
# application profiles
install -Dm644 nvidia-application-profiles-${pkgver}-rc "${pkgdir}/usr/share/nvidia/nvidia-application-profiles-${pkgver}-rc"
install -Dm644 nvidia-application-profiles-${pkgver}-key-documentation "${pkgdir}/usr/share/nvidia/nvidia-application-profiles-${pkgver}-key-documentation"
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/nvidia-utils/LICENSE"
install -Dm644 README.txt "${pkgdir}/usr/share/doc/nvidia/README"
install -Dm644 NVIDIA_Changelog "${pkgdir}/usr/share/doc/nvidia/NVIDIA_Changelog"
cp -r html "${pkgdir}/usr/share/doc/nvidia/"
ln -s nvidia "${pkgdir}/usr/share/doc/nvidia-utils"
popd
# nvidia-smi (needs patch. see script)
install -D -m755 "${_patchedpkg}/nvidia-smi" "${pkgdir}/usr/lib/nvidia/nvidia-smi.orig"
install -D -m755 "${srcdir}/nvidia-smi" "${pkgdir}/usr/bin/nvidia-smi"
# vGPU files
install -D -m755 "${_patchedpkg}/libnvidia-vgpu.so.${_vgpupkgver}" "${pkgdir}/usr/lib/libnvidia-vgpu.so.${_vgpupkgver}"
install -D -m755 "${_patchedpkg}/libnvidia-vgxcfg.so.${_vgpupkgver}" "${pkgdir}/usr/lib/libnvidia-vgxcfg.so.${_vgpupkgver}"
install -D -m755 "${_patchedpkg}/nvidia-vgpud" "${pkgdir}/usr/bin/nvidia-vgpud"
install -D -m755 "${_patchedpkg}/nvidia-vgpu-mgr" "${pkgdir}/usr/bin/nvidia-vgpu-mgr"
install -D -m644 "${_patchedpkg}/sriov-manage" "${pkgdir}/usr/lib/nvidia/sriov-manage"
install -D -m644 "${_patchedpkg}/vgpuConfig.xml" "${pkgdir}/usr/share/nvidia/vgpu/vgpuConfig.xml"
install -D -m644 "${_patchedpkg}/init-scripts/systemd/nvidia-vgpud.service" "${pkgdir}/usr/lib/systemd/system/nvidia-vgpud.service"
install -D -m644 "${_patchedpkg}/init-scripts/systemd/nvidia-vgpu-mgr.service" "${pkgdir}/usr/lib/systemd/system/nvidia-vgpu-mgr.service"
install -D -m644 "${srcdir}/nvidia-vgpu.conf" "${pkgdir}/usr/lib/systemd/system/libvirtd.service.d/20-nvidia-vgpu.conf"
# distro specific files must be installed in /usr/share/X11/xorg.conf.d
install -D -m644 "${srcdir}/nvidia-drm-outputclass.conf" "${pkgdir}/usr/share/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf"
install -D -m644 "${srcdir}/nvidia-utils.sysusers" "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
install -D -m644 "${srcdir}/nvidia.rules" "${pkgdir}/usr/lib/udev/rules.d/60-nvidia.rules"
create_links
install -D -m644 "${_patchedpkg}/LICENSE" "${pkgdir}/usr/share/licenses/$pkgname/LICENSE"
}
package_vgpu-unlock-rs() {
pkgdesc='vGPU unlock library'
url='https://github.com/mbilker/vgpu_unlock-rs'
arch=('x86_64')
# vgpu_unlock-rs
install -D -m755 "vgpu_unlock-rs/target/release/libvgpu_unlock_rs.so" "${pkgdir}/usr/lib/vgpu_unlock_rs/libvgpu_unlock_rs.so"
# vGPU service overrides (I think it's cleaner to put them in this package. )
install -D -m644 "${srcdir}/vgpu_unlock-rs.conf" "${pkgdir}/usr/lib/systemd/system/nvidia-vgpud.service.d/30-vgpu_unlock-rs.conf"
install -D -m644 "${srcdir}/vgpu_unlock-rs.conf" "${pkgdir}/usr/lib/systemd/system/nvidia-vgpu-mgr.service.d/30-vgpu_unlock-rs.conf"
install -D -m644 "vgpu_unlock-rs/LICENSE" "${pkgdir}/usr/share/licenses/$pkgname/LICENSE"
}
package_nvidia-merged-settings() {
pkgdesc='Tool for configuring the NVIDIA graphics driver (merged)'
url='https://github.com/NVIDIA/nvidia-settings'
arch=('x86_64')
license=('GPL2')
depends=('jansson' 'gtk3' 'libxv' 'libvdpau' 'nvidia-merged-utils' 'libxnvctrl')
# Make sure to conflict with nvidia-settings so we dont fuck up someones shit
conflicts=('nvidia-settings')
install -D -m755 "${_patchedpkg}/nvidia-settings" "${pkgdir}/usr/bin/nvidia-settings"
install -D -m644 "${_patchedpkg}/nvidia-settings.1.gz" "${pkgdir}/usr/share/man/man1/nvidia-settings.1.gz"
install -D -m644 "${_patchedpkg}/libnvidia-gtk2.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-gtk2.so.${pkgver}"
install -D -m644 "${_patchedpkg}/libnvidia-gtk3.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-gtk3.so.${pkgver}"
install -D -m644 "${_patchedpkg}/nvidia-settings.desktop" "${pkgdir}/usr/share/applications/nvidia-settings.desktop"
install -D -m644 "${_patchedpkg}/nvidia-settings.png" "${pkgdir}/usr/share/pixmaps/nvidia-settings.png"
# do the fuck around!!!
sed \
-e 's:__UTILS_PATH__:/usr/bin:' \
-e 's:__PIXMAP_PATH__:/usr/share/pixmaps:' \
-e 's/__NVIDIA_SETTINGS_DESKTOP_CATEGORIES__/Settings;HardwareSettings;/' \
-e 's/Icon=.*/Icon=nvidia-settings/' \
-i "${pkgdir}/usr/share/applications/nvidia-settings.desktop"
}
package_opencl-nvidia-merged() {
pkgdesc="opencl implemention for nvidia"
depends=('zlib' 'gcc-libs')
optdepends=('opencl-headers: headers necessary for opencl development')
provides=('opencl-driver' 'opencl-nvidia')
conflicts=('opencl-nvidia')
# opencl
install -D -m755 "${_patchedpkg}/libnvidia-opencl.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-opencl.so.${pkgver}"
install -D -m644 "${_patchedpkg}/LICENSE" "${pkgdir}/usr/share/licenses/$pkgname/license"
}
# multilib
package_lib32-nvidia-merged-utils() {
pkgdesc="NVIDIA drivers utilities; patched for vGPU support w/ Rust unlock & host DRM output (32-bit)"
depends=('lib32-zlib' 'lib32-gcc-libs' 'lib32-libglvnd' "nvidia-merged-utils=${pkgver}")
optdepends=("lib32-opencl-nvidia=${pkgver}")
provides=('lib32-vulkan-driver' 'lib32-opengl-driver' 'lib32-nvidia-libgl' 'lib32-nvidia-utils')
replaces=('lib32-nvidia-libgl')
conflicts=('lib32-nvidia-utils')
pushd "${_patchedpkg}"/32
# Check http://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/README/installedcomponents.html
# for hints on what needs to be installed where.
install -D -m755 "libGLX_nvidia.so.${pkgver}" "${pkgdir}/usr/lib32/libGLX_nvidia.so.${pkgver}"
# OpenGL libraries
install -D -m755 "libEGL_nvidia.so.${pkgver}" "${pkgdir}/usr/lib32/libEGL_nvidia.so.${pkgver}"
install -D -m755 "libGLESv1_CM_nvidia.so.${pkgver}" "${pkgdir}/usr/lib32/libGLESv1_CM_nvidia.so.${pkgver}"
install -D -m755 "libGLESv2_nvidia.so.${pkgver}" "${pkgdir}/usr/lib32/libGLESv2_nvidia.so.${pkgver}"
# OpenGL core library
install -D -m755 "libnvidia-glcore.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-glcore.so.${pkgver}"
install -D -m755 "libnvidia-eglcore.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-eglcore.so.${pkgver}"
install -D -m755 "libnvidia-glsi.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-glsi.so.${pkgver}"
# misc
install -D -m755 "libnvidia-fbc.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-fbc.so.${pkgver}"
install -D -m755 "libnvidia-encode.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-encode.so.${pkgver}"
install -D -m755 "libnvidia-ml.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-ml.so.${pkgver}"
install -D -m755 "libnvidia-glvkspirv.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-glvkspirv.so.${pkgver}"
install -D -m755 "libnvidia-allocator.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-allocator.so.${pkgver}"
# VDPAU
install -D -m755 "libvdpau_nvidia.so.${pkgver}" "${pkgdir}/usr/lib32/vdpau/libvdpau_nvidia.so.${pkgver}"
# nvidia-tls library
install -D -m755 "libnvidia-tls.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-tls.so.${pkgver}"
# CUDA
install -D -m755 "libcuda.so.${pkgver}" "${pkgdir}/usr/lib32/libcuda.so.${pkgver}"
install -D -m755 "libnvcuvid.so.${pkgver}" "${pkgdir}/usr/lib32/libnvcuvid.so.${pkgver}"
# PTX JIT Compiler (Parallel Thread Execution (PTX) is a pseudo-assembly language for CUDA)
install -D -m755 "libnvidia-ptxjitcompiler.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-ptxjitcompiler.so.${pkgver}"
# Optical flow
install -D -m755 "libnvidia-opticalflow.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-opticalflow.so.${pkgver}"
popd
create_links
install -D -m644 "${_patchedpkg}/LICENSE" "${pkgdir}/usr/share/licenses/$pkgname/LICENSE"
}
package_lib32-opencl-nvidia-merged() {
pkgdesc="opencl implemention for nvidia (32-bit)"
depends=('lib32-zlib' 'lib32-gcc-libs')
optdepends=('opencl-headers: headers necessary for opencl development')
provides=('lib32-opencl-driver' 'lib32-opencl-nvidia')
conflicts=('lib32-opencl-nvidia')
# opencl
install -D -m755 "${_patchedpkg}/32/libnvidia-opencl.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-opencl.so.${pkgver}"
create_links
install -D -m644 "${_patchedpkg}/LICENSE" "${pkgdir}/usr/share/licenses/$pkgname/LICENSE"
}

32
README.md Normal file
View file

@ -0,0 +1,32 @@
# Nvidia vGPU-Merged Packages for Arch Linux
Use Nvidia vGPU _and_ GeForce functions of consumer-grade NVIDIA GPUs.
This repository contains scripts for building all components of the "merged" driver package into drop-in replacements for the Arch Linux NVIDIA packages. It adds the following additional functions by means of scripts/drop-ins:
- Wrapper for `nvidia-smi` to support recognizing consumer GPUs as vGPU-capable
- Dependency re-ordering to ensure `libvirtd`, if installed, will start _after_ the NVIDIA vGPU services.
Compatible Linux Versions:
- Various 5.11 or older releases
- 5.12
- 5.14 except for some of the earlier 5.14 releases
- 5.15
## Important
These packages are not guaranteed to work out of the box (or at all), so use it at your own risk. Backups should be taken before attempting to replace stock NVIDIA drivers on any system.
## Installation
1. Build and install desired packages
2. Edit `/etc/vgpu_unlock/profile_override.toml` and set desired overrides.
3. Enable `nvidia-vgpu-mgr.service` and `nvidia-vgpud.service`
4. Reboot.
It is recommended to at least install `nvidia-merged` and `nvidia-merged-settings`, which will include the required services/kernel module sources by dependency.
## Credits
This project would not be possible without all those who came before me that wrote the software and figured out how to implement it:
- [DualCoder - vgpu_unlock](https://github.com/DualCoder/vgpu_unlock)
- [rupansh - twelve.patch](https://github.com/rupansh/vgpu_unlock_5.12)
- [HiFiPhile - cvgpu.c](https://gist.github.com/HiFiPhile/b3267ce1e93f15642ce3943db6e60776/)
- [Krutav Shah - vGPU_Unlock Wiki](https://docs.google.com/document/d/1pzrWJ9h-zANCtyqRgS7Vzla0Y8Ea2-5z2HEi4X75d2Q)
- [tuh8888 - libvirt_win10_vm](https://github.com/tuh8888/libvirt_win10_vm)
- [mbilker - vgpu_unlock-rs](https://github.com/mbilker/vgpu_unlock-rs)

View file

@ -0,0 +1,15 @@
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -5071,6 +5071,11 @@
CODE="
#include <drm/drm_gem.h>
+ #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
+ typedef struct iosys_map nv_sysio_map_t;
+ #else
+ typedef struct dma_buf_map nv_sysio_map_t;
+ #endif
int conftest_drm_gem_object_vmap_has_map_arg(
- struct drm_gem_object *obj, struct dma_buf_map *map) {
+ struct drm_gem_object *obj, nv_sysio_map_t *map) {
return obj->funcs->vmap(obj, map);
}"

View file

@ -0,0 +1,8 @@
Section "OutputClass"
Identifier "nvidia"
MatchDriver "nvidia-drm"
Driver "nvidia"
Option "AllowEmptyInitialConfiguration"
ModulePath "/usr/lib/nvidia/xorg"
ModulePath "/usr/lib/xorg/modules"
EndSection

12
nvidia-smi Normal file
View file

@ -0,0 +1,12 @@
#!/usr/bin/bash
for a in $*
do
case $a in
vgpu)
export LD_PRELOAD="/usr/lib/vgpu_unlock_rs/libvgpu_unlock_rs.so"
;;
esac
done
exec /usr/lib/nvidia/nvidia-smi.orig $@

9
nvidia-utils.install Normal file
View file

@ -0,0 +1,9 @@
post_upgrade() {
echo "If you run into trouble with CUDA not being available, run nvidia-modprobe first."
echo "If you use GDM on Wayland, you might have to run systemctl enable --now nvidia-resume.service"
}
# For the latter nore, see also https://gitlab.gnome.org/GNOME/gdm/-/issues/784
post_install() {
post_upgrade
}

1
nvidia-utils.sysusers Normal file
View file

@ -0,0 +1 @@
u nvidia-persistenced 143 'NVIDIA Persistence Daemon'

5
nvidia-vgpu.conf Normal file
View file

@ -0,0 +1,5 @@
[Unit]
After=nvidia-vgpud.service
After=nvidia-vgpu-mgr.service
Wants=nvidia-vgpud.service
Wants=nvidia-vgpu-mgr.service

9
nvidia.rules Normal file
View file

@ -0,0 +1,9 @@
# Device nodes are created by nvidia-modprobe, which is called by the nvidia DDX.
# In case the DDX is not started, the device nodes are never created, so call
# nvidia-modprobe in the udev rules to cover the Wayland/EGLStream and compute
# case without a started display. In the case where vfio-pci is used
# nvidia-modprobe should not be invoked.
ACTION=="add|bind", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", \
DRIVER=="nvidia", TEST!="/dev/nvidia-uvm", \
RUN+="/usr/bin/nvidia-modprobe", \
RUN+="/usr/bin/nvidia-modprobe -c0 -u"

2
vgpu_unlock-rs.conf Normal file
View file

@ -0,0 +1,2 @@
[Service]
Environment=LD_PRELOAD=/usr/lib/vgpu_unlock_rs/libvgpu_unlock_rs.so