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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A6EF104951B for ; Wed, 11 Mar 2026 09:38:58 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fW5Kr2xH9z3dHR; Wed, 11 Mar 2026 20:38:56 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2a00:1450:4864:20::64a" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1773221936; cv=none; b=B/bTGs7X7jpDVwV9zQMysk+om+Hh2dP5JlaU8TzFxNCyqu4th09UgksbzKcheiFv4ZuMMvb0KQb6LP3P8U9YCv39ubp3K7Ss2CtyCDmx5kNZJVVj1x7DWEjujMO2G4odJ5xPeubn0hIFpQckUMVELG8GBkLp+3pZ74G5WCUG8EV3ZBM5VOQzh5J1UHnYR/pBFeZTRLKUtp9FmMp4a49EZiSj6yAUbKWcewkLYGzEBZuD/OuEAbITHJk1rVxeeSd08hDsv123phhH1uGi3/xQRhEW4crjDV/TkaUMediUC70bHsbWUUyOF/4lVSKCbZDLkqMe7bgC7oxronWXSw2TAQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1773221936; c=relaxed/relaxed; bh=RQubQpcCCRw5LR5oprIFTZzoSHmrBMbhMG4Ewb+bDNM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bS6CQLH5XzTK68bSoQrSIJnZgyJ9AFb9ylT2BuMzJftGwdWMjhGvw8yZ53aKxOAU5GDHC/rLD0LYdagL92byLVbk37aFvO+dSYcoPkXjGy2jj8HJktvXwoa5cr/nCy2riiuMO58SM2cL2Eg6XsW6/2jAUD49HrSrKY94I2W56RqlVN93QI3JVWltvHZWpxaWRSEvar1IyJzkxm1Tno3m7Kjk4y9UGyzYWO4Ob02m959fM0pGBFIfXDBDBRjkwIPkyo6knufPNEiKuhg3FJf4OnHIrfbbkFiaMML1DY2B3hFU+jEuGUG/axF74cVF1GBDqR3B5P7c3SagO17K+6tHAw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=GUjg9Mt3; dkim-atps=neutral; spf=pass (client-ip=2a00:1450:4864:20::64a; helo=mail-ej1-x64a.google.com; envelope-from=3kdixaqkkdlercztvipycxffxcv.tfdczeloggt-uvmczjkj.fqcrsj.fix@flex--aliceryhl.bounces.google.com; receiver=lists.ozlabs.org) smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=GUjg9Mt3; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--aliceryhl.bounces.google.com (client-ip=2a00:1450:4864:20::64a; helo=mail-ej1-x64a.google.com; envelope-from=3kdixaqkkdlercztvipycxffxcv.tfdczeloggt-uvmczjkj.fqcrsj.fix@flex--aliceryhl.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-ej1-x64a.google.com (mail-ej1-x64a.google.com [IPv6:2a00:1450:4864:20::64a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fW5Kp55X3z3dHM for ; Wed, 11 Mar 2026 20:38:54 +1100 (AEDT) Received: by mail-ej1-x64a.google.com with SMTP id a640c23a62f3a-b96e5eb1acaso307916666b.3 for ; Wed, 11 Mar 2026 02:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773221929; x=1773826729; darn=lists.ozlabs.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=RQubQpcCCRw5LR5oprIFTZzoSHmrBMbhMG4Ewb+bDNM=; b=GUjg9Mt3rVYRa4wJsLbEfiCO1cncv3NWl4Q+RzmJ4uo8NgWrAZJXKAKn9YiSJLSxCF CwucQpBBhFwvh82BtBjinjXhhvOCUQ/OL53CS+UBxRAjBN1OJ6IkLM7cscXKD3evIFRB ZM7WznQeLta9gysPHbDUfNIoGG8NP7KPut0/q+IsnefIra+kVefIZprRc38BL04saRrC Oyz/50TQ9Mw9e1QwEzmA8bDzFqAy4D9TvKidSL1RYK7vz7PDvDWq+42wFuoXeXKRQUuH D1GhXcJ9mxU/ii/haGmKNDH/BQCee03x3JWOvE+pOm8EqIVJRQV41HBZSy/CkAuUxTJL oSEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773221929; x=1773826729; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RQubQpcCCRw5LR5oprIFTZzoSHmrBMbhMG4Ewb+bDNM=; b=QA2ZhzVx8blGf4L7f6gYSnoONRb1KNSfJ3ktvz998khOyP4330IqHmMOMp6dacpmPs DJJOHaAtH8Xj6MGKK28zrLfT2bg4xcVUzmugmqYVjdCv917HzgSwO4QQIBTB3GaLEPvk CCR9L/GmZlUe/3Y2LeYk5zCOC3bxxq4mpKDlwmIEGm/diXEkgia7xEbh1FetsCWKX9Oj 9EGvDEmgiEdNPMG57ryEVxz5s26MKGYBauvCo74NqXl9ajKcJmVrEop1RuYhnnLD86e3 5fxrnfDS3GKaNaF+68tcd67QUSzBzbnVQlMC2zf6fSJklvML6huxDGmkNTRaqvKkQmh7 PcjA== X-Forwarded-Encrypted: i=1; AJvYcCWNJgMUgJBXHZ0hnTVLTWn4xbxUtYGmff6C8DFAiA6EUvvZrokhH6lA/mz89XGuIimdAyMmEehwbhsT9zA=@lists.ozlabs.org X-Gm-Message-State: AOJu0YzccPnmNQ51dkRpsUeuN+g0RLlrxDAyhpC0p8pGEvEvkTKcBvMz HvPstjOwnX698rtYpqCUKPxBK5/xlnRvYc0FCilIfPWSt4CdAHW1kfDYYIYARxHFfyCSzEoyKJd pZNKoBahxwhtmZBDSKg== X-Received: from ejja22.prod.google.com ([2002:a17:906:3e96:b0:b8e:ad99:be59]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a17:906:f592:b0:b87:2abc:4a32 with SMTP id a640c23a62f3a-b972e1d254cmr101140266b.18.1773221928398; Wed, 11 Mar 2026 02:38:48 -0700 (PDT) Date: Wed, 11 Mar 2026 09:38:45 +0000 In-Reply-To: <61df6369-333c-430a-bd18-c5b1acae68ea@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list Mime-Version: 1.0 References: <20260227200848.114019-1-david@kernel.org> <20260227200848.114019-17-david@kernel.org> <20260309142954.GM1687929@ziepe.ca> <61df6369-333c-430a-bd18-c5b1acae68ea@kernel.org> Message-ID: Subject: Re: [PATCH v1 16/16] mm/memory: support VM_MIXEDMAP in zap_special_vma_range() From: Alice Ryhl To: "David Hildenbrand (Arm)" Cc: Jason Gunthorpe , linux-kernel@vger.kernel.org, "linux-mm @ kvack . org" , Andrew Morton , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jann Horn , Pedro Falcato , David Rientjes , Shakeel Butt , "Matthew Wilcox (Oracle)" , Madhavan Srinivasan , Michael Ellerman , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Jarkko Sakkinen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Greg Kroah-Hartman , "Arve =?utf-8?B?SGrDuG5uZXbDpWc=?=" , Todd Kjos , Christian Brauner , Carlos Llamas , Ian Abbott , H Hartley Sweeten , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Leon Romanovsky , Dimitri Sivanich , Arnd Bergmann , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Andy Lutomirski , Vincenzo Frascino , Eric Dumazet , Neal Cardwell , "David S. Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , Miguel Ojeda , linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-sgx@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org, rust-for-linux@vger.kernel.org, x86@kernel.org Content-Type: text/plain; charset="utf-8" On Wed, Mar 11, 2026 at 10:15:12AM +0100, David Hildenbrand (Arm) wrote: > On 3/9/26 15:29, Jason Gunthorpe wrote: > > On Fri, Feb 27, 2026 at 09:08:47PM +0100, David Hildenbrand (Arm) wrote: > >> There is demand for also zapping page table entries by drivers in > >> VM_MIXEDMAP VMAs[1]. > >> > >> Nothing really speaks against supporting VM_MIXEDMAP for driver use. We > >> just don't want arbitrary drivers to zap in ordinary (non-special) VMAs. > >> > >> [1] https://lore.kernel.org/r/aYSKyr7StGpGKNqW@google.com > > > > Are we sure about this? > > Yes, I don't think relaxing this for drivers to use it on VM_MIXEDMAP is > a problem. > > > > > This whole function seems like a hack to support drivers that are not > > using an address_space. > > I assume, then using > unmap_mapping_folio()/unmap_mapping_pages()/unmap_mapping_range() instead. > > > > > I say that as one of the five driver authors who have made this > > mistake. > > > > The locking to safely use this function is really hard to do properly, > > IDK if binder can shift to use address_space ?? > I cannot really tell. > > Skimming over the code, it looks like it really always handles "single > VMA" stuff ("Since a binder_alloc can only be mapped once, we ensure the > vma corresponds to this mapping by checking whether the binder_alloc is > still mapped"), which makes the locking rather trivial. > > It does seem to mostly allocate/free pages in a single VMA, where I > think the existing usage of zap_vma_range() makes sense. > > So I'm not sure if using address_space would really be an improvement there. > > Having that said, maybe binder folks can be motivated to look into that. > But I would consider that future work. It doesn't really make sense to have multiple binder VMAs. What happens with Rust Binder is that process A is receiving transactions and has the VMA mapped once. * Process B sends a transaction to process A, and the ioctl (running in process B) will memcpy the message to A directly into the pages of A's VMA. * Then, B wakes up A, which causes A to return from the receive ioctl. * The return value of the receive ioctl is a pointer, which points somewhere inside A's VMA to the location containing the message from B. * Process A will deref the pointer to read the message from B. * Once Process A is done handling the transaction, it invokes another ioctl to tell the kernel that it is done with this transaction, that is, it is not safe for the kernel to reuse that subset of the VMA for new incoming transactions. When Binder returns from its ioctl and gives you a pointer, it needs to know where the VMA is mapped, because otherwise it can't really give you a pointer into the VMA. It's generally not safe for userspace to touch its Binder VMA unless it has been told that there is a message there. Pages that do not contain any messages may be entirely missing, and trying to read them leads to segfault. (Though such pages may also be present if there was previously a message in the page. The unused pages are kept around to reuse them for future messages, unless there is memory pressure.) Alice