Message ID | 20200214222658.12946-40-borntraeger@de.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: s390: Add support for protected VMs | expand |
On Fri, Feb 14, 2020 at 05:26:55PM -0500, Christian Borntraeger wrote: > From: Claudio Imbrenda <imbrenda@linux.ibm.com> > > This is a potential extension to do error handling if we fail to > make the page accessible if we know what others need. > > Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> > --- > mm/gup.c | 17 ++++++++++++----- > mm/page-writeback.c | 6 +++++- > 2 files changed, 17 insertions(+), 6 deletions(-) Sorry, I missed this when replying elsewhere in the thread! Anyway, looks good to me: Acked-by: Will Deacon <will@kernel.org> Thanks, Will
On 18.02.20 17:25, Will Deacon wrote: > On Fri, Feb 14, 2020 at 05:26:55PM -0500, Christian Borntraeger wrote: >> From: Claudio Imbrenda <imbrenda@linux.ibm.com> >> >> This is a potential extension to do error handling if we fail to >> make the page accessible if we know what others need. >> >> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> >> --- >> mm/gup.c | 17 ++++++++++++----- >> mm/page-writeback.c | 6 +++++- >> 2 files changed, 17 insertions(+), 6 deletions(-) > > Sorry, I missed this when replying elsewhere in the thread! > Anyway, looks good to me: > > Acked-by: Will Deacon <will@kernel.org> I can use that for a combined patch (this one merged into the first) ? Correct?
On Tue, Feb 18, 2020 at 05:30:40PM +0100, Christian Borntraeger wrote: > On 18.02.20 17:25, Will Deacon wrote: > > On Fri, Feb 14, 2020 at 05:26:55PM -0500, Christian Borntraeger wrote: > >> From: Claudio Imbrenda <imbrenda@linux.ibm.com> > >> > >> This is a potential extension to do error handling if we fail to > >> make the page accessible if we know what others need. > >> > >> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> > >> --- > >> mm/gup.c | 17 ++++++++++++----- > >> mm/page-writeback.c | 6 +++++- > >> 2 files changed, 17 insertions(+), 6 deletions(-) > > > > Sorry, I missed this when replying elsewhere in the thread! > > Anyway, looks good to me: > > > > Acked-by: Will Deacon <will@kernel.org> > > I can use that for a combined patch (this one merged into the first) ? Correct? Fine by me! Will
diff --git a/mm/gup.c b/mm/gup.c index a1c15d029f7c..354bcfbd844b 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -193,6 +193,7 @@ static struct page *follow_page_pte(struct vm_area_struct *vma, struct page *page; spinlock_t *ptl; pte_t *ptep, pte; + int ret; /* FOLL_GET and FOLL_PIN are mutually exclusive. */ if (WARN_ON_ONCE((flags & (FOLL_PIN | FOLL_GET)) == @@ -250,8 +251,6 @@ static struct page *follow_page_pte(struct vm_area_struct *vma, if (is_zero_pfn(pte_pfn(pte))) { page = pte_page(pte); } else { - int ret; - ret = follow_pfn_pte(vma, address, ptep, flags); page = ERR_PTR(ret); goto out; @@ -259,7 +258,6 @@ static struct page *follow_page_pte(struct vm_area_struct *vma, } if (flags & FOLL_SPLIT && PageTransCompound(page)) { - int ret; get_page(page); pte_unmap_unlock(ptep, ptl); lock_page(page); @@ -276,7 +274,12 @@ static struct page *follow_page_pte(struct vm_area_struct *vma, page = ERR_PTR(-ENOMEM); goto out; } - arch_make_page_accessible(page); + ret = arch_make_page_accessible(page); + if (ret) { + put_page(page); + page = ERR_PTR(ret); + goto out; + } } if (flags & FOLL_TOUCH) { if ((flags & FOLL_WRITE) && @@ -1920,7 +1923,11 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, VM_BUG_ON_PAGE(compound_head(page) != head, page); - arch_make_page_accessible(page); + ret = arch_make_page_accessible(page); + if (ret) { + put_page(head); + goto pte_unmap; + } SetPageReferenced(page); pages[*nr] = page; (*nr)++; diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 4c020e4ae71c..558d7063c117 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2807,7 +2807,11 @@ int __test_set_page_writeback(struct page *page, bool keep_write) inc_zone_page_state(page, NR_ZONE_WRITE_PENDING); } unlock_page_memcg(page); - arch_make_page_accessible(page); + /* + * If writeback has been triggered on a page that cannot be made + * accessible, it is too late. + */ + WARN_ON(arch_make_page_accessible(page)); return ret; }