public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Kani, Toshi" <toshi.kani@hpe.com>
To: "xieyisheng1@huawei.com" <xieyisheng1@huawei.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"guohanjun@huawei.com" <guohanjun@huawei.com>,
	"tanxiaojun@huawei.com" <tanxiaojun@huawei.com>,
	"wangzhou1@hisilicon.com" <wangzhou1@hisilicon.com>,
	"kstewart@linuxfoundation.org" <kstewart@linuxfoundation.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"jcm@redhat.com" <jcm@redhat.com>
Subject: Re: [RFC PATCH] lib/ioremap: Avoid triggering BUG_ON when end is not PAGE_ALIGN
Date: Fri, 30 Mar 2018 17:41:50 +0000	[thread overview]
Message-ID: <1522431689.2693.290.camel@hpe.com> (raw)
In-Reply-To: <1522385385-7074-1-git-send-email-xieyisheng1@huawei.com>

On Fri, 2018-03-30 at 12:49 +0800, Yisheng Xie wrote:
> Zhou reported a bug on Hisilicon arm64 D06 platform with 64KB page size:
 :
> The cause is the size of PCI IO resource is 32KB, which is 4K aligned but
> not 64KB aligned, so when do ioremap_pte_range(), its incoming end is not
> PAGE_ALIGN on 64KB page size system, but ioremap_pte_range increase the
> addr by PAGE_SIZE, which makes addr != end until trigger BUG_ON.
> 
> This patch introduces pte_addr_end(addr, end) to resolve this problem, just
> as what pmd_addr_end do. When end is not PAGE_ALIGN, it will return end
> instead of addr + PAGE_SIZE, therefore ioremap_pte_range() can break out
> when real end is coming.

ioremap_pte_range() assumes that addr and end are aligned by PAGE_SIZE. 
While some improvement can be made in the range check and documentation,
 I do not think it is safe for letting this library function to map
outside of a requested range blindly.

Can you change the caller of ioremap_page_range() to align the request
by PAGE_SIZE so that the caller is aware of what it's asking for? 

Thanks,
-Toshi

  reply	other threads:[~2018-03-30 17:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-30  4:49 [RFC PATCH] lib/ioremap: Avoid triggering BUG_ON when end is not PAGE_ALIGN Yisheng Xie
2018-03-30 17:41 ` Kani, Toshi [this message]
2018-03-31  1:27   ` Yisheng Xie

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=1522431689.2693.290.camel@hpe.com \
    --to=toshi.kani@hpe.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=guohanjun@huawei.com \
    --cc=jcm@redhat.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tanxiaojun@huawei.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=xieyisheng1@huawei.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