mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
Patch series "tools: Fix tools/virtio test build", v2. This series fixes build failures hit by: make -C tools/virtio test Patch 1 adds tools/virtio compatibility definitions needed by current virtio headers when building the tools/virtio tests. Patch 2 makes tools/include/linux/overflow.h include stdint.h for SIZE_MAX, which is used by its size helper functions. With the series applied, make -C tools/virtio test builds virtio_test, vringh_test and vhost_net_test successfully. Tested on x86_64 and arm64 with: make -C tools/virtio clean make -C tools/virtio test This patch (of 2): vhost_net_test builds virtio_ring.c in userspace. Recent virtio headers pull in helper headers that are not provided by the tools/virtio compatibility layer, including asm/percpu_types.h, linux/completion.h, linux/mod_devicetable.h and linux/virtio_features.h. Add the missing compat definitions and the DMA attribute used by the current virtio ring code. Link: https://lore.kernel.org/20260629022124.131894-1-chenyichong@uniontech.com Link: https://lore.kernel.org/20260629022124.131894-2-chenyichong@uniontech.com Signed-off-by: Yichong Chen <chenyichong@uniontech.com> Acked-by: Eugenio Pérez <eperezma@redhat.com> Cc: chenyichong <chenyichong@uniontech.com> Cc: Jason Wang <jasowang@redhat.com> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
80 lines
1.8 KiB
C
80 lines
1.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_VIRTIO_FEATURES_H
|
|
#define _LINUX_VIRTIO_FEATURES_H
|
|
|
|
#include <linux/bug.h>
|
|
#include <linux/string.h>
|
|
#include <linux/types.h>
|
|
|
|
#define VIRTIO_FEATURES_U64S 2
|
|
#define VIRTIO_FEATURES_BITS (VIRTIO_FEATURES_U64S * 64)
|
|
|
|
#define VIRTIO_BIT(b) (1ULL << ((b) & 0x3f))
|
|
#define VIRTIO_U64(b) ((b) >> 6)
|
|
|
|
#define VIRTIO_DECLARE_FEATURES(name) \
|
|
union { \
|
|
u64 name; \
|
|
u64 name##_array[VIRTIO_FEATURES_U64S];\
|
|
}
|
|
|
|
static inline bool virtio_features_chk_bit(unsigned int bit)
|
|
{
|
|
return bit < VIRTIO_FEATURES_BITS;
|
|
}
|
|
|
|
static inline bool virtio_features_test_bit(const u64 *features,
|
|
unsigned int bit)
|
|
{
|
|
return virtio_features_chk_bit(bit) &&
|
|
!!(features[VIRTIO_U64(bit)] & VIRTIO_BIT(bit));
|
|
}
|
|
|
|
static inline void virtio_features_set_bit(u64 *features, unsigned int bit)
|
|
{
|
|
if (virtio_features_chk_bit(bit))
|
|
features[VIRTIO_U64(bit)] |= VIRTIO_BIT(bit);
|
|
}
|
|
|
|
static inline void virtio_features_clear_bit(u64 *features, unsigned int bit)
|
|
{
|
|
if (virtio_features_chk_bit(bit))
|
|
features[VIRTIO_U64(bit)] &= ~VIRTIO_BIT(bit);
|
|
}
|
|
|
|
static inline void virtio_features_zero(u64 *features)
|
|
{
|
|
memset(features, 0, sizeof(features[0]) * VIRTIO_FEATURES_U64S);
|
|
}
|
|
|
|
static inline void virtio_features_from_u64(u64 *features, u64 from)
|
|
{
|
|
virtio_features_zero(features);
|
|
features[0] = from;
|
|
}
|
|
|
|
static inline bool virtio_features_equal(const u64 *f1, const u64 *f2)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < VIRTIO_FEATURES_U64S; ++i)
|
|
if (f1[i] != f2[i])
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
static inline void virtio_features_copy(u64 *to, const u64 *from)
|
|
{
|
|
memcpy(to, from, sizeof(to[0]) * VIRTIO_FEATURES_U64S);
|
|
}
|
|
|
|
static inline void virtio_features_andnot(u64 *to, const u64 *f1, const u64 *f2)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < VIRTIO_FEATURES_U64S; i++)
|
|
to[i] = f1[i] & ~f2[i];
|
|
}
|
|
|
|
#endif /* _LINUX_VIRTIO_FEATURES_H */
|