VFIO passthrough on optimus laptop?

I have an Optimus laptop with 2 GPUs(AMD+Nvidia). I need windows to play a few games with A/C issues. I can choose my GPU using optimus-manager. Is there any way I can use the VFIO scripts or pass my GPU to a Windows VM? Or is dual booting the best bet?
inxi -Fzza

System:    Kernel: 5.10.15-120-tkg-bmq x86_64 bits: 64 compiler: gcc v: 10.2.1 
           parameters: intel_pstate=passive BOOT_IMAGE=/@/boot/vmlinuz-linux-tkg-bmq 
           root=UUID=f2947d3f-0ce7-4b11-8892-ceb656679574 rw rootflags=subvol=@ quiet splash rd.udev.log_priority=3 
           vt.global_cursor_default=0 systemd.unified_cgroup_hierarchy=1 loglevel=3 optimus-manager.startup=hybrid 
           Desktop: KDE Plasma 5.21.0 tk: Qt 5.15.2 info: latte-dock wm: kwin_x11 dm: SDDM Distro: Garuda Linux 
Machine:   Type: Laptop System: ASUSTeK product: TUF Gaming FX505DD_FX505DD v: 1.0 serial: <filter> 
           Mobo: ASUSTeK model: FX505DD v: 1.0 serial: <filter> UEFI: American Megatrends v: FX505DD.315 date: 09/22/2020 
Battery:   ID-1: BAT0 charge: 41.9 Wh condition: 42.2/50.6 Wh (83%) volts: 12.7/12.3 model: FX50442 type: Li-ion serial: N/A 
           status: Charging 
           Device-1: hidpp_battery_1 model: Logitech Wireless Mouse serial: <filter> charge: 55% (should be ignored) 
           rechargeable: yes status: Discharging 
CPU:       Info: Quad Core model: AMD Ryzen 5 3550H with Radeon Vega Mobile Gfx bits: 64 type: MT MCP arch: Zen/Zen+ 
           note: check family: 17 (23) model-id: 18 (24) stepping: 1 microcode: 8108102 L2 cache: 2 MiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 33569 
           Speed: 1355 MHz min/max: 1400/2100 MHz boost: disabled Core speeds (MHz): 1: 1355 2: 1223 3: 1289 4: 1229 5: 1267 
           6: 1389 7: 1270 8: 1183 
           Vulnerabilities: Type: itlb_multihit status: Not affected 
           Type: l1tf status: Not affected 
           Type: mds status: Not affected 
           Type: meltdown status: Not affected 
           Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl and seccomp 
           Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization 
           Type: spectre_v2 mitigation: Full AMD retpoline, IBPB: conditional, STIBP: disabled, RSB filling 
           Type: srbds status: Not affected 
           Type: tsx_async_abort status: Not affected 
Graphics:  Device-1: NVIDIA GP107M [GeForce GTX 1050 3 GB Max-Q] driver: nvidia v: 460.39 alternate: nouveau,nvidia_drm 
           bus ID: 01:00.0 chip ID: 10de:1c91 class ID: 0300 
           Device-2: Advanced Micro Devices [AMD/ATI] Picasso vendor: ASUSTeK driver: amdgpu v: kernel bus ID: 05:00.0 
           chip ID: 1002:15d8 class ID: 0300 
           Device-3: IMC Networks USB2.0 HD UVC WebCam type: USB driver: uvcvideo bus ID: 3-1:2 chip ID: 13d3:56a2 
           class ID: 0e02 serial: <filter> 
           Display: x11 server: X.Org 1.20.10 compositor: kwin_x11 driver: loaded: modesetting,nvidia display ID: :0 
           screens: 1 
           Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.0x11.2") s-diag: 582mm (22.9") 
           Monitor-1: eDP-1 res: 1920x1080 hz: 120 dpi: 142 size: 344x194mm (13.5x7.6") diag: 395mm (15.5") 
           OpenGL: renderer: AMD Radeon Vega 8 Graphics (RAVEN DRM 3.40.0 5.10.15-120-tkg-bmq LLVM 11.1.0) v: 4.6 Mesa 20.3.4 
           direct render: Yes 
