Linux SNPS ARC Archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vineet Gupta <vgupta@kernel.org>,
	 Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	 Russell King <linux@armlinux.org.uk>,
	Greg Ungerer <gerg@linux-m68k.org>,
	linux-mm@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-m68k@lists.linux-m68k.org,
	 linux-snps-arc@lists.infradead.org,
	linux-fsdevel@vger.kernel.org,  linux-cifs@vger.kernel.org,
	samba-technical@lists.samba.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-arch@vger.kernel.org
Subject: Re: [PATCH v2 02/12] m68k: Pass a pointer to virt_to_pfn() virt_to_page()
Date: Mon, 22 May 2023 12:11:27 +0200	[thread overview]
Message-ID: <CAMuHMdXB1fK_G=QZ59qkJWXhb61TyLRMwH3qo_0sSmW0Cfv8hA@mail.gmail.com> (raw)
In-Reply-To: <20230503-virt-to-pfn-v6-4-rc1-v2-2-0948d38bddab@linaro.org>

Hi Linus,

On Mon, May 22, 2023 at 9:00 AM Linus Walleij <linus.walleij@linaro.org> 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@linux-m68k.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

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@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

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

  reply	other threads:[~2023-05-22 10:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22  7:00 [PATCH v2 00/12] arch: Make virt_to_pfn into a static inline Linus Walleij
2023-05-22  7:00 ` [PATCH v2 01/12] fs/proc/kcore.c: Pass a pointer to virt_addr_valid() Linus Walleij
2023-05-22  7:00 ` [PATCH v2 02/12] m68k: Pass a pointer to virt_to_pfn() virt_to_page() Linus Walleij
2023-05-22 10:11   ` Geert Uytterhoeven [this message]
2023-05-22  7:00 ` [PATCH v2 03/12] ARC: init: Pass a pointer to virt_to_pfn() in init Linus Walleij
2023-05-22  7:00 ` [PATCH v2 04/12] riscv: mm: init: Pass a pointer to virt_to_page() Linus Walleij
2023-05-22  7:00 ` [PATCH v2 05/12] cifs: " Linus Walleij
2023-05-22  7:00 ` [PATCH v2 06/12] cifs: Pass a pointer to virt_to_page() in cifsglob Linus Walleij
2023-05-22  7:00 ` [PATCH v2 07/12] netfs: Pass a pointer to virt_to_page() Linus Walleij
2023-05-22  7:00 ` [PATCH v2 08/12] arm64: vdso: Pass (void *) " Linus Walleij
2023-05-22  7:00 ` [PATCH v2 09/12] asm-generic/page.h: Make pfn accessors static inlines Linus Walleij
2023-05-22  7:00 ` [PATCH v2 10/12] ARM: mm: Make virt_to_pfn() a static inline Linus Walleij
2023-05-22  7:00 ` [PATCH v2 11/12] arm64: memory: " Linus Walleij
2023-05-22  7:00 ` [PATCH v2 12/12] m68k/mm: Make pfn accessors static inlines Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMuHMdXB1fK_G=QZ59qkJWXhb61TyLRMwH3qo_0sSmW0Cfv8hA@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=gerg@linux-m68k.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-mm@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=samba-technical@lists.samba.org \
    --cc=vgupta@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).