linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc64/kasan: Pass virtual addresses to kasan_init_phys_region()
@ 2024-02-12  4:50 Benjamin Gray
  2024-05-08 13:39 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Gray @ 2024-02-12  4:50 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Benjamin Gray

The kasan_init_phys_region() function maps shadow pages necessary for
the ranges of the linear map backed by physical pages. Currently
kasan_init_phys_region() is being passed physical addresses, but
kasan_mem_to_shadow() expects virtual addresses.

It works right now because the lower bits (12:64) of the
kasan_mem_to_shadow() calculation are the same for the real and virtual
addresses, so the actual PTE value is the same in the end. But virtual
addresses are the intended input, so fix it.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
---
 arch/powerpc/mm/kasan/init_book3e_64.c | 2 +-
 arch/powerpc/mm/kasan/init_book3s_64.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/mm/kasan/init_book3e_64.c b/arch/powerpc/mm/kasan/init_book3e_64.c
index 11519e88dc6b..43c03b84ff32 100644
--- a/arch/powerpc/mm/kasan/init_book3e_64.c
+++ b/arch/powerpc/mm/kasan/init_book3e_64.c
@@ -112,7 +112,7 @@ void __init kasan_init(void)
 	pte_t zero_pte = pfn_pte(virt_to_pfn(kasan_early_shadow_page), PAGE_KERNEL_RO);
 
 	for_each_mem_range(i, &start, &end)
-		kasan_init_phys_region((void *)start, (void *)end);
+		kasan_init_phys_region(phys_to_virt(start), phys_to_virt(end));
 
 	if (IS_ENABLED(CONFIG_KASAN_VMALLOC))
 		kasan_remove_zero_shadow((void *)VMALLOC_START, VMALLOC_SIZE);
diff --git a/arch/powerpc/mm/kasan/init_book3s_64.c b/arch/powerpc/mm/kasan/init_book3s_64.c
index 9300d641cf9a..3fb5ce4f48f4 100644
--- a/arch/powerpc/mm/kasan/init_book3s_64.c
+++ b/arch/powerpc/mm/kasan/init_book3s_64.c
@@ -62,7 +62,7 @@ void __init kasan_init(void)
 	}
 
 	for_each_mem_range(i, &start, &end)
-		kasan_init_phys_region((void *)start, (void *)end);
+		kasan_init_phys_region(phys_to_virt(start), phys_to_virt(end));
 
 	for (i = 0; i < PTRS_PER_PTE; i++)
 		__set_pte_at(&init_mm, (unsigned long)kasan_early_shadow_page,
-- 
2.43.0


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

* Re: [PATCH] powerpc64/kasan: Pass virtual addresses to kasan_init_phys_region()
  2024-02-12  4:50 [PATCH] powerpc64/kasan: Pass virtual addresses to kasan_init_phys_region() Benjamin Gray
@ 2024-05-08 13:39 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2024-05-08 13:39 UTC (permalink / raw)
  To: linuxppc-dev, Benjamin Gray

On Mon, 12 Feb 2024 15:50:20 +1100, Benjamin Gray wrote:
> The kasan_init_phys_region() function maps shadow pages necessary for
> the ranges of the linear map backed by physical pages. Currently
> kasan_init_phys_region() is being passed physical addresses, but
> kasan_mem_to_shadow() expects virtual addresses.
> 
> It works right now because the lower bits (12:64) of the
> kasan_mem_to_shadow() calculation are the same for the real and virtual
> addresses, so the actual PTE value is the same in the end. But virtual
> addresses are the intended input, so fix it.
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc64/kasan: Pass virtual addresses to kasan_init_phys_region()
      https://git.kernel.org/powerpc/c/295454eda97b9c5f7a64ac5c2bb827fd15efb623

cheers

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

end of thread, other threads:[~2024-05-08 13:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-12  4:50 [PATCH] powerpc64/kasan: Pass virtual addresses to kasan_init_phys_region() Benjamin Gray
2024-05-08 13:39 ` Michael Ellerman

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 NNTP newsgroup(s).