From: Ingo Molnar <mingo@elte.hu>
To: Andi Kleen <andi@firstfloor.org>
Cc: 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 17:03:23 +0100 [thread overview]
Message-ID: <20080214160322.GA27530@elte.hu> (raw)
In-Reply-To: <20080214115905.GA18573@basil.nowhere.org>
* 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.)
Have you tried to boot this patch on 32-bit? There are a couple of new
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,
Ingo
next prev parent reply other threads:[~2008-02-14 16:03 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 [this message]
2008-02-14 17:14 ` Andi Kleen
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=20080214160322.GA27530@elte.hu \
--to=mingo@elte.hu \
--cc=andi@firstfloor.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.