Skip to content

Commit aa549f9

Browse files
Kefeng Wangakpm00
authored andcommitted
mm: support poison recovery from do_cow_fault()
Patch series "mm: hwpoison: two more poison recovery". One more CoW path to support poison recorvery in do_cow_fault(), and the last copy_user_highpage() user is replaced to copy_mc_user_highpage() from copy_present_page() during fork to support poison recorvery too. This patch (of 2): Like commit a873dfe ("mm, hwpoison: try to recover from copy-on write faults"), there is another path which could crash because it does not have recovery code where poison is consumed by the kernel in do_cow_fault(), a crash calltrace shown below on old kernel, but it could be happened in the lastest mainline code, CPU: 7 PID: 3248 Comm: mpi Kdump: loaded Tainted: G OE 5.10.0 #1 pc : copy_page+0xc/0xbc lr : copy_user_highpage+0x50/0x9c Call trace: copy_page+0xc/0xbc do_cow_fault+0x118/0x2bc do_fault+0x40/0x1a4 handle_pte_fault+0x154/0x230 __handle_mm_fault+0x1a8/0x38c handle_mm_fault+0xf0/0x250 do_page_fault+0x184/0x454 do_translation_fault+0xac/0xd4 do_mem_abort+0x44/0xbc Fix it by using copy_mc_user_highpage() to handle this case and return VM_FAULT_HWPOISON for cow fault. [[email protected]: unlock/put vmf->page, per Miaohe] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] 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 99185c1 commit aa549f9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mm/memory.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5089,10 +5089,14 @@ static vm_fault_t do_cow_fault(struct vm_fault *vmf)
50895089
if (ret & VM_FAULT_DONE_COW)
50905090
return ret;
50915091

5092-
copy_user_highpage(vmf->cow_page, vmf->page, vmf->address, vma);
5092+
if (copy_mc_user_highpage(vmf->cow_page, vmf->page, vmf->address, vma)) {
5093+
ret = VM_FAULT_HWPOISON;
5094+
goto unlock;
5095+
}
50935096
__folio_mark_uptodate(folio);
50945097

50955098
ret |= finish_fault(vmf);
5099+
unlock:
50965100
unlock_page(vmf->page);
50975101
put_page(vmf->page);
50985102
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)))

0 commit comments

Comments
 (0)