From: Andrew Lunn <andrew@lunn.ch>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
"Paolo Abeni" <pabeni@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
kvm@vger.kernel.org, virtualization@lists.linux.dev
Subject: Re: [PATCH 3/3] vhost: use checked versions of VIRTIO_BIT
Date: Thu, 9 Oct 2025 14:47:53 +0200 [thread overview]
Message-ID: <d4fcd2d8-ac84-4d9f-a47a-fecc50e18e20@lunn.ch> (raw)
In-Reply-To: <6629538adfd821c8626ab8b9def49c23781e6775.1760008798.git.mst@redhat.com>
On Thu, Oct 09, 2025 at 07:24:16AM -0400, Michael S. Tsirkin wrote:
> This adds compile-time checked versions of VIRTIO_BIT that set bits in
> low and high qword, respectively. Will prevent confusion when people
> set bits in the wrong qword.
>
> Cc: "Paolo Abeni" <pabeni@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/vhost/net.c | 4 ++--
> include/linux/virtio_features.h | 9 +++++++++
> 2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index 43d51fb1f8ea..8b98e1a8baaa 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -76,8 +76,8 @@ static const u64 vhost_net_features[VIRTIO_FEATURES_QWORDS] = {
> (1ULL << VIRTIO_F_ACCESS_PLATFORM) |
> (1ULL << VIRTIO_F_RING_RESET) |
> (1ULL << VIRTIO_F_IN_ORDER),
> - VIRTIO_BIT(VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) |
> - VIRTIO_BIT(VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO),
> + VIRTIO_BIT_HI(VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) |
> + VIRTIO_BIT_HI(VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO),
How any bits in vhost_net_features are currently in use? How likely is
it to go from 2x 64bit words to 3x 64 bit words? Rather than _LO, _HI,
would _1ST, _2ND be better leaving it open for _3RD?
I would also be tempted to rename these macros to include _LO_ and
_HI_ in them. VIRTIO_BIT_HI(VIRTIO_LO_F_IN_ORDER) is more likely to be
spotted as wrong this way.
An alternative would be to convert to a linux bitmap, which is
arbitrary length so you just use bit number and leave the
implementation to map that to the correct offset in the underlying
data structure.
Andrew
next prev parent reply other threads:[~2025-10-09 12:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 11:24 [PATCH 0/3] feature related cleanups Michael S. Tsirkin
2025-10-09 11:24 ` [PATCH 1/3] virtio: dwords->qwords Michael S. Tsirkin
2025-10-09 12:31 ` Andrew Lunn
2025-10-09 13:37 ` Michael S. Tsirkin
2025-10-11 17:25 ` Andrew Lunn
2025-10-11 17:42 ` Michael S. Tsirkin
2025-10-11 18:52 ` Andrew Lunn
2025-10-12 7:26 ` Michael S. Tsirkin
2025-10-12 14:39 ` Andrew Lunn
2025-10-12 19:17 ` Michael S. Tsirkin
2025-10-09 11:24 ` [PATCH 2/3] virtio: words->dwords Michael S. Tsirkin
2025-10-09 11:24 ` [PATCH 3/3] vhost: use checked versions of VIRTIO_BIT Michael S. Tsirkin
2025-10-09 12:47 ` Andrew Lunn [this message]
2025-10-09 12:54 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d4fcd2d8-ac84-4d9f-a47a-fecc50e18e20@lunn.ch \
--to=andrew@lunn.ch \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®