Re: [PATCH v24 16/30] mm: Fixup places that call pte_mkwrite() directly

From: Kirill A. Shutemov
Date: Fri Apr 09 2021 - 11:20:15 EST


On Thu, Apr 01, 2021 at 03:10:50PM -0700, Yu-cheng Yu wrote:
> When serving a page fault, maybe_mkwrite() makes a PTE writable if it is in
> a writable vma. A shadow stack vma is writable, but its PTEs need
> _PAGE_DIRTY to be set to become writable. For this reason, maybe_mkwrite()
> has been updated.
>
> There are a few places that call pte_mkwrite() directly, but have the
> same result as from maybe_mkwrite(). These sites need to be updated for
> shadow stack as well. Thus, change them to maybe_mkwrite():
>
> - do_anonymous_page() and migrate_vma_insert_page() check VM_WRITE directly
> and call pte_mkwrite(), which is the same as maybe_mkwrite(). Change
> them to maybe_mkwrite().
>
> - In do_numa_page(), if the numa entry was writable, then pte_mkwrite()
> is called directly. Fix it by doing maybe_mkwrite().
>
> - In change_pte_range(), pte_mkwrite() is called directly. Replace it with
> maybe_mkwrite().
>
> A shadow stack vma is writable but has different vma
> flags, and handled accordingly in maybe_mkwrite().
>

Have you checked THP side? Looks like at least do_huge_pmd_numa_page()
needs adjustment, no?

--
Kirill A. Shutemov