Skip to content

Commit a115b57

Browse files
mcoquelinmstsirkin
authored andcommitted
vduse: validate block features only with block devices
This patch is preliminary work to enable network device type support to VDUSE. As VIRTIO_BLK_F_CONFIG_WCE shares the same value as VIRTIO_NET_F_HOST_TSO4, we need to restrict its check to Virtio-blk device type. Acked-by: Jason Wang <[email protected]> Reviewed-by: Xie Yongji <[email protected]> Reviewed-by: Eugenio Pérez <[email protected]> Signed-off-by: Maxime Coquelin <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 5da7137 commit a115b57

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/vdpa/vdpa_user/vduse_dev.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,13 +1705,14 @@ static bool device_is_allowed(u32 device_id)
17051705
return false;
17061706
}
17071707

1708-
static bool features_is_valid(u64 features)
1708+
static bool features_is_valid(struct vduse_dev_config *config)
17091709
{
1710-
if (!(features & (1ULL << VIRTIO_F_ACCESS_PLATFORM)))
1710+
if (!(config->features & BIT_ULL(VIRTIO_F_ACCESS_PLATFORM)))
17111711
return false;
17121712

17131713
/* Now we only support read-only configuration space */
1714-
if (features & (1ULL << VIRTIO_BLK_F_CONFIG_WCE))
1714+
if ((config->device_id == VIRTIO_ID_BLOCK) &&
1715+
(config->features & BIT_ULL(VIRTIO_BLK_F_CONFIG_WCE)))
17151716
return false;
17161717

17171718
return true;
@@ -1738,7 +1739,7 @@ static bool vduse_validate_config(struct vduse_dev_config *config)
17381739
if (!device_is_allowed(config->device_id))
17391740
return false;
17401741

1741-
if (!features_is_valid(config->features))
1742+
if (!features_is_valid(config))
17421743
return false;
17431744

17441745
return true;

0 commit comments

Comments
 (0)