linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Kani, Toshi" <toshi.kani@hpe.com>
To: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"anshuman.khandual@arm.com" <anshuman.khandual@arm.com>
Cc: "tglx@linutronix.de" <tglx@linutronix.de>,
	"cpandya@codeaurora.org" <cpandya@codeaurora.org>,
	"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"will.deacon@arm.com" <will.deacon@arm.com>
Subject: Re: [PATCH V3 1/2] mm/ioremap: Check virtual address alignment while creating huge mappings
Date: Mon, 13 May 2019 22:26:30 +0000	[thread overview]
Message-ID: <f56ab0da9e9f20a7c4c019e629052d0e1aa2ffff.camel@hpe.com> (raw)
In-Reply-To: <1557377177-20695-2-git-send-email-anshuman.khandual@arm.com>

On Thu, 2019-05-09 at 10:16 +0530, Anshuman Khandual wrote:
> Virtual address alignment is essential in ensuring correct clearing for all
> intermediate level pgtable entries and freeing associated pgtable pages. An
> unaligned address can end up randomly freeing pgtable page that potentially
> still contains valid mappings. Hence also check it's alignment along with
> existing phys_addr check.
> 
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> Cc: Toshi Kani <toshi.kani@hpe.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Chintan Pandya <cpandya@codeaurora.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> ---
>  lib/ioremap.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/lib/ioremap.c b/lib/ioremap.c
> index 063213685563..8b5c8dda857d 100644
> --- a/lib/ioremap.c
> +++ b/lib/ioremap.c
> @@ -86,6 +86,9 @@ static int ioremap_try_huge_pmd(pmd_t *pmd, unsigned long addr,
>  	if ((end - addr) != PMD_SIZE)
>  		return 0;
>  
> +	if (!IS_ALIGNED(addr, PMD_SIZE))
> +		return 0;
> +
>  	if (!IS_ALIGNED(phys_addr, PMD_SIZE))
>  		return 0;
>  
> @@ -126,6 +129,9 @@ static int ioremap_try_huge_pud(pud_t *pud, unsigned long addr,
>  	if ((end - addr) != PUD_SIZE)
>  		return 0;
>  
> +	if (!IS_ALIGNED(addr, PUD_SIZE))
> +		return 0;
> +
>  	if (!IS_ALIGNED(phys_addr, PUD_SIZE))
>  		return 0;

Not sure if we have such case today, but I agree that it is prudent to
have such checks.  Is there any reason not to add this check to p4d for
consistency?

Thanks,
-Toshi


  reply	other threads:[~2019-05-13 22:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09  4:46 [PATCH V3 0/2] mm/ioremap: Check virtual address alignment Anshuman Khandual
2019-05-09  4:46 ` [PATCH V3 1/2] mm/ioremap: Check virtual address alignment while creating huge mappings Anshuman Khandual
2019-05-13 22:26   ` Kani, Toshi [this message]
2019-05-14  5:55     ` Anshuman Khandual
2019-05-15  2:35       ` [PATCH V4] " Anshuman Khandual
2019-05-15  9:46         ` Will Deacon
2019-05-15 10:10           ` Anshuman Khandual
2019-05-16 18:38         ` Kani, Toshi
2019-06-06 13:51         ` Catalin Marinas
2019-05-09  4:46 ` [PATCH V3 2/2] arm64/mm: Change offset base address in [pud|pmd]_free_[pmd|pte]_page() Anshuman Khandual
2019-06-03 15:36   ` Catalin Marinas
2019-06-06  8:08     ` Anshuman Khandual
2019-06-04 14:24   ` Catalin Marinas
2019-06-06  4:44     ` Anshuman Khandual

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=f56ab0da9e9f20a7c4c019e629052d0e1aa2ffff.camel@hpe.com \
    --to=toshi.kani@hpe.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=cpandya@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    /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).