s390: allow pte_offset_map_lock() to fail
[platform/kernel/linux-starfive.git] / arch / s390 / mm / pgtable.c
index 6effb24..3bd2ab2 100644 (file)
@@ -829,7 +829,7 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
        default:
                return -EFAULT;
        }
-
+again:
        ptl = pmd_lock(mm, pmdp);
        if (!pmd_present(*pmdp)) {
                spin_unlock(ptl);
@@ -850,6 +850,8 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
        spin_unlock(ptl);
 
        ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl);
+       if (!ptep)
+               goto again;
        new = old = pgste_get_lock(ptep);
        pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT |
                            PGSTE_ACC_BITS | PGSTE_FP_BIT);
@@ -938,7 +940,7 @@ int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr)
        default:
                return -EFAULT;
        }
-
+again:
        ptl = pmd_lock(mm, pmdp);
        if (!pmd_present(*pmdp)) {
                spin_unlock(ptl);
@@ -955,6 +957,8 @@ int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr)
        spin_unlock(ptl);
 
        ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl);
+       if (!ptep)
+               goto again;
        new = old = pgste_get_lock(ptep);
        /* Reset guest reference bit only */
        pgste_val(new) &= ~PGSTE_GR_BIT;
@@ -1000,7 +1004,7 @@ int get_guest_storage_key(struct mm_struct *mm, unsigned long addr,
        default:
                return -EFAULT;
        }
-
+again:
        ptl = pmd_lock(mm, pmdp);
        if (!pmd_present(*pmdp)) {
                spin_unlock(ptl);
@@ -1017,6 +1021,8 @@ int get_guest_storage_key(struct mm_struct *mm, unsigned long addr,
        spin_unlock(ptl);
 
        ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl);
+       if (!ptep)
+               goto again;
        pgste = pgste_get_lock(ptep);
        *key = (pgste_val(pgste) & (PGSTE_ACC_BITS | PGSTE_FP_BIT)) >> 56;
        paddr = pte_val(*ptep) & PAGE_MASK;