2021-03-08
00:22choozy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
01:19PhilippvK has quit [Read error: Connection reset by peer]
01:19phiologe has joined #asahi
02:31hspak has quit [Quit: bye]
02:34hspak has joined #asahi
03:03inglor has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
03:13inglor has joined #asahi
03:45_whitelogger has joined #asahi
03:48phiologe has quit [Ping timeout: 260 seconds]
03:48phiologe has joined #asahi
04:04marvin24_ has quit [Ping timeout: 240 seconds]
04:05marvin24 has joined #asahi
04:09nicolas17 has quit [Quit: Konversation terminated!]
05:03marvin24 has quit [Ping timeout: 260 seconds]
05:03marvin24 has joined #asahi
05:43odmir has joined #asahi
05:48odmir has quit [Ping timeout: 276 seconds]
06:30VinDuv has joined #asahi
06:52jeff_miw has joined #asahi
06:55jeff_miwsven: nice:) I would like to help to get usb on m1n1, I have a macbook air, let me the best way to help there
06:56svendo you have a uart cable and feel like reading cursed usb specs? then we could see if there's a way for you to help write serial code.
06:57svenotherwise i'd be happy to have some people test this once i make a little more progress and implement the serial class
06:58svenhttps://www.ti.com/lit/ug/spruhj7a/spruhj7a.pdf this is a user manual for this dwc3 controller fwiw
07:02jeff_miwno uart cable with all the usb pd/vdm stuff ... but I can work how to get one if mandatory. no problem to read the cursed specs :)
07:03svennah, no need to get one. i hope that i'll be able to finish at least an initial version of the serial part this week. after that most people probably won't need the pd uart cable anymore
07:04sveni'll let you know once i have something that is more useful than just printing what commands it receives over uart :)
07:12jeff_miw has quit [Ping timeout: 240 seconds]
07:28VinDuv has quit [Quit: Leaving.]
07:51svenyeah, i think once i have enumerating working CDC serial shouldn't be much more complicated
08:18vimal has quit [Ping timeout: 260 seconds]
08:30raster has joined #asahi
08:34mxw39 has quit [Quit: Konversation terminated!]
08:35vimal has joined #asahi
09:00josiahmendes[m] has quit [Quit: Idle for 30+ days]
09:00dyniec[m] has quit [Quit: Idle for 30+ days]
09:00mofux[m] has quit [Quit: Idle for 30+ days]
09:00mazmarcan: finally ironed out the annoying timer issue over the weekend, though the result isn't pretty at all. guests now work reliably.
09:01mazmarcan: I'll explore a solution that doesn't involve the magic timer LR though, as it prevents the emulation of some GICv3 features Linux relies on.
09:02mofux[m] has joined #asahi
09:21zkrx has quit [Ping timeout: 245 seconds]
09:29svenif I do the phy init manually from m1n1 and use my dart driver in linux their dwc3 driver also works without any modifications in gadget mode fwiw
09:32svenI then switched to writing usb code for m1n1 because I was tired to wait for my kernels to load over uart
09:49zkrx has joined #asahi
10:24marcanI think qemu on macos works reliably without that LR stuff, only mask bits for the two timers, though I'm not entirely sure
10:25marcanthe controller doesn't have DFP negotiation enabled by default, so if you present to it as an UFP it just does nothing until macos boots
10:32Jangal has quit [Remote host closed the connection]
10:32Janhouse has joined #asahi
10:44mazmarcan: the main problem is that you can't inject a timer interrupt using that magic register. the Pending state is only driven by the timer itself, and only the Active state is writable.
10:45mazmarcan: so although we can save/restore the timer state correctly, including the GIC Active state, we can't pend an interrupt from SW, and Linux relies on that for interrupt resending.
10:46mazmarcan: the GICv3 architecture mandates that you can write to the pending state and generate the corresponding interrupt, so that's pretty annoying.
10:47mazmarcan: you don't need to save the pending bit itself. the state of the timer is enough to regenerate it.
10:49mazso short of being able to set the Pending bit in the LR, we can't actually emulate the GICR_ISPENDING register for the virtual timer PPI.
10:52marcanoh, I guess what that HACR bit is redirect the vtimer from FIQ to that LR which then interacts with vGIC?
10:53mazyes. the magic LR takes the timer output as its pending bit, and exposes the resulting interrupt in the guest via ICV_IAR*_EL1.
10:53mazit's a really nice shortcut in the sense that it doesn't generate an exit from the VM when the timer fires.
10:53vimal has quit [Quit: Leaving]
10:54mazbecause that pending state is *only* drive by the timer, SW can't inject an interrupt in that LR despite the timer not firing, which the GICv3 architecture allows.
10:55marcanhow would that be used? wouldn't the guest always expect the timer to be pending when it receives an IRQ?
10:56mazin the case of a level interrupt, that's not a huge problem. it's more for edge interrupt that it is problematic.
10:58mazit really is a corner case, but deviating from the architecture is in general a very bad idea.
11:00mazthe main disadvantage is that you need to force an exit whenever the guest EOI a timer interrupt in order to unmask the physical interrupt.
11:01marcancould we use both, somehow? use a regular LR to inject pending states if the guest asks us to, otherwise let the timer use the shortcut LR
11:01mazwhich we don't have to do on normal GIC implementations, as the HW knows how to link the virtual interrupt to the physical one.
11:03mazsure, but if I can get decent perf with just mask/unmask, I'd be happy to just ditch the IMPDEF stuff.
11:03mazbecase this is a major hack in the vgic implementation, which is already a very complicated beast.
11:21svenmarcan: nice, I'm pretty sure usb host most is just going to work as well then once you have that i2c figured out
11:46klaus has joined #asahi
11:52jaalsa has quit [Quit: jaalsa]
11:52jaalsa has joined #asahi
12:11raster has quit [Quit: Gettin' stinky!]
12:11raster has joined #asahi
12:16jeff_miw has joined #asahi
12:16nmg_ has quit [Ping timeout: 246 seconds]
12:18jeff_miwI tried to mess around to understand how macOS is managing the USB port but I failed miserably to have the boot/kernel to take my kext :(. if anyone has a good pointer to replace an existing original macOS by one hacked, I'm interested :)
12:23nmg has joined #asahi
12:25sventhere are really three components to it: That TI chip connected over i2c to select the mode (DFP,UFP), the PHY (apple calls this one "ATC" I think, essentially magic register pokes required before accessing the controller), and this designware did controller (xhci + configuration for host mode, custom stuff for device mode)
12:25svenpart three is well documented if you just look hard enough. part one is mostly documented as well I think (except for the i2c part) and part 2 is completely custom apple stuff afaict
12:26jeff_miw has quit [Ping timeout: 240 seconds]
12:32raster has quit [Quit: Gettin' stinky!]
12:43tomtastic_ has joined #asahi
12:43tomtastic has quit [Ping timeout: 240 seconds]
13:03Spiffy has quit [Quit: BRB]
13:04Spiffy has joined #asahi
13:13mazarnd: from what I understand, HVF gives you a prety high-level interface to the vcpu, and can do a lot of stuff in the hypervisor layer.
13:14mazarnd: I doubt it. performance would be absolutely terrible, similar to what we end-up with running KVM on a RPi3...
13:52marcanarnd, maz: as far as I know hypervisor.framework only deals with IRQ/FIQ, it does not do vGIC
13:53marcan"After receiving a HV_EXIT_REASON_VTIMER_ACTIVATED exit reason, the caller of hv_vcpu_run() needs to make the interrupts to the VTimer pending in the guest’s virtual interrupt controller."
13:57odmir has joined #asahi
13:57lethalbit has quit [Read error: Connection reset by peer]
13:59lethalbit has joined #asahi
14:42vimal has joined #asahi
14:50mazmarcan: it has to do *some* vgic in the kernel, as the LRs cannot be populated from EL0. from what I see, their interface is exactly the same as KVM, except for the timer (and I don't really understand why).
14:51mazmarcan: to do the GIC in userspace, you'd need to pass the trapping of all ICV_* regs to userspace.
14:54mazI think you are confusing two different things: injecting a IRQ/FIQ directly, and injecting a GIC interrupt.
14:54mazhv_vcpu_set_pending_interrupt clearly injects a GIC interrupt, because there is an interrupt value provided to it.
14:59marcanhttps://gist.github.com/ant4g0nist/9b1786b73293052ed17ffaa1a38e4608#file-hypervisor-rs-L1429 look at this
15:00mazgreat for performance... I'll stay with my in-kernel, non-trapping handling, thank you very much.,
15:04marcanmaz: I'm really looking forward to this, running a few benchmarks side by side on qemu/macos vs qemu/kvm will make for good clickbait ;)
15:16raster has joined #asahi
15:21agrafmaz: I'm not aware of any hw backed GICv3 MSRs, but I haven't looked hard from EL2 either. HVF definitely just traps and delegates emulation to EL0 for everything. The only remotely irq related thing that's handled in-kernel is the arch timer, and that also just tells user space when it crossed cval.
15:27agrafmaz: I'm definitely eager to see some comparison on native vgic vs the el0 loop for real world use cases. Probably has quite a nasty impact on IPI heavy bits
15:44Hetflik[m] has joined #asahi
15:44never_released has quit [Changing host]
15:44never_released has joined #asahi
15:55never_releasedmaz: so there is a GICv3?
15:55never_releasedin addition to AIC?
16:00ldhacker[m] has quit [Quit: Idle for 30+ days]
16:00never_releasedmakes sense
16:01never_releasedmaz: pretty odd that macOS doesn't use that at all
16:01never_releasedand just traps all the regs to the VMM through Hypervisor.framework
16:02maznever_released: but as long as the traps work, we can deal with that in the kernel, where we have all the required emulation already.
16:02never_releasedknowing Apple, it's probably fully functional
16:05never_releasedI wonder if the reg to trap the GIC regs is known though
16:36zkrx has quit [Ping timeout: 245 seconds]
16:45marvin24 has quit [Ping timeout: 260 seconds]
16:56modwizcode has quit [Ping timeout: 246 seconds]
17:00vimal has quit [Ping timeout: 246 seconds]
17:01zkrx has joined #asahi
17:03modwizcode has joined #asahi
17:03nmg has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
17:03nmg has joined #asahi
17:04nicolas17 has joined #asahi
17:10marvin24 has joined #asahi
17:16marvin24 has quit [Ping timeout: 240 seconds]
17:16marvin24 has joined #asahi
17:19vimal has joined #asahi
17:35marcanI mean ffs, the version of macos that shipped on these things had some hideous brokenness in the boot process; everyone was screaming "update before you even dare do anything"
17:39marvin24 has quit [Ping timeout: 240 seconds]
17:40marvin24 has joined #asahi
17:47TheJollyRoger has quit [Quit: TheJollyRoger]
17:57VinDuv has joined #asahi
18:05mxw39 has joined #asahi
18:52aratuk has joined #asahi
18:54aratuk has quit [Remote host closed the connection]
19:20marcanwriting blog posts takes a while... I'm 3500 words into the progress report and I haven't even gotten to the linux kernel yet
19:28KindTwo has joined #asahi
19:31KindOne has quit [Ping timeout: 272 seconds]
19:31KindTwo is now known as KindOne
19:38TheJollyRoger has joined #asahi
19:45klaus has quit [Ping timeout: 272 seconds]
20:31choozy has joined #asahi
20:40aratuk has joined #asahi
20:45aratuk has quit [Ping timeout: 245 seconds]
21:23raster has quit [Quit: Gettin' stinky!]
22:00amw has joined #asahi
22:02marvin24 has quit [Ping timeout: 240 seconds]
22:03marvin24 has joined #asahi
22:03eta has quit [Ping timeout: 245 seconds]
22:07artemist has quit [Ping timeout: 240 seconds]
22:09VinDuv has quit [Quit: Leaving.]
22:12eta has joined #asahi
23:10Guest56 has joined #asahi
23:48choozy has quit [Remote host closed the connection]
23:49richbridger has quit [Quit: Leaving]
23:50richbridger has joined #asahi