Linux MIPS Architecture development
 help / color / mirror / Atom feed
* c17a6554 broke 64BIT_PHYS_ADDR for 32 bit systems
@ 2013-04-17 18:11 Thomas Lange
  2013-04-23 15:14 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Lange @ 2013-04-17 18:11 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

Dear Ralf,

commit c17a6554 unintentionally(?) modified the PAGE_MASK type
from (int) to (long unsigned int).

This breaks ioremap (and possibly more) when using 64BIT_PHYS_ADDR on
32 bit systems.
Example of failing code from ioremap.c:

	phys_addr &= PAGE_MASK;

Since phys_addr is 64 bit (unsigned long long) when 64BIT_PHYS_ADDR and
PAGE_MASK is 32bit (long unsigned int), the upper 32 bits will always
be zeroed which is not what we want/expect.

The code above works if PAGE_MASK is a _signed_ 32bit int though.

Some possible fixes:

A) Simply revert the commit. Makes ioremap work again, but then PAGE_MASK
    is a signed int. Do we really want a mask that is 'signed'?

B) Don't use PAGE_MASK for physical addresses. x86 defines this:

   /* Cast PAGE_MASK to a signed type so that it is sign-extended if
      virtual addresses are 32-bits but physical addresses are larger
      (ie, 32-bit PAE). */
   #define PHYSICAL_PAGE_MASK	(((signed long)PAGE_MASK) & __PHYSICAL_MASK)

   Perhaps mips need something similar?


This is an issue with 3.8 and doesn't seem to be solved in master either.

Regards,
/Thomas

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c17a6554 broke 64BIT_PHYS_ADDR for 32 bit systems
  2013-04-17 18:11 c17a6554 broke 64BIT_PHYS_ADDR for 32 bit systems Thomas Lange
@ 2013-04-23 15:14 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2013-04-23 15:14 UTC (permalink / raw)
  To: Thomas Lange; +Cc: Ralf Baechle, Linux MIPS Mailing List

On Wed, Apr 17, 2013 at 8:11 PM, Thomas Lange <thomas@corelatus.se> wrote:
> commit c17a6554 unintentionally(?) modified the PAGE_MASK type
> from (int) to (long unsigned int).
>
> This breaks ioremap (and possibly more) when using 64BIT_PHYS_ADDR on
> 32 bit systems.
> Example of failing code from ioremap.c:
>
>         phys_addr &= PAGE_MASK;
>
> Since phys_addr is 64 bit (unsigned long long) when 64BIT_PHYS_ADDR and
> PAGE_MASK is 32bit (long unsigned int), the upper 32 bits will always
> be zeroed which is not what we want/expect.
>
> The code above works if PAGE_MASK is a _signed_ 32bit int though.
>
> Some possible fixes:
>
> A) Simply revert the commit. Makes ioremap work again, but then PAGE_MASK
>    is a signed int. Do we really want a mask that is 'signed'?

Already fixed, cfr. https://lkml.org/lkml/2013/4/22/518

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-23 15:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-17 18:11 c17a6554 broke 64BIT_PHYS_ADDR for 32 bit systems Thomas Lange
2013-04-23 15:14 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox