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

Re: [Xen-devel] [PATCH 07/21] lib{xc, xl}: Seed grant tables with xenstore and console grants



> @@ -275,6 +276,169 @@ int xc_dom_boot_image(struct xc_dom_image *dom)
>      return rc;
>  }
> 
> +static unsigned long xc_dom_gnttab_setup(xc_interface *xch, uint32_t domid)
> +{
> +    DECLARE_HYPERCALL;
> +    gnttab_setup_table_t setup_table;

This memory needs to be a hypercall buffer. The easiest way to achieve
this would be to use xc_gnttab_op() which will bounce it for you.

> +    DECLARE_HYPERCALL_BUFFER(unsigned long, gmfnp);
> +    int rc;
> +    unsigned long gmfn;
> +
> +    gmfnp = xc_hypercall_buffer_alloc(xch, gmfnp, sizeof(*gmfnp));
> +    if (gmfnp == NULL)
> +        return -1;
> +
> +    setup_table.dom = domid;
> +    setup_table.nr_frames = 1;
> +    set_xen_guest_handle(setup_table.frame_list, gmfnp);
> +    setup_table.status = 0;
> +
> +    hypercall.op = __HYPERVISOR_grant_table_op;
> +    hypercall.arg[0] = GNTTABOP_setup_table;
> +    hypercall.arg[1] = (unsigned long) &setup_table;
> +    hypercall.arg[2] = 1;
> +
> +    rc = do_xen_hypercall(xch, &hypercall);
> +    gmfn = *gmfnp;
> +    xc_hypercall_buffer_free(xch, gmfnp);
> +
> +    if ( rc != 0 || setup_table.status != GNTST_okay )
> +    {
> +        xc_dom_panic(xch, XC_INTERNAL_ERROR,
> +                     "%s: failed to setup domU grant table "
> +                     "[errno=%d, status=%" PRId16 "]\n",
> +                     __FUNCTION__, rc != 0 ? errno : 0, setup_table.status);
> +        return -1;
> +    }
> +
> +    return gmfn;
> +}
[...]
> +int xc_dom_gnttab_hvm_seed(xc_interface *xch, uint32_t domid,
> +                           unsigned long console_gpfn,
> +                           unsigned long xenstore_gpfn,
> +                           uint32_t console_domid,
> +                           uint32_t xenstore_domid)
> +{
> +#define SCRATCH_PFN_GNTTAB 0xFFFFE

Do we need to reserve this address? Even if not should we do so anyway?
Certainly I think hiding it away in this file is a bit too secret...

hvmloader reserves from hvm_info->reserved_mem_pgstart to the 4GB limit
in the guest's e820. reserved_mem_pgstart starts at special_pfn(0) and
is reduced by mem_alloc in hvmloader.

#define NR_SPECIAL_PAGES     5
#define special_pfn(x) (0xff000u - NR_SPECIAL_PAGES + (x))

So we end up reserving from 0xFEFFB000 to the end. So we are at least
hiding this address from the guest, so that's ok, but I think we need to
document this somewhere -- I'm just not sure where we can put it -- Keir
any ideas?

There's a list of SPECIALPAGE_* in xc_hvm_build but that's not exactly
the height of discoverable either.

> +
> +    int rc;
> +    struct xen_add_to_physmap xatp = {
> +        .domid = domid,
> +        .space = XENMAPSPACE_grant_table,
> +        .idx   = 0, /* TODO: what's this? */

"Index into source mapping space". Since you want the first page of the
grant table 0 seems to be correct.

Ian.



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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