Offering: HULK hulk inclusion category: feature bugzilla: NA ---------------------------------------- Introduce sp_update_prot(). Signed-off-by: Yin Tirui <yintirui@huawei.com> --- mm/share_pool.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mm/share_pool.c b/mm/share_pool.c index bef8d470246d..793111b3325c 100644 --- a/mm/share_pool.c +++ b/mm/share_pool.c @@ -2086,6 +2086,16 @@ static int sp_vma_populate_pages(struct vm_area_struct *vma, struct sp_area *spa return 0; } +static inline void sp_update_prot(struct vm_area_struct *vma, unsigned long prot) +{ + if (prot & PROT_WRITE) + /* clean PTE_RDONLY flags or trigger SMMU event */ + vma->vm_page_prot = __pgprot(((~PTE_RDONLY) & vma->vm_page_prot.pgprot) | + PTE_DIRTY); + else + vm_flags_clear(vma, VM_MAYWRITE); +} + /* wrapper of __do_mmap() and the caller must hold mmap_write_lock(mm). */ static unsigned long sp_mmap(struct mm_struct *mm, struct file *file, struct sp_area *spa, unsigned long *populate, @@ -2115,12 +2125,7 @@ static unsigned long sp_mmap(struct mm_struct *mm, struct file *file, vma = find_vma(mm, addr); vma->spa = spa; - if (prot & PROT_WRITE) - /* clean PTE_RDONLY flags or trigger SMMU event */ - vma->vm_page_prot = __pgprot(((~PTE_RDONLY) & vma->vm_page_prot.pgprot) | - PTE_DIRTY); - else - vm_flags_clear(vma, VM_MAYWRITE); + sp_update_prot(vma, prot); if (sp_area_use_remap(spa)) { ret = sp_vma_populate_pages(vma, spa, addr, size); @@ -2297,12 +2302,7 @@ static int sp_nc_mmap(struct mm_struct *mm, struct sp_area *spa, unsigned long p vma = find_vma(mm, addr); vma->spa = spa; - if (prot & PROT_WRITE) - vma->vm_page_prot = __pgprot(((~PTE_RDONLY) & - vma->vm_page_prot.pgprot) | PTE_DIRTY); - else - vm_flags_clear(vma, VM_MAYWRITE); - + sp_update_prot(vma, prot); vma->vm_page_prot = sp_pgprot_writethrough(vma->vm_page_prot); if (sp_area_use_remap(spa)) { ret = sp_vma_populate_pages(vma, spa, addr, size); -- 2.43.0