Audio:     Device-1: Advanced Micro Devices [AMD] Family 17h HD Audio vendor: ASUSTeK driver: snd_hda_intel v: kernel 
           bus ID: 05:00.6 chip ID: 1022:15e3 class ID: 0403 
           Device-2: GN Netcom Jabra EVOLVE 20 MS type: USB driver: jabra,snd-usb-audio,usbhid bus ID: 1-3:2 
           chip ID: 0b0e:0300 class ID: 0300 serial: <filter> 
           Sound Server: ALSA v: k5.10.15-120-tkg-bmq 
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: ASUSTeK driver: r8169 v: kernel port: e000 
           bus ID: 02:00.0 chip ID: 10ec:8168 class ID: 0200 
           IF: enp2s0 state: down mac: <filter> 
           Device-2: Realtek RTL8822BE 802.11a/b/g/n/ac WiFi adapter vendor: AzureWave driver: rtw_8822be v: N/A 
           modules: rtw88_8822be port: d000 bus ID: 04:00.0 chip ID: 10ec:b822 class ID: 0280 
           IF: wlp4s0 state: up mac: <filter> 
Bluetooth: Device-1: IMC Networks Bluetooth Radio type: USB driver: btusb v: 0.8 bus ID: 1-4:3 chip ID: 13d3:3526 
           class ID: e001 serial: <filter> 
           Message: Required tool hciconfig not installed. Check --recommends 
Drives:    Local Storage: total: 1.14 TiB used: 343.93 GiB (29.4%) 
           SMART Message: Unable to run smartctl. Root privileges required. 
           ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Western Digital model: PC SN520 SDAPNUW-256G-1002 size: 238.47 GiB 
           block size: physical: 512 B logical: 512 B speed: 15.8 Gb/s lanes: 2 rotation: SSD serial: <filter> rev: 20110000 
           temp: 44.9 C scheme: GPT 
           ID-2: /dev/sda maj-min: 8:0 vendor: Seagate model: ST1000LM035-1RK172 size: 931.51 GiB block size: physical: 4096 B 
           logical: 512 B speed: 6.0 Gb/s rotation: 5400 rpm serial: <filter> rev: SDM4 scheme: GPT 
Partition: ID-1: / raw size: 179.39 GiB size: 179.39 GiB (100.00%) used: 114.81 GiB (64.0%) fs: btrfs dev: /dev/nvme0n1p2 
           maj-min: 259:2 
           ID-2: /boot/efi raw size: 500 MiB size: 499 MiB (99.80%) used: 98.4 MiB (19.7%) fs: vfat dev: /dev/nvme0n1p1 
           maj-min: 259:1 
           ID-3: /home raw size: 179.39 GiB size: 179.39 GiB (100.00%) used: 114.81 GiB (64.0%) fs: btrfs dev: /dev/nvme0n1p2 
           maj-min: 259:2 
           ID-4: /var/log raw size: 179.39 GiB size: 179.39 GiB (100.00%) used: 114.81 GiB (64.0%) fs: btrfs 
           dev: /dev/nvme0n1p2 maj-min: 259:2 
           ID-5: /var/tmp raw size: 179.39 GiB size: 179.39 GiB (100.00%) used: 114.81 GiB (64.0%) fs: btrfs 
           dev: /dev/nvme0n1p2 maj-min: 259:2 
Swap:      Kernel: swappiness: 10 (default 60) cache pressure: 75 (default 100) 
           ID-1: swap-1 type: zram size: 1.89 GiB used: 1.1 MiB (0.1%) priority: 32767 dev: /dev/zram0 
           ID-2: swap-2 type: zram size: 1.89 GiB used: 608 KiB (0.0%) priority: 32767 dev: /dev/zram1 
           ID-3: swap-3 type: zram size: 1.89 GiB used: 668 KiB (0.0%) priority: 32767 dev: /dev/zram2 
           ID-4: swap-4 type: zram size: 1.89 GiB used: 580 KiB (0.0%) priority: 32767 dev: /dev/zram3 
           ID-5: swap-5 type: zram size: 1.89 GiB used: 368 KiB (0.0%) priority: 32767 dev: /dev/zram4 
           ID-6: swap-6 type: zram size: 1.89 GiB used: 952 KiB (0.0%) priority: 32767 dev: /dev/zram5 
           ID-7: swap-7 type: zram size: 1.89 GiB used: 740 KiB (0.0%) priority: 32767 dev: /dev/zram6 
           ID-8: swap-8 type: zram size: 1.89 GiB used: 540 KiB (0.0%) priority: 32767 dev: /dev/zram7 
