From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796064133; b=KBgrUrgmQxQhfMMpFW0dXYbP1fWbJUcOUPDHz+DM1i6vhjmxHeCq49uduNzN/1H2KO89 TX+ovyIP2bIK7zwhppn4LgPPL9fjZZEZS/fgMKMFFN0H0ZDK4FfonwyePtAihb+7L3WHo 5OyualHc04ul2tBcPQHZfDTYdnIxbTdiKVFGq9RrzQt5wlaoAXW7ta3n6ZXzL8x8Ii5pA sZfxD7oSmNKyRUbwa84hbb/jWeZEAhtsuN25HkEJPN4lbyXs6BIiI2HFafR73q9PqSRTi hw0GcGzq8iMH30ujfYASiX+q9pOankHiaGHTRW+2fmBOMy/tYB+YjK1X4BXxKdSPBwA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796064133; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=C8ue8zOfS3Vyhx+sgV6tOcKLVltdRWMuzLuedLKtw4U=; b=epwYHV2QjtRn+RdIVSaQWxm3oSOzWv5eAPBv1785i/ymCjsZJLeYtGiXLRivdkKtqZcR us5anzUlicD5yWT/tDMGq3prMcSWEMhPOnbLymF/2HULs1+yF5dKiZpZ1V3821VW4Nh5Q xt1zqVSEH745KTMTDBdP2mg89RsObJraifOmXOVVGGTdfvGlW9nqDD9BqModOFjwLY6YZ o58JCmU3WNnDi/TX/OY5kOSeWXrt/1MBZQR7fbbR6xoiEw6DMCi1ldjDMAkJZq+0PB8o/ UpPcd4H850WN2FlqOyxU9OMzGMBJ28SLtAS8dchmlcHUiNeBwgjWFCThjNz+zFqbPsw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=JBKJmGRv; arc=none smtp.remote-ip=209.85.128.44 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96F60606A31C for ; Mon, 30 Nov 2026 18:42:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 96F60606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=JBKJmGRv Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4bb6c7b6dbdso100200135e9.0 for ; Mon, 30 Nov 2026 10:42:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796064131; x=1796668931; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=C8ue8zOfS3Vyhx+sgV6tOcKLVltdRWMuzLuedLKtw4U=; b=JBKJmGRvmWzsMW0UUmEvPTS/H0AlPs9CEqnqaQB7ng4X28ZNub9QFnDK/EvvPuEwWp ndrGquzmXvlRoPEuOz8gQjSb8dsEHvRDlNThMcSKTtl4ZpMi2ioqOhHxeuozZZOuuB5W 4dFboEnOQLBjWLpEEz8Opy7/NjwdPgQMxjrRa61HSQbnbTlHt3ARKltAlktx0lpq5DtG w0wJgryyah07TtMlvvqcQl0zFA5rPpVUiR/ybSkJrnJdcGJKPiGZLS6HFpGTKxp/+Sgn 7y7K+O3PChNt+eF1B4XFKu1bfSHC4l4BSAFXh3m0xdhPLjtFtzrZ1ZIlMGqA13847N7W /bNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796064131; x=1796668931; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=C8ue8zOfS3Vyhx+sgV6tOcKLVltdRWMuzLuedLKtw4U=; b=e07GKseG3c03g8JYdlHbfeLulLX7rnybN8d9U2UpRt9y6aCrKqZrhdAmb7Gb0/QccN bK6d8aAJM4FwZz2JuitKyiJ+75lplXJDFKgTtOjIsQ008CY54eYpAtjyo+K7m+LQBx12 9ZSev4+K9q61K/x/4TqM1+44swLLBuxv80D6KcX2Y20m+IMGvJ197H4GlrZUNeXqY6Yi SsoGpRTcbJ+NXQJ/0P1RgtiSJVd5R1BvMfyj7xx9IRwyWtDLKx6HfaNSjXzTmZVWboJO lTGLUU+HC0moadlsT+AzE5ouzmwlH4LU89Tvy61FpdE2qzpgHmbl3eVOwR9EBmCulNMb vbMw== X-Forwarded-Encrypted: i=1; AL+hErEkXrTy2l4YI5P2HkiMHIPCq2NuD725HVLST4lzMtlJkX+MhW3np+N2fM+FFA9lYd/TEjgdluJ/IebT7jk=@vger.kernel.org X-Gm-Message-State: APuU4Z+fyK7Zvq72QZkgq51lIknXbTi4qZx0im50PmXivkzkur56yv1v i3XXDInwWGDiosLBmyNaT7gd4Gb5dbVgJYam8SgoKOo1DFSI7VVfX3ES6V9+XHIDnw== X-Gm-Gg: AZFdTZfw3FeSGCN5IsBYOLKGwMPPsooMGwqjompVGXlfgV8utzb7G4fygV33dBI+P1g V9PypbLCPcrN7k6v1pmb0bUDrj3lBZJhuatNsRjUUEoxNlG+msCFc7r+pi5Vy3ocBn3syAIXv2l WAws1a77oQhDTZdrl40E5zmWvAtI0guAdniO8+ULFcA+r928adL76TYWW7CRjn+Vxeyfcb/L8CL 7QCKRtNLi1PN1Ga5mSGT7jnQAA+9UZDs7138Dv4yYgIfAX1ONqCwVGW1NS5yauu6s4LNhgfH5qe lKsYY/p2T1phzTzdjf4OS9yPCHg3lqau3kxY71tnOgXJe9d6lUhVqJ+fYxuOdxONUzgdEr2ehJZ VT9EJEt6Mterh+WoUyVsSy+mTYySxrKQoWIk2t8A7htVi5ruTOCERWKmyHYHkHcR0aX1LdwAoyU 1orV/Q3NOjvybx47naM0GJaYmyNc8VT1cykas9pRlo/7X6dsOAiZB2MqDkOTyuiEYKru6Gsay9u 3AB3tzK4aM6davvQn27rBfaErC6Phopp5EUy7pf0TOck2bbizPQTWYefXg0n0U/NGjhKTHTEpdN QFfH/ePpamGf4iCdWS0WqW7QsOF1HJRShkLGfoNYt9QpwIGAwZmlOjk5ZMpsh94WFGDD2jkhvFT noyvBhrinPVCsn45aL9oXc98su7RuNUfgS+AAvJkhjF0= X-Received: by 2002:a05:600c:848a:b0:4bb:6626:5a25 with SMTP id 5b1f17b1804b1-4bb88813462mr581782765e9.20.1796064130411; Mon, 30 Nov 2026 10:42:10 -0800 (PST) Received: from google.com (0.182.34.34.bc.googleusercontent.com. [34.34.182.0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb905f1489sm650143205e9.0.2026.11.30.10.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 10:42:09 -0800 (PST) Date: Mon, 30 Nov 2026 18:42:06 +0000 From: Vincent Donnefort To: Will Deacon Cc: catalin.marinas@arm.com, rafael@kernel.org, mark.rutland@arm.com, lenb@kernel.org, pavel@kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, thierry.reding@kernel.org, rppt@kernel.org Subject: Re: [PATCH v1 3/4] arm64: mm: Introduce linear_map_needs_set() helper Message-ID: References: <20260918131656.3710047-1-vdonnefort@google.com> <20260918131656.3710047-4-vdonnefort@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: [...] > > +/* > > + * True if the linear map needs to be modified for one of the following > > + * features: > > + * > > + * rodata_full and DEBUG_PAGEALLOC need to protect/unprotect pages in > > + * the linear map. > > + * > > + * KFENCE pool needs to protect/unprotect pages in the linear map if > > + * initialized late. > > + * > > + * Realms need to mark pages shared/protected in the linear map. > > + */ > > +bool linear_map_needs_set(void) > > +{ > > nit: I'm not a big fan of this function name, but see below. > > > + return rodata_full || debug_pagealloc_enabled() || > > + arm64_kfence_can_set_direct_map() || is_realm_world(); > > +} > > + > > static inline bool force_pte_mapping(void) > > { > > const bool bbml3 = system_capabilities_finalized() ? > > @@ -785,7 +803,7 @@ static inline bool force_pte_mapping(void) > > return true; > > This 'return true' above is part of a check for debug_pagealloc_enabled(), > which is now redundant because you've added that to linear_map_needs_set(). The redundant debug_pagealloc_enabled() is the one in linear_map_needs_set(). I believe this one is necessary because we must force PTE regardless of bbml3. > > > if (bbml3) > > return false; > > - return rodata_full || arm64_kfence_can_set_direct_map() || is_realm_world(); > > + return linear_map_needs_set(); > > } > > > > static DEFINE_MUTEX(pgtable_split_lock); > > @@ -1203,7 +1221,7 @@ static void __init map_mem(void) > > > > arm64_kfence_map_pool(); > > > > - linear_map_requires_bbml3 = !force_pte_mapping() && can_set_direct_map(); > > + linear_map_requires_bbml3 = !force_pte_mapping() && linear_map_needs_set(); > > That looks pretty odd now that force_pte_mapping() calls > linear_map_needs_set() under the hood. > > I wonder if you should avoid introducing the new function and just put > the logic in force_pte_mapping() instead? You could rename it to > linear_map_force_pte_mapping(). > > Then map_mem() just needs to check force_pte_mapping() whereas > can_set_direct_map() is force_pte_mapping() || has_bbml3(). > > Will I am not sure we can get by with just linear_map_force_pte_mapping(). When false, we still need to distinguish if this is because we have no feature that requires PTE level mappings or if it is because we might be BBML3. How about something like: static inline bool linear_map_needs_split_or_ptes(void) { return rodata_full || arm64_kfence_can_set_direct_map() || is_realm_world(); } bool linear_map_force_pte_mapping(void) { ... return linear_map_needs_split_or_pte(); } And then perhaps this map_mem() snippet is easier to reason about? void map_mem() { ... if (linear_map_force_pte_mapping()) flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; else if (linear_map_needs_split_or_pte()) linear_map_requires_bbml3 = true; ... } -- Vincent