[lkml]   [2009]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [BUG 2.6.31-rc1] HIGHMEM64G causes hang in PCI init on 32-bit x86
    H. Peter Anvin wrote:
    > Mikael Pettersson wrote:
    >> Thanks, 2.6.31-rc1 vanilla (which didn't boot) plus this one does boot.
    >> /proc/iomem now looks as follows:
    > ... as it should. So far so good, and this is a real problem.
    > However, there is something that really bothers me: *why does this help
    > on Mikael's system, which is PAE and therefore has a 64-bit
    > resource_size_t*? This whole patch should be a no-op! There is still
    > something that doesn't make sense.
    > The use of "unsigned long" in ram_alignment() will overflow after 2^52
    > bytes, but again, that's not the issue here, since the highest "start"
    > value we have is (0x2 << 32).
    > By process of elimination, the culprit must be round_up(), which reveals
    > that the macro definition of round_up() has a *very* sublte behavior
    > with mixed types:
    > #define round_up(x, y) (((x) + (y) - 1) & ~((y) - 1))
    > ram_alignment() returns unsigned long, which becomes (y). This means
    > that the mask word on the right hand of the & gets truncated to 32 bits
    > *before* the masking happens -- since ((y) - 1) is still unsigned long,
    > inverting it will not set bits [63..32] to on.
    > I think this macro is actively dangerous. Better would be:
    > ({ __typeof__(x) __mask = (y)-1; ((x)+__mask) & ~__mask; })
    > ... which is also multiple-inclusion-free at the cost of using gcc
    > ({...}) constructs.
    > The deep irony in this is that in our particular case is perhaps that
    > align_up(x,y)-1 is the same thing as x | (y-1) which would have avoided
    > the problem...

    agreed, that is why we change round_up to take u64.

    wonder if we should kill round_up and use roundup instead.

    in include/linux/kernel.h
    #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))


     \ /
      Last update: 2009-06-30 21:37    [W:0.023 / U:18.652 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site