Message ID | 20240628033509.27612-1-tianruidong@linux.alibaba.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm/hwpoison: avoid speculation access after soft/hard offline | expand |
Ruidong Tian <tianruidong@linux.alibaba.com> writes: > Page that offlined can report CE/UE event due to speculation access. > Delete kernel 1:1 linner mapping after soft/hard offline to avoid it. But that will split the large pages for the direct mapping, costing you every time there is TLB pressure. You can probably do the math, with enough uptime and a reasonable error rate aand this patch there might be not even be 2MB pages left at some point. Cheaper to just ignore them, since they shouldn't cause any other problems. -Andi
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 67858eeb92ed..502ee1107ac6 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -22,6 +22,7 @@ #include <linux/stat.h> #include <linux/slab.h> #include <linux/xarray.h> +#include <linux/set_memory.h> #include <linux/atomic.h> #include <linux/uaccess.h> @@ -600,6 +601,8 @@ static ssize_t soft_offline_page_store(struct device *dev, return -EINVAL; pfn >>= PAGE_SHIFT; ret = soft_offline_page(pfn, 0); + if (!ret) + set_mce_nospec(pfn); return ret == 0 ? count : ret; } @@ -616,6 +619,8 @@ static ssize_t hard_offline_page_store(struct device *dev, return -EINVAL; pfn >>= PAGE_SHIFT; ret = memory_failure(pfn, MF_SW_SIMULATED); + if (!ret) + set_mce_nospec(pfn); if (ret == -EOPNOTSUPP) ret = 0; return ret ? ret : count;
Page that offlined can report CE/UE event due to speculation access. Delete kernel 1:1 linner mapping after soft/hard offline to avoid it. Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com> --- drivers/base/memory.c | 5 +++++ 1 file changed, 5 insertions(+)