1 #include <linux/kernel.h>
2 #include <linux/string.h>
6 #include <linux/poison.h>
9 static inline void set_page_poison(
struct page *
page)
14 static inline void clear_page_poison(
struct page *
page)
19 static inline bool page_poison(
struct page *
page)
24 static void poison_page(
struct page *
page)
28 set_page_poison(page);
33 static void poison_pages(
struct page *
page,
int n)
37 for (i = 0; i <
n; i++)
38 poison_page(page + i);
41 static bool single_bit_flip(
unsigned char a,
unsigned char b)
43 unsigned char error = a ^
b;
45 return error && !(error & (error - 1));
48 static void check_poison_mem(
unsigned char *
mem,
size_t bytes)
58 for (end = mem + bytes - 1; end >
start; end--) {
65 else if (start == end && single_bit_flip(*start,
PAGE_POISON))
75 static void unpoison_page(
struct page *page)
79 if (!page_poison(page))
84 clear_page_poison(page);
88 static void unpoison_pages(
struct page *page,
int n)
92 for (i = 0; i <
n; i++)
93 unpoison_page(page + i);
99 unpoison_pages(page, numpages);
101 poison_pages(page, numpages);