• Christoffer Dall's avatar
    KVM: arm64: Defer saving/restoring 64-bit sysregs to vcpu load/put on VHE · fc7563b3
    Christoffer Dall authored
    Some system registers do not affect the host kernel's execution and can
    therefore be loaded when we are about to run a VCPU and we don't have to
    restore the host state to the hardware before the time when we are
    actually about to return to userspace or schedule out the VCPU thread.
    
    The EL1 system registers and the userspace state registers only
    affecting EL0 execution do not need to be saved and restored on every
    switch between the VM and the host, because they don't affect the host
    kernel's execution.
    
    We mark all registers which are now deffered as such in the
    vcpu_{read,write}_sys_reg accessors in sys-regs.c to ensure the most
    up-to-date copy is always accessed.
    
    Note MPIDR_EL1 (controlled via VMPIDR_EL2) is accessed from other vcpu
    threads, for example via the GIC emulation, and therefore must be
    declared as immediate, which is fine as the guest cannot modify this
    value.
    
    The 32-bit sysregs can also be deferred but we do this in a separate
    patch as it requires a bit more infrastructure.
    Reviewed-by: default avatarAndrew Jones <drjones@redhat.com>
    Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
    Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
    fc7563b3
sysreg-sr.c 9.23 KB