On Mon, Oct 23, 2023 at 12:49:55PM +0100, Joao Martins wrote: > diff --git a/tools/testing/selftests/iommu/iommufd_utils.h > b/tools/testing/selftests/iommu/iommufd_utils.h > index 390563ff7935..6bbcab7fd6ab 100644 > --- a/tools/testing/selftests/iommu/iommufd_utils.h > +++ b/tools/testing/selftests/iommu/iommufd_utils.h > @@ -9,8 +9,6 @@ > #include <sys/ioctl.h> > #include <stdint.h> > #include <assert.h> > -#include <linux/bitmap.h> > -#include <linux/bitops.h> > > #include "../kselftest_harness.h" > #include "../../../../drivers/iommu/iommufd/iommufd_test.h" > @@ -18,6 +16,24 @@ > /* Hack to make assertions more readable */ > #define _IOMMU_TEST_CMD(x) IOMMU_TEST_CMD > > +/* Imported from include/asm-generic/bitops/generic-non-atomic.h */ > +#define BITS_PER_BYTE 8 > +#define BITS_PER_LONG __BITS_PER_LONG > +#define BIT_MASK(nr) (1UL << ((nr) % __BITS_PER_LONG)) > +#define BIT_WORD(nr) ((nr) / __BITS_PER_LONG) > + > +static inline void set_bit(unsigned int nr, unsigned long *addr) > +{ > + unsigned long mask = BIT_MASK(nr); > + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); > + > + *p |= mask; > +} > + > +static inline bool test_bit(unsigned int nr, unsigned long *addr) > +{ > + return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); > +} > + > static void *buffer; > static unsigned long BUFFER_SIZE; This is probably the good option.. Jason