#
✕ nick:marcan
#asahi-dev · 2022-11-22 09:30
marcanI'm not sure how mapping guest memory works? I think the GPU stuff just uses mmap(), so you'd need a way to forward such a mmap() on the host into guest IPA space (and then the guest would forward it into a given process' VA space)
#asahi-dev · 2022-11-22 09:28
marcanI haven't read up on this in detail but AIUI all of the significant shenanigans would be in the qemu/guest kernel side, to forward those ioctls and manage buffer mapping
#asahi-dev · 2022-11-22 09:28
marcanI think so, yeah
#asahi-dev · 2022-11-22 09:27
marcan(other than the existing UAPI attack surface which... well, let's just say doesn't have a great track record on legacy GPUs, but that's already a big problem VMs or not, and maybe Lina's Rust driver will do better there)
#asahi-dev · 2022-11-22 09:27
marcanI'm not sure if there's some minor mm stuff to deal with, but I don't see much of a surface on the host hypervisor kernel
#asahi-dev · 2022-11-22 09:26
marcanqemu could just call the native ioctls
#asahi-dev · 2022-11-22 09:26
marcandoes the hypervisor even need to do anything?
#asahi-dev · 2022-11-22 09:22
marcanin principle it's just funneling an ioctl interface from the guest to the host
#asahi-dev · 2022-11-22 09:22
marcanand on the host side I think you can even get away with minor or no kernel changes depending on the driver? not sure
#asahi-dev · 2022-11-22 09:21
marcanI think the idea is that only the guest kernel would need changes, not guest userspace
#asahi-dev · 2022-11-22 09:20
marcanyes, but this is in principle portable to most modern GPU drivers with little work, because it's based on the existing process isolation concept
#asahi-dev · 2022-11-22 09:20
marcanit just means each guest process looks like a host process as far as the GPU is concerned, and you can have as many VMs and guest processes as you want
#asahi-dev · 2022-11-22 09:19
marcanthis has mesa running on the guest
#asahi-dev · 2022-11-22 09:19
marcanwhich means mesa runs on the host
#asahi-dev · 2022-11-22 09:19
marcanvirtio-gpu is serialization AIUI
#asahi-dev · 2022-11-22 09:19
marcanand can be implemented safely as long as you can map guest contexts to host contexts, since by definition at that layer you already need safe context isolation
#asahi-dev · 2022-11-22 09:18
marcanbut UAPI paravirtualization makes a zillion times more sense for this kind of use case
#asahi-dev · 2022-11-22 09:18
marcan(and is impossible to implement safely for this gpu)
#asahi-dev · 2022-11-22 09:18
marcanmaz: there's no stage 2 here, device assignment doesn't work
#asahi-dev · 2022-11-22 09:17
marcanyou'd trap for the equivalent of every guest GPU submission ioctl, which is already a trap anyway, so probably a not-terrible constant factor
#asahi-dev · 2022-11-22 09:16
marcan(tl;dr on the new gpu virt stuff if I understood it correctly: just run the native driver in the VM and paravirtualize the UAPI)
#asahi-dev · 2022-11-22 09:15
marcanlike you could seriously just run games in a thin VM and use 9p or whatever to share the filesystem and the GPU stuff to share GEM buffers with the host and it all probably will just work with the right amount of duct tape and feel like native apps
#asahi-dev · 2022-11-22 09:15
marcanit's a seriously viable solution too, given what I've heard about upcoming GPU virtualization stuff
#asahi-dev · 2022-11-22 08:38
marcanso sorry, it's going to be 16K until we run out of software that doesn't support it that isn't an emulator of some sort
#asahi-dev · 2022-11-22 08:38
marcanthe result is a better ecosystem for everyone, and I'm in no rush to stop giving them reasons to improve ;)
#asahi-dev · 2022-11-22 08:37
marcanit's working, the pain is getting people to fix stuff
#asahi-dev · 2022-11-22 08:37
marcanwe've actively gotten a bunch of things fixed
#asahi-dev · 2022-11-22 08:37
marcanpowerpc people said they failed at getting people to fix userspace for larger page size support. even Red Hat gave up on ARM I think, for desktop stuff.
#asahi-dev · 2022-11-22 08:34
marcanand we do want default distro kernels to work some day
#asahi-dev · 2022-11-22 08:34
marcanwell, that and that the kernel's idea of page size is hardcoded
#asahi-dev · 2022-11-22 08:34
marcanno, other than the fact that 16K HW / 16K kernel / 4K user is a much harder problem than 16K HW / 4K kernel / 4K user
#asahi-dev · 2022-11-22 08:33
marcanif anything F2FS's continued brokenness is all the more reason to delay 4K support, because it means 16K-broken code still exists
#asahi-dev · 2022-11-22 08:32
marcanso just please stop asking
#asahi-dev · 2022-11-22 08:32
marcanbecause F2FS is solidly in the "no excuse to be broken on 16K" list and I have zero interest in supporting or providing 4K support for that
#asahi-dev · 2022-11-22 08:31
marcanor maybe you should just use a VM for f2fs stuff
#asahi-dev · 2022-11-22 08:31
marcanmaybe you should ask them about that then, instead of bugging sven about the patch
#asahi-dev · 2022-11-22 08:29
marcan:D
#asahi-dev · 2022-11-22 08:28
marcan+1 month for 4K support?
#asahi-dev · 2022-11-22 08:28
marcanyes, but those apps are all foreign/emulated apps and 99% of that category is games and so there's no point until the GPU stuff is there and supports 4K pages
#asahi-dev · 2022-11-22 08:27
marcan(and everyone related to MM I've casually mentioned that to recoiled in horror)
#asahi-dev · 2022-11-22 08:26
marcanyeah, that's... a big project
#asahi-dev · 2022-11-22 08:24
marcanyou mean like mixed userspace processes?
#asahi-dev · 2022-11-22 08:23
marcanlina probably needs to talk to the DRM people about that
#asahi-dev · 2022-11-22 08:23
marcannot sure which one makes more sense
#asahi-dev · 2022-11-22 08:23
marcanphire: and to be clear, the shmem stuff is literally tmpfs, so you're talking about making the kernel's core tmpfs/shmem code support some kind of page folio business / aligned allocations (it already supports huge pages but that's special), or replacing it with something else
#asahi-dev · 2022-11-22 08:22
marcanthat's when 4K kernels will start to make sense
#asahi-dev · 2022-11-22 08:22
marcanI don't want to do that until the GPU stuff is shipping and lina gets around to figuring out a solution for the page size issue
#asahi-dev · 2022-11-22 08:21
marcanphire: if we make it easy for people to use 4K kernels people will stop fixing broken 16K apps
#asahi-dev · 2022-11-22 08:16
marcanyeah
#asahi-dev · 2022-11-22 08:15
marcanso maybe it needs an entire new GEM helper/allocation backend

plus ›