Re: [PATCH] KVM: SEV: drop FOLL_LONGTERM for encrypted region registration

From: Lorenzo Stoakes

Date: Fri Jul 10 2026 - 13:02:35 EST


On Fri, Jul 10, 2026 at 06:38:23PM +0200, David Hildenbrand (Arm) wrote:
> >>
> >> How long ago did I break this though? Why has it taken until now for this to be
> >> reported? :) commit 8ac268436e6d ("mm/gup: disallow FOLL_LONGTERM GUP-nonfast
> >> writing to file-backed mappings") is from May 2023 :)
> >
> > The break didn't come from your changes, it came from commit 7e066cb9b71a ("KVM:
> > SEV: Use long-term pin when registering encrypted memory regions"). I suggested
> > falling back to a non-longterm pin, but David didn't like that idea :-)
>
> Yes, a longterm pin is a longterm pin.

Yes it'd be very unwise to not use a longterm pin here!

>
> If we don't write to the memory, why do we need a write pin? To make sure that
> what we pin was actually unshared?
>
> Well, FOLL_LONGTERM does that nowadays.
>
>
> ... so is maybe dropping the FOLL_WRITE sufficient?

That solves the whole thing, as the check is gated on FOLL_WRITE anyway.

I hadn't dug into the code enough there, been scanning.

So that's a simple fix then? :)

>
> --
> Cheers,
>
> David

Cheers, Lorenzo