From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796064133; b=E7y6zttyWKGxJ5UdJ+IPDja8TrAmO07vrQ52i7fpuyuUusBes93nQFWyLLamHWv/c5I1 9TokSxiegv4wuynpb1huG78CVCoLIrNiqRYp29Y+wUEbFrDKTc1bFBUvei1YYQ9tHttoN FMp39WspTi+EExZA8WeXU4jq4YoqMLGvf7eybTyl7XIun0XkQkgflIV8tpdt9h/0rschh g3XwCQhxFPuCtdiD2LyRb+txREdOwPKKxLDdK7bZABz4P9ZnxeA7Cz0doVrsxrXfBn5mw 49Bgu8kPlWHa5dl7Wz3pQ+Jp1SwE+iDDn+t3uanB1EvoxQiXo2IS4dHUj1GZL+9xe7g== 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=Rl0o+qAH2B9deNf0IWnMSEydhkJMpXi7DSxD+Z+oKqnbgGCtsKkQGfDsLK/PisUcgX0I WdreKQ48APK4K2ZvHo4CG8Jcc0B4VI4OsdMZxTFHvi1h1uukDTB9lf+NhgCuzn50hd+6M KTjdzJ9RmswoBL9MbAbPjrIXeMYoJS4dIH3NuAaT+rpCkwxD9IW1tK3o4vtRNQWUGydXz KnuZwvID2GgQCwaYV1GxdLe3W00cDQzCXBJNmQWJnvRctoRypgZ3spcx30H/nFlcnXAjO X3WpX6EE/IETaej+CvfJf3MYCyoyhfiKH5fpV1tyneCW7AW8yTsClwX4UCYURq9NuZg== 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.221.43 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 98041606A320 for ; Mon, 30 Nov 2026 18:42:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 98041606A320 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-wr1-f43.google.com with SMTP id ffacd0b85a97d-492690dd5daso8449210f8f.1 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=rbSd4Jboqu94mpjvEqBFE9/+9gCyGEFozB5Tt39QjP6PikzS/es5/l1rPJX0rItCpC UbRhShe4uZuuBy67MeNbCAOiLnu5N/tOiUkmWVMRf3J/8NYRsE7T2+omEpTpvru3gExD 1Mx0H0zq8pWHYv4QN9YD86ayP83CH5uLTopMKQBhbfydd/MTrKNOWpHs0lHiUQFPSYqx YPApuYH7W4YxSZH4gG2cvr+r5l42nQ0Oh33GrykiD7rOSP4CLaPOZ4tjKWG0n4H6nPRE OfMXJJ1/CcelEn3VoFxLl4lXzM8evhezaxV5XGllsXFXEKxwVAm8xyBKHPItlRgRbJIl JZ8A== X-Forwarded-Encrypted: i=1; AL+hErHtXCB85K0FcnlTJGzIvV2p9WoZ9uZ8fzZgHtDZoCs7uFcGfm4IM3mNk53M7tdp9cFFVkw+IgZ4ng==@vger.kernel.org X-Gm-Message-State: APuU4Z/0mJlYCoynYifP4F155PkaTsKFtcjBh/m5jPxvl8R9I8AW7MgV KmIwMV4xh63Yyo6CDCncNcx/B8bx/YosNV+04zxWJ3h2oH/rIqof7MAbDkmIDBEq1g== X-Gm-Gg: AZFdTZcVLsOS2qs+iXzX0TQ9GutkM/rbdb8u72dcgHGpHLbKm+NhMY+VEgcdTQjMhFU syc8Wwa18Ld317aQBcvhV3RQgNH5+sa+cgL2sCO0lWUJc/Izu9BtwNShUznWwTQ+zqo8M8INNj8 /9Z6MIb7p5aOIQTXgQ8paDR2MKX/rqyWO3YARFUbnc3/DPwK2LLV7AdCZUM6o5aTV5s8+hdrJ0y sEZCXAXzDrX6itNh5E4z7Iu25LEmSxK/UVNKL+T279OHU/ZtnkFmv85f5YnJUEXFADRKt3wd8GF uhtgDFfytKAR6BjtJZcxJ/z773k0Wfj4Qa5RsVv45aDfsXzqw2bzOaFOnz9N5CzSjQDVrzRn9am jwGoE8dW9XyPln1HgVL578wSoWLK0wh7ub/g1kKW3eRNWC9IRt6gO8EyRmwly5P/NQNuX+PeCOD VT7VGeXrD7F9jvLI8Ou9v89kal1uOAC3Ybqq050zwadnM4XSQwzn9LG9VAo2m4zwRAtiiiGAzZQ 53sVcIUlf951AtH8BTRo+GsmOtCzjeh60jy84OlnRHcYtHCN+zSi5qfDpRp6ug/8Hf1ehoniAhr Y+KV/EVBA1yIhS9mTrRV3S+ejXyKs6bedLFbgHT6wpiJ9kCrlstEUzxpaP0Gdnjzg3hR8Ja/T/i u+vAzBO1owEoQOsrt4J3INWasAgmbHlTKTganMWLS9BM= 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-pm@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