Re: [PATCH] KVM: SEV: drop FOLL_LONGTERM for encrypted region registration
From: David Hildenbrand (Arm)
Date: Wed Jul 01 2026 - 12:42:39 EST
On 7/1/26 18:30, Sean Christopherson wrote:
> On Wed, Jul 01, 2026, David Hildenbrand (Arm) wrote:
>> On 7/1/26 16:45, Pankaj Gupta wrote:
>>> 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. This breaks
>>> virtio-pmem which has file backed (MAP_SHARED) host mapping where GUP rejects
>>> FOLL_WRITE | FOLL_LONGTERM 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").
>>>
>>> Drop FOLL_LONGTERM when registering encrypted memory regions and restore
>>> the previous behavior.
>>
>> But that breaks the original issue of breaking ZONE_MOVABLE/CMA?
>
> Ya.
>
>> If it is a longterm pin, it must use FOLL_LONGTERM. :/
>
> Heh, well, KVM showed that that's not entirely true for many years :-)
What exactly do you mean? KVM MMUs sync through memory notifiers and doesn't
need this.
It's only our "interesting" CoCo code :)
>
> Assuming we can't solve this some other way, and that there are "real" use cases
> that were broken by adding FOLL_LONGTERM, maybe this as a hack-a-fix?
Well, it's not a driver's decision to make. :P
But, can we actually whitelist virtio-pmem in GUP code somehow?
I mean, it does not suffer from the documented writeback issue, that we wanted
to protect from. We similarly allow shmem and hugetlb there.
--
Cheers,
David