diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 1a3ac1646e..2a5e93c284 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -209,6 +209,18 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl__domain_build_state *state, uint32_t domid) { + libxl_ctx *ctx = libxl__gc_owner(gc); + unsigned int shadow_mb = DIV_ROUNDUP(d_config->b_info.shadow_memkb, 1024); + + int r = xc_shadow_control(ctx->xch, domid, + XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, + &shadow_mb, 0); + if (r) { + LOGED(ERROR, domid, + "Failed to set %u MiB shadow allocation", shadow_mb); + return ERROR_FAIL; + } + return 0; } diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index 1baf25c3d9..9bf72e6930 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -47,11 +47,43 @@ static int handle_vuart_init(struct domain *d, return rc; } +static long p2m_domctl(struct domain *d, struct xen_domctl_shadow_op *sc, + XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) +{ + if ( unlikely(d == current->domain) ) + { + printk(XENLOG_ERR "Tried to do a p2m domctl op on itself.\n"); + return -EINVAL; + } + + if ( unlikely(d->is_dying) ) + { + printk(XENLOG_ERR "Tried to do a p2m domctl op on dying domain %u\n", + d->domain_id); + return -EINVAL; + } + + switch ( sc->op ) + { + case XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION: + return 0; + case XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION: + return 0; + default: + { + printk(XENLOG_ERR "Bad p2m domctl op %u\n", sc->op); + return -EINVAL; + } + } +} + long arch_do_domctl(struct xen_domctl *domctl, struct domain *d, XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) { switch ( domctl->cmd ) { + case XEN_DOMCTL_shadow_op: + return p2m_domctl(d, &domctl->u.shadow_op, u_domctl); case XEN_DOMCTL_cacheflush: { gfn_t s = _gfn(domctl->u.cacheflush.start_pfn);