mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
UPSTREAM: kvm: arm64: vgic: Introduce vgic_check_iorange
Add the new vgic_check_iorange helper that checks that an iorange is
sane: the start address and size have valid alignments, the range is
within the addressable PA range, start+size doesn't overflow, and the
start wasn't already defined.
No functional change.
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Ricardo Koller <ricarkol@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211005011921.437353-2-ricarkol@google.com
(cherry picked from commit f25c5e4daf)
Bug: 204960018
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ic702fe5c28dc1c7a7bc5975703acee084b8a7b6b
This commit is contained in:
committed by
Will Deacon
parent
975154d170
commit
fdd4c3ca37
@@ -29,6 +29,28 @@ int vgic_check_ioaddr(struct kvm *kvm, phys_addr_t *ioaddr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vgic_check_iorange(struct kvm *kvm, phys_addr_t ioaddr,
|
||||
phys_addr_t addr, phys_addr_t alignment,
|
||||
phys_addr_t size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = vgic_check_ioaddr(kvm, &ioaddr, addr, alignment);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!IS_ALIGNED(size, alignment))
|
||||
return -EINVAL;
|
||||
|
||||
if (addr + size < addr)
|
||||
return -EINVAL;
|
||||
|
||||
if (addr + size > kvm_phys_size(kvm))
|
||||
return -E2BIG;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vgic_check_type(struct kvm *kvm, int type_needed)
|
||||
{
|
||||
if (kvm->arch.vgic.vgic_model != type_needed)
|
||||
|
||||
@@ -175,6 +175,10 @@ void vgic_irq_handle_resampling(struct vgic_irq *irq,
|
||||
int vgic_check_ioaddr(struct kvm *kvm, phys_addr_t *ioaddr,
|
||||
phys_addr_t addr, phys_addr_t alignment);
|
||||
|
||||
int vgic_check_iorange(struct kvm *kvm, phys_addr_t ioaddr,
|
||||
phys_addr_t addr, phys_addr_t alignment,
|
||||
phys_addr_t size);
|
||||
|
||||
void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu);
|
||||
void vgic_v2_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr);
|
||||
void vgic_v2_clear_lr(struct kvm_vcpu *vcpu, int lr);
|
||||
|
||||
Reference in New Issue
Block a user