Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp3077867rdb; Tue, 13 Feb 2024 06:21:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUIElcGsJZgR9Ym+rOMYdQijRSHZpfxwem/qzUfK6z14CDDpwA7pJ1p9zz8xK4cC2BRJJzTewWUEdBcHEtqTIQkGwG7A0JyCI0a47NdLw== X-Google-Smtp-Source: AGHT+IFpYpirNp6H0gTVJ56igBv0bG2lTOPgc1/ehJzwDw0MWA2dtG3f71S88HWYPjdZHOkHZKa6 X-Received: by 2002:a05:6a20:c907:b0:19e:9c83:da3f with SMTP id gx7-20020a056a20c90700b0019e9c83da3fmr10252484pzb.38.1707834106721; Tue, 13 Feb 2024 06:21:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707834106; cv=pass; d=google.com; s=arc-20160816; b=FbNYKoZ9YMuMYconKueSWcyQh7S/mdgbVE6KxYBB8ctyk2TcSh5UyUXzjf0/E3Ey+/ 31ImVU1Qekf9Uo55jdTZgR2mrbxFccPVtKS+8UkjUqg/muZxvA4Nlr1fTqZqiwADKtmf OaCyqmO7CHSE/GBJsu7+5unEoMPLurUlsWZVvHceVGWWpgv3UAbhAelYl39O2TguA8mZ q42Mt7PFK0gAjtx2wAk+wz+r2+KOQt9q2HgMNR1GPq8nook5F1Wbt3g+SLolkN8Cm1T8 fauncVBdmo+3v7FvdVbIOGmuu+her2Y58UpGoNOiO8xvq447IK5bmtDJIh0mDQuCXwTz 2c4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=gYjYYAvSla/WCu/GGnDV07epZGF6LvaP1khAfrd0siA=; fh=wPR6o31SLd9cfHzkDbIIERiYyIyUpSFWj8beCl5S7Wo=; b=oQTApPE8v+6s4Zfl5DXWJqnPfgYSonYUhZMZMM88j/8zX22o1eEPtkwSWfhxWnsgyK 4moGcdWpvLbuCKCjwFtzUos4pOugfzwjAEH36X4YBauDveEPCgccWZG1LRNccJt2z+CT +ZNV3qmbjSQTnmYQ/t0WvI15liVa5CaFBfym7ctyA5xOb7CFp8ZVk2QjDake6brpRiV5 vEI4DIlHpjKncNgDxZpWySsrh3Ko0DLAJvtKoCzKs84VwgBGoZyMWZ0tsQp7uuYPEW+o HksCVW2SZfOiAKDMLbby4sVjAfo6Q8BebnAbFS1ZlLR0eF6tBZRR6HZRS63w5+kKKja+ F3WQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-63662-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63662-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCVISmN/tValaoL0LocxjidhjMO7Z/bqVy4oo+CbhHCsk4uukOMR5L+7NkJrrTPt/rWiFR6Y2vluU2PmyspRcYMmPa8rKfxNM/udPyg6/Q== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i123-20020a636d81000000b005cfbd190e58si2040917pgc.115.2024.02.13.06.21.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 06:21:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63662-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-63662-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63662-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 59ABB282C42 for ; Tue, 13 Feb 2024 14:21:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33EF557880; Tue, 13 Feb 2024 14:21:16 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4A305786A for ; Tue, 13 Feb 2024 14:21:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707834075; cv=none; b=F7xzKQ6ycJInFsp8Za+NWzyfe22PUEwKfbx64NUy2+jONATUhSqOt57ySiAepdl6pcm/Ccs40mzQnYZ4S8h2A3A5xhCDYLCiL2R+N0tGoIYwWlP8C3ZWwSKBZddo9kyT5eHj+/6vTUZ2UIlCRn69TVtX7PbZWDTRYs/xeli+568= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707834075; c=relaxed/simple; bh=ZgZD4/IRSWm0I0xvH8f9T7/SgKz7hTgSVO/jacBtv1M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Rv3NMY1SGQAUpb55a002EpQn/DwSCiMYXueD3M5j5KLXd0J+v15u3mJkoxLCFlnCnzop7FGZgl6vCID5Hv9bN2eAlfcXE25KnDf8GO4h7nfQO41449Hkr91xr0vC7Lb2KddVxTQIRlnNMXSdveS2Z60ffehCi5oFt+3df69gpxw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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!