On Mon, 16 Mar 2020 at 19:36, Richard Henderson <richard.henderson@xxxxxxxxxx> wrote: > I'm not 100% sure how the system regs function under kvm. > > If they are not used at all, then we should avoid them all en masse an not > piecemeal like this. > > If they are used for something, then we should keep them registered and change > the writefn like so: > > #ifdef CONFIG_TCG > /* existing stuff */ > #else > /* Handled by hardware accelerator. */ > g_assert_not_reached(); > #endif (1) for those registers where we need to know the value within QEMU code (notably anything involved in VA-to-PA translation, as this is used by gdbstub accesses, etc, but sometimes we want other register values too): the sysreg struct is what lets us map from the KVM register to the field in the CPU struct when we do a sync of data to/from the kernel. (2) for other registers, the sync lets us make the register visible as an r/o register in the gdbstub. (this is not very important, but it's nice) (3) Either way, the sync works via the raw_read/raw_write accessors (this is a big part of what they're for), which are supposed to just stuff the data into/out of the underlying CPU struct field. (But watch out because we fall back to using the non-raw read/writefn if there's no raw version provided for a particular register.) If a regdef is marked as NO_RAW then it means there is no raw access and we don't sync the value. (4) I think that in KVM mode we won't deliberately do non-raw accesses, and a quick grep through of the places that do 'readfn' accesses supports that. thanks -- PMM