#asahi-dev · 2023-09-10 12:17
mazyup.#asahi-dev · 2023-09-10 12:17
marcanand from what I see in the code, that includes AIDR_EL1#asahi-dev · 2023-09-10 12:17
mazKVM just exposes the host view. nothing else.#asahi-dev · 2023-09-10 12:16
marcanI mean what does KVM do right now?#asahi-dev · 2023-09-10 12:16
mazno, this can be overloaded with VMIDR_EL2.#asahi-dev · 2023-09-10 12:15
mazKVM has no provision to cope with asymetric systems.#asahi-dev · 2023-09-10 12:15
marcanah, so that isn't trapped?#asahi-dev · 2023-09-10 12:15
mazMIDR values as seen as the host's, directly from KVM. which means that if your vcpu thread migrates from one type to another, you see it.#asahi-dev · 2023-09-10 12:14
marcanhow are CPU implementors passed to the guest right now? is there passthrough mode or is it always some qemu thing?#asahi-dev · 2023-09-10 12:13
marcanand then all KVM has to do is save/restore context for these things#asahi-dev · 2023-09-10 12:13
mazas long as there is an _EL12/EL02 accessor#asahi-dev · 2023-09-10 12:13
marcanwhich means if we're doing that we might as well do what apple intended here, and just expose this raw to the guest and let it deal with it the same way my patch already does on bare metal#asahi-dev · 2023-09-10 12:13
mazfor IMPDEF regs, you could disable TIDCP, and context switch that in the same location.#asahi-dev · 2023-09-10 12:12
marcanone thing to keep in mind is that if we ever enable the APFLG feature especially, that one *definitely* has to be exposing this impdef stuff to EL0, and there's no trapping this#asahi-dev · 2023-09-10 12:10
marcan(and nobody cares for our use case)#asahi-dev · 2023-09-10 12:10
marcanI mean that's pretty obvious)#asahi-dev · 2023-09-10 12:10
maz(well, migrating an apple guest to anything else is fscked for plenty of reasons)#asahi-dev · 2023-09-10 12:10
marcansure, but I think it's fair to say if you start enabling IMPDEF features migration is fscked#asahi-dev · 2023-09-10 12:10
mazbut this still breaks a lot of things: migration of such a guest is fscked.#asahi-dev · 2023-09-10 12:09
mazquite.#asahi-dev · 2023-09-10 12:09
marcanyeah, and the point of upstreaming is... not having that problem :)#asahi-dev · 2023-09-10 12:09
mazthat's the distros problem.#asahi-dev · 2023-09-10 12:09
mazand indeed, I don't plan to have a stable ABI.#asahi-dev · 2023-09-10 12:09
marcanmodules yes#asahi-dev · 2023-09-10 12:08
mazthey've been around for 30 years.#asahi-dev · 2023-09-10 12:08
marcanmaz: well, we all know how stable the Linux kernel APIs are and how sustainable modules are long-term...#asahi-dev · 2023-09-10 12:07
marcanI'll keep my name then (some of the apple names are terribad)#asahi-dev · 2023-09-10 12:06
marcannah it's definitely SPSR semantics, not PSTATE semantics#asahi-dev · 2023-09-10 12:06
mazif you don't need the dynamic flip of TSO inside the guest, then it 's pretty easy to do, and we could probably stick that in a module -- just hook whatever you need to do in the arch-specific vcpu_load/vcpu_put helpers (the module interface itself is to be created).#asahi-dev · 2023-09-10 12:06
marcanwhich I think apple actually calls APSTATE_EL1? so maybe it's not exceptions? let me check...#asahi-dev · 2023-09-10 12:05
marcanah, it's in NZCV bits 26-27 and then save/restore on exceptions is via ASPSR_EL1 bits 1-2 (which is also IMPDEF).#asahi-dev · 2023-09-10 11:58
marcansupposedly NZCV which should map to CPSR bits unless they added state somewhere else...#asahi-dev · 2023-09-10 11:54
marcansorry not CPSR, APSTATE I think? which I think is IMPDEF#asahi-dev · 2023-09-10 11:49
marcannot sure what the rest of the bits do exactly. those 3 are the ones we care about for x86 emu, and TSO is by far the most important one.#asahi-dev · 2023-09-10 11:48
marcanbit 4 sticks some extra x86 flags in CPSR (I think?)#asahi-dev · 2023-09-10 11:47
marcanbit 5 is a pre-spec version of FEAT_AFP#asahi-dev · 2023-09-10 11:47
marcanthere are some other ACTLR bits described here: https://github.com/AsahiLinux/docs/wiki/HW:ARM-System-Registers#actlr_el1-arm-standard-not-standard#asahi-dev · 2023-09-10 11:44
marcanfor exposing TSO to the VM dynamically, we either disable trapping that reg (and AIDR) and signal it somehow, or we provide some kind of hypercall to poke it.#asahi-dev · 2023-09-10 11:44
marcanand then ideally signal the VM somehow, so software running in the guest can know it's in a TSO environment#asahi-dev · 2023-09-10 11:43
marcanso basically, for VM-wide TSO, we need to poke ACTLR_EL12 (e.g. copy it from ACTLR_EL2 to inherit whatever the host configured for that process, or something else)#asahi-dev · 2023-09-10 11:40
marcanmaz: https://gist.github.com/marcan/9ab73ca0614864bea0eea9e953c074d3 it's pretty simple#asahi-dev · 2023-09-10 11:26
eilnsounds good, because I messed up my signature lol#asahi-dev · 2023-09-10 11:25
marcaneiln: will look at camera again a bit later, going to sort out this TSO thing first :p#asahi-dev · 2023-09-10 11:22
eilnwait my key expired#asahi-dev · 2023-09-10 11:19
marcanre ACTLR, I just realized I do know how this works with EL1 since obviously I've tested this in m1n1 HV. I'll write a quick spec.#asahi-dev · 2023-09-10 11:13
marcanI'm not particularly keen on the "this will be downstream forever because upstream won't take it in any form" outcome :/#asahi-dev · 2023-09-10 11:12
marcanmaz: I mean, eventually this should be upstreamed in *some* form. Especially if we're going down the VM route, it will be incredibly silly to require downstream patches on the guest kernel when hardware support is otherwise not an issue.#asahi-dev · 2023-09-10 11:11
eilnhow far do your other machines go before halting? :P#asahi-dev · 2023-09-10 11:11
eilnsorry I wasn't clear. it doesn't have to alloc bottom-up anymore. but it'd be helpful (for me) to leave as is until we confirm the firmware boot mess across all variants. I also haven't checked vm_size for all dts. (rightfully) moving to iova.c is trivial, and I'll handle it right after#asahi-dev · 2023-09-10 11:10
eilnmarcan: I thought unk_size was firmware size too, but 0x180000 worked on 13.5 (0x100000). turns out unk_size only has to be greater than the current size, which the 0x180000 unknowingly covered.