• Ryan Roberts's avatar
    KVM: arm64: Fix PAR_TO_HPFAR() to work independently of PA_BITS. · a0d37784
    Ryan Roberts authored
    Kernel configs with PAGE_SIZE=64KB and PA_BITS=48 still advertise 52 bit
    IPA space on HW that implements LPA. This is by design (admitedly this
    is a very unlikely configuration in the real world).
    
    However on such a config, attempting to create a vm with the guest
    kernel placed above 48 bits in IPA space results in misbehaviour due to
    the hypervisor incorrectly interpretting a faulting IPA.
    
    Fix up PAR_TO_HPFAR() to always take 52 bits out of the PAR rather than
    masking to CONFIG_ARM64_PA_BITS. If the system has a smaller implemented
    PARange this should be safe because the bits are res0.
    
    A more robust approach would be to discover the IPA size in use by the
    page-table and mask based on that, to avoid relying on res0 reading back
    as zero. But this information is difficult to access safely from the
    code's location, so take the easy way out.
    
    Fixes: bc1d7de8 ("kvm: arm64: Add 52bit support for PAR to HPFAR conversoin")
    Signed-off-by: default avatarRyan Roberts <ryan.roberts@arm.com>
    [maz: commit message fixes]
    Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20221103150507.32948-3-ryan.roberts@arm.com
    a0d37784
kvm_arm.h 12.6 KB