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 43BD9C636CD for ; Tue, 7 Feb 2023 10:49:19 +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:MIME-Version:References: 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: List-Owner; bh=XKYp1upIZAu90u0zPCY1kCmxCZxvdG6DSUEhywFdkxk=; b=fR8j3fLoFS3knZ RLobW84KCJNAAIjEvZo30J3+wD3FMTPPkoTAx4uG2yrrjOgGHJk/Bqt5Gn5IL92lFI/n5UIeVKuZ1 2j6wkGLn0MBErXiav9NcrumUYqexEny+MgSEXRiAOY5m9BZkSyNJXO6+uISdSWrGJBgLPf75ehXsV cLn11o6QH80/441FJSwQewC79FHyujWUfIE0ZFYHwZI1uvAyssyeHS0GAHA2VRGEDLASm0P5/VXQ5 9qTuZfca+DBpnHSM/lq9Te2a5tXdpz/bRBBX3DvvZMxh4vto/8y5kewF5agrheaNBHIFdSCbyeoua mSXc8b3nX0Q2/+IvDOmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPLWa-00BnwO-86; Tue, 07 Feb 2023 10:48:32 +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 1pPLWX-00BnvZ-8u for linux-arm-kernel@lists.infradead.org; Tue, 07 Feb 2023 10:48:30 +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 2A287106F; Tue, 7 Feb 2023 02:49:09 -0800 (PST) Received: from FVFF77S0Q05N (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5DA043F703; Tue, 7 Feb 2023 02:48:25 -0800 (PST) Date: Tue, 7 Feb 2023 10:48:22 +0000 From: Mark Rutland To: Zhenhua Huang Cc: Marco Elver , catalin.marinas@arm.com, will@kernel.org, glider@google.com, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: kfence: export kfence_enabled as global variables Message-ID: References: <1675750519-1064-1-git-send-email-quic_zhenhuah@quicinc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230207_024829_374740_22C8D98D X-CRM114-Status: GOOD ( 25.03 ) 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 Tue, Feb 07, 2023 at 03:46:53PM +0800, Zhenhua Huang wrote: > Thanks Marco! > > On 2023/2/7 15:19, Marco Elver wrote: > > On Tue, 7 Feb 2023 at 07:15, Zhenhua Huang wrote: > > > > > > Export the variable to ease the judgement of whether kfence enabled > > > at runtime. It should be more precise than through kernel config > > > "CONFIG_KFENCE". > > > > > > For example We can disable kfence at runtime using bootargs > > > "kfence.sample_interval=0" but CONFIG_KFENCE enabled. > > > It was false positive. > > > > > > Signed-off-by: Zhenhua Huang > > > --- > > > arch/arm64/mm/pageattr.c | 3 ++- > > > include/linux/kfence.h | 2 ++ > > > mm/kfence/core.c | 2 +- > > > 3 files changed, 5 insertions(+), 2 deletions(-) > > > > > > diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c > > > index 79dd201..208d780 100644 > > > --- a/arch/arm64/mm/pageattr.c > > > +++ b/arch/arm64/mm/pageattr.c > > > @@ -7,6 +7,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > #include > > > #include > > > @@ -27,7 +28,7 @@ bool can_set_direct_map(void) > > > * protect/unprotect single pages. > > > */ > > > return (rodata_enabled && rodata_full) || debug_pagealloc_enabled() || > > > - IS_ENABLED(CONFIG_KFENCE); > > > + kfence_enabled; > > > > Unfortunately this won't work, because it's possible to enable KFENCE > > after the kernel has booted with e.g.: echo 100 > > > /sys/module/kfence/parameters/sample_interval > Yeah, got it. Thanks for catching it. > > > > What is the problem you have encountered? Is the page-granular direct > > map causing issues? > We're working on a low memory target, page-granular mapping costed more (2M > per 1GB) memory. Due to GKI constraints, it is not easy to disable > CONFIG_KFENCE. So my intention was to move the judgement to runtime > configurable w/ CONFIG_KFENCE on... > > Do you have any further suggestion/proposal on this? Many Thanks! Just to check, the cost is because we're mapping *all* of memory at page granulatrity, right? If we were to just map the KFENCE region a page granularity, would that be a sufficient saving? We didn't do that so far because it was simpler to just map everything at page granularity (and that's also required by rodata_full, which I though android used?). If it's really important (and rodata_full isn't being used), we could try to do that. To do that we'd need to choose the KFENCE region *before* arm64 creates the fine-grain translation tables, which probable needs an arch_ hook. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel