/ppg/ - PCI Passthrough General

First time ever edition

PROBLEM: You enjoy a nice spot of vidya every now and then, but Linux and vidya is like Apple and being straight.

SOLUTION: PCI Passthrough! Modern linux kernels have builtin drivers and virtualization tools that allow you to give a Windows VM raw access to your hardware, giving you near-native performance while isolating the Windows botnet to a locked-down VM that you only use for vidya.

>Guide
wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF

>Tl;dr what you need
* A reasonably new motherboard and CPU. The motherboard and CPU both must be aware of Intel VT-D or AMD-Vi depending on who you'd rather give your shekels to. LOOK UP YOUR HARDWARE FIRST. Don't guess.

* A modern Linux. Arch works, Fedora works, Ubuntu works. Others may work, but the more you try to be a neckbeard with your OS selection, the more trouble you're going to have setting this up.

* A copy of Windows

* A few hours to kill on a weekend

* No fear of the command line

Ask any questions or report any problems here.

Other urls found in this thread:

newegg.com/Product/ProductList.aspx?Submit=ENE&IsNodeId=1&N=100007709 4025
wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF
youtu.be/okMGtwfiXMo
wiki.xenproject.org/wiki/Xen_PCI_Passthrough
twitter.com/SFWRedditImages

You need a CPU, mobo, and GPU that all support an IOMMU, which most don't.
Useless.

do I need 2 video cards (one for host/one for virtualized OS), or can 1 be shared?

Most old ones don't, many new ones do. If I understand it right, if the motherboard has an option to toggle VT-D or AMD-Vi, then it has IOMMU support.

You absolutely need different cards, but you can get away with running Linux on the integrated one in your CPU, and then passing your gaming card through to the VM.

You don't really need two displays either unless you want to use both at the same time - if you have, say, a Displayport out on your video card and an HDMI out on your motherboard, and your monitor supports both of these, you can just do that and switch inputs on the monitor.

Good idea, OP, I should have started this myself.

You don’t need two “cards” per se, if you have integrated graphics like all recent Intel cpu’s do, that counts.

I’ve done this myself. Waaaaaay fucking better than Wine and putting a leash on Windows feels good.

I was kinda surprised how easy it was. Apt install some things, write some junk into my sysctl and grub.conf, tweak some settings in the vm config file.

