linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yaohui Wang <yaohuiwang@linux.alibaba.com>
To: Dave Hansen <dave.hansen@intel.com>, tglx@linutronix.de
Cc: luto@kernel.org, peterz@infradead.org, mingo@redhat.com,
	bp@alien8.de, x86@kernel.org, linux-kernel@vger.kernel.org,
	luoben@linux.alibaba.com, Tom Lendacky <thomas.lendacky@amd.com>,
	Brijesh Singh <brijesh.singh@amd.com>
Subject: Re: [PATCH v3 1/2] x86/ioremap: fix the pfn calculation mistake in __ioremap_check_ram()
Date: Mon, 5 Jul 2021 10:11:31 +0800	[thread overview]
Message-ID: <a857aeae-6507-d418-8798-83980cff3135@linux.alibaba.com> (raw)
In-Reply-To: <663229c2-1957-2af5-678c-5d553507f5f3@intel.com>



On 2021/7/2 22:49, Dave Hansen wrote:
> Do you know why this check:
> 
>> 	if ((res->flags & IORESOURCE_SYSTEM_RAM) != IORESOURCE_SYSTEM_RAM)
>> 		return false;
> 
> did not catch your out-of-tree driver's errant ioremap()?
>
If ioremap() is invoked on an area that contains normal memory, then:

	(res->flags & IORESOURCE_SYSTEM_RAM) == IORESOURCE_SYSTEM_RAM)

is true, so the original check is false. The code following the check
will continue to scan whether this area contains any page that is not
PageReserved (i.e. that is truly normal RAM).

Your idea should be:

	if ((res->flags & IORESOURCE_SYSTEM_RAM) == IORESOURCE_SYSTEM_RAM)
	return IORES_MAP_SYSTEM_RAM;

But this check is too strict as IORESOURCE_SYSTEM_RAM area may contain
PageReserved pages, and PageReserved pages should be ioremap-able. So
the checking logic of the original __ioremap_check_ram() function is
reasonable.


  reply	other threads:[~2021-07-05  2:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21 12:34 [PATCH v3 0/2] x86/ioremap: fix boundary calculation and boundary judgment issues for ioremap() Yaohui Wang
2021-06-21 12:34 ` [PATCH v3 1/2] x86/ioremap: fix the pfn calculation mistake in __ioremap_check_ram() Yaohui Wang
2021-07-01 14:41   ` Dave Hansen
2021-07-02 10:05     ` Yaohui Wang
2021-07-02 14:49       ` Dave Hansen
2021-07-05  2:11         ` Yaohui Wang [this message]
2021-06-21 12:34 ` [PATCH v3 2/2] kernel/resource: fix boundary judgment issues in find_next_iomem_res() and __walk_iomem_res_desc() Yaohui Wang
2021-07-01 16:29   ` Dave Hansen
2021-07-01  2:44 ` [PATCH v3 0/2] x86/ioremap: fix boundary calculation and boundary judgment issues for ioremap() Yaohui Wang

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=a857aeae-6507-d418-8798-83980cff3135@linux.alibaba.com \
    --to=yaohuiwang@linux.alibaba.com \
    --cc=bp@alien8.de \
    --cc=brijesh.singh@amd.com \
    --cc=dave.hansen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luoben@linux.alibaba.com \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@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 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).