#
…

2021-12-17

01:15yuyichao_ has joined #asahi-dev
01:19yuyichao has quit [Ping timeout: 480 seconds]
01:46yuyichao_ has quit [Ping timeout: 480 seconds]
02:33leah has quit [Ping timeout: 480 seconds]
02:52chadmed has quit [Quit: Konversation terminated!]
02:55riker77_ has joined #asahi-dev
03:00riker77 has quit [Ping timeout: 480 seconds]
03:00riker77_ is now known as riker77
03:13StupidYui has quit [Read error: Connection reset by peer]
03:28tpw_rulessven: so i noticed the shutdown stuff was removed at some point?
03:33leah has joined #asahi-dev
04:02phiologe has joined #asahi-dev
04:03squags has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
04:03squags has joined #asahi-dev
04:05PhilippvK has quit [Ping timeout: 480 seconds]
04:05kov has quit [Quit: Coyote finally caught me]
04:05kov has joined #asahi-dev
04:40nabaiste^ has joined #asahi-dev
04:57tpw_rulesis any of the rtkit stuff documented anywhere except in that file? or has anyone posted logs of rtkit stuff wrt the nvme device?
04:58tpw_rulesi should probably figure out how to set up m1n1's rtkit logger thing
05:29yuyichao_ has joined #asahi-dev
05:54Emantor has quit [Quit: ZNC - http://znc.in]
05:55Emantor has joined #asahi-dev
06:37chadmed has joined #asahi-dev
06:38Dcow has joined #asahi-dev
06:39chadmed has quit [Remote host closed the connection]
06:44Dcow has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
06:52jannau has quit [Ping timeout: 480 seconds]
06:52_jannau_ has quit [Ping timeout: 480 seconds]
06:54Dcow has joined #asahi-dev
06:59Dcow__ has quit [Ping timeout: 480 seconds]
07:10jannau has joined #asahi-dev
07:10_jannau_ has joined #asahi-dev
07:59gladiac is now known as Guest8685
07:59gladiac has joined #asahi-dev
08:05Guest8685 has quit [Ping timeout: 480 seconds]
08:22Dcow_ has joined #asahi-dev
08:38chadmed has joined #asahi-dev
08:43sventpw_rules: Huh, why do you think it was removed?
08:44svenand that file is pretty much the only documentation
08:44svenit’s more recent than what’s in m1n1 as well fwiw
08:55coder_kalyan has joined #asahi-dev
09:32Dcow_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
09:35chadmed has quit [Quit: Konversation terminated!]
10:03chadmed has joined #asahi-dev
10:42Dcow_ has joined #asahi-dev
10:57kettenissven: I'm probably going to look at adding the code to (re-)start the coprocessors in OpenBSD this weekend
10:58kettenisthen I can shut them down in U-Boot
10:58svenlet me know if you have any questions, I’ve done that in that “new” nvme driver there. And also
10:58sven*and also please figure out how to reset them no matter which state they’re in ;)
10:59aleasto has joined #asahi-dev
11:00svenfwiw, that thing doesn’t support the admin abort command. I’ll remove that one from the Linux driver as well
11:00kettenislooks like u-boot doesn't use the abort command
11:01kettenisdoes the nvme/dev branch reflect your latest understanding of the rtkit stuff?
11:42Dcow_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
11:46as400[m] has joined #asahi-dev
11:53Dcow_ has joined #asahi-dev
12:11Dcow_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
12:12svenPretty much
12:12sveni can push my local branch later today
12:12svenbut I think that one only has changes to the nvme part
12:13Dcow_ has joined #asahi-dev
12:17Dcow_ has quit []
12:34svenjust pushed what i have locally
12:58chadmed has quit [Ping timeout: 480 seconds]
13:23tpw_rulessven: ah hm, i guess that commit was never merged? i feel like that is new
13:24tpw_ruleskettenis: did you already have code to shut them down in u-boot in some other branch? i worked on it a bit last night but haven't got it working yet
13:27kettenisI think the nvme driver will need a .remove method
13:33kettenisbut a quick test shows that that doesn't get called
13:35tpw_ruleskettenis: i got far enough to figure out you need this flag: https://github.com/u-boot/u-boot/blob/7958292f5ffa4ecdaaf4c73c6df28006051db6e0/drivers/mmc/mmc-uclass.c#L504 to ask u-boot to remove it before starting the OS
13:37tpw_rulesbut the processors did not seem to be responding to my messages to shut them down. i was a bit suspicious that u-boot left them in a bad state starting up.
13:37sventpw_rules: yes, that code is newer than what's in the main branch
13:38tpw_rulessven: ah ok, i got confused because i saw a commit with the same name that was more recent
13:39kettenistpw_rules: it leaves the device in a usable state; nvme works fine in OpenBSD this way
13:40tpw_ruleskettenis: yeah the drive does work, but it seems the processors are confused. i altered how u-boot started them slightly and then the processors at least replied to my shutdown messages, but linux still couldn't start them back up properly. ah well, i will get back to it in a few hours
13:41svenyou need the "new" code to start them back up
13:41svenor at least set that reset bit in the PMGR regs
13:42tpw_rulesby the way, do all the macbook keyboards work in u-boot in the apple-m1-m1n1-nvme branch
13:42marcanleaving them running isn't really valid anyway without some kind of handoff mechanism for the SART buffers
13:45ketteniscurrently u-boot reserves the memory for the SART buffers in the EFI memory map
13:45kettenisso that part is "safe"
13:45kettenisof course it means that the OS has no access to the logs
13:45ketteniswhich is not ideal
13:46kettenistpw_rules: only usb keyboards work in u-boot
13:46marcankettenis: if it decides to log without getting its locks acked it well might deadlock
13:46kettenisso none of the laptop keyboards do
13:47svenit'll deadlock once rtkit's syslog ring buffer is full
13:47marcanso definitely not safe
13:47svenand if you do large transfers it's going to send some "new WhateverBuffer %d" created messages
13:47kettenisnvme doesn't seem to do any logging though (but SMC does)
13:48svennvme *does* some logging, but only if you saturate the link for a while
13:48kettenisanyway, I agree, this needs to be fixed
13:48sven(also if you send invalid commands)
13:49ketteniswhich is why I didn't try to upstream the NVMe stuff yet
13:51nabaiste^ has quit [Remote host closed the connection]
13:52sveni should fix the error recovery and submit a RFC as well
14:00tpw_ruleskettenis: ah ok, i saw some work on the spi drivers so i wasn't sure
14:29kgarrington has joined #asahi-dev
14:29kgarrington has quit [Remote host closed the connection]
14:42yuyichao_ has quit [Ping timeout: 480 seconds]
14:56skoobasteeve has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
14:59yuyichao_ has joined #asahi-dev
15:06skoobasteeve has joined #asahi-dev
15:16Dcow_ has joined #asahi-dev
15:22jbowen has joined #asahi-dev
16:24Dcow_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
16:26zimsneexh has joined #asahi-dev
16:36Dcow_ has joined #asahi-dev
16:37Dcow_ has quit []
16:42Dcow_ has joined #asahi-dev
17:18yuyichao_ has quit [Quit: Konversation terminated!]
17:23m42uko has quit [Ping timeout: 480 seconds]
17:25yuyichao has joined #asahi-dev
17:35tpw_ruleswhat is the apple device tree name of the ASC responsible for the nvme drive?
17:38j`ey(which is what it's also called in the linux dt)
17:38j`eyans: mbox@277408000 and ans2: nvme@27bcc0000
17:39marcan(and those labels are weird, should probably just be ans_mbox for the first)
17:39marcan(ans2 is the version AIUI, so that one makes sense)
17:39kettenisthat's what sven has in his tree
17:42svenThe kext and ioreg calls it ANS3 fwiw
17:43svenAnd I think in my current tree they’re called ans_mailbox and ans
17:43sventhat old tree had a big “WIP” and “DO NOT MERGE” in the device tree commit that you people all just ignore :p
17:44j`eysven: DO NOT MERGE (into mainline) is how I read it :P
17:45kettenisthe nvme node doesn't need a label as far as I can tell
17:46marcanI think we've been kind of labeling everything out of inertia, but yeah, I don't see us doing anything with that one
18:26kilrain[m] has joined #asahi-dev
18:29yuyichao_ has joined #asahi-dev
18:32yuyichao has quit [Ping timeout: 480 seconds]
19:31conradevDoes anyone know how this raw image change will affect the installation flow? Does this give any insight into what materials are needed on a partition to convince Apple to boot it, or is it orthogonal?
19:31conradevDoes anyone know how this raw image change will affect the installation flow? Does this give any insight into what materials are needed on a partition to convince the bootloader to boot it, or is it orthogonal?
19:40aleasto has quit [Remote host closed the connection]
19:53alyssamarcan: sven: relatedly - Is it theoretically possible to run (a clone of) kmutil under Linux, after security has been downgraded in 1TR?
19:54alyssaOr does the security model prevent that?
19:54svenwhat use case do you have in mine for that?
19:55svenwe we certainly can't do is upgrade and/or change the m1n1/uboot payload from linux
19:55sven*what we
19:55alyssasven: ^ that
19:56svenyeah, not gonna happen
19:56sventhe security model requires assertion of physical presence to update the boot object (i.e. long-press the power button to go into 1TR)
19:56alyssaon e.g. chromebooks with their funny boot model, once security is downgraded you can reflash the machine live with dd to the right partition
19:56alyssawasn't sure how Apple had things set up
19:57svenyeah, apple has a stronger model
19:57ChaosPrincesswhat happens if you bless a mach-o with kmutil, and then overwrite that file on disk?
19:57svenwhat do you mean with "bless a mach-o"?
19:58ChaosPrincesskmutil configure-boot whatever.macho
19:58sventhat just doesn't work
19:58kettenisit will fail to boot
19:58svenconfigure-boot talks to SEPOS and requests it to include the boot object's hash into this local policy thing and then sign that
19:58svenbut SEPOS will only do that if the machine is in 1TR
19:59alyssasven: How do macOS kernel upgrade work?
20:00alyssaApple has a private key backdoor to this? or the installer reboots into 1TR?
20:00svendon't know the details but they can sign the kernel with their key
20:01alyssaHow dreadfully boring :-p
20:01svenit'll also ask for your password during the update because SEPOS will have to re-encrypt anything that was encrypted with a key derived from the old firmware with the key derived from the new firmware
20:01alyssaHuh, neat
20:01alyssaApple takes this seriously :)
20:02sventhere's a security whitepaper from them somewhere that superficially explains all that
20:02sventhis entire design is pretty great :-)
20:02ChaosPrincessso its kinda like secureboot + mok(if permissive security) + disk encryption via tpm tied to firmware and kernel hashes?
20:03sveni don't know what mok is
20:12svenhrm... now that i think about it again, i think you can actually install custom kexts without taking a detour through 1TR after security has been downgraded once
20:25ChaosPrincesssven: so, thats not quite how kmutil works apparently. if you do configure-boot, it will stash the new boot object _somewhere_, and you can freely overwrite the old file, it no longer matters
20:25svenuh, yes?
20:26kettenisif you follow the instructions, you download the file to a ramdisk
20:26kettenisso it will be gone after you reboot
20:27ChaosPrincessfollowing the instructions is for those who dont want to spend a few hours trying to understand why edits to the initrd dont seem to work :P
21:00Dcow_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
21:20tpw_ruleskettenis: i an convinced at this point u-boot is not properly starting the ANS ASC, despite the fact that the drive works. see the logs here: https://pastebin.com/qdXKfVhZ . u-boot does not do most of the transactions on endpoint 4, never gets the final 0xb message on the management endpoint, and never gets any log messages
21:22tpw_rulesi have a feeling it's not happy with the memory addresses it's given. it's not obvious to me how linux allocates the memory it hands out, and it doesn't seem to touch those MMIO registers at 0x2774000xx
21:25svenpretty sure there's something wrong with the device tree you're using for u-boot
21:26svenit looks like it's trying to configure SART at 0x277400000 while that should actually be at 0x27bc50000
21:26tpw_rulesyeah i just had that realization too. but the nvme's sart in the device tree is at 0x27bc50000 . so maybe u-boot is loading it wrong
21:27tpw_rulesand it was never noticed since the drive still works...
21:27svenno, that makes no sense
21:27tpw_ruleswhat doesn't?
21:28svenwhat you just said
21:28svenkeep in mind that the device tree for u-boot and linux probably still looks a bit different at this point
21:29svenspecifically for drivers like sart/nvme that haven't been upstreamed yet
21:30tpw_rulesthis is the relevant part of the u-boot device tree: https://pastebin.com/Vzyv2B6S it's the same as the linux one, except the phandles are different naturally
21:30svenunless apple changed something in the ANS firmware the nvme layer will not come up before at least crashlog and syslog have been initialised successfully
21:30tpw_rulesi see that 0x277400000 pointer in the nvme's registers, do you expect that to point to the sart?
21:31jannauu-boot device tree should not be used. use u-boot-nodtb.bin
21:31sveni'm not too familiar with u-boot but i know that it used to receive syslog messages
21:32tpw_rulesso that line should be reg = <0x02 0x7bcc0000 0x00 0x40000 0x02 0x7bc50000 0x00 0x10000>; ? i'm not so sure
21:32svenwhat makes you think that?
21:33tpw_ruleswell a) because it's how it is in that pastebin in the linux kernel device tree which works and b) i would expect it to read the address of the sart registers from the linked sart node
21:33sventhat's certainly not how it's in the linux device tree
21:33svenreg = <0x2 0x7bcc0000 0x0 0x40000>, <0x2 0x77400000 0x0 0x4000>;
21:33svenand the sart node should be reg = <0x2 0x7bc50000 0x0 0x10000>;
21:34svenbut i don't know if u-boot uses the same bindings
21:34tpw_rulesokay, so then the device tree is correct, i just explained it wrong
21:34tpw_rulesthen yes, i'm pretty sure u-boot copied over the linux device tree, the semantics changed, but no one noticed because the drive still initialized enough to be readable
21:35sventhat sounds weird
21:35svenas i said, i very much remember trying to get away with as little initialization as possible
21:36svenand it wasn't possible to bring up nvme without rtkit being up as well
21:36svennow that could've changed if apple changed the ANS firmware but it would surprise me
21:36ketteniswell, what can I say, this works for me on two machines
21:37kettenisI can access the nvme disk from u-boot and I can use it as the root disk for OpenBSD
21:38kettenisboth machines have macOS 11.x firmware though
21:39svenmy money is still on some issue with the device tree. that hypervisor trace very much looks like u-boot for some reason thinks SART is 0x277400000. and i know it didn't use to think that because it also worked for me
21:39kettenisand I synced up the device tree with the asahi linux branch just a few days ago
21:40kettenisreg = <0x2 0x7bc50000 0x0 0x10000>;
21:40svenyeah, i dunno what's going on with tpw_rules's machine either
21:41sventhat all looks correct to me
21:51tpw_rulesthough the actual problem doesn't appear to be fixed yet
21:56roxfan has quit [Remote host closed the connection]
22:00roxfan has joined #asahi-dev
22:02m42uko has joined #asahi-dev
22:02kettenisnow how did that ever work?
22:03svenmaybe you accidentally did find a way to boot ANS without booting RTKit completely
22:04svenbut i'm still not sure how that could ever work. it should hang once nvme is brought up because it will try to write to the syslog at that point
22:06tpw_rulesi mean it does by all accounts hang. it's just that that doesn't seem to matter too much somehow
22:07svenyeah, but nvme should also hang in that state
22:07tpw_rulesnot really knowing any of the context, maybe the nvme still works if the IOP is okay but the AP is not?
22:08svenuh, i'm confused now
22:08svenIOP = the thing RTKit runs on
22:08svenand that thing should hang if SART isn't configured correctly
22:09kettenisas long as it doesn't log, it should be ok
22:09tpw_rulesthen what is the AP?
22:10kettenisand I've not seen it log
22:10svenokay, that's very strange then
22:10tpw_rulesit seems to always print out stuff about garbage collection when linux starts it
22:10svenbecause it definitely logs when the admin queue is brought up
22:11kettenisboth the u-boot and the OpenBSD driver still have some magic writes inherited from the corellium driver
22:11j`eytpw_rules: ap = application processor, main cpu
22:11kettenisso maybe those are relevant here...
22:12sventhose weird 0x102/0x1002 writes?
22:12pavellatko[m] has joined #asahi-dev
22:12sveni haven't observed any difference without those fwiw
22:12tpw_rulesj`ey: i mean my conception, driven purely by the names of the relevant messages, is that each thing that runs rtkit has both an IOP and an AP. is that true?
22:13sventpw_rules: AP = that thing that runs linux/openbsd/u-boot/..., IOP = that thing which runs RTKit
22:13kettenissven, yes
22:14tpw_rulessven: so there are a bunch of IOPs and one AP (of several cores)? i'm a little confused about what the SET_AP_PWR_STATE message is for then
22:15svenask apple about that one. the name comes from a string RTKit sends over syslog when you use that message with an invalid power state
22:15svenmaybe it's more like "report AP power state"
22:17pavellatko[m] is now known as latko[m]
22:26kettenispushed the fix; thanks tpw_rules for spotting that
22:27svenhrm, so even with those 0x102/0x1002 writes it still tries to write to the syslog. i'm still confused how that ever worked
22:27tpw_rulesi'm pretty sure there is still something wrong as the trace hasn't changed
22:30tpw_rulesi did change a few other miscellaneous things to make the trace look more like linux's. but if/when i get all this working i'll send you a patch
22:31svenfwiw, the trace doesn't have to look exactly identical
22:31sventhe different endpoints on RTKit (syslog, crashlog, etc.) are running in different threads
22:32tpw_rulesit's actual content issues, not just ordering
22:34kettenisI'm fairly confident that I do see a 0xb message for the SMC but don't see one for ANS
22:36sven hm.... that's strange
22:36svenbecause i'm pretty sure i see one for ANS
22:44tpw_ruleswhat exactly does the IOReporting endpoint talk about?
22:51svenlet me know once you figure it out :-)
22:52ketteniszzz time here; going to take a closer look at this from the OpenBSD side tomorrow
22:55svenMight be a descendant of that
23:14amarioguy has joined #asahi-dev
23:18amarioguyso.... hate to ask but how can I start contributing? is there a git repo where we submit stuff like pull reqs and all that?
23:19j`eyamarioguy: no pull requests currently, just do stuff in your own repo!
23:19j`eyand people can test it by cherry-picking or markan will put it into the main asahi repo if its good enough for wider testing
23:24jannaupull request for m1n1 are fine though, repo is https://github.com/AsahiLinux/m1n1
23:29yuyichao has joined #asahi-dev
23:32yuyichao_ has quit [Ping timeout: 480 seconds]
23:42yuyichao has quit [Ping timeout: 480 seconds]
23:43tpw_rulesso this neat t8103-pmgr-pwrstate thing labeled ans2 cannot actually be used to reset the nvme stuff?
…