The patch titled Subject: mm/migrate: properly preserve write attribute in special migrate entry has been added to the -mm tree. Its filename is mm-migrate-properly-preserve-write-attribute-in-special-migrate-entry.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-migrate-properly-preserve-write-attribute-in-special-migrate-entry.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-migrate-properly-preserve-write-attribute-in-special-migrate-entry.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ralph Campbell <rcampbell@xxxxxxxxxx> Subject: mm/migrate: properly preserve write attribute in special migrate entry Use of pte_write(pte) is only valid for present pte, the common code which set the migration entry can be reach for both valid present pte and special swap entry (for device memory). Fix the code to use the mpfn value which properly handle both cases. On x86 this did not have any bad side effect because pte write bit is below PAGE_BIT_GLOBAL and thus special swap entry have it set to 0 which in turn means we were always creating read only special migration entry. So once migration did finish we always write protected the CPU page table entry (moreover this is only an issue when migrating from device memory to system memory). End effect is that CPU write access would fault again and restore write permission. Link: http://lkml.kernel.org/r/20180402023506.12180-1-jglisse@xxxxxxxxxx Signed-off-by: Ralph Campbell <rcampbell@xxxxxxxxxx> Signed-off-by: Jérôme Glisse <jglisse@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff -puN mm/migrate.c~mm-migrate-properly-preserve-write-attribute-in-special-migrate-entry mm/migrate.c --- a/mm/migrate.c~mm-migrate-properly-preserve-write-attribute-in-special-migrate-entry +++ a/mm/migrate.c @@ -2346,7 +2346,8 @@ again: ptep_get_and_clear(mm, addr, ptep); /* Setup special migration page table entry */ - entry = make_migration_entry(page, pte_write(pte)); + entry = make_migration_entry(page, mpfn & + MIGRATE_PFN_WRITE); swp_pte = swp_entry_to_pte(entry); if (pte_soft_dirty(pte)) swp_pte = pte_swp_mksoft_dirty(swp_pte); _ Patches currently in -mm which might be from rcampbell@xxxxxxxxxx are mm-hmm-documentation-editorial-update-to-hmm-documentation.patch mm-hmm-hmm-should-have-a-callback-before-mm-is-destroyed-v3.patch mm-hmm-use-device-driver-encoding-for-hmm-pfn-v2-fix.patch mm-hmm-use-device-driver-encoding-for-hmm-pfn-v2-fix-2.patch mm-migrate-properly-preserve-write-attribute-in-special-migrate-entry.patch ��.n��������+%������w��{.n����������ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f