The absolute hardest part was translating some of the Arch-specific instructions to Ubuntu. (tl;dr: ubuntu doesn't use mkinitcpio, it uses update-initrd)

Couldn't have taken more than 2-3 hours from start to finish.

Just dual boot lol

Dual booting is for plebs who don't wanna do it right. What happens with *everyone* is that they realize that rebooting destroys their working state and takes time, so they end up staying in one OS or another.

This way, you literally just look at another screen or press the input switch on your monitor.

As a bonus, Windows is virtualized away from most of your hardware so you're not getting cucked by the botnet.

I did some benchmarks and found that I lost on average only half a frame compared to Windows 10 bare metal. I’ve pretty much got the perfect configuration down.

That’s one option but it’s more comfy this way.

The machine I'm running on is an assembled Ryzen 1600 w/ a gtx 1060, so no integrated gpu :c

Not true, every CPU/GPU within the last few generations supports it
Only mildy hard part is finding a mobo

Almost anything on this page will work:

newegg.com/Product/ProductList.aspx?Submit=ENE&IsNodeId=1&N=100007709 4025

You lose performance on CPU intensive games, your latency is increased and most hardware available doesn't support it. You are much better getting a cheap HDD and installing Windows on it.

nice, thanks user.

Every single word of that sentence is wrong. Performance overhead can be measured in the single frames, as can latency overhead, and most hardware actually does support it.

Welcome to 2018, gramps.

How hard it would be for a Windows user with very basic Ubuntu knowledge? Windows 10 is a fucking piece of shit and I can't tolerate it anymore.

If you do it right, the performance decrease is literally imperceptible. Kvm lets the guest run code right on the CPU. The miniscule performance decrease comes from having another OS use up CPU cycles but even that can be mitigated by just not launching a WM or DE while the VM runs. You can even reserve RAM for the guest through hugepages as well as CPU cores which greatly reduces any latency.

Follow online guides and ask us questions and you should have it up and running the way you like before the end of the week. It honestly helps if you’re knowledgeable with kvm though. The whole reason I did it was because I’m experienced with it. Worth it though.

Not very - following that guide in the OP will get you most of the way there.

Do you have more guide?

That covers everything pretty much, what do you need help with?

Cant wrap my head at the files and programs involved.

Retard. No, it won't use your CPU to it's maximum since you have to dedicate some cycles to your distro, meaning some heavy CPU games like Witcher 3 will probably suffer a bit, but that's ok, what's not ok is the latency, playing competitive shit like fighting and FPS games with more 16-32ms added will feel like shit. And no, incompatible hardware outnumbers compatible by a vast margin. For example, not all mobos support IOMMU. I agree it's ok for some casual gaming, but I would never replace a proper dual boot setup by that.

is there a way to add an existing Windows partition to virt-manager?
Not on linux right now but I tried some time ago, and I couldn't do it. It seemed like I could only add a VM by using a windows installer iso and running the setup.
I will be trying this again soon, thanks to this thread.

Not in virt-manager, you're going to have to edit the vm config file (virsh edit vmname) for that.

Example:
disk type='block' device='disk'>

This is why you isolate a couple of your cores from the host so that the guest has full access to them and doesn't have to fight with the host for scheduling priority. Same with memory.

Middle diamond LoL player here who's been doing this shit for a while now. You just fucked up your install or configuration and are salty about it.

You really just need to follow the guide top to bottom user, it's self explanatory. Install the stuff it tells you to install and edit the files it tells you to edit.

The only retard here is this faggot. If your CPU and motherboard support VT-D (or AMD-Vi), you have IOMMU support because that is the implementation of the technology.

Step 1: Check your CPU for those two things
Step 2: Check your motherboard for those two things
Step 3: ?????
Step 4: kys

Nice Try HANK, but we know what you're trying to pull on us.
Don't fall for H.A.N.K's shit anons, this will compromise your linux OS and your computer.

>wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF

Alright so this has been my master escape plan for about two years now.

I want to do a full desktop replacement by using an external GPU on a memePad with an i7 in it that I slap into a dock.

Anyone have experience with this? I figured it makes a lot more sense since memePads have USB-C now.

How does it do that? It's a virtual machine on native hardware

>on native hardware
There's your problem.

Please elaborate.

Can't, H.A.N.K is listening.
Just know that anything that routes to or from Native hardware is already compromised.

Ignore this cia nigger

I don't see any reason an eGPU wouldn't work - the most important bit is how the device presents itself to the computer. In the best case, the eGPU is on the PCI bus in its on IOMMU group. In the worst case, it's shared with the CPU.

Linux holds the reins

Then why bother posting at all? Either state your evidence or fuck off.

da fug is hank?

AI used for marketing and shilling on sites like Sup Forums, Amazon, Reddit, etc, and also is used or will be used in malls. It tries to retain customers based on a lot of creepy information like how long someone looks at an ad, their emotional response, gender, age, whatever. It's creepy but unrelated to this thread.

...

Nice, now you have less cores and by consequence less performance.
>Middle diamond LoL player here who's been doing this shit for a while now.
>implying that amount of latency matters in fucking lol
Absolutely lol'd. And please, refrain from playing shit games.

The point is: not all current mobos support it, and those who do are mostly high ends. Do you have hardware from some gens ago? Forget about it, chances of something being incompatible is pretty high.

creepy

Then it's a good thing the OP mentioned reasonably modern hardware isn't it? Stop being a contrarian faggot.

>he fell for the needing 16 cores meme
If you need all those resources, hopefully you'd be insightful enough to understand that gaming while needing them isn't the best idea

It's here with us.
For all i know you're HANK.
If that's the case the fuck off, i don't want your vitamin water.

I have 8 cores. Dedicating 4 of them to a VM ensures an optimal level of performance given that most apps and games are not compute bound.

Similarly, 16GB of memory is enough to run anything.

>implying latency doesn't matter in lol

I suggest taking 's advice. Or suicide. Whatever works.

Oh man, I’m really gonna feel that one single logical core that I left to the host which is mostly idling

>FPS games with more 16-32ms added will feel like shit
as an Australian who has had to deal with a minimum 2-300ms ping in any online game for years it always makes me laugh my ass off when americans complain about having a "omg so high 50ms lag!!!" latency
fuck off

I can speak to this config - I started out with an image file, then once that worked, i created a LVM LV for it and dd'd the image into it. The config is, verbatim, what's given here, just with the device pointed at my lvm volume.

How would I pass through a blu ray drive?

Add a new storage volume and point it at your physical drive /dev/ node.

I approve of this general. Does anyone use Looking Glass / KVMFR here?

I do, but i actually find parsec to work better in my case.

I have a single monitor setup with the VM running in the background constantly so i can parsec into the VM from my laptop just the same as i can directly from the desktop.

Can someone explain to me why KVMFR isn't possible on optimus?

I've noticed that Optimus breaks a lot of random tech. I'm guessing the dual GPU amounts to using some kind of standards-violating hackery.

What do I select for type on the window before that one?

I just play gaymes on linux.

Physical disk device

>dedicate some cycles to your distro
LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL
DEDICATE MUH IDLE CPU CYCLES TO MUH DISTRO OMGERD

you fucking realize not everyone is on a god damn pentium intel cpu.. right?
most cpus today can handle like 20 VMs open and they won't have latency issues. You'll lose like

stop feeding the contrarian troll user-kun

Holy fuck, does this mean i don't have to run my vm on its own physical video output anymore?

This is what made me not bother. Integrated is quite good, but I use my video card for more than gaming and it will take just as long to switch my video card from my VM to linux as it takes me to boot into linux. I know there are other advantages, but seeing as I can suspend my linux to get most of those, I think dual boot is a bit better for stability. Avoiding the MS botnet is a big plus tho.

Ah that's just it though, the only thing you're "switching" is your display input. It's instantaneous.

And if you're using something like kvmfr, you don't even have to do that anymore. You get normal video from your guest on your host's screen.

This is the future of Linux
One of these days Fedora or some other distro will have this setup as a 1-click install, similar to how MS has the Linux Subsystem

just tell me if all the shit with Threadripper has been ironed out yet.
I heard that the AMD NPT bug has finally been identified and fixed, but last I heard TR had more issues remaining than vanilla Ryzen.

>you don't even have to do that anymore
wuut
how does this make sense
technology is CRAZY

>tfw have 3770K
>the non-K version has VT-d
>every K series has had them since Haswell refresh

I'm never buying Intel again even since I found that out about 2 years ago. Especially after all this other shit that's happened.

GPUs don't need to support IOMMU, just the PCIe root complex and the motherboard BIOS.

The hard thing to find in peripherals is SR-IOV support, which is the generally all-around superior alternative to pass-through.

> consumer Vega SR-IOV never ever

It copies the framebuffer from the guest gpu before the guest gpu sends it to the screen and sends it to the host gpu, I think.

Hurry, in about 5 months all of these will be $200+

Might as well get an RX 550, it should have better future resell value.

Pretty much - and since it's literally copying memory around, the latency is almost nonexistent.

youtu.be/okMGtwfiXMo

My gaming is done on a dedicated gaming PC. It's nothing more than a glorified xbox. I remember trying to follow the PCI passthrough guide and Windows wouldn't install or something. Very few people do it so there's very little info out there for troubleshooting help, let alone finding someone with a setup even remotely similar to yours.

Your Linux box doesn't even have to be high end. Mine runs on an FX-8350. When I upgrade my gaming PC, my Linux box will inherit the i5.

When's the last time you tried? A lot of progress has been made in the last few months. I was able to get up and running on just the Arch guide linked in the OP (plus a little more to map the archisms to ubuntuisms).

Once you get your VM configured, itjustwerks.

kvmfr is *very* new and *very* buggy. I know on my system, it does work as advertised, but it drives the CPU usage to 100%. Your game ends up slowing down due to cpu starvation rather than video latency.

Could be because I'm running it on some fuckhuge x34 display though

You are still being cucked. I only buy games that are Linux native now, there are more than enough. If a game isn't native, I just ignore it I don't even wine.

You are a man among men.

More than enough if you only want to play indie shovelware and freetard trash, that is.

Stop lying dickbrain. The only kinds of game you don't get are games like cawadoody and other games you give to kids for their Xbox.

So yeah, only indie shovelware and freetard trash. If all you want are waifu simulators, yeah, linux alone will probably be enough.

You're only lying to yourself.

>dedicate weekend to getting esxi working
>can't do HID passthrough
i suppose i deserve this.

>esxi

Yeah... that's an exercise in self flagellation if there ever was one.

I wish Endless Legend was on Linux

Has anyone run into the Code 43 error with Windows and Nvidia GPUs? I can assign my GPU to the VM in virt-manager, but Windows won't let the driver load...

...

Take your pixel indie shovelware and shove it up your ass hipster

>a weekend
What? I don't remember ESXi requiring anywhere near that kind of effort.

>You need a CPU, mobo, and GPU that all support an IOMMU, which most don't.
Most (if not all) mobos support passthrough with the main x16 slot.

kvm=off or --features kvm_hidden=on

Yes, you have to spoof the hardware. It’s in the OP’s Arch Linux link.

>shit with Threadripper has been ironed out yet

bumping for this question

You still (probably) need a physical output for the card so that Windows knows what display resolution to use. That could be just be a little EDID adapter thing rather than an actual monitor though, and I have also heard that you can use some regedit magic to change the default resolution instead, without using any connection.

If you do that, then you need some other way to see the display. The two ways of doing that are KVMFR (low latency, lossless, local-only), or some normal streaming thing like Steam's streaming (high latency, lossy, networked).

I got KVMFR running last night, but applies. Guest CPU goes to 100% on all 4 cores, and while the video isn't laggy, the stuff I try to run is slow because it can't get any CPU to work with.

Most CPUs that you would bother putting in a self-built desktop support IOMMU, and therefore the motherboard most likely does too. Every GPU that supports EFI supports IOMMU.

GPU passthrough in general usually isn't possible on optimus due to the way it's setup on most laptops. IIRC optimus usually does something like kvmfr on the hardware level were the intel igpu is the one connected directly to the laptop monitor and outputs and the stronger gpu just passes a framebuffer when you use it, that's also why the drivers are usually so finicky.

this works with Xen?

I did this back before official distro support, and I tell ya hwat, boy was it worth it. Eventually had to get rid of it because it was bugged to shit, and could crash the host on occasion, but was easily worth the weekend it took to set up. Now that it's become somewhat standard I might need to give it another crack.

Don't do it. Unless your thinkpad has an external PCI slot (which afaik none do yet), the bandwidth will be disgustingly bad. They say that the docks can support it, but in reality they are non-interrupt, meaning *anything* that accesses the dock (power, usb, even a routine sanity check) will tank your fps for seconds to minutes.

There is a trend of laptops with ePCI though, so take a look around.

Don't see why not, though the instructions seem a bit more complicated.

wiki.xenproject.org/wiki/Xen_PCI_Passthrough

Seems rock solid so far - I only managed to crash my host when dicking around with installing the nvidia drivers for the first time, and that was probably because I was an idiot and didn't have my configuration right yet.

wiki.xenproject.org/wiki/Xen_PCI_Passthrough

Seems like Xen supports it.