Skip to contentSkip to conversation

mm/memremap: avoid calling kasan_remove_zero_shadow() for device private memory

PATCH Applied Miaohe Lin 2 participants 2 messages Jan 26, 2022

Subsystems (2)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH 1/1 mm/memremap: avoid calling kasan_remove_zero_shadow() for device private memory

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.

---
 mm/memremap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/memremap.c +2 -1
index d2a72cf2ff83..d9e05952fff6 100644
@@ -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:
Signature · 1 line
2.23.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Miaohe Lin

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.

Good catch.