From nobody Sat Feb 7 23:24:30 2026 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 D06962DA762 for ; Thu, 9 Oct 2025 11:24:15 +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=1760009059; cv=none; b=VNjBaQdxC5sAth5kEN4gFcfNpq7l6NnUowYAcg14C53wmXWDWBE1KoCJhJq5rrK8Aj4A+zYHWR7DA3XAG+UjeV1/hw1nB9ao8mTrygWxudRCsqw+u2yRIsUsHiJsaahjfX/dTnuuvSC53bpM4wFy6QjYhm/BbQzWbqy7FdWqKbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760009059; c=relaxed/simple; bh=Eq8QXdg73gutxXm7AKa3FAAyfzoJFtKs/7zU83MmOtw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=p6ETGpEVrWqFT+lMpxyW+X0XYcmwlwBI0updxFHwJVkA/gV58SqcoBFmhQ1lAwSP2MSA2KK3r/GkhqI0Ls7FL8fYEQc84G1Dv4iHGGg/shSDY1blZ23VEhcrwVHTfPkHCvKCyh/oebte5BUzD6fAB4TqFkrYjvwCiJVm56AmAzA= 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=BlisNdhQ; 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="BlisNdhQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760009054; 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: in-reply-to:in-reply-to:references:references; bh=74oMbyRbXmj4yyNwDNl68MN1PmvAi+6GhTMV//8rC/U=; b=BlisNdhQQmt/NHMXm6tYZa3Ma1g8/GJFyN3xj1KA1hopRhJ7lNUJBRP+UgmCNWNFif+vVb /zSGCC8iIUwWsDBSflsUmmCgkq4gDYUJZPg8+yHHiiWeakJKJPdwr1MpQpw5+xce7hu2h4 BME0xJb+7ykso2kW6JhhtSJn6KFXXHQ= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-369-vD13BuJ5P92EyTpIK3L9bg-1; Thu, 09 Oct 2025 07:24:13 -0400 X-MC-Unique: vD13BuJ5P92EyTpIK3L9bg-1 X-Mimecast-MFC-AGG-ID: vD13BuJ5P92EyTpIK3L9bg_1760009053 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-78e4e07aa39so24957996d6.0 for ; Thu, 09 Oct 2025 04:24:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760009053; x=1760613853; 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=74oMbyRbXmj4yyNwDNl68MN1PmvAi+6GhTMV//8rC/U=; b=VQ3abFvr1xIWv28AhzMcNPG8PTV8NeBfBd+DcpEClbHidq5EDN0qPKY6qT65d+njEJ lOpC8768A4kr+oOsqJGtDY7cd6YeXkdi6WpE6Y+jrzc51ijyLaSWk/qHWsa5G3Gj46pA +V81eQoeoGU+1zMeQy9A4VgV347Olb37t+g8I2hnFJRcLN4Wxtg0i1HyzG1v0+QwNv0C mSEfFOS0w7h2rk9e0eTsgdcVfF/pNu/z7LGhcRhgaByMzFin4VHcWVoN5i9w+j3mRHzu AJ7qVnSqY6Ab6ZvMfen7ruqNLmYmGGP/6ZfFUfjpQkShVYA2j7pnEIVl4bMt9eN+CLfG KrPQ== X-Gm-Message-State: AOJu0YxUkipZhlGXMxadvlvdkLtvtSVAe1yYfQicRD7cXyXqweB0DVde bW8ATxIPbfL8yV+i7HeKd9b1DELAbeuY4pAooQPbrNEay8ssiYSFDzkgioXorcBtjmV+yfaZ25A 3Q0ud4fA8FYwxcu/AF7mhhfk7OC3wLF1KGZ3ckaJ6VVDOMmTDZlxKKddUjbBq0mzscYS/+zNfmw 1aOZHz3pCbmt9MYwQUlvCgGLA0QN4GChPX1yzyHXECiXM= X-Gm-Gg: ASbGncvjSAfqF7E6C4QdPjjZiaECjdYEK0HDcaxM/d3dbkr3s6lgDpjVhlcWETdjD9O OTUgvw+nHmEo+l7ZwqmIDO+x1ZKExUC9ZmNQJiNKmrPXtSeciOm6xfl7sxePsow9oy4tGPSVYdg Eww3VzNsNON1ameINS/uCCcUeHnReXqYweHyDhkZR6MBlZjEHxjKQEKw1qfihcb4VRzYFZtGdsR HrhEHZY5RjdDhxoETEf8avvk9gwKopihcfaRL79DBiVFkAPq5Kdo8Ck8K5iX+ARAUsD+KZtBWk6 hoob6AAVTNj7pfKj3D5acfiX/OIa7m8J3NA= X-Received: by 2002:ad4:5d61:0:b0:78e:c5c7:1209 with SMTP id 6a1803df08f44-87b2ef56229mr83375586d6.56.1760009052948; Thu, 09 Oct 2025 04:24:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhwynXOsSUCuzIIOIZVdF8Z7wPRpFcney3vzw+6KLV7AofNaekm0l75bt/gqMykMI5XPPJow== X-Received: by 2002:ad4:5d61:0:b0:78e:c5c7:1209 with SMTP id 6a1803df08f44-87b2ef56229mr83375156d6.56.1760009052420; Thu, 09 Oct 2025 04:24:12 -0700 (PDT) Received: from redhat.com ([138.199.52.81]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-878bae60b67sm180829526d6.9.2025.10.09.04.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 04:24:12 -0700 (PDT) Date: Thu, 9 Oct 2025 07:24:08 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org, Paolo Abeni , Jason Wang , Eugenio =?utf-8?B?UMOpcmV6?= , Xuan Zhuo , Jonathan Corbet , kvm@vger.kernel.org, virtualization@lists.linux.dev, linux-doc@vger.kernel.org Subject: [PATCH 1/3] virtio: dwords->qwords Message-ID: <350d0abfaa2dcdb44678098f9119ba41166f375f.1760008798.git.mst@redhat.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A "word" is 16 bit. 64 bit integers like virtio uses are not dwords, they are actually qwords. Fix up macro names accordingly. Fixes: e7d4c1c5a546 ("virtio: introduce extended features") Cc: "Paolo Abeni" Signed-off-by: Michael S. Tsirkin --- drivers/vhost/net.c | 10 +++++----- drivers/virtio/virtio.c | 8 ++++---- drivers/virtio/virtio_debug.c | 2 +- include/linux/virtio.h | 2 +- include/linux/virtio_features.h | 24 ++++++++++++------------ include/linux/virtio_pci_modern.h | 8 ++++---- scripts/lib/kdoc/kdoc_parser.py | 2 +- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 35ded4330431..43d51fb1f8ea 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -69,7 +69,7 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy = TX;" =20 #define VHOST_DMA_IS_DONE(len) ((__force u32)(len) >=3D (__force u32)VHOST= _DMA_DONE_LEN) =20 -static const u64 vhost_net_features[VIRTIO_FEATURES_DWORDS] =3D { +static const u64 vhost_net_features[VIRTIO_FEATURES_QWORDS] =3D { VHOST_FEATURES | (1ULL << VHOST_NET_F_VIRTIO_NET_HDR) | (1ULL << VIRTIO_NET_F_MRG_RXBUF) | @@ -1720,7 +1720,7 @@ static long vhost_net_set_owner(struct vhost_net *n) static long vhost_net_ioctl(struct file *f, unsigned int ioctl, unsigned long arg) { - u64 all_features[VIRTIO_FEATURES_DWORDS]; + u64 all_features[VIRTIO_FEATURES_QWORDS]; struct vhost_net *n =3D f->private_data; void __user *argp =3D (void __user *)arg; u64 __user *featurep =3D argp; @@ -1752,7 +1752,7 @@ static long vhost_net_ioctl(struct file *f, unsigned = int ioctl, =20 /* Copy the net features, up to the user-provided buffer size */ argp +=3D sizeof(u64); - copied =3D min(count, VIRTIO_FEATURES_DWORDS); + copied =3D min(count, VIRTIO_FEATURES_QWORDS); if (copy_to_user(argp, vhost_net_features, copied * sizeof(u64))) return -EFAULT; @@ -1767,7 +1767,7 @@ static long vhost_net_ioctl(struct file *f, unsigned = int ioctl, =20 virtio_features_zero(all_features); argp +=3D sizeof(u64); - copied =3D min(count, VIRTIO_FEATURES_DWORDS); + copied =3D min(count, VIRTIO_FEATURES_QWORDS); if (copy_from_user(all_features, argp, copied * sizeof(u64))) return -EFAULT; =20 @@ -1783,7 +1783,7 @@ static long vhost_net_ioctl(struct file *f, unsigned = int ioctl, return -EOPNOTSUPP; } =20 - for (i =3D 0; i < VIRTIO_FEATURES_DWORDS; i++) + for (i =3D 0; i < VIRTIO_FEATURES_QWORDS; i++) if (all_features[i] & ~vhost_net_features[i]) return -EOPNOTSUPP; =20 diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index a09eb4d62f82..08f8357cdd39 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -272,8 +272,8 @@ static int virtio_dev_probe(struct device *_d) int err, i; struct virtio_device *dev =3D dev_to_virtio(_d); struct virtio_driver *drv =3D drv_to_virtio(dev->dev.driver); - u64 device_features[VIRTIO_FEATURES_DWORDS]; - u64 driver_features[VIRTIO_FEATURES_DWORDS]; + u64 device_features[VIRTIO_FEATURES_QWORDS]; + u64 driver_features[VIRTIO_FEATURES_QWORDS]; u64 driver_features_legacy; =20 /* We have a driver! */ @@ -303,7 +303,7 @@ static int virtio_dev_probe(struct device *_d) } =20 if (virtio_features_test_bit(device_features, VIRTIO_F_VERSION_1)) { - for (i =3D 0; i < VIRTIO_FEATURES_DWORDS; ++i) + for (i =3D 0; i < VIRTIO_FEATURES_QWORDS; ++i) dev->features_array[i] =3D driver_features[i] & device_features[i]; } else { @@ -325,7 +325,7 @@ static int virtio_dev_probe(struct device *_d) goto err; =20 if (drv->validate) { - u64 features[VIRTIO_FEATURES_DWORDS]; + u64 features[VIRTIO_FEATURES_QWORDS]; =20 virtio_features_copy(features, dev->features_array); err =3D drv->validate(dev); diff --git a/drivers/virtio/virtio_debug.c b/drivers/virtio/virtio_debug.c index d58713ddf2e5..40f6b815caef 100644 --- a/drivers/virtio/virtio_debug.c +++ b/drivers/virtio/virtio_debug.c @@ -8,7 +8,7 @@ static struct dentry *virtio_debugfs_dir; =20 static int virtio_debug_device_features_show(struct seq_file *s, void *dat= a) { - u64 device_features[VIRTIO_FEATURES_DWORDS]; + u64 device_features[VIRTIO_FEATURES_QWORDS]; struct virtio_device *dev =3D s->private; unsigned int i; =20 diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 96c66126c074..5b258451dc0e 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -177,7 +177,7 @@ struct virtio_device { union virtio_map vmap; #ifdef CONFIG_VIRTIO_DEBUG struct dentry *debugfs_dir; - u64 debugfs_filter_features[VIRTIO_FEATURES_DWORDS]; + u64 debugfs_filter_features[VIRTIO_FEATURES_QWORDS]; #endif }; =20 diff --git a/include/linux/virtio_features.h b/include/linux/virtio_feature= s.h index f748f2f87de8..bf41d8ec50ef 100644 --- a/include/linux/virtio_features.h +++ b/include/linux/virtio_features.h @@ -4,15 +4,15 @@ =20 #include =20 -#define VIRTIO_FEATURES_DWORDS 2 -#define VIRTIO_FEATURES_MAX (VIRTIO_FEATURES_DWORDS * 64) -#define VIRTIO_FEATURES_WORDS (VIRTIO_FEATURES_DWORDS * 2) +#define VIRTIO_FEATURES_QWORDS 2 +#define VIRTIO_FEATURES_MAX (VIRTIO_FEATURES_QWORDS * 64) +#define VIRTIO_FEATURES_WORDS (VIRTIO_FEATURES_QWORDS * 2) #define VIRTIO_BIT(b) BIT_ULL((b) & 0x3f) -#define VIRTIO_DWORD(b) ((b) >> 6) +#define VIRTIO_QWORD(b) ((b) >> 6) #define VIRTIO_DECLARE_FEATURES(name) \ union { \ u64 name; \ - u64 name##_array[VIRTIO_FEATURES_DWORDS];\ + u64 name##_array[VIRTIO_FEATURES_QWORDS];\ } =20 static inline bool virtio_features_chk_bit(unsigned int bit) @@ -34,26 +34,26 @@ static inline bool virtio_features_test_bit(const u64 *= features, unsigned int bit) { return virtio_features_chk_bit(bit) && - !!(features[VIRTIO_DWORD(bit)] & VIRTIO_BIT(bit)); + !!(features[VIRTIO_QWORD(bit)] & VIRTIO_BIT(bit)); } =20 static inline void virtio_features_set_bit(u64 *features, unsigned int bit) { if (virtio_features_chk_bit(bit)) - features[VIRTIO_DWORD(bit)] |=3D VIRTIO_BIT(bit); + features[VIRTIO_QWORD(bit)] |=3D VIRTIO_BIT(bit); } =20 static inline void virtio_features_clear_bit(u64 *features, unsigned int bit) { if (virtio_features_chk_bit(bit)) - features[VIRTIO_DWORD(bit)] &=3D ~VIRTIO_BIT(bit); + features[VIRTIO_QWORD(bit)] &=3D ~VIRTIO_BIT(bit); } =20 static inline void virtio_features_zero(u64 *features) { - memset(features, 0, sizeof(features[0]) * VIRTIO_FEATURES_DWORDS); + memset(features, 0, sizeof(features[0]) * VIRTIO_FEATURES_QWORDS); } =20 static inline void virtio_features_from_u64(u64 *features, u64 from) @@ -66,7 +66,7 @@ static inline bool virtio_features_equal(const u64 *f1, c= onst u64 *f2) { int i; =20 - for (i =3D 0; i < VIRTIO_FEATURES_DWORDS; ++i) + for (i =3D 0; i < VIRTIO_FEATURES_QWORDS; ++i) if (f1[i] !=3D f2[i]) return false; return true; @@ -74,14 +74,14 @@ static inline bool virtio_features_equal(const u64 *f1,= const u64 *f2) =20 static inline void virtio_features_copy(u64 *to, const u64 *from) { - memcpy(to, from, sizeof(to[0]) * VIRTIO_FEATURES_DWORDS); + memcpy(to, from, sizeof(to[0]) * VIRTIO_FEATURES_QWORDS); } =20 static inline void virtio_features_andnot(u64 *to, const u64 *f1, const u6= 4 *f2) { int i; =20 - for (i =3D 0; i < VIRTIO_FEATURES_DWORDS; i++) + for (i =3D 0; i < VIRTIO_FEATURES_QWORDS; i++) to[i] =3D f1[i] & ~f2[i]; } =20 diff --git a/include/linux/virtio_pci_modern.h b/include/linux/virtio_pci_m= odern.h index 48bc12d1045b..15818bd04716 100644 --- a/include/linux/virtio_pci_modern.h +++ b/include/linux/virtio_pci_modern.h @@ -107,7 +107,7 @@ void vp_modern_set_extended_features(struct virtio_pci_= modern_device *mdev, static inline u64 vp_modern_get_features(struct virtio_pci_modern_device *mdev) { - u64 features_array[VIRTIO_FEATURES_DWORDS]; + u64 features_array[VIRTIO_FEATURES_QWORDS]; =20 vp_modern_get_extended_features(mdev, features_array); return features_array[0]; @@ -116,11 +116,11 @@ vp_modern_get_features(struct virtio_pci_modern_devic= e *mdev) static inline u64 vp_modern_get_driver_features(struct virtio_pci_modern_device *mdev) { - u64 features_array[VIRTIO_FEATURES_DWORDS]; + u64 features_array[VIRTIO_FEATURES_QWORDS]; int i; =20 vp_modern_get_driver_extended_features(mdev, features_array); - for (i =3D 1; i < VIRTIO_FEATURES_DWORDS; ++i) + for (i =3D 1; i < VIRTIO_FEATURES_QWORDS; ++i) WARN_ON_ONCE(features_array[i]); return features_array[0]; } @@ -128,7 +128,7 @@ vp_modern_get_driver_features(struct virtio_pci_modern_= device *mdev) static inline void vp_modern_set_features(struct virtio_pci_modern_device *mdev, u64 features) { - u64 features_array[VIRTIO_FEATURES_DWORDS]; + u64 features_array[VIRTIO_FEATURES_QWORDS]; =20 virtio_features_from_u64(features_array, features); vp_modern_set_extended_features(mdev, features_array); diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser= .py index fe730099eca8..5d629aebc8f0 100644 --- a/scripts/lib/kdoc/kdoc_parser.py +++ b/scripts/lib/kdoc/kdoc_parser.py @@ -638,7 +638,7 @@ class KernelDoc: (KernRe(r'(?:__)?DECLARE_FLEX_ARRAY\s*\(' + args_pattern + r',= \s*' + args_pattern + r'\)', re.S), r'\1 \2[]'), (KernRe(r'DEFINE_DMA_UNMAP_ADDR\s*\(' + args_pattern + r'\)', = re.S), r'dma_addr_t \1'), (KernRe(r'DEFINE_DMA_UNMAP_LEN\s*\(' + args_pattern + r'\)', r= e.S), r'__u32 \1'), - (KernRe(r'VIRTIO_DECLARE_FEATURES\s*\(' + args_pattern + r'\)'= , re.S), r'u64 \1; u64 \1_array[VIRTIO_FEATURES_DWORDS]'), + (KernRe(r'VIRTIO_DECLARE_FEATURES\s*\(' + args_pattern + r'\)'= , re.S), r'u64 \1; u64 \1_array[VIRTIO_FEATURES_QWORDS]'), ] =20 # Regexes here are guaranteed to have the end limiter matching --=20 MST From nobody Sat Feb 7 23:24:30 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 83A582E090B for ; Thu, 9 Oct 2025 11:24:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760009061; cv=none; b=a6FZ7Ea/NsVDzR00LjWhx3/a2D7esaY8i29zHm5MR1DLtjIkGS9OTLx6iSXx1cuLD7cYccFNs5McW1HjzrBqzeQiMIahe7EEK4qtPpi11CD9J5QVShXjT9ka+ib6WXuZNQcGPnfj6n5xsBxbOcjAy3hbJRxurXsgjS8pIZEfMQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760009061; c=relaxed/simple; bh=79q/stfmKaMpC4fkL/3uhckYgC59HswnU0O9ncOSM7k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nLIaPLtdcUlel/KVpvxFkrBL7Ud7etaU5Tv7JWQaTk6XqqiPOqBzpBw/0yZicpPzSExNY2quhZnaxld0faGXQkCNqGlF5Z03ySbUE8TE6EPSbTNzjJ/lDfIFgdkFVccC5IhWyaEkSk3zbd9rVO28tJs5iY1S+TBo5DOnoZCygkk= 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=gH07n6OS; arc=none smtp.client-ip=170.10.133.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="gH07n6OS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760009058; 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: in-reply-to:in-reply-to:references:references; bh=kmAH8BxjdJp2Pz1OPEFZHQJ5FGdMMYsLliyoe1z8SzI=; b=gH07n6OSziZ1nIrglc1f55tINC/Im1TOXJ3Fi0nEmM7K4ts0ZlasE/sawszn3X1vWwGkYu tXA/RmF9KQrSLKd49f+R/YT5lYjh2TYDiHY9LlAuPUEXFjYeSA91Z6l0UooF1kJFq1D2W9 SYSmfJ6uIxQ7it6WxaBtLeWyI+kDC2U= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-2ezJTqfsOMyytwDMshCbFQ-1; Thu, 09 Oct 2025 07:24:17 -0400 X-MC-Unique: 2ezJTqfsOMyytwDMshCbFQ-1 X-Mimecast-MFC-AGG-ID: 2ezJTqfsOMyytwDMshCbFQ_1760009057 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4d77ae03937so32680671cf.3 for ; Thu, 09 Oct 2025 04:24:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760009057; x=1760613857; 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=kmAH8BxjdJp2Pz1OPEFZHQJ5FGdMMYsLliyoe1z8SzI=; b=KNVW5DSkJn/DHxe6sb18df0NYksbsdcoUNS1JIp33UScs4RYK/nZFDY2EAgBwuWwfY EFZ+1BxGzFzlEXGQFeF4Lgn8nXbMk+qny972DrsY9tciCx7t6cJM+0zbh+rif+HFBxx/ FKCQfIMvfRBwD30YzEBbTW+F+bfzCWWr9TaruZmfyQ5oTK3Sz29+TaqtLHR3CeFyMVUx G+5Iu/TpicR2hAMM2gKbSDOTNkAZ4lHGrKFIanWc3r7id94MnnuPXw817WiZ3DvgIsr7 Cg9myZctEba5UZXaGms6ShLttIA8sgnAmLYhdF1vLah5zMqouOF4+IqON0vkdE7BupgH uifg== X-Gm-Message-State: AOJu0Yzw8/3NqJHQ7hvLAhF/k3n36JXXKj8DI1T8zivxeMV0ZAfUYghv WEjte+XK6m6ia5Peb3gpK4dVtrtWDpgNhtI/bqLd2l67zHlPyEGmrsmLkeub5wXr7T8aPGAw+fo 5NXtb8g9maLcEBi9FEaIzIHBdrLDh7IrFNojHBlr4cniUmpBMub5TflCmawL1Dn19uM8LuE/JxQ bVBulQ5LEB6JnbcHuAjrKFKfOP/q4X9l0Eh74Gb4SrKbM= X-Gm-Gg: ASbGncvJzqbulEi/0KhX0Vnu8CevKQAQ9job1vE31FjlLCjMX2C+wjgzlSgISelAwSL ASSZW+f9kbBClyLivqpUBOw3rNQOvSIuSqXgUm++AubvMv/x0TBBshJivnxdGOTxmCMRGs1Dwwb gmvCiWdG7ZgisfUVi25RdnO2vcoJuNBrLGx3GAVzDupMAoU7hM2ows1JKLQHU8emnACOkQHxjes GZDlU3fBKhktVgVZcPHl7/pxHXehrusd00ZWajg6LeQhcB7vMNAkllGrA9pcXKIPSwASQPc5ijG AQ70tRfzEH5g9HtBYf8IR+20lOoe3dBks+g= X-Received: by 2002:ac8:5712:0:b0:4b7:9ddb:abbd with SMTP id d75a77b69052e-4e6ead147abmr98992331cf.27.1760009056662; Thu, 09 Oct 2025 04:24:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFy1nScydZf2w9Y/RF1KZ/toaL4XHDC73RNqYYmsC+Y4XlTLrKctFUYrWVrZX9qDmWKcvcV1Q== X-Received: by 2002:ac8:5712:0:b0:4b7:9ddb:abbd with SMTP id d75a77b69052e-4e6ead147abmr98991861cf.27.1760009056130; Thu, 09 Oct 2025 04:24:16 -0700 (PDT) Received: from redhat.com ([138.199.52.81]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4e55cfd4334sm184991021cf.38.2025.10.09.04.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 04:24:15 -0700 (PDT) Date: Thu, 9 Oct 2025 07:24:12 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org, Paolo Abeni , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= , virtualization@lists.linux.dev Subject: [PATCH 2/3] virtio: words->dwords Message-ID: <46f0fa4570b01988f9fe79b690cbeb93dcd52736.1760008798.git.mst@redhat.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A "word" is 16 bit. 32 bit integers like virtio pci uses are not words, they are actually dwords. Fix up the macro name accordingly. Fixes: e7d4c1c5a546 ("virtio: introduce extended features") Cc: "Paolo Abeni" Signed-off-by: Michael S. Tsirkin --- drivers/virtio/virtio_pci_modern_dev.c | 6 +++--- include/linux/virtio_features.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio= _pci_modern_dev.c index 9e503b7a58d8..4b619cc91bc7 100644 --- a/drivers/virtio/virtio_pci_modern_dev.c +++ b/drivers/virtio/virtio_pci_modern_dev.c @@ -401,7 +401,7 @@ void vp_modern_get_extended_features(struct virtio_pci_= modern_device *mdev, int i; =20 virtio_features_zero(features); - for (i =3D 0; i < VIRTIO_FEATURES_WORDS; i++) { + for (i =3D 0; i < VIRTIO_FEATURES_DWORDS; i++) { u64 cur; =20 vp_iowrite32(i, &cfg->device_feature_select); @@ -427,7 +427,7 @@ vp_modern_get_driver_extended_features(struct virtio_pc= i_modern_device *mdev, int i; =20 virtio_features_zero(features); - for (i =3D 0; i < VIRTIO_FEATURES_WORDS; i++) { + for (i =3D 0; i < VIRTIO_FEATURES_DWORDS; i++) { u64 cur; =20 vp_iowrite32(i, &cfg->guest_feature_select); @@ -448,7 +448,7 @@ void vp_modern_set_extended_features(struct virtio_pci_= modern_device *mdev, struct virtio_pci_common_cfg __iomem *cfg =3D mdev->common; int i; =20 - for (i =3D 0; i < VIRTIO_FEATURES_WORDS; i++) { + for (i =3D 0; i < VIRTIO_FEATURES_DWORDS; i++) { u32 cur =3D features[i >> 1] >> (32 * (i & 1)); =20 vp_iowrite32(i, &cfg->guest_feature_select); diff --git a/include/linux/virtio_features.h b/include/linux/virtio_feature= s.h index bf41d8ec50ef..f41acb035af9 100644 --- a/include/linux/virtio_features.h +++ b/include/linux/virtio_features.h @@ -6,7 +6,7 @@ =20 #define VIRTIO_FEATURES_QWORDS 2 #define VIRTIO_FEATURES_MAX (VIRTIO_FEATURES_QWORDS * 64) -#define VIRTIO_FEATURES_WORDS (VIRTIO_FEATURES_QWORDS * 2) +#define VIRTIO_FEATURES_DWORDS (VIRTIO_FEATURES_QWORDS * 2) #define VIRTIO_BIT(b) BIT_ULL((b) & 0x3f) #define VIRTIO_QWORD(b) ((b) >> 6) #define VIRTIO_DECLARE_FEATURES(name) \ --=20 MST From nobody Sat Feb 7 23:24:30 2026 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 8CD702E265A for ; Thu, 9 Oct 2025 11:24:23 +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=1760009066; cv=none; b=eMm5o9nfRg8zfGoyCuBRXaduTnjTD90F/BRxKHBlobZo9yPbsqJhB5dwLnYi7r6+lsWO4pRjOe+MrveBUYaIo97xpiixSJ1Pc/FXgEYaV05H3Es+WG0h7g2OEN+RHhN/67mCUTTVjy0j/syPZGXsLlKu+mOAucL8B6FyaToowcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760009066; c=relaxed/simple; bh=35UYEAy9Siw0O4CbsRPOR1KpEIW1hIqotirWcRQXYGs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bN7nAtmmrd8vQTHrcjEGPIO0/PVL6df21/kP0ePJBQLni4AdR19U5kH7aQ/EEeL7JNng2m0kzQITfGPgllNnuIHTcnM/O9mT4j52+brzd3brRdmrUx2IQ2uTYloqayzbVFq2WaSTTegmDa1k9SlrxPQihfyq+RhCjOD4nIe/mJ4= 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=HbgLN13p; 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="HbgLN13p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760009062; 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: in-reply-to:in-reply-to:references:references; bh=S+cs/cFEiq3598A0wbNjyWy5VUcCWcxIxlRvjHMyPY8=; b=HbgLN13pHSo1bIaTqcPt7wfzKEHYNIgS6HVeFIyfkuuxlvqyXtliDOReoXdZWSupm3g+tt 8L5XsWOP6vvzdQw5G5MRAt8ECkcKVHo0oXA2Yhu9GdxUmFjGJHLVuh9iEpf9QG4F+Ks4V0 WY9RtGG1t3yyqP9fZ8BoijcVy/HbZVM= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-563-CChhzJ4eP0atHBtB9nrKeg-1; Thu, 09 Oct 2025 07:24:21 -0400 X-MC-Unique: CChhzJ4eP0atHBtB9nrKeg-1 X-Mimecast-MFC-AGG-ID: CChhzJ4eP0atHBtB9nrKeg_1760009061 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-78e831e5a42so36834286d6.2 for ; Thu, 09 Oct 2025 04:24:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760009061; x=1760613861; 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=S+cs/cFEiq3598A0wbNjyWy5VUcCWcxIxlRvjHMyPY8=; b=T7W8LU7V1CtAandARAIhcYd0jokwiobOIyADUvw3kDT1U9egoII5zHyAZ91RuxzF6v ovPMNGsdkD1a0hyJqD4jr626FU7/fu9m/KqenZhNPl1EnTe2nCmXe+i5GkPeSz4+hd/N qAQv52VHAqyJUlfh5IJ7R28l6UlIKYxu1v3Whk4Ebim2kod5GPU1voqme1vUmiLyl9rb 0Fq75G/7UqPhQhB/1RdQyfgUnPuY3+NF8JSSVqdlPFB8pwN2juJKU1kKpiQwwk6sr/4s m2zFn4hMCmKgU2Ta2AAvt8bQrIeXWD9az0f9ku02CI04+iWvLQo5MhQ1eUd4VvYl7zQI PuzA== X-Gm-Message-State: AOJu0YzIoBzch0TcDVO8NdajjHiyrSSKcYPJ2OetQ+Do5LRP1Hv29bOi 4DnuQBFt6H88vohjc7L3NP4jxv67qSDhKpgTMKt3ZrkwgQv+J62MKlhsV5oTz582ejOYvyJO5xP 0KL4tSKoB4dwy7NwH+Lca0R51P0TpAHUqJCz4SWyC/+yo5aN1KGZlNbASua/pAcDjuDDjDjJE6j Glr+lbrci0EOffDdmzG0cUH45hP0TPBXPtYQBKmQ2sTZM= X-Gm-Gg: ASbGncvQsUU09tvw+bi9pqKBfhtVI4Bakpz1sCLunUfBDsxpm/UmGNCFbtz1H4Clqvp +azaob0Ti0uogbwt3G+7sQl19vKgjWdF4tfiWoE+xiyUgpeWmKsm9qmfQADkBxGmmzGpZ5bg+TA 5UV+LKzAFeRfsCinHz0i6P7Y8dKLpJvEhJkMrmhS0IGJFDlx/3NHvoqlK6Ysiv6two+XNFjRPHl Tfk4v74OoiON5nD+PDIgI5LTXpy/lf5alD6I5KyiCU6BVtFcIkIAXZhTmh4YmOoh4ZsyQMJge0e iPdKOBBvzTLYFHrsUS6yb+GzgDl5IOMc+i0= X-Received: by 2002:ad4:4ee3:0:b0:802:3b85:ee18 with SMTP id 6a1803df08f44-87b2dbf70c7mr98353056d6.36.1760009060779; Thu, 09 Oct 2025 04:24:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvx4dSk41JvbEZka6APS8zgOi8sdCQFv4O7dgaejzBvc7AARV8O85qCp/D4IeK5PK1183PNw== X-Received: by 2002:ad4:4ee3:0:b0:802:3b85:ee18 with SMTP id 6a1803df08f44-87b2dbf70c7mr98352316d6.36.1760009060013; Thu, 09 Oct 2025 04:24:20 -0700 (PDT) Received: from redhat.com ([138.199.52.81]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-878bbb1cf52sm181311206d6.28.2025.10.09.04.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 04:24:19 -0700 (PDT) Date: Thu, 9 Oct 2025 07:24:16 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org, Paolo Abeni , Jason Wang , Eugenio =?utf-8?B?UMOpcmV6?= , Xuan Zhuo , kvm@vger.kernel.org, virtualization@lists.linux.dev Subject: [PATCH 3/3] vhost: use checked versions of VIRTIO_BIT Message-ID: <6629538adfd821c8626ab8b9def49c23781e6775.1760008798.git.mst@redhat.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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" Signed-off-by: Michael S. Tsirkin --- 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_QWORD= S] =3D { (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), }; =20 enum { diff --git a/include/linux/virtio_features.h b/include/linux/virtio_feature= s.h index f41acb035af9..466f7d8ed5ba 100644 --- a/include/linux/virtio_features.h +++ b/include/linux/virtio_features.h @@ -9,6 +9,15 @@ #define VIRTIO_FEATURES_DWORDS (VIRTIO_FEATURES_QWORDS * 2) #define VIRTIO_BIT(b) BIT_ULL((b) & 0x3f) #define VIRTIO_QWORD(b) ((b) >> 6) + +/* Get a given feature bit in a given qword. */ +#define VIRTIO_BIT_QWORD(bit, qword) \ + (BUILD_BUG_ON_ZERO(const_true(VIRTIO_QWORD(bit) !=3D (qword))) + \ + BIT_ULL((bit) - 64 * (qword))) + +#define VIRTIO_BIT_LO(b) VIRTIO_BIT_QWORD(b, 0) +#define VIRTIO_BIT_HI(b) VIRTIO_BIT_QWORD(b, 1) + #define VIRTIO_DECLARE_FEATURES(name) \ union { \ u64 name; \ --=20 MST