]> git.hungrycats.org Git - linux/commitdiff
[PATCH] s390: endless loop in follow_page.
authorAndrew Morton <akpm@osdl.org>
Mon, 19 Jan 2004 02:43:46 +0000 (18:43 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Mon, 19 Jan 2004 02:43:46 +0000 (18:43 -0800)
From: Martin Schwidefsky <schwidefsky@de.ibm.com>

Fix endless loop in get_user_pages() on s390.  It happens only on s/390
because pte_dirty always returns 0.  For all other architectures this is an
optimization.

In the case of "write && !pte_dirty(pte)" follow_page() returns NULL.  On all
architectures except s390 handle_pte_fault() will then create a pte with
pte_dirty(pte)==1 because write_access==1.  In the following, second call to
follow_page() all is fine.  With the physical dirty bit patch pte_dirty() is
always 0 for s/390 because the dirty bit doesn't live in the pte.

mm/memory.c

index cd71b713adadc9f7365679194128ca96d414c766..7d8a8ed531438e1a5928af2751a7e969c4b67160 100644 (file)
@@ -651,14 +651,19 @@ follow_page(struct mm_struct *mm, unsigned long address, int write)
        pte = *ptep;
        pte_unmap(ptep);
        if (pte_present(pte)) {
-               if (!write || (pte_write(pte) && pte_dirty(pte))) {
-                       pfn = pte_pfn(pte);
-                       if (pfn_valid(pfn)) {
-                               struct page *page = pfn_to_page(pfn);
-
-                               mark_page_accessed(page);
-                               return page;
-                       }
+               if (write && !pte_write(pte))
+                       goto out;
+               if (write && !pte_dirty(pte)) {
+                       struct page *page = pte_page(pte);
+                       if (!PageDirty(page))
+                               set_page_dirty(page);
+               }
+               pfn = pte_pfn(pte);
+               if (pfn_valid(pfn)) {
+                       struct page *page = pfn_to_page(pfn);
+                       
+                       mark_page_accessed(page);
+                       return page;
                }
        }