All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Andrew Morton <akpm@linux-foundation.org>,
	Geert Uytterhoeven <geert@linux-m68k.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>
Cc: 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,
	linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Ghiti <alexghiti@rivosinc.com>
Subject: [PATCH v3 04/12] riscv: mm: init: Pass a pointer to virt_to_page()
Date: Tue, 23 May 2023 16:05:28 +0200	[thread overview]
Message-ID: <20230503-virt-to-pfn-v6-4-rc1-v3-4-a16c19c03583@linaro.org> (raw)
In-Reply-To: <20230503-virt-to-pfn-v6-4-rc1-v3-0-a16c19c03583@linaro.org>

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 this in the RISCV mm init code, so we can implement
a strongly typed virt_to_pfn().

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/riscv/mm/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 747e5b1ef02d..2f7a7c345a6a 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -356,7 +356,7 @@ static phys_addr_t __init alloc_pte_late(uintptr_t va)
 	unsigned long vaddr;
 
 	vaddr = __get_free_page(GFP_KERNEL);
-	BUG_ON(!vaddr || !pgtable_pte_page_ctor(virt_to_page(vaddr)));
+	BUG_ON(!vaddr || !pgtable_pte_page_ctor(virt_to_page((void *)vaddr)));
 
 	return __pa(vaddr);
 }
@@ -439,7 +439,7 @@ static phys_addr_t __init alloc_pmd_late(uintptr_t va)
 	unsigned long vaddr;
 
 	vaddr = __get_free_page(GFP_KERNEL);
-	BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page(vaddr)));
+	BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page((void *)vaddr)));
 
 	return __pa(vaddr);
 }

-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
From: Linus Walleij <linus.walleij@linaro.org>
To: Andrew Morton <akpm@linux-foundation.org>,
	 Geert Uytterhoeven <geert@linux-m68k.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>
Cc: 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,
	 linux-arm-kernel@lists.infradead.org,
	linux-arch@vger.kernel.org,
	 Linus Walleij <linus.walleij@linaro.org>,
	 Alexandre Ghiti <alexghiti@rivosinc.com>
Subject: [PATCH v3 04/12] riscv: mm: init: Pass a pointer to virt_to_page()
Date: Tue, 23 May 2023 16:05:28 +0200	[thread overview]
Message-ID: <20230503-virt-to-pfn-v6-4-rc1-v3-4-a16c19c03583@linaro.org> (raw)
In-Reply-To: <20230503-virt-to-pfn-v6-4-rc1-v3-0-a16c19c03583@linaro.org>

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 this in the RISCV mm init code, so we can implement
a strongly typed virt_to_pfn().

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/riscv/mm/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 747e5b1ef02d..2f7a7c345a6a 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -356,7 +356,7 @@ static phys_addr_t __init alloc_pte_late(uintptr_t va)
 	unsigned long vaddr;
 
 	vaddr = __get_free_page(GFP_KERNEL);
-	BUG_ON(!vaddr || !pgtable_pte_page_ctor(virt_to_page(vaddr)));
+	BUG_ON(!vaddr || !pgtable_pte_page_ctor(virt_to_page((void *)vaddr)));
 
 	return __pa(vaddr);
 }
@@ -439,7 +439,7 @@ static phys_addr_t __init alloc_pmd_late(uintptr_t va)
 	unsigned long vaddr;
 
 	vaddr = __get_free_page(GFP_KERNEL);
-	BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page(vaddr)));
+	BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page((void *)vaddr)));
 
 	return __pa(vaddr);
 }

-- 
2.34.1


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

WARNING: multiple messages have this Message-ID (diff)
From: Linus Walleij <linus.walleij@linaro.org>
To: Andrew Morton <akpm@linux-foundation.org>,
	 Geert Uytterhoeven <geert@linux-m68k.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>
Cc: 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,
	 linux-arm-kernel@lists.infradead.org,
	linux-arch@vger.kernel.org,
	 Linus Walleij <linus.walleij@linaro.org>,
	 Alexandre Ghiti <alexghiti@rivosinc.com>
Subject: [PATCH v3 04/12] riscv: mm: init: Pass a pointer to virt_to_page()
Date: Tue, 23 May 2023 16:05:28 +0200	[thread overview]
Message-ID: <20230503-virt-to-pfn-v6-4-rc1-v3-4-a16c19c03583@linaro.org> (raw)
In-Reply-To: <20230503-virt-to-pfn-v6-4-rc1-v3-0-a16c19c03583@linaro.org>

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 this in the RISCV mm init code, so we can implement
a strongly typed virt_to_pfn().

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/riscv/mm/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 747e5b1ef02d..2f7a7c345a6a 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -356,7 +356,7 @@ static phys_addr_t __init alloc_pte_late(uintptr_t va)
 	unsigned long vaddr;
 
 	vaddr = __get_free_page(GFP_KERNEL);
-	BUG_ON(!vaddr || !pgtable_pte_page_ctor(virt_to_page(vaddr)));
+	BUG_ON(!vaddr || !pgtable_pte_page_ctor(virt_to_page((void *)vaddr)));
 
 	return __pa(vaddr);
 }
@@ -439,7 +439,7 @@ static phys_addr_t __init alloc_pmd_late(uintptr_t va)
 	unsigned long vaddr;
 
 	vaddr = __get_free_page(GFP_KERNEL);
-	BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page(vaddr)));
+	BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page((void *)vaddr)));
 
 	return __pa(vaddr);
 }

-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-05-23 14:07 UTC|newest]

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

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=20230503-virt-to-pfn-v6-4-rc1-v3-4-a16c19c03583@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexghiti@rivosinc.com \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=geert@linux-m68k.org \
    --cc=gerg@linux-m68k.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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.