2026-05-10
00:17yurix has joined #asahi-dev
01:06yurix has quit [Remote host closed the connection]
01:30vols has joined #asahi-dev
01:43StanfordAppliedCyber[m]I'm working on porting the m1n1 hypervisor to the macbook neo (tl;dr, boot in raw mode, run m1n1 in el2, use a python script to patch all the genter calls in xnu to hypercalls mechanically, load xnu into el1 and emulate sptm (both the handoff and the runtime endpoints))
01:43StanfordAppliedCyber[m]i've made good progress and am debugging a hang somewhere in comppage init right now and am optimistic this approach will work
01:44StanfordAppliedCyber[m]question: should I talk about it here or in the tainted RE channel? this involved extensive disasm of SPTM
01:45StanfordAppliedCyber[m]I have NOT done any disasm of the kexts in the kernelcache, which is ultiamtely what we want to RE with the mmio traces
01:46yurix has joined #asahi-dev
01:50vols_ has joined #asahi-dev
01:54vols has quit [Ping timeout: 480 seconds]
02:00ciara has quit [Remote host closed the connection]
02:09tobhe_ has joined #asahi-dev
02:14ciara has joined #asahi-dev
02:16tobhe has quit [Ping timeout: 480 seconds]
02:31Krishy2007[m]How much of the work done for porting Asahi to M3 actually transfers over to M4?
02:34yurix has quit [Ping timeout: 480 seconds]
02:48damas has joined #asahi-dev
02:56damas has quit [Ping timeout: 480 seconds]
02:58hexdump0815 has joined #asahi-dev
03:00hexdump02 has quit [Ping timeout: 480 seconds]
03:27vols_ has quit []
03:28damas has joined #asahi-dev
03:42Barcher has quit [Quit: WeeChat 4.8.1]
03:47rhysmdnz1111 has joined #asahi-dev
03:48enick_227111 has joined #asahi-dev
03:49nora_ has joined #asahi-dev
03:51nora has quit [Ping timeout: 480 seconds]
03:52enick_22711 has quit [Ping timeout: 480 seconds]
03:53rhysmdnz111 has quit [Ping timeout: 480 seconds]
03:55marvin24_ has joined #asahi-dev
04:01damas has quit [Ping timeout: 480 seconds]
04:02damas has joined #asahi-dev
04:09hwpplayer1 has joined #asahi-dev
04:09hwpplayer1 is now known as Guest9082
04:14Guest9082 is now known as hwpplayer1
04:22damas has quit [Ping timeout: 480 seconds]
04:27hwpplayer1 has quit [Quit: hwpplayer1]
04:28StanfordAppliedCyber[m]yeah basically, and it definitely works
04:28gargantua has joined #asahi-dev
04:29StanfordAppliedCyber[m]will wait for a core dev to tell me to head to the re channel before i discuss any more details
04:29StanfordAppliedCyber[m]if I should head to the RE channel or not*
04:37chadmedif youre gonna talk about apple's code that youve disassembled go to -re. if youre just talking about the general approach you can do so here
04:41gargantua has quit [Ping timeout: 480 seconds]
04:43damas has joined #asahi-dev
04:47StanfordAppliedCyber[m]do we know if anyone else is working on this particular approach? it strikes me as the obvious one and I don't see any blockers that make it nonviable
04:48StanfordAppliedCyber[m]obviously this code could never be shipped to end users, given the whole "massive disasm of sptm", but that's not the point, it'll get us mmio traces
04:51damas has quit [Ping timeout: 480 seconds]
05:08Graypup_ has quit [Quit: meow]
05:08Graypup_ has joined #asahi-dev
05:15chadmedtbh there is absolutely no point if the approach cannot be integrated into the hypervisor codebase and published
05:16Graypup_ has quit [Quit: meow]
05:16Graypup_ has joined #asahi-dev
05:35rhysmdnz1111 has quit [Ping timeout: 480 seconds]
05:40hwpplayer1 has joined #asahi-dev
05:40hwpplayer1 is now known as Guest9087
05:43Guest9087 is now known as hwpplayer1
05:45StanfordAppliedCyber[m]i think i'd want to talk to more experienced reverse engineers about that ofc, and generally i'd imagine the answer depends on how the emulation is done
05:48StanfordAppliedCyber[m]the goal is to be upstreamed
05:52rhysmdnz1111 has joined #asahi-dev
05:56BalasaiPonnaluri[m] has joined #asahi-dev
05:56chadmeddid you try running apple's own sptm blob in a second vm under the hypervisor and trapping XNU's call to it via m1n1? perhaps more effort but less legall frought than trying to reimplement sptm
06:01StanfordAppliedCyber[m]i'd rather make this work first and then see if we can clean up the method, also because i could push the code without the sptm bits and others could fire that up
06:01StanfordAppliedCyber[m]i agree from a copyright perspective that is significantly less risky
06:02StanfordAppliedCyber[m]the answer is i did but sptm is a snowflake-- iirc it hardcodes a bunch of virtual addresses and we'd have to make all those happy
06:04StanfordAppliedCyber[m]if I can get this to work in its current form (ie, the method works), and after deeper discussion with the maintainers we find that the current approach is too risky from a copyright standpoint, then yes that is the approach I'd pivot to, and i'd imagine that carries very little legal risk (obligatory: IANAL)
06:08elvishjerricco2 has joined #asahi-dev
06:11StanfordAppliedCyber[m]actually i'll look into that a bit more, because obviously getting the emulation right is most of my problems now, and using real sptm removes that particular failure case
06:14elvishjerricco has quit [Ping timeout: 480 seconds]
06:14elvishjerricco2 is now known as elvishjerricco
06:16StanfordAppliedCyber[m]you could just patch the standard genter handler with a hypercall and then use that to route xnu genter calls to sptm
06:22hwpplayer1 has quit [Quit: hwpplayer1]
06:26svenreversing SPTM and reimplementing that in m1n1 is very legally challenging unless you write a documentation inbetween and have someone else write the emulator
06:27svenI‘m especially not gonna accept any MR like that from a new contributor, see the binary reversing policy for details
06:28svendon’t get me wrong, the approach will probably work but we really don’t want to enter any legally questionable areas with this project
06:29svenyou’ll also run into some other Apple ISA extensions you’ll have to trap and emulator fwiw but that’s true for every other way as well
06:29StanfordAppliedCyber[m]understood, and yes i did see the policy-- made a point of absolutely never touching any of the kexts in the kernelcache
06:30StanfordAppliedCyber[m]because i do want to get those working at some point and would rather not be documentation writer
06:30StanfordAppliedCyber[m]will move over to the tainted channel for some technical details
06:37asahi has joined #asahi-dev
07:06Yushi has quit [Remote host closed the connection]
07:07Yushi has joined #asahi-dev
07:07Yushi has quit [Remote host closed the connection]
07:08Yushi has joined #asahi-dev
07:09asahi has quit [Quit: asahi]
07:10Yushi has quit [Remote host closed the connection]
07:16Yushi has joined #asahi-dev
07:25Yushi has quit [Remote host closed the connection]
07:26Yushi has joined #asahi-dev
07:38Yushi has quit [Remote host closed the connection]
07:39Yushi has joined #asahi-dev
07:45Yushi has quit [Remote host closed the connection]
07:46Yushi has joined #asahi-dev
07:58gargantua has joined #asahi-dev
08:17hwpplayer1 has joined #asahi-dev
08:17hwpplayer1 is now known as Guest9094
08:18Guest9094 has quit [Remote host closed the connection]
08:30rivendell has quit [Remote host closed the connection]
08:30rivendell has joined #asahi-dev
08:35hwpplayer1 has joined #asahi-dev
08:41nickchanthe asm2c doesn't have to be in m1n1, m1n1 can call into an opaque blob that's uploaded with python to handle sptm calls
08:47StanfordAppliedCyber[m]I think the goal would be a few fold: if we need full txm emulation, we do it by running it some userspace somewhere with its own emulated sptm. it lives in its own world after all
08:48StanfordAppliedCyber[m]re: the actual sptm, i want to get this working to figure out exactly how much of sptm we need
08:48StanfordAppliedCyber[m]say we actually need <100 lines of C to get macos booting to userspace, we can find a way to clean room that
08:48StanfordAppliedCyber[m]if we need 1000 lines, that's still doable, though far harder
08:49StanfordAppliedCyber[m]if we need 10,000 lines, well, good thing you can run multiple guests in el1!
08:50JamesCalligeros[m]Ersatz sptm will not suffice for some changes because some things have been moved out of xnu into sptm (e.g. darts) but its probably fine for most things
08:50StanfordAppliedCyber[m]yeah there's a whole new sptm range for dart
08:50StanfordAppliedCyber[m]it's like region 3 or soemthing
08:51StanfordAppliedCyber[m]but the whole point of this exercise is to figure that out!
08:51StanfordAppliedCyber[m]that said it's 2am in california and I'm going to bed
08:53StanfordAppliedCyber[m]> the LinkedProgram() class already provide the infrastructure to link such blobs
08:53StanfordAppliedCyber[m]I'm already using it to emulate sptm-- python is way too slow for thousands of calls and i'm obviously not going through 1tr for every iteration loop
08:53chaos_princesschainload.py ?
08:54yukachainload currently doesn't work over debugusb (jannau started looking into that yesterday) and the debug-uart is semi-borked on newer devices
08:55StanfordAppliedCyber[m]yeah i hit that
08:55StanfordAppliedCyber[m]dumb solution: add macho segment to m1n1, then memcpy()
08:55StanfordAppliedCyber[m]i'm not kidding, that's how we load the kcache
08:55StanfordAppliedCyber[m]that's how I load the kcache
08:56StanfordAppliedCyber[m]it does mean m1n1.bin is something like 120mb, but hey you only go through 1tr once
08:57nickchandepending how complex the emulation need to be using LinkedProgram() can make clean implementation easier since it should be legally okay to observe the input->output of the questionable blob the same way it is okay to trace xnu
08:57StanfordAppliedCyber[m]I'll defer to the asahi maintainers on this one
08:58StanfordAppliedCyber[m]i can say that my current emulation, which makes it past virtual memory init, is not super complicated
08:58StanfordAppliedCyber[m]like, split it into two things, there's the sptm handoff, and the sptm runtime (the endpoints)
08:58StanfordAppliedCyber[m]the former is a bunch of page mappings
08:59StanfordAppliedCyber[m]the latter is mostly a bunch of simple endpoints with a small number of more complicated ones
08:59StanfordAppliedCyber[m]that said, i'm not experienced on copyright here other than true clean room == kosher
09:47asahi has joined #asahi-dev
10:06cremfuelled has joined #asahi-dev
10:10cremfuelled has quit [Remote host closed the connection]
10:17svenlet’s see how much SPTM emulation actually requires, if it’s really just ~100-1000k lines the write documentation and then someone else implements it is gonna be fine
10:19gargantua has quit [Ping timeout: 480 seconds]
10:20svenM5 is gonna be much more annoying with the secure kernel and exclaves anyway, not sure how feasible emulation is gonna be there
10:30hwpplayer1 has quit []
10:59chaos_princessyou can probably do a "mixed hle", where you hle the gl2 stuff and run everything else in vms
11:44jannauno, not always and waiting between the reads in the form of debug printf to the fb seems to help
11:44asahi has quit [Quit: asahi]
11:50Guest9106 has joined #asahi-dev
11:52Guest9106 is now known as hwpplayer1
11:56jannaufor each 16k block dockchannel_uart_getbyte() spins 8 times on DATA_RX_COUNT for over 100ms
12:01flokliok, so j773s and j714 both have a different offset to the secondary watchdog (0x3bff8 instead of 0x8008). Tempted to add this as another check to m1n1's wdt.c
12:05jannauI've discussed with yuka yester to simply add `if (adt_is_compatibe("arm-io,t8140")) { ... }` for every device which needs it
12:31nickchanbut even then now for the ISA extensions one get most of it in pcc vre (properly documented!) or for a subset of feature, outright at EL0 userspace
12:31freetolgaconsidering that apple is one of the biggest scale hardware designers out there its probably something arm wants kept secret really hard
12:31freetolgabecause it might be something related to security system since apple is the only vendor that uses its own custom security system
12:32nickchan"properly documented:" https://security.apple.com/documentation/private-cloud-compute/virtualresearchenvironment
12:33jannaudockchannel_uart seems to have to wait ~175ms every 2k of data, no wonder it feels slows. does not match what I measured initally on the a18 pro
12:34renoo has joined #asahi-dev
12:35chadmedpoint is for whatever reason raw boot objects cannot access a boatload of apple features that xnu very much relies on, and making m1n1 a mach-o would start it under sptm and make it not work properly , and so here we are
12:43chaos_princessfreetolga: apple uses linux in datacenter, but not on their own hw. their own hw is basically pcc only, and that runs macos derivative
12:43hardy94 has joined #asahi-dev
12:43chaos_princessyou can infer quite a lot by just reading their job postings :P
12:45nickchan the only place i know apple uses macos proper on cloud is... xcode cloud vm running on qemu probably on linux on xeon golds
12:55yurix has joined #asahi-dev
12:56jannauit's even slower on the neo, 350 ms. not sure anything changed or if I measured something else. I think I did memreads for the benchmark but fetching the ADT was clearly faster as well
13:04yurix has quit [Ping timeout: 480 seconds]
13:06gargantua has joined #asahi-dev
13:15gargantu1 has joined #asahi-dev
13:16gargantua has quit [Ping timeout: 480 seconds]
13:20pb17 has quit [Ping timeout: 480 seconds]
13:24pb17 has joined #asahi-dev
13:26gargantu1 has quit [Ping timeout: 480 seconds]
13:37hardy94 has quit [Remote host closed the connection]
13:42Nefsen402 has quit [Remote host closed the connection]
13:43Nefsen402 has joined #asahi-dev
13:52floklihttps://github.com/AsahiLinux/m1n1/commit/0e88df7bc989a71bda2b8acccc0bd6f5657c3ecb planned to only apply for t814x. j274ap has an offset of 0xeb0000, so it doesn't trigger there currently.
13:54flokliIn the dumps I have here, which might be from a more recent macos version, j274ap's wdt/wdt-version is also '2'.
13:58nickchanflokli: have you checked writing to wdt reg[2] helped with the device not resetting on M4 Max
14:03nickchanflokli: basically what I thought is it is always best to disarm the secondary watchdog regardless of whether it is neccessary and don't print bogus messages on SoCs without the secondary watchdog
14:14nickchanwould at least allow the logic to continue working if say m6 doesn't carry any wdt changes this way
14:27yukaWe encountered the M4 Pro and M5 Max not allowing enabling serial using macvdmtool, but it was possible using central scrutinizer
14:30yukait falls under "Bit mask of lines to map to this action" according to https://asahilinux.org/docs/hw/soc/usb-pd/
14:31yukain other news: I captured some debugusb interactions on mac os using wireshark and am trying to recreate them under linux
14:39pb17 has quit [Ping timeout: 480 seconds]
14:56pb17 has joined #asahi-dev
15:04playboicarti[m] has joined #asahi-dev
15:05eric has joined #asahi-dev
15:05eric is now known as gloom
15:06gloom has quit []
15:10lion328 has quit [Ping timeout: 480 seconds]
15:18gloomy has joined #asahi-dev
15:54mazyuka: CS defaults to using the SBU lines to serial. I suspect that macdvmtool is using the secondary set of USB2 lines.
15:58jannauyuka: cs-sw does not send 0x01800306, it mixes in the variable serial pins in. see `vdm[1] |= 1 << (cxt->serial_pin_set + 16);`
16:09weirdtreething has quit [Remote host closed the connection]
16:09gloomy has quit [Quit: leaving]
16:11weirdtreething has joined #asahi-dev
16:14Deewiant has quit [Remote host closed the connection]
16:15Deewiant has joined #asahi-dev
16:17lion328 has joined #asahi-dev
16:20weirdtreething has quit [Remote host closed the connection]
16:21weirdtreething has joined #asahi-dev
17:27svennickchan: nested virt. put SPTM into GL1/fake-GL2 and the exclave kernel into real GL1 and m1n1 into real GL2
17:28svenyuka: wireshark doesn't capture the full thing because macos is dumb, you need a real usb analyzer
17:29svennot any working code, but i can upload the full traces i have and my python parser for those
17:34hardy94 has joined #asahi-dev
17:41hightower3 has joined #asahi-dev
17:48hightower2 has quit [Ping timeout: 480 seconds]
17:53c10l has quit [Quit: Bye o/]
17:54c10l has joined #asahi-dev
17:54c10l has quit []
17:57svenah, looks like the python code is even on this machine that i have with me: https://f.svpe.de/94abc21820b8833bce0fec48dac352e99138910b23dddcd83d644a84bc629a9b_kis-test.py.txt
17:57c10l has joined #asahi-dev
17:58svenhttps://f.svpe.de/2f3b03f14a51fea811f6edc9685b92599558ccb7c08a6ba85039800983fc2703_kis.py.txt
17:59svenmy plan was to write something that watches for apple debug devices and then uses FUSE/CUSE to expose some /dev/tty.applekis.whatever devcies
18:19amarioguy has joined #asahi-dev
19:26yurix has joined #asahi-dev
19:38damas has joined #asahi-dev
20:09prike28386 has joined #asahi-dev
20:25NoTrace404 has joined #asahi-dev
20:29NoTrace404 has quit [Quit: DarkCode IRC Client]
21:00damas has quit [Ping timeout: 480 seconds]
21:04StanfordAppliedCyber[m]thanks for the help and feedback on the approach @ sven @ other asahi devs who chimed in, will keep yall updated with where i make it
21:05StanfordAppliedCyber[m]parts of this are definitely upstreamable ignoring sptm because among other things i'm adding support for 26.4.1, and i'm optimistic we can find a copyright friendly way of getting the sptm emulation here
21:08WindowPain has quit [Ping timeout: 480 seconds]
21:09WindowPain has joined #asahi-dev
21:18hightower4 has joined #asahi-dev
21:25hightower3 has quit [Ping timeout: 480 seconds]
21:27StanfordAppliedCyber[m]apparently there's evidence the amx gate is just a sysctl, i can investigate this pretty easily just by togging the value and then seeing what amx workloads do
22:15StanfordAppliedCyber[m]also, re: m5, exclaves will be annoying but i'm far more optimistic about "just run them as a separate guest" because sk and the exclae userspace are meant to run under the sptm hypervisor in GL, whereas sptm is itself effectively a hypervisor --> it's snowflaky. for exclaves, secure kernel, and other m5 stuff, my first approach would be second guest as opposed to full emulation, at least based off my current understanding.
22:15StanfordAppliedCyber[m]most of the exclave plumbing is in place on the m4
22:16StanfordAppliedCyber[m]i'll add however that the biggest thing in our favor i that sptm mediates all interactions between gl and el, so ultimately the surface we need to emulate can be reduced to a relatively small set of calls + the sptm handoff
22:35berdanka has joined #asahi-dev
22:50berdanka has quit [Quit: Leaving]
22:58hwpplayer1 has quit []
23:01xal has quit []
23:02xal has joined #asahi-dev
23:14gargantua has joined #asahi-dev
23:23gargantua has quit [Ping timeout: 480 seconds]
23:37berdanka_ has joined #asahi-dev
23:43berdanka_ has left #asahi-dev [Leaving]
23:53hardy94 has quit [Remote host closed the connection]
23:55amarioguy has quit [Quit: My Mac has gone to sleep. ZZZzzz…]