From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5E718C32771 for ; Thu, 22 Sep 2022 02:53:14 +0000 (UTC) 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:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HzfEfdS/BRN6LesgvV5j1x0BDCz+AVv7V186Twe8zi8=; b=d0ShDJE0zTdoXK qsXmkwuOcClEXoC9TJ0IBLZbd+AWZIBnrnk64nRcDXa7j0FxZ6i0HLyWNVJsTv5hz0VIaZB8LUN9b PIgn52ViOW+SvlqSootlkG8FFwuKiwmX1hQTmK+Aml504jgXGQqEVwxCtk6TXUEXcyYIQflcU5/6S TO9LRRlyEcIhKwzEdPWJ58dmReD5ou0tb5Rgh5QBKBoEL6hXT49hxxZ0AEwtE19yBx2sa+ChDweBV YW08DfcwjFsg3jau7bVencmb3RIfYxnhgXs7R92A5FuNOULNOsJuiTIgcNW+IOfeqEV/FmeSTsLTV Jlhxyx/vwNw1KoCCTL0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1obCJz-00DBty-Dt; Thu, 22 Sep 2022 02:52:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1obCJu-00DBsX-Nv for linux-arm-kernel@lists.infradead.org; Thu, 22 Sep 2022 02:52:13 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3A06C143D; Wed, 21 Sep 2022 19:52:14 -0700 (PDT) Received: from [10.162.43.8] (unknown [10.162.43.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9AD7B3F5A1; Wed, 21 Sep 2022 19:52:05 -0700 (PDT) Message-ID: <076cf45a-f1e8-8e42-af78-58460f7344f2@arm.com> Date: Thu, 22 Sep 2022 08:22:03 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] arm64/mm: fold check for KFENCE into can_set_direct_map() Content-Language: en-US To: Mike Rapoport , Catalin Marinas , Will Deacon Cc: Mike Rapoport , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220921074841.382615-1-rppt@kernel.org> From: Anshuman Khandual In-Reply-To: <20220921074841.382615-1-rppt@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220921_195210_846711_6087F274 X-CRM114-Status: GOOD ( 20.46 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 9/21/22 13:18, Mike Rapoport wrote: > From: Mike Rapoport > > KFENCE requires linear map to be mapped at page granularity, so that it > is possible to protect/unprotect single pages, just like with > rodata_full and DEBUG_PAGEALLOC. > > Instead of repating > > can_set_direct_map() || IS_ENABLED(CONFIG_KFENCE) > > make can_set_direct_map() handle the KFENCE case. > > This also prevents potential false positives in kernel_page_present() > that may return true for non-present page if CONFIG_KFENCE is enabled. > > Signed-off-by: Mike Rapoport Reviewed-by: Anshuman Khandual > --- > arch/arm64/mm/mmu.c | 8 ++------ > arch/arm64/mm/pageattr.c | 8 +++++++- > 2 files changed, 9 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index e7ad44585f40..c5065abec55a 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -535,7 +535,7 @@ static void __init map_mem(pgd_t *pgdp) > */ > BUILD_BUG_ON(pgd_index(direct_map_end - 1) == pgd_index(direct_map_end)); > > - if (can_set_direct_map() || IS_ENABLED(CONFIG_KFENCE)) > + if (can_set_direct_map()) > flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; > > /* > @@ -1547,11 +1547,7 @@ int arch_add_memory(int nid, u64 start, u64 size, > > VM_BUG_ON(!mhp_range_allowed(start, size, true)); > > - /* > - * KFENCE requires linear map to be mapped at page granularity, so that > - * it is possible to protect/unprotect single pages in the KFENCE pool. > - */ > - if (can_set_direct_map() || IS_ENABLED(CONFIG_KFENCE)) > + if (can_set_direct_map()) > flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; > > __create_pgd_mapping(swapper_pg_dir, start, __phys_to_virt(start), > diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c > index 64e985eaa52d..d107c3d434e2 100644 > --- a/arch/arm64/mm/pageattr.c > +++ b/arch/arm64/mm/pageattr.c > @@ -21,7 +21,13 @@ bool rodata_full __ro_after_init = IS_ENABLED(CONFIG_RODATA_FULL_DEFAULT_ENABLED > > bool can_set_direct_map(void) > { > - return rodata_full || debug_pagealloc_enabled(); > + /* > + * rodata_full, DEBUG_PAGEALLOC and KFENCE require linear map to be > + * mapped at page granularity, so that it is possible to > + * protect/unprotect single pages. > + */ > + return rodata_full || debug_pagealloc_enabled() || > + IS_ENABLED(CONFIG_KFENCE); > } > > static int change_page_range(pte_t *ptep, unsigned long addr, void *data) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel