Improve virtualization

This commit is contained in:
Jafner 2021-11-15 19:58:24 -08:00
parent 1c5ef2b087
commit dd2bf2d9cb
3 changed files with 87 additions and 0 deletions

View File

@ -50,6 +50,19 @@ Open Nvidia X Server Settings, go to GPU 0 and check the VBIOS version.
Browse to https://www.techpowerup.com/vgabios/ and download the correct VBIOS file.
Rename the file to `vbios.rom`.
Actually, dump and patch your own ROM with techpowerup's nvflash and the Bless hex editor.
This will require unloading all of the nvidia kernel modules, so connect via SSH from another host.
Stop the display manager, then unload the nvidia kernel modules
`sudo systemctl stop gdm.service && sudo modprobe -r i2c_nvidia_gpu nvidia_uvm nvidia nvidia_drm`
Then dump the rom.
`sudo ./nvflash --save vbios.rom`
Reload the kernel modules and restart the display manager
`sudo modprobe i2c_nvidia_gpu nvidia_uvm nvidia nvidia_drm && sudo systemctl start gdm.service`
Open the new vbios file in Bless hex editor, search for 'VIDEO' in text mode. Delete all lines up to the `U` character on that line (exclusive). Save the patched version as `vbios_patched.rom`. Restrict its permissions with `chmod 660 vbios_patched.rom` then copy it to the share folder with `sudo cp vbios_patched.rom /usr/share/vbios/vbios.rom`
Place the VBIOS file.
```bash
sudo mkdir /usr/share/vbios && \

39
dotfiles_github/start.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
# debuggings
set -x
# stop display manager
systemctl stop display-manager.service
killall gdm-x-session
# unbind VTconsoles
echo 0 > /sys/class/vtconsole/vtcon0/bind
echo 0 > /sys/class/vtconsole/vtcon1/bind
# unbind EFI-framebuffer
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
# avoid race condition
sleep 10
# unload nvidia
modprobe -r nvidia_drm
modprobe -r nvidia_modeset
modprobe -r drm_kms_helper
modprobe -r nvidia
modprobe -r i2c_nvidia_gpu
modprobe -r drm
modprobe -r nvidia_uvm
# unbind gpu
virsh nodedev-detach pci_0000_09_00_0
virsh nodedev-detach pci_0000_09_00_1
virsh nodedev-detach pci_0000_09_00_2
virsh nodedev-detach pci_0000_09_00_3
# load vfio
modprobe vfio
modprobe vfio_pci
modprobe vfio_iommu_type1

35
dotfiles_github/stop.sh Executable file
View File

@ -0,0 +1,35 @@
# debug
set -x
# unload vfio-pci
modprobe -r vfio_pci
modprobe -r vfio_iommu_type1
modprobe -r vfio
# rebind gpu
virsh nodedev-reattach pci_0000_09_00_0
virsh nodedev-reattach pci_0000_09_00_1
virsh nodedev-reattach pci_0000_09_00_2
virsh nodedev-reattach pci_0000_09_00_3
# rebind VTconsoles
echo 1 > /sys/class/vtconsole/vtcon0/bind
echo 0 > /sys/class/vtconsole/vtcon1/bind
# read nvidia x config
nvidia-xconfig --query-gpu-info > /dev/null 2>&1
# bind EFI-framebuffer
echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
# load nvidia
modprobe nvidia_drm
modprobe nvidia_modeset
modprobe drm_kms_helper
modprobe nvidia
modprobe drm
modprobe nvidia_uvm
# restart display manager
systemctl start gdm.service