2022-12-02
00:06tenkuu_ has quit [Quit: WeeChat 3.7.1]
00:28user982492 has joined #asahi-dev
00:40beeblebrox has quit [Quit: Konversation terminated!]
01:35marcan has quit [Server closed connection]
01:35marcan has joined #asahi-dev
01:48user982492 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
01:54user982492 has joined #asahi-dev
01:57mixi has quit [Server closed connection]
01:57mixi has joined #asahi-dev
02:17Ziemas has quit [Server closed connection]
02:18Ziemas has joined #asahi-dev
02:21vafanlignarde has quit [Server closed connection]
02:21vafanlignarde has joined #asahi-dev
02:33V has quit [Server closed connection]
02:33V has joined #asahi-dev
02:40Foxboron has quit [Server closed connection]
02:40Foxboron has joined #asahi-dev
02:54commandoline_ has quit [Server closed connection]
02:55commandoline has joined #asahi-dev
02:58ma4 has joined #asahi-dev
03:05ma3 has quit [Ping timeout: 480 seconds]
03:06kaprests has quit [Server closed connection]
03:06kaprests has joined #asahi-dev
03:14erincandescent has quit [Server closed connection]
03:19Fanfwe has quit [Server closed connection]
03:20Fanfwe has joined #asahi-dev
03:33capta1nt0ad has joined #asahi-dev
03:34capta1nt0ad has quit []
03:45leah2 has quit [Server closed connection]
03:45leah2 has joined #asahi-dev
03:47ckb has quit [Server closed connection]
03:47ckb has joined #asahi-dev
03:53user982492 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
03:56chadmedan attempt was made but im not sure how good it is. it builds and it runs and its fast but idk if its very "rust"y
04:00vup has quit [Server closed connection]
04:01chadmedbecause the driver would have to be running a time check on the last access to the IOCTL. how would that play out with suspend etc?
04:03chadmedit depends on exactly what we're trying to prevent from happening. if the daemon encounters a runtime error (all possible ones are currently handled) then it can just send a single IOCTL to the driver to enable codec safe mode
04:04chadmedthe keepalive would only be useful in the case of the daemon segfaulting (should be impossible) or being forced dead by oomd or whatever
04:06tpw_rulese.g. all of https://github.com/chadmed/speakersafetyd/blob/main/src/types.rs#L138-L145 would idiomatically be let val: i32 = self.level.val.get_integer(0).expect("level is readable")
04:09chadmedand we dont use the mixer or pcm alsa lib interfaces which are the ones prone to such nonsense
04:10tpw_rulescertainly a lot less likely than in C but it's not absolutely impossible. just saying you would have to register a separate signal handler for that case
04:11tpw_ruleslooked it up and you would want let val: i32 = self.level.val.get_integer(0).unwrap_or_else(|| panic!("level of {} is readable", self.drv))
04:12tpw_rulesthe || introduces a lambda which is only called if get_integer returns None to avoid the (likely negligible) cost of formatting the string in the happy path
04:13chadmedah see i was trying to avoid unwrap()s and expect()s thinking it would be better to explicitly handle each Option and Result from the alsa lib bindings but if thats acceptable then that works and is less gross
04:14chadmedi was under the impression that they just unconditionally panic on failure and i wanted to handle whatever alsa-lib returned in a controlled manner
04:15irth has quit [Server closed connection]
04:15tpw_rulesthey do unconditionally panic on failure, but imo that's what you should hook into if you are just going to complain and die
04:15irth has joined #asahi-dev
04:15CME has quit [Server closed connection]
04:15CME has joined #asahi-dev
04:17tpw_rulesunwrap_or_else will call a function on None and return that functions value but obviously if it panics or std::process::exit()s then that won't happen
04:20tpw_rulesthere is also the RAII approach. i admit i might be misleading you on the panic hook. i think about it a decent amount in embedded rust but maybe it's not a big thing in desktop rust now that i poke a bit
04:21lonjil has quit [Server closed connection]
04:21lonjil has joined #asahi-dev
04:23chadmedit makes sense to me in this case since (imo) we should put the speakers in safe mode and die if we encounter any error
04:24chadmedsomething has gone very wrong if any of the values we get back from the CTL interface are bad, we cant guarantee safety for machines we dont have the config data for, etc
04:30qyliss has quit [Server closed connection]
04:30chadmedmy main concern apart from that anyway was the maths for the actual safety stuff, but i cant really test any of that until the driver has V/ISENSE support anyway
04:30qyliss has joined #asahi-dev
04:31nyx_o has joined #asahi-dev
04:38povik has quit [Server closed connection]
04:38povik has joined #asahi-dev
04:40greguu has quit [Ping timeout: 480 seconds]
04:41espo has quit [Server closed connection]
04:41espo has joined #asahi-dev
04:48noopwafel has quit [Server closed connection]
04:48noopwafel has joined #asahi-dev
04:57veloek has quit [Server closed connection]
04:57veloek has joined #asahi-dev
04:58dsharshakov has joined #asahi-dev
05:00dsharshakovchadmed: "how would that play out with suspend etc?" Block immediately after suspend and unlock when daemon thaws and starts working. We shouldn't let 1% chance (likely bc of user's own stupidity) to bite someone
05:01mjolnir[m] has quit [Server closed connection]
05:01matrix_ds has quit [Server closed connection]
05:01mjolnir[m] has joined #asahi-dev
05:02ahdeb[m] has quit [Server closed connection]
05:02ahdeb[m] has joined #asahi-dev
05:03dsharshakovSuspend can be a corner case for ALSA, btw. In PW we have quite some bugs of hardware not working after resume (some are caused by drivers though). So if daemon is dead after suspend (alsa bugged out, or device resumed badly and only gives 00s or otherwise garbage) it shouldn't be considered adequate
05:03chadmedtheres a PR in AsahiLinux/linux that makes power management work for the tas codecs, so we dont have to worry about the hardware doing undefined stuff
05:04matrix_ds has joined #asahi-dev
05:05dsharshakovAnd yes, it might be useful to check whether hw doesn't give us obvious nonsense such as high-entropy data or constants (or other failure modes). We mustn't claim it's fine by measurements but raise an alarm
05:05chadmedits more a case of how much overengineering do we want to do to prevent an edge case of an edge case of an edge case (someone not using a DE on the laptops -> the daemon crashing -> someone blaring bass boosted amogus trap nightcore remix at full volume)
05:06dsharshakov* daemon receiving a signal from layer8 which truly believes you tossed some malware to them. How could speakersafetyd be useful for my computer hmmm
05:07dsharshakovAnd some issues which lead to us getting garbled buffers might exist really if some bug happens in the kernel driver
05:07chadmedyeah and what if evil ninjas sent by tim apple break into my house and killall speakersafetyd while im not looking? should speakersafetyd have an aperture science turret built in to it?
05:08dsharshakovWell, if it's not pinging kernel enters safe mode then
05:09chadmedwe could run this treadmill all day and all night and end up with a 30MB binary that has a firewall built into it to stop people breaking in via telnet to run aplay -D hw:0,1
05:10dsharshakovThe ping is not overengineering imo. This way to destroy the speakers user has to know how to call ping ioctls, that unlikely coexist with stupid actions
05:11chadmedagain though, its a case of this only _ever_ being a possible failure mode in a vanishingly small set of circumstances
05:11dsharshakovWell, not insisting. The overall approach seems quite nice engineered, looking forward to seeing some info about it working
05:12chadmedhell with the IRs alone the speakers are impossible to blow up, so not only does the daemon have to fail but you have to be accessing it via the raw alsa device AND doing so at sustained full volume
05:12chadmedif the daemon is killed by any means we already have our panic and fail handlers that would theoretically do the IOCTL to put them into safemode
05:12dsharshakovAnd if it ooms oom service likely will send a sigterm first
05:13dsharshakovIdk if kernel oom killer will warn before killing
05:13chadmedso theres like 0.00000000001% chance that we enter a state where a keepalive would be useful
05:13dsharshakovYes, oomd and early earlyoom send terminate, but what about kernel
05:14dsharshakovI see the point
05:14dsharshakovWell, users need to kill it with segkill to avoid proper shutdown, Yes?
05:16dsharshakov has quit [Remote host closed the connection]
05:29dsharshakov has joined #asahi-dev
05:31dsharshakovSIGKILL cannot be handled rly. Well, then in typical scenario systemd restarts the thing. But there're edge cases...
05:32dsharshakovDoing own daemon-in-daemon supervision can help a bit, but that seems to be hackier than a ping ioctl.
05:32dsharshakovI mean running another instance as a child process
05:34dsharshakov has quit [Remote host closed the connection]
05:34chadmedi guess with a keepalive signal its just a matter of the implementation difficulty and whether or not such things are tolerated in the kernel
05:36chadmedand to me it seems silly to implement something that unorthodox in the kernel to cover a failure mode with such a slim possibility
05:37chadmedalso we should probably make sure it, yknow, actually does what it says on the tin first
05:39chadmedim more worried about getting V/ISENSE out of the driver and making sure we can catch over temp situations in a controlled state at the moment
05:42tpw_ruleshow does macos handle this? if it's just a function of V/ISENSE, why is a (perhaps configurable) model in the kernel not doing the math
05:44tpw_rulesand i mean 16 bit float for this purpose can surely be done as 64 bit fixed point integers to an acceptable level of accuracy
05:44chadmedV/ISENSE are lines hooked up to the amp output. ISENSE is a shunt resistor and VSENSE just measures the voltage across the voice coil
05:46tpw_rulesman i am awful at words tonight. probably a sign it's way past my bedtime. good luck and bye
05:47marcanI absolutely want this to have things like only allowing a trusted/special process to raise levels above the max and resetting when that fd is closed or when a keepalive fails
05:48marcan(yes this will require core ALSA changes, we'll bikeshed it I'm sure, but I will not ship a solution that does not have that level of safety in some form)
05:48chadmedoh okay, so as long as the process dies and does nothing else to the CTL interface the kernel will handle the rest?
05:48marcanthere will be a keepalive of some sort, though that keepalive may be implicit in "is actively reading the PCM data". I need to see how that would work, and also how it will all work when the TX side PCM is closed or idle
05:49marcanmy current idea is we want the safety capture PCM to always be available, but simply cease to deliver data when the output is idle, and the daemon should compensate for that algorithm-wise
05:52marcansince they come in the same way as input audio data as far as the hardware is concerned, I don't see much reason to reinvent that wheel
05:52dsharshakov has joined #asahi-dev
05:52chadmedright. ive modeled them as read only elems on the ctl interface but that probably doesnt make a lot of sense. shouldnt be too hard to change if we have a dedicated pcm to open
05:54chadmedit should be fine if theyre on their own pcm, i had issues earlier this week trying to open the speaker pcm while pipewire had it open at the same time
05:54dsharshakovYes, marcan's idea is very nice, kernel has no problem finding idle streams. However, I want to better know how would you trust a process? Probably it just has to be root, know the handshake and boost volume only after opening the VISENSE pcm
05:55marcanthe only security required is that regular users should not be able to blow up the speakers, and that it should never happen "by accident"
05:56dsharshakov has quit [Remote host closed the connection]
05:58tpw_ruleschadmed: got nerd sniped again and i really cannot see how those v/isense values would be floats. they will just be counts relative to the full scale in the datasheet
05:58ashi has joined #asahi-dev
06:00ashimarcan: If it is discouraged to use "random" branchen, then indeed you should make things private. It is totally clear that no one here should expect anything to work, but I thought #asahi-alt is all unsupported anyway, so we can tinker like we want including pointing people to what we did to make things work.
06:01chadmedi.e. packaging and maintenance of _released_ asahi software on other distros to make them work
06:03tpw_rulesbut if it comes back as an audio stream then maybe moving it closer to userspace and using that plumbing makes more sense. i think i take back my idea to put it in the kernel. but yeah i very strongly suspect those numbers will be (N/65535)*3.75A/14V full scale value listed
06:05ashiI do not ship anything, but I did make gpu work on debian, and I thought it would be nice to tell people how. Obviously it is completely bad for the project. So I will keep things for myself and enjoy "random" branches without any feedback. Thanks for clarifying.
06:06ashiSeriously, if the code is intended for the inner circle only, you should just make it private, I also do it sometimes before things are ready.
06:07chadmedthe idea is to be transparent and forthcoming, especially given that people are donating their money to this project
06:10loki_val has quit [Server closed connection]
06:10crabbedhaloablut has joined #asahi-dev
06:14chadmedlike i have a kernel branch locally with the speaker s2idle fix in it and the amp gains set to the "full" macos level because i have a DSP graph for pipewire that i know is safe for _me_ to use
06:14chadmedim not gonna ship that in gentoo though because i know someones gonna go "the bass isnt fully sick and hectic enough", crank up some slider and blow things up and then complain here that we broke their $3000 laptop
06:15ashichadmed: For me it is not a bad idea to play with dev branches and see new stuff working while knowing it could crash at any times.
06:15chadmedokay sure but dont ship it and dont complain about bugs if you run into them because chances are someone already knows about them
06:16Stary has quit [Server closed connection]
06:16ashiAnd even I know how I can enable them, I would not, after I read all of marcans writeups and the comments in speaker research
06:16Stary has joined #asahi-dev
06:17chadmedyeah exactly so if you know these things happen, dont spruik dev branches to people when you dont know how theyre going to behave with them
06:18chadmedreminds me of people distributing pre-publication research manuscripts that are then rejected during peer review
06:21greguu has joined #asahi-dev
06:23ashiOh damn, I am so sorry, I though I joined #asahi-alt - did not intend to spam your dev channel :(
06:25ashi has left #asahi-dev [Leaving]
06:40m5zs7k has quit [Server closed connection]
06:40m5zs7k has joined #asahi-dev
07:17SSJ_GZ has joined #asahi-dev
07:32ChaosPrincessDid someone end up testing a restore from complete destruction of all data in nor flash?
07:33chadmed_ has joined #asahi-dev
07:36dsharshakov has joined #asahi-dev
07:37dsharshakovChaosPrincess: iirc it's only repairable by Apple (or you if you have backed it up). However, the SPI controller node it's attached to is blocked in DT, so you cannot destroy the flash accidentally
07:38dsharshakovit shouldn't be needed for us anyway since all useful data is extracted and filled into the ADT aiui
07:42dsharshakovthe boot selection or what precisely?
07:43svenand dunno what else is stored in there but wouldn’t surprise me if there’s more useful things
07:43dsharshakovI remember reading some writeup telling that NOR contains ID and calibration, so unless you have a backup you need to send it to Apple to repair (maybe Apple Store employees can restore as well, but certainly needs some tech)
07:45dsharshakovWell, that's another risk area like speakers are. Maybe it doesn't worth it unless tested and consideres carefully
07:46dsharshakovSo far it's boot picker (replaceable by just holding option while booting), updates (how to download those, maybe that's better done by the second macOS install or rebooting into stub)
07:47dsharshakovWhat else? Maybe bt pairing data as well, but most likely SEP holds that
07:47dsharshakovHave anyone RE'd SEP enough or just thoughts?
07:48dsharshakovhowever that's not SO sensitive to live in SEP, that makes sense
07:49svenAnd the dfu restore can and does talk to apples servers. It wouldn’t surprise me if it can just download whatever is required from there
07:50dsharshakovsven: they keep a backup of sn-paired data like wireless calibration?
07:52dsharshakovthen someone will have to verify that before shipping with nvram enabled...
07:53dsharshakovEssentially the two things possibly permanently breakable from software thus requiring extra safety when playing around
07:55dsharshakovwell, can someone imagine other part of the system you could damage with software not being able to DFU-restore afterwards?
07:56dsharshakovspeakers are one of those, and nvram might be so as well (needs testing). Anything else seems to be unbreakable thanks to SMC and other hardware handlers of critical things
08:07dsharshakov has quit [Quit: Page closed]
08:13ChaosPrincessI have already "tested" corrupting nvram, just interested in what happens if the rest of the nor is corrupted
08:32joske has joined #asahi-dev
08:33joske has quit []
10:05cylm_ has joined #asahi-dev
10:05leitao has joined #asahi-dev
10:06cylm has quit [Ping timeout: 480 seconds]
10:15leitao has quit [Ping timeout: 480 seconds]
10:29gabuscus has quit [Ping timeout: 480 seconds]
10:36gabuscus has joined #asahi-dev
10:41chadmed_ has quit [Remote host closed the connection]
10:45chadmed_ has joined #asahi-dev
11:45kenzie7 has quit []
11:46kenzie7 has joined #asahi-dev
12:44beeblebrox has joined #asahi-dev
12:49chadmed_ has quit [Remote host closed the connection]
13:10goldsoultheory has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
13:11kettenis has quit [Ping timeout: 480 seconds]
13:11r0ni has quit [Ping timeout: 480 seconds]
13:21goldsoultheory has joined #asahi-dev
14:44leitao has joined #asahi-dev
14:53leitao has quit [Ping timeout: 480 seconds]
15:29kilolima is now known as kl_
16:27jluthra has quit [Remote host closed the connection]
16:27jluthra has joined #asahi-dev
18:12corion has joined #asahi-dev
18:49dsharshakov has joined #asahi-dev
18:50dsharshakovamarioguy: well, that was not a surprise. I just supposed sep could be involved in storing the pairing keys as they're sorta secure material. however, not to that extent
18:51dsharshakovamarioguy: what it is? Is there a map or description of what is in the NOR?
18:52dsharshakov"in the nvram proxy data in the ADT" seems someone needs to expose the adt node as a efuse-like node in OF DT and then as a nvram device to userspace so that bluez can get it either directly or using our initramfs scripts
18:53jannauI thought of transferring the bt keys to the devicetree but as far as I can see it would be readable by every user
18:53dsharshakov"do you mind hopping in asahi-re" - no problem, write there, I might just read from logs if I have no questions
18:54dsharshakov"it would be readable by every user" might be the case if you simply place it there. But if it's an nvram device node, user cannot access it. `cat /dev/nvram` gives me permission error on my AMD machine
18:56nicolas17 has joined #asahi-dev
18:56dsharshakovBut how to do it (pass ADT pairing to bluetoothd) sanely? Reserved memory page created by m1n1, copy adt pairing data there and then expose the page as a virtual device from the kernel?
18:57dsharshakovamarioguy: got your msg. IIRC marcan had the same findings, that ID info loss will likely break DFU as well, so will likely need employees regenerating the data
18:58dsharshakovjannau: how can non-root user read the DT info?
19:00dsharshakovwell, then it's likely to be considered public to the apps. Well, maybe there're some examples of passing sorta secret data from bootloader to Linux in other OF systems?
19:01jannauonly in sysfs, ls -ld /proc/device-tree: "/proc/device-tree -> /sys/firmware/devicetree/base"
19:02dsharshakovSo it'll be read from NOR, not using the ADT proxied data?
19:04dsharshakovWell, since nvram has more use cases, this makes more sense than working around to receive the bt pairing data from ADT. Also this way devices paired in Linux could be made working with macOS/recoveryOS
19:05amarioguyfwiw it doesn't look like nvram has any property that can't be restored with a DFU restore
19:06dsharshakovThere's a burned-in SN in the SoC itself so restore tool can just grab backups from the Apple online?
19:06dsharshakovECID is what, sorry?
19:08dsharshakovBefore enabling users to nuke the NOR somebody has to be sure to know how to restore that
19:08nicolas17did anyone *actually* screw up the NOR contents including serial number, and do a DFU restore, and the restore tool recovered the data from Apple based on the ECID (exclusive chip ID)? there were theories that it worked that way but idk if anyone took the risk and tried it
19:09sveni mean.. maybe just dump all traffic while running idevicerestore and check if there's NOR calibration data in there
19:09dsharshakovyeah, but to restore the machine AC2 needs to grab the ECID and somehow match it to the machine data
19:09nicolas17sven: you mean while running AC2, in case this is actually a missing idevicerestore feature :P
19:09dsharshakovsven: great idea to do before nuking a test machine
19:11dsharshakovbtw did he already get the m2 air back?
19:12dsharshakovwould be fun if NOR can be debricked by DFU. then speakers are the only soft-breakable thing in the system which makes it fairly solid
19:12dsharshakovAh, okay, but the question remains
19:13dsharshakovwhat're the examples? Maybe microLED XDR backlight (it has temperature sensors)
19:13dsharshakovvoltages for all components are handled by SMC, so unless it bugs out we're safe
19:14nicolas17I'm not sure how much we can mess with thermals from software, but yes, that's generally one area
19:14dsharshakovoh btw what do power curves lina has been calculating mean? what are they used in for GPU?
19:15dsharshakovare they just for software to account for the power GPU uses (like perf metrics) or needed for hardware management and affect performance states somehow?
19:25systwi has joined #asahi-dev
19:26dsharshakovnicolas17: they're likely to have a thermal protection poweroff by SMC firmware. Nobody checked probably, I don't know for sure
19:29dsharshakovSo overheating the SoC is very unlikely. But microLEDs are being cut in brightness when it's too hot, as stated by Apple support
19:30dsharshakovProbably current DCP support doesn't enable the XDR mode anyway, so screens are unlikely to heat up that much. But when the microLED backlight will be used to its full potential for HDR support thermal safety might need to be taken into accout
19:31systwi__ has quit [Ping timeout: 480 seconds]
19:35dsharshakov has quit [Quit: Page closed]
19:44corion has quit []
19:57tired has quit [Quit: /]
19:58tired has joined #asahi-dev
20:08corion has joined #asahi-dev
20:11as400 has quit [Remote host closed the connection]
20:17as400 has joined #asahi-dev
20:26djorz has joined #asahi-dev
20:42goldsoultheory has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
21:17chengsun has joined #asahi-dev
21:19kettenis has joined #asahi-dev
21:22chengsun_ has joined #asahi-dev
21:22systwi_ has joined #asahi-dev
21:26systwi has quit [Ping timeout: 480 seconds]
21:27chengsun_ has quit [Quit: Quit]
21:28chengsun has quit [Ping timeout: 480 seconds]
21:52corion has quit [Quit: Page closed]
22:09ChaosPrincessSo, the reason im asking is that i am getting a new m1 machine soon, and can test complete nor destruction. (If i can"t recover it myself, ill just take it back to the store and claim it was doa)
22:57amarioguyChaosPrincess: you can always take a bit by bit copy of the nand and reflash using an HW programmer :P
22:58amarioguy(fun note this is the only way to downgrade assuming you haven't updated and SEP hasn't rolled it's anti-replay token in secure storage)
23:00tanty has quit []
23:09tanty has joined #asahi-dev
23:12tanty has quit []
23:15tanty has joined #asahi-dev
23:38SSJ_GZ has quit [Ping timeout: 480 seconds]
23:39goldsoultheory has joined #asahi-dev
23:42yamii has quit [Ping timeout: 480 seconds]