All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: sparclinux@vger.kernel.org
Subject: Re: [PATCH 09/10] sparc64: Add basic validations to {pud,pmd}_bad().
Date: Thu, 01 May 2014 16:17:02 +0000	[thread overview]
Message-ID: <20140501161702.GA17134@ravnborg.org> (raw)
In-Reply-To: <20140430.175556.65359624693463383.davem@davemloft.net>

On Wed, Apr 30, 2014 at 05:55:56PM -0400, David Miller wrote:
> 
> Instead of returning false we should at least check the most basic
> things, otherwise page table corruptions will be very difficult to
> debug.
> 
> PMD and PTE tables are of size PAGE_SIZE, so none of the sub-PAGE_SIZE
> bits should be set.
> 
> We also complement this with a check that the physical address the
> pud/pmd points to is valid memory.
> 
> PowerPC was used as a guide while implementating this.
> 
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
>  arch/sparc/include/asm/pgtable_64.h | 46 +++++++++++++++++++++++++------------
>  1 file changed, 31 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
> index ff97960..fd4dbdd 100644
> --- a/arch/sparc/include/asm/pgtable_64.h
> +++ b/arch/sparc/include/asm/pgtable_64.h
> @@ -71,6 +71,23 @@
>  
>  #include <linux/sched.h>
>  
> +extern unsigned long sparc64_valid_addr_bitmap[];
> +
> +/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
> +static inline bool __kern_addr_valid(unsigned long paddr)
It would had been self-documenting if the type is changed to phys_addr_t here.
But I see that we do not use phys_addr_t much (only one place) in sparc code today.

> +{
> +	if ((paddr >> MAX_PHYS_ADDRESS_BITS) != 0UL)
> +		return false;
> +	return test_bit(paddr >> 22, sparc64_valid_addr_bitmap);
> +}
I assume it is a coincidence that we have the same block size
in sparc64_valid_addr_bitmapi (22) as we have for REAL_HPAGE_SHIFT.

	Sam

  reply	other threads:[~2014-05-01 16:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-30 21:55 [PATCH 09/10] sparc64: Add basic validations to {pud,pmd}_bad() David Miller
2014-05-01 16:17 ` Sam Ravnborg [this message]
2014-05-01 16:48 ` David Miller
2014-05-06  3:59 ` David Miller

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=20140501161702.GA17134@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=sparclinux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.