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 3F8792FF641 for ; Tue, 3 Mar 2026 07:33:53 +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=1772523234; cv=none; b=BVaL9D8DAJhu8G4z18u1WFDFUrRuzJtQ6y6BABxlRtnQfm8m+xzA7wPNMHUOc5nYKh4Mgt50ybnE1/f+mBoeUEmc5vz+iqZYRUG0+0F1TE+7You6tbMk7RXJynMS8bc2FcsEmOMg8toIjO0wMX9YaiXaHP7AigcKqP3DcoJy91s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772523234; c=relaxed/simple; bh=59qHQ7DnDrxED0p5GkQ9k+GnHJ0hTz0cSxZxj2NdNqA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JejHYfo1XW992Og2mdPaC+bC44ntL6UI47mnlrgDiZu7MmStLzNbk8gB53VA86K9UlRtzzni3ILI6LvzIi+W+CRjXARXov8cE++LyC+J8y/gkTamnahCRDLJ5y9GJQbYHrT6b4G6UKiIfAexOdQidF6/TpmAua5pbZSlmx/YgWI= 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=ZGSkmVSg; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=mk/q1Q79; 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="ZGSkmVSg"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="mk/q1Q79" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772523232; 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=NlXojMn4d5weZIUKImq/I3PU8ARhz8g49XhRbNnib+o=; b=ZGSkmVSgRjxw73y1Lxp6hIRsRadFpDSMvA5BTVJ+1JPiugx8xXAEdm5P52FXrMzuxLzZsW IjqzC0LxZiR/fveichildBOu8GCT3IYfhRccuxRPl/A38COQM7TC0Sy28/N3qVTXf4XhqT R2sy7OsBjkeFzUVpxTzMydMf15vOzs4= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-531-rzfCucltNROTN0VNRtphug-1; Tue, 03 Mar 2026 02:33:51 -0500 X-MC-Unique: rzfCucltNROTN0VNRtphug-1 X-Mimecast-MFC-AGG-ID: rzfCucltNROTN0VNRtphug_1772523230 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-439beddef55so699638f8f.0 for ; Mon, 02 Mar 2026 23:33:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1772523230; x=1773128030; 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=NlXojMn4d5weZIUKImq/I3PU8ARhz8g49XhRbNnib+o=; b=mk/q1Q79fxhvYtw35Ok0OObfPrjYUZ6CZMU8zqdZ2iIO5e9HlyFb//0O8jS7szZHqa SIP3gMN0SCsPt141I1O7LrwquZ2SSw51XUU6WjPtKTWwsun+sGKdbtl2jMB5p32v8SdW mF8zhy6Dgi9OpFaw4nUZ63ktAKtqCz7RcZJ48+VeQpZnrkX509A+OzJTJHFQjJcluMv1 ++ceaJ3W/jqnBm40LuRMyYSwmfa7I40E36BUEbvfnsgRa9yqzA+zalYHA4UcL9vm76Ks Kh2/Sj+0KhrbLufL/rOFWVmVFd3aOd54/Q6/CI7DpG/db3rmOZgdNgYnxDbeduVdfSAm 1IuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772523230; x=1773128030; 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=NlXojMn4d5weZIUKImq/I3PU8ARhz8g49XhRbNnib+o=; b=mXFMWDYoJsBnwebjUXV5KdTBlo4oeKW6pIyfbXSBNRxo5bEELE8BsAor/uudUYn56q WN356BGZT1iNr3f60c+8JHMSzCe9kpOLgZ7Zleczbw9r6b8ROe2SN4bisPK7I5NQK8wk O/QJBkU3URKaJ55Lb30oo3wskJK0/rtZKWLjeozOWBfsvRmibF/f6hrgTq0EaUsKpnvX r/Nw/vTXYtOCi7Dz2naI/GlrAXuEruqcTmTqj91QA54hsz+gYodpD5VYcC4r4+AkiUOX vfSTl5Xviisct4CvsyTei25angLkWBGYyiD6cA20uXESDriv3fvgQtMZh9USnpKHsJ68 jqig== X-Forwarded-Encrypted: i=1; AJvYcCWsCzDSJYteSq3Jof5EydtT/xV7LNiiYGCClwLsSfEmPUjlGYRFDdaiQRMMDpJsAB/+J3KlPka4iLQn8Ik=@vger.kernel.org X-Gm-Message-State: AOJu0YwtCcr+vkN2Bhxju2EBhcazbo9OE2skJEX/tAICTeF+ifHGcA5V J5SX6CQt+N1hhptniOp3kZDwZ6xAIlULue5NPwJZWDGRORE2i6+NXpEIUqq0fYxAhrvNkV2KkDM KLh6nqBpVCAsChHTpLLJJTlE0eERzPdlrXIexGDCc/QN7WD99iE136hSEdY47qSeTNw== X-Gm-Gg: ATEYQzzdeIpjllXaN4HIO6TbyljbmHlN0QXmL14NdrKf4vL0u0qLvN7oQ+yRHVnJ09l MF+xgdzCnsPEhvonvTERYYfSFwo4le0qGwaH8E/QGnFCcDNnTPmtpHUcVuc0VTU/pEie7IeFCL8 bydXqd2DwP8wEOESesK+0r5289hpGssCqFiL4Ycsra3pQb4XG2VpDHACKlVZrXsdTqOKLUvptat nIxjeYncTJ3bpGuTV4WH8PCvljQkgbKip1oc6k8ERZEfMQ8xmCsuDL/jZ0vtSYl8V9L+V0t4OAC p5uYviLMWtVYHpP930V1xRzl5KYaP5CqY1LtpR1/pYdl4iirxxNKLP0LiOyFZFRmBZ3JUZAnaxY ZtIAURxcbqtha2NRAUuMxasooXomAZ+OUP6XllN2GPji2xw== X-Received: by 2002:a05:6000:4387:b0:439:c279:32e9 with SMTP id ffacd0b85a97d-439c2793574mr874599f8f.39.1772523229749; Mon, 02 Mar 2026 23:33:49 -0800 (PST) X-Received: by 2002:a05:6000:4387:b0:439:c279:32e9 with SMTP id ffacd0b85a97d-439c2793574mr874537f8f.39.1772523229106; Mon, 02 Mar 2026 23:33:49 -0800 (PST) Received: from redhat.com (IGLD-80-230-79-166.inter.net.il. [80.230.79.166]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439b485a0b6sm17215211f8f.39.2026.03.02.23.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2026 23:33:48 -0800 (PST) Date: Tue, 3 Mar 2026 02:33:45 -0500 From: "Michael S. Tsirkin" To: Jason Wang Cc: Eugenio Perez Martin , Cindy Lu , Laurent Vivier , Xuan Zhuo , Maxime Coquelin , linux-kernel@vger.kernel.org, Yongji Xie , Stefano Garzarella , virtualization@lists.linux.dev Subject: Re: [PATCH v2 3/5] vduse: add VDUSE_GET_FEATURES ioctl Message-ID: <20260303022922-mutt-send-email-mst@kernel.org> References: <20260210082554.1582553-1-eperezma@redhat.com> <20260210082554.1582553-4-eperezma@redhat.com> 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 Tue, Mar 03, 2026 at 03:20:22PM +0800, Jason Wang wrote: > On Fri, Feb 13, 2026 at 3:39 PM Eugenio Perez Martin > wrote: > > > > On Fri, Feb 13, 2026 at 2:25 AM Jason Wang wrote: > > > > > > On Thu, Feb 12, 2026 at 4:23 PM Eugenio Perez Martin > > > wrote: > > > > > > > > On Thu, Feb 12, 2026 at 9:07 AM Jason Wang wrote: > > > > > > > > > > On Tue, Feb 10, 2026 at 4:26 PM Eugenio Pérez wrote: > > > > > > > > > > > > Add an ioctl to allow VDUSE instances to query the available features > > > > > > supported by the kernel module. > > > > > > > > > > > > Signed-off-by: Eugenio Pérez > > > > > > --- > > > > > > A simple u64 bitmap is used for feature flags. While a flexible array > > > > > > could support indefinite expansion, 64 bits is sufficient for the > > > > > > foreseeable future and simplifies the implementation. > > > > > > > > > > > > Also, dev_dbg is used for logging rather than dev_err as these can be > > > > > > triggered from userspace. > > > > > > --- > > > > > > v2: > > > > > > * return -EINVAL if ioctl called with version < 2, so userland visible > > > > > > reply is kept (Jason). > > > > > > --- > > > > > > drivers/vdpa/vdpa_user/vduse_dev.c | 28 ++++++++++++++++++++++++++++ > > > > > > include/uapi/linux/vduse.h | 7 ++++++- > > > > > > 2 files changed, 34 insertions(+), 1 deletion(-) > > > > > > > > > > > > diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c > > > > > > index d1da7c15d98b..7458cbaed4c7 100644 > > > > > > --- a/drivers/vdpa/vdpa_user/vduse_dev.c > > > > > > +++ b/drivers/vdpa/vdpa_user/vduse_dev.c > > > > > > @@ -52,6 +52,9 @@ > > > > > > > > > > > > #define IRQ_UNBOUND -1 > > > > > > > > > > > > +/* Supported VDUSE features */ > > > > > > +static const uint64_t vduse_features; > > > > > > + > > > > > > /* > > > > > > * VDUSE instance have not asked the vduse API version, so assume 0. > > > > > > * > > > > > > @@ -1947,6 +1950,19 @@ static bool vduse_validate_config(struct vduse_dev_config *config, > > > > > > sizeof(config->reserved))) > > > > > > return false; > > > > > > > > > > > > + if (api_version < VDUSE_API_VERSION_2) { > > > > > > + if (config->vduse_features) { > > > > > > + dev_dbg(vduse_ctrl_dev, > > > > > > + "config->vduse_features with version %llu", > > > > > > + api_version); > > > > > > + return false; > > > > > > + } > > > > > > + } else { > > > > > > + if (config->vduse_features & ~vduse_features) > > > > > > + return false; > > > > > > + } > > > > > > + > > > > > > + > > > > > > if (api_version < VDUSE_API_VERSION_1 && > > > > > > (config->ngroups || config->nas)) > > > > > > return false; > > > > > > @@ -2207,6 +2223,18 @@ static long vduse_ioctl(struct file *file, unsigned int cmd, > > > > > > ret = vduse_destroy_dev(name); > > > > > > break; > > > > > > } > > > > > > + case VDUSE_GET_FEATURES: > > > > > > + if (control->api_version < VDUSE_API_VERSION_2) { > > > > > > + dev_dbg(vduse_ctrl_dev, > > > > > > + "VDUSE_GET_FEATURES ioctl with version %llu", > > > > > > + control->api_version); > > > > > > + ret = -EINVAL; > > > > > > + break; > > > > > > + } > > > > > > + > > > > > > + ret = put_user(vduse_features, (u64 __user *)argp); > > > > > > + break; > > > > > > + > > > > > > default: > > > > > > ret = -EINVAL; > > > > > > break; > > > > > > diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h > > > > > > index 27832d46084c..8898d9daa777 100644 > > > > > > --- a/include/uapi/linux/vduse.h > > > > > > +++ b/include/uapi/linux/vduse.h > > > > > > @@ -37,6 +37,7 @@ > > > > > > * @vq_align: the allocation alignment of virtqueue's metadata > > > > > > * @ngroups: number of vq groups that VDUSE device declares > > > > > > * @nas: number of address spaces that VDUSE device declares > > > > > > + * @vduse_features: VDUSE features > > > > > > * @reserved: for future use, needs to be initialized to zero > > > > > > * @config_size: the size of the configuration space > > > > > > * @config: the buffer of the configuration space > > > > > > @@ -53,7 +54,8 @@ struct vduse_dev_config { > > > > > > __u32 vq_align; > > > > > > __u32 ngroups; /* if VDUSE_API_VERSION >= 1 */ > > > > > > __u32 nas; /* if VDUSE_API_VERSION >= 1 */ > > > > > > - __u32 reserved[11]; > > > > > > + __u64 vduse_features; > > > > > > > > > > Nit: Should we document " /* if VDUSE_API_VERSION >= 2 */ > > > > > > > > > > But I have an open question, is this better to just introduce a > > > > > VDUSE_SET_FEATURES then we can do negotiation to avoid bumping API > > > > > versions? > > > > > > > > > > > > > How do you know if you can call VDUSE_GET_FEATURES and > > > > VDUSE_SET_FEATURES then? vduse_ioctl does not even return -ENOIOCMD > > > > but -EINVAL if you call the equivalent of VDUSE_GET_FEATURES on > > > > current Linux master. Or should the VDUSE instance assume that if the > > > > ioctl returns -EINVAL the kernel does not support them? > > > > > > If we go that way, yes. > > > > > > > I'm ok with doing the change. Kind of, I still think that increasing > > the API version is way cleaner, so no ioctl returns any error in > > regular initialization. But python's style "ask forgiveness not > > permission" is also ok for me. > > > > But I'm really missing the motivation of it. What's the problem with > > the increase of the version that you are trying to solve here? > > For example, if a feature is simply added via a new ioctl. I think we > don't need to bump the version. An example is the umem reg/dereg. > VDUSE starts from this choice so I think we should stick to that. > > I think a better time to bump the version are > > 1) an ioctl is expected to behave differently > 2) new ioctls are mutually exclusive with one(s) of the existing ioctls > 3) new initialization protocol > > etc. > > > > > Can we make a rule to know when to increase the version, and when it > > is not needed and it is ok for ioctls to just return -EINVAL or > > -ENOIOCTLCMD, so future series can hit the right behavior from earlier > > versions? > > See above. > > > > > From your comment I extract that we don't need to increase the API > > version number if we just add ioctls commands to the device, like > > probing if an ioctl exists. Also, we don't need to increase the > > version if we can tell if a member in vduse_dev_config is known to > > exist because a previous ioctl (or feature flag) succeeded. > > > > Am I missing something? > > I might be wrong, just some thoughts. Please correct me if I was wrong. > > Thanks > > > Not bumping version is nice as people can cherry pick features. OTOH if people are cherry picking features then userspace has to support all kind of combinations of features. So I think there can not be a simple rule, it boils down to this: if userspace can handle all failures easily - just add an ioctl. If userspace can not and would merely assert on success - update the version. -- MST