2022-02-14
00:12chengsun has joined #asahi-gpu
00:19chengsun_ has quit [Ping timeout: 480 seconds]
03:36PhilippvK has quit [Ping timeout: 480 seconds]
03:37phiologe has joined #asahi-gpu
04:27user982492 has joined #asahi-gpu
06:01chadmed has quit [Remote host closed the connection]
06:29user982492 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
06:34chadmed has joined #asahi-gpu
07:05mrkajetanp has quit [Ping timeout: 480 seconds]
09:21phirethe pipeline bind uses a weird address space: https://cgit.freedesktop.org/mesa/mesa/tree/src/asahi/lib/cmdbuf.xml#n495
09:22phireI've got the launch command: 00001002 00018000 00000020 00000001 00000001 00000020 00000001 00000001 6000217c
09:23bisko has joined #asahi-gpu
09:26phireso there is this weird, extra address space? that apparently only pipeline defintions live in?
09:37mrkajetanp has joined #asahi-gpu
10:02marcanalso, are we sure AGX firmware can alter the page tables? I'm going to have to include that info in my tech doc since I've been saying proprietary blobs don't have full RAM access and that seems to be an exception
10:02marcanbut I also wouldn't be surprised if Apple did *something* and in fact it's more restricted
10:03marcane.g. it could be that the reason for that special VA range is because that's the one thing AGX firmware *can* access
10:04marcane.g. it could be that the UAT/GART filters the high range/TTBR to only allow translation to stuff within a specific carveout region
10:05phireThey cover the agx-asc firmware blob that iboot put in main ram, and the IO range for agx-asc's registers
10:07phiremain ram. The L0 page is at gpu-region-base, kernel points L0[1] at gfx-shared-region-base
10:09phireI haven't fully investiated the permission bits. It's possible the pagetables are setup in such a way that the firmware can't modify them once booted
10:11phireit's in the 0xfa0_00000000 vaddr range (everything the macos kernel passes into it is in that range)
10:12phireHere is a pagetable dump of context 0: https://gist.github.com/phire/13c92abd5462d2ea9f3b7d6a6af19c14
10:22MajorBiscuit has joined #asahi-gpu
10:29marcanhm, yeah, I don't see how that would work based on VA ranges, but it could still be what you say about the PTs getting locked
10:32phireinteresting. I get the feeling we are going to have to RE this blob just so we know it's security model
10:35marcanbut yeah, if the AGX firmware maps its own PTs read-only, and then VMSA locks itself, early in init, that's all the code we need to audit to say "no backdoor here"
10:40marcanbtw, stringsing the kexts, they seem to call the PTs UAT and GART somewhat interchangeably
10:41phireyes. UAT seems to mean Unified Address Translater, So I'm guessing there used to be a seperate GART and DART
10:43marcanyeah, like maybe the ARM's actual sysreg TTBR1 gets pointed to the same L1[0] and that all uses the standard VMSA lockdown stuff
10:44marcanand then it's possible the ARM never actually has to R/W data in the lower half of the address space directly
10:44marcanwe have rtkit-private-vm-region-base which points to what very much looks like a typical ARM top half VM address space base
11:25phireit doesn't seem to be far off, from what I can tell. But I don't know the ARM MMU very well
11:38phireI guess if the ARM core never touches the lower address range, it doesn't need to care about the gpu contexts and handle updates to gpu-region-base
12:00marcanand by the nature of it, if it can guarantee those PTs never point to crazyland, then all we need to do is audit the GXF code (which is one page) to convince ourselves that there is no backdoor
12:00marcanI think that's good enough for the "no, really, Apple don't have a backdoor here" argument
12:01phireFrom what I can see, context switching is controlled by second field in work submission commands.
12:04svenand then there was ofc that one kernel with llvm bitcode released under the open source license. that should contain full symbols and then some for GXF as well :D
12:08phireif GXF is so small, could we rewrite it, and then graft the rest of apple's firmware onto it?
12:09svenGXF is what apple called "guarded exception level". it's a lateral level to EL2 called GL2 with a different interpretation of pagetable permissions and usually the only code that gets to modify pagetables
12:11phireWhat I'm wondering is could we take the bulk of apple's gfx-asc firmware, but replace the GFX level code with our own code?
12:12sveni think apple calls that CTRR. iBoot loads the firmware of all co-procs into a memory region and setups CTRR to write protect it
12:16phireDoes that mean since we have control over the pagetables, we could hijack all of the agx-asc firmware except for the GFX level?
12:18sveni didn't follow the pagetable discussion, but I think that if you control whatever TTBR0/1 points to you can even hijack the GL2 code
12:18svenyeah. if we can modify the full pagetable we can just map the firmware (or parts of it) somewhere else
12:20svenhrm... unless they also limit the physical addresses that are allowed to contain code like they do for the XNU kernel
12:21phirethough, that might not enough to satisfy the people conserned about backdoors. It would be a racecondition to replace the pagetables before too much of the agx-asc firmware runs
13:30marcanas far as I can tell it reads the GPTBAT base from a random global that is not in a PPL-only write protected page?
14:09balrog has quit [Quit: Bye]
14:17balrog has joined #asahi-gpu
14:38yuyichao has quit [Ping timeout: 480 seconds]
14:55yuyichao has joined #asahi-gpu
15:14marcanwe know the firmwares are quite pwnable, the bigger question is what is the backdoor surface and whether Apple are going to harden the PPL stuff to the point where we can say we don't need to audit the whole firmware
16:54user982492 has joined #asahi-gpu
17:15nafod has quit [Quit: Ping timeout (120 seconds)]
17:15nafod has joined #asahi-gpu
17:28balrog has quit [Remote host closed the connection]
17:28balrog has joined #asahi-gpu
17:38MajorBiscuit has quit [Ping timeout: 480 seconds]
18:04user982492 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
19:01user982492 has joined #asahi-gpu
19:43Gaspare has joined #asahi-gpu
20:47boardwalk has quit [Quit: Ping timeout (120 seconds)]
20:48boardwalk has joined #asahi-gpu
21:11Gaspare has quit [Read error: Connection reset by peer]
23:24user982492 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
23:57VinDuv has quit [Remote host closed the connection]
23:57VinDuv has joined #asahi-gpu