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: <29837ab4-3682-4f2f-b8f7-7d367195525d@redhat.com>
Date: Thu, 12 Jun 2025 11:05:14 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: Jason Wang <jasowang@...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 RFC v3 1/8] virtio: introduce extended features

On 6/12/25 2:50 AM, Jason Wang wrote:
> On Fri, Jun 6, 2025 at 7:46 PM Paolo Abeni <pabeni@...hat.com> wrote:
>> @@ -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);
>> +               BUG_ON(f >= VIRTIO_FEATURES_MAX);
>> +               virtio_features_set_bit(driver_features, f);
> 
> Instead of doing BUG_ON here, could we just stop at 128 bits?

I think it would be nice to have a sanity check to ensure the driver
code is sync with the core. What about a WARN_ON_ONCE?

>> @@ -121,6 +124,8 @@ struct virtio_config_ops {
>>         void (*del_vqs)(struct virtio_device *);
>>         void (*synchronize_cbs)(struct virtio_device *);
>>         u64 (*get_features)(struct virtio_device *vdev);
>> +       void (*get_extended_features)(struct virtio_device *vdev,
>> +                                     u64 *features);
> 
> I think it would be better to add a size to simplify the future extension.

Note that the array size is implied by the virtio-features definition.
Future extensions will be obtained by increasing the
VIRTIO_FEATURES_DWORD define, with no other change to the code.

I think a length here would be redundant.

>> +static inline bool virtio_features_equal(const u64 *f1, const u64 *f2)
>> +{
>> +       u64 diff = 0;
>> +       int i;
>> +
>> +       for (i = 0; i < VIRTIO_FEATURES_DWORDS; ++i)
>> +               diff |= f1[i] ^ f2[i];
>> +       return !!diff;
> 
> Nit: we can return false early here.

I can do in in the next revision.

[same disclaimer here: I'm traveling for the whole week, my replies will
be rare and delayed]

/P


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