[PATCH] mm: properly handle fault on huge page migration

From: Jerome Glisse
Date: Tue Jun 04 2013 - 11:34:14 EST


When huge page is being migrated it's pmd is non zero but does not have
any of the huge pmd flags set. It's a swap entry pmd. The handle_mm_fault
never check for this case and thus if a fault happen in the huge page
range while it's being migrated handle_mm_fault will interpret badly the
pmd.

Signed-off-by: Jerome Glisse <jglisse@xxxxxxxxxx>
---
mm/memory.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/mm/memory.c b/mm/memory.c
index 6dc1882..e2a039c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3793,6 +3793,7 @@ retry:
pmd, flags);
} else {
pmd_t orig_pmd = *pmd;
+ swp_entry_t entry;
int ret;

barrier();
@@ -3829,6 +3830,20 @@ retry:

return 0;
}
+
+ swp_entry_t entry = pte_to_swp_entry((pte_t)orig_pmd);
+ if (unlikely(non_swap_entry(entry))) {
+ if (is_migration_entry(entry)) {
+ migration_entry_wait(mm, pmd, address);
+ /* Retry the fault */
+ return 0;
+ } else if (is_hwpoison_entry(entry)) {
+ return VM_FAULT_HWPOISON;
+ } else {
+ /* Something else is wrong invalid pmd print it ? */
+ return VM_FAULT_SIGBUS;
+ }
+ }
}

if (pmd_numa(*pmd))
--
1.7.11.7


--KsGdsel6WgEHnImy--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/