[PATCH] powerpc: Fail remap_4k_pfn() if PFN doesn't fit inside PTE
Stephen Rothwell
sfr at canb.auug.org.au
Thu Jul 10 08:49:11 EST 2014
Hi Madhusudanan,
On Wed, 09 Jul 2014 21:38:31 +0530 Madhusudanan Kandasamy <kmadhu at linux.vnet.ibm.com> wrote:
>
> diff --git a/arch/powerpc/include/asm/pte-hash64-64k.h b/arch/powerpc/include/asm/pte-hash64-64k.h
> index d836d94..10af7f1 100644
> --- a/arch/powerpc/include/asm/pte-hash64-64k.h
> +++ b/arch/powerpc/include/asm/pte-hash64-64k.h
> @@ -74,8 +74,15 @@
> #define pte_pagesize_index(mm, addr, pte) \
> (((pte) & _PAGE_COMBO)? MMU_PAGE_4K: MMU_PAGE_64K)
>
> +static inline int bad_4k_pfn(void)
> +{
> + WARN_ON(1);
> + return -EINVAL;
> +}
> +
> #define remap_4k_pfn(vma, addr, pfn, prot) \
> - remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, \
> - __pgprot(pgprot_val((prot)) | _PAGE_4K_PFN))
> + ((pfn >= (1UL << (64 - PTE_RPN_SHIFT))) ? bad_4k_pfn() : \
> + remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, \
> + __pgprot(pgprot_val((prot)) | _PAGE_4K_PFN)))
>
> #endif /* __ASSEMBLY__ */
WARN_ON() returns the value it is passed, so no helper is needed:
#define remap_4k_pfn(vma, addr, pfn, prot) \
- remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, \
- __pgprot(pgprot_val((prot)) | _PAGE_4K_PFN))
+ WARN_ON(((pfn >= (1UL << (64 - PTE_RPN_SHIFT)))) ? -EINVAL : \
+ remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, \
+ __pgprot(pgprot_val((prot)) | _PAGE_4K_PFN)))
--
Cheers,
Stephen Rothwell sfr at canb.auug.org.au
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20140710/d82ecde3/attachment.sig>
More information about the Linuxppc-dev
mailing list