From nobody Fri Nov 29 16:34:21 2024 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B8061C68F for ; Thu, 19 Sep 2024 02:56:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726714602; cv=none; b=vAtP+PQicNHIv1kxrh2Fb/CYyVBShf6bCMZQtKuhueXgI28siNDVWEwQ21NyfUvv0ut4Vu8sOXYf2Ta9Vil0mpS8lo9pOdkDzWC7PObg8X1cL00Wn0PjSvFAvtiKe3ru6pSdAWZ9Br1/Ka38tvnAXvVVELKMOiZbxafvrxHxHik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726714602; c=relaxed/simple; bh=A/alsdJ4ayr16CiiF9B4T3/cT2Sxc3m5R8nEMlHIXkY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hMtKQBKUCZS+/d7zGanM7nUVCaRO2oFOPtgcy6NXCO9Dwlb0sukpHNnqIlKsI37egVKYWb4A88qikcAJOOTCKgIgv+eJneHupVOl31lcl+S5UovYn++JWY24+2yCRvcBpUdjvdy6SMR4L+bvJuxzErTetExCo6QaoUTg5zPukK0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dVCeC1xx; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dVCeC1xx" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2057835395aso4873205ad.3 for ; Wed, 18 Sep 2024 19:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726714600; x=1727319400; darn=vger.kernel.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=9gdBU6NTSnQ45ASWgUOhpCdQmMAIjthCFPvKHCG5k1I=; b=dVCeC1xx0kY3uo67c04Xqr+IU+/F+q+d0A+kvJNhMZRYIVuJhVCgFfLCq6gE8MQMTi A6KqVk8nSFB4ulEMU8NW8PnP27d5ww/dhtb4OuQQ2F4i6RAd9HrOmU/r2d0KEJrlL+2S vCtqIqsYsYk4xTDd0ofmYdsYNsnnQBHA7wynS2b7q0AacIEtOx3NO6Lf5+jfwR5eG0bf czT7BkynX/ecgHV+T0rFdsIxILGiJ8lt2uiQTMBWSYM8mNoIdOzWb5yYb+pB3iGr27T/ tS7YNFU4s3drsalN+/M6QQJ0dUdLT3S8b2TBQdxHQAdSWJI3cLffogBaPuDeRdSzf1ye CfeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726714600; x=1727319400; 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=9gdBU6NTSnQ45ASWgUOhpCdQmMAIjthCFPvKHCG5k1I=; b=LbfmZl7Lpj6nq+4XREs6XULQZx4JMRw54wNpM/KbNwweqM+O0UAVWNUuG4jRVW5rGX SS6JQUPXvMhD5j/bEvbH9oXZgxNyloEqidHwlIji2056hJfmLkpeI5+JPVRDigKfk6sZ v1fv2Rg0OAlWbJ9eQc78xtuCuUl4zLJ6qXXxb30jYKThSGYMFSvbUpWKquTJK02efIt2 RE9ONouxfveeRCOM2fc+83Lm+C8Hj7+vV7yuR9JvoVzS49GQWzuQFbJuMQ6+S2V967qb XIaurZEIR6dN2tL/AH2Xd8SYGnmkD9LABF1hSPisUq9qjC7ZzKaRwwa7qgUhCvdfhrbD E+hQ== X-Forwarded-Encrypted: i=1; AJvYcCXV+Ub+iVUD0v0D8I4BHMLIDoil/+XGONoHcbpCIPhnMJMgQm70VH0o2sPWtp0x91KQAchBgPAwFRSfOaE=@vger.kernel.org X-Gm-Message-State: AOJu0YyedqXGQi1m+1XV7/gk5zeTnYifXmg1ZCozXmn6GNxY99bSntcf mR1pptlwOqtOq+lL6WdcBhZRZ9DJdTE8Cz58SfoZFYpNbIxYbF6w X-Google-Smtp-Source: AGHT+IEErXbCyxVJ/WoGn8BSiRcCs9SEMeQSmif53htHavGlyC9/1FoEX9bAXEfU4wjU0v/bb5Bxuw== X-Received: by 2002:a17:902:e812:b0:206:c75a:29d9 with SMTP id d9443c01a7336-2076e3eb0cbmr391823725ad.42.1726714600089; Wed, 18 Sep 2024 19:56:40 -0700 (PDT) Received: from dw-tp.. ([171.76.85.129]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-207946d2823sm71389105ad.148.2024.09.18.19.56.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2024 19:56:39 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org Cc: Michael Ellerman , Nicholas Piggin , Madhavan Srinivasan , Christophe Leroy , Hari Bathini , "Aneesh Kumar K . V" , Donet Tom , Pavithra Prakash , Nirjhar Roy , LKML , kasan-dev@googlegroups.com, "Ritesh Harjani (IBM)" Subject: [RFC v2 03/13] book3s64/hash: Remove kfence support temporarily Date: Thu, 19 Sep 2024 08:26:01 +0530 Message-ID: <5f6809f3881d5929eedc33deac4847bf41a063b9.1726571179.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Kfence on book3s Hash on pseries is anyways broken. It fails to boot due to RMA size limitation. That is because, kfence with Hash uses debug_pagealloc infrastructure. debug_pagealloc allocates linear map for entire dram size instead of just kfence relevant objects. This means for 16TB of DRAM it will require (16TB >> PAGE_SHIFT) which is 256MB which is half of RMA region on P8. crash kernel reserves 256MB and we also need 2048 * 16KB * 3 for emergency stack and some more for paca allocations. That means there is not enough memory for reserving the full linear map in the RMA region, if the DRAM size is too big (>=3D16TB) (The issue is seen above 8TB with crash kernel 256 MB reservation). Now Kfence does not require linear memory map for entire DRAM. It only needs for kfence objects. So this patch temporarily removes the kfence functionality since debug_pagealloc code needs some refactoring. We will bring in kfence on Hash support in later patches. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/include/asm/kfence.h | 5 +++++ arch/powerpc/mm/book3s64/hash_utils.c | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/kfence.h b/arch/powerpc/include/asm/k= fence.h index fab124ada1c7..f3a9476a71b3 100644 --- a/arch/powerpc/include/asm/kfence.h +++ b/arch/powerpc/include/asm/kfence.h @@ -10,6 +10,7 @@ =20 #include #include +#include =20 #ifdef CONFIG_PPC64_ELF_ABI_V1 #define ARCH_FUNC_PREFIX "." @@ -25,6 +26,10 @@ static inline void disable_kfence(void) =20 static inline bool arch_kfence_init_pool(void) { +#ifdef CONFIG_PPC64 + if (!radix_enabled()) + return false; +#endif return !kfence_disabled; } #endif diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s= 64/hash_utils.c index e1eadd03f133..296bb74dbf40 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -431,7 +431,7 @@ int htab_bolt_mapping(unsigned long vstart, unsigned lo= ng vend, break; =20 cond_resched(); - if (debug_pagealloc_enabled_or_kfence() && + if (debug_pagealloc_enabled() && (paddr >> PAGE_SHIFT) < linear_map_hash_count) linear_map_hash_slots[paddr >> PAGE_SHIFT] =3D ret | 0x80; } @@ -814,7 +814,7 @@ static void __init htab_init_page_sizes(void) bool aligned =3D true; init_hpte_page_sizes(); =20 - if (!debug_pagealloc_enabled_or_kfence()) { + if (!debug_pagealloc_enabled()) { /* * Pick a size for the linear mapping. Currently, we only * support 16M, 1M and 4K which is the default @@ -1134,7 +1134,7 @@ static void __init htab_initialize(void) =20 prot =3D pgprot_val(PAGE_KERNEL); =20 - if (debug_pagealloc_enabled_or_kfence()) { + if (debug_pagealloc_enabled()) { linear_map_hash_count =3D memblock_end_of_DRAM() >> PAGE_SHIFT; linear_map_hash_slots =3D memblock_alloc_try_nid( linear_map_hash_count, 1, MEMBLOCK_LOW_LIMIT, @@ -2120,7 +2120,7 @@ void hpt_do_stress(unsigned long ea, unsigned long hp= te_group) } } =20 -#if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KFENCE) +#ifdef CONFIG_DEBUG_PAGEALLOC static DEFINE_RAW_SPINLOCK(linear_map_hash_lock); =20 static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi) @@ -2194,7 +2194,13 @@ int hash__kernel_map_pages(struct page *page, int nu= mpages, int enable) local_irq_restore(flags); return 0; } -#endif /* CONFIG_DEBUG_PAGEALLOC || CONFIG_KFENCE */ +#else /* CONFIG_DEBUG_PAGEALLOC */ +int hash__kernel_map_pages(struct page *page, int numpages, + int enable) +{ + return 0; +} +#endif /* CONFIG_DEBUG_PAGEALLOC */ =20 void hash__setup_initial_memory_limit(phys_addr_t first_memblock_base, phys_addr_t first_memblock_size) --=20 2.46.0