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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48102C282EC for ; Tue, 18 Mar 2025 12:14:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F7F9280002; Tue, 18 Mar 2025 08:14:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1833C280001; Tue, 18 Mar 2025 08:14:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02216280002; Tue, 18 Mar 2025 08:14:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D6652280001 for ; Tue, 18 Mar 2025 08:14:33 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1A8AA120FDC for ; Tue, 18 Mar 2025 12:14:35 +0000 (UTC) X-FDA: 83234564910.13.40E799D Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 6FB57180007 for ; Tue, 18 Mar 2025 12:14:31 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742300073; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=64IIiCxSmb90ZQ6fmueb4xJ3WQaFIC2OATzJjR0a98k=; b=yf3Fk9va7fuDDAvvCiNx3tPLuSbu/Ft0C8iBFlgmQF46gyyaZwV8V2W/ktCIKoXYhFxRyF jcJgg7oW2l3U/wj4THpZQvMV5SPDFDmAqP44nDSVB49mNS6ncllcYjtLcJhqHmBFIvquCh skKjSezH9IHIo3EGYT0wvGHw3aWAS0c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742300073; a=rsa-sha256; cv=none; b=X5jcd2urOUuHQMRswnGKORB6E91TuC8liQ+t/GiBTnUvAjy71nCplRFwtrxSCy+QE/kjgD RRVD9+BGjk7P1tZ/yEjTtLRNx0L/42OhlEDjDVCb/7r6EE5eZnmHWOzjQ+ia5aCTg1Tsbf BktrNJ+l4K/mHhDEv2iXHQJhPuILb4Q= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com 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 E278013D5; Tue, 18 Mar 2025 05:14:38 -0700 (PDT) Received: from [10.57.85.104] (unknown [10.57.85.104]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7AF4D3F673; Tue, 18 Mar 2025 05:14:22 -0700 (PDT) Message-ID: Date: Tue, 18 Mar 2025 13:14:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 00/11] Always call constructor for kernel page tables To: Ryan Roberts , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Albert Ou , Andreas Larsson , Andrew Morton , Catalin Marinas , Dave Hansen , "David S. Miller" , Geert Uytterhoeven , Linus Walleij , Madhavan Srinivasan , Mark Rutland , Matthew Wilcox , Michael Ellerman , "Mike Rapoport (IBM)" , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , Qi Zheng , Will Deacon , Yang Shi , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-openrisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org References: <20250317141700.3701581-1-kevin.brodsky@arm.com> <70349335-84ee-4bca-a3d6-d7cf3c05b92b@arm.com> Content-Language: en-GB From: Kevin Brodsky In-Reply-To: <70349335-84ee-4bca-a3d6-d7cf3c05b92b@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 6FB57180007 X-Stat-Signature: um3atjxkpxhs3tdn7hiq6tcptcftjgwe X-HE-Tag: 1742300071-283644 X-HE-Meta: U2FsdGVkX1+yeYjEJXzjeT0xdfWhizV9LJzzpCEXySiMjSiaOFEyAxXHPqi3I6QZsQN8vCK0PjfmpssHc+yJ/76d0JgTE7WZNR+6LdHvb0v0ygsCncdsokkPH898ug4sEpmGqqWwrtgdP4nnUY34u1fB8JYsIrpL4B45Q3Tk542UVrINVWDlqEwHsQn7Ut1p+gMBav/GC+r7fNnet52YsjUehcq0AdGDLC0FyYsIVQ0CEACAtTyIaYlw58R9zjBtbxOOjN/82CsoWw3pPtesM6uJOborxSyR+rQNBvnxcHH1Ogt4KoBLPvup1UINZrgApWJYTJx8XoLG4oS+7s7sIWmiLPgDzu/w4TvB/QzliVmwfrC3+M9cm94Ovv2hN+zkaXped8G8Qo+vKlGn11KRGwzHXqy9MtTwethiB++mBulLa+sQDKnRZ1/0gIg8qK0rBEaUZz5x0PRvyAT0b4iQiVWbGt63gFJRGeIg1OaaBg//iAcI0upfK40ol6cXCXRnnct5k9Nt26Zr/UffnZGbLWAiFffuZQKB9sdRdKFFiDE3vMezm16vJ4QMcgeJK5g6GG54ZEN/GdSzYDGmN9kcONRxHWPT6oGQGtey3sE2hhyDcK9Oro3R7cvUcXXrDDDi95mOAdzroEPms9/9arOmcVS799KNAQH7e014NeAVKkdN3eQhH3AyIyoTDwSBNhUivuJ0TMQrwyYXM0c3+8TDSFuYnTdErskWVwg1kGhu6/XAekROy1oRSoCwCgX4K+5EpLVUdvHA4lMyVk5pc0sgnvovPEEFjfPPD6hihPtN9yXNqtC0vyg1eBt579zfuHoOw1lo9WZnj2szU2FsIIiZgGScSs63ixHNDL525g5wwp6b6Ve9+o54WAMRMh2/6zyxXxYdRmWU36hizSoPK8C7fCMQr5hPnth5IGhunaMK9zUIFLQg4KriT+6KFkjo3oYtxfy1VsrAY5MfV0ZqVSb 4oW3j4Th nEHzt0xPPakCzQgtzRvWm06cm4D2UzmlaHdIvVMFpssuSk9kYGnwCEg9wXKv5fLikfXd1Okf1rdpDtm1xbfKqJ/S/QU4edCoFj3ZljED7Pg62oChmpTAJe1uqBZSISXSeIj8ZAd0knYWjKKd66XPVAU0umw== X-Bogosity: 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: On 17/03/2025 16:30, Ryan Roberts wrote: > On 17/03/2025 14:16, Kevin Brodsky wrote: >> The complications in those special pgtable allocators beg the question: >> does it really make sense to treat efi_mm and init_mm differently in >> e.g. apply_to_pte_range()? Maybe what we really need is a way to tell if >> an mm corresponds to user memory or not, and never use split locks for >> non-user mm's. Feedback and suggestions welcome! > The difference in treatment is whether or not the ptl is taken, right? So the > real question is when calling apply_to_pte_range() for efi_mm, is there already > a higher level serialization mechanism that prevents racy accesses? For init_mm, > I think this is handled implicitly because there is no way for user space to > cause apply_to_pte_range() for an arbitrary piece of kernel memory. Although I > can't even see where apply_to_page_range() is called for efi_mm. The commit I mentioned above, 61444cde9170 ("ARM: 8591/1: mm: use fully constructed struct pages for EFI pgd allocations"), shows that apply_to_page_range() is called from efi_set_mapping_permissions(), and this indeed hasn't changed. It is itself called from efi_virtmap_init(). I would expect that no locking at all is necessary here, since the mapping has just been created and surely isn't used yet. Now the question is where exactly init_mm is special-cased in this manner. I can see that walk_page_range() does something similar, there may be more cases. And the other question is whether those functions are ever used on special mm's, aside from efi_set_mapping_permissions(). > FWIW, contpte.c has mm_is_user() which is used by arm64. Interesting! But not pretty, that's basically checking that the mm is not &init_mm or &efi_mm... which wouldn't work for a generic implementation. It feels like adding some attribute to mm_struct wouldn't hurt. It looks like we've run out of MMF_* flags though :/ - Kevin