#
…

2021-05-08

00:21mrkajetanp has joined #asahi
00:22modwizcode has quit [Ping timeout: 246 seconds]
00:29modwizcode has joined #asahi
00:45KindOne has quit [Ping timeout: 260 seconds]
00:45mrkajetanp has quit [Quit: WeeChat 3.1]
00:47KindOne has joined #asahi
00:51odmir has quit [Remote host closed the connection]
00:52odmir has joined #asahi
00:57odmir has quit [Ping timeout: 260 seconds]
01:20Emantor has quit [Quit: ZNC - http://znc.in]
01:20Emantor has joined #asahi
01:23odmir has joined #asahi
01:34odmir has quit [Ping timeout: 268 seconds]
01:48odmir has joined #asahi
01:51phiologe has quit [Ping timeout: 276 seconds]
01:51phiologe has joined #asahi
01:53odmir has quit [Ping timeout: 260 seconds]
01:57phiologe has quit [Ping timeout: 260 seconds]
02:00phiologe has joined #asahi
02:25Bublik has joined #asahi
02:26Bublik_ has quit [Ping timeout: 260 seconds]
02:35phiologe has quit [Ping timeout: 250 seconds]
02:35odmir has joined #asahi
02:35phiologe has joined #asahi
02:39odmir has quit [Ping timeout: 240 seconds]
03:23qyousef_ has quit [Ping timeout: 252 seconds]
04:01marvin24 has quit [Ping timeout: 276 seconds]
04:01marvin24_ has joined #asahi
04:02robinp_ is now known as robinp
04:37odmir has joined #asahi
04:43odmir has quit [Read error: Connection reset by peer]
05:22VinDuv has joined #asahi
06:00adamcstephens has quit [Quit: The Lounge - https://thelounge.chat]
06:04adamcstephens has joined #asahi
06:04neunon has quit [Quit: ZNC 1.8.2 - https://znc.in]
06:06neunon has joined #asahi
06:17dottedmagI wonder how much work is needed for QEMU to run macOS under Linux on M1? Nearly zero or a lot?
06:19dottedmagIs KVM x86-specific?
06:19dottedmagScratch that, description on linux-kvm.org is obsolete :(
06:28VinDuvKVM (or equivalent) virtualizes the CPU but you’d still need to emulate the rest of the M1 hardware
06:31dottedmagRight, and I suppose not much of it could be just passed through...
06:55ardottedmag: kvm (the interface the kernel provides) is available on a couple of different architectures, not just x86
07:02dottedmagar: Yeah, I was misled by linux-kvm.org that apparently wasn't updated since forever
07:08jeffmiw has joined #asahi
07:10jeffmiw has quit [Remote host closed the connection]
07:10jeffmiw has joined #asahi
07:11pipcet[m]dottedmag: https://worthdoingbadly.com/xnuqemu3/ apparently worked at some point
07:14pipcet[m]and we could pass through everything but USB, I think.
07:19marcandottedmag: kvm on linux on m1 should already work better in some ways than the hypervisor stuff on macos (:)), but that's to virtualize linux/windows
07:20marcanpipcet[m]: the problem with "passing through" is you need to involve the IOMMUs
07:20marcanyou can't just "pass through" hardware under KVM like I can under my toy hypervisor, there needs to be DMA and IRQ remapping
07:20marcanand not all the hardware in the M1 runs through the same kind of IOMMU
07:21marcanonce we better understand the hardware, we'll have a better idea of what can be done
07:22marcanin particular the GPU is a big question mark, but there's reason to believe Apple is interested in virtualizing macos, so it's possible the hardware is built to enable this kind of feature
07:23marcanalso, to run macos unmodified, KVM may need quite a bit of patching to support custom M1 features; at the very least we need to set everything to trap, but that might be very slow as it causes vmexits for tons of stuff
07:24marcanso that might be useful for experiments, but possibly not for end users; to do it properly KVM would need more M1-specific stuff and that's harder to implement and upstream
07:24marcanit's certainly something to investigate in the future, but it'll probably come quite further down the line
07:25marcanspeaking of hypervisors, going to stream some more of that in a few minutes
07:42arthis hypervisor is super cool, and seems like the kind of thing that would also be useful also for devices other than just the ones based on m1
07:44marcanyeah, it's already useful for debugging linux to some extent... and now I'm conflicted, because m1n1 is quite apple silicon-centric by design
07:45marcanI really don't want to turn this into a big portable bootloader thing, but on the other hand the HV stuff is eminently useful elsewhere
07:45marcanmaybe just the HV bits can be extracted into a stand-alone thing you can plug into another existing bootloader more easily?
07:45marcanalthough e.g. the HV page tables all assume 16K pages which few ARM systems support AIUI, so...
08:08jeffmiw has quit [Remote host closed the connection]
08:25jeffmiw has joined #asahi
08:30jeffmiw has quit [Ping timeout: 268 seconds]
08:46pipcet[m]marcan: I have a plan for that (start macos physically, teach qemu to identity-map /dev/mem for the relevant ranges)
08:47marcanpipcet[m]: it's not going to work unless you make all of macos' RAM also identity mapped
08:48pipcet[m]sorry, I don't understand. qemu would still use its own page tables to translate simulated virtual to simulated physical, which would be equal to actual physical.
08:49pipcet[m]but that's post-HV fine tuning, really.
08:51marcanyou would need to restrict the RAM that Linux is allowed to use, and give macos a contiguous chunk of physical RAM
08:52pipcet[m]yes, I'm already doing that.
08:52marcanyou also need to emulate AIC
08:52pipcet[m]or modify the driver to coexist peacefully
08:52pipcet[m]or use a linux version without the actual AIC driver.
08:53pipcet[m]plenty of ways of doing that.
08:53marcanlinux needs AIC
08:53marcancoexistence is unlikely to work
08:53pipcet[m]no, it needs FIQ
08:53pipcet[m]which doesn't go through AIC
08:53marcanit needs AIC if you want any non-polled IO
08:54marcanif you're going to cripple Linux to this point, I fail to see what that buys you over just using the HV in m1n1
08:54marcanwhat are you going to do, patch the nvme driver etc to use polling instead of IRQs?
08:54pipcet[m]I don't think coexistence is going to be much of a problem, actually.
08:54pipcet[m]why woud I need the nvme driver?
08:54marcanpresumably you want linux to have some kind of working storage
08:54marcanif not nvme, then USB
08:54pipcet[m]all Linux needs is a usb port, and we already have polling for that.
08:55marcanfor serial, yes
08:55marcanpresuambly you want a filesystem
08:55marcanlinux also doesn't have a polling driver for usb
08:55marcanm1n1 does
08:55marcan... so you're loading a big blob of linux and qemu and everything into a tmpfs... without any network, storage, or anything... what's the point then?
08:55marcanyou lose any benefits you'd get from doing this under linux
08:55pipcet[m]and we don't even need usb for a minimal setup, we can communicate with macos through shared memory and do the i/o from the emulated macos
08:56pipcet[m]yes, I'm not convinced this approach is worth it, but it's not totally impossible
08:57marcanit's possible, I just don't really see the point :)
08:57svenfwiw, i don't think at least genter/gexit will trap as long as GXF is disabled.
08:57marcanwhen you're giving the guest access to 95% of the hardware directly, having a massive OS in the way without being able to use most of its features just increases the bug/problem surface
08:57sventhey're just undefined then
08:57marcansven: what if I set a bunch of HACR_EL2 bits?
08:57marcan(like I did)
08:57marcanwell, let's find out
08:58sveni think i checked and they don't. but please double check :)
08:59pipcet[m]marcan: again, I'm not convinced it's worth it or working on it, but someone asked and it's totally possible, if possibly harder than just getting the HV to work properly.
09:01marcansven: yeah, seems they don't :(
09:02svenso you might be able to trap them after enabling GXF but ugh
09:06svenmarcan: sooo.... you could just replace genter/gexit in the kernel text with hvc instructions while loading it :D
09:08svenyou know you want to! :P
09:11j`eymight be worth getting the code into place for replacements, might be other use cases too!
09:19j`eygood suggestion from youtube chat to just rewrite vbar_el1
10:04vimal has joined #asahi
10:06jeffmiw has joined #asahi
10:10jeffmiw has quit [Ping timeout: 268 seconds]
10:14vimal has quit [Ping timeout: 260 seconds]
10:27vimal has joined #asahi
10:35raster has joined #asahi
10:38choozy has joined #asahi
10:42idt23[m] has joined #asahi
10:57klaus has quit [Ping timeout: 252 seconds]
10:57Bublik_ has joined #asahi
11:00Bublik has quit [Ping timeout: 265 seconds]
11:05klaus has joined #asahi
11:07odmir has joined #asahi
11:08odmir_ has joined #asahi
11:11jamadazi has joined #asahi
11:11odmir has quit [Ping timeout: 260 seconds]
11:13odmir_ has quit [Ping timeout: 260 seconds]
11:14jamadazihi guys! there hasn't been a public update post on the project for a long time now (a couple of months?), how's it going? has there been much progress on the project since the blog post update?
11:14jamadazii know those initial patches were accepted into mainline, but i don't know anything else
11:15j`eyjamadazi: theres a stream right now, about wrting a hypervisor
11:16j`eywhich will be used to help understand more of the hw
11:18marcanthe hv isn't even returning from the last exception
11:18marcanit's not the guest borking me, it's a bug somewhere
11:18marcanTTY> hv_exc_sync
11:18marcanTTY> ret
11:18marcanPass: mrs x13, s3_5_c15_c4_0 = d
11:18marcanTTY> hv_exc_sync
11:18marcanSkip: msr s3_5_c15_c4_0, x13 = d
11:18marcanwell that's weird on a skip...
11:58maknho has joined #asahi
12:01maknho____ has quit [Ping timeout: 260 seconds]
12:42marcanah no, I think that's just the USB buffering
12:53jeffmiw has joined #asahi
13:35modrobert has quit [Read error: Connection reset by peer]
13:35m0drobert has joined #asahi
13:35m0drobert is now known as modrobert
13:59marcanit was PAN.
13:59marcandidn't realize PAN leaks up to EL2
13:59j`eybut doesnt that show as an exception?
14:01VinDuv has quit [Quit: Leaving.]
14:04VinDuv has joined #asahi
14:12klaus has quit [Ping timeout: 260 seconds]
14:12KindOne has quit [Ping timeout: 268 seconds]
14:14klaus has joined #asahi
14:16marcanj`ey: EL2 faults
14:16marcanthe bit isn't cleared when entering EL2
14:17marcanand since m1n1 maps everything as EL0-accessible, EL2 can't access any data, not even the stack
14:17marcanso everything explodes
14:17marcansetting pan to 0 as the first instruction of the EL2 handlers fixes it
14:17marcanbefore any stack accesses
14:23kettenisshort series with the proposed pinctrl bindings sent to the appropriate mailing lists
14:24kettenisfinally got things in a state where all the checking tools are happy with them
14:24ketteniswe should try to make some progress on the cock bindings as well though
14:31svenpeterUgh, yes. I’ve been meaning to send the initial dumb version where a page is mapped for each clock for a while now
14:36VinDuv has left #asahi [#asahi]
14:39raster has quit [Quit: Gettin' stinky!]
14:41Spectrejan[m] has joined #asahi
14:41kettenisAh, but I may have botched the sending by effectively spoofing using my @openbsd.org address
14:43kettenisis it rude to send them again with that fixed?
14:43VinDuv has joined #asahi
14:43jeffmiw_ has joined #asahi
14:47Emantorkettenis: I'd wait for comments/Acks first. As long as the patches are fine I wouldn't bother to send again.
14:47c4r1c4[m] has joined #asahi
14:48jeffmiw_ has quit [Ping timeout: 240 seconds]
14:48ketteniswell, they'll probably not make it to the mailing lists this way
14:48sveni received them fwiw
14:49jn__the pinctrl bindings made it to LKML at least
14:49Emantorye, the MLs don't care much about the spoofing.
14:49kettenisok, thanks
15:09agnem has quit [Quit: WeeChat 3.1]
15:29qyousef_ has joined #asahi
15:43odmir has joined #asahi
15:47odmir has quit [Remote host closed the connection]
15:49odmir has joined #asahi
15:50agnem has joined #asahi
15:56marcanso macos is panicing now... trying to figure out how to decode the panic from the hypervisor, since serial isn't initialized yet
15:57kettenisprogress, I guess?
16:04odmir has quit [Remote host closed the connection]
16:10yrlfmarcan: so if I understand it correctly, it prints the panic to the framebuffer, but macos died before it hits serial?
16:10j`eyi dont think the panic is getting to the framebuffer either
16:11pipcet[m]kettenis: FWIW, gmail classified your messages as spam, probably because of the spoofing thing
16:12yrlfone hack would be to try to find the panic function in macos and hook that
16:13yrlfotherwise, what options are there? OCR the framebuffer?
16:14yrlfj`ey: damn, then that's _really_ early__
16:15yrlf(didnt see your message before I sent mine)
16:15j`eyI'm just guessing, lets see what markan says :P
16:19marcanyrlf: there is no framebuffer yet either
16:19marcanI already have the panic hooked because it triggers a debugger trap and I have all exceptions hooked
16:19marcanI'm writing a panic decoder in python now
16:21yrlfahh, yeah, doing a debugger trap on panic definitely is something that makes sense for them to do
16:23yrlfthis kind of "semihosted" way of doing development with python and m1n1 cooperating definitely makes a lot of things easier
16:27marcanxnu's va_list doesn't seem to match the arm standard one... :/
16:27kettenisyeah, apple's arm64 ABI is "different"
16:32marcanah, it only uses stack args apparently
16:35c4r1c4[m] has left #asahi ["User left"]
16:45zkrx has quit [Ping timeout: 240 seconds]
16:51zkrx has joined #asahi
16:53odmir has joined #asahi
16:59jeffmiw has quit [Ping timeout: 240 seconds]
17:01marcanInvalid kernel stack pointer (probable corruption). at pc 0xfffffe00113dd374, lr 0xc1ff7e00112837e8 (saved state: 0xfffffe0015083cb0)
17:01marcanah, maybe this is a PAC thing; it's entirely possible the PAC registers are VHE'd and I'm passing through to the wrong ones
17:02Bublik has joined #asahi
17:03zkrx has quit [Ping timeout: 268 seconds]
17:04Bublik_ has quit [Ping timeout: 252 seconds]
17:05kettenisthat lr value looks wrong ;)
17:07marcanPAC codes go in the upper bits
17:07marcanso it might be a legitimate PAC'ed LR
17:08zkrx has joined #asahi
17:10marcan"Invalid kernel stack pointer" is supposedly a stack pointer issue though
17:13marcanbut the actual faulting instruction there is a null deref
17:15marcanand it's a null deref reading from some percpu/thread info stuff
17:15marcanI'm starting to wonder how many levels deep into a fault I am
17:16marcan(for reference: so far this is kernel panic -> undefined instruction aka debuger trap -> hvc hook -> m1n1)
17:16marcanbut it looks like the panic is a stack check that happened due to a null deref
17:29marcanI think this might be a recursive fault triggering a stack overflow
17:37marcanyup so the fault chain currently is
17:38marcana data abort on a possibly bad but not null address -> 15 frames of recursive null pointer dereferences due to the thread context not being fully initialized -> panic due to stack overflow -> debugger break -> hypercall hook -> m1n1 -> python exception handler
17:39* etablinks
17:55solarkraft has joined #asahi
17:57marcanI guess I'm going to have to figure out how to get kernel symbols to make any sense of this
18:01roxfanwe need to go deeper.jpg
18:02jn__are there kernel symbols baked into the live kernel?
18:02marcanI think there are symbol files available
18:03marcanbut I'm going to upgrade this first, I'm on an ancient version
18:03roxfanKDK has symbolized kernels but they're not the same as retail
18:04marcancould just boot one of those
18:05roxfan"The kernel (release) variant matches the shipping kernel for users" claims the readme
18:05roxfanand there's kernel.dSYM
18:44jeffmiw has joined #asahi
18:45jeffmiw_ has joined #asahi
18:45jeffmiw has quit [Read error: Connection reset by peer]
18:48vimal has quit [Quit: Leaving]
18:52marcanok so the fault address is actually a null physical pointer
18:52marcanit's a bad vaddr that corresponds, offset-wise, to physical address 0
18:52marcanso obviously something's borked
18:55marcanI suspect devtree. maybe it's trying to look up mach-o sections in the memory map, I don't currently update those...
19:03roxfanwhen in doubt, blame Apple :)
19:03trimental has joined #asahi
19:04pipcet[m]marcan: but it wouldn't boot when chain-loaded then, and it does, right?
19:06marcanthat's true
19:06marcanhowever, there is at least one that would stay the same: the mach header
19:06pipcet[m]you have the trustcache, SEPFW, BootArgs, and DeviceTree in the devtree?
19:06marcanthat one would be valid when chainloaded, but not hv
19:09pipcet[m]you're not chainloading in place?
19:12marcannot with the hypervisor, obviously
19:14pipcet[m]I confess that's not obvious to me.
19:17odmir has quit [Remote host closed the connection]
19:18marcanm1n1 lives where iBoot loaded things initially, the guest goes higher in memory
19:20pipcet[m]oh, I thought m1n1 relocated itself somewhere safe (because obviously that's what I'm doing). It might be worth it just to try relocating m1n1 somewhere and loading the guest at the physical address iBoot gave you?
19:21balrog marcan kernel symbols? go to developer.apple.com/download/more, download the matching KDK, and install it. The symbols get installed in /Library/Developer/KDKs/KDK_version.kdk/System/Library/Kernels/kernel.BUILD.dSYM
19:21odmir has joined #asahi
19:21balrogThe symbols file for the release kernel is included, but the release kernel is built with lots of inlining
19:21balrog(there's a DWARF file inside the dSYM, if you need to access it directly)
19:22balrogAnd yeah you need to be on 11.3 or later, or there won't be symbols for the t8101 kernel at all
19:24marcanpipcet[m]: I'd rather fix the problem than work around it
19:25marcanthe whole point of this exercise is understanding
19:26odmir has quit [Remote host closed the connection]
19:27odmir has joined #asahi
19:29odmir has quit [Remote host closed the connection]
19:35jeffmiw_ has quit [Remote host closed the connection]
19:40jeffmiw has joined #asahi
19:40pipcet[m]sorry, probably misundertanding things again.
19:40odmir has joined #asahi
19:47yrlfmarcan: the fact that it's possible to debug this huge chain of faults and at all is already a _huge_ success of m1n1 and the hypervisor stuff you are doing
19:47yrlfs/and at all/at all/
19:48yrlfprops to already getting this far! at this point I probably wouldn't want to develop an OS without such a nice debugging tool as m1n1
20:14balrogmarcan: the documentation with the KDK explains how to do two machine debugging but I'm not sure how that plays within m1
20:14balrogwithin m1n1*
20:23VinDuv has quit [Quit: Leaving.]
20:34roxfando they support two-machine debugging for arm? iirc first releases supported panic symbolication only
20:40odmir has quit [Remote host closed the connection]
20:47linkmauve has quit [Ping timeout: 246 seconds]
20:55kettenis has quit [Ping timeout: 240 seconds]
20:57kettenis has joined #asahi
21:07jeffmiw has quit [Remote host closed the connection]
21:07odmir has joined #asahi
21:10jeffmiw has joined #asahi
21:11jeffmiw_ has joined #asahi
21:11jeffmiw has quit [Read error: Connection reset by peer]
21:12odmir has quit [Ping timeout: 250 seconds]
21:21odmir has joined #asahi
21:23diamondbond has joined #asahi
21:51jamadazi has quit [Quit: WeeChat 3.1]
22:06jeffmiw_ has quit [Remote host closed the connection]
22:17odmir has quit [Remote host closed the connection]
22:17odmir has joined #asahi
22:22odmir has quit [Ping timeout: 250 seconds]
22:23jeffmiw has joined #asahi
22:27jeffmiw has quit [Ping timeout: 260 seconds]
22:35raster has joined #asahi
22:47odmir has joined #asahi
22:51odmir has quit [Remote host closed the connection]
22:51odmir has joined #asahi
23:50choozy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
…