mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
bitmap: Add test for out-of-boundary modifications for scatter & gather
Make sure that bitmap_scatter() and bitmap_gather() do not modify the bits outside of the given nbits span. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Yury Norov <ynorov@nvidia.com>
This commit is contained in:
parent
c369299895
commit
6b5a4b6873
|
|
@ -354,18 +354,22 @@ static void __init test_replace(void)
|
||||||
|
|
||||||
static const unsigned long sg_mask[] __initconst = {
|
static const unsigned long sg_mask[] __initconst = {
|
||||||
BITMAP_FROM_U64(0x000000000000035aULL),
|
BITMAP_FROM_U64(0x000000000000035aULL),
|
||||||
|
BITMAP_FROM_U64(0x0000000000000000ULL),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned long sg_src[] __initconst = {
|
static const unsigned long sg_src[] __initconst = {
|
||||||
BITMAP_FROM_U64(0x0000000000000667ULL),
|
BITMAP_FROM_U64(0x0000000000000667ULL),
|
||||||
|
BITMAP_FROM_U64(0x0000000000000000ULL),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned long sg_gather_exp[] __initconst = {
|
static const unsigned long sg_gather_exp[] __initconst = {
|
||||||
BITMAP_FROM_U64(0x0000000000000029ULL),
|
BITMAP_FROM_U64(0x0000000000000029ULL),
|
||||||
|
BITMAP_FROM_U64(0x0000000000000000ULL),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned long sg_scatter_exp[] __initconst = {
|
static const unsigned long sg_scatter_exp[] __initconst = {
|
||||||
BITMAP_FROM_U64(0x000000000000021aULL),
|
BITMAP_FROM_U64(0x000000000000021aULL),
|
||||||
|
BITMAP_FROM_U64(0x0000000000000000ULL),
|
||||||
};
|
};
|
||||||
|
|
||||||
static void __init test_bitmap_sg(void)
|
static void __init test_bitmap_sg(void)
|
||||||
|
|
@ -379,18 +383,18 @@ static void __init test_bitmap_sg(void)
|
||||||
/* Simple gather call */
|
/* Simple gather call */
|
||||||
bitmap_zero(bmap_gather, 100);
|
bitmap_zero(bmap_gather, 100);
|
||||||
bitmap_gather(bmap_gather, sg_src, sg_mask, nbits);
|
bitmap_gather(bmap_gather, sg_src, sg_mask, nbits);
|
||||||
expect_eq_bitmap(sg_gather_exp, bmap_gather, nbits);
|
expect_eq_bitmap(sg_gather_exp, bmap_gather, 100);
|
||||||
|
|
||||||
/* Simple scatter call */
|
/* Simple scatter call */
|
||||||
bitmap_zero(bmap_scatter, 100);
|
bitmap_zero(bmap_scatter, 100);
|
||||||
bitmap_scatter(bmap_scatter, sg_src, sg_mask, nbits);
|
bitmap_scatter(bmap_scatter, sg_src, sg_mask, nbits);
|
||||||
expect_eq_bitmap(sg_scatter_exp, bmap_scatter, nbits);
|
expect_eq_bitmap(sg_scatter_exp, bmap_scatter, 100);
|
||||||
|
|
||||||
/* Scatter/gather relationship */
|
/* Scatter/gather relationship */
|
||||||
bitmap_zero(bmap_tmp, 100);
|
bitmap_zero(bmap_tmp, 100);
|
||||||
bitmap_gather(bmap_tmp, bmap_scatter, sg_mask, nbits);
|
bitmap_gather(bmap_tmp, bmap_scatter, sg_mask, nbits);
|
||||||
bitmap_scatter(bmap_res, bmap_tmp, sg_mask, nbits);
|
bitmap_scatter(bmap_res, bmap_tmp, sg_mask, nbits);
|
||||||
expect_eq_bitmap(bmap_scatter, bmap_res, nbits);
|
expect_eq_bitmap(bmap_scatter, bmap_res, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PARSE_TIME 0x1
|
#define PARSE_TIME 0x1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user