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 27FD4D2F7CC for ; Wed, 16 Oct 2024 21:45:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA9116B007B; Wed, 16 Oct 2024 17:45:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A59E86B0082; Wed, 16 Oct 2024 17:45:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 921636B0083; Wed, 16 Oct 2024 17:45:49 -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 712826B007B for ; Wed, 16 Oct 2024 17:45:49 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BE100AAE05 for ; Wed, 16 Oct 2024 21:45:28 +0000 (UTC) X-FDA: 82680797724.10.E5922C5 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) by imf11.hostedemail.com (Postfix) with ESMTP id B09F540004 for ; Wed, 16 Oct 2024 21:45:36 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=tU4ZhuCZ; spf=pass (imf11.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.178 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729115002; 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:dkim-signature; bh=v5cxppTEMM7NUJQ2rhvny6tsM0muKpV+U5GhjqYjGB4=; b=imZMcGAvEb5gRHYY2zhCKGj62GRXXi/6OrneN9HdDc8XFI35ClOiqFE1EBpKS6qfiOqQw7 lDcm+G3ND5DLIql/TzqGtW3kwVefvMLXOOMeSTjqTW/qOl9kM/YlAY5gT5dmWyeTTC6nmh HV4xTUSWXnnS9jIWblBS75uKGAPN6qE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729115002; a=rsa-sha256; cv=none; b=b+QOshKY1tDhauMwnnMgSIJNFxumCaKlB99yqsKQt+CecuPbKMTT7fK3nbHnkbkbrZNpxp O2WlNZdJ3QF6lcED0ZGV0hlcdwo6HU8+9plbTysdIkLjKzD9nxcKzJ8rVfNTdzjuaPetbk we5skK1NlcLnzHv82BjzZ+v6lzG53s8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=tU4ZhuCZ; spf=pass (imf11.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.178 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Wed, 16 Oct 2024 14:45:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1729115145; h=from:from: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=v5cxppTEMM7NUJQ2rhvny6tsM0muKpV+U5GhjqYjGB4=; b=tU4ZhuCZJKMgX7Vht4WtZmHqMrcvFgLxy4ZoA/bDRs+sRX/YFmu5OUMY7gbvgpIJANpft9 WYYI2QfKlBdgkAyFx8WmTjfvjfqLd+/WXtebKXI+G3Tk3GuDsfvnAVTxpEV6RpdIDVBIcF dGMdsygCheqtOw2+pbk2SOLtqzItV0o= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Yosry Ahmed Cc: Andrii Nakryiko , bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, martin.lau@kernel.org, linux-mm@kvack.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, Yi Lai , pbonzini@redhat.com, seanjc@google.com, tabba@google.com, david@redhat.com, jackmanb@google.com, jannh@google.com, rppt@kernel.org Subject: Re: [PATCH bpf] lib/buildid: handle memfd_secret() files in build_id_parse() Message-ID: <55xdknbnbcyj4fv3qfoqrjyc5okfxltlcbkxmmdhvb5eflgexs@y6b5nfrpr4ex> References: <20241014235631.1229438-1-andrii@kernel.org> <2rweiiittlxcio6kknwy45wez742mlgjnfdg3tq3xdkmyoq5nn@g7bfoqy4vdwt> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 1iyxs3anyg4mecp4zukw3sixbmgqqimg X-Rspamd-Queue-Id: B09F540004 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729115136-435207 X-HE-Meta: U2FsdGVkX1/pJTs+6hCRYuDS0ypRrFs6VND2p5z3csO6Ai/AuF15qfnsrG8vEYOFo/DpQh+diVr8rm39Da6TQhzY9z58anSU1VVAk4cJRUljtWFbY8u/W98fzrjT3SiFYqq/Sq8bpJLpm1TjdonMwy2fRb4uT0QzBOu2R6/c2S0IjufZTMEDaDwKidcmAi1krS63RgdnmYDShI5FdOwIjNPUZv2U4RVQ9GmyFUemPOKouBNYQsl0B5eqDUujp34hM648ht1RCt8rv90I3cBQ+tUjxaKQstbWK90w4Mg5OqTv7zQXa8BWEzYud0BuVRjZvcAZ10u14gJ6MIOc2/TPFrUZylPEaT3j0l2+arOITo3prKOjrwtnd3Z9haOBVagCqD+cdM8TbKDVBWN2z4IVHG+dE/QD8Py3sxVEbOd41zKEYrMFJFj1ibj2acuQGrb47VL9/hL2eN1hpPk/B3IFdI5I9e+/T7w85fmYFGa+iwB7nE9p9XrYCsZOywoHXdChFyhGKPkfwb6M5j6Nr0fTq97MPG1pamXLHugBYj9vVshTKW3W7g/02oS/LLtG9iCMne4A5E55aDULLF5zrDK0Q9MBrNCCiR6v+5oPBmORvB66jSSMcyzF1ZXVK/XiQWU5aM2SttzkkzOclahKVauhGjr67lKAuR787Hxzo08+2qPK0DyuEGhKTyBwXlG+yeWi+x/c1Ob8ar9Lq2Mjratuy/YPx5KP28naD+svesujQQP9Tc9WnM1N9qWAlhkxct9zJGtKx+liLisXUwz3lUgOOPBRKBz5XxrVcLhWSfPzLQLzHCE76LITQLEwFVt3RXEXX5YUws6K68GAsFMCCWWcYZRWk7ew6J4btxy1A0Oq4IOT9ti0lByx+LKvjKdA5zBwKkgeDa2bXGpwbK3xOYzJHWwD0Pwti9bnDAe7ws6prN38I7MA9jJRgyGgcRWSyGJAMWlegrNHtFEWxH3eSCw koHVnzsf RkQiFwAuipvcHVQmk40kX9/YDMrrdhYbLr+vgeIpXw34kTyczJFF3Lphcl8rCE4v4WCMHxjL7u+zBi1G697aGrIhHxeUQMVJD47y7dpi3OhYE30ZrNpp0jxz35oXNX4E/l/oUG2KzBHj8pbRtd81PhVqk59nq/oBvjCnTIqjhfTlVoyLpjbosDaNBFW0ACYBvqfgUhdQRmv69Rnwc840XDG6Nv9LrJbpwZtm3 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 Wed, Oct 16, 2024 at 12:59:13PM GMT, Yosry Ahmed wrote: > On Wed, Oct 16, 2024 at 11:39 AM Shakeel Butt wrote: > > > > Ccing couple more folks who are doing similar work (ASI, guest_memfd) > > > > Folks, what is the generic way to check if a given mapping has folios > > unmapped from kernel address space? > > I suppose you mean specifically if a folio is not mapped in the direct > map, because a folio can also be mapped in other regions of the kernel > address space (e.g. vmalloc). > > From my perspective of working on ASI on the x86 side, I think > lookup_address() is > the right API to use. It returns a PTE and you can check if it is > present. > > Based on that, I would say that the generic way is perhaps > kernel_page_present(), which does the above on x86, not sure about > other architectures. It seems like kernel_page_present() always > returns true with !CONFIG_ARCH_HAS_SET_DIRECT_MAP, which assumes that > unmapping folios from the direct map uses set_direct_map_*(). > > For secretmem, it seems like set_direct_map_*() is indeed the method > used to unmap folios. I am not sure if the same stands for > guest_memfd, but I don't see why not. > > ASI does not use set_direct_map_*(), but it doesn't matter in this > context, read below if you care about the reasoning. > > ASI does not unmap folios from the direct map in the kernel address > space, but it creates a new "restricted" address space that has the > folios unmapped from the direct map by default. However, I don't think > this is relevant here. IIUC, the purpose of this patch is to check if > the folio is accessible by the kernel, which should be true even in > the ASI restricted address space, because ASI will just transparently > switch to the unrestricted kernel address space where the folio is > mapped if needed. > > I hope this helps. > Thanks a lot. This is really helpful.