[lkml]   [2008]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subjectwrong usage of MAX_DMA_ADDRESS in bootmem.h
    I have implemented highmem for ARM.  To catch wrong usage of __pa() and 
    __va() with out of range values, I added a range check when

    One issue is that bootmem.h uses __pa(MAX_DMA_ADDRESS). However
    MAX_DMA_ADDRESS on ARM is defined as 0xffffffff because there is usually
    no restriction on the maximum DMA-able address.

    RMK suggested that those places should be using ISA_DMA_THRESHOLD
    instead -- here's an excert of our conversation on this topic:

    > I suspect all those places which are doing __pa(MAX_DMA_ADDRESS) really
    > want to be using ISA_DMA_THRESHOLD - that's something to raise on LKML
    > if it's causing problems.
    > > > Given the definition I've just given, if there's no restrictions on
    > > > what can be DMA'd from, defining 'MAX_DMA_ADDRESS' to a constant well
    > > > in excess of the maximum amount of RAM is quite reasonable. Since most
    > > > ARM platforms don't have any restrictions on memory that can be DMA'd,
    > > > the existing code is perfectly reasonable and correct.
    > >
    > > It falls apart when the range check on values passed to __pa() is
    > > enabled in a highmem context.
    > As I say, having it in excess of the real amount of RAM fitted is not a
    > problem. Unfortunately, it makes the range check fall apart but I suspect
    > that's because of inappropriate use.

    So what about this patch?

    diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
    index 95837bf..7a97ffe 100644
    --- a/include/linux/bootmem.h
    +++ b/include/linux/bootmem.h
    @@ -96,21 +96,21 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
    unsigned long goal);
    #define alloc_bootmem(x) \
    - __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
    + __alloc_bootmem(x, SMP_CACHE_BYTES, ISA_DMA_THRESHOLD)
    #define alloc_bootmem_nopanic(x) \
    - __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
    + __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, ISA_DMA_THRESHOLD)
    #define alloc_bootmem_low(x) \
    __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0)
    #define alloc_bootmem_pages(x) \
    - __alloc_bootmem(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
    + __alloc_bootmem(x, PAGE_SIZE, ISA_DMA_THRESHOLD)
    #define alloc_bootmem_pages_nopanic(x) \
    - __alloc_bootmem_nopanic(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
    + __alloc_bootmem_nopanic(x, PAGE_SIZE, ISA_DMA_THRESHOLD)
    #define alloc_bootmem_low_pages(x) \
    __alloc_bootmem_low(x, PAGE_SIZE, 0)
    #define alloc_bootmem_node(pgdat, x) \
    - __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
    + __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, ISA_DMA_THRESHOLD)
    #define alloc_bootmem_pages_node(pgdat, x) \
    - __alloc_bootmem_node(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
    + __alloc_bootmem_node(pgdat, x, PAGE_SIZE, ISA_DMA_THRESHOLD)
    #define alloc_bootmem_low_pages_node(pgdat, x) \
    __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0)

     \ /
      Last update: 2008-09-30 21:37    [W:0.022 / U:2.568 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site