[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] Mapping Dom0 page in hypervisor from domctl


  • To: Xen-devel@xxxxxxxxxxxxx
  • From: Bread Cutter <cutter409@xxxxxxxxx>
  • Date: Thu, 2 Jul 2015 08:14:14 -0400
  • Delivery-date: Thu, 02 Jul 2015 12:14:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

Hi all,

I'm trying to map a page provided by Dom0 into Xen's address space,
but I keep freezing the physical computer when I try. Maybe I'm
hitting a spinlock or something, but clearly I'm doing something
incorrectly. I'll probably be able to get farther once I have another
computer with a serial port to get logging, but hopefully it's
something obvious.

Dom0 sends a domctl containing a virtual address. I attempt to
translate it to a GFN, and then get the page_info structure, and
finally map it.

Source code:

        /* Unmap any existing mapping */
        if ( d->arch.hvm_domain.dom0_mapping.page_info )
        {
            unmap_domain_page(d->arch.hvm_domain.dom0_mapping.buffer);
            put_page(d->arch.hvm_domain.dom0_mapping.page_info);

            d->arch.hvm_domain.dom0_mapping.buffer = NULL;
            d->arch.hvm_domain.dom0_mapping.page_info = NULL;
        }

        if ( domctl->va )
        {
            struct page_info* page_info;
            uint64_t gfn;
            uint32_t pfec = 0;

            gdprintk (XENLOG_DEBUG, "Using guest VA 0x%lX\n", domctl->va);

            /* Validate that the given VA is page-aligned */
            if ((domctl->va & ~PAGE_MASK) != 0)
            {
                gdprintk (XENLOG_DEBUG, "VA is not page aligned\n");
                ret = -EINVAL;
                break;
            }

            /* Translate the given virtual address to the guest frame number */
            gfn = paging_gva_to_gfn(current, domctl->va, &pfec);
            if ( gfn == INVALID_GFN )
            {
                gdprintk (XENLOG_DEBUG, "Invalid GFN\n");
                ret = -EFAULT;
                break;
            }
            gdprintk (XENLOG_DEBUG, "Translated to gfn 0x%lX\n", gfn);

            /* Get the page info */
            page_info = get_page_from_gfn(current->domain, gfn, NULL,
P2M_UNSHARE);
            if ( !page_info )
            {
                gdprintk (XENLOG_DEBUG, "No page info\n");
                ret = -ESRCH;
                break;
            }
            gdprintk (XENLOG_DEBUG, "Translated to mfn 0x%lX\n",
page_to_mfn(page_info));

            d->arch.hvm_domain.dom0_mapping.page_info = page_info;
            d->arch.hvm_domain.dom0_mapping.buffer =
(uint8_t*)map_domain_page_global(page_to_mfn(page_info));
            if ( !d->arch.hvm_domain.dom0_mapping.buffer )
            {
                gdprintk (XENLOG_DEBUG, "Map failed\n");
                put_page(page_info);
                ret = -ENOMEM;
                break;
            }

            gdprintk (XENLOG_DEBUG, "All Mapped: %p\n",
d->arch.hvm_domain.dom0_mapping.buffer);
        }

Any insight into what I'm doing wrong would be appreciated!

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.