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 D7818C4829D for ; Mon, 12 Feb 2024 20:39:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 465FE6B007D; Mon, 12 Feb 2024 15:39:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 415986B007E; Mon, 12 Feb 2024 15:39:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2682E6B0080; Mon, 12 Feb 2024 15:39:10 -0500 (EST) 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 10D3C6B007D for ; Mon, 12 Feb 2024 15:39:10 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A200A40778 for ; Mon, 12 Feb 2024 20:39:09 +0000 (UTC) X-FDA: 81784316418.04.043FFDF Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf08.hostedemail.com (Postfix) with ESMTP id 61F26160006 for ; Mon, 12 Feb 2024 20:39:07 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707770348; 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=ftNmF3tZ+P3amd6e4QJsIAlImL4+aUhDn2omsstzILU=; b=wnKXxqko0BcXkjFE0Oj7wd+uKHyaWCTo78q1sAH7leGM0vb1t4uTXrAzKvayC4t3IzOHxp /t9VNtnxELe5xAlS4ny90q6sBXAZOff5N2CeVcHg/hN1+IdGdrtJRutK/JShavZheDfA3J 49FJOFBiPupYuT1hwRd9TMOn9bduos8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707770348; a=rsa-sha256; cv=none; b=x13huRn+XMeAONx/MTR2JfF5Qo8IqNa2tInPONrIAz+TcH22Xk02v3ktUjdlkLQiUckBVO oiAQTFvmieb8jeMJbncdKEdOy893Gs1sQVSPFr2pebU4jcMsBFd34+HGSdnv1efB/KnJJE dAn/XTPtvbd/iXh8XVmcBA7jkddAaSY= 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 56446DA7; Mon, 12 Feb 2024 12:39:47 -0800 (PST) Received: from [10.57.78.115] (unknown [10.57.78.115]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C95403F766; Mon, 12 Feb 2024 12:39:00 -0800 (PST) Message-ID: <64395ae4-3a7d-45dd-8f1d-ea6b232829c5@arm.com> Date: Mon, 12 Feb 2024 20:38:59 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 19/25] arm64/mm: Wire up PTE_CONT for user mappings Content-Language: en-GB From: Ryan Roberts To: Mark Rutland Cc: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240202080756.1453939-1-ryan.roberts@arm.com> <20240202080756.1453939-20-ryan.roberts@arm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 61F26160006 X-Rspam-User: X-Stat-Signature: gn68jgf3r3qf11h7t1ieq3cois1whojy X-Rspamd-Server: rspam01 X-HE-Tag: 1707770347-900957 X-HE-Meta: U2FsdGVkX1+2+0t1NU2Pw4B8Sp2xOj8T92T5Eza+2S9YNGFIsQqqzGMQvfdUYKedzpDysabqa//6xW0sWA6tvFXn4Q+AD8Uog3RCqnkidTGdL7Vz7QocivGznJn9aO/Q5pZNPOyqAdccKp/24BL8IJxUirECfjZaxn/tW9qpWN/Af11sTjsNIGatv2tZtWJrZ+NeTkatJ8JqWxpp/AIlkoa0o5Ut95W2g+ajsbz2OqiqHBOtxdurZwoz4GqhBJ5zJ0q0QjACs3CjblOIRSVhHzmajigq/FSOflKkisiBjRk8oW84sVCF5g31UPEJss2eBB3xdSnwvLRQRU09AwuHeLlKRB/bZB+QR/rQzY+MujldrnVvdXapckxkGlisLPvsGVlhsK+EQh42XIegJtohBHzRERT08hU/8W6n08g3KGUbCozE6psOkz57zSpz1EfGS0tX5HYIJw9XZvYAvrpEnpugvb3/dXkrKlm/AyZHhih9zf3BNBSPBsex4nrLmxHe9nKMnH6iGrWHekRrLoUsN3HzdYqBSrKkohg98OJYEmqnEaAh4bL1lSLAw40fzXABuKDxatvxoTTWsF6xvBk0VvYMaxjW4QtFSLqMPmD37ZaB8CLmZ05MQLEtE2lSQfQhQJ9Qmt8Cn0yK0L0BlLOjwOAPsiAK/rqKUSwRR5G0qvUv29of7TyPLUCPLf4lJfB+dcPOWGu5Xivgb7komsZRDui+pIN+dyEaR1qYH6iERNww+c+nSjsJJrY3+rK5g+cZ3Vf1sAiDSf6uDi9wsjUcvC6gG4nMj696tU4p5yuAMAH1ZiZcIRnIhnH0AH2xt+qqDTvdM79FOmUgxAzwB7/vUacFQuINzQAk33gxmeGxzFVvrMWk20i6/C04uM1pyBLKzOxXySiaNozm74SwbdjD6VB9lEeq3JlVCq5Yoi6RlISFJXHKpq77RBeYmnEpc4aXZeZHknoTfRHyZzO0zxJ r14P8tM1 yycolgZ6iLsAuUR3+6/zqqvLRu0OgIcdX+IbiE2eQ0ldTHZCzjYcoBgFdU089v0Fc9/zW+SQcRzH/QC0t+V9BDF49CeMBPnBvUBSGBeAhpfW9xWEoHSpc8C4uniIxPtXDv6TMBh1f5ckMwery2tqaG1vrUi+Fsq4dnw6yN73dS6opPs+8tXZ7IWsTG/jNceISPy1GZuIfA6Otis+2h3kodVpGr3XBAU4ckSZV5jWJCvy5PXGUHrIZCFqlMnMMN77gv7k5C83n3sdwncA= 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: [...] >>>> +static inline bool mm_is_user(struct mm_struct *mm) >>>> +{ >>>> + /* >>>> + * Don't attempt to apply the contig bit to kernel mappings, because >>>> + * dynamically adding/removing the contig bit can cause page faults. >>>> + * These racing faults are ok for user space, since they get serialized >>>> + * on the PTL. But kernel mappings can't tolerate faults. >>>> + */ >>>> + return mm != &init_mm; >>>> +} >>> >>> We also have the efi_mm as a non-user mm, though I don't think we manipulate >>> that while it is live, and I'm not sure if that needs any special handling. >> >> Well we never need this function in the hot (order-0 folio) path, so I think I >> could add a check for efi_mm here with performance implication. It's probably >> safest to explicitly exclude it? What do you think? > > Oops: This should have read "I think I could add a check for efi_mm here > *without* performance implication" It turns out that efi_mm is only defined when CONFIG_EFI is enabled. I can do this: return mm != &init_mm && (!IS_ENABLED(CONFIG_EFI) || mm != &efi_mm); Is that acceptable? This is my preference, but nothing else outside of efi references this symbol currently. Or perhaps I can convince myself that its safe to treat efi_mm like userspace. There are a couple of things that need to be garanteed for it to be safe: - The PFNs of present ptes either need to have an associated struct page or need to have the PTE_SPECIAL bit set (either pte_mkspecial() or pte_mkdevmap()) - Live mappings must either be static (no changes that could cause fold/unfold while live) or the system must be able to tolerate a temporary fault Mark suggests efi_mm is not manipulated while live, so that meets the latter requirement, but I'm not sure about the former? Thanks, Ryan