#asahi-re · 2022-04-06 13:46
kameksah, I see#asahi-re · 2022-04-06 13:46
marcanno, firmware is *per OS*#asahi-re · 2022-04-06 13:45
marcannot the same way, because we can choose what firmware versions we support#asahi-re · 2022-04-06 13:45
kamekseg, you update macos, and now you can't dual boot linux anymore#asahi-re · 2022-04-06 13:45
kameksis that a problem for linux too?#asahi-re · 2022-04-06 13:45
marcanindeed macos updates all come with their own GPU firmware#asahi-re · 2022-04-06 13:45
kameksso a macos could also update the GPU side firmware and break the ABI ?#asahi-re · 2022-04-06 13:44
marcanit's not happening#asahi-re · 2022-04-06 13:44
marcanbasically, forget about it#asahi-re · 2022-04-06 13:44
marcannevermind that messing with kernel drivers like this one means putting the system into permissive security mode and manually loading your own kernels, which is terrible UX for normal macOS users and can't even be done without the KDK and you can't redistribute that#asahi-re · 2022-04-06 13:44
marcanI mean the GPU firmware#asahi-re · 2022-04-06 13:44
kameksby firmware, you mean the GPU ioctls ?#asahi-re · 2022-04-06 13:43
marcanthis isn't going to work stably, ever#asahi-re · 2022-04-06 13:43
marcanit isn't even clear if the *firmware* ABI is stable, and Apple internal kernel magic also definitely isn't stable, so no#asahi-re · 2022-04-06 13:42
kameksI see. so the only way on mac is to completely replace the kernel driver and reimplement metal as well (assuming it is possible)#asahi-re · 2022-04-06 13:41
marcanthe only stable graphics APIs on macOS are Metal and OpenGL, so basically anything else is impossible to make forward-compatible#asahi-re · 2022-04-06 13:40
marcanthey gave up on that idea and now just call libc like everyone else#asahi-re · 2022-04-06 13:39
kamekshow did go solve it? did they just stopped using those syscalls?#asahi-re · 2022-04-06 13:37
marcanso yeah#asahi-re · 2022-04-06 13:37
marcanGo tried it with boring old UNIX syscalls and a macOS upgrade broke all Go apps; and obviously the GPU API is much, much less stable than that#asahi-re · 2022-04-06 13:37
kameksyou have a point#asahi-re · 2022-04-06 13:36
kameks;-(#asahi-re · 2022-04-06 13:36
marcanso any random macOS upgrade can and likely will break your code#asahi-re · 2022-04-06 13:36
marcanby the way, you're probably going to have a bad time trying to make this work and maintain it on macOS, because Apple makes no kernel<->userspace ABI guarantees#asahi-re · 2022-04-06 13:35
kameksok, got it#asahi-re · 2022-04-06 13:34
marcanright, and I'm saying that's not on Linux#asahi-re · 2022-04-06 13:34
kameksyes, that's the case#asahi-re · 2022-04-06 13:34
marcanwith the same VA#asahi-re · 2022-04-06 13:34
kamekswell I think the 360 was exploited because the GPU could write any address, including kernel#asahi-re · 2022-04-06 13:34
marcanyes, but the point is your userspace pages are automatically GPU pages in the context of your process#asahi-re · 2022-04-06 13:33
kameksright, but the mapping still go through the OS, you can't just randomly change permission for kernel owned pages#asahi-re · 2022-04-06 13:33
marcanAIUI on some consoles the GPU and CPU share page tables, so no explicit GPU map operations are necessary#asahi-re · 2022-04-06 13:32
kamekson console as well, we ask the kernel for GPU map. some of them have unified memory space, some of them don't. but the kernel still keeps proper permission to avoid privilege escalation using the GPU#asahi-re · 2022-04-06 13:31
kameksyup, I mean, have it in a user accessible API, not driver internal#asahi-re · 2022-04-06 13:31
marcanAFAIK the only notable difference is the memory management as I said, i.e. with Linux you do need to ask the kernel to GPU-map buffers since the page tables are maintained separately for GPU and CPU#asahi-re · 2022-04-06 13:30
marcanthat's pretty much already how it works in every sane graphics driver, yes#asahi-re · 2022-04-06 13:26
kameksabout RE, I've read it and I fully agree to follow the practices#asahi-re · 2022-04-06 13:25
kameksideally, my stuff would also run on a stock macos#asahi-re · 2022-04-06 13:24
kameksWhat'd like to have/do is a user-space driver, that ideally also run on mac. So I wouldn't be responsible for page allocation and protection or the ring buffer. But mostly raw command encoding, helpers to tile textures, find memory footprints (where to put mips) and so on. If that's more or less already what the kernel is doing, that's all the better#asahi-re · 2022-04-06 13:17
marcaneither way as far as reverse engineering, please read this: https://asahilinux.org/copyright/#asahi-re · 2022-04-06 13:17
marcanI don't know whether Linux supports unified GPU/CPU page tables, but if it doesn't and the M1 can do it, that'd be a good thing to work on a general solution for, since I think some other architectures can too#asahi-re · 2022-04-06 13:12
marcanso basically it sounds like what you actually want is to just not use mesa or talk directly to lower layers of mesa, and keep the same kernel interface#asahi-re · 2022-04-06 13:12
marcan... that'd have to be discussed with upstream#asahi-re · 2022-04-06 13:12
marcaneither way the kernel interface is intended to be as low level as possible while maintaining security and multitasking guarantees, so the chances you can improve upon whatever we come up with there aren't terribly high; memory management is another question but it's also not something you can just rip out, and if you want to propose something radically different from what DRM supports today, ...#asahi-re · 2022-04-06 13:09
marcanalso some consoles may share page tables between apps and the GPU, which may or may not be possible on Linux#asahi-re · 2022-04-06 13:09
marcanusually the draw command buffer is filled by userspace but submission will go through the kernel, and the kernel maintains the main command ring buffer#asahi-re · 2022-04-06 13:09
marcankameks: on consoles there are different security considerations than on Linux, and very different multitasking requirements. how this works or can be made to work varies from platform to platform.#asahi-re · 2022-04-06 13:02
kamekson M1 GPU, the command buffer still reside in kernel space?#asahi-re · 2022-04-06 13:01
kameksbut even if the platform were to not support a high level API such as Vulkan, we could implement it ourselves if we had the time for it. we got all the tools#asahi-re · 2022-04-06 13:01
chadmedintel's mesa stuff creates the buffer batches and then flicks them off to the kernel driver for submission