xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: 'Jan Beulich' <JBeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	"Tim (Xen.org)" <tim@xen.org>,
	George Dunlap <George.Dunlap@citrix.com>,
	JulienGrall <julien.grall@arm.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Ian Jackson <Ian.Jackson@citrix.com>
Subject: Re: [PATCH v16 06/11] x86/hvm/ioreq: add a new mappable resource type...
Date: Wed, 20 Dec 2017 17:02:50 +0000	[thread overview]
Message-ID: <bd89b57f67474a9ebf33dab67fd22f08@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <5A3A9F440200007800198E6F@prv-mh.provo.novell.com>

> -----Original Message-----
> From: Xen-devel [mailto:xen-devel-bounces@lists.xenproject.org] On Behalf
> Of Jan Beulich
> Sent: 20 December 2017 16:35
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>; Wei Liu
> <wei.liu2@citrix.com>; George Dunlap <George.Dunlap@citrix.com>;
> Andrew Cooper <Andrew.Cooper3@citrix.com>; Ian Jackson
> <Ian.Jackson@citrix.com>; Tim (Xen.org) <tim@xen.org>; JulienGrall
> <julien.grall@arm.com>; xen-devel@lists.xenproject.org
> Subject: Re: [Xen-devel] [PATCH v16 06/11] x86/hvm/ioreq: add a new
> mappable resource type...
> 
> >>> On 15.12.17 at 11:41, <paul.durrant@citrix.com> wrote:
> > +static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
> > +{
> > +    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
> > +
> > +    if ( iorp->page )
> > +    {
> > +        /*
> > +         * If a guest frame has already been mapped (which may happen
> > +         * on demand if hvm_get_ioreq_server_info() is called), then
> > +         * allocating a page is not permitted.
> > +         */
> > +        if ( !gfn_eq(iorp->gfn, INVALID_GFN) )
> > +            return -EPERM;
> > +
> > +        return 0;
> > +    }
> > +
> > +    iorp->va = alloc_xenheap_page();
> > +    if ( !iorp->va )
> > +        return -ENOMEM;
> > +
> > +    clear_page(iorp->va);
> > +
> > +    iorp->page = virt_to_page(iorp->va);
> > +    share_xen_page_with_guest(iorp->page, s->domain,
> XENSHARE_writable);
> > +    return 0;
> > +}
> 
> Why the much more limited (on huge systems) Xen heap all of the
> sudden?

Largely I'm trying to follow the same procedure used for the grant tables. Also, Xen is always going to need a mapping for these pages so using xenheap is convenient. If you think that's too limited then I can go back to domheap (but for the target domain rather than the tools domain) and map the page into Xen explicitly.

> 
> > +static void hvm_free_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
> > +{
> > +    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
> > +
> > +    if ( !iorp->page )
> > +        return;
> > +
> > +    iorp->page = NULL;
> > +
> > +    free_xenheap_page(iorp->va);
> > +    iorp->va = NULL;
> > +}
> 
> I've looked over the code paths coming here, and I can't convince
> myself that any mapping that the server has established would be
> gone by the time the page is being freed. I'm likely (hopefully)
> overlooking some aspect here.
> 

Hmm. Maybe you're right. The lack of ref counting might be a problem. It was so much simpler to allocate from the tools domain's heap, but the restrictions in do_mmu_update() rule that out. I'm really not sure how to fix this.

> > +int arch_acquire_resource(struct domain *d, unsigned int type,
> > +                          unsigned int id, unsigned long frame,
> > +                          unsigned int nr_frames, xen_pfn_t mfn_list[])
> > +{
> > +    int rc;
> > +
> > +    switch ( type )
> > +    {
> > +    case XENMEM_resource_ioreq_server:
> > +    {
> > +        ioservid_t ioservid = id;
> > +        unsigned int i;
> > +
> > +        rc = -EINVAL;
> > +        if ( id != (unsigned int)ioservid )
> > +            break;
> > +
> > +        rc = 0;
> > +        for ( i = 0; i < nr_frames; i++ )
> > +        {
> > +            mfn_t mfn;
> > +
> > +            rc = hvm_get_ioreq_server_frame(d, id, frame + i, &mfn);
> 
> Neither up from here nor in the called function it is being checked
> that d is actually a HVM domain.

Yes, that's an oversight.

  Paul

> 
> Jan
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2017-12-20 17:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-15 10:41 [PATCH v16 00/11] x86: guest resource mapping Paul Durrant
2017-12-15 10:41 ` [PATCH v16 01/11] x86/hvm/ioreq: maintain an array of ioreq servers rather than a list Paul Durrant
2017-12-15 10:41 ` [PATCH v16 02/11] x86/hvm/ioreq: simplify code and use consistent naming Paul Durrant
2017-12-15 10:41 ` [PATCH v16 03/11] x86/hvm/ioreq: use gfn_t in struct hvm_ioreq_page Paul Durrant
2017-12-15 10:41 ` [PATCH v16 04/11] x86/hvm/ioreq: defer mapping gfns until they are actually requsted Paul Durrant
2017-12-15 10:41 ` [PATCH v16 05/11] x86/mm: add HYPERVISOR_memory_op to acquire guest resources Paul Durrant
2017-12-15 10:41 ` [PATCH v16 06/11] x86/hvm/ioreq: add a new mappable resource type Paul Durrant
2017-12-20 16:35   ` Jan Beulich
2017-12-20 17:02     ` Paul Durrant [this message]
2017-12-21  9:47       ` Jan Beulich
2017-12-21 10:01         ` Paul Durrant
2017-12-21 11:31           ` Jan Beulich
2017-12-21 11:49             ` Paul Durrant
2017-12-15 10:41 ` [PATCH v16 07/11] x86/mm: add an extra command to HYPERVISOR_mmu_update Paul Durrant
2017-12-15 10:41 ` [PATCH v16 08/11] tools/libxenforeignmemory: add support for resource mapping Paul Durrant
2017-12-15 10:41 ` [PATCH v16 09/11] tools/libxenforeignmemory: reduce xenforeignmemory_restrict code footprint Paul Durrant
2017-12-15 10:41 ` [PATCH v16 10/11] common: add a new mappable resource type: XENMEM_resource_grant_table Paul Durrant
2017-12-15 10:41 ` [PATCH v16 11/11] tools/libxenctrl: use new xenforeignmemory API to seed grant table Paul Durrant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bd89b57f67474a9ebf33dab67fd22f08@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).