public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: "Huang, Ying" <ying.huang@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>, Andi Kleen <ak@suse.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86: ioremap_nocache fix
Date: Fri, 25 Jan 2008 11:27:38 +0100	[thread overview]
Message-ID: <20080125102738.GQ23708@elte.hu> (raw)
In-Reply-To: <1201238561.15972.17.camel@caritas-dev.intel.com>


* Huang, Ying <ying.huang@intel.com> wrote:

> This patch fixes a bug of ioremap_nocache. ioremap_nocache() will call 
> __ioremap() with flags != 0 to do the real work, which will call 
> change_page_attr_addr() if phys_addr + size - 1 < (end_pfn_map << 
> PAGE_SHIFT). But some pages between 0 ~ end_pfn_map << PAGE_SHIFT are 
> not mapped by identity map, this will make change_page_attr_addr 
> failed.

very interesting! Is this in response to a bug you've triggered?

i believe the scenario you outlne could trigger on 64-bit boxen, if they 
try to ioremap an area not covered by the direct ptes:

> @@ -41,8 +41,15 @@ ioremap_change_attr(unsigned long phys_a
>  	if (phys_addr + size - 1 < (end_pfn_map << PAGE_SHIFT)) {
>  		unsigned long npages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
>  		unsigned long vaddr = (unsigned long) __va(phys_addr);
> +		int level;
>  
>  		/*
> +		 * If there is no identity map for this address,
> +		 * change_page_attr_addr is unnecessary
> +		 */
> +		if (!lookup_address(vaddr, &level))
> +			return err;
> +		/*

and we'd incorrectly fail the ioremap() with -EINVAL, and return a hard 
error to the driver - and causing broken boxes, right?

Thomas has unified most of ioremap*.c as well, and we'll make sure this 
fix survives the unification. The 64-bit code limped along before by 
accident, because the (pre-cleanup) 64-bit __change_page_attr() code 
incorrectly returned 0 for invalid ranges:

        kpte = lookup_address(address);
        if (!kpte) return 0;

which masked the bug you fixed now. 32-bit always returned -EINVAL on 
invalid ranges.

	Ingo

  reply	other threads:[~2008-01-25 10:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-25  5:22 [PATCH] x86: ioremap_nocache fix Huang, Ying
2008-01-25 10:27 ` Ingo Molnar [this message]
2008-01-25 13:50   ` huang ying

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=20080125102738.GQ23708@elte.hu \
    --to=mingo@elte.hu \
    --cc=ak@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=ying.huang@intel.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