• Nicholas Piggin's avatar
    KVM: PPC: Book3S HV P9: Restore host CTRL SPR after guest exit · 5088eb40
    Nicholas Piggin authored
    The host CTRL (runlatch) value is not restored after guest exit. The
    host CTRL should always be 1 except in CPU idle code, so this can result
    in the host running with runlatch clear, and potentially switching to
    a different vCPU which then runs with runlatch clear as well.
    
    This has little effect on P9 machines, CTRL is only responsible for some
    PMU counter logic in the host and so other than corner cases of software
    relying on that, or explicitly reading the runlatch value (Linux does
    not appear to be affected but it's possible non-Linux guests could be),
    there should be no execution correctness problem, though it could be
    used as a covert channel between guests.
    
    There may be microcontrollers, firmware or monitoring tools that sample
    the runlatch value out-of-band, however since the register is writable
    by guests, these values would (should) not be relied upon for correct
    operation of the host, so suboptimal performance or incorrect reporting
    should be the worst problem.
    
    Fixes: 95a6432c ("KVM: PPC: Book3S HV: Streamlined guest entry/exit path on P9 for radix guests")
    Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20210412014845.1517916-2-npiggin@gmail.com
    5088eb40
book3s_hv.c 151 KB