From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAAC23382FD for ; Mon, 12 Jan 2026 07:57:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768204624; cv=none; b=WdrOkQldKLL2M5ZDci5n2ZW9cyyGQhxWo719WzVyFTyKvOdCf6yHhxPfgoh9rz2WJ3tvedFCUw4omoIr+ry/yQXw0fqag6Qe4cIai7xykrl4pHhd7ND/tbS1LS9sO1/zfTagXXiQypfRnABkgr/kLU6XHAaGLNiRLoGcfuFOCIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768204624; c=relaxed/simple; bh=3GOLCDXkfVVZ05Y4cv6TNh30GUTHtbL7SYOT4Ce5zik=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mHlEBV0qw56IR2UYWqdoi+Q4UhO7qVKC4KDbWkPAyxudO5Kxa+LbJstLDBldT3FkhThv7W9wpN5AYfl809r5kO7F+C7QKgl+462Jgg3eU7+IpwPWZURTqMu0k3LON/PxOajo5Fg+R7y628dX0qYCnr0gBQmBjXUQ5pAPjkuQQ8s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Vm43jAmb; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=KOWfKK6o; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Vm43jAmb"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="KOWfKK6o" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768204622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uNaI6vAiTafGJ4P5WzAhAEUj9FDWGHWtqmNkDzYuPE4=; b=Vm43jAmbSU2cZKlmUjHlgtvIQsUfTt1nfkZ5i7ctPZCEs4ga+lvwbPigDDRj6udnOKwvep NSr/UIHCf0xCdDvoA2odpkeTjXsurW7hHqUOp2dBXkmENO6e4YuVNZiUNTmMDQCFpWe48m nGIHz++9JDqs/ppI+w+W/bBkkU8pt7g= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-259-cJ6itMeSPhWmGNYXA6LFgQ-1; Mon, 12 Jan 2026 02:57:00 -0500 X-MC-Unique: cJ6itMeSPhWmGNYXA6LFgQ-1 X-Mimecast-MFC-AGG-ID: cJ6itMeSPhWmGNYXA6LFgQ_1768204619 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4779ecc3cc8so42291835e9.3 for ; Sun, 11 Jan 2026 23:57:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1768204619; x=1768809419; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=uNaI6vAiTafGJ4P5WzAhAEUj9FDWGHWtqmNkDzYuPE4=; b=KOWfKK6oFTk2CTUdElrlGooP8OrpyQyGOTeWiixiZYhXKzEf1Z1N6uyRqnh2my1TWc 2VAdYhBLjfeN3fRPPzgn8txW2Oqo2VaLNMgtZ+Tdu7Qtf8alP164WASfqo8Dqj9NuEP2 zxBVEp9hVsRCDXRwpyJj6Qxrs8mSFQorLvmPXJ7QejZtPGttgIerdA7F8JFXHx/4SxH3 ZyJnD4ijcoaJApV6X/lfvySpH/jQ5KW+79KcMDP/soGZRayMzqsXvAuBURqgMWMhd07t 1HNkXoPfQ0C79GvUkK9HwDKi+YzEL2P3TxxaVNug/EY414UCuTN3HZaxcQiXmhQ7yFOR u6Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768204619; x=1768809419; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uNaI6vAiTafGJ4P5WzAhAEUj9FDWGHWtqmNkDzYuPE4=; b=SRQNCPZd7REtS7hDqRQOr0dMHi+QSAA+/gRX8wI14ITY3TWwmazjNl0rMhWrXcSG/K VEWaRztWhV0QP6zZPPqto8qLQdf6a/BZ/Ye/VeIe8ymLY7Qm8Php1OHSWGtk599wlIwX cJ+x1bExipPRmGQ6tXrw6+OhW4Mbi6VvnT8v+M4OH4uAk1G2bjkwtmaX+UleP+m5Y4Eh jbJi8CoQ+2GNOPr9fQ38V8bFCGtOQcEK1SIj06kCHQy/oIG0ewOK8Q/a2WOIjvr9iTQj K2Efj4rivrizhSK4xEaWeQD84Z83a1ybHnQPOJmsrlPqcFpQgWVyMk0S5FDlrQU27pfI gnHw== X-Gm-Message-State: AOJu0YxuaNTDUDOf4ZFxb8Amyj2irWf77oesurF8Mrt15CMM60pLP3L5 1BsVH2Z70NNkyvFel/ChWSet1voYx1iC5wZ0Hhx/I/GyDYmaNtib3jvzC40D6QIoK/e7Fv8O9TX 3OuaGhGniMpWFcpdgy2nURM1aot02VL6ea7pEGPBM+tqmLWnxbAuMyFQAT9aLT7dGA350qJqPig == X-Gm-Gg: AY/fxX74Wgdad2s6Ngxma8kW8nnfPs2AfdtTM75GIT3098aDGRe6GAo+YG5pRJdlipi MbHLyOXpxjacohvlcdgzceIOKKF6Mu8sLpsAy7FLOuEni8W20y3rzUMVOW2vZ3ZeqEN5Xjs+Xn9 TUyQiVYS9WZ2A8lpueGM8PYTn0dplrLT2a0FyK9MlsD7pPvu1nf/R1ADGfuy2XN9qNWQ/4hcDyN kAnitsOG4rzAk6Ue//mx6Xl8zB33H6AXGPR3RaK2K9rDGUsQ7+zGXbTLBs13oE7xFDcBmFapsiz 6oQ9mD6CoPiypqtRFJ3UPM3GmWlzwiD1cbIIeN6Q1/8znpgDD+greBb+g36K3OLmoW8VGLcyb8t AjOgmuaK2If6s6fxpgtiRV0Y4S/JrHak= X-Received: by 2002:a05:600c:3556:b0:477:6374:6347 with SMTP id 5b1f17b1804b1-47d84b3bb18mr205145995e9.22.1768204619046; Sun, 11 Jan 2026 23:56:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEspCuw6gu7JaBhGRE+BEzTTY49qSNtwWtVX3obRDb+/f1rMFg2mt//SfGiZ/PkjtZLbS9GYA== X-Received: by 2002:a05:600c:3556:b0:477:6374:6347 with SMTP id 5b1f17b1804b1-47d84b3bb18mr205145755e9.22.1768204618585; Sun, 11 Jan 2026 23:56:58 -0800 (PST) Received: from redhat.com (IGLD-80-230-35-22.inter.net.il. [80.230.35.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f410c6csm353613865e9.1.2026.01.11.23.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jan 2026 23:56:57 -0800 (PST) Date: Mon, 12 Jan 2026 02:56:55 -0500 From: "Michael S. Tsirkin" To: Eugenio Perez Martin Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, Maxime Coquelin , Laurent Vivier , Cindy Lu , jasowang@redhat.com, Xuan Zhuo , Stefano Garzarella , Yongji Xie Subject: Re: [PATCH v11 04/12] vhost: move vdpa group bound check to vhost_vdpa Message-ID: <20260112025556-mutt-send-email-mst@kernel.org> References: <20260109152430.512923-1-eperezma@redhat.com> <20260109152430.512923-5-eperezma@redhat.com> <20260110184515-mutt-send-email-mst@kernel.org> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Jan 12, 2026 at 08:38:26AM +0100, Eugenio Perez Martin wrote: > On Sun, Jan 11, 2026 at 12:46 AM Michael S. Tsirkin wrote: > > > > On Fri, Jan 09, 2026 at 04:24:22PM +0100, Eugenio Pérez wrote: > > > Remove duplication by consolidating these here. This reduces the > > > posibility of a parent driver missing them. > > > > > > Signed-off-by: Eugenio Pérez > > > --- > > > drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 --- > > > drivers/vdpa/vdpa_sim/vdpa_sim.c | 6 ------ > > > drivers/vhost/vdpa.c | 2 +- > > > 3 files changed, 1 insertion(+), 10 deletions(-) > > > > > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > > index ddaa1366704b..44062e9d68f0 100644 > > > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > > > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > > @@ -3640,9 +3640,6 @@ static int mlx5_set_group_asid(struct vdpa_device *vdev, u32 group, > > > struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev); > > > int err = 0; > > > > > > - if (group >= MLX5_VDPA_NUMVQ_GROUPS) > > > - return -EINVAL; > > > - > > > mvdev->mres.group2asid[group] = asid; > > > > > > mutex_lock(&mvdev->mres.lock); > > > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c > > > index c1c6431950e1..df9c7ddc5d78 100644 > > > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > > > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > > > @@ -606,12 +606,6 @@ static int vdpasim_set_group_asid(struct vdpa_device *vdpa, unsigned int group, > > > struct vhost_iotlb *iommu; > > > int i; > > > > > > - if (group > vdpasim->dev_attr.ngroups) > > > - return -EINVAL; > > > - > > > > BTW is the original ">" here an off by one error? Should have been >= ? > > if yes then this is a kind of bugfix and maybe needs a fixes tag. > > > > Ouch that's a good catch, thanks! Do you prefer me to mark this patch > as "Fixes:" and send it for backporting to stable to or to create a > new patch just adding the ">=" and then moving the check to the vdpa > core on top? It seems adequate to just send this to backporting. Do document that this is a fix in the commit log though. > > > - if (asid >= vdpasim->dev_attr.nas) > > > - return -EINVAL; > > > - > > > iommu = &vdpasim->iommu[asid]; > > > > > > mutex_lock(&vdpasim->mutex); > > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > > > index 05a481e4c385..9d25b735b43d 100644 > > > --- a/drivers/vhost/vdpa.c > > > +++ b/drivers/vhost/vdpa.c > > > @@ -680,7 +680,7 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > > > case VHOST_VDPA_SET_GROUP_ASID: > > > if (copy_from_user(&s, argp, sizeof(s))) > > > return -EFAULT; > > > - if (s.num >= vdpa->nas) > > > + if (idx >= vdpa->ngroups || s.num >= vdpa->nas) > > > return -EINVAL; > > > if (!ops->set_group_asid) > > > return -EOPNOTSUPP; > > > -- > > > 2.52.0 > >