Re: [PATCH v2 5/5] kvm: selftests: aarch64: use a tighter assert in vgic_poke_irq()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 26, 2022 at 07:08:58PM -0800, Ricardo Koller wrote:
> vgic_poke_irq() checks that the attr argument passed to the vgic device
> ioctl is sane. Make this check tighter by moving it to after the last
> attr update.
> 
> Signed-off-by: Ricardo Koller <ricarkol@xxxxxxxxxx>
> Reported-by: Reiji Watanabe <reijiw@xxxxxxxxxx>
> Cc: Andrew Jones <drjones@xxxxxxxxxx>
> ---
>  tools/testing/selftests/kvm/lib/aarch64/vgic.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/lib/aarch64/vgic.c b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> index 79864b941617..f365c32a7296 100644
> --- a/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> +++ b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> @@ -138,9 +138,6 @@ static void vgic_poke_irq(int gic_fd, uint32_t intid,
>  	uint64_t val;
>  	bool intid_is_private = INTID_IS_SGI(intid) || INTID_IS_PPI(intid);
>  
> -	/* Check that the addr part of the attr is within 32 bits. */
> -	assert(attr <= KVM_DEV_ARM_VGIC_OFFSET_MASK);
> -
>  	uint32_t group = intid_is_private ? KVM_DEV_ARM_VGIC_GRP_REDIST_REGS
>  					  : KVM_DEV_ARM_VGIC_GRP_DIST_REGS;
>  
> @@ -150,6 +147,9 @@ static void vgic_poke_irq(int gic_fd, uint32_t intid,
>  		attr += SZ_64K;
>  	}
>  
> +	/* Check that the addr part of the attr is within 32 bits. */
> +	assert((attr & ~KVM_DEV_ARM_VGIC_OFFSET_MASK) == 0);
> +
>  	/*
>  	 * All calls will succeed, even with invalid intid's, as long as the
>  	 * addr part of the attr is within 32 bits (checked above). An invalid
> -- 
> 2.35.0.rc0.227.g00780c9af4-goog
>

 
Reviewed-by: Andrew Jones <drjones@xxxxxxxxxx>




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux