#
…

2021-05-25

00:36balrogbrinly: look at osfmk/vm, primarily vm_compressor.c
00:36balrog11.3 has some mitigations already
00:37brinlyyeah I know
00:37brinlyI just wanna find the exact vesion
00:37brinlyso Im not looking through like 50 changes
01:32bgb has joined #asahi
01:43bgb has quit [Remote host closed the connection]
01:44bgb has joined #asahi
02:24marcanI don't know the exact version
02:28phiologe has joined #asahi
02:32PhilippvK has quit [Ping timeout: 480 seconds]
02:47aquijoule__ has joined #asahi
02:48bgb has quit [Read error: Connection reset by peer]
02:53aquijoule_ has quit [Ping timeout: 480 seconds]
02:56uberushaximus has quit [Quit: uberushaximus]
03:01bgb has joined #asahi
03:11bgb has quit [Ping timeout: 480 seconds]
03:20marvin24_ has joined #asahi
03:23marvin24 has quit [Ping timeout: 480 seconds]
03:53bgb has joined #asahi
04:47awordnot has quit [Ping timeout: 480 seconds]
05:09SunWuKung has joined #asahi
05:16bgb has quit [Ping timeout: 480 seconds]
05:17bgb has joined #asahi
05:57VinDuv has joined #asahi
06:10SunWuKung has quit [Remote host closed the connection]
06:18VinDuv has quit [Quit: Leaving.]
06:53keenriser has joined #asahi
06:59EER has quit [Ping timeout: 480 seconds]
07:08rann has joined #asahi
07:48maz has joined #asahi
07:48bgb has quit [Ping timeout: 480 seconds]
08:03bgb has joined #asahi
08:12tardyp has quit [Read error: Connection reset by peer]
08:20jabashque has quit [Remote host closed the connection]
08:26jabashque has joined #asahi
08:45bgb has quit [Ping timeout: 480 seconds]
08:47bgb has joined #asahi
08:52choozy has joined #asahi
08:59bgbmarcan/sven: can the m1n1 usb function co-work with macos host?
09:02svenor, well, you could give one port to Mac OS and one to m1n1
09:03_whitelogger has joined #asahi
09:06_whitelogger has joined #asahi
09:13_whitelogger has joined #asahi
09:13svenI don't understand that question
09:13svenwhy do you want to know that?
09:14bgbwell, more directly, why macos cannot co-work with the m1n1 usb function?
09:15_whitelogger has joined #asahi
09:17svenhow would that work?
09:17_jannau_HW access is exclusive. the hypervisor would need code to support sharing HW resources with mac os
09:18svenyou'd have two drivers competing over a single HW block
09:18svenit's also not really required. it's possible to mux the Mac OS serial output over m1n1's usb driver together with the MMIO trace
09:19svenis there any other reason you have in mind for sharing that USB port?
09:19_whitelogger has joined #asahi
09:22bgb_ has joined #asahi
09:25bgb has quit [Ping timeout: 480 seconds]
09:32bgb_all right, I have missed a lot about m1n1 usb, mmiotrace etc.
09:33bgb_ has quit [Quit: WeeChat 3.0.1]
09:35bgb has joined #asahi
09:47bgb has quit [Ping timeout: 480 seconds]
09:58tmbinc has joined #asahi
10:20choozy has quit [Ping timeout: 480 seconds]
10:30marcansven: that's what I've been doing, one port for each
10:30marcanthough I'm not entirely sure if it will work properly; yesterday I disabled the other port too just in case (well, yesterday I disabled a ton of stuff)
10:35Simonx22 has joined #asahi
10:47eta has quit [Remote host closed the connection]
10:48svenyeah, it also wouldn't surprise me if some phy stuff is actually shared between the two ports and breaks
10:48sventhough at least in theory they both also have a separate phy mmio space. but who knows what kinda of fun surprises are lurking in there
10:52eta has joined #asahi
10:54eta has quit [Remote host closed the connection]
10:55kettenisthe i2c controller that has the type-C PD chips on it is shared
10:57eta has joined #asahi
11:00eta has quit [Remote host closed the connection]
11:03eta has joined #asahi
11:06eta has quit [Remote host closed the connection]
11:06eta has joined #asahi
11:08svenI hope that doesn't matter though since it shouldn't try to speak to the m1n1 port once it has been removed from the ADT
11:08svenbut who knows :-)
11:09eta has quit [Remote host closed the connection]
11:12eta has joined #asahi
11:12eta has quit []
11:15eta has joined #asahi
11:15eta has quit [Remote host closed the connection]
11:34eta has joined #asahi
11:49pipcet[m]the IRQ line is shared between the two I2C chips
12:27marcansven: sooo it dies in GXF, but it dies *completely* :D
12:28marcanthe core wedges *in* the GXF exception vector
12:33svenwow :D
12:33svenlike, it just stop working?
12:34j_eystopped on a `mov`
12:34pipcet[m]marcan: that happened here (now have it working), but I thought it was because I was failing to virtualize the GXF page tables properly
12:36marcanis there a separate GXF VM TTBAR?
12:37pipcet[m]marcan; can you read the PC from another CPU core? (write 0xc5acce55 to 0x210030fb0, read 32 bits from 0x210040090 and discard, then reading 64 bits from 0x210040090 gives you the lower 49 bits of CPU0's PC)
12:38svenTTBAR?
12:38marcanyes, that's what i'm doing
12:38marcan*TTBR or whatever
12:38marcanwhich is how I know it's wedged in that vector
12:38svenI don't think so
12:38svenor, well, I haven't found anything like that
12:38svenfrom what I can tell it's always using the same pagetables
12:39marcanactually hold on
12:39marcanit's moving
12:39marcanit's not wedged
12:39marcanit's just recursively faulting or something
12:39pipcet[m]sven: are you sure? I think it uses a different top-level page table which just shares the lower levels
12:39svenpipcet[m]: what makes you think that?
12:39marcanbut the interesting thing is debug_putc isn't working then
12:39svenhuh.. maybe some weird permission remap thing?
12:40pipcet[m]sven: I virtualized it to get my mmiotrace working
12:40Shizmarcan: also props for an actually short stream :)
12:40marcanmmio broken for gxf maybe? let me check the perms...
12:40sveni.e. the exception vector is not marked as executable in the SPRR register or the stack isn't writable?
12:40Shiz has quit []
12:40Shiz has joined #asahi
12:40svenoh wait.. the SP in GXF is weird fwiw
12:40pipcet[m]sven: I had to map my injected page using the actual ttbr_el2 value read from the GXF (I think) exception vector.
12:40pipcet[m]it points to the beginning of the page
12:40pipcet[m]not the top
12:40marcanI set it to PERM_RW_EL0 which maps to ELrw_GLrw
12:41marcanat both EL1 and EL0 (well EL2 instead of EL1)
12:41marcanso let's see
12:41svencan you read the SP with that coresigh stuff?
12:42jixcoresigh :D
12:43marcannot sure, it failed the debug request, need to poke around later
12:43marcandinner first
12:43pipcet[m]sven: if you can it should go on the wiki, I haven't found a way yet :-)
12:43sventhe SP was strange. iirc macOS always sets it up from TPIDR_GL1/2
12:43pipcet[m]but debug_putc doesn't use the stack
12:44marcanso mmio does work "normally" from m1n1
12:44pipcet[m]so I suspect it's trying to resolve the mmio page, failing, and faulting recursively.
12:44marcanlet me try in the middle of the hv in case config changes
12:45marcanyeah. still works
12:46pipcet[m]silly question, but you're using the right page table, right? As I said, I had to virtualize it separately so it probably is different from the EL2 page table.
12:47Raqbit has joined #asahi
12:47svenmarcan: did you try in the middle of the hv after xnu already enabled gxf in el1?
12:47svenit shouldn't make a difference but...
12:48marcanyes, I think so
12:49svenso it faults from GL1 to GL2 and then just hangs?
12:49marcan>>> mrs(GXF_CONFIG_EL12)
12:49marcanseems enabled
12:50svenhm, yes
12:50svenwith some mystery bits I don't know about
12:50marcandebug_print works from gl2 in this state
12:50pipcet[m]in my case it was faulting recursively because the injected page wasn't in the right page table
12:50marcanjust branching there
12:50marcan"injected" page?
12:51ave has quit [Quit: o/ https://thelounge.lasagna.dev]
12:51pipcet[m]I injected a page into the GL2 code so it would wait for another core to actually handle the page fault, as part of virtualizing the page tables so I could have an mmiotrace.
12:51ave has joined #asahi
12:52pipcet[m]I assume you're injecting the mapping for the uart's mmio page similarly?
12:54pipcet[m]or do you use the mapping macos set up for you?
12:54svenuh, it's a hv. he just uses two stage translations
12:54sventhere's no need to inject anything into xnu's pagetables
12:55pipcet[m]I thought he was wedged in the GL2 code and couldn't get back to the HV?
12:55svenGL2 *is* the hypervisor
12:55svenGL1 is xnu
12:58pipcet[m]oh, I must have misread "debug_putc isn't working then"
13:00svenyes, debug_putc in GL2 isn't working apparently
13:01choozy has joined #asahi
13:10karlyeurl has joined #asahi
13:15marcannor is any memory access, apparently
13:15marcanI know what this fucking thing is
13:15marcanI've been here done this
13:15marcangoddammit
13:16marcan52823eaab
13:16marcanof course I need that for the GXF vectors too
13:16marcancc sven
13:18marcan> !GLEXC:a!
13:18marcanand it works
13:18marcanit's just a damn FIQ
13:36svenglad you figured it out ;)
13:37kettenisis there a particular reason why usb_init() is only called if there is no payload?
13:38svenyou probably just need usb_phy_bringup or however it's called if you want to use dwc3 in uboot/openbsd
13:39kettenisthe other bits don't seem to hurt ;)
13:39svenfair enough :D
13:40svenI'm still surprised the phy bringup is also enough for host mode
13:48kettenisI'll see if I can come up with a diff that does just the clocks and usb_phy_bringup()
13:49marcansven: okay, got to a panic on SEP bringup now
13:49marcanthis is way further than it's ever gotten
13:50j_eymarcan: sick!
13:51marcan(this of course also explains all the hideous non-deterministicness... timer FIQs in GL2, duh)
13:52svenyeah, that sounds nasty
13:54Shizhell ye
13:56j_eymarcan: you mean the non-det breadcrumbs?
14:08radex has joined #asahi
14:34choozy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
14:35choozy has joined #asahi
14:54_whitelogger has joined #asahi
14:58smvg has joined #asahi
14:59smvg has quit []
15:30marcanj_ey: no, just the general "it crashes in a different place depending on completely random changes" thing
15:30marcanlike trapping more/fewer registers etc
15:30marcanoh, and this also explains why trapping the GXF registers breaks
15:30marcanbecause it would probably genter then trap on something, and that would hang
15:30marcanI bet trapping GXF works fine now
16:09SunWuKung has joined #asahi
16:39VinDuv has joined #asahi
17:03marcanj_ey: like to clarify, xnu is multitasking at this point, so non-det breadcrumbs make some sense, but what *didn't* make sense is crashing way earlier/way later depending on random configuration changes
17:04marcanit's never gotten past sec cpu bringup (possibly because for whatever reason that puts it in gl1 long enough to reliably die; large page table changes?) but it's randomly died way earlier, sometimes consistently depending on settings
17:07j_eybut wasn't the FIQ from a timer, which should have happened roughly at the same time?
17:08j_eyor was disabling some configuration just causing different things to print, so it looked like it happened at different times?
17:09marcanit's the timer firing *while* it's in GL1 that makes it go into GL2
17:09marcanthe HV timer fires at 1000Hz
17:09marcanbut I guess the guest spends little enough time in GL1 until that point in boot that most of the time it didn't crash
17:10j_eyaha, the guest needed to be in GL1 for it to happen!
17:10marcanbut of course changing configuration settings would do things like make some operations slower, or more likely to trap while in GL1
17:10marcanit seems it's always EL1 -> EL2 and GL1 -> GL2
17:10marcanthey basically operate in parallel, roughly identically other than the separate context registers for GLx
17:11marcanso right now I just point the GL2 VBAR at the same vectors as the EL2 VBAR, and have wrappers to read/write the context registers that pick the right one based on the current mode
17:11marcanand that just makes the whole thing work, and agnostic to whether it's in GL2 or EL2
17:11marcaneret goes back to GL1 or EL1 as required
17:11j_ey(I just watched that bit on the quick stream)
17:11j_eyin_gl2()
17:12marcansven had already worked most of it out, but I'd been *assuming* GL1 somehow trapped to EL2 because, well, it was getting way too far for that not to be the case!
17:12marcanand because I wasn't seeing the GL2 exceptions
17:12marcan... but the PAN thing plus PPL apparently being not called into that often and running fast conspired to confuse me
17:16marcan(maybe the PPL is only half there? Apple says it's not like iPhones; clearly there's GXF in use but how much exactly?)
17:17marcanwell, now that I can probably actually grap gxf registers I guess I'll find out
17:24Misthios has quit [Quit: Misthios]
17:24Misthios has joined #asahi
17:33svendoes apple even mention GXF anywhere?
17:33sveni thought their last update still only mentions APRR
17:33svenwhich didn't exist on any x86 macs :)
18:12keenriser has quit [Remote host closed the connection]
18:53pugguu has joined #asahi
18:55pugguuHey marcan how far are we with the hypervisor if we were to put it as a percentage
19:00pugguu😉 ASCII 0x1E i said percentage so u do not have to do a time
19:00pugguuDangit didnt work
19:03pugguuTried to do strikethrough
19:03pugguuOoooo begining and end oh well
19:21tsida has joined #asahi
19:31pugguu has quit [Remote host closed the connection]
19:31pugguu has joined #asahi
19:36TheLinkhope you're not using leading zeros :P
19:43Thomas___ has joined #asahi
19:44choozyWhy is it necessary to write a hypervisor instead of using something like KVM on top of the current Asahi?
19:58agrafchoozy: With KVM, Linux will take ownership of most underlying hardware, so you would need to create a virtual platform on top. With the m1n1 hypervisor, we can leave ownership of most hardware with macOS and then trace its access to it.
20:06kubes has joined #asahi
20:09kubes has quit []
20:11pugguu has quit [Ping timeout: 480 seconds]
20:25dottedmag has quit [Quit: QUIT]
20:26dottedmag has joined #asahi
20:29sorearif it wasn't clear this is a very specialized hypervisor for hardware documentation, normal users will use KVM
20:51VinDuv has quit [Quit: Leaving.]
20:52atom1[m] has joined #asahi
21:01choozyAh allrighty
21:40Thomas___ has quit []
21:40Tom has joined #asahi
21:43Tom is now known as TestingTom
21:43TestingTom is now known as Thomas____
22:19choozy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
…