Commit 1bfe5febe34d2be2120803c10720e179186357c9

Authored by Haicheng Li
Committed by Andi Kleen
1 parent 4fd466eb46

HWPOISON: add an interface to switch off/on all the page filters

In some use cases, user doesn't need extra filtering. E.g. user program
can inject errors through madvise syscall to its own pages, however it
might not know what the page state exactly is or which inode the page
belongs to.

So introduce an one-off interface "corrupt-filter-enable".

Echo 0 to switch off page filters, and echo 1 to switch on the filters.
[AK: changed default to 0]

Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>

Showing 3 changed files with 11 additions and 0 deletions Side-by-side Diff

mm/hwpoison-inject.c
... ... @@ -92,6 +92,11 @@
92 92 if (!dentry)
93 93 goto fail;
94 94  
  95 + dentry = debugfs_create_u32("corrupt-filter-enable", 0600,
  96 + hwpoison_dir, &hwpoison_filter_enable);
  97 + if (!dentry)
  98 + goto fail;
  99 +
95 100 dentry = debugfs_create_u32("corrupt-filter-dev-major", 0600,
96 101 hwpoison_dir, &hwpoison_filter_dev_major);
97 102 if (!dentry)
... ... @@ -258,4 +258,5 @@
258 258 extern u64 hwpoison_filter_flags_mask;
259 259 extern u64 hwpoison_filter_flags_value;
260 260 extern u64 hwpoison_filter_memcg;
  261 +extern u32 hwpoison_filter_enable;
... ... @@ -49,10 +49,12 @@
49 49  
50 50 atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
51 51  
  52 +u32 hwpoison_filter_enable = 0;
52 53 u32 hwpoison_filter_dev_major = ~0U;
53 54 u32 hwpoison_filter_dev_minor = ~0U;
54 55 u64 hwpoison_filter_flags_mask;
55 56 u64 hwpoison_filter_flags_value;
  57 +EXPORT_SYMBOL_GPL(hwpoison_filter_enable);
56 58 EXPORT_SYMBOL_GPL(hwpoison_filter_dev_major);
57 59 EXPORT_SYMBOL_GPL(hwpoison_filter_dev_minor);
58 60 EXPORT_SYMBOL_GPL(hwpoison_filter_flags_mask);
... ... @@ -145,6 +147,9 @@
145 147  
146 148 int hwpoison_filter(struct page *p)
147 149 {
  150 + if (!hwpoison_filter_enable)
  151 + return 0;
  152 +
148 153 if (hwpoison_filter_dev(p))
149 154 return -EINVAL;
150 155