From patchwork Fri Apr 28 16:01:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 9705015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F398A60225 for ; Fri, 28 Apr 2017 16:03:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1CDF28688 for ; Fri, 28 Apr 2017 16:03:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3E3E2868F; Fri, 28 Apr 2017 16:03:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3F49428688 for ; Fri, 28 Apr 2017 16:03:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48L2-00005T-LY; Fri, 28 Apr 2017 16:01:44 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48L1-0008W5-3p for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:01:43 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 14/AB-03587-66763095; Fri, 28 Apr 2017 16:01:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsVyMfTAGt3UdOZ Ig+uX9Cy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxlP7rYCi4aV/zaJ9HAOEmti5GLQ0hgBqPE 0p7vTCAOi8A8Zokd3fPZuhg5OSQE+lklmlblQNhxEqf+bWOEsKslPr9ZAlYjJKAlcfTUbFaIS c1MEl9/rgdKcHCwCZhIzOqQAKkREVCSuLdqMtgCZoG3jBL9H0+xgiSEBRIlFm5azwJiswioSu x7vRhsAa+At8T/y3+YIJbJSdw818kMYnMK+Ehc61/GDrHYW6K7YR7LBEaBBYwMqxjVi1OLylK LdI31kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECw4oBCHYwdvxzOsQoycGkJMpb 6c4cKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCd2oaUE6wKDU9tSItMwcY4DBpCQ4eJRFeCZA0b 3FBYm5xZjpE6hSjMceLy+/fM3E8WfnjPZMQS15+XqqUOG8ESKkASGlGaR7cIFjkXWKUlRLmZQ Q6TYinILUoN7MEVf4VozgHo5Iwbw7IFJ7MvBK4fa+ATmECOoXFhQHklJJEhJRUA6OGp/vlV/L td5intdkITZfje/t/5oJps6UDdYOmSb5cxJSQ8Ogyj6BCVfTjzvocjm1ODu4JvokCc604BDg1 o1aWmrK4632tnH/uyGOffZUa6TdLzDc9yD2zkYX/+q3S/Tw7whrXCivsvMvf+TH84LknO7veW JmlbJO4eEg+MvPzxf0dM4qEdyuxFGckGmoxFxUnAgAHNqNetwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-27.messagelabs.com!1493395300!76313593!1 X-Originating-IP: [209.85.192.172] 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 50061 invoked from network); 28 Apr 2017 16:01:41 -0000 Received: from mail-pf0-f172.google.com (HELO mail-pf0-f172.google.com) (209.85.192.172) by server-10.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:01:41 -0000 Received: by mail-pf0-f172.google.com with SMTP id i4so13947186pfc.0 for ; Fri, 28 Apr 2017 09:01:41 -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:in-reply-to:references; bh=hdX+ngkWmG6KM/S14DnCDQSrXUxjir/JgEr69Bebol8=; b=RxFD7T/eo5dK4YypufWp7nRFesEnJbO5DoXJdvSDvGBBNTcMvfPq6R2k0bUPVAtbM5 b7/LoYdxk3bfrUbH25LO+QBkgVicwh73zkIQSMhgkTTNHgOVawyVtAvZvIFa4cnrVxQ3 L1xhwSRYi+sZHXPKk1psQN0fx2iJqxSdKBb34= 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:in-reply-to :references; bh=hdX+ngkWmG6KM/S14DnCDQSrXUxjir/JgEr69Bebol8=; b=JobZAhqwet9r4SORS8h4qFZf9K78PRhpjSLUBf2u+EJw5OBHwh85HsJW4Tn5rvpj0g KNnXrrMlvC+oni0Z02KDmSYVftEbks9gDw/czcTBcJDdNwnTFzCS8a4UuakSLblHayq8 AVTS9tdn6AQUqKEbyITJ56Na+6UEwZxNSgrjnpdOBevltqy8xdI2LEXh9uvT/phECFwm lGjlVSfLJ4q+mp7IN4OxL5BloMcrf+RPIvRWFwfbE4wzjHxbU853LHG8Rf8VNsJWMPdm okNpmUXfSxTzij1mNlVlStjE81dtAcILZt6x6PfH58jnl/vxAo7h6iR3nE46UCeQ4mLf i6Xw== X-Gm-Message-State: AN3rC/4+I56pUR/hxYLVTS7uFocGdwnd8XWe6NBNFUGXdu65a30gcCiC ZkLciZ7o2A7TkwwQ X-Received: by 10.84.160.226 with SMTP id v31mr16066256plg.122.1493395299836; Fri, 28 Apr 2017 09:01:39 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.01.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:01:39 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:16 +0530 Message-Id: <1493395284-18430-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 02/10 v2] xen/arm: vpl011: Add new vuart domctl interface to setup pfn and evtchn 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" X-Virus-Scanned: ClamAV using ClamSMTP 1. Add two new domctl API to: - Allocate a new event channel for sending/receiving events to/from Xen. - Map the PFN allocted by the toolstack to be used as IN/OUT ring buffers. Xen will communicate with xenconsole over 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 v1: - Replaced the hvm interface with domctl interface tools/libxc/include/xenctrl.h | 26 ++++++++++++++++++++++++++ tools/libxc/xc_domain.c | 39 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/domctl.c | 20 ++++++++++++++++++++ xen/arch/x86/domctl.c | 4 ++++ xen/include/public/domctl.h | 11 +++++++++++ 5 files changed, 100 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 1629f41..bebfe7d 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -886,6 +886,32 @@ int xc_vcpu_getcontext(xc_interface *xch, vcpu_guest_context_any_t *ctxt); /** + * This function returns information about the pfn and the event channel + * to be used for setting up a virtual uart console. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the domain to get information from + * @parm vuart_pfn the pfn to be used for the ring buffer + * @return 0 on success, negative error on failure + */ +int xc_domain_vuart_set_pfn(xc_interface *xch, + uint32_t domid, + uint32_t vuart_pfn); + +/** + * This function returns information about the pfn and the event channel + * to be used for setting up a virtual console. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the domain to get information from + * @parm vuart_evtchn the event channel to be used for console events + * @return 0 on success, negative error on failure + */ +int xc_domain_vuart_get_evtchn(xc_interface *xch, + uint32_t domid, + uint32_t *vuart_evtchn); + +/** * This function returns information about the XSAVE state of a particular * vcpu of a domain. If extstate->size and extstate->xfeature_mask are 0, * the call is considered a query to retrieve them and the buffer is not diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 00909ad4..943f202 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -343,6 +343,45 @@ int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid, return 0; } +int xc_domain_vuart_set_pfn(xc_interface *xch, + uint32_t domid, + uint32_t vuart_pfn) +{ + 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_SET_PFN; + domctl.u.vuart_op.pfn = vuart_pfn; + + if ( (rc = do_domctl(xch, &domctl)) < 0 ) + return rc; + + return rc; +} + +int xc_domain_vuart_get_evtchn(xc_interface *xch, + uint32_t domid, + uint32_t *vuart_evtchn) +{ + DECLARE_DOMCTL; + int rc = 0; + + *vuart_evtchn = -1; + + domctl.cmd = XEN_DOMCTL_vuart_op; + domctl.domain = (domid_t)domid; + domctl.u.vuart_op.cmd = XEN_DOMCTL_VUART_OP_GET_EVTCHN; + + if ( (rc = do_domctl(xch, &domctl)) < 0 ) + return rc; + + *vuart_evtchn = domctl.u.vuart_op.evtchn; + + return rc; +} + int xc_domain_getinfo(xc_interface *xch, uint32_t first_domid, unsigned int max_doms, diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index 971caec..e400f87 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,25 @@ 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; + if ( d->arch.vpl011.initialized ) + { + if ( domctl->u.vuart_op.cmd == XEN_DOMCTL_VUART_OP_SET_PFN ) + { + rc = vpl011_map_guest_page(d, domctl->u.vuart_op.pfn); + } + else + { + domctl->u.vuart_op.evtchn = d->arch.vpl011.evtchn; + rc = __copy_to_guest(u_domctl, domctl, 1); + } + return rc; + } + else + return -EINVAL; + } default: { int rc; diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index e104be2..49e907d 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1465,6 +1465,10 @@ long arch_do_domctl( recalculate_cpuid_policy(d); break; + case XEN_DOMCTL_vuart_op: + ret = -EOPNOTSUPP; + break; + default: ret = iommu_do_domctl(domctl, d, u_domctl); break; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index e6cf211..8bee0c3 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1138,6 +1138,15 @@ 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_SET_PFN 0 +#define XEN_DOMCTL_VUART_OP_GET_EVTCHN 1 + uint32_t cmd; /* XEN_DOMCTL_VUART_OP_* */ + uint32_t pfn; /* IN */ + uint32_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 +1227,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 +1290,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; };