From patchwork Wed May 10 14:31:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 99000 Delivered-To: patch@linaro.org Received: by 10.182.142.97 with SMTP id rv1csp232492obb; Wed, 10 May 2017 07:35:41 -0700 (PDT) X-Received: by 10.107.185.10 with SMTP id j10mr4153170iof.3.1494426941032; Wed, 10 May 2017 07:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494426941; cv=none; d=google.com; s=arc-20160816; b=l5kfQV/s5Cx/XpufC6Te5jh7EHbyFwqjqZxBvQBe/lK/j12mEBU82za2UX6NiwfOeT 8/MzJcHnV4u53ASQJ2T4JELJYvHmATaToVv12uQNv/RCz1wOK5eMiXdZiyvu+eOXfCnW Oo7tUmc3G85+E79G1PeQMMla0gOatmp1n8hkD73xSK8c6BzEryq0m9TLTosqvA+PHgDf /qlgW4T7Q97KvL7tPQIZWqQ85I99dfH4PIubF5YD9uOTJIre5qSz3JBS86hOjoEvo/fN 8mafsfc2XwQ5D21l7SxCTJGrwBqtexKbHi3f78mg5k7yFQyOrS998PS9qzFEu3jZVsTt nldQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:message-id:date:to:from:dkim-signature :arc-authentication-results; bh=hvTGaqSzUTU6vchBHgRYQq9cQJPKDdPwQ3+VCozDiOk=; b=DXVNQLmFvWqbNGeTHaetJh0Dl7A1E/4fPXxN40DcC7x5TrCrfwOrnJNbRoLzeXJalv TLEO25jGukcmIPZdrBUyWmLEGwawMflo/ZcF2E5FwRns1cui36GkFsokbm+NrLmw77mR Lr/5ksB9TQsdHv0IIysSQzf5nl/GPCLK4anT6Aj1xgjfRAoEssIkzjFaefl5uAXdOeG5 sRqV0jAAA7ArIyFP0JI/0ts4ad1CtCsopoCn5so3zcuV3FmbGrJrkAXnklBtiLUMS+ca x2/Y1E+5Cqt9K/70EoI3yhb7qPZXtjVAL+pF4ae6mEkHOf5R3FiTg8xTTgpwGvUFU1Dg 4avw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id j5si3769782iti.12.2017.05.10.07.35.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 07:35:41 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8SgM-0004Lc-4y; Wed, 10 May 2017 14:33:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8SgL-0004LS-2n for xen-devel@lists.xenproject.org; Wed, 10 May 2017 14:33:37 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 8E/E8-02192-0C423195; Wed, 10 May 2017 14:33:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgkeJIrShJLcpLzFFi42Lxqg021d2vIhx p8Hq6lsX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvFkWR9TwQ/7iq3vrjM2ME7W72Lk4hASmM4o MafzICuIwyLQziyx6MlrMEdC4B2LxO0bX9m7GDmBnDiJ3Qc3MkPYFRLvn91gBbGFBLQkjp6az QoxqplJ4urVR0ANHBxsAiYSszokQGpEBJQk7q2azARSwywwn1Fib89ZsGZhgUSJdf2PWEBsFg FViVuve9lAenkFvCWeX1KD2CUncfNcJ/MERr4FjAyrGDWKU4vKUot0jSz0kooy0zNKchMzc3Q NDYz1clOLixPTU3MSk4r1kvNzNzECQ6WegYFxB2P7Cb9DjJIcTEqivLq7hCKF+JLyUyozEosz 4otKc1KLDzHKcHAoSfBeVBaOFBIsSk1PrUjLzAEGLUxagoNHSYQ3HCTNW1yQmFucmQ6ROsWoy /Fo5Y/3TEIsefl5qVLivNNBigRAijJK8+BGwCLoEqOslDAvIwMDgxBPQWpRbmYJqvwrRnEORi Vh3hSQKTyZeSVwm14BHcEEdEQggwDIESWJCCmpBsY1kvM3fT2ob6T0imfBR/6c4n6GUOaK3T/ N3aUj/XpYHzg0/FHwWXJ6W+Q+rQmSKnnx3sLX2wse+LSp/93wrqUiK/OJmw+HH09RZtvny7wv 9ny2jEhNSqvboTH3ONu3e/81oh7Zp++a2/Gw1LLgVtHSWVxT6nPf+//1FVVabLx248HqH/fD5 yqxFGckGmoxFxUnAgBA1LSbmwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-16.tower-31.messagelabs.com!1494426814!92099446!1 X-Originating-IP: [74.125.83.53] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12905 invoked from network); 10 May 2017 14:33:35 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-16.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 May 2017 14:33:35 -0000 Received: by mail-pg0-f53.google.com with SMTP id 64so17644947pgb.3 for ; Wed, 10 May 2017 07:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=uoO4LTDCtKzaTBzN1ADQ/rpbda73uXAKbSzaL0Ant7I=; b=B5j8dCxwgv0ThTUvJYwL/KLG+j07dYrQWuEHF8suv1yUzUphXQiCitzQjZk8LpQuge 46wU/uulfK/az3Da7IYylCDmHOd3HwmkzUFa5galQAm6NyfLtB4bkf59rJ8MzadWV7in Hj7kZNgtZ+WBzqAmIwXjmyeP95bnonn5gAcno= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uoO4LTDCtKzaTBzN1ADQ/rpbda73uXAKbSzaL0Ant7I=; b=pQCzntIRPmX6zclnGN5Q5eUM95u7sl8ggUhUZFGv0KmiMjMIG1x+/54s88qX1gj60i CIxGbyrU4z52dJy95y05rJNUHVLgm8qLA6oSncnKNxI8qG3XQ16sKqx+x5YgUhg23qG/ GaU5+mfwuUqI3ZLQAAzOrCit8iQn+tOSq/OYlMPzvLys+P74ZBDF7sNsrcMYDyg07wX8 p+7NGbPaKWwsqm8Spls6KO0ps7VoHr4kyAmkHKKFFK5IBhVxE7LpUcst6bXVl+TvkYz4 nbV4EGKbtj1ch5WggymBa2PAPLXwumdz2l6JjYJFLOvDTVY7zxrfmPlkC7TCfFFhFAxM JE0Q== X-Gm-Message-State: AODbwcA49MmFkYJX+sBtRqOdLrHADw4SW2K8BARRoODgLAcUe1dDaKJZ zBR++TJOkwWpOfYU X-Received: by 10.84.205.69 with SMTP id o5mr8712752plh.106.1494426813674; Wed, 10 May 2017 07:33:33 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([61.0.91.57]) by smtp.gmail.com with ESMTPSA id u74sm6478661pfk.58.2017.05.10.07.33.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 May 2017 07:33:33 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Wed, 10 May 2017 20:01:18 +0530 Message-Id: <1494426678-32639-1-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 05/12 v3] xen/arm: vpl011: Add new domctl APIs to initialize/de-initialize vpl011 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add two new domctl APIs to initialize and de-initialize vpl011. It takes the GFN and console backend domid as input and returns an event channel to be used for sending and receiving events from Xen. Xen will communicate with xenconsole using GFN as the ring buffer and the event channel to transmit and receive pl011 data on guest domain's behalf. Signed-off-by: Bhupinder Thakur --- Changes since v2: - Replaced the DOMCTL APIs defined for get/set of event channel and GFN with a set of DOMCTL APIs for initializing and de-initializing vpl011 emulation. tools/libxc/include/xenctrl.h | 26 ++++++++++++++++++++++++++ tools/libxc/xc_domain.c | 38 ++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_dom.c | 10 ++++++++++ tools/libxl/libxl_domain.c | 2 ++ xen/arch/arm/domctl.c | 27 +++++++++++++++++++++++++++ xen/include/public/domctl.h | 13 +++++++++++++ 6 files changed, 116 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 1629f41..13ef215 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -884,6 +884,32 @@ int xc_vcpu_getcontext(xc_interface *xch, uint32_t domid, uint32_t vcpu, vcpu_guest_context_any_t *ctxt); +/** + * This function intializes the vpl011 emulation and returns + * the event to be used by the backend for communicating with + * the emulation code. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the domain to get information from + * @parm console_domid the domid of the backend console + * @parm gfn the guest pfn to be used as the ring buffer + * @parm evtchn the event channel to be used for events + * @return 0 on success, negative error on failure + */ +int xc_dom_vpl011_init(xc_interface *xch, + uint32_t domid, + uint32_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn); + +/** + * This function de-intializes the vpl011 emulation. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the domain to get information from + */ +int xc_dom_vpl011_deinit(xc_interface *xch, + uint32_t domid); /** * This function returns information about the XSAVE state of a particular diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 00909ad4..ec48b9b 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -343,6 +343,44 @@ int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid, return 0; } +int xc_dom_vpl011_init(xc_interface *xch, + uint32_t domid, + uint32_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn) +{ + DECLARE_DOMCTL; + int rc = 0; + + domctl.cmd = XEN_DOMCTL_vuart_op; + domctl.domain = (domid_t)domid; + domctl.u.vuart_op.cmd = XEN_DOMCTL_VUART_OP_INIT_VPL011; + domctl.u.vuart_op.console_domid = console_domid; + domctl.u.vuart_op.gfn = gfn; + + if ( (rc = do_domctl(xch, &domctl)) < 0 ) + return rc; + + *evtchn = domctl.u.vuart_op.evtchn; + + return rc; +} + +int xc_dom_vpl011_deinit(xc_interface *xch, + uint32_t domid) +{ + DECLARE_DOMCTL; + int rc = 0; + + domctl.cmd = XEN_DOMCTL_vuart_op; + domctl.domain = (domid_t)domid; + domctl.u.vuart_op.cmd = XEN_DOMCTL_VUART_OP_DEINIT_VPL011; + + rc = do_domctl(xch, &domctl); + + return rc; +} + int xc_domain_getinfo(xc_interface *xch, uint32_t first_domid, unsigned int max_doms, diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 5d914a5..e7489d9 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -688,6 +688,15 @@ static int libxl__build_dom(libxl__gc *gc, uint32_t domid, goto out; } + if ( info->vuart && + (ret = xc_dom_vpl011_init(CTX->xch, + domid, + state->console_domid, + dom->vuart_gfn, + &state->vuart_port)) != 0 ) { + LOGE(ERROR, "xc_dom_vpl011_init failed"); + goto out; + } out: return ret != 0 ? ERROR_FAIL : 0; } @@ -788,6 +797,7 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid, if (xc_dom_translated(dom)) { state->console_mfn = dom->console_pfn; state->store_mfn = dom->xenstore_pfn; + state->vuart_gfn = dom->vuart_gfn; } else { state->console_mfn = xc_dom_p2m(dom, dom->console_pfn); state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 08eccd0..1d2c65a 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1028,6 +1028,8 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis) goto out; } + xc_dom_vpl011_deinit(ctx->xch, domid); + if (libxl__device_pci_destroy_all(gc, domid) < 0) LOGD(ERROR, domid, "Pci shutdown failed"); rc = xc_domain_pause(ctx->xch, domid); diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index 971caec..11707db 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -119,6 +120,32 @@ long arch_do_domctl(struct xen_domctl *domctl, struct domain *d, d->disable_migrate = domctl->u.disable_migrate.disable; return 0; + case XEN_DOMCTL_vuart_op: + { + int rc; + struct xen_domctl_vuart_op *vuart_op = &domctl->u.vuart_op; + + switch(vuart_op->cmd) + { + case XEN_DOMCTL_VUART_OP_INIT_VPL011: + rc = domain_vpl011_init(d, vuart_op->console_domid, + vuart_op->gfn, &vuart_op->evtchn); + if ( !rc ) + rc = __copy_to_guest(u_domctl, domctl, 1); + break; + + case XEN_DOMCTL_VUART_OP_DEINIT_VPL011: + domain_vpl011_deinit(d); + rc = 0; + break; + + default: + rc = -EINVAL; + break; + } + + return rc; + } default: { int rc; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index e6cf211..bfa56cb 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -36,6 +36,7 @@ #include "grant_table.h" #include "hvm/save.h" #include "memory.h" +#include "event_channel.h" #define XEN_DOMCTL_INTERFACE_VERSION 0x0000000d @@ -1138,6 +1139,16 @@ struct xen_domctl_psr_cat_op { uint32_t target; /* IN */ uint64_t data; /* IN/OUT */ }; + +struct xen_domctl_vuart_op { +#define XEN_DOMCTL_VUART_OP_INIT_VPL011 0 +#define XEN_DOMCTL_VUART_OP_DEINIT_VPL011 1 + uint32_t cmd; /* XEN_DOMCTL_VUART_OP_* */ + uint32_t console_domid; /* IN */ + xen_pfn_t gfn; /* IN */ + evtchn_port_t evtchn; /* OUT */ +}; + typedef struct xen_domctl_psr_cat_op xen_domctl_psr_cat_op_t; DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cat_op_t); @@ -1218,6 +1229,7 @@ struct xen_domctl { #define XEN_DOMCTL_monitor_op 77 #define XEN_DOMCTL_psr_cat_op 78 #define XEN_DOMCTL_soft_reset 79 +#define XEN_DOMCTL_vuart_op 80 #define XEN_DOMCTL_gdbsx_guestmemio 1000 #define XEN_DOMCTL_gdbsx_pausevcpu 1001 #define XEN_DOMCTL_gdbsx_unpausevcpu 1002 @@ -1280,6 +1292,7 @@ struct xen_domctl { struct xen_domctl_psr_cmt_op psr_cmt_op; struct xen_domctl_monitor_op monitor_op; struct xen_domctl_psr_cat_op psr_cat_op; + struct xen_domctl_vuart_op vuart_op; uint8_t pad[128]; } u; };