lkml.org 
[lkml]   [2021]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 01/16] KVM: arm64: Introduce do_share() helper for memory sharing between components
Hi Andrew,

On Friday 15 Oct 2021 at 16:11:49 (+0100), Andrew Walbran wrote:
> On Wed, 13 Oct 2021 at 16:58, 'Quentin Perret' via kernel-team
> > +struct pkvm_mem_transition {
> > + u64 nr_pages;
> > +
> > + struct {
> > + enum pkvm_component_id id;
> > + u64 addr;
> Is this the physical address or the IPA of the initiator? It would be
> good to have a comment explaining.

That's the address in the initiator's address space. For the host and
guests that'll be an IPA (which also happens to be the same as the PA
for the host) and for the hypervisor that'll be an EL2 VA.

But yes, a comment won't hurt, so I'll add something.

<snip>
> > +static int check_share(struct pkvm_page_req *req,
> > + struct pkvm_page_share_ack *ack,
> > + struct pkvm_mem_share *share)
> > +{
> > + if (!addr_is_memory(req->phys))
> > + return -EINVAL;
> > +
> > + if (req->initiator.state == PKVM_PAGE_OWNED &&
> > + ack->completer.state == PKVM_NOPAGE) {
> > + return 0;
> > + }
> > +
> > + if (req->initiator.state != PKVM_PAGE_SHARED_OWNED)
> > + return -EPERM;
> > +
> > + if (ack->completer.state != PKVM_PAGE_SHARED_BORROWED)
> > + return -EPERM;
> > +
> > + if (ack->completer.phys != req->phys)
> > + return -EPERM;
> > +
> > + if (ack->completer.prot != share->prot)
> > + return -EPERM;
> I guess this is the workaround you mentioned for the fact that the
> host can share the same page twice? It might be worth adding a comment
> to explain that that's what's going on.

Yep, that's what is going on here. But FWIW I'm currently reworking the
way we refcount pages in v2, which will now become the host's
responsibility. So, that should simplify things quite a bit at EL2, and
make all of the above go away :-)

Cheers,
Quentin

\
 
 \ /
  Last update: 2021-10-19 12:38    [W:0.130 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site