#
…

2023-11-28

00:18rndm has joined #asahi-dev
00:23rndm has quit [Remote host closed the connection]
00:24kidplayer666 has quit [Quit: Connection closed for inactivity]
00:25rndm has joined #asahi-dev
00:40i509vcb has joined #asahi-dev
00:57pounce has quit [Ping timeout: 480 seconds]
01:03pounce has joined #asahi-dev
03:26hightower3 has joined #asahi-dev
03:33hightower2 has quit [Ping timeout: 480 seconds]
04:14crabbedhaloablut has joined #asahi-dev
04:14jeisom has quit [Read error: Connection reset by peer]
04:14jeisom has joined #asahi-dev
04:25i509vcb has quit [Quit: Connection closed for inactivity]
04:28tbodt has quit []
04:28tbodt has joined #asahi-dev
04:32jeisom has quit [Ping timeout: 480 seconds]
04:43tristan2 has joined #asahi-dev
04:45tristan2_ has quit [Ping timeout: 480 seconds]
06:54kidplayer666 has joined #asahi-dev
06:58veebop has joined #asahi-dev
07:02elvishjerricco has quit [Read error: No route to host]
07:03elvishjerricco has joined #asahi-dev
07:04capta1nt0ad has joined #asahi-dev
07:35richyliu2 has quit [Ping timeout: 480 seconds]
07:39richyliu2 has joined #asahi-dev
08:24capta1nt0ad has quit [Ping timeout: 480 seconds]
08:33pjakobsson_ has quit [Ping timeout: 480 seconds]
08:36capta1nt0ad has joined #asahi-dev
08:54capta1nt0ad has quit [Remote host closed the connection]
08:55capta1nt0ad has joined #asahi-dev
09:04kidplayer666 has quit [Quit: Connection closed for inactivity]
09:18capta1nt0ad has quit [Ping timeout: 480 seconds]
10:02kidplayer666 has joined #asahi-dev
11:04capta1nt0ad has joined #asahi-dev
11:13capta1nt0ad has quit [Ping timeout: 480 seconds]
11:18russelltg has quit [Quit: Connection closed for inactivity]
11:19RoguePlanet has joined #asahi-dev
11:19RoguePlanet has quit []
12:39svencan anyone who has multiple M-series SoCs connect the same usb 3 device in the same orientation to all of them and trace atcphy? i want to confirm that there are no differences between the various generations
12:41svenmainly because there were some reports of usb3 being a bit flaky but I think that's because I have the atcphy/dwc3 order wrong in the current kernel
12:44ydalton has joined #asahi-dev
13:14jeisom has joined #asahi-dev
13:24darkapex1 has quit [Ping timeout: 480 seconds]
13:25jeisom has quit [Quit: Leaving]
13:31nicolas17 has quit [Ping timeout: 480 seconds]
14:07DannyBWhee. i figured out why the m3 mmu hangs but i'm not sure what to do about it. It seems the state that m1n1 expects us to start in is not how things start for the m3. So for example, i have to clear the TCR register in chickens (or at least set it to the value that XNU does), to make the MMU init work, even though the MMU init *also* sets the TCR register itself. If i don't, the chip hangs when we set the SCTLR
14:07DannyBXNU resets the TCR very early and uses statically allocated bootstrap pagetables very early in the init until it sets up real pagetables.
14:07DannyBUnless someone has a better idea, i'm going to assume that the set of things that m1n1 wants is defined as "however the m1/m2 chip registers start right now", and ensure we put the m3 in the same state in chickens.
14:07DannyBThe alternative would be to have a real spec of what we expect the invariants to be for m1n1, and put all the chips in that state. Maybe later
14:07DannyBregister. So i assume something changed that is causing addresses to be translated or whatever in a way that we don't want on the m3, but not m1/m2. The MMU is not on when we get it on m3, so i have no idea why this has any effect, but it does!
14:12svenhrm, i think when i wrote the original MMU code I didn't rely on any previous state of the architectural registers
14:13svenif the chickens are correct maybe they changed something with how SPRR/GXF works?
14:14mazif they have stuffed non-architectural stuff in TCR_EL2, that's going to be fun. not.
14:15svenI'd try to remove the sprr/gxf init from m1n1's mmu and see if that changes anything. I think we only need that for the HV
14:16svenhrm, no, looking at it again we leave SPRR/GXF disabled in the MMU init and only prepare everything for the HV
14:17DannyBsven: I'll give it a shot
14:17DannyBsven: I have run it without gxf init and no dice
14:17DannyBsven: but not tried turning off SPRR permissions
14:17svenI think it's just the call to mmu_init_sprr() which may do weird things if they changed those regs
14:17DannyBthere is also an additional MSR lockdown register that is write only
14:18DannyBwhich appears to be MSR lockdown for EL2
14:18DannyBbut i set them to lockdown nothing in chickens (and have tried both ways there too)
14:20DannyBAs for chickens themselves, i automated running every combination of lines in chickens for m3 and they all have the same behavior if i don't play with TCR (IE none of them change that we hang the chip the second MMU is turned on)
14:20DannyBI also was able to get most of the names/info of these chicken bits from the kernel debug info
14:20DannyBand they don't look related
14:20DannyBto MMU/SPRR
14:21DannyB(On the plus side, i did figure out 75% of the unknown chicken bits we are using on the M2 and documented them :)
14:21svennice :)
14:21mazinteresting!
14:21svenhave you checked if the initial xnu pagetables look weird in some way or how that TCR value XNU differs from the one inside m1n1?
14:23svenI don't remember if the initial pagetables already use SPRR but they might
14:23DannyBYes. I have the initial XNU TCR value, and decoded it, ours did not look crazy but maybe i decoded it wrong.
14:23DannyBThe initial TCR, and bootstrap pagetables, are the same in XNU for 14.2 for m2/m3. I was going to look at older kernels today see if it was differnet before, and they just chose something in 14.2 that works for all
14:23DannyBThat code is now old
14:23DannyBand definitely busted
14:24DannyBi'll update it to my hacked up current version
14:24svenj`ey: i'm only asking dumb questions anyway because that usually helps when i'm stuck at weird bugs like that :D
14:24DannyBRubber duck debugging is great
14:24DannyBso please, have at it :)
14:25DannyBThere is a bootstrap SPRR set of perms
14:25DannyBi know the value but don't know what sets it
14:26DannyBThe initial SPRR perms for EL1 (set by iboot i guess?) is 0x2020A5203020FAF5LL
14:26svenhmm... how does the XNU TCR differ from ours?
14:26DannyBand the initial TCR set by XNU in common_start is 0x10800236511A511uLL
14:27svenor, wait, you first set it to the XNU value and then later m1n1 overwrites it and the MMU works then?
14:27DannyBeven though nothing in between allocates memory
14:27DannyBActually
14:28DannyBwe configure TCR in mmu_configure after initing pagetables/etc
14:28DannyBso we do call memalign
14:28DannyBwith whatever the TCR is set to initially
14:29john-cabaj has joined #asahi-dev
14:29svenhrm, how would TCR matter before the MMU is on?
14:29j`eybut the mmu isnt on, right?
14:29DannyBalso a good question
14:29svenbefore mmu_configure? I don't think so
14:29DannyBIt's not
14:30DannyBbecause we would bai and issue a message if SCTLR_M is not
14:30DannyBThere are things that matter regardless of SCTLR state
14:30j`eyDannyB: have you tried setting TCR to some other value, not the one XNU uses?
14:31DannyBsetting it to 0 works
14:31DannyBBut there are things that matter in TCR even with MMU off
14:31DannyBfor example
14:31DannyB"This control has an effect regardless of whether stage 1 of the EL1&0 translation regime is enabled or not."
14:31DannyBTop byte ignore
14:32DannyBi tink that's it
14:32DannyBjust MTX1/0 and TBI1/0
14:34svenMTX should only matter if MTE is available but I don't think the M3 has that
14:35j`eybut presumably those aren't the issue, if setting everything to 0 is fine..
14:35mazdumping the id registers would settle it.
14:37DannyBBTW, can we talk about how weird
14:37DannyB"This affects addresses generated in EL0 and EL1 using AArch64 where the address would be translated by tables pointed to by TTBR0_EL1. It has an effect whether the EL1&0 translation regime is enabled or not."
14:37DannyBwhat does it mean to affect the address generation if they would be translated, but it has effect whether the translation is enabled or not?
14:38DannyBi guess they mean it has effect if it would be translated if the translation was on, even if translation is off?
14:38svenhuh, that does sound strange
14:38DannyBif so it would be easier to say "this bit affects all memory accesses"
14:38DannyBsince they should be equivalent
14:38DannyBin any case, i'll read the ID registers when i get back to the laptop
14:39svendo they write to TCR in the chicken bit sequence inside xnu? maybe there's some truly weird hw bug where they have to do that specifically ordered w.r.t some chicken bit
14:39DannyBit's the first piece of common_start
14:39DannyBthey write it on all m2/m3
14:40svenah, right
14:44DannyBThe open source code of this part is actually correct (IE it matches the compiled kernels):
14:44DannyBThey have set the TCR here for years
14:44svenhm, okay, so probably nothing special then
14:45DannyBit sets it to
14:45DannyB#define TCR_EL1_BOOT (TCR_EL1_BASE | (T1SZ_BOOT << TCR_T1SZ_SHIFT) | (TCR_TG0_GRANULE_SIZE))
14:46DannyBBase is
14:46DannyB (TCR_IPS_VALUE | TCR_SH0_OUTER | TCR_ORGN0_WRITEBACK | \
14:46DannyB TCR_SH1_OUTER | TCR_ORGN1_WRITEBACK | \
14:46DannyB#define TCR_EL1_BASE \
14:46DannyB TCR_IRGN0_WRITEBACK | (T0SZ_BOOT << TCR_T0SZ_SHIFT) | \
14:46DannyB TCR_IRGN1_WRITEBACK | (TCR_TG1_GRANULE_SIZE) | \
14:46DannyB TCR_TBI0_TOPBYTE_IGNORED | (TCR_TBID0_ENABLE) | TCR_E0PD_VALUE | \
14:46DannyB TCR_EL1_DTBI | TCR_EL1_ASID | TCR_EL1_EXTRA)
14:46DannyBand boot is
14:49nicolas17 has joined #asahi-dev
14:50DannyBAnyway, let me turn off sprr perms and see if that works without messing with TCR.
14:57ydalton has quit [Remote host closed the connection]
15:04svenit’s still so weird that first writing zero to tcr makes everything work
15:12darkapex1 has joined #asahi-dev
15:13svendouble checked that we also overwrite tcr from m1n1 so the previous value really shouldn’t matter :/
15:15DannyBi actually was going to ask if anyone has ever decrypted iboot on macos
15:15DannyBand see what the heck it's doing
15:15DannyBfor m3 vs m2, if anything
15:15DannyBWe are basically trying to figure out if iBoot has put it in a different state or what
15:17svenI think there are keys floating around for some iboots
15:18sveni'm still very confused because we overwrite TCR anyway. what state is left that get cleared by first setting that one to zero?
15:19svenwhat happens if you just write the m1n1 value twice? does that also fix it? :D
15:23svenalso looked for missing barriers but we have a isb inbetween setting up tcr and enabling the mmu
15:42pounce has quit [Ping timeout: 480 seconds]
15:45nicolas17there are M2 keys
15:47nicolas17does anyone here have M3 Max? Siguza was looking for the bootrom version and CPRV (which appear on the DFU serial string)
15:48j`eythat's what DannyB has
15:53pounce has joined #asahi-dev
15:53nimprod3l has joined #asahi-dev
16:03mazhuh, I never realised: generating a reset command from a CS on a M2 that is powered-off brings it back to life (tested on M2 Pro mini and M2 MBA). doesn't work on my M1 mini.
16:09kettenisworks on my M1 mini
16:09kettenisthere is a quirk though
16:09svencentral scrutinizer, hardware that talks usb pd to send those Apple VDM commands
16:10kettenisit only seems to work if you power down the machine with CS connected to another machine
16:14mazmaybe the FW on my M1 is a bit too old (never updated).
16:15kettenisasahi,system-fw-version: '12.3'
16:15kettenisguess I did update it at some point
16:15mazI'm still on whatever the thing came with.
16:16maz11.0 or similar.
16:28DannyBnicolas17: I have one. what do you need? (I'm not near it for a few hours, but can get it when i am back)
16:29DannyB@sven: We do call memory allocation functions prior to setting the TCR. But the MMU is disabled. So the only effect could be from top byte ignore i guess?
16:29DannyB(or MTE if it's supported and enabled)
16:31DannyBI have not tried writing our value earlier
16:31DannyBi wil do that
16:32nicolas17DannyB: enter DFU, run "irecovery -q" from the other machine, it will show CPRV and SRTG (bootrom version)
16:32nicolas17(you may want to redact ECID if you post the whole output :P)
16:32DannyBokay, i'll be near it in an hour or two
16:32nicolas17yeah no rush, thanks!
16:36svenim pretty sure the memory allocation functions just do internal bookkeeping and ignore whatever the mmu does
16:42DannyBOne random thing i noticed - we init the mcc, and init the mmu, but we never actually set the cache to a known state (disabled or enabled). mcc_init just sets up the registers. Apple's MCC init explicitly disables and then enables cache.
16:47sventhe mmu should work with MMC left in whatever state iboot leaves it - at least for m1
16:47DannyBin any cse, this has all been useful so far. i'll go try some stuff here and see what happens
16:48svenI‘m very curious about the root cause for this :)
17:04pounce has quit [Ping timeout: 480 seconds]
17:06pounce has joined #asahi-dev
17:17pounce has quit [Ping timeout: 480 seconds]
17:39pounce has joined #asahi-dev
17:51pounce has quit [Ping timeout: 480 seconds]
18:03pounce has joined #asahi-dev
18:05elvishjerricco has quit [Ping timeout: 480 seconds]
18:09nicolas17macOS 14.2 beta 4 is out
18:16nimprod3l has quit [Read error: Connection reset by peer]
18:17nimprod3l has joined #asahi-dev
18:20nyx_o has quit [Ping timeout: 480 seconds]
18:28pounce has quit [Ping timeout: 480 seconds]
20:11pounce has joined #asahi-dev
20:21john-cabajApologies if this has been discussed, but have any Asahi patches been upstreamed in 6.6 not in 6.5? It's easy enough to backport Asahi commits following the v6.6 tag, but if any patches fell in 6.6, it's trickier to determine.
20:25nimprod3l has quit [Ping timeout: 480 seconds]
20:26j`eyjohn-cabaj: you mean you have a 6.5 kernel tree, and want to port the patches from the curent 6.6 asahi tree?
20:26j`eybut dont want to miss stuff that was upstreamed in 6.6?
20:34pounce has quit [Ping timeout: 480 seconds]
20:35crabbedhaloablut has quit []
20:55j`eyIm not sure if there's an easy way to do that in general really
20:56elvishjerricco has joined #asahi-dev
20:56john-cabajThere's definitely iommu changes between 6.5 and 6.6 that some Asahi patches will need backported, possibly others.
20:56john-cabajBut those weren't Asahi specific. Anything Asahi specific existing upstream in 6.6 not in 6.5 is a bit of a blind spot.
20:57j`eygit range-diff v6.5..asahi-6.5-29 v6.6..asahi-6.6-3 might help a bit
20:59john-cabajGood idea, that's a start.
21:00j`eyor just switch to 6.6 :p
21:02john-cabajYeah, could do that too. Then will need backport kernels to previous releases. But that still might be easier.
21:27elvishjerricco has quit [Remote host closed the connection]
21:28blazra3 has joined #asahi-dev
21:30blazra has quit [Remote host closed the connection]
21:30blazra3 is now known as blazra
21:42elvishjerricco has joined #asahi-dev
21:45qyousef has quit [Write error: connection closed]
21:45qyousef has joined #asahi-dev
21:46kuruczgy has quit [Read error: Connection reset by peer]
21:46d4ve has quit [Read error: Connection reset by peer]
21:46amada95 has quit [Read error: Connection reset by peer]
21:46coder_kalyan has quit [Read error: Connection reset by peer]
21:46signaryk has quit [Read error: Connection reset by peer]
21:46alethkit has quit [Write error: connection closed]
21:46handlerug has quit [Write error: connection closed]
21:46probie has quit [Write error: connection closed]
21:46akspecs has quit [Write error: connection closed]
21:46okt has quit [Write error: connection closed]
21:46tsujp has quit [Write error: connection closed]
21:46rosefromthedead has quit [Write error: connection closed]
21:46pldtf has quit [Write error: connection closed]
21:46ella-0 has quit [Write error: connection closed]
21:46cds has quit [Write error: connection closed]
21:46dubiousness has quit [Write error: connection closed]
21:46dk_ has quit [Write error: connection closed]
21:46elvishjerricco has quit [Remote host closed the connection]
21:46cds has joined #asahi-dev
21:46probie has joined #asahi-dev
21:46dk_ has joined #asahi-dev
21:46okt has joined #asahi-dev
21:46signaryk has joined #asahi-dev
21:46tsujp has joined #asahi-dev
21:46coder_kalyan has joined #asahi-dev
21:46kuruczgy has joined #asahi-dev
21:46handlerug has joined #asahi-dev
21:46rosefromthedead has joined #asahi-dev
21:46alethkit has joined #asahi-dev
21:46akspecs has joined #asahi-dev
21:46pldtf has joined #asahi-dev
21:46amada95 has joined #asahi-dev
21:46dubiousness has joined #asahi-dev
21:46ella-0 has joined #asahi-dev
21:46d4ve has joined #asahi-dev
21:46esden has quit [Ping timeout: 480 seconds]
21:47esden has joined #asahi-dev
22:05jole has quit [Remote host closed the connection]
22:05jole has joined #asahi-dev
22:08jole has quit [Remote host closed the connection]
22:08jole has joined #asahi-dev
22:39jeisom has joined #asahi-dev
23:14so101 has joined #asahi-dev
…