Re: [RFC PATCH 0/5] Prototype for direct map awareness in page allocator

From: Mike Rapoport
Date: Thu May 25 2023 - 16:38:09 EST


On Fri, May 19, 2023 at 11:25:53AM -0700, Sean Christopherson wrote:
> On Fri, May 19, 2023, Mike Rapoport wrote:
> > On Fri, May 19, 2023 at 08:40:48AM -0700, Sean Christopherson wrote:
> > > On Thu, Mar 09, 2023, Mike Rapoport wrote:
> > > > On Thu, Mar 09, 2023 at 01:59:00AM +0000, Edgecombe, Rick P wrote:
> > >
> > > Would it be possible to drop that assumption/requirement, i.e. allow allocation of
> > > __GFP_UNMAPPED without __GFP_ZERO? At a glance, __GFP_UNMAPPED looks like it would
> > > be a great fit for backing guest memory, in particular for confidential VMs. And
> > > for some flavors of CoCo, i.e. TDX, the trusted intermediary is responsible for
> > > zeroing/initializing guest memory as the untrusted host (kernel/KVM) doesn't have
> > > access to the guest's encryption key. In other words, zeroing in the kernel would
> > > be unnecessary work.
> >
> > Making and unmapped allocation without __GFP_ZERO shouldn't be a problem.
> >
> > However, using a gfp flag and hooking up into the free path in page
> > allocator have issues and preferably should be avoided.
> >
> > Will something like unmapped_alloc() and unmapped_free() work for your
> > usecase?
>
> Yep, I'm leaning more and more towards having KVM implement its own ioctl() for
> managing this type of memory. Wiring that up to use dedicated APIs should be no
> problem.

Ok, I've dropped the GFP flag and made unmapped_pages_{alloc,free} the only
APIs.

Totally untested version of what I've got is here:
https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=unmapped-alloc/rfc-v2

I have some thoughts about adding support for 1G pages, but this is still
really vague at the moment.

> Thanks!

--
Sincerely yours,
Mike.