Re: [PATCH v7 00/14] KVM: mm: fd-based approach for supporting KVM guest private memory
From: Sean Christopherson
Date: Fri Aug 19 2022 - 18:53:16 EST
On Thu, Aug 18, 2022, Hugh Dickins wrote:
> On Fri, 19 Aug 2022, Sean Christopherson wrote:
> > On Thu, Aug 18, 2022, Kirill A . Shutemov wrote:
> > > On Wed, Aug 17, 2022 at 10:40:12PM -0700, Hugh Dickins wrote:
> > > > If your memory could be migrated, that would be some reason to use
> > > > filesystem page cache (because page migration happens to understand
> > > > that type of memory): but it cannot be migrated.
> > >
> > > Migration support is in pipeline. It is part of TDX 1.5 [1].
> >
> > And this isn't intended for just TDX (or SNP, or pKVM). We're not _that_ far off
> > from being able to use UPM for "regular" VMs as a way to provide defense-in-depth
>
> UPM? That's an acronym from your side of the fence, I spy references to
> it in the mail threads, but haven't tracked down a definition. I'll
> just take it to mean the fd-based memory we're discussing.
Ya, sorry, UPM is what we came up with as shorthand for "Unmapping guest Private
Memory". Your assumption is spot on, it's just a fancy way of saying "guest is
backed with inaccessible fd-based memory".
> > without having to take on the overhead of confidential VMs. At that point,
> > migration and probably even swap are on the table.
>
> Good, the more "flexible" that memory is, the better for competing users
> of memory. But an fd supplied by KVM gives you freedom to change to a
> better implementation of allocation underneath, whenever it suits you.
> Maybe shmem beneath is good from the start, maybe not.
The main flaw with KVM providing the fd is that it forces KVM to get into the
memory management business, which us KVM folks really, really do not want to do.
And based on the types of bugs KVM has had in the past related to memory management,
it's a safe bet to say the mm folks don't want us getting involved either :-)
The combination of gup()/follow_pte() and mmu_notifiers has worked very well.
KVM gets a set of (relatively) simple rules to follow and doesn't have to be taught
new things every time a new backing type comes along. And from the other side, KVM
has very rarely had to go poke into other subsystems' code to support exposing a
new type of memory to guests.
What we're trying to do with UPM/fd-based memory is establish a similar contract
between mm and KVM, but without requiring mm to also map memory into host userspace.
The only way having KVM provide the fd works out in the long run is if KVM is the
only subsystem that ever wants to make use of memory that isn't accessible from
userspace and isn't tied to a specific backing type, _and_ if the set of backing
types that KVM ever supports is kept to an absolute minimum.