#
…

2021-01-31

00:03x4m3 has joined #asahi-dev
01:51WhyNotHugo has quit [Ping timeout: 260 seconds]
01:52WhyNotHugo has joined #asahi-dev
02:21yuyangchee98[m] has joined #asahi-dev
03:31PhilippvK_ has joined #asahi-dev
03:31PhilippvK has quit [Ping timeout: 264 seconds]
04:13br377 has quit [Ping timeout: 264 seconds]
04:15br377 has joined #asahi-dev
04:33marcanfigured out the sError thing. turns out mapping device memory as nGnRnE isn't enough to guard it, you need to also mark it non-executable...
04:33marcanthe M1 decided to speculate an instruction fetch from address 0.
04:34marcanthat is very weird, though, because you'd *think* that means it would also break with the MMU off, where there is no such thing as non-executable...
04:34marcanbut then again I only saw this behavior, so far, on return from a page fault, which can only happen with the MMU on, so...
04:34marcanspeculation/prediction strikes again
04:35marcanthis thing really does punch you in the face if you miss any of these details, moreso than any other CPU I've ever used
04:52modwizcodeI feel like that's because most other CPUs aren't quite as speculative and the intel and amd ones have a microcode to make it behave more probably
04:53modwizcodeAlso I wonder if some of that speculation is disabled unless the MMU is on, like caching.
04:53marcancould be
04:53marcanthough the problem happened with caches off too, just with MMU on
04:53modwizcodeYeah but I mean like the whole caching system is disabled with MMU off
04:54modwizcodeI'm guess it's a good gate to wait to enable anything that might be buggy until there's an OS capable of dealing with it
04:54modwizcodeAnyway how'd you figure this one out?]
04:54modwizcodeEverytime you write to more HID registers I get to stub them out in my qemu branch :p
04:54marcanwell the L2 subsystem address was basically zero (ignoring the high bits which seem to have a special meaning)
04:55marcanso... it sounded like something was hitting zero
04:55marcanso I tried just unmapping zero and it worked
04:55marcanand then I thought something must be broken because it's nGnRnE mapped and yet something was still hitting it speculatively... in what looked like an instruction fetch path even...
04:56modwizcodeI still haven't watched the chicken bits stream, from the registers I've had to poke, what's the L2 stuff pertain to?
04:56krbtgti wonder if a lot of these... quirks is part of M1's perf crown
04:56modwizcodeDid it give you a signal that it was an instruction path?
04:56marcanmodwizcode: it was happening on *return* from a page fault
04:56modwizcodeI'm more impressed that they can disable all the broken stuff
04:56marcanso... what else would it be?
04:56modwizcodeI didn't realize you meant literally... return
04:57marcanlike the PC wasn't advancing at all
04:57modwizcodeI feel like I've seen that note you screenshotted there
04:57marcananyway, the L2 error reporting can be disabled, which is what corellium do - presumably because they have bad address faults lurking and they didn't want to bother fixing them
04:58modwizcodeRight so I was wondering if they disable that, but thing still work, is it just subtly broken?
04:58marcanwell a bad read or write from unmapped address ranges just does nothing, other than report the error
04:58marcanactually a bad read will report a sync error
04:58marcanbut a bad write, or speculation, or any of that stuff, is just SError
04:59marcanand those can be disabled in the control register
04:59marcanbut that still means you're doing something wrong
04:59marcanand it might break other things
04:59modwizcodewait what is SError? I thought it meant secure until now but then I thought it was sync.
04:59marcanSystem Error
04:59marcanit's an asynchronous exception
04:59modwizcodeYeah okay that makes sense
05:00marcanlike MCE on x86
05:02modwizcodeyour patch setting TTBR1_EL2 faulted under emulator and I realized that I needed to set some id bits to enable the EL2 virtualization extension fully.
05:03modwizcodeDo you have a dump of the ID registers handy by any chance?
05:03marcanwhich ones?
05:03modwizcodeID_AA64MMFR[0-3]_EL1
05:03modwizcodeand there's a few others I might need but those ones I know I need now
05:05modwizcodearm 64 is such a weird architecture, there's so much crap that's shoved in using the MSR type functionality, and they have crazy names for everything. The TLB flush instruction has insane argumentation. (I think it's the tlb flush one?)
05:05marcan>>> mrs(ID_AA64MMFR0_EL1)
05:05marcan0x12120f100001
05:05marcan>>> mrs(ID_AA64MMFR1_EL1)
05:05marcan0x11212100
05:05marcan>>> mrs(ID_AA64MMFR2_EL1)
05:05marcan0x1201111100001011
05:05marcanand yeah, half the documentation is incomprehensible
05:06marcanI used to like ARM, but I think I don't any more
05:06modwizcodeI should just pull open the actual architecture reference PDF which is 1000x better but I'm lazy
05:06marcanPPC is way saner, at least the docs
05:06modwizcodeYeah same here lol
05:06modwizcodeI like PPC's assembly syntax better
05:06modwizcodeAlthough I've used it less
05:06marcanI'm fine with arm asm
05:06marcan32 and 64
05:06marcanthe core stuff I mean
05:06modwizcodeThanks for getting me the registers btw
05:06marcanbut stuff like the cache ops etc get pretty ridiculous
05:06modwizcodeYeah I was looking at the MMU enable to make sure I didn't have to touch it and I was like what are these arguments
05:07davidrysk[m]how much of it is ARM and how much of it is Apple's version of it?
05:07modwizcodepoint of unification, point of coherance sort of make sense, but then you have inner shared, outer shared.
05:07modwizcodeMost of it's arms
05:07modwizcodeApple's stuff is mostly just model specific registers to poke at and disable/enable added functionality they've got from what I can tell, marcan probably knows more
05:08marcanyeah, we're talking about the ARM stuff
05:08marcanApple's stuff is actually much simpler to understand
05:08marcanI mean the chicken bits are deep CPU feature stuff, so of course nobody knows what those really do
05:08marcanbut it's just a pile of enables/disables/knobs for that stuff
05:08marcanthe incomprehensible stuff is things like ARM's hypervisor and MMU control registers
05:09modwizcodeOh god ARM's hypervisor thing I thought was going to make sense and it totally doesn't
05:09modwizcodeIt makes no sense at all
05:09krbtgtmarcan: wrt ppc docs, my problem after reading them is IBM bit ordering is the opposite from everyone else
05:09marcanoh yeah, big endian land
05:09marcanbut everything *else* is sane
05:09krbtgtmarcan: acxtually not
05:09modwizcodeExcept when PPC decided to be little endian
05:09krbtgtthey order bits from least signigicant *bit* on the left
05:09modwizcodeoh god they're like the ethernet people
05:09davidrysk[m]what about G5 and all of its idiosyncrasies?
05:09marcankrbtgt: no they don't
05:10marcanthey order bits from least significant bit on the right
05:10marcanthey just *call* the most significant bit, on the left, bit 0
05:10krbtgtah right, i mixed it up
05:11modwizcodeARMs docs also do something I find really insufferable which is instead of documenting how enabling one bit that affects others does it, it documents in every other bit how that bit is affected. Which spreads out the meaning of things like the E2H bit into everything. The best part is the E2H bit documentation says "See E2H bit for more details"
05:12modwizcodemarcan: do the barriers you added before print_regs calls have visible effects?
05:13davidrysk[m]I've seen someone say that ARM documentation "reads like stereo instructions"
05:13modwizcodeI don't know how to interpret that but I'll take it
05:13davidrysk[m]ever dealt with boring dull appliance manuals? :P
05:14modwizcodealso is ther eany more details about what SYS_CYC_OVRD does? From m1n1 it seems like it masks interrupts somehow? Why do they have a second place to mask interrupts?
05:22marcanmodwizcode: I want to make sure that speculation doesn't mess up ordering of the L2 error status registers; before I added the one after that sometimes it was already SErroring before it *really* returned from the page fault
05:22marcanthe wonders of speculation
05:22modwizcodethat's amazing
05:22marcanthis is low level enough that I don't really mind the shotgun approach to barriers, figuring out the details with all of these system and even undocumented MSRs is not worth it
05:23marcanfor Linux using standard stuff we do need to know the specific requirements though
05:23modwizcodeYeah it's basically impossible I think
05:23modwizcodeTo understand them completely with how much tweaking can be done at a microarchitectural level. Like I said I'm sort of in awe that they had the foresight to have so many of these be tweakable.
05:24marcanthe thing is all CPUs are like this
05:24modwizcodeI know that all cpus are like this, but knowing what's going to be broken ahead of time is a skill.
05:24marcanIntel and AMD just hide it behind microcode blobs (that contain startup sequences that just poke chicken bits, among other things) and proprietary bringup blobs (AGESA etc)
05:24marcaneveryone puts a zillion chicken bits in their cores
05:24marcanthe fun thing here is Apple delegates fixing all this stuff to the OS kernel *and* documents the bit descriptions
05:24modwizcodeYeah that's interesting
05:24marcanso we get to see deep CPU design knobs that we usuall don't
05:25modwizcodeI mean also though I wonder how much of this complexity the typical arm core even has.
05:25marcanwell, judging by the pile of "work around cortex-whatever" errata fixes in the linux kernel...
05:25modwizcodehmm maybe I'm not enough aware of those yet
05:25marcanI'd say ARM have done a much better job of making those chicken bits ahead of time instead of hideous workarounds the kernel needs to apply
05:25marcanprobably, anyway
05:26marcaner, Apple
05:26modwizcodeI wonder if not poking these bits at all would leave you with a functional core enough to work around it
05:26marcanin some cases, probably
05:26marcanalso of note, chickens.py used to set all the chicken bits backwards
05:26marcanand it still mostly worked :)
05:27marcanI only noticed after applying it after the C code ram and noticing it was undoing everything
05:27marcanI had set/clear switched :)
05:27marcanso a lot of this stuff is not completely obvious
05:27modwizcodeLOL. did you see my question about the SYS_CYC_OVRD bits? I'm guessing CYC refers to cyclone, but what's the deal with those and IRQs?
05:27davidrysk[m]a lot of it probably comes up when you're doing more complex stuff
05:27marcanI think that register got introduced with cyclone and then the name stuck
05:27marcanand I think those can be used for IRQ injection maybe?
05:28modwizcodeoh interesting
05:31modwizcodeexample of horrible arm instruction "tlbi vmalls12e1is"
05:31ldhacker[m]What assembly language should I be learning for the M1? Just trying to create a hobby OS that I don’t plan on releasing to learn the OS DEV side of things. Also, any book/reference recommendations?
05:33TheJollyRoger has joined #asahi-dev
05:36comexmodwizcode: still beats the arm 32-bit version, mcr p15, 0, r0, c8, c5, 0
05:37comexi mean, at that point, why do you even have an assembler
05:37modwizcodeNo I like that version!
05:37comexif you're going to have a bunch of magic numbers, why not just hardcode the instruction word
05:37modwizcodeThe documents have a sort of saneness as to what each register mean
05:37modwizcode*er each subop
05:37modwizcodeI used to sort of know it when I was reversing wii stuff
05:37comexdisagree :)
05:39davidrysk[m]marcan: any plans to do another stream sometime?
05:39modwizcodeAnyway I better get to bed before someone gets mad at me
05:39davidrysk[m]night modwizcode
05:40marcandavidrysk[m]: I don't really plan them, depends on what I'm doing :)
05:40marcanbut there will be circuit design streams soonish
05:40davidrysk[m]ldhacker: M1 uses aarch64... I'd also recommend any good computer architecture books
05:41davidrysk[m]marcan: cool :)
06:12amw has joined #asahi-dev
06:34VinDuv has joined #asahi-dev
07:43amwIs the m1n1 loader / kernel stable enough to try booting on a MacBookAir M1 with out serial cable?
07:43amwIf so I was thinking about trying to get this to happen and documenting the setup of the booting
07:54amwIf it's not obvious - I don't have a magic USB Type-C serial cable nor likely to get one anytime soon and if MacOS can easily dual boot / recover it would be safe?
07:55amwThe framebuffer displays on the screen - there's no input till USB / Keyboard is up but still let's one experiment via printk?
08:34VinDuvAFAIK the boot process is very safe, you can always hold the power button to change the boot device back to macOS; if the recovery partition gets damaged (very unlikely) the Mac won’t boot but can be restored using another Mac with DFU mode (see https://github.com/AsahiLinux/docs/wiki/M1-vs.-PC-Boot)
08:35VinDuvBut unless I’ve missed something, m1n1 is not currently able to load a Linux kernel and initramfs from disk; you have to transfer them over serial
08:37amwVinDuv: Ok - Some how I thought the disk was working
08:38amwWould it be possible to concatenate the Linux kernel + device tree to m1n1 ?
08:41kit_ty_kate has quit [Ping timeout: 272 seconds]
08:44VinDuvamw: I guess so, but you’ll have to re-“bless” m1n1 every time you modify it I think
08:57bisko has quit [Quit: Textual IRC Client: www.textualapp.com]
08:57amwVinDuv: Good point - but still really fun for me to get working with on my MBA - perhaps not practical for serious debugging though.
09:01amw has quit [Ping timeout: 240 seconds]
09:04VinDuvof course :)
10:15marcanoh, they left
10:16marcanI was going to say there is no way to brick these machines as long as you don't write to NOR flash
10:17marcan... I have no idea why corellium actually declare the SPI flash in their device tree, unless they have to read anything from it (which I doubt, iBoot should put everything necessary in the device tree) we are definitely *not* doing that
10:17marcanthat is a recipe for a bad codepath/script gone rogue bricking machines
10:18marcananyway, m1n1 will be usable for normal kernel boot soon, as soon as I get SMP up I'll write in appended payload support
10:18marcanright now serial is required
10:18marcanthat should be done today
10:19kettenismarcan: some of ARM's own cores do the speculative execution of nGnRnE as well
10:43Bluerisemarcan: on some machines, like an APU, it's helpful for firmware upgrades. but on the Macs I wouldn't dare change anything like that, it'd be stupid.
10:46amw has joined #asahi-dev
10:49Glanzmannmarcan: Look forward to m1n1 to be able to boot the payload with out usb cable.
10:50marcanBluerise: leave firmware updates to macos :)
10:50Glanzmannmarcan: Have you already all the device drivers from corellium in your kernel or are there bigger changes required?
10:50marcanGlanzmann: I am not merging corellium drivers right now
10:50marcanI am getting the core platform support clean first
10:51marcanI have no reason to rush things, this isn't a race
10:51marcanthey are hacking on things as fast as possible, that is not our goal here :)
10:51marcanI spent yesterday working out what was causing bus errors on m1n1 - corellium just turns off bus error reporting
10:51GlanzmannYeah, I read that in the backlog somewhere. :-)
10:59amwmarcan: When you have m1n1+linux+dtb+initramdisk booting do we need a new partition for it?
10:59marcanno, there is no storage driver yet in my tree anyway
10:59marcanbut I would recommend having a secondary macos install you use for linux, instead of messing with your primary one
10:59marcanand then having a separate partition prepared for when the storage driver is in
11:00amwIs there a guide to making a secondary MacOS install? Google?
11:00acelogic has quit [Ping timeout: 265 seconds]
11:00marcanwriting documentation is part of my task list now that this is getting usable for people :)
11:01marcanI'll write something up today/tomorrow
11:01amwBTW The m1n1+linux+dtb+initramdisk blob wouldn't need a storage driver as it has the init ramdisk?
11:01kettenis has quit [Quit: leaving]
11:02amwSo that means as long as the 1TR can access the bless blob it can be selected in the 1TR mode or something?
11:02marcanif you have two partitions, you can select your OS in the boot picker normally
11:03marcanno need to keep kmutiling, and no need to screw up your macos partition (Apple's updater probably won't be very happy if you keep replacing the macos kernel)
11:03marcanthis also means different SEP contexts and such once we get to implementing that
11:03marcanit's the right way to do it
11:04amwok - using boot picker to boot our blessed m1n1+what ever is the easy way.
11:05kettenis has joined #asahi-dev
11:06kettenis has quit [Client Quit]
11:06amwLokking forward to it - happy to write up my experiences if that's any help
11:06marcanit'll be helpful for people to follow the process and point out any gotchas :)
11:06kettenis has joined #asahi-dev
11:07amwIt's wonderfull learning so many new tools and interesting things - thanks
11:30Glanzmannmarcan: I'll try as soon as the instrcutions are up.
12:09amw has quit [Ping timeout: 246 seconds]
14:49roxfan2 is now known as roxfan
16:35snalty has quit [Quit: ZNC 1.8.2 - https://znc.in]
16:36TheJollyRoger has quit [Ping timeout: 268 seconds]
16:37modwizcodemarcan: no idea if it's been covered but do you expect Linux to have access to store secrets in the secure enclave? Obviously it won't have OS X access but would it theoretically supprot storing linux keyrings and the like?
16:38TheJollyRoger has joined #asahi-dev
16:39marcanmodwizcode: that's one of the goals, yes
16:39marcanI definitely want to be able to use it for U2F and SSH keys if possible
16:40marcanI don't see why it wouldn't be
16:40modwizcodeYeah I just wasn't sure if they made the effort to properly support access outside OSX, I think it's probably easier to not do that so who knos
16:41marcanI mean, what's OSX?
16:41marcanit's not like the SE knows we're not OSX
16:42modwizcodeI mean I guess it knows what got booted though
16:42marcanit knows a mach-o kernel got booted
16:42modwizcodeBut you're right it doesn't know it's not OS X
16:42marcanI mean I already tested booting a patched darwin (I just changed the version number)
16:42marcanworks fine
16:43modwizcodeThat's reassuring
16:46modwizcodeWhy does aarch64 have so many damn timers
17:10kettenisvirtualization
17:41taziden has quit [Ping timeout: 265 seconds]
17:44acelogic has joined #asahi-dev
17:59taziden has joined #asahi-dev
18:07vafanlignardeBluerise: if you happen to have one of those YZStudio ZY12PDN USD-PD triggers, there's a FUSB302 chip on those (you still need a type-c breakout and level converter though). Someone recently posted an OSS firmware. I've attempted to get Apple VDM working on top of that code although I've only succeeded with UFP and Get Action List so far: https://git.io/JtBD7
18:15BlueriseHeh, nice
18:17dhewgvs? c++ firmware? what?
18:17Bluerisevafanlignarde: I have a setup with a hummingboard pulse (ptn5110, tcpci compatible) right now
18:17Bluerisewhich I know kettenis has as well
18:18Bluerisebut I might order two... need to think about it. this would allow reducing one device from being complex to being dumb ;) which is an improvement if things work
18:18Bluerisebbl, grabbing food
18:19vafanlignardeBluerise: neat. are there breakout boards easily available for that chip?
19:13Bluerisevafanlignarde: which one did you get, the one with screw terminal, bare or usb cage?
19:13Bluerisefor the ptn5110? haven't seen any :/
19:13Blueriseso far I've seen that one on the i.mx8mq eval kit and the hummingboard pulse
19:14Blueriseoof, if I pay double it'll supposedly arrive in 3 weeks instead of 4-5
19:23vafanlignardeBluerise: i had a few with screw terminals (ZY12PDN-3) but I found that I needed to desolder the terminals to be able to solder wires for the UART onto the MCU.. the ZY12PDN-1 comes without a screw terminal.
19:37Bluerisekettenis: I ordered two. Will take a month to arrive at my place, then I'll see how I can flash i
19:38Blueriseso this week I'll build you one with the hummingboard, next month we might not need the hummingboard anymore
19:39Blueriseand in two months marcan might have serial prototypes :P
19:40kettenisyou're taunting him?
19:40BlueriseNah, just looking forward to a solution that stays on a single pcb, without any weird wires...
19:44bastilianI'm hoping that the M1 to M1 via USB-C will work soon.
19:46BlueriseHm, does the debug mode reset if you pull the USB-C plug?
19:46Blueriseor does serial continue to be available once enabled?
19:47j`eybastilian: oh no, ill have to buy another m1 :P
19:47bastilianhehee. :D been there.
19:49bastilianI'm thinking, that at some point there could be a similar solution for non-M1 machines and not as involved as a USB-C PD UART DIY cable, just a proper USB-C (PD) cable.
19:50bastilianBluerise: I don't know, that may depend on the machine. maybe. I really don't know, i try to piece together things, but my electronics and low level hardware knowledge is limited. ...so don't listen to me rambling. :D
20:35amw has joined #asahi-dev
20:37acelogic has quit [Remote host closed the connection]
20:39acelogic has joined #asahi-dev
20:44djhworld has joined #asahi-dev
20:48djhworld has quit [Client Quit]
20:49djhworld has joined #asahi-dev
21:05irl25519 has joined #asahi-dev
21:25VinDuv has quit [Quit: Leaving.]
21:29amw has quit [Ping timeout: 240 seconds]
21:37djhworld has quit [Quit: The Lounge - https://thelounge.chat]
21:39djhworld has joined #asahi-dev
21:51irl25519 has quit [Quit: irl25519]
21:56amw has joined #asahi-dev
23:00yrlf has quit [Quit: The Lounge - https://thelounge.chat]
23:01yrlf has joined #asahi-dev
23:03taziden has quit [Ping timeout: 240 seconds]
23:06taziden has joined #asahi-dev
23:23rwhitbyvafanlignarde: This seems to be much the same board as the ZY12PDN: https://www.aliexpress.com/item/32814956486.html - I happen to have 2 of these boards.
23:27rwhitbyBluerise: https://www.nxp.com/products/interfaces/usb-interfaces/usb-type-c-shield-board-for-kinetis-freedom-and-lpc-boards:OM13588 is pretty much the only dev board that NXP did for the PTN5110 (there's a DP version as well). Note that this board is very low volume - if Digikey runs out of stock you have to wait for some months for new boards (I used this board in a low-volume customer design).
23:28rwhitbyI'm not aware of any breakout boards for ptn5110. I have lots of different proprietary boards with it on. Fun fact - the discontinued Valve VirtualLink adapter for the Index VR headset has one in it.
23:39Blueriserwhitby: it's in stock at NXp, 67$ including shipping to .de
23:40rwhitbySWD doesn't have test pads on the WiTRN UPD005 - there is a windows tool which updates it over DFU.
23:40Blueriseoh and mouser has it as well
…