#
…

2022-08-29

00:02e1eph4nt has quit [Ping timeout: 482 seconds]
00:28e1eph4nt has joined #asahi-dev
00:37e1eph4nt has quit [Ping timeout: 480 seconds]
00:46e1eph4nt has joined #asahi-dev
00:54e1eph4nt has quit [Ping timeout: 480 seconds]
01:20e1eph4nt has joined #asahi-dev
01:24riker77 has quit [Ping timeout: 480 seconds]
01:24riker77 has joined #asahi-dev
01:28e1eph4nt has quit [Ping timeout: 480 seconds]
01:29benpoulson has joined #asahi-dev
01:37benpoulson has quit [Ping timeout: 480 seconds]
01:57e1eph4nt has joined #asahi-dev
02:51goombado[m] has joined #asahi-dev
03:01e1eph4nt has quit [Ping timeout: 480 seconds]
03:08pyropeter2 has joined #asahi-dev
03:10pyropeter1 has quit [Ping timeout: 480 seconds]
03:19nicolas17 has quit [Quit: Konversation terminated!]
03:27e1eph4nt has joined #asahi-dev
03:36e1eph4nt has quit [Ping timeout: 480 seconds]
03:44e1eph4nt has joined #asahi-dev
04:41benpoulson has joined #asahi-dev
04:46hays has quit [Remote host closed the connection]
04:48hays has joined #asahi-dev
04:49benpoulson has quit [Ping timeout: 480 seconds]
04:53e1eph4nt has quit [Ping timeout: 480 seconds]
04:57e1eph4nt has joined #asahi-dev
05:20cste005 has quit [Quit: Leaving]
05:53maxkofler has joined #asahi-dev
05:58maxkofler has quit [Quit: Quit]
06:07the_lanetly_052__ has joined #asahi-dev
06:22mps has joined #asahi-dev
06:27bisko has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
06:40TristenNollman[m] has joined #asahi-dev
06:50SergioLopez[m] has joined #asahi-dev
06:57marcanchadmed: the python firmware thing is relevant, but doesn't need to be automagic for gentoo IMO
06:57marcanso just package it as a python package and maybe add a python-exec wrapper to run it with the right arguments by default
06:57marcanno need to run it as a postinstall or anything
06:58marcangentoo users can be told to do it manually :)
07:00marcansven: two streams per dispext almost implies 2 monitors on M1, or MST? which would be unheard of for Apple but...
07:00marcanone theory I have is that maybe dcpext can route the two planes to different outputs? so you lose one plane per output but you get two
07:00marcanbut I didn't really see anything sane in the current firmware API to imply it actually supports doing this sanely, though who knows
07:00svendon't know yet, all i know is that 0 is dispext0,0 and 1 is dispext0,1
07:01marcanmaybe the hardware can do it and the firmware can't, that'd be very apple
07:01sven(in that crossbar mux)
07:01svenyeah, could be
07:01marcanalso, that would explain the two eDP outputs vs one DISP0
07:01marcanmaybe DISP0/DCP can also do two outputs
07:01svenI don't think it supports MST fwiw. I can only route a single stream to DPPHY
07:01_jannau_ok, so I can just create a merge request for the asahi-fwextract ebuild
07:02svenI can route two streams to DPIN0/1 and tunnel them both over USB4 then
07:02_jannau_maybe the crossbar is prepared for MST but dcp/disp is still lacking
07:02svenas I said, I don't think the crossbar even supports MST via DP alt-mode
07:02marcanmaybe it's just for the TB equivalent?
07:03marcanbut can you route *separate* DISPEXTs to the same USB4 PHY? I mean that has to work, right? (especially for t6k)
07:03sveni could also configure the atcphy0 crossbar to dispext0,0 and the atcphy1 crossbar to dispext0,1
07:03marcanso in theory m1 should support two external monitors then, if dispext can do that
07:04svenor the atcphy0 crossbar to dispext1,0 and dispext2,0 if using USB4 tunneling
07:04svenat least the crossbar part I think
07:04marcaninteresting
07:04svenand XNU debug strings clearly call this dispextN,M
07:05svendispext%u,%u -> atc%u,%u (atc%u-%s)
07:05svenfirst %u in atc is the atc index second on selects between "dpphy", "dpin0" and "dpin1"
07:05svenand dpin0/1 is usb4 tunneling
07:06sveni'll play around with it a bit once I actually get dp alt mode up in m1n1 :D
07:11e1eph4nt has quit [Ping timeout: 480 seconds]
07:13marcanha, AppleDCPDPTXProxy has strings which imply this matrix of routes: die[01]:dispext[0123]:core[01] -> atc[0123]:{dptx,lpdptx}:{dpphy,dpin[01]}
07:13marcanI wonder if that implies they can route DP streams across dies in t6002, that would be neat
07:13marcanand core0/1 is definitely a thing then
07:14marcannot sure what the dptx/lpdptx story is about though
07:16marcanif you look at DCPs on the die shot though, they clearly have two symmetric halves, so that supports the "two cores" idea too
07:18marcanthere's also this: IOMFB: DCPLink::start failed with 0x%x (pipe:%u)
07:18marcanI think DCPLink is the main DCP thing, so maybe there's somehow a whole separate instance per core?
07:19sveninteresting
07:20marcanfrom DCP.bin:
07:20marcanport %p (port%u, core%u)
07:20marcandcpav-edp-core0-nub
07:20marcandcpav-dpext-core0-nub
07:20marcandcpav-dpext-core1-nub
07:20marcancore%u -> atc%u,%u (supportsHPD=%u)
07:21marcanI swear if this thing actually supports two ext displays on M1...
07:22svenlol :D
07:22sventhat would be fun
07:23svenweird that apple doesn't make use of that then though
07:23marcanyeah... well, apple doesn't make use of a lot of things in these socs...
07:23svenhuh, also DCP itself needs to know to which atc its stream is routed? ("core%u -> atc%u,%u (supportsHPD=%u)")
07:23_jannau_but why would apple not support that? no resources for fixing issues/testing it properly
07:25marcanI have a feeling that Apple have this thing where sometimes they can't ship certain hardware features because the software isn't ready on time, and they're too proud to admit to it or add it back in later, so they just don't
07:26marcanbut everyone is clamoring for multiple monitor support, and it's *bizarre* they didn't ship it with M2 at least if it can do it
07:26sveni kinda hope this actually works. would be a fun tweet. "Here's my M1 macbook air with two external screen running Asahi Linux" :D
07:27svenmaybe it's also just broken in some way
07:27svenand they didn't manage to fix it for M2 in time
07:27marcanI mean there's also that mystery ANE1 in t6001
07:27marcanor two of them in t6002
07:31svendptx,lpdptx <-- any idea what lpdptx means?
07:33e1eph4nt has joined #asahi-dev
07:33marcan"low power" I think, I think that's the one for the internal panel?
07:34svenah, makes sense I guess
07:34marcanthe M1 has 6 (!) lanes of LPDPTX, 4 of which are connected to the internal panel
07:34marcanand also, 12 (!!) lanes of LPDPRX (!?)
07:34_jannau_I have problems reading it different than "low power" as synonym for eDP but I'm confused what thta has to do with the dp-xbar routing
07:35marcanI suspect the LPDPRX stuff is for DisplayPort cameras (?)
07:35svenfor dpphy the mux control has two fields, DPPHY_SELECT0 = 23, 20, E_DISPEXT and DPPHY_SELECT1 = 11, 8, E_DISPEXT
07:35marcanbut it could also support some kind of input passthrough a la old iMacs
07:35svenboth are always set to the same value
07:36marcansven: separate lanes?
07:36svenyeah, could be
07:36svenit's unfortunately one of the few registers where they don't just give us the name/fields in debug strings
07:37marcanapple calls the display eDP and the lanes LPDP so I think they are synonyms
07:39benpoulson has joined #asahi-dev
07:41e1eph4nt has quit [Ping timeout: 480 seconds]
07:41svenhrm, so if DCP.bin knows about core0/1 the firmware should have sone support for it, shouldn’t it?
07:41marcanyou'd think so, yeah
07:45marcanthere's unused bits in the DCP message bitfield, I could see them sneaking a pipe ID in there...
07:47benpoulson has quit [Ping timeout: 480 seconds]
07:48jakebot60 has quit [Quit: The Lounge - https://thelounge.chat]
07:48svenI’m going to be very happy if this works out
07:49svendual external screen is the only thing that makes me want to upgrade my mba
07:50e1eph4nt has joined #asahi-dev
07:53jakebot60 has joined #asahi-dev
07:55hir0pro has joined #asahi-dev
07:58e1eph4nt has quit [Ping timeout: 480 seconds]
08:02phirecome over and join us people who use ultrawide monitors
08:03phireI have very view regrets, except my particular one has more than a few firmware bugs.
08:03phire*very few
08:06e1eph4nt has joined #asahi-dev
08:11the_lanetly_052__ has quit [Ping timeout: 480 seconds]
08:15e1eph4nt has quit [Ping timeout: 480 seconds]
08:24e1eph4nt has joined #asahi-dev
08:58veloek_ is now known as veloek
09:16hir0pro has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
09:18hir0pro has joined #asahi-dev
09:32e1eph4nt has quit [Ping timeout: 480 seconds]
09:56e1eph4nt has joined #asahi-dev
09:57DmitrySharshakov[m]jannau: how's audio routed into DCP? I couldn't find its way inside the driver
10:02povikwhat do you mean routed?
10:02povikthe firmware interface for it hasn't been reversed yet
10:02DmitrySharshakov[m]You answered this probably
10:03svenyeah, we don't know how that routing works yet
10:03svenso there's nothing in the driver
10:03povikwe know the SIO coprocessor serves as a kind of DMA controller for the audio stream
10:03DmitrySharshakov[m]Understood, thanks
10:03povikbut that's about it
10:03svenoh, so we might actually need a SIO DMA driver in linux?
10:03_jannau_there are other endpoints on the DCP rtkit interface which could be related to audio
10:04sventhat also reminds me that I wanted to look at that firmware to see if it's literally a co-processor that polls HW regs to pretend that they actually support DMA
10:04e1eph4nt has quit [Ping timeout: 480 seconds]
10:09_jannau_the dcpep calls itself do not mention audio
10:11poviksven: we might. i will be happy to write a dmaengine driver for it
10:11povikbut then there's the other pieces involving DCP...
10:11povikbtw where does KNOWN_MSGS in trace_dcp come from?
10:11povikasking for the AOP interfaces
10:15e1eph4nt has joined #asahi-dev
10:17shorneHello, I am jumping right into s2idle suspend stuff and compiling the kernel with CONFIG_SUSPEND (it seems onts not enabled on asahi by default)
10:18shorneSOme general questions, if I am not reverse englineering (yet) do I need to care about m1n1?
10:18svenyeah, because wifi and pcie will break if you enable that
10:18shorneyeah, thats what I want to see
10:19shorneAlso, I see the docs about configuring m1n1 all discuss setting it up from macOs
10:19svenuh, are you sure?
10:19svenmost people use a second linux machine
10:20shornedo I need to switch back to macOS to change m1n1 settings
10:20shorneah.. hence basic questions
10:20sveni'm still confused what you are trying to do
10:22shorneOh, its 2 different things. One is just compiling and internalling the kernel, not questions about that.
10:23shornethe question about m1n1 is completely separate
10:23bisko has joined #asahi-dev
10:24shorneI need the guide explains using kmutil, and it menions fuOS and ESP
10:24shorneI am not sure what either of those are
10:24Jamie[m]fuOS is Fully Untrusted OS (i.e. Linux)
10:25Jamie[m]ESP is EFI System Partition
10:25shorneAh, ok thats much more clear
10:25shorneThen sven mentioned using a separate linux box, I dont see anything about that
10:26svenwhat are you trying to do exactly?
10:28shorneI am trying to get started learning about how to hack on asahi linux
10:28shorneI want to help with s2idle
10:28shornebut I figured I need to
10:29shorne1. learn how to run m1n1 and figure out how to read the debug/probe ourput
10:30svenhttps://github.com/AsahiLinux/docs/wiki/Tethered-Boot-Setup-%28For-Developers%29 that's probably a good start for how to quickly launch new kernels
10:30shorne2. just build and test my own kernel
10:30svenoh, and it also mentions the hypervisor at the end to trace what macos is doing
10:30svenhrm, wait. no.
10:30svenyou'll want https://github.com/AsahiLinux/docs/wiki/SW%3AHypervisor for running macos under the hv
10:31shorneyeah, I think its both things I am trying to do
10:31svenyeah, so mostly just follow those guides then. they should explain everything that's required
10:31shorneI will try those both out
10:32shorneI have my kernel compiled, thats the easy part
10:33shornesorry, times up, UK is off today I need to go out with the family
10:33shorneI need to run through those guides tonight
10:41benpoulson has joined #asahi-dev
10:49benpoulson has quit [Ping timeout: 480 seconds]
10:59jannaupovik: extracted from the kext and/or fw
10:59j`eyshorne: if you just want to run linux and not macos under the HV, the asahi-installer is a place to start
11:05povikwe are missing DEFAULT_ARCH for the darwin case
11:06poviknot sure what should be there for non-arm64 darwin
11:08derzahl has quit [Ping timeout: 480 seconds]
11:16hir0pro has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
11:23e1eph4nt has quit [Ping timeout: 480 seconds]
11:47e1eph4nt has joined #asahi-dev
11:56e1eph4nt has quit [Ping timeout: 480 seconds]
12:04e1eph4nt has joined #asahi-dev
12:13hir0pro has joined #asahi-dev
12:24c10l4 has joined #asahi-dev
12:24c10l has quit [Read error: Connection reset by peer]
12:24c10l4 is now known as c10l
12:56hir0pro has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
13:04Gaspare has joined #asahi-dev
13:09derzahl has joined #asahi-dev
13:12e1eph4nt has quit [Ping timeout: 480 seconds]
13:13Race has quit [Ping timeout: 480 seconds]
13:36e1eph4nt has joined #asahi-dev
13:40bisko has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
13:45e1eph4nt has quit [Ping timeout: 480 seconds]
13:46Gaspare has quit [Quit: Gaspare]
13:47kaprests has joined #asahi-dev
13:53e1eph4nt has joined #asahi-dev
13:54kaprests_ has quit [Ping timeout: 480 seconds]
14:01e1eph4nt has quit [Ping timeout: 480 seconds]
14:03hir0pro has joined #asahi-dev
14:04bisko has joined #asahi-dev
14:14e1eph4nt has joined #asahi-dev
14:35gabuscus has quit [Ping timeout: 480 seconds]
14:39gabuscus has joined #asahi-dev
14:40Gaspare has joined #asahi-dev
14:52bluetail21 has quit []
14:55bisko has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
14:56mini0n has joined #asahi-dev
14:57CellularDuck[m] has joined #asahi-dev
14:57CellularDuck[m] has left #asahi-dev [#asahi-dev]
15:08svencan somehow maybe run a tracer with that while connecting two displays via a single usb4 dock?
15:08sveni'm pretty sure I know what will happen (PCLK1/2 get enabled and then two dispexts are routed to dpin0/1) but I'd like to confirm that
15:23e1eph4nt has quit [Ping timeout: 480 seconds]
15:32e1eph4nt has joined #asahi-dev
15:32hir0pro has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
15:33hir0pro has joined #asahi-dev
15:45e1eph4nt has quit [Ping timeout: 480 seconds]
15:54e1eph4nt has joined #asahi-dev
15:55Gaspare has quit [Read error: No route to host]
16:01hir0pro has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
16:16hir0pro has joined #asahi-dev
16:21hir0pro has quit []
17:01e1eph4nt has quit [Ping timeout: 480 seconds]
17:04jannauI think my thinkpad docking station is not compatible with other devices (physically). maybe with an usb cable which shouldn't exist
17:06svencan you connect a single external screen via that dock?
17:07svenwould also be nice to confirm dpin0/1
17:09svenoh. wait. i think i can actually test that myself on the M1
17:10sven[cpu4] [XBarTracer@/arm-io/atc1-dpxbar] MMIO: W.4 OUT_N_CLK_EN = 0x110 (DPIN0=0, DPIN1=1, DPPHY=1)
17:10svenyup, so dpin is definitely USB4 tunneling
17:11svenmarcan: ^-- can you maybe try to connect two external screens via a single usb4 dock on the pro/max and trace the crossbar?
17:11jannauoh, you actually ment USB4, my dock is thunderbolt 3
17:12sveni think thunderbolt 3 is similar enough to usb4
17:13Dcow[m]I have thunderbolt monitor. If it help, I can setup tracer over weekend
17:13svena single one isn't enough
17:13Dcow[m]it's 5k
17:13svenI'd like to see two screens on a single usb4 connection
17:13jannauthe studio display might work
17:14svendoes 5k always require 2 separate dp streams?
17:14jannauwith another monitor connected
17:14svenyeah, that should work as well
17:14svenI neither have a studio display nor a pro/max though :D
17:16Dcow[m]it's LG Ultrafine 5k, not studio, but it's AFAIK it's tiled
17:16Dcow[m]but it's working with m1 mini
17:17svenmight be still interesting to see
17:17svenbut i'm mostly interested in what happens on pro/max with two display streams going over a single atcphy port
17:17Dcow[m]what trace are you intrestred, m1 or m1 max?
17:17svenif it works on the m1 it's likely just a single stream and i can test that myself
17:19Bastian[m]may be a dumb question, would this be something different than these adapter things https://www.amazon.com/dp/B09N6R91DZ do to get dual monitor support?
17:19dottedmagI have 5K LG UltraFine monitor (5120x2880) that is definitely multi-stream and it works with M1.
17:19dottedmagIf this is an interesting configuration I can set it up in a ~week's time for tracing.
17:20svenhuh, yeah. if it's definitely multi-stream that would be very interesting
17:20dottedmagOK, I'll ping you once I'm around this monitor again :)
17:21svenBastian[m]: yes, display link doesn't use DP altmode or DP tunneling at all
17:21jannauBastian[m]: no, displaylink is not a display output for this question
17:21svenit's just a usb3 device that needs a driver which sends the framebuffer over some proprietary protocol
17:22dottedmagI know this LG is multi-stream because I saw how utterly broken it is under Linux on Intel + GNOME or sway. It was funny seeing GNOME using two parts of displays as two outputs, and even somewhat usable.
17:22ardisplaylink is cursed. i had a docking station for a work laptop based on that a couple jobs ago, and it was very bad experience
17:23Bastian[m]I love that the answers start with yes and no :D thank you
17:23svenhrm, i'm quite surprised that it works at all on the M1
17:23dottedmagMe too. Maybe that's the reason why Apple does not advertise two-monitors support for M1: it would be too hard to tell apart which combinations would work and which ones won't.
17:24svenjust to confirm, it comes up with the full 5k resolution on the m1?
17:25dottedmagAh, does it matter how is it connected? I only tried Thunderbolt.
17:26e1eph4nt has joined #asahi-dev
17:26svenhrm, so looking at the spec from display port it seems that 5k should be possible even with a single stream
17:26jannaumy dell 4k display which needs mst support for 60fps is not driven in mst mode by macos
17:26jannaubut the lg display was sold by apple so maybe they handle it specially
17:26svenso maybe that display just supports the higher bandwidth DP modes and linux just messes up and tries to use MST instead?
17:27marcanmaz: this isn't released/merged anywhere yet, but feel free to merge/cherry pick bits/150-xhci-firmware
17:27svenwould still be interesting to see what exactly happens
17:27dottedmagHmm. Might be.
17:27sveneither way, let me know once you're that monitor again. i'd like to see a full atcphy + crossbar trace
17:27sven+around
17:28marcanyou need https://github.com/lzfse/lzfse (lzfse.so in your ld path) and then clone asahi-installer and run `python -m asahi_firmware.update /boot/efi/asahi /boot/efi/vendorfw/firmware.tar /boot/efi/vendorfw/manifest.txt && /usr/bin/update-vendor-firmware`
17:28Dcow[m]Do I need to have new installation of macos for hv?
17:29Dcow[m]or I can add m1n1 into chain for the current one?
17:29dottedmagsven: roger that
17:29marcansven: apple historically had 5K displays in tiled mode (e.g. the one in my iMac, which doesn't work, so I'm stuck at 4K)
17:29marcanDCP supports this apparently
17:29marcandelegate: parsed tiled display topology (%s): singleEnclosure: %s bezelInfoPresent: %s incompleteTiledBehavior: %u singleTileBehavior: %u tileTopology: (%u,%u) tileLocation: (%u,%u) tileSize: %ux%u bezelInfo: (t: %u, b: %u, r: %u, l: %u) identifier: Vendor: %02x-%02x
17:30svenhuh, interesting
17:30nicolas17 has joined #asahi-dev
17:30marcanthough that almost looks like a videowall thing, with the bezel stuff
17:30marcanbut who knows, maybe it's a generic thing that also works for that 5K stuff
17:30svenI wonder what exactly it does to support that
17:31marcanmaybe this is what that core0/core1 thing is for?
17:31svenyeah, could be
17:31svenwould be interesting to see how it configure the crossbar in that setup
17:33svenI think it can route any dispext to any atcphy (i.e. even across cores) fwiw
17:34e1eph4nt has quit [Ping timeout: 480 seconds]
17:34sventhe top level handler is display-crossbar0 and there's also only a single one in the t6x ADTs which contains all dispexts and all atcs
17:35svenand I don't see anything that limits e.g. dcpext0 to only atcphy0 and 1
17:36marcaninteresting
17:36marcanguess they really went all out on that d2d link
17:38svenyup. also makes our lives easier since we can mix and match dcpexts to atcphys however we want :-)
17:38sven*lifes
17:38nicolas17what's atcphy?
17:39sventhe type-c phy that sits behind each usb c port and handles all the magic low-level physical stuff
17:39nicolas17oh, Apple Type-C?
17:39svenprobably
17:42DmitrySharshakov[m]Essentially a multiplexer which can connect Type-C pins to either DisplayPort, Thunderbolt, USB 3 or some debug stuff probably
17:42DmitrySharshakov[m]Btw does atc support 2x2 scheme where you give 2 lanes for DP and 2 for USB 3 link?
17:43marcanthe debug stuff is unrelated
17:43DmitrySharshakov[m]Of course that works with TB, but that should be a variant for the DP altmode as well IIRC
17:43svenit's also much more than a mux
17:43DmitrySharshakov[m]marcan: It uses SBU?
17:43svenbut yes, it supports USB3+DP-altmode at the same time
17:44marcanthe debug stuff is muxed by the type C controller chip and never uses the SS lanes
17:44marcanATC is exclusively about the SS lanes
17:44marcanand it is not a mux, it is a PIPE multi-phy and a bunch of stuff around it
17:44marcanDisplayPort, TB, USB3 are not separate PHYs
17:44marcanit's a combined PIPE PHY
17:45nicolas17"PHY Interface for PCI Express"?
17:45marcanyeah, lol
17:45DmitrySharshakov[m]marcan: Ah, alright, quite a lot more complex thing
17:45nicolas17damn acronyms
17:45svenyeah, it also does dwc3 and thunderbolt NHI power, reset and clocks
17:45marcanthe HS lanes are connected directly to dwc3, right?
17:46sventhere's a usb2 phy somewhere inside ATCPHY as well
17:46marcanof course, but I mean there's no mux
17:46sveni don't think so
17:46marcanit's the same usb2 phy block as the debug block
17:46marcanso probably pretty dumb and stand alone
17:46sventhere's just some weird interaction if you switch the SS lanes to USB3 and try to use USB2 at the same time without bringing up the USB3 PHY
17:47marcanthat just sounds like dwc3 gets confused
17:47svenyeah, pretty much
17:47sventhere's a lot of ways to confuse dwc3 if you slightly misconfigure atcphy
17:47svenand a few ways to trigger some watchdog that resets the entire SoC as well
17:47marcanthat's probably cio?
17:48nicolas17I wonder if the iPad Pro 3/4 uses the same
17:48sventhat's what I think
17:48nicolas17(iPad Pro 5 obviously does, since it's M1)
17:48svenso one way to break everything is to enable the CIO clock/power-domain/whatever without having powered up ATCPHY first
17:48svenresets the whole thing in ~3 seconds
17:49sventhen there's what's likely the CIO watchdog which resets the SoC after ~30 seconds if you bring up ATCPHY and then enable the CIO power-domain/whatever but don't boot CIO
17:50marcanoh of course
17:50marcanif you do that, cio crashes
17:50marcanand that probably triggers the watchdog
17:50sventhere's another way to reset everything as well if you misconfigure some of the lanes even without involving CIO
17:50svendunno what exactly I did to trigger that though
17:51marcanI mean on t8112 the soc crashes if you *read* the wrong mmio range so...
17:51marcanthere's lots of stupid stuff like that
17:51svenheh, yeah
17:51marcananything that triggers a fault in the wrong place
17:51svenprobably something dumb like that
17:51marcanalso macos is even pickier because it enables AMCC IRQs
17:51marcanand then any weirdness gets a panic
17:51marcanwe should implement that in linux some time, to catch mistakes
17:52marcan(just don't make it into a panic...)
17:52svenyup :D
17:53nicolas17in theory could we tell the AMCC to make the kernel code pages permanently read-only like XNU does? and does that have a chance of getting upstreamed?
17:54marcanthat happens in CPU registers
17:54nicolas17yeah I think they're MSRs
17:55marcanbut that will never work for typical linux
17:55marcanbecause it can't work with modules
17:55benpoulson has joined #asahi-dev
17:55marcanalso, Lina told me the other day she figured out it breaks huge pages covering the read-only region, which is ridiculous
17:55marcanso given that little factoid, I'd consider it too broken to use in Linux
17:57marcanapparently that's why she'd been getting faults trying to read GPU firmware for crash dumps... Apple started setting CTRR for the firmware region, and m1n1 uses huge pages when it can
17:58marcanmaz: so yes, we have another architecture break here, lovely.
17:58marcanin recent firmwares you can't use huge pages for lowmem, it throws up an address size fault (!)
17:59e1eph4nt has joined #asahi-dev
17:59nicolas17well there's security models where the Linux kernel and its modules are signed and root can't load new modules at runtime, which is quite Apple-like and could allow for KTRR, but if it breaks other things... eh
17:59marcanI guess they implement CTRR in the MMU/TLB, and since they can't get the proper granularity if you use 32M pages, it just... forbids them in/overlapping the region
17:59marcanthankfully there is no 32M region that overlaps user RAM and the CTRR region, so this only affects special-purpose memory
18:00marcannicolas17: loading modules at all is unlikely to work, the way Apple does things, all the modules are pre-linked and all the text sections combined and made contiguous
18:01marcanyou need something like that to get all the text regions to be continuous in physmem
18:02* marcansleeps
18:02svenyeah, as much as I like the idea of KTRR I don't see that happening with linux :(
18:05benpoulson has quit [Remote host closed the connection]
18:06nicolas17and no it doesn't prevent loading modules from userland, it requires them to be signed
18:07DmitrySharshakov[m]Lockdown is just signature verification and many other rules enforced
18:07DmitrySharshakov[m]x86 does not have hardware RO memory (well, maybe somewhere in the SMM...)
18:07DmitrySharshakov[m]So lockdown mode does not make kernel image immutable to itself
18:08nicolas17DmitrySharshakov[m]: I know, I just meant it would be a prerequisite
18:08DmitrySharshakov[m]Yes, but kernel has to write parts of its memory to link a module in
18:08nicolas17if you don't use lockdown mode and intend to allow root to load arbitrary modules, then you surely can't use KTRR anyway :)
18:09DmitrySharshakov[m]However I guess some parts of the kernel might be extra hardened, at least some code which is never touched while module loads
18:10DmitrySharshakov[m]This will lock us out of kexec and kpatch
18:10nicolas17lockdown mode disables kexec too
18:11DmitrySharshakov[m]Idk if we can lock some generally immutable parts and will it make any sense if something will have to be RO for modules to load
18:11DmitrySharshakov[m]nicolas17: It does restrict it to SecureBoot, doesn't it&
18:14marcanit doesn't make sense to lock only part of it. the whole thing only makes sense from the premise that *all* of the kernel is locked down and the CPU is locked down so it can *only* execute from that region.
18:15DmitrySharshakov[m]Well yes, since if something in between entrance and exit of higher EL is RW to evil forces, they can make it call outside of the secure area
18:15nicolas17DmitrySharshakov[m]: there was significant opposition from Torvalds and others against tying lockdown and secureboot, so the patch that was ultimately merged makes them independent
18:16nicolas17it's questionable if it's useful to have one and not the other, but you can
18:16marcanit isn't
18:16marcanthey are different threat models
18:17marcansecureboot protects against physical attacks, lockdown protects against runtime attacks
18:17marcanthey certainly complement each other, but they do make sense in isolation
18:20DmitrySharshakov[m]Well how does XNU load its kexts? Or doesn't it do that at all on aarch64?
18:20nicolas17the arguments were "lockdown without secure boot will instill a false sense of security, since the lockdown can be circumvented by attacking the boot chain" and "a kernel that supports secure boot without lockdown can be compromised after boot to run untrusted code in kernel mode"; that argument lost and they were made independent :)
18:21marcanDmitrySharshakov[m]: it doesn't
18:21nicolas17DmitrySharshakov[m]: afaik there's a monolithic "kernel cache" that is basically the kernel and the modules pre-linked, and it gets loaded as a single unit
18:21marcanand there is an "AuxKC" that contains all third-party kexts, which is also pre-provisioned and that must happen in recovery mode
18:21DmitrySharshakov[m]Yes, so all other devices are handled by userspace drivers since they aren't in kc?
18:21marcanso it's two text regions, one for the apple stuff, one for everyone else's
18:22DmitrySharshakov[m]marcan: Do end-users ever use this kind of thing?
18:22nicolas17DmitrySharshakov[m]: in Apple's ideal world, all other devices are DriverKit (userspace), but kexts are "unfortunately" still a thing so there's the "AuxKC" as marcan said
18:22marcanthere is automation to make it soooomewhat seamless to users
18:22marcanit involves a reboot through recovery mode that shows a progress bar then comex back
18:22marcanand a lot of really fiddly stuff to make it secure
18:22marcan*comes back
18:23nicolas17but Apple has been progressively making it more of a pain in the ass to load kexts for many years now
18:24DmitrySharshakov[m]Well, so looks like there's no practical use of mainlining such a feature. It could be done for special occasions though I guess
18:24nicolas17yeah, I hadn't realized modules were such a problem for this
18:24DmitrySharshakov[m]Building modules in to make a monolithic kc-like kernel without module support and then locking kernel memory into RO
18:26DmitrySharshakov[m]Might be useful for some people if internal parts + USB common classes are embedded this way. However, as I mentioned, that monolithization of the kernel would be certainly not upstreamable
18:27DmitrySharshakov[m]Well, and tun, and wireguard etc. Non-modular Linux is as possible as kext-free macOS is, but not really decent for most cases
18:29tpw_ruleswould it be possible to pre-load all modules into memory but not actually call them unless necessary?
18:29tpw_rulesthat sounds like what the kernel cache does anyway
18:29DmitrySharshakov[m]Possible, but not feasible
18:30DmitrySharshakov[m]Just recalled Logitech input is also a kernel module on Linux (at least rich functions). Having tons of userspace drivers isn't great, so that's not a good way to go
18:31DmitrySharshakov[m]tpw_rules: Their size I guess
18:31tpw_rules"Yes, but kernel has to write parts of its [code] memory to link a module in" does this go beyond actually loading the module into kernel space?
18:31DmitrySharshakov[m]kernelcache has essential drivers (parts of the Mac itself and basic externals)
18:32DmitrySharshakov[m]tpw_rules: Probably not
18:32DmitrySharshakov[m]But I couldn't imagine having all the modules built in
18:32tpw_rulesso you just wouldn't want to reserve the RAM required
18:36DmitrySharshakov[m]Imagine we only can have USB pluggable devices. There's just a ton of them
18:37benpoulson has joined #asahi-dev
18:38DmitrySharshakov[m]However, somebody has to calculate that
18:41DmitrySharshakov[m]Well, `/lib/modules/<ver>/kernel` contains xz-ed modules, they could be counted (including un-xz-ing them)
18:52svenI don’t think size is a good point here
18:53sveni don’t know how exactly Linux module loading works but I’d expect that you’d need some major changes to make it put all text in a region it’ll never have to write to
18:53bluetail21 has joined #asahi-dev
18:55DmitrySharshakov[m]Dumping a lot of drivers out of Fedora's aarch64 modules package yielded 160 MiB with not all drivers decompressed
18:55DmitrySharshakov[m]Why is contiguous text region necessary for this thing?
18:56DmitrySharshakov[m]I guess it can be achieved when linking modules in (config Y), which essentially produces the same thing as kernelcache
18:56svenbecause you can only protect a single contiguous region with KTRR
18:56DmitrySharshakov[m]cannot kernel executable code be protected as well?
18:57nicolas17if you protect the kernel's core executable pages with KTRR, now you used up your single region, and modules are still writable
18:57DmitrySharshakov[m]I guess kernel will be around 150 MB if compiled with all modules for builtin devices and whatever can be hotplugged. Quite a lot for kernel image
18:58nicolas17and if you overwrite a module's code then you get that executed in kernel mode anyway
18:58DmitrySharshakov[m]Builtin modules should be in the same region
18:58nicolas17so you don't really win much security by protecting the kernel alone without modules
18:59DmitrySharshakov[m]nicolas17: I mean protecting the kernel _with_ modules
18:59DmitrySharshakov[m]With them being statically linked together
18:59nicolas17you mean not building them as modules to begin with, but inside the kernel? that may be possible yeah
19:00DmitrySharshakov[m]Just like kc, a single monolith
19:02DmitrySharshakov[m]What's the largest kernel image ever built and what could possibly stop it from working when tons of unused modules are linked in?
19:02nicolas17I guess the other problem is that putting "an attacker gets arbitrary write in kernel mode" into your threat model, that opens a big can of worms even if you protect code with KTRR :P
19:05DmitrySharshakov[m]Yes. So we're left with the only approach to enabling ktrr: evict everything from the kernel land and make them use VFIO to implement their PCIe card drivers in userspace and libusb for usb ofc
19:06e1eph4nt has quit [Ping timeout: 480 seconds]
19:06DmitrySharshakov[m]Someone has to try building everything needed in and enable the thing
19:06DmitrySharshakov[m]Gentoo users will definitely enjoy the concept of building a moduleless kernel
19:16e1eph4nt has joined #asahi-dev
19:20bisko has joined #asahi-dev
19:21DmitrySharshakov[m]Well, if somebody cares, that could be a kernel build-time option, which implies nothing can be built as a module. This would open a way for some really special scenarios where people can easily do a custom monolithic kernel build
19:24e1eph4nt has quit [Ping timeout: 480 seconds]
19:33e1eph4nt has joined #asahi-dev
19:38cuolin^ has joined #asahi-dev
19:42e1eph4nt has quit [Ping timeout: 480 seconds]
19:44benpoulson has quit [Remote host closed the connection]
19:50e1eph4nt has joined #asahi-dev
19:57benpoulson has joined #asahi-dev
20:14cuolin^ has quit [Ping timeout: 480 seconds]
20:18cuolin^ has joined #asahi-dev
20:57e1eph4nt has quit [Ping timeout: 480 seconds]
21:06e1eph4nt has joined #asahi-dev
21:14e1eph4nt has quit [Ping timeout: 480 seconds]
21:22e1eph4nt has joined #asahi-dev
21:27benpoulson has quit [Remote host closed the connection]
21:30e1eph4nt has quit [Ping timeout: 480 seconds]
21:55e1eph4nt has joined #asahi-dev
21:55chengsun has joined #asahi-dev
21:57chengsun_ has quit [Ping timeout: 480 seconds]
23:03e1eph4nt has quit [Ping timeout: 480 seconds]
23:19e1eph4nt has joined #asahi-dev
23:28e1eph4nt has quit [Ping timeout: 480 seconds]
23:37e1eph4nt has joined #asahi-dev
23:48jluthra_ has quit [Remote host closed the connection]
23:48jluthra_ has joined #asahi-dev
…