#
…

2021-06-19

00:36marcanbloom: feel free to set +M if we get another attack
01:20Emantor has quit [Quit: ZNC - http://znc.in]
01:20Emantor has joined #asahi
02:03skipwich has quit [Ping timeout: 480 seconds]
02:06bgb_ has joined #asahi
02:14skipwich has joined #asahi
02:23bgb_ has quit [Ping timeout: 480 seconds]
02:24bgb_ has joined #asahi
02:32bgb_ has quit [Ping timeout: 480 seconds]
02:43bgb_ has joined #asahi
02:49amwI am seeing 1TR access different from https://www.youtube.com/watch?v=ilnfvkgzVvg - now have to select partition and then login to get to Utilities/Terminal
02:49amwI believe it is the 1TR as I can run csrutil disable in there - perhaps new in latest Mac upgrade?
02:51bgb_ has quit [Ping timeout: 480 seconds]
02:52yuyichao has joined #asahi
02:55amwmarcan: Have added a basic help command to shell.py which I think is useful - see https://paste.debian.net/1201723/
02:55amwCan update it some more and submit a pull request if your interested - it's quite small change
02:57PhilippvK has joined #asahi
03:00phiologe has quit [Ping timeout: 480 seconds]
03:22bgb_ has joined #asahi
03:42marvin24_ has joined #asahi
03:46marvin24 has quit [Ping timeout: 480 seconds]
03:51bgb_ has quit [Ping timeout: 480 seconds]
04:15TheJollyRoger has quit [Remote host closed the connection]
04:15TheJollyRoger has joined #asahi
04:55VinDuv has joined #asahi
05:14amwQuestion: Can I run linux under m1n1? The run_guest.py tool requires a Mach-O payload
05:18amwWhen I run the linux.py tool on Linux my USB devices appear to disappear? i.e. m1n1 dis-appears but I am using marcan/dart/dev branch which tries to use dwc3 USB driver ? - See https://paste.debian.net/1201729/
05:18bgb_ has joined #asahi
05:24VinDuvI’m pretty sure the m1n1 USB devices will always disappear if you start Linux directly with linux.py; if Linux itselfs starts emulating a USB serial port it will reappear, but the transition won’t be seamless
05:27VinDuvYou should be able to run Linux under the hypervisor though; for this I think you need to run m1n1 under the hypervisor, then start linux.py with the hypervised m1n1
05:28amwVinDuv: Ok - run_guest.py with m1n1.macho and then try linux.py?
05:29VinDuvM1N1DEVICE=/the/secondary/virtual/usb/port linux.py …
05:32amwok - otherwise according to https://github.com/AsahiLinux/m1n1#payloads you can concatnate additional payloads to m1n1 and then perhaps chainload that new m1n1?
05:33VinDuvyes, I was thinking about that, you should be able to run_guest a m1n1 with concatened payloads and the payload will run under HV
05:33VinDuvmight be easier
05:34bgb_ has quit [Ping timeout: 480 seconds]
05:40amwHmm plain chainload.py boots up the kernel which boots up to init, but the script times out waiting for serial port to appear. I guess kernel is run at EL2 not under m1n1
05:50amwHmm: Some success with original suggestion run_guest.py -S m1n1-payload.macho - I get a shell, kernel loaded, but all CPUs are started and I don't know where to jump to with kboot_boot?
05:56amwOops I missed the start command - starts up the kernel ...
06:00VinDuvyou should run a picocom on the secondary m1n1 USB device to see the boot logs
06:06marcanamw: do you have FileVault enabled?
06:07amwVinDuv: Yes that works (no CRs on linux console messages but initrd is good)!
06:08amwmarcan: Don't think so. Never used FileVault as far as I know - presume it's a MacOS thingie
06:08marcanencryption
06:08marcanI believe the security model is that if you have FileVault enabled, you need to authenticate before being allowed to run your own code
06:09marcanunless they changed it in 11.4, which they might have
06:10amwAaah - your referencing my original 1TR questions! - I would have to boot back to MacOS and work out how to check if FileVault is set up to answer
06:10marcanSystem Preferences > Security & Privacy > FileVault I believe
06:12marcanVinDuv: the problem with running m1n1/linux under the HV is there is no vUART input support yet; been meaning to add that...
06:14marcanamw: re run_guest.py, open up a picocom on the secondary USB CDC-ACM device
06:15marcanyou should see m1n1 boot and at least linux earlycon output
06:15marcanbut I expect the linux UART driver to really hate my lame vuart
06:15marcan(once it loads)
06:15marcanalso, if the devicetree is instantiating the USB device that the HV is using, that will go very wrong; there is no logic in m1n1 to disable that in the devtree if it's missing in the ADT, maybe that should be added
06:17marcanat least I guess I should make the HV unmap that from the guest :-)
06:17amwSee https://paste.debian.net/1201733/ to see the run_guest.py output ttyACM0 followed by the linux kernel console serial output on ttyACM1
06:18marcankind of impressed it got to a shell, heh
06:18marcanno kernel debug args though I guess
06:19amwmarcan: It's just a initrd that prints in a loop for ever till it locked up at 100?
06:19marcanI guess? I didn't write that initrd
06:20amwNo it's some rubbish debug one I had from months back - just to prove I can run something (with out any input)
06:20amwNow I have linux under the HV I need a way to dump the registers and see where it is executing et cetera.
06:21marcanI've wanted to add a concat thing to set kernel commandlines more easily, something like just 'cmdline:' + commandline + '\0' as a payload format
06:21amwIt says all the CPUs are running.... Is that right?
06:21marcanbut for now you can stick it directly in the devicetree
06:21marcanno, it shouldn't
06:21marcanFDT: CPU 1 is not alive, disabling... etc
06:22marcanonly CPU 0 should be alive when running under the HV
06:22marcanunless you mean the beginning bit
06:22marcanthe HV *does* start all CPUs
06:22marcanthen only uses CPU0 except it puts the watchdog on CPU1 (or was it 7?)
06:22marcanso technically all CPUs are up but only CPU0 is usable
06:22amwThe run_guest.py prints out "starting secondary CPUs..." and then 1 ...7 started...
06:22marcanbut the guest only sees CPU0
06:23marcanthat's just because the m1n1 smp support is initialized with a one shot function that starts all CPUs
06:23marcanand the HV wants to use one of the secondaries for the watchdog
06:23amwok - got me excited (and confused :-)
06:23marcanit shouldn't be too hard to make the HV support SMP
06:23marcanbut I need spinlock primitives and some trivial emulation of the cpustart hardware :)
06:24amwIs there a command to read a register from the CPU0 ? I'm thinking the PC
06:24marcanfrom the shell? the shell runs on cpu0, you're in that context
06:25marcanhv.ctx.elr is the guest return address (i.e. next instruction to be executed after returning)
06:25marcanhv.ctx.regs[0] etc will give you the GPRs
06:25marcanyou can get a backtrace with `bt`
06:25marcanI should add more proper debug-friendly commands, like a "show regs" thing :)
06:25marcanright now it only does that on exceptions
06:26TheJollyRoger has quit [Remote host closed the connection]
06:26amwWow! That stuff all works great
06:26marcanhonestly it should just expose a gdb stub at some point, so you can just use standard tools to load symbols etc
06:26TheJollyRoger has joined #asahi
06:27amwI'll try to map it by hand to symbols - it looks like it has the same stack trace all the time - halt loop?
06:27marcanquite likely the idle loop, yeah
06:27marcanyou can also do a disasm thing, sec
06:27marcandisassemble_at(p.hv_translate(hv.ctx.elr, True) - 32, 64)
06:27marcantry that
06:28marcan(you need to have gcc/binutils for aarch64 installed)
06:28marcanI should make that use keystone/capstone instead of that hideous shell-out hack
06:29amwI'm blown away by the power of this - all your commands work great : See https://paste.debian.net/1201734/
06:29marcanglad you like it :)
06:30marcanand yeah, wfi, so idle loop :)
06:30marcanneeds a lot more work to make it an ergonomic debugger, but the primitives are there
06:30marcanwell, except breakpoints and single-stepping
06:30marcanthat's a big missing thing
06:30marcanthough there is `step` which is a funny hack that just runs the guest for a few cycles (driven by a timer interrupt)
06:31marcan(it should eventually be a real single-step but I haven't gotten around to using the debug hardware yet)
06:33amwI can't seem to match up the stack trace addresses to System.map addresses - Perhaps they are all mapped up as it is the guest...
06:33marcanyou probably have kASLR
06:34marcanthe stack trace addresses are guest addresses (virtual)
06:34amw# CONFIG_RANDOMIZE_BASE is not set
06:34marcanmaybe there's an offset anyway?
06:34marcancan you upload the System.map somewhere?
06:36amwHave you got a spot? I don't have any servers running on the internet
06:38amwNot seeing anything on my weechat = but I'm very newbie...
06:39amwI can send an e-mail
06:40marcanyou should have a separate query window
06:40marcanor just /query marcan
06:41amwok - yep - uploaded.
06:42marcanffff8000102fdc30 T cpu_do_idle
06:42marcanStack trace:
06:42marcan - 0xfffff000102fdc3c
06:42marcanthat checks out
06:43amwok - Offset by a little - thanks
06:43marcanyeah, because the addresses are the *call* addresses
06:44marcanthere's no System.map support but.... it should be a one-liner
06:44marcanlet's see
06:46marcanamw: try: hv.symbols = sorted((int(i[0], 16), i[2]) for i in (i.split() for i in open("System.map").readlines()))
06:46marcanthen `bt` again
06:48marcanoh wait, I just noticed the 0xfffff000102fdc3c vs ffff8000102fdc30 - f vs 8
06:48marcanhuh, wonder what that's about
06:48amwI had to put the full path to System.map but bt is unchanged.
06:49marcanohh the opposite
06:49marcanmasking is set up for macos, no linux
06:53marcanamw: git pull, then run these commands (without restarting the hv!)
06:54marcanhv._reloadme()
06:54marcanload_system_map("/path/to/System.map")
06:54marcanfixed the pac mask thing :-)
06:55marcanI guess I should make the pac mask automatic by inspecting the pac registers at some point
07:29amwSorry - had to go drive some one - that didn't do anything though - https://paste.debian.net/?show=1201738;lines=0
07:50VinDuvamw: just a guess, but try setting hv.pac_mask = 0xffff000000000000
07:51VinDuv(not really sure if it’s the right way to do it, but that should give you more correct addresses I think)
07:54amwVinDuv: Nope :-(
07:55VinDuvdid you get 0xffff8000102fdc3c (four f, one 8) at the top of the stack trace this time?
07:55amwYep: 0xffff8000102fdc3c
07:57VinDuvcan you get the values of hv.sym_offset , hv.tba.virt_base , and hv.macho.vmin ?
08:00amwhv.sym_offset=-0xa110000 , hv.tba.virt_base=0xfffffe001005c000 hv.macho.vmin=0xfffffe0007004000
08:09aleasto has joined #asahi
08:09amwWoops just crashed my hv ... disassemble_at(0xffff8000102fdc3c, 8) -> it just rebooted...
08:14VinDuvthis is definitely not the right way to do it, but if you set hv.sym_offset = hv.tba.virt_base = hv.macho.vmin = 0 and hv.pac_mask = 0xffff000000000000 I think you should get your symbols…
08:19m42uko has quit [Ping timeout: 480 seconds]
08:24amwVinDuv: Too many values to unpack Exception.... - see https://paste.debian.net/?show=1201741;lines=0
08:28VinDuvdid you reload system.map?
08:30m42uko has joined #asahi
08:30amwGot this - https://paste.debian.net/1201742/ - how am I reloading the Sysmap?
08:32amwYep - that did it !
08:36VinDuvIf I’m not mistaken your patch to addr() should not be needed now that you have symbols — if you revert it and hv._reloadme() it you should have a nicer output
08:37VinDuv(The bug is in sym(), it should always return a tuple — https://github.com/AsahiLinux/m1n1/blob/main/proxyclient/m1n1/hv.py#L426 should be return None, None)
09:21choozy has joined #asahi
09:39Andalu30 has joined #asahi
10:06crabbedhaloablut has quit []
10:08crabbedhaloablut has joined #asahi
10:15crabbedhaloablut has quit []
10:17crabbedhaloablut has joined #asahi
11:04VinDuv has quit [Quit: Leaving.]
11:10bgb_ has joined #asahi
11:33bgb_ has quit [Ping timeout: 480 seconds]
11:38VinDuv has joined #asahi
11:39VinDuv has left #asahi [#asahi]
11:39VinDuv has joined #asahi
11:44choozy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
11:48VinDuv has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
11:48VinDuv has joined #asahi
12:26bgb_ has joined #asahi
12:39bgb_ has quit [Ping timeout: 480 seconds]
12:39Andalu30 has quit [Ping timeout: 480 seconds]
12:50marcanamw: pushed a fix
12:51marcanah, fixed the bug now too
12:51marcan(force push)
12:54minecrell has quit [Quit: :( ]
12:55minecrell has joined #asahi
12:55minecrell has quit []
13:20minecrell has joined #asahi
13:24bgb_ has joined #asahi
13:38yuyichao has quit [Quit: Konversation terminated!]
13:41Andalu30 has joined #asahi
13:51bgb_ has quit [Ping timeout: 480 seconds]
14:35TheJollyRoger has quit [Ping timeout: 480 seconds]
15:06roxfan has quit [Remote host closed the connection]
15:06bgb_ has joined #asahi
15:18roxfan has joined #asahi
15:19bgb_ has quit [Quit: WeeChat 3.0.1]
15:51bps has quit [Ping timeout: 480 seconds]
16:02berryRed has joined #asahi
16:05Andalu30 has quit [Ping timeout: 480 seconds]
16:58Andalu30 has joined #asahi
18:35eta has quit [Quit: Gateway shutdown]
18:38eta has joined #asahi
18:46berryRed has quit [Quit: Leaving]
19:13TheJollyRoger has joined #asahi
19:52aleasto has quit [Remote host closed the connection]
20:58amwEven using the load_system_map command it's still not working - https://paste.debian.net/1201789/
21:24ml00 has joined #asahi
21:29peaklight__ has quit [Read error: Connection reset by peer]
21:30ml00hi, shouldn't these be just if read: and if write:? because False does nothing - https://github.com/AsahiLinux/m1n1/blob/7c19dcc33fbc26dc0def1d1df3f6dad529bf08d4/proxyclient/m1n1/hv.py#L187
21:33j_eyyeah that looks weird
21:34j_eymarcan: ^
21:40ml00 has quit [Remote host closed the connection]
21:41bps has joined #asahi
22:02Andalu30 has quit []
22:49bps has quit [Ping timeout: 480 seconds]
22:57bps has joined #asahi
23:03choozy has joined #asahi
23:07bps has quit [Remote host closed the connection]
23:19aleasto has joined #asahi
23:32choozy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
23:47aleasto has quit [Quit: Konversation terminated!]
…