Re: [PATCH RFC v3 2/8] virtio_pci_modern: allow configuring extended features
From: Paolo Abeni <pabeni@redhat.com>
Date: 2025-06-12 09:34:54
On 6/12/25 2:57 AM, Jason Wang wrote:
On Fri, Jun 6, 2025 at 7:46 PM Paolo Abeni [off-list ref] wrote:quoted
-u64 vp_modern_get_features(struct virtio_pci_modern_device *mdev); -u64 vp_modern_get_driver_features(struct virtio_pci_modern_device *mdev); -void vp_modern_set_features(struct virtio_pci_modern_device *mdev, - u64 features); +void +vp_modern_get_driver_extended_features(struct virtio_pci_modern_device *mdev, + u64 *features); +void vp_modern_get_extended_features(struct virtio_pci_modern_device *mdev, + u64 *features); +void vp_modern_set_extended_features(struct virtio_pci_modern_device *mdev, + const u64 *features); + +static inline u64 +vp_modern_get_features(struct virtio_pci_modern_device *mdev) +{ + u64 features_array[VIRTIO_FEATURES_DWORDS]; + int i; + + vp_modern_get_extended_features(mdev, features_array); + for (i = 1; i < VIRTIO_FEATURES_DWORDS; ++i) + WARN_ON_ONCE(features_array[i]);It looks to me it's sufficient and safe to just return featuers_array[0] here. Or maybe we need some comment to explain why we need WARN here.
vp_modern_get_extended_features() can return a 'features' array including extended features. Callers of vp_modern_get_features() can deal with/expect features to be present only in the lower 64 bit range. This check is intended to catch early device bug/inconsistencies, but I'm unsure if e.g. syzkaller could hit with some fancy setup. I can drop the check in the next revision. /P