public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <ak@muc.de>
To: David Hinds <dhinds@sonic.net>
Cc: linux-kernel@vger.kernel.org, torvalds@osdl.org
Subject: Re: PCI memory allocation bug with CONFIG_HIGHMEM
Date: Tue, 06 Jan 2004 04:32:41 +0100	[thread overview]
Message-ID: <m37k054uqu.fsf@averell.firstfloor.org> (raw)
In-Reply-To: <1aJdi-7TH-25@gated-at.bofh.it> (David Hinds's message of "Mon, 05 Jan 2004 21:10:20 +0100")

David Hinds <dhinds@sonic.net> writes:

> In arch/i386/kernel/setup.c we have:
>
> 	/* Tell the PCI layer not to allocate too close to the RAM area.. */
> 	low_mem_size = ((max_low_pfn << PAGE_SHIFT) + 0xfffff) & ~0xfffff;
> 	if (low_mem_size > pci_mem_start)
> 		pci_mem_start = low_mem_size;
>
> which is meant to round up pci_mem_start to the nearest 1 MB boundary
> past the top of physical RAM.  However this does not consider highmem.
> Should this just be using max_pfn rather than max_low_pfn?

max_pfn would get memory >4GB on highmem systems, which generally
doesn't work because many PCI devices only support 32bit addresses.

IMHO the only reliable way to get physical bus space for mappings
is to allocate some memory and map the mapping over that.
On x86-64 the allocation must be GFP_DMA, on i386 it can be GFP_KERNEL.

The problem is that BIOS commonly use physical address space without
marking it in the e820 map. For example the AGP aperture is normally
not marked in any way in the e820 map, but you definitely cannot reuse
its bus space. The old code assumed that there is a memory hole below
the highest memory address <4GB, but that can be not true on a system
with >3GB.

We unfortunately must assume on such systems that all holes in e820
space are already used by something. On a system with <3GB you 
are usually lucky because there is some space left, but even that
can break and e.g. conflict with reserved ACPI mappings. In theory
you could have a heuristic with something like "if E820_RAM is 
<2GB just allocate it after the highest E820_RAM map not conflicting
with other E820 mappings", but this would be quite hackish and 
may break on weird systems.

BTW drivers/char/mem.c makes the same broken assumption. It really
wants to default to uncached access for any holes, but default to
cached for real memory. Doing that also requires reliable hole detection,
which we don't have.

One approach I haven't checked is that the ACPI memory map may have
fixed the problem (no defined way to get a hole)

As long as you only have e820 I think there is no real alternative to
the "put io map over memory" technique.

-Andi

       reply	other threads:[~2004-01-06  3:33 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1aJdi-7TH-25@gated-at.bofh.it>
2004-01-06  3:32 ` Andi Kleen [this message]
2004-01-06  3:40   ` PCI memory allocation bug with CONFIG_HIGHMEM Linus Torvalds
2004-01-06  4:05     ` Andi Kleen
2004-01-06  5:04       ` Linus Torvalds
2004-01-06  8:12         ` Andi Kleen
2004-01-06  9:11           ` Mika Penttilä
2004-01-06  9:44             ` Andi Kleen
2004-01-06 10:16               ` Mika Penttilä
2004-01-06 10:49                 ` Andi Kleen
2004-01-06 15:27               ` Linus Torvalds
2004-01-06 15:37                 ` Andi Kleen
2004-01-06 15:48                   ` Linus Torvalds
2004-01-06 22:29                     ` Adam Belay
2004-01-07  4:06                       ` Linus Torvalds
2004-01-07  5:02                         ` Andi Kleen
2004-01-07  5:55                           ` Dave Jones
2004-01-07  6:06                             ` Linus Torvalds
2004-01-07  6:08                               ` Dave Jones
2004-01-07  6:45                                 ` Linus Torvalds
2004-01-07  6:51                             ` Andi Kleen
2004-01-07  2:43                               ` Adam Belay
2004-01-07  8:32                       ` Helge Hafting
2004-01-06 22:45                   ` Eric W. Biederman
2004-01-07  0:06                     ` Linus Torvalds
2004-01-07  4:58                       ` Eric W. Biederman
2004-01-07  5:32                         ` Linus Torvalds
2004-01-07 15:53                           ` Eric W. Biederman
2004-01-07 16:32                             ` Linus Torvalds
2004-01-07 17:32                               ` Eric W. Biederman
2004-01-08 19:34                               ` Eric W. Biederman
2004-01-07  9:31                         ` Russell King
2004-01-07 15:06                           ` Eric W. Biederman
2004-01-07 20:29                             ` Russell King
2004-01-06 22:56     ` Eric W. Biederman
2004-01-05 20:07 David Hinds
2004-01-05 23:00 ` Russell King
2004-01-05 23:45   ` David Hinds
2004-01-06  0:36 ` Linus Torvalds
2004-01-06  0:44   ` David Hinds
2004-01-06  1:11     ` Linus Torvalds
2004-01-06  1:41       ` Linus Torvalds

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=m37k054uqu.fsf@averell.firstfloor.org \
    --to=ak@muc.de \
    --cc=dhinds@sonic.net \
    --cc=linux-kernel@vger.kernel.org \
    --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