Skip to content

Commit 658be46

Browse files
Kefeng Wangakpm00
authored andcommitted
mm: support poison recovery from copy_present_page()
Similar to other poison recovery, use copy_mc_user_highpage() to avoid potentially kernel panic during copy page in copy_present_page() from fork, once copy failed due to hwpoison in source page, we need to break out of copy in copy_pte_range() and release prealloc folio, so copy_mc_user_highpage() is moved ahead before set *prealloc to NULL. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kefeng Wang <[email protected]> Reviewed-by: Jane Chu <[email protected]> Reviewed-by: Miaohe Lin <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Jiaqi Yan <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Tony Luck <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent aa549f9 commit 658be46

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mm/memory.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,8 +926,11 @@ copy_present_page(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma
926926
* We have a prealloc page, all good! Take it
927927
* over and copy the page & arm it.
928928
*/
929+
930+
if (copy_mc_user_highpage(&new_folio->page, page, addr, src_vma))
931+
return -EHWPOISON;
932+
929933
*prealloc = NULL;
930-
copy_user_highpage(&new_folio->page, page, addr, src_vma);
931934
__folio_mark_uptodate(new_folio);
932935
folio_add_new_anon_rmap(new_folio, dst_vma, addr, RMAP_EXCLUSIVE);
933936
folio_add_lru_vma(new_folio, dst_vma);
@@ -1166,8 +1169,9 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
11661169
/*
11671170
* If we need a pre-allocated page for this pte, drop the
11681171
* locks, allocate, and try again.
1172+
* If copy failed due to hwpoison in source page, break out.
11691173
*/
1170-
if (unlikely(ret == -EAGAIN))
1174+
if (unlikely(ret == -EAGAIN || ret == -EHWPOISON))
11711175
break;
11721176
if (unlikely(prealloc)) {
11731177
/*
@@ -1197,7 +1201,7 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
11971201
goto out;
11981202
}
11991203
entry.val = 0;
1200-
} else if (ret == -EBUSY) {
1204+
} else if (ret == -EBUSY || unlikely(ret == -EHWPOISON)) {
12011205
goto out;
12021206
} else if (ret == -EAGAIN) {
12031207
prealloc = folio_prealloc(src_mm, src_vma, addr, false);

0 commit comments

Comments
 (0)