From patchwork Wed Jan 26 09:26:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12724762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBA31C2BA4C for ; Wed, 26 Jan 2022 09:26:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CF406B0074; Wed, 26 Jan 2022 04:26:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 07F436B0075; Wed, 26 Jan 2022 04:26:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAFEA6B0078; Wed, 26 Jan 2022 04:26:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0072.hostedemail.com [216.40.44.72]) by kanga.kvack.org (Postfix) with ESMTP id DCADF6B0074 for ; Wed, 26 Jan 2022 04:26:47 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8E70B56461 for ; Wed, 26 Jan 2022 09:26:47 +0000 (UTC) X-FDA: 79071908454.14.8119F8F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf14.hostedemail.com (Postfix) with ESMTP id 9D476100009 for ; Wed, 26 Jan 2022 09:26:46 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JkJCr5n5GzZfJv; Wed, 26 Jan 2022 17:22:48 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan 2022 17:26:43 +0800 From: Miaohe Lin To: CC: , , Subject: [PATCH] mm/memremap: avoid calling kasan_remove_zero_shadow() for device private memory Date: Wed, 26 Jan 2022 17:26:02 +0800 Message-ID: <20220126092602.1425-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9D476100009 X-Rspam-User: nil Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: gkpirqtpz5capikbhhoskp6445dcfyni X-HE-Tag: 1643189206-869875 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001878, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: Muchun Song --- 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: