From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Madhusudanan Kandasamy <kmadhu@linux.vnet.ibm.com>
Cc: Paul Mackerras <paulus@samba.org>,
linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] powerpc: Fail remap_4k_pfn() if PFN doesn't fit inside PTE
Date: Thu, 10 Jul 2014 08:49:11 +1000 [thread overview]
Message-ID: <20140710084911.22cb58d4@canb.auug.org.au> (raw)
In-Reply-To: <53BD68FF.7000307@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1419 bytes --]
Hi Madhusudanan,
On Wed, 09 Jul 2014 21:38:31 +0530 Madhusudanan Kandasamy <kmadhu@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@canb.auug.org.au
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2014-07-09 22:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-09 16:08 [PATCH] powerpc: Fail remap_4k_pfn() if PFN doesn't fit inside PTE Madhusudanan Kandasamy
2014-07-09 22:49 ` Stephen Rothwell [this message]
2014-07-10 7:46 ` Madhusudanan Kandasamy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140710084911.22cb58d4@canb.auug.org.au \
--to=sfr@canb.auug.org.au \
--cc=kmadhu@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).