From: Yufeng Wang <[email protected]>
Hi Eugenio,
This series follows up on your review of the vhost/net GET_FEATURES_ARRAY
fix [1], where you asked for a switch in tools/virtio/vhost_net_test.c to
exercise VHOST_GET_FEATURES_ARRAY and VHOST_SET_FEATURES_ARRAY. The fix
itself is unchanged from the v2 you Acked [2] and is not included here.
Patch 3 adds the requested "--features-array" switch. When it is given,
the test programs features via VHOST_SET_FEATURES_ARRAY and then verifies
VHOST_GET_FEATURES_ARRAY by issuing it twice with the same count,
comfortably above VIRTIO_FEATURES_U64S: once into a zero-initialized
buffer and once into a buffer pre-filled with a non-zero sentinel. The
two reads must match on every entry: the kernel fills the prefix with the
device features and clear_user()s the trailing entries it did not fill.
A clear_user() with the wrong start address clobbers the prefix instead
of the tail; the sentinel buffer then keeps non-zero data in the trailing
entries and disagrees with the clean read. Using a count comfortably
above VIRTIO_FEATURES_U64S (rather than matching it exactly) keeps the
test correct as the kernel's feature-word count grows, so this is exactly
the path that [1] fixes and the test doubles as a regression test for it.
Patches 1-2 are build prerequisites needed for the harness to compile
against current headers: a device-id compat header (since
mod_devicetable.h was split into include/linux/device-id/) and an
__must_be_array stub (needed by struct_size(), which the new test uses).
With them, `make -C tools/virtio test` builds virtio_test, vringh_test
and vhost_net_test cleanly.
Patch 3 depends on [1] for its GET path to pass. Tested on x86_64:
- without [1]: ./vhost_net_test --features-array aborts in
verify_get_features_array() (the GET clear_user bug);
- with [1]: both ./vhost_net_test and ./vhost_net_test --features-array
complete RX/TX with started == completed == 0x100000.
[1] https://lore.kernel.org/all/[email protected]/
[2]
https://lore.kernel.org/all/cajaqywfp7j5_pvop0jihuaq8appgnojds3ob-qk7ribpz_d...@mail.gmail.com/
Yufeng Wang (3):
tools/virtio: add device-id compat header for virtio
tools/virtio: add __must_be_array stub
tools/virtio: add --features-array switch
tools/virtio/linux/compiler.h | 1 +
tools/virtio/linux/device-id/virtio.h | 1 +
tools/virtio/vhost_net_test.c | 70 +++++++++++++++++++++++++--
3 files changed, 68 insertions(+), 4 deletions(-)
create mode 100644 tools/virtio/linux/device-id/virtio.h
--
2.34.1
No virus found
Checked by Hillstone Network AntiVirus