linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memremap: avoid calling kasan_remove_zero_shadow() for device private memory
@ 2022-01-26  9:26 Miaohe Lin
  2022-01-26 10:06 ` Muchun Song
  0 siblings, 1 reply; 2+ messages in thread
From: Miaohe Lin @ 2022-01-26  9:26 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe

For device private memory, we do not create a linear mapping for the memory
because the device memory is un-accessible. Thus we do not add kasan zero
shadow for it. So it's unnecessary to do kasan_remove_zero_shadow() for it.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memremap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/memremap.c b/mm/memremap.c
index d2a72cf2ff83..d9e05952fff6 100644
--- a/mm/memremap.c
+++ b/mm/memremap.c
@@ -302,7 +302,8 @@ static int pagemap_range(struct dev_pagemap *pgmap, struct mhp_params *params,
 	return 0;
 
 err_add_memory:
-	kasan_remove_zero_shadow(__va(range->start), range_len(range));
+	if (!is_private)
+		kasan_remove_zero_shadow(__va(range->start), range_len(range));
 err_kasan:
 	untrack_pfn(NULL, PHYS_PFN(range->start), range_len(range));
 err_pfn_remap:
-- 
2.23.0



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

* Re: [PATCH] mm/memremap: avoid calling kasan_remove_zero_shadow() for device private memory
  2022-01-26  9:26 [PATCH] mm/memremap: avoid calling kasan_remove_zero_shadow() for device private memory Miaohe Lin
@ 2022-01-26 10:06 ` Muchun Song
  0 siblings, 0 replies; 2+ messages in thread
From: Muchun Song @ 2022-01-26 10:06 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: Andrew Morton, Linux Memory Management List, LKML

On Wed, Jan 26, 2022 at 5:27 PM Miaohe Lin <linmiaohe@huawei.com> wrote:
>
> For device private memory, we do not create a linear mapping for the memory
> because the device memory is un-accessible. Thus we do not add kasan zero
> shadow for it. So it's unnecessary to do kasan_remove_zero_shadow() for it.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Good catch.

Reviewed-by: Muchun Song <songmuchun@bytedance.com>


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

end of thread, other threads:[~2022-01-26 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26  9:26 [PATCH] mm/memremap: avoid calling kasan_remove_zero_shadow() for device private memory Miaohe Lin
2022-01-26 10:06 ` Muchun Song

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).