LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andi Kleen <andi@firstfloor.org>,
	torvalds@osdl.org, tglx@linutronix.de,
	linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] Fix direct mapping correctly in ioremap
Date: Thu, 14 Feb 2008 18:14:02 +0100	[thread overview]
Message-ID: <20080214171402.GB16255@one.firstfloor.org> (raw)
In-Reply-To: <20080214160322.GA27530@elte.hu>

On Thu, Feb 14, 2008 at 05:03:23PM +0100, Ingo Molnar wrote:
> 
> * Andi Kleen <andi@firstfloor.org> wrote:
> 
> > -	if (ioremap_change_attr(vaddr, size, mode) < 0) {
> > +	/* Fix up the direct mapping for the new cache attributes */
> > +	err = ioremap_change_attr((unsigned long)__va(phys_addr),
> > +				size + offset, mode);
> 
> Ugh. This would break the 32-bit kernel - if any phys_addr larger than 
> 1GB is passed in (which is the common case on 32-bit) then we'll start 
> changing the attributes of random (most likely user-space) pages!
> That is because on 32-bit __va() does this:
> 
>   #define __va(x)                  ((void *)((unsigned long)(x)+PAGE_OFFSET))
> 
> where on 32-bit 3GB:1GB split PAGE_OFFSET is defined to 0xc0000000.
> 
> So if a driver passes in the physical address of a PCI device with a BAR 
> at 0xe1000000 somewhere in the PCI aperture, we'll get 
> 0xe1000000+0xc0000000 == 0x91000000 - right in the middle of user-space.
> 
> Changing attributes there is very wrong. (it could even crash the kernel 
> in certain circumstances.)

True. It needs a end_pfn_map check.  I'll revise.

> Have you tried to boot this patch on 32-bit? There are a couple of new 

Yes, it booted on several machines.  Don't think I saw CPA messages,
but i might have missed them.

> safety nets in the cpa code that would/should trigger very visibly - 
> such as the warning here:
> 
>                 if (!pte_val(old_pte)) {
>                         printk(KERN_WARNING "CPA: called for zero pte. "
>                                "vaddr = %lx cpa->vaddr = %lx\n", address,
>                                 cpa->vaddr);
>                         WARN_ON(1);
>                         return -EINVAL;
>                 }
> 
> (these are already there in -git)
> 
> Please have a look at how we solved the "secondary alias" 64-bit problem 
> in x86.git#mm and please resend against x86.git#mm if you still think 
> something is missing. Thanks,

I want this regression fixed in .25, so #mm is not an option for this.

-Andi


      reply	other threads:[~2008-02-14 16:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-14 11:59 [PATCH] Fix direct mapping correctly in ioremap Andi Kleen
2008-02-14 16:03 ` Ingo Molnar
2008-02-14 17:14   ` Andi Kleen [this message]

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=20080214171402.GB16255@one.firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=torvalds@osdl.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).