lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACGkMEv8b33EeMuHU03EGByumHRMhT3C6_Xeq_Lig=gjroofRg@mail.gmail.com>
Date: Wed, 18 Jun 2025 09:51:39 +0800
From: Jason Wang <jasowang@...hat.com>
To: Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org, Willem de Bruijn <willemdebruijn.kernel@...il.com>, 
	Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller" <davem@...emloft.net>, 
	Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, 
	"Michael S. Tsirkin" <mst@...hat.com>, Xuan Zhuo <xuanzhuo@...ux.alibaba.com>, 
	Eugenio Pérez <eperezma@...hat.com>, 
	Yuri Benditovich <yuri.benditovich@...nix.com>, Akihiko Odaki <akihiko.odaki@...nix.com>
Subject: Re: [PATCH v4 net-next 1/8] virtio: introduce extended features

On Wed, Jun 18, 2025 at 12:12 AM Paolo Abeni <pabeni@...hat.com> wrote:
>
> The virtio specifications allows for up to 128 bits for the
> device features. Soon we are going to use some of the 'extended'
> bits features (above 64) for the virtio_net driver.
>
> Introduce extended features as a fixed size array of u64. To minimize
> the diffstat allows legacy driver to access the low 64 bits via a
> transparent union.
>
> Introduce an extended get_extended_features configuration callback
> that devices supporting the extended features range must implement in
> place of the traditional one.
>
> Note that legacy and transport features don't need any change, as
> they are always in the low 64 bit range.
>
> Signed-off-by: Paolo Abeni <pabeni@...hat.com>
> ---
> v3 -> v4:
>   - moved bit sanity check in virtio_features_*
>   - replaced BUG_ON with WARN_ON_ONCE
>   - *_and_not -> _andnot
>   - short circuit features comparison
> v2 -> v3:
>   - uint128_t -> u64[2];
> v1 -> v2:
>   - let u64 VIRTIO_BIT() cope with higher bit values
>   - add .get_features128 instead of changing .get_features signature
> ---
>  drivers/virtio/virtio.c         | 43 +++++++++-------
>  drivers/virtio/virtio_debug.c   | 27 +++++-----
>  include/linux/virtio.h          |  5 +-
>  include/linux/virtio_config.h   | 41 +++++++--------
>  include/linux/virtio_features.h | 88 +++++++++++++++++++++++++++++++++
>  5 files changed, 151 insertions(+), 53 deletions(-)
>  create mode 100644 include/linux/virtio_features.h
>
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index 95d5d7993e5b..5c48788cdbec 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -53,7 +53,7 @@ static ssize_t features_show(struct device *_d,
>
>         /* We actually represent this as a bitstring, as it could be
>          * arbitrary length in future. */
> -       for (i = 0; i < sizeof(dev->features)*8; i++)
> +       for (i = 0; i < VIRTIO_FEATURES_MAX; i++)
>                 len += sysfs_emit_at(buf, len, "%c",
>                                __virtio_test_bit(dev, i) ? '1' : '0');
>         len += sysfs_emit_at(buf, len, "\n");
> @@ -272,22 +272,22 @@ static int virtio_dev_probe(struct device *_d)
>         int err, i;
>         struct virtio_device *dev = dev_to_virtio(_d);
>         struct virtio_driver *drv = drv_to_virtio(dev->dev.driver);
> -       u64 device_features;
> -       u64 driver_features;
> +       u64 device_features[VIRTIO_FEATURES_DWORDS];
> +       u64 driver_features[VIRTIO_FEATURES_DWORDS];
>         u64 driver_features_legacy;
>
>         /* We have a driver! */
>         virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER);
>
>         /* Figure out what features the device supports. */
> -       device_features = dev->config->get_features(dev);
> +       virtio_get_features(dev, device_features);
>
>         /* Figure out what features the driver supports. */
> -       driver_features = 0;
> +       virtio_features_zero(driver_features);
>         for (i = 0; i < drv->feature_table_size; i++) {
>                 unsigned int f = drv->feature_table[i];
> -               BUG_ON(f >= 64);
> -               driver_features |= (1ULL << f);
> +               if (!WARN_ON_ONCE(f >= VIRTIO_FEATURES_MAX))

Nit: Any reason why switching to use WARN_ON_ONCE()?

Other than this.

Acked-by: Jason Wang <jasowang@...hat.com>

Thanks


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