Sensors:   System Temperatures: cpu: 62.5 C mobo: N/A gpu: amdgpu temp: 62.0 C 
           Fan Speeds (RPM): cpu: 3100 
Info:      Processes: 297 Uptime: 1h 33m wakeups: 17 Memory: 15.14 GiB used: 4.95 GiB (32.7%) Init: systemd v: 247 Compilers: 
           gcc: 10.2.0 clang: 11.1.0 Packages: pacman: 1793 lib: 541 Shell: Zsh v: 5.8 running in: konsole inxi: 3.3.01 

I assume you’re asking about this because you’ve already done some basic research or have prior knowledge, so to confirm, you can use the same approaches as any other Arch-derived distribution.

5 Likes

You would have to determine if the graphics cards are in different IOMMU Groups. Otherwise you will need a kernel with the acs patch.

Anyways, it is kind of difficult to navigate the Arch Linux Wiki stuff of VFIO(not hard, but a little daunting.)
For me, I preferred to have a video tutorial when I was first learning
Here is what I used: How I Built The "Poor-Shamed" Computer... - YouTube

This won't get you the best configuration, but it will get you started.
There is a lot of work to get VFIO passthrough up and running well.
In addition, once it is properly done, it is better to send the display output from the passed through card to an external display(like a monitor). I do think there is a way to mirror the passed through display to the regular linux display(aka your laptop screen), but I've never gotten that to work.

If you want to do the work for VFIO, it seems possible, but there may be some caveats in its usablity.

If you are willing to reboot and spend 90 seconds to get to Windows, dual booting is the easier option. I totally get it though, it feels bad to dual boot, because then you'll catch yourself using Windows more often than Linux.

3 Likes

you’ll catch yourself using Windows more often than Linux.

Nope. I have Windows in dual boot. I reboot now to play my games. I dont use it more, as soon as Im done with the game I reboot back to Linux.(Games which have AC issues like Apex and R6S)

1 Like

Ah got you.
There are some coming fixes for Anti-Cheat issues, but that's been said for a while now, so it's really hard to tell.
Apparently, there was some integration into linux kernel 5.11 that addresses it, but I believe developers would still have to opt in to get it to work.

It's good that you managed to stay single tracked when in windows. When I dualbooted, I played games on windows, then I ended up doing my schoolwork on windows, the I ended up forgetting about Linux.

The dark times have passed me now and I don't play any games with Anti-Cheat issues.

1 Like

Did you ever get this to work? I'm having trouble following the many guides all over the internet.

Same here. I tried following the Arch wiki and can't get it to work. Wondering if there's something specific to Garuda's configs that require doing something differently...?

The way to test that would be to install Arch and see if the instructions on the Arch wiki work. If so, then it's Garuda. If not, then it's you.

3 Likes

Yes it is possible to get it working on linux. I have gotten it to work on manjaro before but got stuck on the dreaded code 43 error. I heard of a workaround by a guy on reddit involving a hdmi dummy plug plugged into your laptop's hdmi port which fools hte card into thinking its connected to an external monitor. Then he used looking glass to stream the vm to his host machine.

However good news is that with the new nvidia beta driver 465 they decided to remove hte code 43 error and allow poeple to use vfio. Hence how I found this thread. Would appreciate someone making a vfio script for garuda because in the past I used scripts to set it up and got it to working point. Otherwise manually I may mess something up as my linux knowledge isn't that deep yet.

I just remembered to make a icon for this

I don’t need, so IDK if this help, but good start point for you to solve your problem?

1 Like

I already use optimus-manager for switching graphics and kept it set to hybrid mode with dynamic power management on. What I want is a sort of guiding script like the one I found for manjaro. It goes through and takes care of what it can and prompts for manual intervention with clear instructions.

Edit: Script in question - GitHub - pavolelsig/passthrough_helper_manjaro

Then fork it and customize to your liking.

2 Likes

A post was split to a new topic: Want Garauda on my Optimus laptop (MSI GE72VR) with Win10 as an accelerated VM on it,