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 5B334C48260 for ; Tue, 13 Feb 2024 14:21:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E10888D0011; Tue, 13 Feb 2024 09:21:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC0DA8D000E; Tue, 13 Feb 2024 09:21:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB0708D0011; Tue, 13 Feb 2024 09:21:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B96B48D000E for ; Tue, 13 Feb 2024 09:21:15 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 89DFD1A0B26 for ; Tue, 13 Feb 2024 14:21:15 +0000 (UTC) X-FDA: 81786992910.06.95FD4E3 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id EE96C180028 for ; Tue, 13 Feb 2024 14:21:12 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707834073; 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=gYjYYAvSla/WCu/GGnDV07epZGF6LvaP1khAfrd0siA=; b=By5p5/v8g3R4Ke1vbvyZVBq58T38M6KsRUOYZL5/OIi7LyMhLuKMBh2/vTK1MdL9U75zNC cHkHWiJA8Kc8bWKW88SjGDNKB0I6LYkHlFX+4QH8khV3BnvYqyxYh2rOPaRB5jUKBcuHqj Kk3YU5vFHQCkGVafIPI8eH/PjDxLCOI= 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 ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707834073; a=rsa-sha256; cv=none; b=qtxx7Bdh4p+wkLCNDJcUwRG4wwA/ZKbWJMdwwjEIGNssKXpK9I5ENIYCw3B7FIPyA9XcDO rii98C0e/21dHfui19jR32UluJI2K2UNMB9pavxlXd8CTcL5pa54+DNOKCoiY1rFvqtTjQ vHatNr/FitOUTMpl1venydwHr3/fjnE= 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 355E0DA7; Tue, 13 Feb 2024 06:21:53 -0800 (PST) Received: from [10.1.36.184] (XHFQ2J9959.cambridge.arm.com [10.1.36.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5BF583F762; Tue, 13 Feb 2024 06:21:08 -0800 (PST) Message-ID: Date: Tue, 13 Feb 2024 14:21:07 +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 To: Ard Biesheuvel , David Hildenbrand Cc: Mark Rutland , Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , 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> <64395ae4-3a7d-45dd-8f1d-ea6b232829c5@arm.com> <41499621-482f-455b-9f68-b43ea8052557@redhat.com> <1d302d7a-50ab-4ab4-b049-75ed4a71a87d@arm.com> <99e2a92c-f2a2-4e1e-8ce2-08caae2cb7e4@redhat.com> <64b872bd-4b12-4dbd-b043-1ad11aeaa19a@redhat.com> <3de2130b-9f0f-4a11-ac06-7bf814de641c@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: EE96C180028 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 4cxdpawko4i8id11dczntii1jdqoqa1u X-HE-Tag: 1707834072-263412 X-HE-Meta: U2FsdGVkX19c/+CV03I4DTAIwGgfZcTyb4WNJZGGx9P7bfeTtHc92p6FxfLQlEP5HNW27LicRu4aAJaa33HatpoA+nlphs89c67PJ9sO3kAiSagkwQ1HA7VvSCePHWoCdasuWEzpQzScWIJGJwsJUanUcZMFiskEUQIxUI4OduZHFdcEVtpnjxfKhvCu0HkZSzoCfHLN4NWb3xU1zcZ3a+t7a5Ve7HrlWILtZl1IcBpviYwJ0l3jvcSC3g4cRCHHUfHElT9bUasKtTR6JXoHBcOV8hzH0OpEOOmHyJQ0J/l+LdhTQJmcHnz/iTnZVTcuuD2lTLa1NqA3Jk/PJD9omkKHYWXA3ulHo7W42i/GjI7MgrVDOmJc0w81a+vwMyq7roEJgQfyNG/sXt4YoxmcwgUwhVLhzxdfuHeAIkOKHG99m+ahBcGiXvpUEOmF9A2LC35SWEh4LpoiKvJHhSlWmtSzUJ/00Rfylv6//syBe5SgiSjtSuLNDkEjSWFH1Dpg3905HADsLiD25dt8vete9LDOX5Tsw9oqNK/c4S8f1v+pT9TVHPjTdqifbe08Pzftv51p2QutMNWV7Rm+IZGtHr1f4FbMasfwAixOqYFuc3HAIMd+kIlmIs/gNM6kGmhkUPuGWKCnaDV0yg1nMdaLGtwtpS90HqI698E7rECM2rf9s/o4ctQKdAk80YEqYD5i+SKu55XteTY+y3iiBS3vc05SlnG1iRF/VK7wvka7zhITvzSfbtnfqkmvGSD8Ly+XXrEGNwzA4jIoNTjXJiFBfuCMVM2jHv+lhVZqIdLsw9ZQnEXCYNIl5nUCU+6xQTAlOd0IMG1Yx1d8ePpRP+bfJcaLwIN2Wvpe7h1c+CzTy/LR9k4+f4RNY8we7mZA7FvZg45nEdu294tqPR95UO972YwjwkS/vgCTjHN8O/oosmwenqiekNnIB9xh9ph8E16MhvzsoGwXsulk9vTrJt4 O/Q== 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 13/02/2024 14:08, Ard Biesheuvel wrote: > On Tue, 13 Feb 2024 at 15:05, David Hildenbrand wrote: >> >> On 13.02.24 15:02, Ryan Roberts wrote: >>> On 13/02/2024 13:45, David Hildenbrand wrote: >>>> On 13.02.24 14:33, Ard Biesheuvel wrote: >>>>> On Tue, 13 Feb 2024 at 14:21, Ryan Roberts wrote: >>>>>> >>>>>> On 13/02/2024 13:13, David Hildenbrand wrote: > ... >>>>>>> Just a thought, you could have a is_efi_mm() function that abstracts all that. >>>>>>> >>>>>>> diff --git a/include/linux/efi.h b/include/linux/efi.h >>>>>>> index c74f47711f0b..152f5fa66a2a 100644 >>>>>>> --- a/include/linux/efi.h >>>>>>> +++ b/include/linux/efi.h >>>>>>> @@ -692,6 +692,15 @@ extern struct efi { >>>>>>> >>>>>>> extern struct mm_struct efi_mm; >>>>>>> >>>>>>> +static inline void is_efi_mm(struct mm_struct *mm) >>>>>>> +{ >>>>>>> +#ifdef CONFIG_EFI >>>>>>> + return mm == &efi_mm; >>>>>>> +#else >>>>>>> + return false; >>>>>>> +#endif >>>>>>> +} >>>>>>> + >>>>>>> static inline int >>>>>>> efi_guidcmp (efi_guid_t left, efi_guid_t right) >>>>>>> { >>>>>>> >>>>>>> >>>>>> >>>>>> That would definitely work, but in that case, I might as well just check for it >>>>>> in mm_is_user() (and personally I would change the name to mm_is_efi()): >>>>>> >>>>>> >>>>>> static inline bool mm_is_user(struct mm_struct *mm) >>>>>> { >>>>>> return mm != &init_mm && !mm_is_efi(mm); >>>>>> } >>>>>> >>>>>> Any objections? >>>>>> >>>>> >>>>> Any reason not to use IS_ENABLED(CONFIG_EFI) in the above? The extern >>>>> declaration is visible to the compiler, and any references should >>>>> disappear before the linker could notice that efi_mm does not exist. >>>>> >>>> >>>> Sure, as long as the linker is happy why not. I'll let Ryan mess with that :) >>> >>> I'm not sure if you are suggesting dropping the mm_is_efi() helper and just use >>> IS_ENABLED(CONFIG_EFI) in mm_is_user() to guard efi_mm, or if you are suggesting >>> using IS_ENABLED(CONFIG_EFI) in mm_is_efi() instead of the ifdefery? >>> >>> The former was what I did initially; It works great, but I didn't like that I >>> was introducing a new code dependecy between efi and arm64 (nothing else outside >>> of efi references efi_mm). >>> >>> So then concluded that it is safe to not worry about efi_mm (thanks for your >>> confirmation). But then David wanted a VM_WARN check, which reintroduces the >>> code dependency. So he suggested the mm_is_efi() helper to hide that... This is >>> all starting to feel circular... >> >> I think Ard meant that inside mm_is_efi(), we could avoid the #ifdef and >> simply use IS_ENABLED(). >> > > Yes. > > static inline void mm_is_efi(struct mm_struct *mm) > { > return IS_ENABLED(CONFIG_EFI) && mm == &efi_mm; > } Ahh, got it. Yes, I'll do it like this. Thanks!