>From d68c98047ce54c62f3454997a55f23ff6fb317cd Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Thu, 1 Dec 2022 10:19:22 -0500 Subject: [PATCH] fixup! mm/migrate: fix read-only page got writable when recover pte Content-type: text/plain Signed-off-by: Peter Xu --- mm/migrate.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index c13c828d34f3..d14f1f3ab073 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -214,7 +214,14 @@ static bool remove_migration_pte(struct folio *folio, if (is_writable_migration_entry(entry)) pte = maybe_mkwrite(pte, vma); else - /* NOTE: mk_pte can have write bit set */ + /* + * NOTE: mk_pte() can have write bit set per memory + * type (e.g. shmem), or pte_mkdirty() per archs + * (e.g., sparc64). If this is a read migration + * entry, we need to make sure when we recover the + * pte from migration entry to present entry the + * write bit is cleared. + */ pte = pte_wrprotect(pte); if (pte_swp_uffd_wp(*pvmw.pte)) { -- 2.37.3