#asahi-re · 2022-10-05 09:20
rqou_unrelated to all of that, the kext seems to allocate an "InsnFifo" that the firmware then manages#asahi-re · 2022-10-05 09:20
rqou_firmware properties 2, 3, and 4 might also all relate to encrypting things#asahi-re · 2022-10-05 09:19
rqou_(there's getFPADSCryptInfo and getKDADSCryptInfo functions, for one, as well as a dedicated "adsbuf" DART stream and a bunch of "ads" related debug messages in the firmware)#asahi-re · 2022-10-05 09:18
rqou_a not-insignificant amount of AVD logic seems to be related to handling "ADS" which (for complicated-to-describe-to-others blatant guessing reasons) i believe is related to FairPlay#asahi-re · 2022-10-05 00:15
rqou_it's not just DCP lol#asahi-re · 2022-10-05 00:14
rqou_look in the constructor for CAvePipeMcpu#asahi-re · 2022-10-05 00:14
rqou_that all do... something#asahi-re · 2022-10-05 00:14
rqou_the RTKit AVE firmware contains over a dozen Cortex-M3 sub-firmwares#asahi-re · 2022-10-05 00:13
rqou_unrelated to AVD, but i just found that the AVE unit also has a co-coprocessor#asahi-re · 2022-10-03 20:35
rqou_although irq mapping is unclear#asahi-re · 2022-10-03 20:35
rqou_afaict it doesn't have access to any hardware the AP doesn't also have access to#asahi-re · 2022-10-03 20:34
rqou_we _might_ also be able to just ignore the firmware#asahi-re · 2022-10-03 20:34
rqou_it's not signed or anything, and i've already confirmed running custom arbitrary code#asahi-re · 2022-10-03 20:33
rqou_depending on how thorough we go with the RE effort we might just be able to write our own firmware#asahi-re · 2022-10-03 20:31
rqou_the firmware is somehow written so that most of it takes pointers to the sram base address (or the base address of something else important in the sram) such that ghidra can't follow any xrefs#asahi-re · 2022-10-03 20:31
rqou_unclear#asahi-re · 2022-10-03 20:29
rqou_in general there's a _ton_ of magic offsets that different classes in the driver and the firmware just have to somehow keep in sync#asahi-re · 2022-10-03 20:28
rqou_this part is created by CAvdApComm*::ConfigurePioHdr*#asahi-re · 2022-10-03 20:27
rqou_it's all a really confusing mess#asahi-re · 2022-10-03 20:27
rqou_which is copied into cortex-m3 sram at address 10003070 + (some idx that i don't understand yet) * 0x16d8#asahi-re · 2022-10-03 20:26
rqou_for h.264 the first chunk at offset +0x0 is 0xB0 32-bit words#asahi-re · 2022-10-03 20:26
rqou_but the sub-parts do#asahi-re · 2022-10-03 20:26
rqou_the 0xb7504 doesn't change with codec#asahi-re · 2022-10-03 20:24
rqou_it's made up of a bunch of sub-blocks, and the 0x60 command has pointers to various bits of it#asahi-re · 2022-10-03 20:24
rqou_frame params seem to be 0xb7504 bytes total, but it's not one contiguous thing#asahi-re · 2022-10-03 20:16
rqou_the metadata seems to be called "frame params" by the driver and is filled in by CAHDec*::populate* functions#asahi-re · 2022-10-03 20:07
rqou_frame data is _probably_ in DART stream 0, and i have no idea how it's tied in with the metadata#asahi-re · 2022-10-03 20:07
rqou_no, it's just metadata#asahi-re · 2022-10-03 19:33
rqou_6) ??? 7) profit (haven't gotten to this bit yet)#asahi-re · 2022-10-03 19:33
rqou_5) the APIODMA block copies even more data (from main memory) into the cortex-m3 sram#asahi-re · 2022-10-03 19:33
rqou_4) cortex-m3 reads some of the command fields and pokes the address into the APIODMA block, and then waits for it to finish#asahi-re · 2022-10-03 19:32
rqou_3) driver sends the address of the command it just wrote into the cortex-m3 mailbox#asahi-re · 2022-10-03 19:32
rqou_so far the data flow as i understand it is: 1) driver writes "frame params" into main memory mapped by DART stream 1 2) driver writes a 0x60 byte command by directly poking it into cortex-m3 sram#asahi-re · 2022-10-03 19:30
rqou_for extra funsies, this base address is hardcoded in the kext, it's not read from the ADT#asahi-re · 2022-10-03 19:27
rqou_attempting to access the DART causes the dma engine to explicitly report a fault, but other accesses like main memory seem to just get stuck#asahi-re · 2022-10-03 19:25
rqou_definitely can't access the DART#asahi-re · 2022-10-03 19:25
rqou_so it might be able to access the other avd peripheral registers too, but tbd#asahi-re · 2022-10-03 19:25
rqou_marcan: the macos driver programs the dma base address to point to the piodma hardware block itself, but then all dma packets that the driver emits seem to target the cortex-m sram via an additional offset#asahi-re · 2022-10-03 11:08
rqou_what a clusterfuck of an architecture#asahi-re · 2022-10-03 11:08
rqou_also, afaict (need to double-check) this DMA engine is being used... to just copy even more data into the cortex-m3 data memory#asahi-re · 2022-10-03 10:59
rqou_this dma engine seems to be called "APIODMA" and also exists (in seemingly identical fashion) in the hardware scaler#asahi-re · 2022-10-03 10:58
rqou_finally got back into doing some AVD re, and it turns out the cortex-m3 inside the avd has access to a dma engine that can write to physical addresses. afaict not _arbitrary_ addresses (i.e. i tried to write to a DART TTBR and it failed, and a write to main memory seemed to have been dropped), but i'm not sure how restrictions on it are configured/enforced#asahi-re · 2022-07-20 19:59
rqou_the kext has symbol names that contain "ADS" near symbol names referencing FairPlay#asahi-re · 2022-07-20 19:59
rqou_also i'm definitely just randomly guessing about this, but i think dart stream 2 is for DRM#asahi-re · 2022-07-20 19:40
rqou_btw, if you have any idea how to clear the overflow error flag on the mailbox, i'd be interested (no matter what i poke it doesn't seem to go away)#asahi-re · 2022-07-20 19:39
rqou_e.g. there's actually four mailboxes, but you'd never know that by just tracing and copying macos#asahi-re · 2022-07-20 19:36
rqou_Jamie[m]: thanks. what you have so far looks consistent with what i've got, but rn i'm focusing down a bit on the M3<->AP interface to make sure the fine details are understood#asahi-re · 2022-07-20 13:54
rqou_also iirc doesn't have mpu, etc.#asahi-re · 2022-07-20 13:54
rqou_it's not even the same ISA#asahi-re · 2022-07-20 13:54
rqou_lmao