Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp3068793rdb; Tue, 13 Feb 2024 06:09:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUBQCqKcQhkaGQFG4KOqb6veYvaMKLYj0lUJu97ctyjhbSWvAOve9QMrpxYfpQsj0R29l3Xc4hQwVVSK/h+/y9aES7jCKd44xAhvRVKmg== X-Google-Smtp-Source: AGHT+IHjJBzMQwr+1ZityHyZUL2bmvKR/bs8kkKl0Y9m5Lw7xXwzbYkInp3NV5gea0AR077d510G X-Received: by 2002:a17:902:da88:b0:1d9:4a08:71f9 with SMTP id j8-20020a170902da8800b001d94a0871f9mr9964745plx.31.1707833340833; Tue, 13 Feb 2024 06:09:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVdS8D5ByW1WDb7dtByK6TI/HtgGW1Tq85vNjhhISjhua2p/0ysS6WHgRCYqLFOF8ZJPWbCHzmlUWzlceG0jMTbvpi0gTXh6W96gttSnA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u6-20020a17090341c600b001d73e8bbf45si1180603ple.349.2024.02.13.06.09.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 06:09:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63642-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b="Tu/LiHhQ"; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-63642-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63642-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 A19F12899F9 for ; Tue, 13 Feb 2024 14:08:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 386CC5731C; Tue, 13 Feb 2024 14:08:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Tu/LiHhQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DAF73EA78 for ; Tue, 13 Feb 2024 14:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833333; cv=none; b=c9bxhU7WfYvizz62DaSLcIhypoo9s/XNA6WLvqAAVs4nT2WumFuPeE2U7MiersSFk/zowD/4mvGRErMxpSIcdjqUKLkkaQ+FamoUbGoUoUkjJlvTKBobv0CiJjjTGe3Yz7MWKo13h/3y/jMh7YnWENJlDP/tU67cxiZZ8gLMmKM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833333; c=relaxed/simple; bh=TsHGewO4d1sZ/2Wke7Alzolt9Fz7V7TAkLcK4gqK7t4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=A97t2tOZN3iv3GfJSRMgYX9cHB3UUr6kHZJGWSUf1Pp8AAqtJQbMAhuhh4v6QVexODR5DZcniCLX63LtCG7I1Zga0X5T9hE+RATxrB3bkhKc0zoC0CL3yQ7AuFVuc1vDkZlJFvkH3ynmryMu1Dw/ekVYiOywTXDA+JTzzdjK1D8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tu/LiHhQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B91F0C433A6 for ; Tue, 13 Feb 2024 14:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707833332; bh=TsHGewO4d1sZ/2Wke7Alzolt9Fz7V7TAkLcK4gqK7t4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Tu/LiHhQ1ASQkknxYy5I2zbpBLo3Lke7GhTHufl7uofAXbgbEe1jZcVkcpsWcXG2f yRo4KTwjF0w0rUA57dPszbcC/4sDiwAtBb3k5omG8X2jUt5bVmzr6WXIxc69HK4IAh 4GBvbrLwnELnRYURYkRQ83RxSnTzgS90NWsYF3YxAX8/IIGbMzXnzd1QvwA62+kk+T tHOIU4Zy1ByBI3P71eRSNYhBol4KDImVoeQleaAwtHsB6F8Mfrjm+EMM3/EzF2piKO aE57OkljvhTV+9P73w0F7bFWZ/mjd9kJrufdcOsgKtH9g2zvdniF1QDKv8tCLb2Ssv WR+UMWaBwATzg== Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5116ec49081so4699984e87.2 for ; Tue, 13 Feb 2024 06:08:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUCW/qbfqo3ABqUyftdePQNW7y1cKXhR9nU2+yod482l4UGnh3QO3y+yQZdFwoulajL1f+tjGyW1OcsGobu3QXwwNALxcILe1LdOkxd X-Gm-Message-State: AOJu0YxXWQQB64AaWOu8qJcPpB4S0AMCC2dX319BPPZX0Xw8kipz2pmM Bn6WXW1q7P2hfktRw+XGePoU5DHH7zwifGpZNrIKgUSQBM09XMewuw9l/lXh0m7TjxOLYH/Q9xV 2GHODJKfXBc4yyP3O2HcVcTGWFgA= X-Received: by 2002:ac2:46da:0:b0:511:96d0:5ae1 with SMTP id p26-20020ac246da000000b0051196d05ae1mr1799024lfo.40.1707833330972; Tue, 13 Feb 2024 06:08:50 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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> In-Reply-To: From: Ard Biesheuvel Date: Tue, 13 Feb 2024 15:08:39 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 19/25] arm64/mm: Wire up PTE_CONT for user mappings To: David Hildenbrand Cc: Ryan Roberts , 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 Content-Type: text/plain; charset="UTF-8" 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; }