mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gupta, Pankaj" <pankaj.gupta@amd.com>
To: Sean Christopherson <seanjc@google.com>
Cc: "David Hildenbrand (Arm)" <david@kernel.org>,
	pbonzini@redhat.com, tglx@kernel.org, bp@alien8.de,
	mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org,
	thomas.lendacky@amd.com, hpa@zytor.com, yangge1116@126.com,
	ljs@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] KVM: SEV: drop FOLL_WRITE for encrypted region registration
Date: Tue, 21 Jul 2026 04:08:57 +0200	[thread overview]
Message-ID: <001fa28e-0355-4f06-9110-d8ef44d963e3@amd.com> (raw)
In-Reply-To: <al579lcf0NnxhD3T@google.com>

>>>> Commit 7e066cb9b71a ("KVM: SEV: Use long-term pin when registering
>>>> encrypted memory regions") added FOLL_LONGTERM to
>>>> sev_mem_enc_register_region() so anonymous guest RAM is migrated out of
>>>> MIGRATE_CMA/ZONE_MOVABLE before a long term pin. It also kept
>>>> FOLL_WRITE on the pin.
>>>>
>>>> Combining FOLL_WRITE with FOLL_LONGTERM breaks registration of file-backed
>>>> guest memory, such as virtio-pmem host memory-backend-file mappings
>>>> (MAP_SHARED). GUP rejects long-term writable pins on dirty tracked file
>>>> mappings since:
>>>>
>>>> commit 8ac268436e6d ("mm/gup: disallow FOLL_LONGTERM GUP-nonfast writing to file-backed mappings")
>>>> commit a6e79df92e4a ("mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings").
>>>>
>>>> Region registration only requires long-term pin to prevent page migration and
>>>> does not write through this GUP pin.
>>>>
>>>> Drop FOLL_WRITE and pin guest memory only with FOLL_LONGTERM.
>>> Worth mentioning here something like
>>>
>>> "In the past, FOLL_WRITE was required to trigger CoW unsharing, making sure that
>>> we don't end up replacing the page in the page tables during a later write fault
>>> after already having pinned a (shared) page in MAP_PRIVATE mappings.
>>> FOLL_LONGTERM does that nowadays (see gup_must_unshare()) even without FOLL_WRITE.
> Heh, this was going to be my exact question about why it was safe to drop FOLL_WRITE :-)
>
>>> Given that SEV only pins RAM for XYZ and doesn't actually write to the pinned
>>> pages, we can just drop the FOLL_WRITE"
>>>
>>> Fill out XYZ :)
>> Sure :)
>>
>> I will update the commit message in v3.
> No need for a v3, I'll add a blurb when applying.

Thanks, Sean!

Best regards,

Pankaj


  reply	other threads:[~2026-07-21  2:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15  6:36 Pankaj Gupta
2026-07-15  7:35 ` Lorenzo Stoakes (ARM)
2026-07-15  9:49 ` David Hildenbrand (Arm)
2026-07-15 14:09   ` Gupta, Pankaj
2026-07-20 19:50     ` Sean Christopherson
2026-07-21  2:08       ` Gupta, Pankaj [this message]
2026-07-31 20:10 ` Sean Christopherson

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=001fa28e-0355-4f06-9110-d8ef44d963e3@amd.com \
    --to=pankaj.gupta@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@kernel.org \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    --cc=yangge1116@126.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

all inboxes | Powered by JetHome®