@@ -264,19 +264,33 @@ __iowrite64_copy(void __iomem *to, const void *from, size_t count)
264264typedef int (* ioremap_prot_hook_t )(phys_addr_t phys_addr , size_t size ,
265265 pgprot_t * prot );
266266int arm64_ioremap_prot_hook_register (const ioremap_prot_hook_t hook );
267+ void __iomem * __ioremap_prot (phys_addr_t phys , size_t size , pgprot_t prot );
267268
268- #define ioremap_prot ioremap_prot
269+ static inline void __iomem * ioremap_prot (phys_addr_t phys , size_t size ,
270+ pgprot_t user_prot )
271+ {
272+ pgprot_t prot ;
273+ ptdesc_t user_prot_val = pgprot_val (user_prot );
274+
275+ if (WARN_ON_ONCE (!(user_prot_val & PTE_USER )))
276+ return NULL ;
269277
270- #define _PAGE_IOREMAP PROT_DEVICE_nGnRE
278+ prot = __pgprot_modify (PAGE_KERNEL , PTE_ATTRINDX_MASK ,
279+ user_prot_val & PTE_ATTRINDX_MASK );
280+ return __ioremap_prot (phys , size , prot );
281+ }
282+ #define ioremap_prot ioremap_prot
271283
284+ #define ioremap (addr , size ) \
285+ __ioremap_prot((addr), (size), __pgprot(PROT_DEVICE_nGnRE))
272286#define ioremap_wc (addr , size ) \
273- ioremap_prot ((addr), (size), __pgprot(PROT_NORMAL_NC))
287+ __ioremap_prot ((addr), (size), __pgprot(PROT_NORMAL_NC))
274288#define ioremap_np (addr , size ) \
275- ioremap_prot ((addr), (size), __pgprot(PROT_DEVICE_nGnRnE))
289+ __ioremap_prot ((addr), (size), __pgprot(PROT_DEVICE_nGnRnE))
276290
277291
278292#define ioremap_encrypted (addr , size ) \
279- ioremap_prot ((addr), (size), PAGE_KERNEL)
293+ __ioremap_prot ((addr), (size), PAGE_KERNEL)
280294
281295/*
282296 * io{read,write}{16,32,64}be() macros
@@ -297,7 +311,7 @@ static inline void __iomem *ioremap_cache(phys_addr_t addr, size_t size)
297311 if (pfn_is_map_memory (__phys_to_pfn (addr )))
298312 return (void __iomem * )__phys_to_virt (addr );
299313
300- return ioremap_prot (addr , size , __pgprot (PROT_NORMAL ));
314+ return __ioremap_prot (addr , size , __pgprot (PROT_NORMAL ));
301315}
302316
303317/*
0 commit comments