• Paul Mackerras's avatar
    KVM: PPC: Book3S HV: Add radix checks in real-mode hypercall handlers · acde2572
    Paul Mackerras authored
    POWER9 running a radix guest will take some hypervisor interrupts
    without going to real mode (turning off the MMU).  This means that
    early hypercall handlers may now be called in virtual mode.  Most of
    the handlers work just fine in both modes, but there are some that
    can crash the host if called in virtual mode, notably the TCE (IOMMU)
    hypercalls H_PUT_TCE, H_STUFF_TCE and H_PUT_TCE_INDIRECT.  These
    already have both a real-mode and a virtual-mode version, so we
    arrange for the real-mode version to return H_TOO_HARD for radix
    guests, which will result in the virtual-mode version being called.
    
    The other hypercall which is sensitive to the MMU mode is H_RANDOM.
    It doesn't have a virtual-mode version, so this adds code to enable
    it to be called in either mode.
    
    An alternative solution was considered which would refuse to call any
    of the early hypercall handlers when doing a virtual-mode exit from a
    radix guest.  However, the XICS-on-XIVE code depends on the XICS
    hypercalls being handled early even for virtual-mode exits, because
    the handlers need to be called before the XIVE vCPU state has been
    pulled off the hardware.  Therefore that solution would have become
    quite invasive and complicated, and was rejected in favour of the
    simpler, though less elegant, solution presented here.
    Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
    Tested-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
    Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
    acde2572
book3s_64_vio_hv.c 14.2 KB