[PATCH] powerpc: Fix signature of pfn_to_kaddr()

Michael Ellerman mpe at ellerman.id.au
Fri Nov 10 17:16:52 AEDT 2023

Linus Walleij <linus.walleij at linaro.org> writes:
> On Tue, Nov 7, 2023 at 6:57 AM Michael Ellerman <mpe at ellerman.id.au> wrote:
>> I'm struggling to connect the removal of const with those bug reports.
>> It looks like all those warnings are about 0xc000000000000000 being
>> outside the range of unsigned long when building 32-bit.
> Aha right. I wonder what actually causes that.

It is the 32-bit VDSO being built:

      VDSO32C arch/powerpc/kernel/vdso/vgettimeofday-32.o
    In file included from <built-in>:4:
    In file included from /home/michael/linux/lib/vdso/gettimeofday.c:5:
    In file included from ../include/vdso/datapage.h:137:
    In file included from ../arch/powerpc/include/asm/vdso/gettimeofday.h:7:
    ../arch/powerpc/include/asm/page.h:230:9: warning: result of comparison of constant 13835058055282163712 with expression of type 'unsigned long' is always true [-Wtautological-constant-out-of-range-compare]
      230 |         return __pa(kaddr) >> PAGE_SHIFT;
          |                ^~~~~~~~~~~
    ../arch/powerpc/include/asm/page.h:217:37: note: expanded from macro '__pa'
      217 |         VIRTUAL_WARN_ON((unsigned long)(x) < PAGE_OFFSET);              \
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
    ../arch/powerpc/include/asm/page.h:202:73: note: expanded from macro 'VIRTUAL_WARN_ON'
      202 | #define VIRTUAL_WARN_ON(x)      WARN_ON(IS_ENABLED(CONFIG_DEBUG_VIRTUAL) && (x))
          |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
    ../arch/powerpc/include/asm/bug.h:88:25: note: expanded from macro 'WARN_ON'
       88 |         int __ret_warn_on = !!(x);                              \
          |                                ^

Which is a bit of a frankenstein, because we're building 32-bit VDSO
code for a 64-bit kernel, and using some of the kernel headers for that.

So the warning is correct, we are doing a tautological comparison.
Except that we're not actually using that code in the VDSO, it's just
included in the VDSO because it needs PAGE_SHIFT.

Anyway none of that is your fault, you just had the misfortune of
touching page.h :)

I think I see a way to clean it up. Will send a patch.


More information about the Linuxppc-dev mailing list