• Ricardo Koller's avatar
    KVM: arm64: vgic: Add more checks when restoring ITS tables · 243b1f6c
    Ricardo Koller authored
    Try to improve the predictability of ITS save/restores (and debuggability
    of failed ITS saves) by failing early on restore when trying to read
    corrupted tables.
    
    Restoring the ITS tables does some checks for corrupted tables, but not as
    many as in a save: an overflowing device ID will be detected on save but
    not on restore.  The consequence is that restoring a corrupted table won't
    be detected until the next save; including the ITS not working as expected
    after the restore.  As an example, if the guest sets tables overlapping
    each other, which would most likely result in some corrupted table, this is
    what we would see from the host point of view:
    
    	guest sets base addresses that overlap each other
    	save ioctl
    	restore ioctl
    	save ioctl (fails)
    
    Ideally, we would like the first save to fail, but overlapping tables could
    actually be intended by the guest. So, let's at least fail on the restore
    with some checks: like checking that device and event IDs don't overflow
    their tables.
    Signed-off-by: default avatarRicardo Koller <ricarkol@google.com>
    Reviewed-by: default avatarOliver Upton <oupton@google.com>
    Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20220510001633.552496-3-ricarkol@google.com
    243b1f6c
vgic-its.c 70.1 KB