#
…

2024-02-13

00:20nicolas17okay so, what if I want to run *Linux* under the m1n1 hypervisor and trace its hardware access?
00:24wrender has quit [Ping timeout: 480 seconds]
00:34j`eynicolas17: run_guest.sh will help
00:44fossdd_ has joined #asahi-dev
00:45fossdd__ has joined #asahi-dev
00:46fossdd___ has joined #asahi-dev
00:47nicolas17I'm trying linux.py, with the kernel, dtb and initramfs copied from the Fedora installation
00:47nicolas17after "TTY> Preparing to boot kernel at" the serial connection dies and the machine reboots
00:47nicolas17I wonder if I have the wrong root dev
00:48fossdd has quit [Ping timeout: 480 seconds]
00:50nicolas17ohh, this guide was written for arch
00:50nicolas17now I'm on fedora with btrfs, I need to give it the btrfs subvolume name
00:52fossdd_ has quit [Ping timeout: 480 seconds]
00:53fossdd__ has quit [Ping timeout: 480 seconds]
00:54fossdd___ has quit [Ping timeout: 480 seconds]
00:56nicolas17USB0: shutdown
00:56nicolas17usb-dwc3@382280000: timeout while waiting for DWC3_DSTS_DEVCTRLHLT during shutdown
00:57nicolas17USB1: shutdown
00:57nicolas17is the last stuff I see on screen before it reboots
00:58nicolas17(the reboot is so quick that the serial interface dies before it can send all that, I had to record a video of the screen)
01:11fossdd has joined #asahi-dev
01:23fossdd_ has joined #asahi-dev
01:25fossdd has quit [Ping timeout: 480 seconds]
01:36nicolas17mmmmaybe the problem is this kernel is an EFI binary and I need a "raw" kernel image? :<
01:57al3xtjames has quit [Quit: al3xtjames]
02:00KxCORP has quit [Quit: Bye!]
02:00KxCORP has joined #asahi-dev
02:05Bertrand___ has quit [Ping timeout: 480 seconds]
02:05Bertrand___ has joined #asahi-dev
02:07nicolas17oh well run guest wants a Linux build directory so I have to build a kernel from source *anyway*
02:08tpw_rulesit didn't when i last used it, like a couple years ago
02:08tpw_rulesyou can feed it symbols and stuff which is nice
02:09nicolas17"Use this utility script to properly boot a Linux kernel under the m1n1 hypervisor: tools/run_guest_kernel.sh"
02:09nicolas17"Note that the script expects the path to the Linux build tree (i.e. the directory where .config and Makefile are). It will pick out the kernel and corresponding device trees from within."
02:11tpw_rulesi manually invoked that stuff
02:12nicolas17ah I see, run_guest_kernel figures things out from the build tree and calls run_guest
02:12nicolas17also it's chainloading a second m1n1 which I may not need
02:13nicolas17but anyway is linux.py or run_guest.py supposed to work with an EFI image?
02:13tpw_rulesi wouldn't imagine so
02:13nicolas17then I need to build my own because the stuff I found in fedora's /boot is an EFI image ^^'
02:14tpw_rulesdo they only ship it that way? i wonder if there's a way to unpack it
02:14tpw_ruleskind of rude if so i would say, but maybe that makes sense for a *stares judgementally* binary distro
02:14nicolas17I made the mistake of starting to build it on my x86 laptop
02:15tpw_rulesnot cross?
02:15nicolas17yes, using a cross compiler
02:15nicolas17but I bet gcc would go brrrr much faster on the M2
02:15tpw_rulesah, then what's the mistake
02:15nicolas17i5-8250U vs Apple M2
02:18nicolas17wish I could know progress%
02:35john-cabaj has quit [Ping timeout: 480 seconds]
02:44nicolas17tpw_rules: while waiting for the build to finish I started it on the M2 too, it finished in 18 minutes and the x86 cross-build is still going; see, that's why it was a mistake :P
02:45nicolas17oh wait it effing failed
02:47nicolas17it was missing pahole to process debug info or something
03:00nickchan has quit [Quit: ZNC 1.8.2+deb3.1 - https://znc.in]
03:00nickchan has joined #asahi-dev
03:09nicolas17hm, in a normal boot, m1n1 starts u-boot which starts grub which starts linux... here m1n1 directly starts linux, how does that work? I thought uboot and grub did extra initialization that was necessary for linux?
03:10tpw_rulesnot really
03:11tpw_rulescertainly not grub, u-boot doesn't iirc in the apple silicon scenario
03:11nicolas17I got the kernel to boot but it can't find the root filesystem
03:11nicolas17it drops me into "press enter for maintenance shell" but the keyboard doesn't work either
03:12tpw_rulesdoes a USB one?
03:14wrender has joined #asahi-dev
03:16nicolas17my cheap crappy USB keyboard has a damaged cable (I get "unable to enumerate USB device" on this x86 laptop and this time I couldn't get it to work by wiggling the cable)
03:17nicolas17maybe *fedora's kernel configuration* doesn't work in this scenario and I should use https://github.com/AsahiLinux/PKGBUILDs/blob/main/linux-asahi/config instead
03:22tpw_rulesare you missing a kernel command line argument? idk how fedora finds the rootfs
03:22nicolas17my original kernel build on the i5 is still going btw, at this point I'm just curious how long it will take :D
03:23nicolas17I tried "rootwait root=UUID=15636f9a-6784-410d-8635-e6c9f9d7adf5 rootflags=subvol=root" (which is almost what the normal boot has) and it says it can't find /dev/disk/by-uuid/156...
03:23nicolas17so it's not a btrfs issue, it's not even finding the block dev
03:23tpw_rulesoh, so maybe there is an issue detecting the disk
03:23tpw_rulesi don't think u-boot has anything to do with that, but maybe it inits the nvme or something and there's a timeout?
03:24nicolas17wonder if this kernel has nvme as a module... but wouldn't it get the module from the initramfs then?
03:25tpw_rulesassuming you built it into there and it's the same version and stuff
03:26nicolas17...yeahhh I probably have a big version mismatch
03:26nicolas17I was just going to use fedora's kernel and initramfs from /boot
03:26nicolas17but the kernel is EFI and I need a plain image
03:26nicolas17so I built my own kernel from the asahi-linux repo... and tried booting it with fedora's initramfs
03:26tpw_ruleswhy not just get the same kernel source
03:26nicolas17in hindsight that's probably not going to have matching versions >_<
03:27nicolas17where can I find that? I don't know how to fedora :<
03:27tpw_ruleshold on i figured all that out and wrote it down for myself
03:28tpw_rulesidk if you can build it like a normal linux tree, i never tried
03:29tpw_rulesbut copr i think is what builds the .rpms and the latest ver there matches the latest tag in that repo
03:31tpw_rulesso i'm 95% sure it's the source and what users are actually installing. would be nice to figure out how to query dnf and check
03:31tpw_rules(never used dnf either i don't think)
03:33* nicolas17clones repo and meanwhile watches how his original cross-build is *still going*
03:52jeisom has quit [Ping timeout: 480 seconds]
04:02Bertrand___ has quit [Read error: Connection reset by peer]
04:02Bertrand___ has joined #asahi-dev
04:28nicolas17oh also I get no serial console, USB disconnects as soon as the kernel starts
04:39nicolas17ah serial console is only with hv
04:49nicolas17okay! I have a serial console via run_guest
04:52nicolas17x86 crossbuild just finished, 165 min XD
04:54tristan2 has joined #asahi-dev
04:56tristan2_ has quit [Ping timeout: 480 seconds]
04:59wrender has quit [Ping timeout: 480 seconds]
05:00gladiac is now known as Guest2584
05:00gladiac has joined #asahi-dev
05:06Guest2584 has quit [Ping timeout: 480 seconds]
05:09nicolas17I think I got it, Fedora's EXTRAVERSION and my own didn't match so it couldn't load any modules from the initrd
05:58nicolas17okay this is too fragile... I need to figure out how to build my own initramfs from my own built modules
07:22Bertrand___ has quit [Ping timeout: 480 seconds]
08:08Bertrand___ has joined #asahi-dev
13:18mf54 has quit [Remote host closed the connection]
13:18mf54 has joined #asahi-dev
13:28jeisom has joined #asahi-dev
13:40WindowPain has joined #asahi-dev
13:40WindowPa| has quit [Read error: Connection reset by peer]
14:20jeisom has quit [Ping timeout: 480 seconds]
14:25john-cabaj has joined #asahi-dev
16:09zzywysmnicolas17: everyone looks at me weird when i try to slim down kernel configurations for Apple Silicon, but i suppose a 165 minute build must be thrilling for some
16:12j`eyzzywysm: not at all, I also spent a long time working on a slim build :P
16:12j`eyI probably went further than you since I also did source changes!
16:13zzywysmj`ey: if you've got a link to those source changes, i'd love to peek
16:13j`eynicolas17: also if by EFI image you mean the kernel file.. that should be fine to boot
16:13j`eythe EFI header is also executable arm64 assembly!
16:14j`eyzzywysm: no sorry just did it locally, I can maybe look at sending you some bits (I dont think it's worth actually doing, was just for fun)
16:14mazj`ey: by luck!
16:14zzywysmj`ey: what were the nature of the source changes?
16:15j`eyccmp x18, #0, #0xd, pl, does nothing, but encodes to MZ!
16:15j`eyzzywysm: stuff like enabling the LSE instructions at compile time, removing a bunch of the perf tables that werent for M1
16:16j`eyI tried to compile a kernel without nvhe KVM.. but that stuff is tangled quite firmly
16:16zzywysmi like KVM, and use a M1 most of the time
16:16j`eyzzywysm: M1 doesn't support the nvhe mode
16:16zzywysmi'm afraid to disable containers because i suspect NixOS would crap a brick
16:16j`ey(a particular mode of KVM, it supports the other mode)
16:17j`eynvhe = arm 8.0 virtualisation, vhe = 8.1+ virtualisation
16:19mazI really don't want to have to ever split the two. specially when people use nVHE on 9.x HW.
16:19zzywysmi'm of the philosophy that every kernel configuration option you can turn off is a return-oriented-programming gadget that no longer exists
16:20mazzzywysm: sure. but the maintenance cost is way too high, and completely impractical.
16:21zzywysmmaz: the maintenance cost is basically "every time a new kernel release gets cut, you do a make oldconfig and answer a couple questions"
16:21mazno: the maintenance cost is that an every *patch* you apply, you test *all* the possible combinations.
16:21mazthat's what maintenance means.
16:22kraem has quit [Remote host closed the connection]
16:22zzywysmmaz: but by drastically reducing the size of the kernel configuration, you also drastically reduce the size of the exponential tree of testing you need to be doing
16:23zzywysmcode that isn't built can't hurt you
16:23mazzzywysm: size doesn't matter in that case. I can compile a kernel in a couple of minutes. testing takes hours, multiplied by the number of architectural variants this needs to run on.
16:25j`eymaz: yes I was just trying to split it for fun, but it was a case of never-ending errors, so I gave up
16:27j`eyzzywysm: I agree if you have some fixed hw for whatever reason, but of course general purpose distros cant do that
16:27mazj`ey: a better option is to keep building it, but to reclaim the section at boot time. I had patches for that, but it was something like a couple of pages, which wasn't worth the complexity.
16:27kraem has joined #asahi-dev
16:28j`eymakes sense
16:29kraem has quit [Remote host closed the connection]
16:30zzywysmthe next step for my personal Apple Silicon machines is getting the Asahi firmware into CONFIG_EXTRA_FIRMWARE so i can go module-less
16:30zzywysmmmmm, delicious module-less-ness
16:30j`eyzzywysm: ah yeah, I did that too
16:30chadmed has quit [Quit: Konversation terminated!]
16:31chadmed has joined #asahi-dev
16:31chadmed has quit []
16:31chadmed has joined #asahi-dev
16:32john-cabaj has quit [Remote host closed the connection]
16:32john-cabaj has joined #asahi-dev
16:33chadmed has quit []
16:33chadmed has joined #asahi-dev
16:33chadmed has quit []
16:34chadmed has joined #asahi-dev
16:34chadmed has quit []
16:34kraem has joined #asahi-dev
16:35chadmed has joined #asahi-dev
16:36chadmed has quit []
16:36chadmed has joined #asahi-dev
16:37zzywysmchadmed is likely asleep and doesn't realize a gremlin is repeatedly plugging and unplugging his Ethernet cable
16:37chadmed has quit []
16:38chadmed has joined #asahi-dev
16:39chadmed has quit []
16:40chadmed has joined #asahi-dev
16:54dylanchapell has quit [Read error: Connection reset by peer]
16:59buroaHow can we build m1n1 using musl instead of glibc?
17:02svenwhat makes you think m1n1 needs glibc?
17:05buroaThat's what is used to compile it.
17:05buroaI want to compile it using musl, so I can build it into Talos Linux's toolchain, which uses alpine.
17:06j`eyburoa: it doesnt use libc
17:06dylanchapell has joined #asahi-dev
17:06buroaIt doesn't use musl, so what does it use?
17:06j`eynothing
17:10buroaI don't have libc in my build as I use musl. By default that is using libc, so it's building.
17:12j`eynot sure what the issue is, but alpine has m1n1, that uses musl, so it works
17:19mazdragging libc in something as low-level as m1n1 would be... interesting.
17:21buroaSo building it with musl gets all kinds of errors... error: implicit declaration of function 'atol' [-Werror=implicit-function-declaration]
17:22buroaThere are many more, but that's just the surface.
17:22j`eythat's defined in src/string.{c,h}
17:23svensysinc/string.h i think
17:23j`eysorry yeah, src/string.c sysinc/string.h
17:23j`eyburoa: as I showed, alpine builds it just fine, so something weird in your setup
17:25buroaIt's... very custom
17:25buroaOnce I get this all figured out, I'll be able to publish Talos Linux versions for the community.
17:26jannegcan you paste the full failing compile command? i.e. the last compile cmd line from `make V=1`
17:29jannegcan you grep in /toolchain/lib/gcc/aarch64-linux-musl/13.2.0/include for "STRING_H"
17:30buroaYep, sec
17:32j`eynice spot janneg
17:32jannegthat file shouldn't be in the compiler include path "/toolchain/lib/gcc/aarch64-linux-musl/13.2.0/include"
17:40zzywysmwhen people tell me that the musl movement isn't a compulsion, i will remember this :D
17:41jannegI don't think this is related to musl
17:42zzywysmjanneg: he says "So building it with musl gets all kinds of errors..." not realizing that neither musl nor glibc are necessary to build m1n1
17:42svenlet's focus on the problem instead of musl vs. glibc
17:43zzywysmhe's building with -ffreestanding and -Werror=implicit-function-declaration simultaneously, are those mutually compatible?
17:44svenyeah, and that's also just from the normal m1n1 Makefile
17:47sam_yes, they are mutually compatible
17:47sam_you need prototypes for things either way
17:48sam_it's just about where they come from :)
17:48jannegwhy would -ffreestanding be incompatible with -Werror=implicit-function-declaration? the latter just errors out if an used function misses an declaration
17:48sam_exactly
17:48sam_(and it's default in gcc 14+, clang 16+)
17:49jannegm1n1 has prototypes for every used libc function in sysinc/
17:49zzywysmah, cool
17:57jeisom has joined #asahi-dev
18:01Bertrand___ has quit [Read error: Connection reset by peer]
18:02Bertrand___ has joined #asahi-dev
18:05svenweird, it includes /usr/include/string.h for some reason
18:07svenwhat does /toolchain/bin/gcc --version print?
18:08jannegthat would mean that "-nostdinc" is somehow broken
18:08svenyeah, i'm curious which compiler that is
18:10jannegfedora's 13.2.1 works as expected
18:12jannegtry adding "-nostdinc++", that was added in gcc-13 but it would be strange if that borked gcc -nostdinc
18:13jannegplease add "-v" to the command to generate display.S and paste the output from the command line
18:16svenhuh, where does -isystem /usr/include come from?
18:17svenoh, wait, you can that with just -nostdinc++
18:17svenplease run that -v thing again with -nostdinc present
18:17svenwe would've seen that earlier when you can make V=1
18:18jannegno, that outputs /toolchain/lib/gcc/aarch64-linux-musl/13.2.0/include
18:19jannegplease add -nostdinc++ instead of replacing -nostdinc
18:19jannegbut I would expect the output to be the same
18:20svenare you sure? i just see -nostdinc++ there and no -nostdinc
18:20buroaWait, you want both?
18:21j`eyburoa: I would look at your gcc build see what flags youre passing..
18:22sventhis smells like a messed up toolchain
18:23svencan you paste /toolchain/lib/gcc/aarch64-linux-musl/13.2.0/specs ?
18:23jannegthere is nothing suspicious in there. config is printed first
18:24jannegor the output of `/toolchain/bin/gcc -dumpspecs`
18:24svenyou can probably add that -isystem /usr/include by messing with that file
18:25svenand if this toolchain was never used to build with -nostdinc no one would've noticed that bug
18:26j`eyI think the kernel uses nostdinc..
18:26svenso much for that theory :D
18:27sventhat looks very suspicious
18:28sventhat seems to add -isystem /include for the c pre-processor
18:28svenhrm, that's not /usr/include though
18:29janneg`ln -s /toolchain/include /usr/include` looks a little suspicios as well
18:32jannegwith that adjustment the "--with-native-system-header-dir=/toolchain/include" from the gcc configure line looks suspicious as well
18:32sventhis very much sounds like a broken toolchain to me
18:33sam_how did this thing get built
18:33jannegyes, to me as well. only open question is how did break
18:34sam_oh boy it's that script? adjust.sh?
18:34svenduct tape and lots of luck? :D
18:34sam_not enough!
18:34svendo you know about that script? :D
18:35sam_all i know is what i just read from some of the above links and i feel a bit ill
18:35sventhough i guess that repo is archived so maybe it's not used anymore?
18:37j`eyanyway, not a m1n1 issue :P
18:39zzywysmwhy can't i link musl into these arm64 assembly files?
18:40jannegcurrent toolchain repo seems to be https://github.com/siderolabs/toolchain
18:43jannegand I don't see any gross hacks uin there
18:43wrender has joined #asahi-dev
18:46svenat this point it's either something else inside that spec file or a gcc that was somehow patched i think
18:51wrender has quit [Ping timeout: 480 seconds]
18:52buroaOk, I got it to build.
18:52buroaLast step: I need to concat m1n1 and u-boot.
18:52jannegburoa: how?
18:53jannegdon't forget the dtbs
18:53buroaThat's what I wanted to ask you guys.
18:53nicolas17no, how did you get it to build :D
18:53buroaAnd I stopped using the base and just depended on the tools. It's complicated
18:53buroaI built it exactly how Talos builds the kernel stage, essentially
18:53buroaIt must do something different with the toolchain.
18:54buroaI see that we have some Apple stuff inside u-boot upstream: https://docs.u-boot.org/en/latest/board/apple/m1.html#image-installation
18:54buroaThis is how Talos builds a lot of their u-boot things.
18:55j`eyyoul probably want to use the downstream uboot fork
18:55buroaYou guys seem smart, lol, so it should make sense :P
18:56buroaAnyways, I'm at the last step, and I have m1n1.bin from previously built stage... I want to include all of the .dtb's somehow (is that possible) for all the systems we support
18:56buroaSomething like this: cat /m1n1/m1n1.bin ${APPLE_M1_U_BOOT}/u-boot-nodtb.bin?? > /rootfs/apple_m1/u-boot.bin
18:56j`eywe have a script for it!
18:57buroaTalos does things extra, so I have to craft this a-like. Let me take a look at those.
18:57buroaThey do include a dbts folder... do I put them in there?
18:58zzywysmdtbs get cat-ted in, in between m1n1 and u-boot
18:58j`eyno, the dtbs go in the m1n1+uboot image
18:58buroa./usr/install/arm64/dtb/apple
18:59buroaThere are multiple dtbs though, how do I make one unified u-boot.bin with them?
18:59j`eyburoa: see the update-m1n1 script
19:00buroaAhh! Just cat them all together!
19:00buroaSiiiimple
19:02jannegremember to compress u-boot with gzip. that is mandatory since m1n1 can't determine size of the u-boot binary
19:02anders_2 has joined #asahi-dev
19:04jeisom has quit [Ping timeout: 480 seconds]
19:04buroaThanks for everyone's help here!
19:04buroaI'll let you know if I get this booted up :-)
19:05buroaThose were my two blockers. So really, thanks again
19:05j`eygood luck!
19:07john-cabaj has quit [Quit: john-cabaj]
19:09anders__2 has quit [Ping timeout: 480 seconds]
19:10john-cabaj has joined #asahi-dev
19:19zzywysm has quit [Quit: Textual IRC Client: www.textualapp.com]
19:20zzywysm has joined #asahi-dev
20:04___nick___ has joined #asahi-dev
20:07___nick___ has quit []
20:09___nick___ has joined #asahi-dev
20:33jeisom has joined #asahi-dev
20:51__gilles has joined #asahi-dev
20:56WindowPa- has joined #asahi-dev
21:01WindowPain has quit [Ping timeout: 480 seconds]
21:05jeisom has quit [Quit: Leaving]
21:06jeisom has joined #asahi-dev
21:08___nick___ has quit [Ping timeout: 480 seconds]
21:10jeisom_ has joined #asahi-dev
21:10jeisom has quit [Read error: Connection reset by peer]
21:31wrender has joined #asahi-dev
21:50jeisom_ has quit [Ping timeout: 480 seconds]
22:03jeisom has joined #asahi-dev
22:39wrender has quit [Ping timeout: 480 seconds]
22:47wrender has joined #asahi-dev
22:55wrender has quit [Ping timeout: 480 seconds]
22:56wrender has joined #asahi-dev
23:06wrender has quit [Ping timeout: 480 seconds]
23:08commandoline has joined #asahi-dev
23:09commandoline_ has quit [Read error: Connection reset by peer]
23:14wrender has joined #asahi-dev
23:23wrender has quit [Ping timeout: 480 seconds]
23:30wrender has joined #asahi-dev
23:35nicolas17j`ey: I tried copying /boot/vmlinuz-6.6.3-413.asahi.fc39.aarch64+16k from Fedora Asahi to my other computer and booting that with run_guest_kernel.sh, it throws "ERROR: Devicetree found but no kernel."
23:35nicolas17gzipping it doesn't help
23:37nicolas17PE32+ executable (EFI application) Aarch64 (stripped to external PDB), for MS Windows
23:38nicolas17ok you know what does work
23:38j`eyyeah, I had run similar files with m1n1
23:39nicolas17except with kernel modules disabled
23:39nicolas17so everything is built in and the incompatible modules in the initramfs are ignored
23:40nicolas17hm I have keyboard but not trackpad
23:54nicolas17and no touchbar or wireless... must be firmware then
23:55nicolas17"You can ignore the Arch Linux initramfs, but you should instead provide an initramfs with /lib/firmware/{brcm/apple} to make sure the built-in modules can find their firmware early"
…