Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp560899lqp; Sun, 9 Jun 2024 08:33:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWwXxM6hLOXSCt2UBBieYUu0UwAHI/26UBJDK7+Hj+viRo0ovV/8NrgLMIjY0mH+na7Fgszl/FNqdbBugrV3AusveBgHBaZ8z4vCjlTlQ== X-Google-Smtp-Source: AGHT+IGiZyWoch9J/5M/nNtbScyxxCGcM+cS75its9OfCI9vVuBJPKFo1jnnBS8RKaJV1OdhWFZV X-Received: by 2002:a17:906:7aca:b0:a68:ece7:8db5 with SMTP id a640c23a62f3a-a6cd665e55bmr496581766b.31.1717947207901; Sun, 09 Jun 2024 08:33:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717947207; cv=pass; d=google.com; s=arc-20160816; b=OnCIm2D9S44/AZ5FSNTn45qjeDIwSjZB8WoGtbWpuP7NQ6F1eps+173amL4ZoeZFyX qkjpRtTyD9qYm1SJwqHtvE/v1mRmPdx+Xhq6dw5aSDSstKE7oAFBdnoty1BhHRoXeo9G bJQDBMq3WTPQ3Fykpkjt8g6o2LGDJxpSURTTu3afRj7g7rb+Y7j6UEPsBMgV6OMnBhj6 YeISn2Tkip80pobGzotiPPgR1K+tszmrE7fFJqh+o9kZ5YNQC4LzhYOYI17S+ryhmAn5 1ri3BXdUb90ZeLlzYnt9LWN9DDi/GPDTKFzScv4MJRxXsrfxn0VekaYHLeLiPgrmhU6o ypfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dvLb4EQePzdCw1JidNRQOd0lUeEVij5wud7SriP9HXs=; fh=zyteQSFr9uzSS6YcmRcUGEh3BoKv5Enjf60x7NG517c=; b=s/9y/8w9VnhZ1EimF5yDVjK/eR2f36vqrt/+/Yc4Z6NlYT9e64WTNY4+lv7XXpD5DS fpVsDdzXods7TBHnrzvNxu4aYj2dhiglBuuLzSa8tNO12L4wzCd+E+ofpNn1PFT2gfNs IX7KFoa8ixeKVMVha9FSOQC2KQG5ICDlc20/C8TK50Dw5xEMgpZjMwIZBmxho+f9fsQT Sngk83tCSJXQ/YlSoGF5ApVZOIm4qDv9NGgMMy3nHA1UogUfGlEth6/SHWGalJ1bTeXJ 99+tzFyT7825W/eRcpTqvhxH4lNIjFS9cDkrIxGTb0PgZUiCFA3ECd27+AtK0cnbWnv2 ZU9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s+j8k3X0; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-207396-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207396-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f18bd28f9si62069566b.52.2024.06.09.08.33.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 08:33:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207396-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s+j8k3X0; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-207396-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207396-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 977EF1F21079 for ; Sun, 9 Jun 2024 15:33:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42C1C45C0B; Sun, 9 Jun 2024 15:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="s+j8k3X0" Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CACD44207D for ; Sun, 9 Jun 2024 15:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717947198; cv=none; b=fi+LnF7YjpTl4GqppGMCIeMwppuxWzK8+li77LWiCKhxvX2/Wg7ARRdQOKx0bJpqiG1UxdDrtby1RLEGuVbGwIgArHIQQQfuWOt3heXtrCShb6eWFZ/8XuHBL6Lao/ZFI7VgK0V4xRpOEva1OPfx2huWUgEgqogwVVC1S7cPwMA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717947198; c=relaxed/simple; bh=r4v/UAXdtaVQkhy3RY4WN1zXyyz8Oiobysf6yxbLWck=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oNs/+O7LtU5DDvYFCDcU3ZXs1vDei6jvJNyDt8+DGTqZznibVr7j/xPGUm8p+syeboRlRNHmDr78azs+axorJTwvlQWSPjYZCxq26z7Qhg5dpVW/Rx9qtV7dAr3FPpBTXYWeeFRD6xXQtcn9sFlZ+CTWQVPflwMmd05Tnp+4S3Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=s+j8k3X0; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-421792aa955so11623815e9.1 for ; Sun, 09 Jun 2024 08:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717947195; x=1718551995; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=dvLb4EQePzdCw1JidNRQOd0lUeEVij5wud7SriP9HXs=; b=s+j8k3X03tydr5dzTCiWG/szBtN2dnnYY1oI99tPUTgJS1+5q5idKpXsfJPZvf98Gm udxSMh38XDJuegRTX5ac2j1BppV/UkNEn7HTp1y5CUjCBejDDxR6kHaWv9VkGaDarq/5 qf+V+B/TZSwM5b39zSp4OG6bC897Of+bt3vC4/Ms6o1gV2kSiIvhcOrMftwaSHAeXVpZ 5uqm41bwPW0bw7nvgmDedI4rcMR9TiNB7o+8MY5kIJMyBicRCC0cEKdM+SuXoULrPhFz QyclpCH9O6ufltIWptXfkOm1aDtqRheTt2FwZfDde70D3RT7dBoeIdUNayTVhhvyN8mH bgpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717947195; x=1718551995; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dvLb4EQePzdCw1JidNRQOd0lUeEVij5wud7SriP9HXs=; b=e7hXANRzJpvNjdcDlsFUGFyZzufnxc09GUR7KoFwvKmqP77vEkpgljvUoTyR3RiXaS 1Tuk5szieEuKGjE6xxuVnJAfZFUDmBe03nbGqfmajWrBExVjkdCteMeuPbZ7a8gNT76n 3CwNEf9+oaNJxx840pH4qV5gKV8mePCDoUHNwkRbvaOiZvd0ScijOGUOtfziAidcy75o PqnMLOM653/mS+n8Kd73QleKs9VegJs5BaL8lv6RNAf1Oaasg9Qsta2jE+t4oKlfIRT3 KBirv9K2NnCt9cKtcN1mwaxa/wcSTSNv8Ftot+ucd/VwQBLkCxu2Soyww/qfqcpy9/XF eQNw== X-Forwarded-Encrypted: i=1; AJvYcCWS+4rFAW0xub8CSmxmoUZiFn/enlvzP0PMXRaU3oSzcyDjUl0fgzrIpqE9DpoR8EK0+RsqAbxS50ciltLOUgi6k9lwQ00D/wEKHDPA X-Gm-Message-State: AOJu0Yw/K3kiXs1MDKkzUuxTFEipEJU90TMvVQq3gXMjZ9D0DPzFiNW8 NHvlp8gOKfApaSvNa2jngC2gGwpVpzgEyLPXBPiOEtGjyOujuLQ/6yCCpiyHV5Q= X-Received: by 2002:a05:600c:1f8b:b0:421:7983:f1c4 with SMTP id 5b1f17b1804b1-4217983f41cmr39632065e9.6.1717947194928; Sun, 09 Jun 2024 08:33:14 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215c2c7e8fsm114725415e9.38.2024.06.09.08.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 08:33:14 -0700 (PDT) Date: Sun, 9 Jun 2024 18:33:11 +0300 From: Dan Carpenter To: Fred Griffoul Cc: griffoul@gmail.com, Catalin Marinas , Will Deacon , Alex Williamson , Waiman Long , Zefan Li , Tejun Heo , Johannes Weiner , Mark Rutland , Marc Zyngier , Oliver Upton , Mark Brown , Ard Biesheuvel , Joey Gouly , Ryan Roberts , Jeremy Linton , Jason Gunthorpe , Yi Liu , Kevin Tian , Eric Auger , Stefan Hajnoczi , Christian Brauner , Ankit Agrawal , Reinette Chatre , Ye Bin , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH v4 2/2] vfio/pci: add msi interrupt affinity support Message-ID: <1855e4d2-02da-4ea1-94b3-8daf044b1243@moroto.mountain> References: <20240607190955.15376-1-fgriffo@amazon.co.uk> <20240607190955.15376-3-fgriffo@amazon.co.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240607190955.15376-3-fgriffo@amazon.co.uk> On Fri, Jun 07, 2024 at 07:09:49PM +0000, Fred Griffoul wrote: > diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c > index e97d796a54fb..e87131d45059 100644 > --- a/drivers/vfio/vfio_main.c > +++ b/drivers/vfio/vfio_main.c > @@ -1505,23 +1505,28 @@ int vfio_set_irqs_validate_and_prepare(struct vfio_irq_set *hdr, int num_irqs, > size = 0; > break; > case VFIO_IRQ_SET_DATA_BOOL: > - size = sizeof(uint8_t); > + size = hdr->count * sizeof(uint8_t); > break; > case VFIO_IRQ_SET_DATA_EVENTFD: > - size = sizeof(int32_t); > + size = hdr->count * sizeof(int32_t); Not related to your patch, but this multiply can integer overflow on 32bit systems. Better to use size_mul(). regards, dan carpenter > + break; > + case VFIO_IRQ_SET_DATA_AFFINITY: > + size = hdr->argsz - minsz; > + if (size > cpumask_size()) > + size = cpumask_size(); > break; > default: > return -EINVAL; > } > > if (size) { > - if (hdr->argsz - minsz < hdr->count * size) > + if (hdr->argsz - minsz < size) > return -EINVAL; > > if (!data_size) > return -EINVAL; > > - *data_size = hdr->count * size; > + *data_size = size; > } > > return 0;