From patchwork Mon May 24 07:36:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 12276685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADAB8C04FF3 for ; Mon, 24 May 2021 17:20:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C4C0613EC for ; Mon, 24 May 2021 17:20:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C4C0613EC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=synaptics.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=D7ufJWy5gcDvnXTLk4M4k0tNTp4427+ThfGnrIn4hvo=; b=h41CiK0Yux04yy zWXaPCEppEo5lBQQ60SQ1OCM0eeyDS6Xiqe0o7/JUaFJecKOdKNcz5AENwjVeHOYVx41odzmOQHbR jepaJoEWtDC44m6M66lu250U8HOQqn97VvI9j9aFC8ybA+ym4tz4WtoeVcj/BpHPuZ8HsKBTwm4O1 gVUUmC19FGIs/nUUx+BFMKmXaUGvHpy3Jz9zkAXsQ0WxWRHWhk26OrqZdbP/upk7YzMsa1xLvQ6v3 VLoPZWSuM7ctg95JGiOzjmoIebdPl3NF0UpZpBPhXBvIVMTfd5robH9lWR28qUvkMTQDvtFlMwc39 YDcTersU2uA8ThgUTDsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1llED9-001FEB-Dx; Mon, 24 May 2021 17:17:55 +0000 Received: from mail-bn7nam10on2062.outbound.protection.outlook.com ([40.107.92.62] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ll5Ag-000kSW-H6 for linux-arm-kernel@lists.infradead.org; Mon, 24 May 2021 07:38:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kHS896E7PwneaJJZhHUva2IUXFja6lQkplYFhvjLeQh+QJt1B/KFCrXO0C2T5XBIRvQXLrT18pM2YaVSsQpSdXX+ygZdQI/DYePpF1E946PlL39n8Jrz5C0skBez6g/igB+AtHiXdys9She7oDginzBa1820FJ7JwqAm4zxo3GossuziWClC6g5CCDubRZBAIs6cOqcWbkkme+yTP6hqt06Bti25Gd20iLQqhOPiQenzQ+4pmllHpKVqn2EVDmKwEOaYXQUNSOKL+QSY3TfwjcbyIf96l5s1mdqlZvb8nk9wtzhr0743m3YQdHWv38+dGT5ky8gUaQP5Xr/Vq/TXHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NhvjebfPNXIOqyHNM2pJ78YbP5wPDI8MQw9MT8qppTE=; b=TMQerOUyRwlLhmoo15k5fdCCgqmOUz+HhV0SWqbvF9CW2MYwIUeRG+ceCOmyWv6r6zFFhDyBJiOmPLVp5vxoX894l/2kA9MKCrF9DIgzkjs3EVsGeuBuTccyxXF9pD+68l+uTCnbsgx8zGGBSuoEkl9NlJphpj5MpJDTOUT6y5RFvA+TMSN+dFjuQmsmPIF9oR7xKEO1wpur0spTXgLyh7pwrtgqpga4//NiSHDdDmz6DkRiq4h4QC39VHBGpPrCL7pyM3Ecv1imtc6Dpco0trvp70DcENr1V3k2zHlFJmACqjc9GTQ6OIsEGEnDePRC4x592Jo1eIktucnV7KSOOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NhvjebfPNXIOqyHNM2pJ78YbP5wPDI8MQw9MT8qppTE=; b=I5nUaLXinUzpLMdNPmRKTzXllJUsoG3l9+ASdc9Gj84oXER9U8RyhNtt5nv7TR1J5JMjcTpVQg4iJbauaqnQ2b5ZfdlmqbpRXFDSxssfyxhvmRH9mAT4lNqxrQ/ibdx5TB5CLyfVCishLeqGCv+SI0h7XV1KpbEQnmPoj0jZPls= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=synaptics.com; Received: from BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) by BN9PR03MB6089.namprd03.prod.outlook.com (2603:10b6:408:11a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Mon, 24 May 2021 07:38:37 +0000 Received: from BN9PR03MB6058.namprd03.prod.outlook.com ([fe80::308b:9168:78:9791]) by BN9PR03MB6058.namprd03.prod.outlook.com ([fe80::308b:9168:78:9791%4]) with mapi id 15.20.4150.027; Mon, 24 May 2021 07:38:37 +0000 Date: Mon, 24 May 2021 15:36:59 +0800 From: Jisheng Zhang To: Catalin Marinas , Will Deacon , Marco Elver , Alexander Potapenko Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arm64: mm: don't use CON and BLK mapping if KFENCE is enabled Message-ID: <20210524153659.58a707a9@xhacker.debian> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Originating-IP: [192.147.44.204] X-ClientProxiedBy: SJ0PR03CA0239.namprd03.prod.outlook.com (2603:10b6:a03:39f::34) To BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from xhacker.debian (192.147.44.204) by SJ0PR03CA0239.namprd03.prod.outlook.com (2603:10b6:a03:39f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Mon, 24 May 2021 07:38:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9aaecae7-790a-4af7-6d69-08d91e86f105 X-MS-TrafficTypeDiagnostic: BN9PR03MB6089: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KPgihMOTnb7yd6Pqu+8YrmeoE/qcfVPV9Ez8U6Tvua2+RilViuDiQu7cOzViBs0h2p622Y3U+jSsz7exOPDrmlSpiz5PvPbBCKj0fDvfP40RJxMFoqYfkA2djz84hTTpk09OysKS/fM1ExhSdnMcjh8OUC4ojH6kjHd71oO1/UQUbivkI0WtS6nQcciNgiTGfGOUHwdGg5TEDRtsTXb5li0BahO3YcCCxWjsLrGesJnUKxBGpdZNk+TF3oaZo4IbBLgwT1iQpaHxVqMuNeo/ATRdswhD/UhnVwJyG8EQ135jDfPBV839T26RpObNhn82qPuI5yBZ5/R4TOVcrLqvF1KZQpm3uRIGy7qFLxiwtkbVQU1F0m9Mg0OIqurbbdM6WEl8KB30GGcFvJgK9U1+UU1c0yNzsZxCEnVrvQhLb14akTVzib8MdpJGbzl4k1REe2M5rZ2GdV3BpRgom+Nd4+8xkyMUv5Gbofxxhrp5+kDKzfLQUfVViVRuDHxojHHuNrjgM4AK1fvjxAANbzlclGISfSZcLnfBCXflOl79/RQnrRzaVjqVKTnnq/UcEwvtaB8o+UMo4nCRJGNEScnyNbU5n24YndSKfvgh7lKWxYg+p3j7KjgyHIkRlEEb/t20wzxwzdRTbNrv2X/rN6Q+kwGl2uHFNyWge8DiIJHCg3Q= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR03MB6058.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(376002)(396003)(136003)(39850400004)(366004)(16526019)(6666004)(186003)(52116002)(86362001)(7696005)(6506007)(956004)(316002)(2906002)(8936002)(26005)(66556008)(38100700002)(66476007)(478600001)(66946007)(8676002)(9686003)(110136005)(83380400001)(55016002)(38350700002)(1076003)(4326008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: AbcWDO4nD5DdKNzJl5hfNfNT4dJE/P23Y3HLJP/kGj7HMCn5GIL/RNeGnN3jPZWIZg8gwffc2LKkYouwuw3CVbt7csfuAYXnOU5IUX2qdElZlEY3pT0MYsYh24b/DrKxL1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FMkaNb1K2Ar+VKAX50Smvmkj0KkZ7vUZSqmnHnN6v4DoFOScWPXeX7Ywc5Nolic4CjDQJV+8GgJ1vqldANcyMjjsAdQkAEJwWZ/NtMXKIToy5FbMucR9LEBxwoNhyjT X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9aaecae7-790a-4af7-6d69-08d91e86f105 X-MS-Exchange-CrossTenant-AuthSource: BN9PR03MB6058.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2021 07:38:36.9971 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UFbkqQcZX+MwMqjlSt+SW9hJcgLOCuVWNbKXsL2bZsKxW+QOcGR8VRCc8olZ/ftlh/cyODm1qcahezjWwR1oHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR03MB6089 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210524_003842_664405_CC2126A3 X-CRM114-Status: GOOD ( 10.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Fix below warning if KFENCE=y but RODATA_FULL=n: [ 0.000000] ------------[ cut here ]------------ [ 0.000000] WARNING: CPU: 0 PID: 0 at mm/memory.c:2462 apply_to_pmd_range+0xec/0x190 [ 0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.13.0-rc1+ #10 [ 0.000000] Hardware name: linux,dummy-virt (DT) [ 0.000000] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO BTYPE=--) [ 0.000000] pc : apply_to_pmd_range+0xec/0x190 [ 0.000000] lr : __apply_to_page_range+0x94/0x170 [ 0.000000] sp : ffffffc010573e20 [ 0.000000] x29: ffffffc010573e20 x28: ffffff801f400000 x27: ffffff801f401000 [ 0.000000] x26: 0000000000000001 x25: ffffff801f400fff x24: ffffffc010573f28 [ 0.000000] x23: ffffffc01002b710 x22: ffffffc0105fa450 x21: ffffffc010573ee4 [ 0.000000] x20: ffffff801fffb7d0 x19: ffffff801f401000 x18: 00000000fffffffe [ 0.000000] x17: 000000000000003f x16: 000000000000000a x15: ffffffc01060b940 [ 0.000000] x14: 0000000000000000 x13: 0098968000000000 x12: 0000000098968000 [ 0.000000] x11: 0000000000000000 x10: 0000000098968000 x9 : 0000000000000001 [ 0.000000] x8 : 0000000000000000 x7 : ffffffc010573ee4 x6 : 0000000000000001 [ 0.000000] x5 : ffffffc010573f28 x4 : ffffffc01002b710 x3 : 0000000040000000 [ 0.000000] x2 : ffffff801f5fffff x1 : 0000000000000001 x0 : 007800005f400705 [ 0.000000] Call trace: [ 0.000000] apply_to_pmd_range+0xec/0x190 [ 0.000000] __apply_to_page_range+0x94/0x170 [ 0.000000] apply_to_page_range+0x10/0x20 [ 0.000000] __change_memory_common+0x50/0xdc [ 0.000000] set_memory_valid+0x30/0x40 [ 0.000000] kfence_init_pool+0x9c/0x16c [ 0.000000] kfence_init+0x20/0x98 [ 0.000000] start_kernel+0x284/0x3f8 Fixes: 840b23986344 ("arm64, kfence: enable KFENCE for ARM64") Signed-off-by: Jisheng Zhang Acked-by: Mark Rutland --- arch/arm64/mm/mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 6dd9369e3ea0..89b66ef43a0f 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -515,7 +515,8 @@ static void __init map_mem(pgd_t *pgdp) */ BUILD_BUG_ON(pgd_index(direct_map_end - 1) == pgd_index(direct_map_end)); - if (rodata_full || crash_mem_map || debug_pagealloc_enabled()) + if (rodata_full || crash_mem_map || debug_pagealloc_enabled() || + IS_ENABLED(CONFIG_KFENCE)) flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; /*