Last active
July 27, 2024 20:23
-
-
Save Nislaco/8eb6f0a75c2faf2b0a2b94ce6de2b783 to your computer and use it in GitHub Desktop.
Build script for WSL2-Linux-Kernel 5.15y for Ubuntu LTS guest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
BRANCH=linux-msft-wsl-5.15.y | |
if [ "$EUID" -ne 0 ]; then | |
echo "Swithing to root..." | |
exec sudo $0 "$@" | |
fi | |
apt-get install -y git dkms | |
git clone -b $BRANCH --no-checkout --depth=1 https://github.com/microsoft/WSL2-Linux-Kernel.git | |
cd WSL2-Linux-Kernel | |
git sparse-checkout set --no-cone /drivers/hv/dxgkrnl /include/uapi/misc/d3dkmthk.h | |
git checkout | |
BATCH='test' | |
RUN=$(git rev-parse --short HEAD) | |
VERSION="${RUN}${BATCH}" | |
curl -fsSL https://content.staralt.dev/dxgkrnl-dkms/main/0001-Add-a-gpu-pv-support.patch | git apply -v | |
echo | |
curl -fsSL https://content.staralt.dev/dxgkrnl-dkms/main/0002-Add-a-multiple-kernel-version-support.patch | git apply -v | |
echo | |
curl -fsSL https://content.staralt.dev/dxgkrnl-dkms/main/0003-Fix-gpadl-has-incomplete-type-error.patch | git apply -v | |
echo | |
cp -r drivers/hv/dxgkrnl /usr/src/dxgkrnl-$VERSION | |
mkdir -p /usr/src/dxgkrnl-$VERSION/include/{uapi/misc,linux} | |
cp include/uapi/misc/d3dkmthk.h /usr/src/dxgkrnl-$VERSION/include/uapi/misc/d3dkmthk.h | |
sed -i 's/\$(CONFIG_DXGKRNL)/m/' /usr/src/dxgkrnl-$VERSION/Makefile | |
echo "EXTRA_CFLAGS=-I\$(PWD)/include -D_MAIN_KERNEL_" >> /usr/src/dxgkrnl-$VERSION/Makefile | |
cat > /usr/src/dxgkrnl-$VERSION/dkms.conf <<EOF | |
PACKAGE_NAME="dxgkrnl" | |
PACKAGE_VERSION="$VERSION" | |
BUILT_MODULE_NAME="dxgkrnl" | |
DEST_MODULE_LOCATION="/kernel/drivers/hv/dxgkrnl/" | |
AUTOINSTALL="yes" | |
EOF | |
wget https://raw.githubusercontent.com/thexperiments/dxgkrnl-dkms-git/main/dxgkrnl.h.patch | |
patch -u /usr/src/dxgkrnl-$VERSION/dxgkrnl.h ./dxgkrnl.h.patch | |
sed -i 's/l(event->cpu_event, 1)/l(event->cpu_event)/g' /usr/src/dxgkrnl-$VERSION/dxgmodule.c | |
dkms add dxgkrnl/$VERSION | |
dkms build dxgkrnl/$VERSION | |
dkms install dxgkrnl/$VERSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This compiles off git for WSL kernel mod directly for ubuntu 24.04 using LTS kernel. IE 6.8.0-39-generic
Other repos used for patches:
https://github.com/thexperiments/dxgkrnl-dkms-git?tab=readme-ov-file
https://github.com/staralt/dxgkrnl-dkms
In my testing Linux GPU_PV only seems to work if all GPU's (if multiple/multi vendor) are passed through. Manually selecting one specific GPU fails when trying to initialize the card in my attempts.
Please see this GitHub for info as well as previously listed ones for info in setting up driver's files between Host and Guest as well as partitioning GPU for passthrough .
https://github.com/brokeDude2901/dxgkrnl_ubuntu?tab=readme-ov-file
Tested on a system with 3 Gpus from 2 vendors all 3 devices show as Microsoft dxg devices.
#This example works for passing through multiple gpus into ubuntu..
$gpu_list = Get-VMHostPartitionableGpu
foreach ($k in $gpu_list){
$instance_path = $k.Name
$instance_path
Add-VMGpuPartitionAdapter -VMName $vm -InstancePath $instance_path
}