[PATCH] ARM: Stricten arguments to virt_to_pfn()
Geert Uytterhoeven
geert at linux-m68k.org
Mon May 16 05:30:25 PDT 2022
Hi Linus,
Thanks for your patch!
On Mon, May 16, 2022 at 2:18 PM Linus Walleij <linus.walleij at linaro.org> wrote:
> The kernel convention is that the argument passed to virt_to_pfn()
> (virtual address to page frame number) needs to be an unsigned long,
> but ARM has avoided this by including a cast to (unsigned long)
> inside the definition of virt_to_pfn() itself. This creates problems
> if we want to make virt_to_pfn() an actual function with a typed argument,
> so fix up the offending call sites.
IMHO this is a step in the wrong direction: a virtual address should
use "void *".
See also e.g. virt_to_phys() on both arm32 and arm64:
static inline phys_addr_t virt_to_phys(const volatile void *x)
{
return __virt_to_phys((unsigned long)(x));
}
BTW, virt_to_pfn() differs, though. Arm32 has:
#define virt_to_pfn(kaddr) \
((((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT) + \
PHYS_PFN_OFFSET)
while arm64 has:
#define virt_to_pfn(x)
__phys_to_pfn(__virt_to_phys((unsigned long)(x)))
In the latter, it is more ibvious the cast to "unsigned long" is there
because __virt_to_phys() takes "unsigned long". Perhaps this should
be made clearer by calling virt_to_phys() instead?.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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
More information about the linux-arm-kernel
mailing list