powerpc/nohash: Replace pte_user() by pte_read()
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Mon, 25 Sep 2023 18:31:43 +0000 (20:31 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 19 Oct 2023 06:12:46 +0000 (17:12 +1100)
pte_user() is now only used in pte_access_permitted() to check
access on vmas. User flag is cleared to make a page unreadable.

So rename it pte_read() and remove pte_user() which isn't used
anymore.

For the time being it checks _PAGE_USER but in the near futur
all plateforms will be converted to _PAGE_READ so lets support
both for now.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/72cbb5be595e9ef884140def73815ed0b0b37010.1695659959.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/nohash/32/pte-8xx.h
arch/powerpc/include/asm/nohash/pgtable.h
arch/powerpc/mm/ioremap.c

index 62c965a4511ab8382671eb3107621c229b1d71fc..1ee38befd29a28e43688f172bcb5a5a13dcb9108 100644 (file)
@@ -112,13 +112,6 @@ static inline pte_t pte_mkwrite_novma(pte_t pte)
 
 #define pte_mkwrite_novma pte_mkwrite_novma
 
-static inline bool pte_user(pte_t pte)
-{
-       return !(pte_val(pte) & _PAGE_SH);
-}
-
-#define pte_user pte_user
-
 static inline pte_t pte_mkhuge(pte_t pte)
 {
        return __pte(pte_val(pte) | _PAGE_SPS | _PAGE_HUGE);
index 9a91efa6455b8a86286b993763c4152735b372ef..84b6a160d2fc34fd15abe9815316e84b88bd489c 100644 (file)
@@ -159,9 +159,6 @@ static inline int pte_write(pte_t pte)
        return pte_val(pte) & _PAGE_WRITE;
 }
 #endif
-#ifndef pte_read
-static inline int pte_read(pte_t pte)          { return 1; }
-#endif
 static inline int pte_dirty(pte_t pte)         { return pte_val(pte) & _PAGE_DIRTY; }
 static inline int pte_special(pte_t pte)       { return pte_val(pte) & _PAGE_SPECIAL; }
 static inline int pte_none(pte_t pte)          { return (pte_val(pte) & ~_PTE_NONE_MASK) == 0; }
@@ -189,10 +186,14 @@ static inline int pte_young(pte_t pte)
  * and PTE_64BIT, PAGE_KERNEL_X contains _PAGE_BAP_SR which is also in
  * _PAGE_USER.  Need to explicitly match _PAGE_BAP_UR bit in that case too.
  */
-#ifndef pte_user
-static inline bool pte_user(pte_t pte)
+#ifndef pte_read
+static inline bool pte_read(pte_t pte)
 {
+#ifdef _PAGE_READ
+       return (pte_val(pte) & _PAGE_READ) == _PAGE_READ;
+#else
        return (pte_val(pte) & _PAGE_USER) == _PAGE_USER;
+#endif
 }
 #endif
 
@@ -207,7 +208,7 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
         * A read-only access is controlled by _PAGE_USER bit.
         * We have _PAGE_READ set for WRITE and EXECUTE
         */
-       if (!pte_present(pte) || !pte_user(pte) || !pte_read(pte))
+       if (!pte_present(pte) || !pte_read(pte))
                return false;
 
        if (write && !pte_write(pte))
index 7823c38f09deeafaae518d3bcef7260274f44886..7b0afcabd89f0574a918de4b66ca27ff6fbeb12a 100644 (file)
@@ -50,10 +50,6 @@ void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long flags)
        if (pte_write(pte))
                pte = pte_mkdirty(pte);
 
-       /* we don't want to let _PAGE_USER leak out */
-       if (WARN_ON(pte_user(pte)))
-               return NULL;
-
        if (iowa_is_active())
                return iowa_ioremap(addr, size, pte_pgprot(pte), caller);
        return __ioremap_caller(addr, size, pte_pgprot(pte), caller);