Re: [PATCH v2 02/12] m68k: Pass a pointer to virt_to_pfn() virt_to_page()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Linus,

On Mon, May 22, 2023 at 9:00 AM Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:
> Functions that work on a pointer to virtual memory such as
> virt_to_pfn() and users of that function such as
> virt_to_page() are supposed to pass a pointer to virtual
> memory, ideally a (void *) or other pointer. However since
> many architectures implement virt_to_pfn() as a macro,
> this function becomes polymorphic and accepts both a
> (unsigned long) and a (void *).
>
> Fix up the offending calls in arch/m68k with explicit casts.
>
> The page table include <asm/pgtable.h> will include different
> variants of the defines depending on whether you build for
> classic m68k, ColdFire or Sun3, so fix all variants.
>
> Tested-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

Thanks for the update!

> ---
> ChangeLog v2->v3:

v3?

> - Fix the sun3 pgtable macro to not cast to unsigned long.
> - Make a similar change to the ColdFire include.

The ColdFire change is not correct, cfr. below...

> ChangeLog v1->v2:
> - Add an extra parens around the page argument to the
>   PD_PTABLE() macro, as is normally required.
> ---
>  arch/m68k/include/asm/mcf_pgtable.h  | 4 ++--
>  arch/m68k/include/asm/sun3_pgtable.h | 4 ++--
>  arch/m68k/mm/mcfmmu.c                | 3 ++-
>  arch/m68k/mm/motorola.c              | 4 ++--
>  arch/m68k/mm/sun3mmu.c               | 2 +-
>  arch/m68k/sun3/dvma.c                | 2 +-
>  arch/m68k/sun3x/dvma.c               | 2 +-
>  7 files changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/arch/m68k/include/asm/mcf_pgtable.h b/arch/m68k/include/asm/mcf_pgtable.h
> index d97fbb812f63..f67c59336ab4 100644
> --- a/arch/m68k/include/asm/mcf_pgtable.h
> +++ b/arch/m68k/include/asm/mcf_pgtable.h
> @@ -115,8 +115,8 @@ static inline void pgd_set(pgd_t *pgdp, pmd_t *pmdp)
>         pgd_val(*pgdp) = virt_to_phys(pmdp);
>  }
>
> -#define __pte_page(pte)        ((unsigned long) (pte_val(pte) & PAGE_MASK))
> -#define pmd_page_vaddr(pmd)    ((unsigned long) (pmd_val(pmd)))
> +#define __pte_page(pte)        (__va (pte_val(pte) & PAGE_MASK))

I guess "__va(...)" should be "(void *)..." instead?

However, that will cause an issue below, as

    #define pte_pagenr(pte)        ((__pte_page(pte) - PAGE_OFFSET) >>
PAGE_SHIFT)

does depend on __pte_page() returning "unsigned long".
Fortunately pte_pagenr() appears unused, so it can be removed.

So for now, it might be simpler to add the cast to the caller.


> +#define pmd_page_vaddr(pmd)    (__va (pmd_val(pmd)))

This looks bogus, too, as it should return "unsigned long".

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux