#
…

2022-07-17

00:00Jamie[m](although AVE might be completely un-looked-at too?)
00:04rqou_do you have any notes on avd?
00:11Catyre has joined #asahi-re
00:11Catyre has quit [Remote host closed the connection]
00:29doggkruse has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
01:45L1Q has quit [Ping timeout: 480 seconds]
02:55phiologe has joined #asahi-re
02:58PhilippvK has quit [Ping timeout: 480 seconds]
03:18RevHelix has quit [Quit: I am going to make my own channel, with blackjack and hookers!]
04:31chadmedrqou_: i gave up on touchid (mesa) if you wanna have a crack at that. it has a private interface to SEP that i _think_ might be impossible to snoop on from the HV and im not skilled enough to really go beyond what ive already pushed into m1n1 :/
04:33chadmedthe only data that is trafficked between it and the APs seems to be an encrypted command buffer of some kind to bring it up and tell it to wait for a fingerprint. everything else goes to the SEP
04:35chadmedand to really rub salt in the wound, tracing the SEP is too slow to reliably get anything useful. mesa seems to time out waiting for the SEP to tell it something which invalidates the input data and makes macos refuse to accept it
05:37nicolas17oh what? I thought the touchid sensor was connected to the SEP *only*
05:37chadmedno it talks to the APs over the same SIO interface that the kb and touchpad do
05:38nicolas17I always thought it was AP <-> SEP <-> mesa sensor, and no AP <-> mesa connection at all
05:38nicolas17interesting
05:38chadmedthe only repeatable and intelligible data is a bringup sequence (which seems to just be the APs asking if its awake)
05:39chadmedafter that the data is encrypted and changes on every boot (the format/packet size stays the same though which is why i think its an encrypted command buffer)
05:40nicolas17if it's the AP encrypting it, it should be possible to intercept...
05:40chadmedi dont think it is
05:40nicolas17but that would need code-level RE
05:42nicolas17well how does the AP come up with that encrypted buffer? either it has some plaintext and encrypts it, or it gets encrypted data from (say) the SEP and forwards it
05:43chadmedtheres a few functions in one of the mesa drivers associated with encrypting and transmitting a command buffer
05:43chadmedBUT, theres also a much much smaller driver which is just a shim for the SEP interface and i think thats the one these machines use
05:44nicolas17can m1n1 set a breakpoint on that code, so you know which one is running?
05:45chadmedi could probably check without dicking around in m1n1 too but im like ~80% sure that its not the full fat driver
05:45chadmedand i say that because after the power on pings early in boot, theres no more data sent across the interface for a while then all of a sudden there is just encrypted commands
05:46chadmedtheres no apparent negotiation or anything like that
05:46chadmedit just stops after powering it on then a few seconds later there is encrypted data
05:46nicolas17could it be doing the "negotiation" via the SEP?
05:46chadmedand these are the only two DMA channels associated with mesa on the SPI bus so it _must_ be talking to the SEP over a private interface
05:47chadmedwell yeah but like i said the SEP tracer isnt really useful for this (yet)
05:47nicolas17ah, need better SEP tracing first, I see
05:48chadmedi did try hacking on the tracer sven wrote but it was a goose chase
05:49chadmedto effectively trace mesa i think we need to know a) the endpoint in the SEP the APs use to talk to it about mesa, and b) whatever interface mesa talks to the SEP over which might even just be staight up impossible idk
05:49chadmedthe SEP FW is encrypted so we cant really look at it in ghidra can we?
05:53nicolas17the Mac SEP FW is encrypted
05:54nicolas17SEP for older iPhones can be decrypted, but I'm not sure how useful it would be
05:54chadmedyeah so figuring out how mesa interacts with the SEP is going to be almost impossible
05:55chadmedif we sort of do the same thing apple does (use the SEP to mediate authentication) then we might not need to, but then touchid support is effectively blocked until we have SEP support
05:55nicolas17I thought you had to do that anyway
05:56chadmedwell my initial plan was to see if we could get fingerprint data out of mesa directly somehow and do it like that until the SEP works
05:56chadmedbut alas no
05:57chadmedit does send some silly amount of data over SIO when your finger is on it, which i originally thought might be fingerprint data
05:57chadmedbut idk what it is now im doubting myself constantly :P
06:00nicolas17hm, I think there isn't a direct SEP-Mesa hardware connection
06:01nicolas17rather the AP has to forward the data between them, but it's encrypted and the AP can't see what it is
06:02nicolas17I'm not entirely sure, there's some ambiguity in the way this is written, or I'm too tired to read it confidently
06:04nicolas17if that's right, then you should see the encrypted garbage being sent to mesa actually came verbatim from the SEP, and viceversa, and the AP is just forwarding ciphertext back and forth
06:05nicolas17and maybe you don't see that because the SEP tracer isn't catching it
06:06nicolas17take none of this as fact, I'm joining the speculation :)
06:07nicolas17but yeah I believe the AP can't see raw fingerprint data by design
06:07svenpretty sure that’s how it works
06:10chadmedyeah it cant i tried poking at the big data packet and it was all nonsense
06:10nicolas17so in hardware/wiring it's not AP <-> SEP <-> mesa as I said earlier, rather it's SEP <-> AP <-> mesa; *but* it's encrypted end-to-end
06:10chadmedlet me look at the logs i dumped
06:19chadmedyeah there is some sort of negotiation sequence but ofc its encrypted. xnu seems to only load the sep shim driver too
06:20chadmedAppleMesaSEPDriver
06:21nicolas17so yeah I think if you're not seeing encrypted data coming from mesa and then immediately the *same* encrypted data going to the SEP, then the SEP trace is incomplete :)
06:23chadmedlike i said, tracing the sep at all results in it not working properly so yes i cannot see the data on the SEP <-> AP leg
06:25nicolas17oh I missed that
06:25nicolas17bleh how is it so timing sensitive?
06:26chadmedbecause the SEP is involved in basically everything and tracing it at all results in everything just slowing to an absolute crawl
06:26chadmedthe system takes about 15 or 20 minutes to get to a login screen then an equal amount of time to settle down after logging in until you can click anything
06:27chadmedthen you have the problem of getting into system settings to the touchid module and trying to get it to enrol a fingerprint
06:27nicolas17producing how many gigabytes of log until login screen? :D
06:27chadmedmacos just gives up waiting for the data and doesnt validate the fingerprint
06:28chadmedi didnt even bother logging with the SEP tracer enabled, the volume of output is about on par with lina's gpu logs, probably worse
06:28nicolas17oh, tracer enabled but throwing the traced data away?
06:29chadmedi was still trying to figure out which EP is even mesa's so there was no point logging a bunch of undocumented garbage data
06:29chadmedi still dont know which EP it is :)
06:29chadmedi would hazard a guess that it is 0x18 since some XNU logs relating to AppleMesaSEPDriver appear just before EP 0x18 is announced as being enabled but that doesnt necessarily mean anything
06:30nicolas17I'll go back to my userland comfort zone :p
06:45nicolas17 has quit [Ping timeout: 480 seconds]
06:56the_lanetly_052 has joined #asahi-re
07:59bisko has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
08:29marcanSEP can't possibly be quite as bad as lina's logs... she's logging *every single memory access from CPU to GPU-mapped memory*
08:29marcaneven if there's a lot of traffic, just logging buffers back and forth has to be faster
08:30marcanmaybe I should take a look at that tracerr?
08:30chadmedif you disable the SKS EP its nowhere near as bad to be fair
08:30marcanmight be doing something silly with trace modes...
08:30marcanor that, yeah, just filter it
08:32marcanthere's also that thing lina did to speed up the whole m1n1 USB comms 3x (?)
08:32marcanI should poke her to push that
08:32chadmedyeah tracing SIO doesnt grind the kb and trackpad down anymore which is lovely
08:33marcanI don't think it's upstream yet?
08:33chadmedhuh... maybe it really just was that SKS endpoint
08:36chadmedeither way i had a poke earlier and there were some messages on the sbio endpoint of SEP but _only_ immediately after taking your finger off the sensor and they had no data so there's still something missing somewhere
08:38chadmedthere was no SEP traffic coinciding with the polling stuff over SIO
08:45sventhe endpoint should be SBIO
08:45svenand the tracer isn’t nearly as bad as the GPU one
08:45svenbut it’s still pretty verbose
08:46svenyou probably want to disable SKS at least and there’s even a allowlist for endpoints already
08:55chadmedyeah i turned off SKS and its fast enough to interact with the sensor and macos is happy with it so thats cool
09:01rqou_is there a way to get m1n1 to break into the shell (and disassemble code) when a mmio register is written?
09:01rqou_i'm taking a look at avd, half of its regs overlap something mapped in pmgr for some reason, and i cannot for the life of me figure out where any of these registers are being written from
09:03rqou_the first half of avd overlaps pmgr[51] (on m1 max)
09:23bisko has joined #asahi-re
09:27the_lanetly_052 has quit [Ping timeout: 480 seconds]
09:35bisko has quit [Ping timeout: 480 seconds]
09:38bisko has joined #asahi-re
09:44bisko has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
09:48bisko has joined #asahi-re
10:01bisko has quit [Ping timeout: 480 seconds]
10:03bisko has joined #asahi-re
10:27Catyre has joined #asahi-re
10:27bisko has quit [Read error: Connection reset by peer]
10:33bisko has joined #asahi-re
10:35Catyre has quit [Ping timeout: 480 seconds]
10:37Jamie[m]oh yeah idk what’s up with the first half of it
10:38Jamie[m]sorry didn’t get chance to assemble my notes, gotta sleep now, will find them tomorrow
10:40Jamie[m]or maybe you will have reproduced all my work by that point :)
10:42bisko has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
10:46MajorBiscuit has joined #asahi-re
11:15nehsou^ has joined #asahi-re
12:07MajorBiscuit has quit [Ping timeout: 480 seconds]
14:42nehsou^ has quit [Ping timeout: 480 seconds]
14:42Misthios has quit [Quit: Misthios]
14:43Misthios has joined #asahi-re
16:03marcanrqou_: pmgr is a kitchen sink of nonsense and the ADT reg ranges are a huge mess
16:03marcanpmgr directly maps some device ranges, and some devices directly map pmgr ranges
16:04marcanentirely possible that the first half is just pmgr stuff shoved into that driver for no good reason
16:26rqou_marcan: after some more poking, i think the thing is a "axi2af" block, with a bunch of tunables. unfortunately i can't seem to actually get the tunable data from the PMGR kext, because every tool i've tried chokes on what i assume is the macho chained fixup data (but might be a different problem)
16:28marcanjust hypervisor log it?
16:28marcanwe should put that nonsense in m1n1 anyway
16:28rqou_that doesn't give me the masks
16:29marcanyou could fake the read data as 000 and fff to get the masks, but tbh it probably doesn't matter much
16:29rqou_oh yeah, could do that
16:30rqou_not sure if this can be handled in m1n1, the tunables might get lost when the device is power/clock gated?
16:30marcanthat's something to work out
16:31marcanlots of things seem to stick across power/clock gates though
16:31marcanespecially apple stuff
16:31marcanso I wouldn't be surprised if this does
16:31rqou_in the hv trace i see it getting poked multiple times, not just at boot
16:31rqou_or maybe none of this is actually needed, i haven't tried actually poking the hardware yet
16:31marcancan you tell if it really loses the data?
16:32rqou_haven't tried at all yet, will need to investigate
16:32rqou_it's possible it's only important for performance tuning
16:34rqou_the AVD kext definitely also makes calls into the AMCC driver to tune some caching behavior (do we understand any of that yet?)
16:34marcanno, also seriously?
16:35marcanthat's so goofy
16:35marcanlet's ignore all that for now
16:35rqou_i mean, the adt outright says so: "function-mcc_dataset = 125:M$DS()"
16:35marcanmaybe it's something like "don't cache AVD streams"?
16:36rqou_at least this one doesn't involve a hacky layering violation
16:36svenfwiw, sone atc tunables stick around even through a atc reset, but others have to be reapplied again and again
16:37svenand yet macOS applies them all again and again (and my driver too because if I have to apply some tunables I might as well apply them all)
16:41rqou_on a different topic, i didn't see anything whatsoever touch btcoex in the "converged ipc" kexts, so if that's the issue it's either a command sent from macos userspace or a problem on the wifi side
16:42rqou_i'm guessing probably the latter
17:13marcanit seems the btc_mode is 0 when the nvram says it should be set to 1
17:14marcanso either something about nvram loading is broken or something isresetting it
17:37rqou_ has quit [Ping timeout: 480 seconds]
17:53nicolas17 has joined #asahi-re
18:02nicolas17 has quit [Ping timeout: 480 seconds]
18:12svenafaict most of the fancy stuff happens inside BlueTool anyway (like firmware selection or sending the right calibration data)
18:12svenbut sounds like btcoex is mostly a WiFi thing
18:12nicolas17 has joined #asahi-re
18:28MajorBiscuit has joined #asahi-re
18:28MajorBiscuit has quit []
18:37bisko has joined #asahi-re
18:50rqou_ has joined #asahi-re
20:03marcanyeah, I think it's mostly handled on the wifi side
21:04Catyre has joined #asahi-re
21:16Catyre has quit [Ping timeout: 480 seconds]
21:26Catyre has joined #asahi-re
22:00yrlf has quit [Quit: The Lounge - https://thelounge.chat]
22:16yrlf has joined #asahi-re
23:00Catyre has quit [Ping timeout: 480 seconds]
…