public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -fixes v2] riscv: Sparse-Memory/vmemmap out-of-bounds fix
@ 2024-02-29 19:17 Dimitris Vlachos
  2024-02-29 22:10 ` patchwork-bot+linux-riscv
  0 siblings, 1 reply; 2+ messages in thread
From: Dimitris Vlachos @ 2024-02-29 19:17 UTC (permalink / raw)
  To: linux-riscv, linux-kernel, palmer, alexghiti, paul.walmsley
  Cc: clameter, akpm, rppt, arnd, mick, csd4492, maraz

Offset vmemmap so that the first page of vmemmap will be mapped
to the first page of physical memory in order to ensure that
vmemmap’s bounds will be respected during
pfn_to_page()/page_to_pfn() operations.
The conversion macros will produce correct SV39/48/57 addresses
for every possible/valid DRAM_BASE inside the physical memory limits.

v2:Address Alex's comments

Suggested-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Dimitris Vlachos <dvlachos@ics.forth.gr>
Reported-by: Dimitris Vlachos <dvlachos@ics.forth.gr>
Closes: https://lore.kernel.org/linux-riscv/20240202135030.42265-1-csd4492@csd.uoc.gr
Fixes: d95f1a542c3d ("RISC-V: Implement sparsemem")
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
---
 arch/riscv/include/asm/pgtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 0c94260b5..875c9a079 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -84,7 +84,7 @@
  * Define vmemmap for pfn_to_page & page_to_pfn calls. Needed if kernel
  * is configured with CONFIG_SPARSEMEM_VMEMMAP enabled.
  */
-#define vmemmap		((struct page *)VMEMMAP_START)
+#define vmemmap		((struct page *)VMEMMAP_START - (phys_ram_base >> PAGE_SHIFT))
 
 #define PCI_IO_SIZE      SZ_16M
 #define PCI_IO_END       VMEMMAP_START
-- 
2.39.2


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

* Re: [PATCH -fixes v2] riscv: Sparse-Memory/vmemmap out-of-bounds fix
  2024-02-29 19:17 [PATCH -fixes v2] riscv: Sparse-Memory/vmemmap out-of-bounds fix Dimitris Vlachos
@ 2024-02-29 22:10 ` patchwork-bot+linux-riscv
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-02-29 22:10 UTC (permalink / raw)
  To: Dimitris Vlachos
  Cc: linux-riscv, linux-kernel, palmer, alexghiti, paul.walmsley,
	clameter, akpm, rppt, arnd, mick, csd4492, maraz

Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Thu, 29 Feb 2024 21:17:23 +0200 you wrote:
> Offset vmemmap so that the first page of vmemmap will be mapped
> to the first page of physical memory in order to ensure that
> vmemmap’s bounds will be respected during
> pfn_to_page()/page_to_pfn() operations.
> The conversion macros will produce correct SV39/48/57 addresses
> for every possible/valid DRAM_BASE inside the physical memory limits.
> 
> [...]

Here is the summary with links:
  - [-fixes,v2] riscv: Sparse-Memory/vmemmap out-of-bounds fix
    https://git.kernel.org/riscv/c/a11dd49dcb93

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-02-29 22:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-29 19:17 [PATCH -fixes v2] riscv: Sparse-Memory/vmemmap out-of-bounds fix Dimitris Vlachos
2024-02-29 22:10 ` patchwork-bot+linux-riscv

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