Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Zi Yan <ziy@nvidia.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	linux-mm@kvack.org, Lorenzo Stoakes <ljs@kernel.org>,
	Lance Yang <lance.yang@linux.dev>,
	Kiryl Shutsemau <kas@kernel.org>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RDMA/uverbs: Don't return the shared zero page from rdma_umap_fault()
Date: Thu, 29 Oct 2026 11:44:46 +0100	[thread overview]
Message-ID: <b2eac616-fa24-422c-b0b1-3247befbd277@kernel.org> (raw)
In-Reply-To: <EBA77B7E-B4AE-4725-8E82-061676C9B1DE@nvidia.com>

On 10/29/26 03:00, Zi Yan wrote:
> On 28 Oct 2026, at 16:34, David Hildenbrand (Arm) wrote:
> 
>> On 10/28/26 18:49, Zi Yan wrote:
>>>
>>>
>>> Not urgent. Like Jason said in another email, RDMA only runs on arch
>>> with special PTE, so refcount, mapcount, rss are balanced. With DEBUG_VM,
>>> zero_page checks in rmap will fire on the returned zero_page.
>>>
>>>
>>> There is one wrinkle, it does not work on
>>> s390 + mm_forbids_zeropage() == true, where zero page is not present,
>>> and a private zero page is needed.
>>
>> Yes, see vm_mixed_zeropage_allowed() I added.
>>
>> In a VM_PFNMAP it doesn't matter. It's only a problem if we can GUP involved
>> IIRC, and VM_PFNMAP just disallows it entirely.
>>
>> Similar for s390, it doesn't support any form of memory deduplication (incl.
>> shared zeropage) for some KVM use cases. IIRC, PFNMAP does not really apply there.
> 
> Got it. It is then all clear to modify vmf_insert_pfn_prot() to support
> zeropage for VM_PFNMAP (no huge zeropage support will be added).
> 
>>
>> (have to make sure that gup-fast doesn't try pinning the shared zeropage)
> 
> With special pte, GUP-fast bails out on the PTE. Without special pte,
> gup_fast_pte_range() simply returns 0. Then GUP slow rejects VM_PFNMAP.
> 
>>
>> (of course, the shared zeropage must never get mapped writable)
> 
> vmf_insert_pfn_prot() will only accept a shared zeropage on a VMA if the
> VMA has neither VM_WRITE nor VM_MAYWRITE. It should prevent the VMA
> becoming writable. Also it will ensure the result PTE is not writable.
> 
> As we discussed on IRC, VM_WARN_ON_ONCE_VMA(vma->vm_flags & VM_PFNMAP, vma)
> will be added after __do_fault() to enforce no page is returned
> from ->fault().
> 
> Since it is not urgent, I will probably send V2 after rc1 is out.
> Thank you for all the info.

Thanks for handling this!

-- 
Cheers,

David

      reply	other threads:[~2026-10-29 10:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26  2:04 [PATCH] RDMA/uverbs: Don't return the shared zero page from rdma_umap_fault() Zi Yan
2026-10-26  2:20 ` sashiko-bot
2026-10-26  8:55 ` Jose A. Perez de Azpillaga
2026-10-26 11:49 ` Jason Gunthorpe
2026-10-26 15:41   ` Zi Yan
2026-10-26 12:20 ` David Hildenbrand (Arm)
2026-10-26 15:48   ` Zi Yan
2026-10-28  8:43     ` David Hildenbrand (Arm)
2026-10-28 17:49       ` Zi Yan
2026-10-28 20:34         ` David Hildenbrand (Arm)
2026-10-29  2:00           ` Zi Yan
2026-10-29 10:44             ` David Hildenbrand (Arm) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2eac616-fa24-422c-b0b1-3247befbd277@kernel.org \
    --to=david@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kas@kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox