From patchwork Fri Oct 18 17:29:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 13842093 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 ECFD0D3DEA2 for ; Fri, 18 Oct 2024 17:31:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BECB6B00A9; Fri, 18 Oct 2024 13:31:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76F0D6B00AA; Fri, 18 Oct 2024 13:31:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 611BA6B00AB; Fri, 18 Oct 2024 13:31:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 40BD26B00A9 for ; Fri, 18 Oct 2024 13:31:20 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 15FFD1A1A35 for ; Fri, 18 Oct 2024 17:30:58 +0000 (UTC) X-FDA: 82687414194.28.B5F3B88 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf23.hostedemail.com (Postfix) with ESMTP id 01567140023 for ; Fri, 18 Oct 2024 17:31:10 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NaLB6kRR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729272558; a=rsa-sha256; cv=none; b=nPkFZ0FNl21GCAutIFeaMi6tAdw5DdNiffCuHpp0Mb7nd5vh5sKL7LVsLjfziwmCYRLQ+4 cVZuHMegbFLnJujDhAaFJawM5sdzVIUE1XTp2qdtBgUxvU11pn0svcqFM4CYV6sXmMGGBP ot0JPjLhWH7x/QxqzK9/YngbNkYtPDk= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NaLB6kRR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729272558; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=M+pQKseSbUwQ7nDgMGbwYxJsHyJez2ZBxycyN9iER7I=; b=NtIEncPbO/fUo6+fnUEFCgMY8O9oPP/KglnsnPg8dkgpSdgTMhb6KJCEJVyJRJ/6Uq5b7Z bg4rIDNWjx3UDlSysmBDrfv417WwzURiCdGveBp7VdYonW/j/A+vzzHmC8FSkaQeYlLkq7 Uc4Kl/ElN7sp21gb6YPY74ttCA4vNGM= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-71e4244fdc6so1726152b3a.0 for ; Fri, 18 Oct 2024 10:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729272677; x=1729877477; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M+pQKseSbUwQ7nDgMGbwYxJsHyJez2ZBxycyN9iER7I=; b=NaLB6kRRBWfyAxaqZo0lCJnVZ/aDsb3aoPoglE795lyhEfLlCuKEi/w5Jy9ldm9UJc mUPOnr+nmQLCTuOAzp+wLbuMF9K9SLO5AQKoOVC3E+hlVHXCDcIkbEaqbkBgy6sD/eeC 7aEn7hIBx3bfGBgfltRnlAONrvTVVxINLLV6gcr9ilryxK3oEcEKYAWKjZ0As8nRLluy Zz1LeslSP/H0V7A49DKwRI1UzcnHQkRV+IxkB48MYHbMQZvRvyoXEnNHMTRqRhfUnLOP WKL7sgjSr98KBiPfWvQHfRb9bQlsZjXGJ8S036RiboEBgR5f3GFZePc/bmuBN5a22gWB 7ttw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729272677; x=1729877477; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M+pQKseSbUwQ7nDgMGbwYxJsHyJez2ZBxycyN9iER7I=; b=mCEaukB5K3G7gwIhJJ9egOp0r4dzlHbzcx2hxO1NvU53A5X4a82aLkJlCdU8mzvGku sJukZXNNGKIWKHN4gn9QJmBUFk+FuqzLuzNIfuTdqY2Ad714LJ88TtwjRYuOvQ4naCdi r0swS1dPCfGkr93Uawf629wxDyGTBbK7dfX35T8EXp1hOZBzyQGyEvGU8BSUK1BMCBB4 98pfYIAO4KM2Sax8H0nTwrkzukwl/KtdOXQICkkJ66vx8A4K1ymMZ3RRa+P3FN1GGp03 K6Eeb+w2JE861z9qXlnrEhYxjrUaarXYGXPqdoS9GNQuhkBK17eifqBlRVSq7amm3mtI CCog== X-Forwarded-Encrypted: i=1; AJvYcCVUYvDSZPCBZLJUfzf0K5W+AG8NsGughSDpTwV0x53TWOW1QN0pa50ItA2xcKJyYLXxQMvb7ty3Lg==@kvack.org X-Gm-Message-State: AOJu0Yya/lFGuwwrsFmolFNUxF9CgIhIZwRfSOlyqFMUDJ417kxOTVIy 5iynv9JcnhnWAhC2R2ymd8uPhRkTr0QnHQKANyVecauEmRVsxKwX X-Google-Smtp-Source: AGHT+IFVWe1xUi/sLyBKrxUXKe/50HIPEi+N9laTmy/mjDBIPEDqbRrd1jNCsq8LdLHdy/KQ/lg9Ig== X-Received: by 2002:a05:6a21:168d:b0:1d9:61b:9607 with SMTP id adf61e73a8af0-1d92c4a0231mr4271987637.6.1729272677039; Fri, 18 Oct 2024 10:31:17 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.80.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ea3311f51sm1725242b3a.36.2024.10.18.10.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 10:31:16 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org Cc: kasan-dev@googlegroups.com, linux-mm@kvack.org, Marco Elver , Alexander Potapenko , Heiko Carstens , Michael Ellerman , Nicholas Piggin , Madhavan Srinivasan , Christophe Leroy , Hari Bathini , "Aneesh Kumar K . V" , Donet Tom , Pavithra Prakash , LKML , "Ritesh Harjani (IBM)" Subject: [PATCH v3 11/12] book3s64/hash: Disable kfence if not early init Date: Fri, 18 Oct 2024 22:59:52 +0530 Message-ID: <4a6eea8cfd1cd28fccfae067026bff30cbec1d4b.1729271995.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 01567140023 X-Stat-Signature: 44fkiihebcyttes3zmpm5nrqumqu6bt5 X-Rspam-User: X-HE-Tag: 1729272670-157809 X-HE-Meta: U2FsdGVkX19Bgdxt0yWCtU2w9f9S76prDaH+SLzqHmuRqIWuBNGMcbAr2QouEES/R5c/qEP3eyyMvYegcVMMSlYE50fg+GPjprZFcpQpNapvXxfKJ1AYqTrzCK/Hq24e8JskRd2aoRYqEkmoB7mezeenr6iQsgfh7SRxKS59A1LBGysjCbxI0t39tBGnp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ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Enable kfence on book3s64 hash only when early init is enabled. This is because, kfence could cause the kernel linear map to be mapped at PAGE_SIZE level instead of 16M (which I guess we don't want). Also currently there is no way to - 1. Make multiple page size entries for the SLB used for kernel linear map. 2. No easy way of getting the hash slot details after the page table mapping for kernel linear setup. So even if kfence allocate the pool in late init, we won't be able to get the hash slot details in kfence linear map. Thus this patch disables kfence on hash if kfence early init is not enabled. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/mm/book3s64/hash_utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index 558d6f5202b9..2f5dd6310a8f 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -410,6 +410,8 @@ static phys_addr_t kfence_pool; static inline void hash_kfence_alloc_pool(void) { + if (!kfence_early_init_enabled()) + goto err; /* allocate linear map for kfence within RMA region */ linear_map_kf_hash_count = KFENCE_POOL_SIZE >> PAGE_SHIFT; @@ -1074,7 +1076,7 @@ static void __init htab_init_page_sizes(void) bool aligned = true; init_hpte_page_sizes(); - if (!debug_pagealloc_enabled_or_kfence()) { + if (!debug_pagealloc_enabled() && !kfence_early_init_enabled()) { /* * Pick a size for the linear mapping. Currently, we only * support 16M, 1M and 4K which is the default