From patchwork Mon Aug 28 08:55:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111107 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4547975qge; Mon, 28 Aug 2017 01:58:44 -0700 (PDT) X-Received: by 10.36.39.77 with SMTP id g74mr5747651ita.89.1503910724076; Mon, 28 Aug 2017 01:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910724; cv=none; d=google.com; s=arc-20160816; b=XsaYy1IVND5FPVf3XtScCm/dfPmLcRKCYWECH8I2wnf6iNmaeHtpSqmQCbpZ4wTpKI srJCcfu81IRNV+8b0od2rD/8UX/eEghgMO6ReXKhvYFJhhecGN7aoDdpXjDpxDNUU12S hqXtmdn0RylOeA+Zvnr9+56e/GXw1OzXTxOwaYv7t+dIymcTDjUajBLPyRt5Lc9l1ec+ sSS4PeTfuvp49tzJ4vuoUFjcCzArd2GrPsb9q1aZ/9Z9IOupVZW10EwiDEDdtKde+vs9 CQ0YBN205u7M1WOMsq0sMG2IYDsZ/5CH/YiSPoB9zpcGwFD8H1EaTOsLB+zK/loY6L0A caHg== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=h2Lgi14r56Z7LAI2sE2QMZenSofcYUDVfI3wXyIoGr8=; b=Iue2jJC/z3KNwZ1Dsw/PqNlD6dtzUhlEnJvemeRI5dd5Y35l2zvGE0uM8bmpT28SdD HFnVVUSsCXEibh2HmcT/2kHdQI4BQjnBeCXnBfmGdnWSopDLAcrtG2MX7X7xZlRHu3q5 6IlmiJ6v0LPPJw41orFY6Yy71NcGTIyYUnvbW2ey7p7MrwcxMg4pVG0wNHJnEEgG+9wq GJtL9fNF0T/oe0e2mvnwaORaIafguavo2mlvYotb2g+hAnqHT0+CIsLoMkleby9iyS1z 3xOc6AgKZMS57DsQlMcKSAYQqBg0wh16rfsvvPxzRatZ7+U5mNLasJ8rnKC8decBdJds WGnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=DUPNhwmF; 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 m186si7876889ith.33.2017.08.28.01.58.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:44 -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 header.s=google header.b=DUPNhwmF; 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 1dmFqM-0004et-4O; Mon, 28 Aug 2017 08:56:26 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqJ-0004eh-V1 for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:24 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 2D/3A-03044-7BAD3A95; Mon, 28 Aug 2017 08:56:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsVyMfTABt1ttxZ HGqx9r2fxfctkJgdGj8MfrrAEMEaxZuYl5VcksGbce/mTqaBVoOLIVL8Gxga+LkYuDiGBmYwS 7b+3MYE4LALzmCV+TrzODOJICPSzSnxe/5exi5ETyEmTeH7/IBuEXSbx9tleMFtIQEvi6KnZr BCj9jNJnP5yFKibg4NNwERiVocESI2IgJLEvVWTwTYwC1xglJj59zlYs7BAksTUC8eZQGwWAV WJn3MnsoLYvALeEiuONkItk5O4ea6TGcTmFPCR2LH2LjvEYm+JrtcfWCcwCixgZFjFqFGcWlS WWqRraKCXVJSZnlGSm5iZA+SZ6eWmFhcnpqfmJCYV6yXn525iBIYWAxDsYDz+Pu4QoyQHk5Io 786KxZFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHjP3ATKCRalpqdWpGXmAIMcJi3BwaMkwvvjB lCat7ggMbc4Mx0idYrRkuPKlXVfmDg2rF4PJKcc2P6FSYglLz8vVUqc1wdkngBIQ0ZpHtw4WC ReYpSVEuZlBDpQiKcgtSg3swRV/hWjOAejkjCvN8gUnsy8Eritr4AOYgI6SFFwIchBJYkIKak GxlRmiVWs4tM7/rfbJv6IWfGj7S9LxUSvUyfOF04/G872wnfd6V3PlSR1JcLW9O1mbLuj83o5 W1jcOo75LyVOJYjvijv7pZn7xq7DNy++vPsgseCy8uWs+FdWEwKWcTCY9XmWShxxa2t/IpksN TG++WLzIQGL2ia7+boRtlzvM/4HrU/088suVWIpzkg01GIuKk4EAK3kkZ2/AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-21.messagelabs.com!1503910581!79756814!1 X-Originating-IP: [209.85.192.176] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28775 invoked from network); 28 Aug 2017 08:56:22 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-8.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:22 -0000 Received: by mail-pf0-f176.google.com with SMTP id h75so14497990pfh.1 for ; Mon, 28 Aug 2017 01:56:22 -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=hEkKGCPm47FMsgYwL/NrMZbix4eTUybWDHit8lEDoDc=; b=DUPNhwmF9ZXyjvWAkIVDs9nQ9qlmQ3t+vt3a18InUd0XuZuUFr3kJpSC2i1glQMKuw xBGw2+tsRcolyra5BdmkFoKT6oE5OJFDL/YtOBDoH2MmUuB33DuvkzP+mts9cRScswet e9YFFh/HXKI0iAwBhGiQlBbZUDRZ9G04BGd+I= 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=hEkKGCPm47FMsgYwL/NrMZbix4eTUybWDHit8lEDoDc=; b=AWhJvFYFLezJpHErmfYj1RlJbuO6hecYGunADEJgPOXFNYt3s9yy6cAu9vusEU/+U0 R03/f0ZOy9y8nyiPlSXXQz4U60bpi7vEZwJ0IdF/BlP0bNddgWgzgblQO3yKA/t5U7eG zs8M8kQpwLuDvX514dqT4OZiesBAg0+oxWxjihrHyXkgL+IQ8b93Tw/sVxWDg85VVEvR 1033kR1py5J4D12F5xxOZuSiM6486bPBWpux/JdlEAibYC7X2ixniMU3fUb8dAqjHCel ZOXtPMwrMNc6LoxGCHKOyFbnp7uyBTVc6DOmA4FYuRsCH6xgWTAD0Gdy/TWf3SMRUyma SpqQ== X-Gm-Message-State: AHYfb5gDYDwTstsviD7W9E2aCRa/wpAguxp+hrmu17c4COiQLuyVNUxJ 69iRRcK4lD1LkNJWc8uhGQ== X-Received: by 10.99.47.66 with SMTP id v63mr6656102pgv.4.1503910581072; Mon, 28 Aug 2017 01:56:21 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:20 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:44 +0530 Message-Id: <1503910570-24427-2-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 01/27 v8] xen/arm: vpl011: Define common ring buffer helper functions in console.h 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" DEFINE_XEN_FLEX_RING(xencons) defines common helper functions such as xencons_queued() to tell the current size of the ring buffer, xencons_mask() to mask off the index, which are useful helper functions. pl011 emulation code will use these helper functions. io/console.h includes io/ring.h which defines DEFINE_XEN_FLEX_RING. In console/daemon/io.c, string.h had to be included before io/console.h because ring.h uses string functions. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Split this change in a separate patch. tools/console/daemon/io.c | 2 +- xen/include/public/io/console.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 7e474bb..e8033d2 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -21,6 +21,7 @@ #include "utils.h" #include "io.h" +#include #include #include #include @@ -29,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/xen/include/public/io/console.h b/xen/include/public/io/console.h index e2cd97f..5e45e1c 100644 --- a/xen/include/public/io/console.h +++ b/xen/include/public/io/console.h @@ -27,6 +27,8 @@ #ifndef __XEN_PUBLIC_IO_CONSOLE_H__ #define __XEN_PUBLIC_IO_CONSOLE_H__ +#include "ring.h" + typedef uint32_t XENCONS_RING_IDX; #define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1)) @@ -38,6 +40,8 @@ struct xencons_interface { XENCONS_RING_IDX out_cons, out_prod; }; +DEFINE_XEN_FLEX_RING(xencons); + #endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */ /* From patchwork Mon Aug 28 08:55:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111106 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4547956qge; Mon, 28 Aug 2017 01:58:43 -0700 (PDT) X-Received: by 10.107.57.8 with SMTP id g8mr5239638ioa.357.1503910723412; Mon, 28 Aug 2017 01:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910723; cv=none; d=google.com; s=arc-20160816; b=WxdbKEyRGpON5BJ04UUWwPFfTxX2BK+p1NCWG/1l5V2ZmWefs7JDDJtxovqD04KA9n k4yfit2Ge+UpZ+aRWW+Zy4/piUb7RT9+hp7O+aAYQ/yxByEC70vhZjCwSD9zN/HYEeqi e+/cIrX8+XeDHPFSM0Rb324p8unVSjAnv+JmYVVPsMmYb6666dMHg0vZl76qVBeHM58q OEB10pgo51d8DBAZ036MEZzSibaBbQKP2ter7UsC6H9Tn4UiEKAUnAxJxSlN/iIpbTp7 QXjB2Vt5B2SUN//62HB+lF1IKKOmNzuHnji1yUu8anKY7a1Aa8GBFkzXXLSzz+TNZ72H 9J2A== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=AS3zQsWci2c+8AHchunCQAjlO9bkR8X/mKxvTDypkSE=; b=ynAkZDL9DpcKVimaznP5QyZGYcDoJwLycMNTcWbO5tLvZZBgouhqOX2nImLakJHUQr /TgxKA7rB9S8qRsB0Oguam8Rzd6TRC2eof1alIt0YNwucAOGvhhxaXzRX+hET2f+dT9N 5z5U2fx4iqk9hPOqwxmLGK96WtjlkEBJh1OahbEsAsLw20WSz279L0cnDxyfHlnfVgOU 9YBlyX6sb8OKr2jrC/nkkA5XWH4UCFnW3wkyO6qKImxT80L1hpq/Slq8LRQTpM18y3hd fDijlw6VYnq/o1E+5KDV+hhdFpCRY575lpduzC+kLkuBtpzQ2QeOKVHmZzUzewZJk42d U/dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NTkhCpn7; 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 w2si7452410itb.90.2017.08.28.01.58.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:43 -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 header.s=google header.b=NTkhCpn7; 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 1dmFqR-0004gd-BO; Mon, 28 Aug 2017 08:56:31 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqQ-0004fW-9w for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:30 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id 36/38-01732-DBAD3A95; Mon, 28 Aug 2017 08:56:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRWlGSWpSXmKPExsVyMfTABt09txZ HGrzoF7H4vmUykwOjx+EPV1gCGKNYM/OS8isSWDMe/e5iL7i+krHi6+0upgbG1U2MXYycHEIC MxklNnyI7mLk4mARmMcs8f/qJGYQR0Kgn1Xi38U2sCoJgTSJXYsfsEDYVRJz1lxjg+jWkjh6a jYrSIOQwH4miXVz5wAVcXCwCZhIzOqQAKkREVCSuLdqMhNIDbPARGaJBT+Os4MkhAU8Ja4/vc 0EYrMIqEos3TkZbAGvgLfEsqP/oZbJSdw818kMYnMK+EjsWHuXHWKxt0TX6w+sExgFFjAyrGL UKE4tKkst0jU00UsqykzPKMlNzMzRNTQw1stNLS5OTE/NSUwq1kvOz93ECAwvBiDYwbhiu+ch RkkOJiVR3p0ViyOF+JLyUyozEosz4otKc1KLDzHKcHAoSfCG3ATKCRalpqdWpGXmAAMdJi3Bw aMkwvvjBlCat7ggMbc4Mx0idYrRlePKlXVfmDgW9GwAklMObAeST95s/83E0fIWSAqx5OXnpU qJ8/qAzBYAac4ozYMbDYvSS4yyUsK8jEDHCvEUpBblZpagyr9iFOdgVBLm9QaZwpOZVwJ3wSu g45iAjlMUXAhyXEkiQkqqgXHusZchU9N+T1zz4wvPdOM/2y7tufZ+tVnphon6JSuyJn2tFX0p EvSfyU5e7Ff1zCuCG69kzf/lPks2eNvcWyskg1cLHlH9wb3gfdr1mM3dNjlhKuvb5ukVXntx4 LR/mfId28m3FQ9d6dl3VH+W61Pu3OSC2A8Zj/wit0SI1zP8rL6jwnwmSHmPEktxRqKhFnNRcS IAxIeEqc0CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-7.tower-31.messagelabs.com!1503910586!104345744!1 X-Originating-IP: [209.85.192.176] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61550 invoked from network); 28 Aug 2017 08:56:27 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-7.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:27 -0000 Received: by mail-pf0-f176.google.com with SMTP id c15so14532639pfm.2 for ; Mon, 28 Aug 2017 01:56:27 -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=H8nYWJJvskdpTyy2mqBHUV+kyca8yTnXyZEZyG0ytCU=; b=NTkhCpn77egBFJzqKS7Q6sYC/+k45DmCU1nfmlehmCUxxbG9L7OL4Udu9J7P4iDRlP r9wSoW2NJGljxbGKF5ssjj+JSiZmGKRcwyY8s4X1hg3/rkRV0j0Bv7/Lcro/8D8fr4K7 Cb8q96RtFs4E65a2PSeEJytzF205hpcCT2EKY= 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=H8nYWJJvskdpTyy2mqBHUV+kyca8yTnXyZEZyG0ytCU=; b=TI4flybvH8O3E/8m9t+XcLrdg53hYp8mZ7o0dglYzbiFQ+LnjqZyhvLPijiL3FS0Qb 95+Uwbil8bCqIF6fPLfKL4ilhLd7MixXniY3bk8Zf7v2t2Q3/Ac93f23b72oxMxW3cdL Y/SF1jAhSrLXTG63YvE4KS54QMj3If6rlHNsY4Nu/2Xqi27Bygt/MgieOVEXmnnxIe9M 9Cl5NECrmBuP2VHDW4q8j3FpitASypeZTOaR/M3AUR8s6BbaA6j82NTwJqbUL6jCEmll 4Z65b0uG4FgFaeLLJHzt3IPpyjL3a0Eh6sVhBLyBdyTUgXUn7Sjavw8GR88feAVAmMlf /pBA== X-Gm-Message-State: AHYfb5hYK+sNMufkuQEw9cbfmPAVsY6G85Dwh0oO8amcyfxDPX19FTMi 8oQNzfMYOjAjssPMEPzWIw== X-Received: by 10.101.75.141 with SMTP id t13mr6870314pgq.269.1503910586056; Mon, 28 Aug 2017 01:56:26 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:25 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:45 +0530 Message-Id: <1503910570-24427-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Andre Przywara Subject: [Xen-devel] [PATCH 02/27 v8] xen/arm: vpl011: Add SBSA UART emulation in Xen 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 emulation code to emulate read/write access to pl011 registers and pl011 interrupts: - Emulate DR read/write by reading and writing from/to the IN and OUT ring buffers and raising an event to the backend when there is data in the OUT ring buffer and injecting an interrupt to the guest when there is data in the IN ring buffer - Other registers are related to interrupt management and essentially control when interrupts are delivered to the guest This patch implements the SBSA Generic UART which is a subset of ARM PL011 UART. The SBSA Generic UART is covered in Appendix B of https://static.docs.arm.com/den0029/a/Server_Base_System_Architecture_v3_1_ARM_DEN_0029A.pdf Signed-off-by: Bhupinder Thakur Acked-by: Julien Grall Reviewed-by: Stefano Stabellini --- CC: Andrew Cooper CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall CC: Andre Przywara Changes since v7: - Set/clear the TX interrupt status bit based on whether space available for 16 bytes in the ring buffer - Clear the BUSY status bit as soon as space becaomes available in the ring buffer Changes since v6: - Removed freeing of mmio_handlers in vpl011_deinit() as the handlers get freed when a domain is destroyed. Since this is a minor change, I have included the reviewed-by and acked-by tags. Changes since v5: - use instead of for including arm specific header files. - renamed shadow_uartris to shadow_uartmis to indicate that it is masked interrupt status. - use smp_mb() instead of smp_rmb() in vpl011_write_data(). Changes since v4: - Renamed vpl011_update() to vpl011_update_interrupt_status() and added logic to avoid raising spurious interrupts. - Used barrier instructions correctly while reading/writing data to the ring buffer. - Proper lock taken before reading ring buffer indices. Changes since v3: - Moved the call to DEFINE_XEN_FLEX_RING from vpl011.h to public/console.h. This macro defines standard functions to operate on the ring buffer. - Lock taken while updating the interrupt mask and clear registers in mmio_write. - Use gfn_t instead of xen_pfn_t. - vgic_free_virq called if there is any error in vpl011 initialization. - mmio handlers freed if there is any error in vpl011 initialization. - Removed vpl011->initialized flag usage as the same check could be done using vpl011->ring-ref. - Used return instead of break in the switch handling of emulation of different pl011 registers. - Renamed vpl011_update_spi() to vpl011_update(). Changes since v2: - Use generic vreg_reg* for read/write of registers emulating pl011. - Use generic ring buffer functions defined using DEFINE_XEN_FLEX_RING. - Renamed the SPI injection function to vpl011_update_spi() to reflect level triggered nature of pl011 interrupts. - The pl011 register access address should always be the base address of the corresponding register as per section B of the SBSA document. For this reason, the register range address access is not allowed. Changes since v1: - Removed the optimiztion related to sendiing events to xenconsole - Use local variables as ring buffer indices while using the ring buffer xen/arch/arm/Kconfig | 7 + xen/arch/arm/Makefile | 1 + xen/arch/arm/vpl011.c | 454 +++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/domain.h | 6 + xen/include/asm-arm/pl011-uart.h | 2 + xen/include/asm-arm/vpl011.h | 72 +++++++ xen/include/public/arch-arm.h | 6 + 7 files changed, 548 insertions(+) create mode 100644 xen/arch/arm/vpl011.c create mode 100644 xen/include/asm-arm/vpl011.h diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index d46b98c..f58019d 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -50,6 +50,13 @@ config HAS_ITS prompt "GICv3 ITS MSI controller support" if EXPERT = "y" depends on HAS_GICV3 +config SBSA_VUART_CONSOLE + bool "Emulated SBSA UART console support" + default y + ---help--- + Allows a guest to use SBSA Generic UART as a console. The + SBSA Generic UART implements a subset of ARM PL011 UART. + endmenu menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 282d2c2..3a381ee 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -51,6 +51,7 @@ obj-$(CONFIG_HAS_GICV3) += vgic-v3.o obj-$(CONFIG_HAS_ITS) += vgic-v3-its.o obj-y += vm_event.o obj-y += vtimer.o +obj-$(CONFIG_SBSA_VUART_CONSOLE) += vpl011.o obj-y += vpsci.o obj-y += vuart.o diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c new file mode 100644 index 0000000..56d9cbe --- /dev/null +++ b/xen/arch/arm/vpl011.c @@ -0,0 +1,454 @@ +/* + * arch/arm/vpl011.c + * + * Virtual PL011 UART + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Since pl011 registers are 32-bit registers, all registers + * are handled similarly allowing 8-bit, 16-bit and 32-bit + * accesses except 64-bit access. + */ +static bool vpl011_reg32_check_access(struct hsr_dabt dabt) +{ + return (dabt.size != DABT_DOUBLE_WORD); +} + +static void vpl011_update_interrupt_status(struct domain *d) +{ + struct vpl011 *vpl011 = &d->arch.vpl011; + uint32_t uartmis = vpl011->uartris & vpl011->uartimsc; + + /* + * This function is expected to be called with the lock taken. + */ + ASSERT(spin_is_locked(&vpl011->lock)); + + /* + * TODO: PL011 interrupts are level triggered which means + * that interrupt needs to be set/clear instead of being + * injected. However, currently vGIC does not handle level + * triggered interrupts properly. This function needs to be + * revisited once vGIC starts handling level triggered + * interrupts. + */ + + /* + * Raise an interrupt only if any additional interrupt + * status bit has been set since the last time. + */ + if ( uartmis & ~vpl011->shadow_uartmis ) + vgic_vcpu_inject_spi(d, GUEST_VPL011_SPI); + + vpl011->shadow_uartmis = uartmis; +} + +static uint8_t vpl011_read_data(struct domain *d) +{ + unsigned long flags; + uint8_t data = 0; + struct vpl011 *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + XENCONS_RING_IDX in_cons, in_prod; + + VPL011_LOCK(d, flags); + + in_cons = intf->in_cons; + in_prod = intf->in_prod; + + smp_rmb(); + + /* + * It is expected that there will be data in the ring buffer when this + * function is called since the guest is expected to read the data register + * only if the TXFE flag is not set. + * If the guest still does read when TXFE bit is set then 0 will be returned. + */ + if ( xencons_queued(in_prod, in_cons, sizeof(intf->in)) > 0 ) + { + data = intf->in[xencons_mask(in_cons, sizeof(intf->in))]; + in_cons += 1; + smp_mb(); + intf->in_cons = in_cons; + } + else + gprintk(XENLOG_ERR, "vpl011: Unexpected IN ring buffer empty\n"); + + if ( xencons_queued(in_prod, in_cons, sizeof(intf->in)) == 0 ) + { + vpl011->uartfr |= RXFE; + vpl011->uartris &= ~RXI; + } + + vpl011->uartfr &= ~RXFF; + + vpl011_update_interrupt_status(d); + + VPL011_UNLOCK(d, flags); + + /* + * Send an event to console backend to indicate that data has been + * read from the IN ring buffer. + */ + notify_via_xen_event_channel(d, vpl011->evtchn); + + return data; +} + +static void vpl011_write_data(struct domain *d, uint8_t data) +{ + unsigned long flags; + struct vpl011 *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + XENCONS_RING_IDX out_cons, out_prod; + + VPL011_LOCK(d, flags); + + out_cons = intf->out_cons; + out_prod = intf->out_prod; + + smp_mb(); + + /* + * It is expected that the ring is not full when this function is called + * as the guest is expected to write to the data register only when the + * TXFF flag is not set. + * In case the guest does write even when the TXFF flag is set then the + * data will be silently dropped. + */ + if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) != + sizeof (intf->out) ) + { + intf->out[xencons_mask(out_prod, sizeof(intf->out))] = data; + out_prod += 1; + smp_wmb(); + intf->out_prod = out_prod; + } + else + gprintk(XENLOG_ERR, "vpl011: Unexpected OUT ring buffer full\n"); + + if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) == + sizeof (intf->out) ) + { + vpl011->uartfr |= TXFF; + vpl011->uartris &= ~TXI; + } + + vpl011->uartfr |= BUSY; + + vpl011->uartfr &= ~TXFE; + + vpl011_update_interrupt_status(d); + + VPL011_UNLOCK(d, flags); + + /* + * Send an event to console backend to indicate that there is + * data in the OUT ring buffer. + */ + notify_via_xen_event_channel(d, vpl011->evtchn); +} + +static int vpl011_mmio_read(struct vcpu *v, + mmio_info_t *info, + register_t *r, + void *priv) +{ + struct hsr_dabt dabt = info->dabt; + uint32_t vpl011_reg = (uint32_t)(info->gpa - GUEST_PL011_BASE); + struct vpl011 *vpl011 = &v->domain->arch.vpl011; + struct domain *d = v->domain; + unsigned long flags; + + switch ( vpl011_reg ) + { + case DR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + *r = vreg_reg32_extract(vpl011_read_data(d), info); + return 1; + + case RSR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + /* It always returns 0 as there are no physical errors. */ + *r = 0; + return 1; + + case FR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + *r = vreg_reg32_extract(vpl011->uartfr, info); + VPL011_UNLOCK(d, flags); + return 1; + + case RIS: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + *r = vreg_reg32_extract(vpl011->uartris, info); + VPL011_UNLOCK(d, flags); + return 1; + + case MIS: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + *r = vreg_reg32_extract(vpl011->uartris & vpl011->uartimsc, + info); + VPL011_UNLOCK(d, flags); + return 1; + + case IMSC: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + *r = vreg_reg32_extract(vpl011->uartimsc, info); + VPL011_UNLOCK(d, flags); + return 1; + + case ICR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + /* Only write is valid. */ + return 0; + + default: + gprintk(XENLOG_ERR, "vpl011: unhandled read r%d offset %#08x\n", + dabt.reg, vpl011_reg); + return 0; + } + + return 1; + +bad_width: + gprintk(XENLOG_ERR, "vpl011: bad read width %d r%d offset %#08x\n", + dabt.size, dabt.reg, vpl011_reg); + domain_crash_synchronous(); + return 0; + +} + +static int vpl011_mmio_write(struct vcpu *v, + mmio_info_t *info, + register_t r, + void *priv) +{ + struct hsr_dabt dabt = info->dabt; + uint32_t vpl011_reg = (uint32_t)(info->gpa - GUEST_PL011_BASE); + struct vpl011 *vpl011 = &v->domain->arch.vpl011; + struct domain *d = v->domain; + unsigned long flags; + + switch ( vpl011_reg ) + { + case DR: + { + uint32_t data = 0; + + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + vreg_reg32_update(&data, r, info); + data &= 0xFF; + vpl011_write_data(v->domain, data); + return 1; + } + + case RSR: /* Nothing to clear. */ + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + return 1; + + case FR: + case RIS: + case MIS: + goto write_ignore; + + case IMSC: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + vreg_reg32_update(&vpl011->uartimsc, r, info); + vpl011_update_interrupt_status(v->domain); + VPL011_UNLOCK(d, flags); + return 1; + + case ICR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + vreg_reg32_clearbits(&vpl011->uartris, r, info); + vpl011_update_interrupt_status(d); + VPL011_UNLOCK(d, flags); + return 1; + + default: + gprintk(XENLOG_ERR, "vpl011: unhandled write r%d offset %#08x\n", + dabt.reg, vpl011_reg); + return 0; + } + +write_ignore: + return 1; + +bad_width: + gprintk(XENLOG_ERR, "vpl011: bad write width %d r%d offset %#08x\n", + dabt.size, dabt.reg, vpl011_reg); + domain_crash_synchronous(); + return 0; + +} + +static const struct mmio_handler_ops vpl011_mmio_handler = { + .read = vpl011_mmio_read, + .write = vpl011_mmio_write, +}; + +static void vpl011_data_avail(struct domain *d) +{ + unsigned long flags; + struct vpl011 *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + XENCONS_RING_IDX in_cons, in_prod, out_cons, out_prod; + XENCONS_RING_IDX in_ring_qsize, out_ring_qsize; + + VPL011_LOCK(d, flags); + + in_cons = intf->in_cons; + in_prod = intf->in_prod; + out_cons = intf->out_cons; + out_prod = intf->out_prod; + + smp_rmb(); + + in_ring_qsize = xencons_queued(in_prod, + in_cons, + sizeof(intf->in)); + + out_ring_qsize = xencons_queued(out_prod, + out_cons, + sizeof(intf->out)); + + /* Update the uart rx state if the buffer is not empty. */ + if ( in_ring_qsize != 0 ) + { + vpl011->uartfr &= ~RXFE; + if ( in_ring_qsize == sizeof(intf->in) ) + vpl011->uartfr |= RXFF; + vpl011->uartris |= RXI; + } + + /* Update the uart tx state if the buffer is not full. */ + if ( out_ring_qsize != sizeof(intf->out) ) + { + vpl011->uartfr &= ~TXFF; + vpl011->uartris |= TXI; + if ( out_ring_qsize == 0 ) + { + vpl011->uartfr &= ~BUSY; + vpl011->uartfr |= TXFE; + } + } + + vpl011_update_interrupt_status(d); + + VPL011_UNLOCK(d, flags); +} + +static void vpl011_notification(struct vcpu *v, unsigned int port) +{ + vpl011_data_avail(v->domain); +} + +int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info) +{ + int rc; + struct vpl011 *vpl011 = &d->arch.vpl011; + + if ( vpl011->ring_buf ) + return -EINVAL; + + /* Map the guest PFN to Xen address space. */ + rc = prepare_ring_for_helper(d, + gfn_x(info->gfn), + &vpl011->ring_page, + &vpl011->ring_buf); + if ( rc < 0 ) + goto out; + + rc = vgic_reserve_virq(d, GUEST_VPL011_SPI); + if ( !rc ) + { + rc = -EINVAL; + goto out1; + } + + rc = alloc_unbound_xen_event_channel(d, 0, info->console_domid, + vpl011_notification); + if ( rc < 0 ) + goto out2; + + vpl011->evtchn = info->evtchn = rc; + + spin_lock_init(&vpl011->lock); + + register_mmio_handler(d, &vpl011_mmio_handler, + GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL); + + return 0; + +out2: + vgic_free_virq(d, GUEST_VPL011_SPI); + +out1: + destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page); + +out: + return rc; +} + +void domain_vpl011_deinit(struct domain *d) +{ + struct vpl011 *vpl011 = &d->arch.vpl011; + + if ( !vpl011->ring_buf ) + return; + + free_xen_event_channel(d, vpl011->evtchn); + destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 8dfc1d1..1a1145d 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -11,6 +11,7 @@ #include #include #include +#include struct hvm_domain { @@ -145,6 +146,11 @@ struct arch_domain struct { uint8_t privileged_call_enabled : 1; } monitor; + +#ifdef CONFIG_SBSA_VUART_CONSOLE + struct vpl011 vpl011; +#endif + } __cacheline_aligned; struct arch_vcpu diff --git a/xen/include/asm-arm/pl011-uart.h b/xen/include/asm-arm/pl011-uart.h index 123f477..57e9ec7 100644 --- a/xen/include/asm-arm/pl011-uart.h +++ b/xen/include/asm-arm/pl011-uart.h @@ -49,6 +49,8 @@ /* FR bits */ #define TXFE (1<<7) /* TX FIFO empty */ #define RXFE (1<<4) /* RX FIFO empty */ +#define TXFF (1<<5) /* TX FIFO full */ +#define RXFF (1<<6) /* RX FIFO full */ #define BUSY (1<<3) /* Transmit is not complete */ /* LCR_H bits */ diff --git a/xen/include/asm-arm/vpl011.h b/xen/include/asm-arm/vpl011.h new file mode 100644 index 0000000..1b583da --- /dev/null +++ b/xen/include/asm-arm/vpl011.h @@ -0,0 +1,72 @@ +/* + * include/xen/vpl011.h + * + * Virtual PL011 UART + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + */ + +#ifndef _VPL011_H_ +#define _VPL011_H_ + +#include +#include +#include +#include + +/* helper macros */ +#define VPL011_LOCK(d,flags) spin_lock_irqsave(&(d)->arch.vpl011.lock, flags) +#define VPL011_UNLOCK(d,flags) spin_unlock_irqrestore(&(d)->arch.vpl011.lock, flags) + +struct vpl011 { + void *ring_buf; + struct page_info *ring_page; + uint32_t uartfr; /* Flag register */ + uint32_t uartcr; /* Control register */ + uint32_t uartimsc; /* Interrupt mask register*/ + uint32_t uarticr; /* Interrupt clear register */ + uint32_t uartris; /* Raw interrupt status register */ + uint32_t shadow_uartmis; /* shadow masked interrupt register */ + spinlock_t lock; + evtchn_port_t evtchn; +}; + +struct vpl011_init_info { + domid_t console_domid; + gfn_t gfn; + evtchn_port_t evtchn; +}; + +#ifdef CONFIG_SBSA_VUART_CONSOLE +int domain_vpl011_init(struct domain *d, + struct vpl011_init_info *info); +void domain_vpl011_deinit(struct domain *d); +#else +static inline int domain_vpl011_init(struct domain *d, + struct vpl011_init_info *info) +{ + return -ENOSYS; +} + +static inline void domain_vpl011_deinit(struct domain *d) { } +#endif +#endif /* _VPL011_H_ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index bd974fb..85ab665 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -410,6 +410,10 @@ typedef uint64_t xen_callback_t; #define GUEST_ACPI_BASE 0x20000000ULL #define GUEST_ACPI_SIZE 0x02000000ULL +/* PL011 mappings */ +#define GUEST_PL011_BASE 0x22000000ULL +#define GUEST_PL011_SIZE 0x00001000ULL + /* * 16MB == 4096 pages reserved for guest to use as a region to map its * grant table in. @@ -444,6 +448,8 @@ typedef uint64_t xen_callback_t; #define GUEST_TIMER_PHYS_NS_PPI 30 #define GUEST_EVTCHN_PPI 31 +#define GUEST_VPL011_SPI 32 + /* PSCI functions */ #define PSCI_cpu_suspend 0 #define PSCI_cpu_off 1 From patchwork Mon Aug 28 08:55:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111110 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4547994qge; Mon, 28 Aug 2017 01:58:45 -0700 (PDT) X-Received: by 10.107.20.70 with SMTP id 67mr6147345iou.100.1503910725298; Mon, 28 Aug 2017 01:58:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910725; cv=none; d=google.com; s=arc-20160816; b=TnIyMCvhcqD/FvlwN5NiEe80U8UKc/WEdr3bxNeWL2QGuUpVCXRw1opk08UdKcivrt +Hb8vtTLfid3Nmowt/kXpoRhoVUdnXpVOpfV61hXFDBorexeJo9VrNz1XMFH1Gc79YgX sEP4aQuYwYgh4wOhNK9q217pj0nPJ6Y0cGKHi+TGr2sQTt0FmZ8OSZnr3YA0bi/sN3Ke 9pB/HRUnAxuNmYkkV/OQY0CShhVsRCBfwHbCcKXDQvCLdZKk4r+4Vr1lTRIJ/AL5Fd37 gnpDLMgKB2NTo5f0or+5Ky7ylV0YaNxsrkUEPpiEU43KxQHT2aITW0wjEC42ra7zGOXL zhfA== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=d23F1O6qb/I6F+2OFIqAHgS6mjWuJ06gCWICNNt5+jg=; b=K7ze61VlbG1AyY2JdptiwROOJu2WcmW4tR4YEwJp0EzRTQpsHOTGzXXn+3k/gp9Hxh CuhDq01F8LIQFqoDOg7MQtoQYxblgOvGFgawgm33GzpZisUHMLL8ohiZTZEEooeROSiJ BvKEjaRP24wcVJ/y1rVwsjxDUyKcpyT0+RMtvuHmFcAW61fhTGwgxaREk6Gb+u7EiAhr JlvdYJeYO29sFg1jPjiiDgKY5L9F4Yh+aivZrjOnQ2ynbnFVQFyJGNbBtx7KUTU8GkFq KF7TolRSWqNmSSNl/dipefgFdOmDN2rOrgWVyib34HRTPAS/GFTK4WpaWZIwaWPP+cce c2Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kGliBpza; 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 h134si11934211iof.279.2017.08.28.01.58.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:45 -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 header.s=google header.b=kGliBpza; 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 1dmFqT-0004i6-Lr; Mon, 28 Aug 2017 08:56:33 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqS-0004h2-7j for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:32 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id AA/44-01995-FBAD3A95; Mon, 28 Aug 2017 08:56:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsXiVRtsqrvv1uJ Ig8kHrC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oztL86wF7ySrJiyZhNzA+Md0S5GTg4hgemM Es9PWnQxcnGwCMxjllh0aCoTiCMh0M8qceHRHCaQKgmBNInzi0+xQNjlEt/X3WKG6NaSOHpqN itIg5DAfiaJ3VOfM3YxcnCwCZhIzOqQAKkREVCSuLdqMthQZoH5jBJNk3rZQBLCAhESvbe6GE FsFgFViSnbL7GC2LwC3hLr2vawQSyTk7h5rhNsGaeAj8SOtXfZIRZ7S3S9/sA6gVFgASPDKka N4tSistQiXUNLvaSizPSMktzEzBxdQwNjvdzU4uLE9NScxKRiveT83E2MwNCqZ2Bg3MH4+7jf IUZJDiYlUd6dFYsjhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwhtwEygkWpaanVqRl5gCDHCYtw cGjJML7ASTNW1yQmFucmQ6ROsWoyzHpwPYvTEIsefl5qVLivD4gRQIgRRmleXAjYBF3iVFWSp iXkYGBQYinILUoN7MEVf4VozgHo5Iw70GQKTyZeSVwm14BHcEEdISi4EKQI0oSEVJSDYwuMzL EhNvMpsc9vzLfcop3eLLiOrk2ucZ48zuqcw9yX1D3WJyuuzDuz2GfsGd3v339y3SyivmDXaXd 6hkd1/7yCFtND9QIexKU/mGy94TJJhuEnBKqjsisZlFf+u1zRFTlBLbvVj/PKAVF73U/53DyI t8my3mCn6JLuF7Hff5dX39h26La65OUWIozEg21mIuKEwEZmCKrswIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-4.tower-31.messagelabs.com!1503910589!53826548!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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61183 invoked from network); 28 Aug 2017 08:56:30 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-4.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:30 -0000 Received: by mail-pg0-f53.google.com with SMTP id 63so22237882pgc.2 for ; Mon, 28 Aug 2017 01:56:30 -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=l6qPJ2j2XHzH4tm5SO40ctm3ZgjV1/opafjwCKIt+cs=; b=kGliBpzaNzpWPTkyVHzwxhxC9rf9isqq1MnHIOjhD8WEX1WXBnqDRyFWKSK7hM8cOv L7+7RDOWncbZZ8iIIsb+uy19eQ2+cHY6filvcA0eJgm4gn8yfBLkuXcd3EgciQKx5upA hefxKew/G7XkY5ff6IN9iFa6lLli401bu9BSA= 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=l6qPJ2j2XHzH4tm5SO40ctm3ZgjV1/opafjwCKIt+cs=; b=V7CVKMIDd8Nvxi61GzIJBTqQ9+XyGYQA0fI2/zvng8VGRf2lUSIfjZ75aYDHfknFWk wJZg3WWcbYVWV5PPHl+sCnZVueGaIjISaC6hXReNxKhFUpULz/y6rOAuHZMNxJHplVno Bdn2jHZkvFZwdYH0w9TaKwuOu2GMY/10XHurjOVbtDfU+VXWok9L2rbdR5bGs/Hhg+d5 sL+8K+E13VsGMTYoW666XU1SyDb0J8VhxnRemBr4JLCuCy1pHaJ/Uoo4Axi1XluVxO0L cFL2OZq4YkyP6W5ZhXqNbl0MxpIufsucUS6x3cdF6rcyh3t1xbzzytjuRCUFblB/ZdQ7 +MDA== X-Gm-Message-State: AHYfb5iRzfwpDJTcSE9p5gzu1oJzNdDOUSQvNyIONw1NudTKwSySVXik jkfZBjPiL5gZjv6GZXxhSQ== X-Received: by 10.98.9.90 with SMTP id e87mr6762112pfd.138.1503910589097; Mon, 28 Aug 2017 01:56:29 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:28 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:46 +0530 Message-Id: <1503910570-24427-4-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 03/27 v8] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart 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" Allocate a new gfn to be used as a ring buffer between xenconsole and Xen for sending/receiving pl011 console data. Signed-off-by: Bhupinder Thakur Acked-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Removed xc_get_vuart_gfn() as it is not required since the vpl011 initialization function which used this API has been moved to after gfn is allocated. - I have included the reviewed-by and acked-by tags as there is no change in the logic. Changes since v3: - Added a new helper function xc_get_vuart_gfn() to return the GFN allocated for vpl011. - Since a new function has been added in this patch, I have not included Stefano's reviewed-by and Wei's acked-by tags. Changes since v2: - Removed the DOMCTL call to set the GFN as now this information is passed in the DOMCTL call to initialize vpl011 emulation. tools/libxc/include/xc_dom.h | 2 ++ tools/libxc/xc_dom_arm.c | 5 ++++- tools/libxc/xc_dom_boot.c | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index ce47058..6e06ef1 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -216,6 +216,8 @@ struct xc_dom_image { /* Extra SMBIOS structures passed to HVMLOADER */ struct xc_hvm_firmware_module smbios_module; + + xen_pfn_t vuart_gfn; }; /* --- pluggable kernel loader ------------------------------------- */ diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index e7d4bd0..c981b7a 100644 --- a/tools/libxc/xc_dom_arm.c +++ b/tools/libxc/xc_dom_arm.c @@ -26,10 +26,11 @@ #include "xg_private.h" #include "xc_dom.h" -#define NR_MAGIC_PAGES 3 +#define NR_MAGIC_PAGES 4 #define CONSOLE_PFN_OFFSET 0 #define XENSTORE_PFN_OFFSET 1 #define MEMACCESS_PFN_OFFSET 2 +#define VUART_PFN_OFFSET 3 #define LPAE_SHIFT 9 @@ -85,10 +86,12 @@ static int alloc_magic_pages(struct xc_dom_image *dom) dom->console_pfn = base + CONSOLE_PFN_OFFSET; dom->xenstore_pfn = base + XENSTORE_PFN_OFFSET; + dom->vuart_gfn = base + VUART_PFN_OFFSET; xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_pfn); xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_pfn); xc_clear_domain_page(dom->xch, dom->guest_domid, base + MEMACCESS_PFN_OFFSET); + xc_clear_domain_page(dom->xch, dom->guest_domid, base + VUART_PFN_OFFSET); xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CONSOLE_PFN, dom->console_pfn); xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_STORE_PFN, diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c index c3b44dd..8a376d0 100644 --- a/tools/libxc/xc_dom_boot.c +++ b/tools/libxc/xc_dom_boot.c @@ -226,6 +226,8 @@ int xc_dom_boot_image(struct xc_dom_image *dom) return rc; if ( (rc = clear_page(dom, dom->xenstore_pfn)) != 0 ) return rc; + if ( (rc = clear_page(dom, dom->vuart_gfn)) != 0 ) + return rc; /* start info page */ if ( dom->arch_hooks->start_info ) From patchwork Mon Aug 28 08:55:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111108 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4547980qge; Mon, 28 Aug 2017 01:58:44 -0700 (PDT) X-Received: by 10.107.138.29 with SMTP id m29mr6177720iod.263.1503910724495; Mon, 28 Aug 2017 01:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910724; cv=none; d=google.com; s=arc-20160816; b=BjK+aLkFx96n/eofMvwAv35cebjogu5Gwy+tMzrfsIObMASVmjEAlgqChKOB6LReUS hqNJegSlMNCUZOc+8WQDczXKU7wBBdP3HsIT5kP6hy0HScIobSOM47G0tb7Rgjapkps+ d2VzphcnRi/llmkhFTsKaU/Hfaj4jQWafNx24TCAvJg/eLtdg43+z0HF1cEeknuk7cRs 16ANPsqjkHQk+JtxCvl184c0VegT6eKTdcR9GpRiHse1Ppy5SdT+j9U345hHg7uB/4d0 gBQx1eqniAQOeWnW/kTDNJy6BtoJrbnsur8URU0rYaflM/jhGsCDC9Bh0bv15lGnfmZR mLXw== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=8dtN5Z6XkzSAzP7su9v/SMW6vqO0BrcpmaesV0kPtew=; b=KkY/WWpBxwi3fA/+dYM0xuwfl3pl2rhXGCFcyo/CCHROBwX9WV7uYgussVAT6J0kHT Ms+opF673mZ31QAc5lOLvuLvB/Xvtdsyjd0MiYqS81daC4I7fr1tKZCu3lPzGg1Q2eQ3 BrvbhA24Dv+fGVxErGfB1DrPUYVFK338QaBF7kEzW+JZ94NxbN84+YLZCaDXVrTweRei GxVxBCy0/tlvX+ux9w6sOrv2vCLg2NFaCWDtHp5Dvek305LD+Zk3DJOBUagJx5wu7lnk ktRj0hPCNTcLKIui9pyyWDwMH2CQY/EK4NF1gtUVaLkSY7ykilyxGbMpRLlvi1nu8TlT fogw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LlByt/GW; 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 o11si7475679itb.111.2017.08.28.01.58.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:44 -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 header.s=google header.b=LlByt/GW; 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 1dmFqW-0004jW-St; Mon, 28 Aug 2017 08:56:36 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqV-0004iq-79 for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:35 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 93/80-02962-2CAD3A95; Mon, 28 Aug 2017 08:56:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsVyMfTANt2DtxZ HGtxdbWLxfctkJgdGj8MfrrAEMEaxZuYl5VcksGZ8n97KWPDJuOL9kXOMDYzLNLsYuTiEBGYy SrTOuMgI4rAIzGOWODJ1KZgjIdDPKnH5wCP2LkZOICdNYsOKb0xdjBxAdrXEzMZCkLCQgJbE0 VOzWSEm7WeS6L93jRmkhk3ARGJWhwRIjYiAksS9VZOZQGqYBeYzSjRN6mUDSQgLeEp8/nKcGc RmEVCV2Hu2kx2kl1fAW6Lxnh7EWjmJm+c6wUo4BXwkdqy9yw6x11ui6/UH1gmMAgsYGVYxahS nFpWlFukaWeglFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgQGFgMQ7GA8vzbwEKMk B5OSKO/OisWRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4z9wEygkWpaanVqRl5gBDHCYtwcGjJ ML7ASTNW1yQmFucmQ6ROsVoyXHlyrovTBwbVq8HklMObP/CJMSSl5+XKiXO+xCkQQCkIaM0D2 4cLA4vMcpKCfMyAh0oxFOQWpSbWYIq/4pRnINRSZj3IMgUnsy8Eritr4AOYgI6SFFwIchBJYk IKakGxpxnLx1WcU+Zneiknp1UrKNVXHCwbAVDY9uP3+mf7506K98dMrH443eRzH4x11K+z7u/ 7c5rOsv55fyFTR23onj9iirbyxuvSNbseq9sxqF2fqma87kZ3EefdzXeTtnOHW2ePFF97xq2v /lSbcZz9n78/FmrJvdknHbsaYcojstl2yetbCr2U2Ipzkg01GIuKk4EAPU+I0W+AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-2.tower-21.messagelabs.com!1503910592!65946901!1 X-Originating-IP: [209.85.192.182] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45323 invoked from network); 28 Aug 2017 08:56:33 -0000 Received: from mail-pf0-f182.google.com (HELO mail-pf0-f182.google.com) (209.85.192.182) by server-2.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:33 -0000 Received: by mail-pf0-f182.google.com with SMTP id h75so14499389pfh.1 for ; Mon, 28 Aug 2017 01:56:33 -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=p3M4k25sgODLCb8EWa11OUakliOw4e6cNBaSDFl9PHQ=; b=LlByt/GWzRDCATMtjk/IpKxIIHr7hxSM30HCXaK+NT2HZv4gmmYsDrTbKB9uOhW9ae DBevDVtxVH3rgflzL6Pl/aWgSHIGuO0H+3wVz2CEJ0R5D5Osz3te5Ig8lbWiEzn+pgZ3 sqtlzDT1ZOutEnbs1R6FEa6jC3mV8KuFl+Rsc= 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=p3M4k25sgODLCb8EWa11OUakliOw4e6cNBaSDFl9PHQ=; b=jqLWlZLssvSU2wlxOSgOCUHL1B0CDG3nABUMAjbt8DNFGdWNPnEEBZEdplO1+N4ICJ SoPXVWZjg68xq57+0+jgASM7GFXcf8TTk9PatQqogtDT24heNlD9CtKh4dZPjjikL0kB l0x+SnQq5RT+dE5+Jhwthm6O1aw9rHn4b/fmKp0+Xy9buR7GhoPvVSbx9Wzi5ilKfLmy lnHayhSauPEMlOB57e0qKigbZP/SM6cM6afifgaUBn2GvSdRcwojRCL3X+aqHGolmDtV qIv48wCVlff2AXsn3IbymSBqpAX3FqqHajXSmZaQXDlC4EKMrGAE3GP1cmENYB7scW+v metA== X-Gm-Message-State: AHYfb5g2mRHnC6xNarILO7y4nz0+xJC62+VD5u2jg8DnI2x+xsZ7DlmS SqVrKiP0Qn/gPsAVFaBItw== X-Received: by 10.99.121.138 with SMTP id u132mr6919249pgc.424.1503910591900; Mon, 28 Aug 2017 01:56:31 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:31 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:47 +0530 Message-Id: <1503910570-24427-5-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 04/27 v8] xen/arm: vpl011: Add support for vuart in libxl 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" An option is provided in libxl to enable/disable SBSA vuart while creating a guest domain. Libxl now supports a generic vuart console and SBSA uart is a specific type. In future support can be added for multiple vuart of different types. User can enable SBSA vuart by adding the following line in the guest configuration file: vuart = "sbsa_uart" Signed-off-by: Bhupinder Thakur Acked-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Renamed "pl011" to "sbsa_uart". Changes since v3: - Added a new config option CONFIG_VUART_CONSOLE to enable/disable vuart console support. - Moved libxl_vuart_type to arch-arm part of libxl_domain_build_info - Updated xl command help to mention new console type - vuart. Changes since v2: - Defined vuart option as an enum instead of a string. - Removed the domain creation flag defined for vuart and the related code to pass on the information while domain creation. Now vpl011 is initialized independent of domain creation through new DOMCTL APIs. tools/libxl/libxl.h | 6 ++++++ tools/libxl/libxl_console.c | 3 +++ tools/libxl/libxl_dom.c | 1 + tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_types.idl | 7 +++++++ tools/xl/xl_cmdtable.c | 2 +- tools/xl/xl_console.c | 5 ++++- tools/xl/xl_parse.c | 8 ++++++++ 8 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 229e289..8ce920a 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -306,6 +306,12 @@ #define LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE 1 /* + * LIBXL_HAVE_BUILDINFO_ARM_VUART indicates that the toolstack supports virtual UART + * for ARM. + */ +#define LIBXL_HAVE_BUILDINFO_ARM_VUART 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 446e766..853be15 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -67,6 +67,9 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, case LIBXL_CONSOLE_TYPE_SERIAL: cons_type_s = "serial"; break; + case LIBXL_CONSOLE_TYPE_VUART: + cons_type_s = "vuart"; + break; default: goto out; } diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index f54fd49..e0f0d78 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -803,6 +803,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_internal.h b/tools/libxl/libxl_internal.h index 7247509..6b38453 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1139,6 +1139,9 @@ typedef struct { uint32_t num_vmemranges; xc_domain_configuration_t config; + + xen_pfn_t vuart_gfn; + evtchn_port_t vuart_port; } libxl__domain_build_state; _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid, diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 6e80d36..9959efb 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -105,6 +105,7 @@ libxl_console_type = Enumeration("console_type", [ (0, "UNKNOWN"), (1, "SERIAL"), (2, "PV"), + (3, "VUART"), ]) libxl_disk_format = Enumeration("disk_format", [ @@ -240,6 +241,11 @@ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [ (2, "COLO"), ]) +libxl_vuart_type = Enumeration("vuart_type", [ + (0, "unknown"), + (1, "sbsa_uart"), + ]) + # # Complex libxl types # @@ -581,6 +587,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), + ("vuart", libxl_vuart_type), ])), # Alternate p2m is not bound to any architecture or guest type, as it is # supported by x86 HVM and ARM support is planned. diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 2c71a9f..3094bce 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -133,7 +133,7 @@ struct cmd_spec cmd_table[] = { &main_console, 0, 0, "Attach to domain's console", "[options] \n" - "-t console type, pv or serial\n" + "-t console type, pv , serial or vuart\n" "-n console number" }, { "vncviewer", diff --git a/tools/xl/xl_console.c b/tools/xl/xl_console.c index 0508dda..4e65d73 100644 --- a/tools/xl/xl_console.c +++ b/tools/xl/xl_console.c @@ -27,6 +27,7 @@ int main_console(int argc, char **argv) uint32_t domid; int opt = 0, num = 0; libxl_console_type type = 0; + char *console_names = "pv, serial, vuart"; SWITCH_FOREACH_OPT(opt, "n:t:", NULL, "console", 1) { case 't': @@ -34,8 +35,10 @@ int main_console(int argc, char **argv) type = LIBXL_CONSOLE_TYPE_PV; else if (!strcmp(optarg, "serial")) type = LIBXL_CONSOLE_TYPE_SERIAL; + else if (!strcmp(optarg, "vuart")) + type = LIBXL_CONSOLE_TYPE_VUART; else { - fprintf(stderr, "console type supported are: pv, serial\n"); + fprintf(stderr, "console type supported are: %s\n", console_names); return EXIT_FAILURE; } break; diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 5c2bf17..71588de 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -918,6 +918,14 @@ void parse_config_data(const char *config_source, if (!xlu_cfg_get_long (config, "maxvcpus", &l, 0)) b_info->max_vcpus = l; + if (!xlu_cfg_get_string(config, "vuart", &buf, 0)) { + if (libxl_vuart_type_from_string(buf, &b_info->arch_arm.vuart)) { + fprintf(stderr, "ERROR: invalid value \"%s\" for \"vuart\"\n", + buf); + exit(1); + } + } + parse_vnuma_config(config, b_info); /* Set max_memkb to target_memkb and max_vcpus to avail_vcpus if From patchwork Mon Aug 28 08:55:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111102 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4547859qge; Mon, 28 Aug 2017 01:58:36 -0700 (PDT) X-Received: by 10.107.59.150 with SMTP id i144mr5362032ioa.226.1503910716172; Mon, 28 Aug 2017 01:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910716; cv=none; d=google.com; s=arc-20160816; b=UZTV887sbcOT8Cxaof/Rk9Fp37/0roqeLa67buL8oBcw260aCnzj2AH+X1AhggsgoU UWnwHAXc4nRc++pX1ckXZIEnF3U58pA9h3bdhuFayBwnBkJTAjSO6LF81X0KobpmRXuT g9EzYGeKHedqZrh2G0DcxRsiYDPtJJmGuLzf0ewa9mRc860A3UOSLwL650mvATyqwgdY 1kIbrcMfwozWe3IuzYVIfkzzeBjdqrFsb6s3fBsx2nz8LO/vXRuphaja2qFUEAQO6bTd JtPkCqWu92Xv2wqclrldLZ9ZfSH4y0jBII0icpJI9fOrz8msNSa9nXlwQ4sBQ3NEcAif CZoQ== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=mV9Hngypj1Q3cb4StM0ZIyrwNRJbKGcsu6meTYrpf88=; b=MZXGPTlJukq3Cvb6EsAf0kumcn3JbcQVBCXuVta3u1G43gykqTEXd4fjD5Rck/Dn9s 5522mQv7iocxjDrbL+aEI93EU7SUkLKCboFeaedNZb3iXnPfunlHbm0JDAnhV5IcsBG/ Rhx+HpGqx1pv+QSmALPN2iyDIOpHHDi83AsXrDEX9GhvkvNI2Ins2+gWs616MvC0Kcpx JT0RKx8eqUzhPXoXFkiM/gnQ/3DGhwbQtftxinfVUi1NGzqeDJzxOCZXcjNbcZk1aZqI JCZHelvL/JTMhDSdQRpQ/S2F7WuBfSvYFJqWvmbd5xVjp7ElUGaPBlJlJhPYxpDcZmOj IOLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=B4V+WUK8; 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 z82si7739947itb.40.2017.08.28.01.58.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:36 -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 header.s=google header.b=B4V+WUK8; 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 1dmFqc-0004lf-3n; Mon, 28 Aug 2017 08:56:42 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqa-0004kt-JW for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:40 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 2B/BC-01736-7CAD3A95; Mon, 28 Aug 2017 08:56:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRWlGSWpSXmKPExsXiVRuspXvk1uJ Ig6/djBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aCXd3sBZfYKw4fncXcwHibrYuRi0NIYDqj xLo1y5lBHBaBecwSfXPesnYxcnJICPSzSjy6HARhp0nc+/4EKM4BZFdK/NpiCRIWEtCSOHpqN ivEoP1MElcaZzKD1LAJmEjM6pAAqRERUJK4t2oyE4jNLBAqMfXvAxYQW1ggS+Jiz0VGEJtFQF Xi45wnLCCtvALeEmvP10NslZO4ea6TGcTmFPCR2LH2LjvEWm+JrtcfWCcwCixgZFjFqFGcWlS WWqRraKGXVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKyXnJ+7iREYVAxAsIOxabvnIUZJDiYl Ud6dFYsjhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwhtwEygkWpaanVqRl5gDDGyYtwcGjJML74 wZQmre4IDG3ODMdInWK0Zij6cOWL0wckw5s/8IkxJKXn5cqJc7rAzJJAKQ0ozQPbhAs7i4xyk oJ8zICnSbEU5BalJtZgir/ilGcg1FJmNcbZApPZl4J3L5XQKcwAZ2iKLgQ5JSSRISUVAOjzKP nna8PrD5tMHnxKt0bVSWLjSYIP9tZI1Pxqyny54pJpzfrGixRqLobEHYzO3Wqgefs1MrcqYyu HrFR68J8X0henbrhxqLKT9n2PazbfiyXWLHTjsVW8u6t+adsE9aevt3brimiUVznym+u6+re0 r1hRYqaXpPwj6kqL6cmt8bsYOGWOvVWiaU4I9FQi7moOBEAmre6U7YCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-206.messagelabs.com!1503910594!70319978!1 X-Originating-IP: [74.125.83.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57339 invoked from network); 28 Aug 2017 08:56:35 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-14.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:35 -0000 Received: by mail-pg0-f42.google.com with SMTP id t3so22359395pgt.0 for ; Mon, 28 Aug 2017 01:56: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:in-reply-to:references; bh=nFTNxZDC2qp97HE4gxLCge8kPmvOQujiAaRxzy3SoOk=; b=B4V+WUK8qMP+kl1/uhYdXhXC3vbegd6yUICjFZs1+maeqFeW/2yJMkFn2psVy/djoI vxY/97aa1Sz98QPrLjWMDegCcwvglfFIdiIBCuDk2ChgSFUyv9S7XImHJbtK4ovCX5/Z Vy49Zc+5s+Jv8k4wJYdHDAlACz7U//D2hnpOc= 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=nFTNxZDC2qp97HE4gxLCge8kPmvOQujiAaRxzy3SoOk=; b=L0RK7m3YE8Bmoc/s16OZFBColTk9B8nduGdUlJzZyNEFMlTW2wW1+Qjj4FyYEAmlsF wKObNDHy6kKmaA24pC+n+k2VPCkPNPyzlUYJWV/C/HOaPFJ3Og2a61eMmh/sP6vNsWy2 y4EgTElKSoEUGSigzTGQjyoApYDEtuAR1+cNvPU7PDEcEX2zB4NViR5WOnNUzQr3YbaA fFNGF8oLqdjqJOFw85/3ZxHNE1hV85JVZiJxSkg3zS6tW9Y5pByxAPORDKhyel6lb4GR J4ROb5LznBB/zfMPjevGnAnyyibaIdeB+yvSBpdsT709DX8TWwyJVloicpOLWekaYyrJ 6m3Q== X-Gm-Message-State: AHYfb5jF6TFcBceLc/TvCOFIVf1oNXTxSko79a+CcotnircP5tGsEYtJ fhlXcgxdYwbNo/IH1gYKzQ== X-Received: by 10.99.122.85 with SMTP id j21mr4428488pgn.117.1503910594262; Mon, 28 Aug 2017 01:56:34 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:33 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:48 +0530 Message-Id: <1503910570-24427-6-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 05/27 v8] xen/arm: vpl011: Rearrange xen header includes in alphabetical order in domctl.c 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" Rearrange xen header includes in alphabetical order in domctl.c. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Reviewed-by: Julien Grall --- CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Corrected include of in alphabetical order. xen/arch/arm/domctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index 971caec..db6838d 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -4,12 +4,12 @@ * Copyright (c) 2012, Citrix Systems */ -#include -#include #include -#include #include #include +#include +#include +#include #include #include From patchwork Mon Aug 28 08:55:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111112 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548028qge; Mon, 28 Aug 2017 01:58:47 -0700 (PDT) X-Received: by 10.36.245.70 with SMTP id k67mr4738712ith.183.1503910727751; Mon, 28 Aug 2017 01:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910727; cv=none; d=google.com; s=arc-20160816; b=LwH8pBSPmjmQssLx5sXVUdYY8tGV9xM09vhaNnAdGt35k0Pptz4oU6kaccsSsd42No P+oKgjGp7yXO5EbS8WL8ZrW22d6cpr4zHPwkycfDcteDyNMPeoN2ApQ9Y49Brz/vn6rF FwUBo3UGG+kUECnPoqzaCvTKE1uPQxOtzGFrWJCc0c/+/yA/WzvZATmxVhH8He1/9GTD hWPdl3k/kK3U83JbNXwu8JkxT5gvBwAAD8xFMixOzDXxuV50fpy66OSESJUjfpaFdb3b ykVG7/jTOl6N1Y8HAX2Cvlh4w9njUATI99Pf+wOtBH1THdwFYUJi17k7gCndFjOG/X4g oTpQ== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=/4KhhswuG+IgCj1v1BFqy/wcndGMtZYbzauC9J8VZjo=; b=nRdHWUIjI9QEeyaXFE+CjgyyNi60LMbgnhoZfqyTAzvl1+Wt2JHCPI83xxjxG2IOcL dAG5DkT/Oim1F9449oZYXOG0sEmItZhpacbwpCDhnOoc4DZOULkRxc7tV24GSxFe0cO3 wiNHU+lFeteYL/61mee5ZD6/jV+EAeK+dEL8HMwNnT7llU6nDtL4hvXNQjtWW0J0YtrT VxapvUCGE078SYIZTgjgrL7Vyadoih5qsb9OUzkTmrjYVAwD7Dl9Sd6FOsh80KnzRe++ dR08O33700JRIFOASNSHhKaTYezqblN+S135yCa6yFMaJr4Igd568CnVCmWgFqI0QA4w 2yOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Zri0KNKQ; 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 u187si7358232itg.159.2017.08.28.01.58.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:47 -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 header.s=google header.b=Zri0KNKQ; 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 1dmFqe-0004n1-Aw; Mon, 28 Aug 2017 08:56: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 1dmFqc-0004lZ-Ce for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:42 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id B2/75-11743-9CAD3A95; Mon, 28 Aug 2017 08:56:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsVyMfTAKt2TtxZ HGiw6x2zxfctkJgdGj8MfrrAEMEaxZuYl5VcksGZMmtbIVLA6uWL+zr1sDYxnPboYuTiEBGYy SjzZ9p0FxGERmMcsMWn/diYQR0Kgn1Wi6cEH1i5GTiAnTeLasR1QdqnErLu32UBsIQEtiaOnZ rNCjNrPJLHm4B2gbg4ONgETiVkdEiA1IgJKEvdWTWYCsZkFnjNJTLukA2ILC4RIdDedZAaxWQ RUJR4vPcQO0sor4C2xaI8uxCo5iZvnOsFKOAV8JHasvcsOsdZbouv1B9YJjAILGBlWMaoXpxa VpRbpmuolFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgSGFQMQ7GCcftn/EKMkB5OS KO/OisWRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4Q24C5QSLUtNTK9Iyc4ABDpOW4OBREuH9c QMozVtckJhbnJkOkTrFaMxx5cq6L0wcUw5s/8IkxJKXn5cqJc7rAzJJAKQ0ozQPbhAs8i4xyk oJ8zICnSbEU5BalJtZgir/ilGcg1FJmPcgyBSezLwSuH2vgE5hAjpFUXAhyCkliQgpqQbGQ18 ybu27HKu5RyZ957xfSU3R771NTG0sG8S2fjqfm3wsuGCenoggy7W4dZUtV1eXtL9Ic+qqcFSa WNE+Z3We2NYn9qpaOTt1nj73uTO/bZu5XxYTp+qC52c9A/cabRIzntHFuSrgTtLHZ9cZA1dNP iG/NcfZ7J3q/MWBdb6Mfwrvf0t22L5ViaU4I9FQi7moOBEAmQRbH7cCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-27.messagelabs.com!1503910599!81934732!1 X-Originating-IP: [209.85.192.170] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54458 invoked from network); 28 Aug 2017 08:56:40 -0000 Received: from mail-pf0-f170.google.com (HELO mail-pf0-f170.google.com) (209.85.192.170) by server-11.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:40 -0000 Received: by mail-pf0-f170.google.com with SMTP id r62so14493251pfj.0 for ; Mon, 28 Aug 2017 01:56:40 -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=j/K28gpSttebxQEDQg6Y/f68NojfzcXlR+upHykF660=; b=Zri0KNKQeft0x1/nhefxdXbhacUzK525QDqtG1D96yvdrYn2qZXQwQ5PyOVrpFTQig HmiwORpfXIai5Q2Ar7o78eyaDSUWJ1QfvVM2WrahlOdVrQA453CzCMQqp1E7j1KrUYNU b5WwKIuRhPghmqBAYLaGZZ+/S/dRsaWeN1ps0= 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=j/K28gpSttebxQEDQg6Y/f68NojfzcXlR+upHykF660=; b=WcaJOLfEXrKXG/z3F2XRGmuifnzMwBAcFYHv/WpMH9733NuWIiKnTwuWNWq6+bR0W0 NEOujvkRsZqWhpI8I/hxsRnUHQfIgDgcpBkbSxcmm9deJUYhUqorHy2nNQmsvxQl1loN BCVnE3OIl3i8Llxz4bW2GUhLGF4wdgFBLePHFoLO5oPTjyrtEkmGW0r8SHeejyP2CU/D +aGlq8eEaRMPrAd/BFepnsRkdLT4pllRl72sB+4CgzGaM1CapnYvpGRWXqBq2vARGiJg 2IZxF8xXPyvzlNBC+69+QG4+Ibq2DEvOIrGc4K9T+SH50g1+dYJJvLRbPrlJk6EtS8XC qGzQ== X-Gm-Message-State: AHYfb5hkKGlsmna/KGommiC+O3F8LMroGIZ0ne3WfXyGBcBKPkig6iLJ /4lT4BFSizGj5VyBR+7Eiw== X-Received: by 10.99.3.22 with SMTP id 22mr4491915pgd.99.1503910599018; Mon, 28 Aug 2017 01:56:39 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:38 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:49 +0530 Message-Id: <1503910570-24427-7-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 06/27 v8] xen/arm: vpl011: Add a new domctl API to 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 a new domctl API to 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 the guest domain's behalf. Signed-off-by: Bhupinder Thakur --- CC: Ian Jackson CC: Wei Liu CC: Andrew Cooper CC: George Dunlap CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Julien Grall Changes since v6: - Renamed the vuart initialization function to a generic name xc_dom_vuart_init - Used domid_t as a type instead of uint32_t for domid - Checking the vuart type explicitly against vpl011 enum value Changes since v5: - xc_dom_vpl011_init() will be compiled for both x86/arm architectures as there is nothing architecture specific in this function. This function will return error when called for x86. - Fixed coding style issues in libxl. Changes since v4: - Removed libxl__arch_domain_create_finish(). - Added a new function libxl__arch_build_dom_finish(), which is called at the last in libxl__build_dom(). This function calls the vpl011 initialization function now. Changes since v3: - Added a new arch specific function libxl__arch_domain_create_finish(), which calls the vpl011 initialization function. For x86 this function does not do anything. - domain_vpl011_init() takes a pointer to a structure which contains all the required information such as console_domid, gfn instead of passing parameters separately. - Dropped a DOMCTL API defined for de-initializing vpl011 as that should be taken care when the domain is destroyed (and not dependent on userspace libraries/applications). 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 | 20 +++++++++++++++++++ tools/libxc/xc_domain.c | 25 +++++++++++++++++++++++ tools/libxl/libxl_arch.h | 7 +++++++ tools/libxl/libxl_arm.c | 22 +++++++++++++++++++++ tools/libxl/libxl_dom.c | 4 ++++ tools/libxl/libxl_x86.c | 8 ++++++++ xen/arch/arm/domain.c | 6 ++++++ xen/arch/arm/domctl.c | 46 +++++++++++++++++++++++++++++++++++++++++++ xen/include/public/domctl.h | 21 ++++++++++++++++++++ 9 files changed, 159 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index c7710b8..35bbb3b 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -886,6 +886,26 @@ int xc_vcpu_getcontext(xc_interface *xch, vcpu_guest_context_any_t *ctxt); /** + * This function initializes the vuart 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 type type of vuart + * @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_vuart_init(xc_interface *xch, + uint32_t type, + domid_t domid, + domid_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *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 3bab4e8..d2d5111 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -343,6 +343,31 @@ int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid, return 0; } +int xc_dom_vuart_init(xc_interface *xch, + uint32_t type, + domid_t domid, + domid_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; + domctl.u.vuart_op.cmd = XEN_DOMCTL_VUART_OP_INIT; + domctl.u.vuart_op.type = type; + 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_domain_getinfo(xc_interface *xch, uint32_t first_domid, unsigned int max_doms, diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h index 5e1fc60..784ec7f 100644 --- a/tools/libxl/libxl_arch.h +++ b/tools/libxl/libxl_arch.h @@ -44,6 +44,13 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, libxl_domain_build_info *info, struct xc_dom_image *dom); +/* perform any pending hardware initialization */ +_hidden +int libxl__arch_build_dom_finish(libxl__gc *gc, + libxl_domain_build_info *info, + struct xc_dom_image *dom, + libxl__domain_build_state *state); + /* build vNUMA vmemrange with arch specific information */ _hidden int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc, diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..b8147f0 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1038,6 +1038,28 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, return 0; } +int libxl__arch_build_dom_finish(libxl__gc *gc, + libxl_domain_build_info *info, + struct xc_dom_image *dom, + libxl__domain_build_state *state) +{ + int rc = 0; + + if (info->arch_arm.vuart != LIBXL_VUART_TYPE_SBSA_UART) + return rc; + + rc = xc_dom_vuart_init(CTX->xch, + XEN_DOMCTL_VUART_TYPE_VPL011, + dom->guest_domid, + dom->console_domid, + dom->vuart_gfn, + &state->vuart_port); + if (rc < 0) + LOG(ERROR, "xc_dom_vuart_init failed\n"); + + return rc; +} + int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc, uint32_t domid, libxl_domain_build_info *info, diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index e0f0d78..5f92023 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -702,6 +702,10 @@ static int libxl__build_dom(libxl__gc *gc, uint32_t domid, LOGE(ERROR, "xc_dom_gnttab_init failed"); goto out; } + if ((ret = libxl__arch_build_dom_finish(gc, info, dom, state)) != 0) { + LOGE(ERROR, "libxl__arch_build_dom_finish failed"); + goto out; + } out: return ret != 0 ? ERROR_FAIL : 0; diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c index 455f6f0..0aaeded 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -391,6 +391,14 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, return rc; } +int libxl__arch_build_dom_finish(libxl__gc *gc, + libxl_domain_build_info *info, + struct xc_dom_image *dom, + libxl__domain_build_state *state) +{ + return 0; +} + /* Return 0 on success, ERROR_* on failure. */ int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc, uint32_t domid, diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index eeebbdb..85accdf 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -857,6 +857,12 @@ int domain_relinquish_resources(struct domain *d) if ( ret ) return ret; + /* + * Release the resources allocated for vpl011 which were + * allocated via a DOMCTL call XEN_DOMCTL_vuart_op. + */ + domain_vpl011_deinit(d); + d->arch.relmem = RELMEM_xen; /* Fallthrough */ diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index db6838d..ea91731 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -5,9 +5,11 @@ */ #include +#include #include #include #include +#include #include #include #include @@ -20,6 +22,29 @@ void arch_get_domain_info(const struct domain *d, info->flags |= XEN_DOMINF_hap; } +static int handle_vuart_init(struct domain *d, + struct xen_domctl_vuart_op *vuart_op) +{ + int rc; + struct vpl011_init_info info; + + info.console_domid = vuart_op->console_domid; + info.gfn = _gfn(vuart_op->gfn); + + if ( d->creation_finished ) + return -EPERM; + + if ( vuart_op->type != XEN_DOMCTL_VUART_TYPE_VPL011 ) + return -EOPNOTSUPP; + + rc = domain_vpl011_init(d, &info); + + if ( !rc ) + vuart_op->evtchn = info.evtchn; + + return rc; +} + long arch_do_domctl(struct xen_domctl *domctl, struct domain *d, XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) { @@ -119,6 +144,27 @@ 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: + rc = handle_vuart_init(d, vuart_op); + break; + + default: + rc = -EINVAL; + break; + } + + if ( !rc ) + rc = __copy_to_guest(u_domctl, domctl, 1); + + return rc; + } default: { int rc; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 0669c31..ed2ea80 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 0x0000000e @@ -1148,6 +1149,24 @@ 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 0 + uint32_t cmd; /* XEN_DOMCTL_VUART_OP_* */ +#define XEN_DOMCTL_VUART_TYPE_VPL011 0 + uint32_t type; /* IN - type of vuart. + * Currently only vpl011 supported. + */ + uint64_aligned_t gfn; /* IN - guest gfn to be used as a + * ring buffer. + */ + evtchn_port_t evtchn; /* OUT - remote port of the event + * channel used for sending + * ring buffer events. + */ + domid_t console_domid; /* IN */ +}; + typedef struct xen_domctl_psr_cat_op xen_domctl_psr_cat_op_t; DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cat_op_t); @@ -1228,6 +1247,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 @@ -1290,6 +1310,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; }; From patchwork Mon Aug 28 08:55:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111114 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548072qge; Mon, 28 Aug 2017 01:58:51 -0700 (PDT) X-Received: by 10.107.59.80 with SMTP id i77mr5000709ioa.288.1503910731645; Mon, 28 Aug 2017 01:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910731; cv=none; d=google.com; s=arc-20160816; b=zOlptJrVTSjV16O++r+knFBAEI+dpp/WGZ9J1LTlJB3+WmUFYCFoqXqwk2D8uBumBB t1Tq/ATI5okprROxeuCHQXSPk4pc1VU1lSrY/PQmriDAE6FknpDj0kOvIPwj24y4aE4I y9UkT9nGlyLGerJ/nfDhUH1Un0sa+nqnPTfK/mUEGYmHlDTEa9H5E8lF0BhuW8RR6nr2 xmAufdwnHdCWNiSt6sZNQtu4jnIfxiFDV1TE1GJ6Pp6rU+4ar7KH3gTO3xgVXYB1bqJO LPHo9Y1PyL8vMKN8Km/t3jKBPGiAV8ABeSE6Avx+8T7/ZxMmYA6KDxjxxcQVRIBNB3wR MBDA== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=T1W83F6O6Kc21Vb9shMnui2lDzQnYqH2DbtyX6bjXBg=; b=Ex9exFSWIu7XHXK1eZ0yMhfWR+WTbiUf5xtLOBI/EGSK3PDA0ngw2Vvti/q3iBenML 7stX/p20ZxJppEFjTiNpDo9bOFhwPE2fSKp5nUf6XmqXIwn9dOc02T+JGwsziipOQ3Zx zpoZB2LngPNk4nQHzcdfRA0RE4HBnxTwh7/9UN5pmc2K8KxND+UX+EFyNaYI3vonqV+u UK/K/WrW1c5m8QD8GUNPl55R1+hoMzH6NPQa8GuZoh1cfSrT9W1mhg57DOpwSjjseuwG Lfk4KZ0uaK4WgK8AUqzE+r+ONhUMo5lSTDUKC2ppUhrUu/bUzYvusixaT7pjherrvFIt z7UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ABPQEKON; 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 h17si12180088iod.181.2017.08.28.01.58.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:51 -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 header.s=google header.b=ABPQEKON; 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 1dmFqg-0004pD-NU; Mon, 28 Aug 2017 08:56:46 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqf-0004o2-8k for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:45 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 6F/82-03368-CCAD3A95; Mon, 28 Aug 2017 08:56:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIIsWRWlGSWpSXmKPExsXiVRusqXv61uJ Ig9fXzS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxl028yF3RYV9y5N4e9gXGNbhcjF4eQwHRG idV/Z7OBOCwC85glju15BuZICPSzSuyd1wnkcAI5aRKr3q9ggbArJDZ/+soIYgsJaEkcPTWbF WLUfiaJG99ambsYOTjYBEwkZnVIgNSICChJ3Fs1mQmkhllgPqNE06ResKHCAv4STa1bWUFsFg FViZ0HD7OD2LwC3hJrl/9khlgmJ3HzXCeYzSngI7Fj7V12iMXeEl2vP7BOYBRYwMiwilGjOLW oLLVI19BYL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMLgYgGAH45dlAYcYJTmY lER5d1YsjhTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwXvmJlBOsCg1PbUiLTMHGOYwaQkOHiUR3 g8gad7igsTc4sx0iNQpRl2OSQe2f2ESYsnLz0uVEuf1ASkSACnKKM2DGwGLuUuMslLCvIxARw nxFKQW5WaWoMq/YhTnYFQS5j0IMoUnM68EbtMroCOYgI5QFFwIckRJIkJKqoEx7NnPzQeuxDh 8kLkqaPEk8um3gsVTbr5uqkni9JE5nJ5+L/ro7n7xD/ePWWgdXHpOKHCqz0eR4yWOShN4rgb9 TFn/7B37hOXPhF9PEH/i8qKLx6ytZp9+4csH/gubRfvO5D2Y37DC72Tnk2ennwZteyf0eefFs JPV+w3Z896caQ51EHl5Xi04XomlOCPRUIu5qDgRALI+YKq0AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-21.messagelabs.com!1503910602!73233126!1 X-Originating-IP: [74.125.83.41] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38182 invoked from network); 28 Aug 2017 08:56:43 -0000 Received: from mail-pg0-f41.google.com (HELO mail-pg0-f41.google.com) (74.125.83.41) by server-10.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:43 -0000 Received: by mail-pg0-f41.google.com with SMTP id 63so22239321pgc.2 for ; Mon, 28 Aug 2017 01:56:43 -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=u7iNqMhDSt45oYpw7rX/c6FW4ApFInM/Yj9vI6RxQMI=; b=ABPQEKONDAtCJDhTrmIlSGjziiKEfV4arwTHqlgQezKoNgVW95wIk8ZoUWxyJ/GhID FI8a9mYaYrxMjgv6/5fACBJiwYyDHATTEdTcCxcTRRuUayJViM7Uwy5DyXEUYht4MX+4 bq33PAnNZXEh5DgO+bC45EjPKsn8ZN+afEYd8= 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=u7iNqMhDSt45oYpw7rX/c6FW4ApFInM/Yj9vI6RxQMI=; b=fcVbubSP+oNe5LJQuumOWj+g+PTAarq939+Bsi7JLMRxx6sWqgDmHggl8Y8npQ2mVb lm5b5fCNSiqaYV/buEYR6uWX1dneErmutfSl5RZD104jXNd8cuzgsdUvtl53fS3kOq9O SClytpfHJNOxPWqOkGsNwylUaDOa4yh1ikJaxuayI0/hqJdncHRgD1TpRT6dXbCcLvEY ZvREYNcEM/uF+2QFbZkODTlfqU81PP+ia+hgj3m+CTbMxyKtNGiMxE7aa/khmunGSJNP rShr8slxXcRtbgRn04+VeGAO4eswnf11y1cb8BBROg/2CCjdbBqtypKgKykjfT64GvSh Ppxw== X-Gm-Message-State: AHYfb5iITPU70JDCYZzrae5V19Vp9tmnypHK/R73FASkK9X+5Ev/DLQO 6xVyU2uAbCPgsqgigAEhmA== X-Received: by 10.99.44.10 with SMTP id s10mr6653603pgs.116.1503910602015; Mon, 28 Aug 2017 01:56:42 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:41 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:50 +0530 Message-Id: <1503910570-24427-8-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 07/27 v8] xen/arm: vpl011: Add a new vuart node in the xenstore 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 a new vuart console node to xenstore. This node is added at /local/domain/$DOMID/vuart/0. The node contains information such as the ring-ref, event channel, buffer limit and type of console. Xenconsole reads the node information to setup the ring buffer and event channel for sending/receiving vuart data. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - vuart_device moved inside libxl__device_vuart_add() as a local variable. Changes since v3: - Added a backend node for vpl011. - Removed libxl__device_vuart_add() for HVM guest. It is called only for PV guest. tools/libxl/libxl_console.c | 44 ++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_create.c | 9 +++++++- tools/libxl/libxl_device.c | 9 ++++++-- tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_types_internal.idl | 1 + 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 853be15..cdaf7fd 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -344,6 +344,50 @@ out: return rc; } +int libxl__device_vuart_add(libxl__gc *gc, uint32_t domid, + libxl__device_console *console, + libxl__domain_build_state *state) +{ + libxl__device device; + flexarray_t *ro_front; + flexarray_t *back; + int rc; + + ro_front = flexarray_make(gc, 16, 1); + back = flexarray_make(gc, 16, 1); + + device.backend_devid = console->devid; + device.backend_domid = console->backend_domid; + device.backend_kind = LIBXL__DEVICE_KIND_VUART; + device.devid = console->devid; + device.domid = domid; + device.kind = LIBXL__DEVICE_KIND_VUART; + + flexarray_append(back, "frontend-id"); + flexarray_append(back, GCSPRINTF("%d", domid)); + flexarray_append(back, "online"); + flexarray_append(back, "1"); + flexarray_append(back, "state"); + flexarray_append(back, GCSPRINTF("%d", XenbusStateInitialising)); + flexarray_append(back, "protocol"); + flexarray_append(back, LIBXL_XENCONSOLE_PROTOCOL); + + flexarray_append(ro_front, "port"); + flexarray_append(ro_front, GCSPRINTF("%"PRIu32, state->vuart_port)); + flexarray_append(ro_front, "ring-ref"); + flexarray_append(ro_front, GCSPRINTF("%lu", state->vuart_gfn)); + flexarray_append(ro_front, "limit"); + flexarray_append(ro_front, GCSPRINTF("%d", LIBXL_XENCONSOLE_LIMIT)); + flexarray_append(ro_front, "type"); + flexarray_append(ro_front, "xenconsoled"); + + rc = libxl__device_generic_add(gc, XBT_NULL, &device, + libxl__xs_kvs_of_flexarray(gc, back), + NULL, + libxl__xs_kvs_of_flexarray(gc, ro_front)); + return rc; +} + int libxl__init_console_from_channel(libxl__gc *gc, libxl__device_console *console, int dev_num, diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 1158303..6c3acb3 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1367,7 +1367,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, } case LIBXL_DOMAIN_TYPE_PV: { - libxl__device_console console; + libxl__device_console console, vuart; libxl__device device; for (i = 0; i < d_config->num_vfbs; i++) { @@ -1375,6 +1375,13 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, libxl__device_vkb_add(gc, domid, &d_config->vkbs[i]); } + if (d_config->b_info.arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) { + init_console_info(gc, &vuart, 0); + vuart.backend_domid = state->console_domid; + libxl__device_vuart_add(gc, domid, &vuart, state); + libxl__device_console_dispose(&vuart); + } + init_console_info(gc, &console, 0); console.backend_domid = state->console_domid; libxl__device_console_add(gc, domid, &console, state, &device); diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 00356af..3b10c58 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -26,6 +26,9 @@ static char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device) if (device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0) return GCSPRINTF("%s/console", dom_path); + if (device->kind == LIBXL__DEVICE_KIND_VUART) + return GCSPRINTF("%s/vuart/%d", dom_path, device->devid); + return GCSPRINTF("%s/device/%s/%d", dom_path, libxl__device_kind_to_string(device->kind), device->devid); @@ -170,7 +173,8 @@ retry_transaction: * historically contained other information, such as the * vnc-port, which we don't want the guest fiddling with. */ - if (device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0) + if ((device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0) || + (device->kind == LIBXL__DEVICE_KIND_VUART)) xs_set_permissions(ctx->xsh, t, frontend_path, ro_frontend_perms, ARRAY_SIZE(ro_frontend_perms)); else @@ -800,7 +804,8 @@ void libxl__devices_destroy(libxl__egc *egc, libxl__devices_remove_state *drs) dev->domid = domid; dev->kind = kind; dev->devid = atoi(devs[j]); - if (dev->backend_kind == LIBXL__DEVICE_KIND_CONSOLE) { + if (dev->backend_kind == LIBXL__DEVICE_KIND_CONSOLE || + dev->backend_kind == LIBXL__DEVICE_KIND_VUART) { /* Currently console devices can be destroyed * synchronously by just removing xenstore entries, * this is what libxl__device_destroy does. diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 6b38453..3f7cff9 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1206,6 +1206,9 @@ _hidden int libxl__device_console_add(libxl__gc *gc, uint32_t domid, libxl__device_console *console, libxl__domain_build_state *state, libxl__device *device); +_hidden int libxl__device_vuart_add(libxl__gc *gc, uint32_t domid, + libxl__device_console *console, + libxl__domain_build_state *state); /* Returns 1 if device exists, 0 if not, ERROR_* (<0) on error. */ _hidden int libxl__device_exists(libxl__gc *gc, xs_transaction_t t, diff --git a/tools/libxl/libxl_types_internal.idl b/tools/libxl/libxl_types_internal.idl index 7dc4d0f..c463c33 100644 --- a/tools/libxl/libxl_types_internal.idl +++ b/tools/libxl/libxl_types_internal.idl @@ -26,6 +26,7 @@ libxl__device_kind = Enumeration("device_kind", [ (9, "VUSB"), (10, "QUSB"), (11, "9PFS"), + (12, "VUART"), ]) libxl__console_backend = Enumeration("console_backend", [ From patchwork Mon Aug 28 08:55:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111119 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548138qge; Mon, 28 Aug 2017 01:58:55 -0700 (PDT) X-Received: by 10.36.5.194 with SMTP id 185mr4067075itl.101.1503910735838; Mon, 28 Aug 2017 01:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910735; cv=none; d=google.com; s=arc-20160816; b=N8DZFP8ILqUTeou6eVesmKnK6+5+oXY1xiRmwQs+zQQ/BXNH8h3Jb6haQjGrYolcCd vFit3Y0DZlTOBShM0Jm3IMwLGcchyrkhd0oimssyfjoWpAV3ZIGusntenvAEhayhcKd+ qoi+IRvbvkEdS+KFE1GNzo9Vrjd/cAvXK63QOrvQolExTryh48Pxnml37VG7X0D9i7cg mJZVXWLoTQHJhFXkUdvfzsuhIE9P6VUdNVDZ4ePo3Qnk77ONl7CF1XdPiaH1+nlezyUB 4OXvEKtmqHM9CQgFAWY0xhuOY1Ig7p25IpCwlj+6aNy2fkk+o7Anreywpv02cJIv6kzy JXBw== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=lUHrSFtRcdxi7jno74yZPIn1tbfCDeIZZLckatWcVNg=; b=vkNsjkmpJWM4MHDNw5ERU799vYVhjOEAGyij7I6vuq0FBB6+heVqnJLoj/4m3SC22G uAiMhl682yZ00S9o4rH6UDm+k4xXgoQDSPAICtKQQW/iHthGNdXm8nnhM88plCNaiuMn /U7vCE59A2sItKFgdolX3YDVf7z2HgmArbgLi51IC1yQivu/T4uG2gRsA4Q0RiOtYsTT 1YevcpjWn0C81E1dAU/U1reTi3b4tUddvIRmGrElWVo3bD1a8h1fRzrDyA1QvR8fIPyL d4MaaX5IP78ddQdlek6wUcLciHztvdHJL58p1IEQSG9/QwixLFRGfHqPz3FJWYeMKotw JK+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iiRKm5GP; 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 e16si1643499iof.228.2017.08.28.01.58.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:55 -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 header.s=google header.b=iiRKm5GP; 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 1dmFqj-0004rT-Va; Mon, 28 Aug 2017 08:56:49 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqj-0004qZ-29 for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:49 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 60/9D-03557-0DAD3A95; Mon, 28 Aug 2017 08:56:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRWlGSWpSXmKPExsXiVRusrXv+1uJ Ig51HRCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ow/N2+wFCxazFhxbvVJ5gbGJS2MXYxcHEIC 0xkl/k7awwbisAjMY5aYs7qXtYuRk0NCoJ9V4s3Nagg7TeLgmodsEHalxJOvr5lAbCEBLYmjp 2azQkzazySxdtUn9i5GDg42AROJWR0SIDUiAkoS91ZNZgKpYRaYzyjRNKkXbJAw0NAVOy8yg9 gsAqoSc5+vBovzCnhLPOu7AbVMTuLmuU6wGk4BH4kda++yQyz2luh6/YF1AqPAAkaGVYwaxal FZalFusaGeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgeHFAAQ7GJsWBR5ilORg UhLl3VmxOFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBG/ITaCcYFFqempFWmYOMNBh0hIcPEoiv D9uAKV5iwsSc4sz0yFSpxiNOTasXv+FiWPSge1fmIRY8vLzUqXEeX1AJgmAlGaU5sENgkXgJU ZZKWFeRqDThHgKUotyM0tQ5V8xinMwKgnzeoNM4cnMK4Hb9wroFCagUxQFF4KcUpKIkJJqYPR eOeXLH8vGzyJRk388Sf708sPrc8zuoXOV9vysf3bdRzXUrzWS95D/yt+CC5f3K1vz/H+d6HbI qOX7h9pW1jlqC70sI8MF0mssPxpdUlsow/LouKac51Tdv+9XTFQ74f20Oc9h+WyHu0JTN4q88 pdU3ZV7XN31YOZbx/p+1t7QvV9faaW1WymxFGckGmoxFxUnAgDCIiMRuwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-27.messagelabs.com!1503910605!101313052!1 X-Originating-IP: [74.125.83.43] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63932 invoked from network); 28 Aug 2017 08:56:46 -0000 Received: from mail-pg0-f43.google.com (HELO mail-pg0-f43.google.com) (74.125.83.43) by server-14.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:46 -0000 Received: by mail-pg0-f43.google.com with SMTP id 83so22175040pgb.4 for ; Mon, 28 Aug 2017 01:56:46 -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=Ot1bQTJbL3uvWQMApMJcqouOKIP7MuaE+/N/bjqFU8k=; b=iiRKm5GPBriX2GgzWEpygB0amAcq2q4ELwQCvoh2Mv1CaQS5+3EBNVoeVjcsrzzrd7 EJR2OsDkcR9XNqSUKB0AA/0xxyFkPVjQ9OwiRzgxBkOPTclPWJnxGAOJEGQAhi7SC/Io iUykFjoAK9BR+Ir0V/MCu4WUnzXdGciDdQkEk= 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=Ot1bQTJbL3uvWQMApMJcqouOKIP7MuaE+/N/bjqFU8k=; b=DmWzG9CMfy5WFLii74UmZr6xHQlTbgo1rTEGE/EzOUbHBn0k/5c+7NwEWZZAjkoxnC cyRnJCMN3Jiy8Q04eEV7sNc+JXhit1v9tEK7GNxWNaaPUJXmMSIQTyG3XlwBwIzPe+r6 7HP6kI48b86rLFZPlG9bRCi5uYd/YZcRFMEuKrIwm57lBhfFVEC3sUAG2hokPDF0206c /YJ1+mp/M/Vv03I1lVgkestF76HzJDCGy2jvzcS3huEGkeLezLKTTQURuT+5aL+TaquF vcZTPw/c4PrgHfoaAd2Q/xu5gwae4efbhz2UNKUPYOVhh5xDw2czStmPLIHlyceIs3ri UZkQ== X-Gm-Message-State: AHYfb5jgYsn7E0q+2OoP7hC88/s3UxEIslhw69/0HS7Qp9STafwZyBAE LjPGZ8F+oykA3HSgyrMoUA== X-Received: by 10.99.67.194 with SMTP id q185mr6542852pga.77.1503910605104; Mon, 28 Aug 2017 01:56:45 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:44 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:51 +0530 Message-Id: <1503910570-24427-9-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 08/27 v8] xen/arm: vpl011: Modify xenconsole to define and use a new console structure 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" Xenconsole uses a domain structure which contains console specific fields. This patch defines a new console structure, which would be used by the xenconsole functions to perform console specific operations like reading/writing data from/to the console ring buffer or reading/writing data from/to console tty. This patch is in preparation to support multiple consoles to support vuart console. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Moved the following fields from the struct domain to struct console: ->xenevtchn_handle *xce_handle; ->int xce_pollfd_idx; ->int event_count; ->long long next_period; Changes since v3: - The changes in xenconsole have been split into four patches. This is the first patch which modifies the xenconsole to use a new console structure. Changes since v2: - Defined a new function console_create_ring() which sets up the ring buffer and event channel a new console. domain_create_ring() uses this function to setup a console. - This patch does not contain vuart specific changes, which would be introduced in the next patch. - Changes for keeping the PV log file name unchanged. Changes since v1: - Split the domain struture to a separate console structure - Modified the functions to operate on the console struture - Replaced repetitive per console code with generic code tools/console/daemon/io.c | 299 +++++++++++++++++++++++++--------------------- 1 file changed, 165 insertions(+), 134 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index e8033d2..30cd167 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -89,25 +89,30 @@ struct buffer { size_t max_capacity; }; -struct domain { - int domid; +struct console { int master_fd; int master_pollfd_idx; int slave_fd; int log_fd; - bool is_dead; - unsigned last_seen; struct buffer buffer; - struct domain *next; char *conspath; int ring_ref; - xenevtchn_port_or_error_t local_port; - xenevtchn_port_or_error_t remote_port; xenevtchn_handle *xce_handle; int xce_pollfd_idx; - struct xencons_interface *interface; int event_count; long long next_period; + xenevtchn_port_or_error_t local_port; + xenevtchn_port_or_error_t remote_port; + struct xencons_interface *interface; + struct domain *d; +}; + +struct domain { + int domid; + bool is_dead; + unsigned last_seen; + struct domain *next; + struct console console; }; static struct domain *dom_head; @@ -160,9 +165,10 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, static void buffer_append(struct domain *dom) { - struct buffer *buffer = &dom->buffer; + struct console *con = &dom->console; + struct buffer *buffer = &con->buffer; XENCONS_RING_IDX cons, prod, size; - struct xencons_interface *intf = dom->interface; + struct xencons_interface *intf = con->interface; cons = intf->out_cons; prod = intf->out_prod; @@ -187,22 +193,22 @@ static void buffer_append(struct domain *dom) xen_mb(); intf->out_cons = cons; - xenevtchn_notify(dom->xce_handle, dom->local_port); + xenevtchn_notify(con->xce_handle, con->local_port); /* Get the data to the logfile as early as possible because if * no one is listening on the console pty then it will fill up * and handle_tty_write will stop being called. */ - if (dom->log_fd != -1) { + if (con->log_fd != -1) { int logret; if (log_time_guest) { logret = write_with_timestamp( - dom->log_fd, + con->log_fd, buffer->data + buffer->size - size, size, &log_time_guest_needts); } else { logret = write_all( - dom->log_fd, + con->log_fd, buffer->data + buffer->size - size, size); } @@ -338,14 +344,16 @@ static int create_domain_log(struct domain *dom) static void domain_close_tty(struct domain *dom) { - if (dom->master_fd != -1) { - close(dom->master_fd); - dom->master_fd = -1; + struct console *con = &dom->console; + + if (con->master_fd != -1) { + close(con->master_fd); + con->master_fd = -1; } - if (dom->slave_fd != -1) { - close(dom->slave_fd); - dom->slave_fd = -1; + if (con->slave_fd != -1) { + close(con->slave_fd); + con->slave_fd = -1; } } @@ -418,11 +426,12 @@ static int domain_create_tty(struct domain *dom) char *data; unsigned int len; struct termios term; + struct console *con = &dom->console; - assert(dom->slave_fd == -1); - assert(dom->master_fd == -1); + assert(con->slave_fd == -1); + assert(con->master_fd == -1); - if (openpty(&dom->master_fd, &dom->slave_fd, NULL, NULL, NULL) < 0) { + if (openpty(&con->master_fd, &con->slave_fd, NULL, NULL, NULL) < 0) { err = errno; dolog(LOG_ERR, "Failed to create tty for domain-%d " "(errno = %i, %s)", @@ -430,7 +439,7 @@ static int domain_create_tty(struct domain *dom) return 0; } - if (tcgetattr(dom->slave_fd, &term) < 0) { + if (tcgetattr(con->slave_fd, &term) < 0) { err = errno; dolog(LOG_ERR, "Failed to get tty attributes for domain-%d " "(errno = %i, %s)", @@ -438,7 +447,7 @@ static int domain_create_tty(struct domain *dom) goto out; } cfmakeraw(&term); - if (tcsetattr(dom->slave_fd, TCSANOW, &term) < 0) { + if (tcsetattr(con->slave_fd, TCSANOW, &term) < 0) { err = errno; dolog(LOG_ERR, "Failed to set tty attributes for domain-%d " "(errno = %i, %s)", @@ -446,7 +455,7 @@ static int domain_create_tty(struct domain *dom) goto out; } - if ((slave = ptsname(dom->master_fd)) == NULL) { + if ((slave = ptsname(con->master_fd)) == NULL) { err = errno; dolog(LOG_ERR, "Failed to get slave name for domain-%d " "(errno = %i, %s)", @@ -454,18 +463,18 @@ static int domain_create_tty(struct domain *dom) goto out; } - success = asprintf(&path, "%s/limit", dom->conspath) != + success = asprintf(&path, "%s/limit", con->conspath) != -1; if (!success) goto out; data = xs_read(xs, XBT_NULL, path, &len); if (data) { - dom->buffer.max_capacity = strtoul(data, 0, 0); + con->buffer.max_capacity = strtoul(data, 0, 0); free(data); } free(path); - success = (asprintf(&path, "%s/tty", dom->conspath) != -1); + success = (asprintf(&path, "%s/tty", con->conspath) != -1); if (!success) goto out; success = xs_write(xs, XBT_NULL, path, slave, strlen(slave)); @@ -473,7 +482,7 @@ static int domain_create_tty(struct domain *dom) if (!success) goto out; - if (fcntl(dom->master_fd, F_SETFL, O_NONBLOCK) == -1) + if (fcntl(con->master_fd, F_SETFL, O_NONBLOCK) == -1) goto out; return 1; @@ -519,29 +528,32 @@ static int xs_gather(struct xs_handle *xs, const char *dir, ...) static void domain_unmap_interface(struct domain *dom) { - if (dom->interface == NULL) + struct console *con = &dom->console; + + if (con->interface == NULL) return; - if (xgt_handle && dom->ring_ref == -1) - xengnttab_unmap(xgt_handle, dom->interface, 1); + if (xgt_handle && con->ring_ref == -1) + xengnttab_unmap(xgt_handle, con->interface, 1); else - munmap(dom->interface, XC_PAGE_SIZE); - dom->interface = NULL; - dom->ring_ref = -1; + munmap(con->interface, XC_PAGE_SIZE); + con->interface = NULL; + con->ring_ref = -1; } static int domain_create_ring(struct domain *dom) { int err, remote_port, ring_ref, rc; char *type, path[PATH_MAX]; + struct console *con = &dom->console; - err = xs_gather(xs, dom->conspath, + err = xs_gather(xs, con->conspath, "ring-ref", "%u", &ring_ref, "port", "%i", &remote_port, NULL); if (err) goto out; - snprintf(path, sizeof(path), "%s/type", dom->conspath); + snprintf(path, sizeof(path), "%s/type", con->conspath); type = xs_read(xs, XBT_NULL, path, NULL); if (type && strcmp(type, "xenconsoled") != 0) { free(type); @@ -550,77 +562,77 @@ static int domain_create_ring(struct domain *dom) free(type); /* If using ring_ref and it has changed, remap */ - if (ring_ref != dom->ring_ref && dom->ring_ref != -1) + if (ring_ref != con->ring_ref && con->ring_ref != -1) domain_unmap_interface(dom); - if (!dom->interface && xgt_handle) { + if (!con->interface && xgt_handle) { /* Prefer using grant table */ - dom->interface = xengnttab_map_grant_ref(xgt_handle, + con->interface = xengnttab_map_grant_ref(xgt_handle, dom->domid, GNTTAB_RESERVED_CONSOLE, PROT_READ|PROT_WRITE); - dom->ring_ref = -1; + con->ring_ref = -1; } - if (!dom->interface) { + if (!con->interface) { /* Fall back to xc_map_foreign_range */ - dom->interface = xc_map_foreign_range( + con->interface = xc_map_foreign_range( xc, dom->domid, XC_PAGE_SIZE, PROT_READ|PROT_WRITE, (unsigned long)ring_ref); - if (dom->interface == NULL) { + if (con->interface == NULL) { err = EINVAL; goto out; } - dom->ring_ref = ring_ref; + con->ring_ref = ring_ref; } /* Go no further if port has not changed and we are still bound. */ - if (remote_port == dom->remote_port) { + if (remote_port == con->remote_port) { xc_evtchn_status_t status = { .dom = DOMID_SELF, - .port = dom->local_port }; + .port = con->local_port }; if ((xc_evtchn_status(xc, &status) == 0) && (status.status == EVTCHNSTAT_interdomain)) goto out; } - dom->local_port = -1; - dom->remote_port = -1; - if (dom->xce_handle != NULL) - xenevtchn_close(dom->xce_handle); + con->local_port = -1; + con->remote_port = -1; + if (con->xce_handle != NULL) + xenevtchn_close(con->xce_handle); /* Opening evtchn independently for each console is a bit * wasteful, but that's how the code is structured... */ - dom->xce_handle = xenevtchn_open(NULL, 0); - if (dom->xce_handle == NULL) { + con->xce_handle = xenevtchn_open(NULL, 0); + if (con->xce_handle == NULL) { err = errno; goto out; } - rc = xenevtchn_bind_interdomain(dom->xce_handle, + rc = xenevtchn_bind_interdomain(con->xce_handle, dom->domid, remote_port); if (rc == -1) { err = errno; - xenevtchn_close(dom->xce_handle); - dom->xce_handle = NULL; + xenevtchn_close(con->xce_handle); + con->xce_handle = NULL; goto out; } - dom->local_port = rc; - dom->remote_port = remote_port; + con->local_port = rc; + con->remote_port = remote_port; - if (dom->master_fd == -1) { + if (con->master_fd == -1) { if (!domain_create_tty(dom)) { err = errno; - xenevtchn_close(dom->xce_handle); - dom->xce_handle = NULL; - dom->local_port = -1; - dom->remote_port = -1; + xenevtchn_close(con->xce_handle); + con->xce_handle = NULL; + con->local_port = -1; + con->remote_port = -1; goto out; } } - if (log_guest && (dom->log_fd == -1)) - dom->log_fd = create_domain_log(dom); + if (log_guest && (con->log_fd == -1)) + con->log_fd = create_domain_log(dom); out: return err; @@ -630,16 +642,17 @@ static bool watch_domain(struct domain *dom, bool watch) { char domid_str[3 + MAX_STRLEN(dom->domid)]; bool success; + struct console *con = &dom->console; snprintf(domid_str, sizeof(domid_str), "dom%u", dom->domid); if (watch) { - success = xs_watch(xs, dom->conspath, domid_str); + success = xs_watch(xs, con->conspath, domid_str); if (success) domain_create_ring(dom); else - xs_unwatch(xs, dom->conspath, domid_str); + xs_unwatch(xs, con->conspath, domid_str); } else { - success = xs_unwatch(xs, dom->conspath, domid_str); + success = xs_unwatch(xs, con->conspath, domid_str); } return success; @@ -651,6 +664,7 @@ static struct domain *create_domain(int domid) struct domain *dom; char *s; struct timespec ts; + struct console *con; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d", @@ -667,25 +681,26 @@ static struct domain *create_domain(int domid) dom->domid = domid; - dom->conspath = xs_get_domain_path(xs, dom->domid); - s = realloc(dom->conspath, strlen(dom->conspath) + + con = &dom->console; + con->conspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->conspath, strlen(con->conspath) + strlen("/console") + 1); if (s == NULL) goto out; - dom->conspath = s; - strcat(dom->conspath, "/console"); + con->conspath = s; + strcat(con->conspath, "/console"); - dom->master_fd = -1; - dom->master_pollfd_idx = -1; - dom->slave_fd = -1; - dom->log_fd = -1; - dom->xce_pollfd_idx = -1; + con->master_fd = -1; + con->master_pollfd_idx = -1; + con->slave_fd = -1; + con->log_fd = -1; + con->xce_pollfd_idx = -1; - dom->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; + con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; - dom->ring_ref = -1; - dom->local_port = -1; - dom->remote_port = -1; + con->ring_ref = -1; + con->local_port = -1; + con->remote_port = -1; if (!watch_domain(dom, true)) goto out; @@ -697,7 +712,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(dom->conspath); + free(con->conspath); free(dom); return NULL; } @@ -729,30 +744,34 @@ static void remove_domain(struct domain *dom) static void cleanup_domain(struct domain *d) { + struct console *con = &d->console; + domain_close_tty(d); - if (d->log_fd != -1) { - close(d->log_fd); - d->log_fd = -1; + if (con->log_fd != -1) { + close(con->log_fd); + con->log_fd = -1; } - free(d->buffer.data); - d->buffer.data = NULL; + free(con->buffer.data); + con->buffer.data = NULL; - free(d->conspath); - d->conspath = NULL; + free(con->conspath); + con->conspath = NULL; remove_domain(d); } static void shutdown_domain(struct domain *d) { + struct console *con = &d->console; + d->is_dead = true; watch_domain(d, false); domain_unmap_interface(d); - if (d->xce_handle != NULL) - xenevtchn_close(d->xce_handle); - d->xce_handle = NULL; + if (con->xce_handle != NULL) + xenevtchn_close(con->xce_handle); + con->xce_handle = NULL; } static unsigned enum_pass = 0; @@ -782,7 +801,8 @@ static void enum_domains(void) static int ring_free_bytes(struct domain *dom) { - struct xencons_interface *intf = dom->interface; + struct console *con = &dom->console; + struct xencons_interface *intf = con->interface; XENCONS_RING_IDX cons, prod, space; cons = intf->in_cons; @@ -812,7 +832,8 @@ static void handle_tty_read(struct domain *dom) ssize_t len = 0; char msg[80]; int i; - struct xencons_interface *intf = dom->interface; + struct console *con = &dom->console; + struct xencons_interface *intf = con->interface; XENCONS_RING_IDX prod; if (dom->is_dead) @@ -825,7 +846,7 @@ static void handle_tty_read(struct domain *dom) if (len > sizeof(msg)) len = sizeof(msg); - len = read(dom->master_fd, msg, len); + len = read(con->master_fd, msg, len); /* * Note: on Solaris, len == 0 means the slave closed, and this * is no problem, but Linux can't handle this usefully, so we @@ -841,7 +862,7 @@ static void handle_tty_read(struct domain *dom) } xen_wmb(); intf->in_prod = prod; - xenevtchn_notify(dom->xce_handle, dom->local_port); + xenevtchn_notify(con->xce_handle, con->local_port); } else { domain_close_tty(dom); shutdown_domain(dom); @@ -851,37 +872,39 @@ static void handle_tty_read(struct domain *dom) static void handle_tty_write(struct domain *dom) { ssize_t len; + struct console *con = &dom->console; if (dom->is_dead) return; - len = write(dom->master_fd, dom->buffer.data + dom->buffer.consumed, - dom->buffer.size - dom->buffer.consumed); + len = write(con->master_fd, con->buffer.data + con->buffer.consumed, + con->buffer.size - con->buffer.consumed); if (len < 1) { dolog(LOG_DEBUG, "Write failed on domain %d: %zd, %d\n", dom->domid, len, errno); domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); } else { - buffer_advance(&dom->buffer, len); + buffer_advance(&con->buffer, len); } } static void handle_ring_read(struct domain *dom) { xenevtchn_port_or_error_t port; + struct console *con = &dom->console; if (dom->is_dead) return; - if ((port = xenevtchn_pending(dom->xce_handle)) == -1) + if ((port = xenevtchn_pending(con->xce_handle)) == -1) return; - dom->event_count++; + con->event_count++; buffer_append(dom); - if (dom->event_count < RATE_LIMIT_ALLOWANCE) - (void)xenevtchn_unmask(dom->xce_handle, port); + if (con->event_count < RATE_LIMIT_ALLOWANCE) + (void)xenevtchn_unmask(con->xce_handle, port); } static void handle_xs(void) @@ -948,9 +971,11 @@ static void handle_log_reload(void) if (log_guest) { struct domain *d; for (d = dom_head; d; d = d->next) { - if (d->log_fd != -1) - close(d->log_fd); - d->log_fd = create_domain_log(d); + struct console *con = &d->console; + + if (con->log_fd != -1) + close(con->log_fd); + con->log_fd = create_domain_log(d); } } @@ -1059,48 +1084,52 @@ void handle_io(void) /* Re-calculate any event counter allowances & unblock domains with new allowance */ for (d = dom_head; d; d = d->next) { + struct console *con = &d->console; + /* CS 16257:955ee4fa1345 introduces a 5ms fuzz * for select(), it is not clear poll() has * similar behavior (returning a couple of ms * sooner than requested) as well. Just leave * the fuzz here. Remove it with a separate * patch if necessary */ - if ((now+5) > d->next_period) { - d->next_period = now + RATE_LIMIT_PERIOD; - if (d->event_count >= RATE_LIMIT_ALLOWANCE) { - (void)xenevtchn_unmask(d->xce_handle, d->local_port); + if ((now+5) > con->next_period) { + con->next_period = now + RATE_LIMIT_PERIOD; + if (con->event_count >= RATE_LIMIT_ALLOWANCE) { + (void)xenevtchn_unmask(con->xce_handle, con->local_port); } - d->event_count = 0; + con->event_count = 0; } } for (d = dom_head; d; d = d->next) { - if (d->event_count >= RATE_LIMIT_ALLOWANCE) { + struct console *con = &d->console; + + if (con->event_count >= RATE_LIMIT_ALLOWANCE) { /* Determine if we're going to be the next time slice to expire */ if (!next_timeout || - d->next_period < next_timeout) - next_timeout = d->next_period; - } else if (d->xce_handle != NULL) { + con->next_period < next_timeout) + next_timeout = con->next_period; + } else if (con->xce_handle != NULL) { if (discard_overflowed_data || - !d->buffer.max_capacity || - d->buffer.size < d->buffer.max_capacity) { - int evtchn_fd = xenevtchn_fd(d->xce_handle); - d->xce_pollfd_idx = set_fds(evtchn_fd, + !con->buffer.max_capacity || + con->buffer.size < con->buffer.max_capacity) { + int evtchn_fd = xenevtchn_fd(con->xce_handle); + con->xce_pollfd_idx = set_fds(evtchn_fd, POLLIN|POLLPRI); } } - if (d->master_fd != -1) { + if (con->master_fd != -1) { short events = 0; if (!d->is_dead && ring_free_bytes(d)) events |= POLLIN; - if (!buffer_empty(&d->buffer)) + if (!buffer_empty(&con->buffer)) events |= POLLOUT; if (events) - d->master_pollfd_idx = - set_fds(d->master_fd, + con->master_pollfd_idx = + set_fds(con->master_fd, events|POLLPRI); } } @@ -1163,33 +1192,35 @@ void handle_io(void) } for (d = dom_head; d; d = n) { + struct console *con = &d->console; + n = d->next; - if (d->event_count < RATE_LIMIT_ALLOWANCE) { - if (d->xce_handle != NULL && - d->xce_pollfd_idx != -1 && - !(fds[d->xce_pollfd_idx].revents & + if (con->event_count < RATE_LIMIT_ALLOWANCE) { + if (con->xce_handle != NULL && + con->xce_pollfd_idx != -1 && + !(fds[con->xce_pollfd_idx].revents & ~(POLLIN|POLLOUT|POLLPRI)) && - (fds[d->xce_pollfd_idx].revents & + (fds[con->xce_pollfd_idx].revents & POLLIN)) handle_ring_read(d); } - if (d->master_fd != -1 && d->master_pollfd_idx != -1) { - if (fds[d->master_pollfd_idx].revents & + if (con->master_fd != -1 && con->master_pollfd_idx != -1) { + if (fds[con->master_pollfd_idx].revents & ~(POLLIN|POLLOUT|POLLPRI)) domain_handle_broken_tty(d, domain_is_valid(d->domid)); else { - if (fds[d->master_pollfd_idx].revents & + if (fds[con->master_pollfd_idx].revents & POLLIN) handle_tty_read(d); - if (fds[d->master_pollfd_idx].revents & + if (fds[con->master_pollfd_idx].revents & POLLOUT) handle_tty_write(d); } } - d->xce_pollfd_idx = d->master_pollfd_idx = -1; + con->xce_pollfd_idx = con->master_pollfd_idx = -1; if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Mon Aug 28 08:55:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111120 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548158qge; Mon, 28 Aug 2017 01:58:57 -0700 (PDT) X-Received: by 10.36.254.67 with SMTP id w64mr5005699ith.20.1503910737067; Mon, 28 Aug 2017 01:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910737; cv=none; d=google.com; s=arc-20160816; b=RPLtih9ez5ExB+zQWqtJbfsJMDkmTBXndlNMzzDWpObIWl/t18ST0OnW3eiHD9cL5u DVuD7wucUMIHZmzHUOL/uP9pATyD9Stx88UfQZlFRsnQkjwJEK/hHh4UiyU2bmWxE/B+ D63HGqYpOtCSmuOTg4X4JylUzkxdtOUou0KLVmOI7MU4VLpC65tIAwlAtzsxvxaeRpos X/cxGIP8nfkTy0YLAYGR3jbunm8sk+AHZ2aULVPIO3AWmlpNzA1hQAxy1Ardnwe1R71v qx65dI9m2plkx5wPKHBhwulXAQyGYnQvU8n3A57HO7Ht7WgCEZgKs8DVUL4wf6Nn2qLx hhJg== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=VinFKbGW/N9iWYxDU/IUOtMObQz7BGGOyQ2kukHnANc=; b=A4pYg5hd50zGJvLPyqeyeZ2MKNnKC5rjybtIQnm7U37qzTWMdG7bdjfFyR2w/k1quS 3K0vbwfYmb+O9my4V1zqDl6PO9uFelCtBYYgIrmeU23OPrRODk5CvqHy+USE+Ufu82pE D6g4Asvaop7RZpdl/O/CN1fMf1wDE6dBpWCjETCYipRbk1Wd0/wEgnePmrWo3klPYvyt X0J8bXnLF46olewfPiO43e5FeA1XBoDn/QZz3Si5+4cOIcEZzkrZvszq84nOVqC0KfJy l2sOVX/DT4KEYlfLnt3lrMu6olGPez+uKEsprTpA5AA3C2MUDMoDG2UCKhiIj9rkRHGt p0eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Qqh0BxLW; 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 z69si7460092ita.97.2017.08.28.01.58.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:57 -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 header.s=google header.b=Qqh0BxLW; 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 1dmFqn-0004uV-9q; Mon, 28 Aug 2017 08:56:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFql-0004sx-JJ for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:51 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id BF/1B-03044-2DAD3A95; Mon, 28 Aug 2017 08:56:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsVyMfTAZt2LtxZ HGmycZ2XxfctkJgdGj8MfrrAEMEaxZuYl5VcksGZceN3LXvBXumLDzf+sDYz7xbsYuTiEBGYy Srzee44RxGERmMcs0XvgLDuIIyHQzypx5/VjoAwnkJMmsWJLExuEXS0xufcEK4gtJKAlcfTUb FaIUfuZJDZ3v2HqYuTgYBMwkZjVIQFSIyKgJHFv1WQmkBpmgfmMEk2TesEGCQskSDy6d5wdxG YRUJVo7P/KDGLzCvhI7FqwC2qxnMTNc51gcU6g+I61d9khFntLdL3+wDqBUWABI8MqRo3i1KK y1CJdIwO9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYzA4GIAgh2Mv5YFHGKU5GBS EuXdWbE4UogvKT+lMiOxOCO+qDQntfgQowwHh5IEb8hNoJxgUWp6akVaZg4wzGHSEhw8SiK8H 0DSvMUFibnFmekQqVOMxhxXrqz7wsQx5cD2L0xCLHn5ealS4rw+IKUCIKUZpXlwg2Dxd4lRVk qYlxHoNCGegtSi3MwSVPlXjOIcjErCvAdBpvBk5pXA7XsFdAoT0CmKggtBTilJREhJNTAePDi hn32X+cQaYIjEGvXM7bHk6Z6+TF/4bdhDibCEw18qV7C/FnReo5dpaa1zfm4dn7mEy/eipr8z C9en6WSKKqt/5tP7vvCI6do9llWV7DuCw8VUktTOiVx86xUzS6Cx8qpZy6+ef0lCUzqsTVX0z q1onvkm4H/gxtsvd1pHLf61X/SwjhJLcUaioRZzUXEiADU4Fgq6AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1503910608!104229544!1 X-Originating-IP: [209.85.192.179] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22400 invoked from network); 28 Aug 2017 08:56:49 -0000 Received: from mail-pf0-f179.google.com (HELO mail-pf0-f179.google.com) (209.85.192.179) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:49 -0000 Received: by mail-pf0-f179.google.com with SMTP id r62so14494442pfj.0 for ; Mon, 28 Aug 2017 01:56:49 -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=AGHJrnwneXKl3Z1bjGKh+k5Ixw7YK+0ghFT9u/p0sak=; b=Qqh0BxLWbmRNUJxMBwhWdAGZLxwxBmsyc9/WRp3+Y3z/rXPwEQ+mUkq1zCtkm9ezZw xlFJhLDY973ERJlHAbPwK9OauKmmuaNmhszpxWyEgsmq/UJjIbX47YTzPCYKGq10x1eN Zl28pbcL2xvw0aooDYhEOgvF53Bj/1Jb1AO1M= 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=AGHJrnwneXKl3Z1bjGKh+k5Ixw7YK+0ghFT9u/p0sak=; b=AqvHeDMkeyPd9CpJSDRTUGDd8bkqF3Akq+ogl/nTyXIl2yvTbZNutjq/5UwnRzv/ZP 2m4wniow4RRglWfI+vP6HqV3gDNkJaKCygKoUdvT98SadtCMFnOCs2i6brj5gVuwnqWT MsyLuoKppezcO5vDp3I4Lny1Mwvhyl/oE94+L7gXUvBy2wfKtaInQpsHGYxpXzjIuAJ9 WWMrlDfcN2ekJPdS48AVhG13jiyPvy38waqg1pUFDgqOV75bN3uzNrnG5AtvV//1FXfX fbFtL7iYiLDtFVrLCac4PrR+RiNmJ7D69grPk+S/BngaA+TJfNSZD0Af4uWoUZKr6ov1 HPcQ== X-Gm-Message-State: AHYfb5hjAxT2DsXZqw3xwi7xFdeKi1+UNwmLrmYs3ajB8j8OC7Tq5tCz P+R/JhWkheTZRf6zgItQLw== X-Received: by 10.99.121.138 with SMTP id u132mr6919835pgc.424.1503910608233; Mon, 28 Aug 2017 01:56:48 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:47 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:52 +0530 Message-Id: <1503910570-24427-10-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 09/27 v8] xen/arm: vpl011: Rename the console structure field conspath to xspath 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" The console->conspath name is changed to console->xspath as it is clear from the name that it is referring to xenstore path. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Split this change in a separate patch. tools/console/daemon/io.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 30cd167..6f5c69c 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -95,7 +95,7 @@ struct console { int slave_fd; int log_fd; struct buffer buffer; - char *conspath; + char *xspath; int ring_ref; xenevtchn_handle *xce_handle; int xce_pollfd_idx; @@ -463,7 +463,7 @@ static int domain_create_tty(struct domain *dom) goto out; } - success = asprintf(&path, "%s/limit", con->conspath) != + success = asprintf(&path, "%s/limit", con->xspath) != -1; if (!success) goto out; @@ -474,7 +474,7 @@ static int domain_create_tty(struct domain *dom) } free(path); - success = (asprintf(&path, "%s/tty", con->conspath) != -1); + success = (asprintf(&path, "%s/tty", con->xspath) != -1); if (!success) goto out; success = xs_write(xs, XBT_NULL, path, slave, strlen(slave)); @@ -546,14 +546,14 @@ static int domain_create_ring(struct domain *dom) char *type, path[PATH_MAX]; struct console *con = &dom->console; - err = xs_gather(xs, con->conspath, + err = xs_gather(xs, con->xspath, "ring-ref", "%u", &ring_ref, "port", "%i", &remote_port, NULL); if (err) goto out; - snprintf(path, sizeof(path), "%s/type", con->conspath); + snprintf(path, sizeof(path), "%s/type", con->xspath); type = xs_read(xs, XBT_NULL, path, NULL); if (type && strcmp(type, "xenconsoled") != 0) { free(type); @@ -646,13 +646,13 @@ static bool watch_domain(struct domain *dom, bool watch) snprintf(domid_str, sizeof(domid_str), "dom%u", dom->domid); if (watch) { - success = xs_watch(xs, con->conspath, domid_str); + success = xs_watch(xs, con->xspath, domid_str); if (success) domain_create_ring(dom); else - xs_unwatch(xs, con->conspath, domid_str); + xs_unwatch(xs, con->xspath, domid_str); } else { - success = xs_unwatch(xs, con->conspath, domid_str); + success = xs_unwatch(xs, con->xspath, domid_str); } return success; @@ -682,13 +682,13 @@ static struct domain *create_domain(int domid) dom->domid = domid; con = &dom->console; - con->conspath = xs_get_domain_path(xs, dom->domid); - s = realloc(con->conspath, strlen(con->conspath) + + con->xspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->xspath, strlen(con->xspath) + strlen("/console") + 1); if (s == NULL) goto out; - con->conspath = s; - strcat(con->conspath, "/console"); + con->xspath = s; + strcat(con->xspath, "/console"); con->master_fd = -1; con->master_pollfd_idx = -1; @@ -712,7 +712,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->conspath); + free(con->xspath); free(dom); return NULL; } @@ -756,8 +756,8 @@ static void cleanup_domain(struct domain *d) free(con->buffer.data); con->buffer.data = NULL; - free(con->conspath); - con->conspath = NULL; + free(con->xspath); + con->xspath = NULL; remove_domain(d); } From patchwork Mon Aug 28 08:55:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111113 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548067qge; Mon, 28 Aug 2017 01:58:51 -0700 (PDT) X-Received: by 10.107.19.225 with SMTP id 94mr5833422iot.333.1503910731102; Mon, 28 Aug 2017 01:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910731; cv=none; d=google.com; s=arc-20160816; b=Hf1z1+Z5X8o+P++x+5O+lXjIT7pD0ImbAYptCo57eDJ1/Q7nKwMsJFyrfFTf4cQjFn UwlHGBsP7tq5vYidXiru/d8aCv2/450j+QvffYJOU1A3DxmhQhbVCo0eOeHVJRYF1sqe eJq4i8uXynzlx+lxUUf5QNt9py9zX+g/MapCO3hJkHHMdlGJotsiV0KV1DgEijfjyV0T MV3uv1m9MRhqPPx1NIx+rojHimAM2cH0Fm3TLvrocjBhI8ftpzBYllbByKOStubhNG3W wqzb5mxtXFKT46zfMCmoiceXmToY8Ke2d6M9N0BLPpydMQzlcdhG/JvN/khHGna/VohS rYvQ== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=WXsVKFtSEvooh/gQViJFmbABTRKBe0u52bhIWXyD934=; b=uV+BEA/zJB5mL8MUNgX/nuKl6zRojQLyQXbbfFq9zXnNnRNwu6FLHg0ZXglsqscS9a S5UpviiHmgAhk7svgkj0SDmfhoFNPjQuU/E0rEX5Kuxckg3dfSIMearaoz3hEAj4ydx7 a4hFR/T1Ak5MeCtO71IZgwIop/79yIun3RMinJZF6bSIuoy+5bZU0tdeOpRJfsmczmq0 PYlvRa2/MFkuKkGeXZbm0/0lmyY87tjJx5NJvZB1hDOFlvBBzrEJj4jbnllNT6NZEuKe RnzeBNAeRXwZVL79w3JycQUOVy9qG87zh6R9vDq4O/DzPTxcr2Y/xKNmkcmYn+Ung713 L7Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jDa95iia; 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 q133si12054371iod.171.2017.08.28.01.58.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:51 -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 header.s=google header.b=jDa95iia; 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 1dmFqq-0004xd-Gv; Mon, 28 Aug 2017 08:56:56 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqo-0004vf-KK for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:54 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 38/11-02962-6DAD3A95; Mon, 28 Aug 2017 08:56:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfTAWt2rtxZ HGsy+ImrxfctkJgdGj8MfrrAEMEaxZuYl5VcksGY0nDjLXPDWs6Lr0A7GBsa/Nl2MXBxCAjMZ Jb7OWckE4rAIzGOWWL3+OwuIIyHQzyqx7Pg59i5GDiAnTeLvGqEuRk4gs0pi2Z4zTCC2kICWx NFTs1khJu1nkph09TYjSD2bgInErA4JkBoRASWJe6smgy1gFpjPKNE0qZcNJCEskCmx7t8iRh CbRUBV4kTPNbChvAI+Eg9O/GeBWCYncfNcJzOIzQkU37H2LjvEYm+JrtcfWCcwCixgZFjFqF6 cWlSWWqRrppdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJERhYDECwg3HeCf9DjJIc TEqivDsrFkcK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuA9cxMoJ1iUmp5akZaZAwxxmLQEB4+SC O8HkDRvcUFibnFmOkTqFKMxx5Ur674wcUw5sP0LkxBLXn5eqpQ4rw9IqQBIaUZpHtwgWOxdYp SVEuZlBDpNiKcgtSg3swRV/hWjOAejkjDvX5ApPJl5JXD7XgGdwgR0iqLgQpBTShIRUlINjCZ twmuZr56Iu/NvCtu5/dxcE9ffXfqLxbyL6fa8dOuvtw0N92g8sbzNZ/zga4SCvPCV7dqhP+dm XPnF6lGgaR60pvfa/4S+xwcWZRlFP6rZckLv8KnnkqKa1/+5spxwmDO5ZXPZ/6pb079dXMtgG OlxMO6415uANfMFLnu8UU+/6/dlzWvPxf+UWIozEg21mIuKEwEdCI8suAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-27.messagelabs.com!1503910612!113454457!1 X-Originating-IP: [209.85.192.173] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62290 invoked from network); 28 Aug 2017 08:56:53 -0000 Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:53 -0000 Received: by mail-pf0-f173.google.com with SMTP id c15so14535943pfm.2 for ; Mon, 28 Aug 2017 01:56:52 -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=/c87JD9XyWkvHP2iWascyeQ5IUSzbfWQc11J8Ir9N+k=; b=jDa95iiadY/i2F+4wXD8dfq4Ei9JXg27kyruI54n+eo+1rfhNn8iOqiXl6wQkzYMSN k8qabMqvaH8nVNZdb1DdwU7qze5h6RtGkUZnmajlsZ2DedfWVxSfBsDLeo9JJe6tSTT4 HLJ4oXZKADQqieD817SVP5VZ1NcrVz3qzBOEQ= 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=/c87JD9XyWkvHP2iWascyeQ5IUSzbfWQc11J8Ir9N+k=; b=Vn5NW8I5r1nWeGz8RU3eOVTgjPlPspx+vOPWm0mXEnAXNWssnDJRj8xnbaVJEjKJtM HPHNo+9tcIpOLqMqqeMCvdt/mvuZMyZCgYr3eSDw0SNYAFoGlPH9+nG42JDsWZwQyDdD vj1rkJKY8Wv1WamhEEp4V70ywe8qjlvxN7jw+c84PT0gv3O0qF4PycgpNoIRd1ptlvd7 zNcS3n5unAXAsi1GhufSSVBHTFQ4OPupU6IAPWhYtYjqk3Pns4l9JBpiNxxm4vNRh784 Xta8tBpBnAbO8LklQ4mfxc/keAHUcrJwEicA+ty4gexxinffzd4tcSFh+QRL3rph9RGw acRg== X-Gm-Message-State: AHYfb5gG46/gfwuYu3kke2ORSTTHB+GjBBUf/wFsyw1NzaoweGnw2ZtE V2YjDq6u2NRrtek5lFl++Q== X-Received: by 10.99.96.205 with SMTP id u196mr6849341pgb.347.1503910611583; Mon, 28 Aug 2017 01:56:51 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:51 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:53 +0530 Message-Id: <1503910570-24427-11-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 10/27 v8] xen/arm: vpl011: Modify xenconsole functions to take console structure as input 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" Xenconsole functions take domain structure as input. These functions shall be modified to take console structure as input since these functions typically perform console specific operations. Also the console specific functions starting with prefix "domain_" shall be modified to "console_" to indicate that these are console specific functions. This patch is in preparation to support multiple consoles to support vuart console. Signed-off-by: Bhupinder Thakur Acked-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v3: - The changes in xenconsole have been split into multiple patches. This is the second patch. tools/console/daemon/io.c | 79 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 6f5c69c..a2a3496 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -163,10 +163,10 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } -static void buffer_append(struct domain *dom) +static void buffer_append(struct console *con) { - struct console *con = &dom->console; struct buffer *buffer = &con->buffer; + struct domain *dom = con->d; XENCONS_RING_IDX cons, prod, size; struct xencons_interface *intf = con->interface; @@ -296,12 +296,13 @@ static int create_hv_log(void) return fd; } -static int create_domain_log(struct domain *dom) +static int create_console_log(struct console *con) { char logfile[PATH_MAX]; char *namepath, *data, *s; int fd; unsigned int len; + struct domain *dom = con->d; namepath = xs_get_domain_path(xs, dom->domid); s = realloc(namepath, strlen(namepath) + 6); @@ -342,10 +343,8 @@ static int create_domain_log(struct domain *dom) return fd; } -static void domain_close_tty(struct domain *dom) +static void console_close_tty(struct console *con) { - struct console *con = &dom->console; - if (con->master_fd != -1) { close(con->master_fd); con->master_fd = -1; @@ -417,7 +416,7 @@ void cfmakeraw(struct termios *termios_p) } #endif /* __sun__ */ -static int domain_create_tty(struct domain *dom) +static int console_create_tty(struct console *con) { const char *slave; char *path; @@ -426,7 +425,7 @@ static int domain_create_tty(struct domain *dom) char *data; unsigned int len; struct termios term; - struct console *con = &dom->console; + struct domain *dom = con->d; assert(con->slave_fd == -1); assert(con->master_fd == -1); @@ -487,7 +486,7 @@ static int domain_create_tty(struct domain *dom) return 1; out: - domain_close_tty(dom); + console_close_tty(con); return 0; } @@ -526,10 +525,8 @@ static int xs_gather(struct xs_handle *xs, const char *dir, ...) return ret; } -static void domain_unmap_interface(struct domain *dom) +static void console_unmap_interface(struct console *con) { - struct console *con = &dom->console; - if (con->interface == NULL) return; if (xgt_handle && con->ring_ref == -1) @@ -540,11 +537,11 @@ static void domain_unmap_interface(struct domain *dom) con->ring_ref = -1; } -static int domain_create_ring(struct domain *dom) +static int console_create_ring(struct console *con) { int err, remote_port, ring_ref, rc; char *type, path[PATH_MAX]; - struct console *con = &dom->console; + struct domain *dom = con->d; err = xs_gather(xs, con->xspath, "ring-ref", "%u", &ring_ref, @@ -563,7 +560,7 @@ static int domain_create_ring(struct domain *dom) /* If using ring_ref and it has changed, remap */ if (ring_ref != con->ring_ref && con->ring_ref != -1) - domain_unmap_interface(dom); + console_unmap_interface(con); if (!con->interface && xgt_handle) { /* Prefer using grant table */ @@ -621,7 +618,7 @@ static int domain_create_ring(struct domain *dom) con->remote_port = remote_port; if (con->master_fd == -1) { - if (!domain_create_tty(dom)) { + if (!console_create_tty(con)) { err = errno; xenevtchn_close(con->xce_handle); con->xce_handle = NULL; @@ -632,7 +629,7 @@ static int domain_create_ring(struct domain *dom) } if (log_guest && (con->log_fd == -1)) - con->log_fd = create_domain_log(dom); + con->log_fd = create_console_log(con); out: return err; @@ -648,7 +645,7 @@ static bool watch_domain(struct domain *dom, bool watch) if (watch) { success = xs_watch(xs, con->xspath, domid_str); if (success) - domain_create_ring(dom); + console_create_ring(con); else xs_unwatch(xs, con->xspath, domid_str); } else { @@ -695,6 +692,7 @@ static struct domain *create_domain(int domid) con->slave_fd = -1; con->log_fd = -1; con->xce_pollfd_idx = -1; + con->d = dom; con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; @@ -746,7 +744,7 @@ static void cleanup_domain(struct domain *d) { struct console *con = &d->console; - domain_close_tty(d); + console_close_tty(con); if (con->log_fd != -1) { close(con->log_fd); @@ -768,7 +766,7 @@ static void shutdown_domain(struct domain *d) d->is_dead = true; watch_domain(d, false); - domain_unmap_interface(d); + console_unmap_interface(con); if (con->xce_handle != NULL) xenevtchn_close(con->xce_handle); con->xce_handle = NULL; @@ -799,9 +797,8 @@ static void enum_domains(void) } } -static int ring_free_bytes(struct domain *dom) +static int ring_free_bytes(struct console *con) { - struct console *con = &dom->console; struct xencons_interface *intf = con->interface; XENCONS_RING_IDX cons, prod, space; @@ -816,30 +813,30 @@ static int ring_free_bytes(struct domain *dom) return (sizeof(intf->in) - space); } -static void domain_handle_broken_tty(struct domain *dom, int recreate) +static void console_handle_broken_tty(struct console *con, int recreate) { - domain_close_tty(dom); + console_close_tty(con); if (recreate) { - domain_create_tty(dom); + console_create_tty(con); } else { - shutdown_domain(dom); + shutdown_domain(con->d); } } -static void handle_tty_read(struct domain *dom) +static void handle_tty_read(struct console *con) { ssize_t len = 0; char msg[80]; int i; - struct console *con = &dom->console; struct xencons_interface *intf = con->interface; + struct domain *dom = con->d; XENCONS_RING_IDX prod; if (dom->is_dead) return; - len = ring_free_bytes(dom); + len = ring_free_bytes(con); if (len == 0) return; @@ -853,7 +850,7 @@ static void handle_tty_read(struct domain *dom) * keep the slave open for the duration. */ if (len < 0) { - domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); + console_handle_broken_tty(con, domain_is_valid(dom->domid)); } else if (domain_is_valid(dom->domid)) { prod = intf->in_prod; for (i = 0; i < len; i++) { @@ -864,15 +861,15 @@ static void handle_tty_read(struct domain *dom) intf->in_prod = prod; xenevtchn_notify(con->xce_handle, con->local_port); } else { - domain_close_tty(dom); + console_close_tty(con); shutdown_domain(dom); } } -static void handle_tty_write(struct domain *dom) +static void handle_tty_write(struct console *con) { ssize_t len; - struct console *con = &dom->console; + struct domain *dom = con->d; if (dom->is_dead) return; @@ -882,7 +879,7 @@ static void handle_tty_write(struct domain *dom) if (len < 1) { dolog(LOG_DEBUG, "Write failed on domain %d: %zd, %d\n", dom->domid, len, errno); - domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); + console_handle_broken_tty(con, domain_is_valid(dom->domid)); } else { buffer_advance(&con->buffer, len); } @@ -901,7 +898,7 @@ static void handle_ring_read(struct domain *dom) con->event_count++; - buffer_append(dom); + buffer_append(con); if (con->event_count < RATE_LIMIT_ALLOWANCE) (void)xenevtchn_unmask(con->xce_handle, port); @@ -925,7 +922,7 @@ static void handle_xs(void) /* We may get watches firing for domains that have recently been removed, so dom may be NULL here. */ if (dom && dom->is_dead == false) - domain_create_ring(dom); + console_create_ring(&dom->console); } free(vec); @@ -975,7 +972,7 @@ static void handle_log_reload(void) if (con->log_fd != -1) close(con->log_fd); - con->log_fd = create_domain_log(d); + con->log_fd = create_console_log(con); } } @@ -1121,7 +1118,7 @@ void handle_io(void) if (con->master_fd != -1) { short events = 0; - if (!d->is_dead && ring_free_bytes(d)) + if (!d->is_dead && ring_free_bytes(con)) events |= POLLIN; if (!buffer_empty(&con->buffer)) @@ -1208,15 +1205,15 @@ void handle_io(void) if (con->master_fd != -1 && con->master_pollfd_idx != -1) { if (fds[con->master_pollfd_idx].revents & ~(POLLIN|POLLOUT|POLLPRI)) - domain_handle_broken_tty(d, + console_handle_broken_tty(con, domain_is_valid(d->domid)); else { if (fds[con->master_pollfd_idx].revents & POLLIN) - handle_tty_read(d); + handle_tty_read(con); if (fds[con->master_pollfd_idx].revents & POLLOUT) - handle_tty_write(d); + handle_tty_write(con); } } From patchwork Mon Aug 28 08:55:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111124 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548219qge; Mon, 28 Aug 2017 01:59:00 -0700 (PDT) X-Received: by 10.107.182.194 with SMTP id g185mr4929417iof.243.1503910740813; Mon, 28 Aug 2017 01:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910740; cv=none; d=google.com; s=arc-20160816; b=02DPPct1/ZFZQ4Qr/LusM+FX1JiRz4OdqvMPRntH9VHaFUY+hWfXpITUhhVh6mft3M NTyuaTiZ/D0D8kB2g0NMamOgY8ibPa1vHqDoaxVah4X2qAt6llCZ6YJ8D9xbPNvBzHUQ w0xNxcympVYH5O5My24hKAi7OmlcT5pFG4NhLmpbuRKv4SkmRinu7lD85fbB51VMzyeN PhDsA/P6VP+DEPNrCFAofJzSlEf63MM1qXG2MACfS7p4l4XWw63EYuGk04BG7U2KnO56 thw2PTe6lYVqBrvHVnDQ6IjM+hnjmzhAyVipI4vbSzZ84AWwngkhUSQCn/o9+cCFNKMr DaYw== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=+uFY/pVc8SURBInWhEretAHlX4Js5xxDKWVSHnOsbQU=; b=r/8oQdbwNGu4Mlpt+xiU0u2hhiXiC39GEDkKlb3yPiGad4bDCLUDOCVDXdwiiFNXMK 3wd3mF6ztN8aut1PsN4URM9613mAEliqWG+RHABq4l/BKz0YQIx47mS69cvlkVFc+kh7 KtyxIGwmwoxbJoKT9X69MrDjF0BmivMStBWARnfOYbDrEWE2FJjOXZuUkK32AArhtR1C WCUyhe5r1k68Izy1F+ooB4To9VpTAgSAeMQe/PEC/JcP758q41lcEJKSnsZEF5V9/lha 7i60FrEEOBuFOABEPVwAiKOFrOe8eZe46SaxtIzRyFZCfRc9Q39Y6eHD7UCmfog1RZ0M 8uSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=I8teHis6; 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 s40si11733507ioi.361.2017.08.28.01.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:59:00 -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 header.s=google header.b=I8teHis6; 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 1dmFqs-0004zj-ON; Mon, 28 Aug 2017 08:56:58 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqr-0004yp-Vl for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:58 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 0D/23-02176-9DAD3A95; Mon, 28 Aug 2017 08:56:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsVyMfTAJt0btxZ HGsy9JGnxfctkJgdGj8MfrrAEMEaxZuYl5VcksGY8vLaeqaBBvGLH2vVsDYzThLsYuTiEBGYy SvTenc0O4rAIzGOWmLd3KUsXIyeHhEA/q0TL90wIO03iVm8LI4RdIbH660awGiEBLYmjp2azQ kzazySxbeMN5i5GDg42AROJWR0SIDUiAkoS91ZNZgKpYRaYzyjRNKmXDSQhLBAhMenlIWYQm0 VAVWLl+SfsIL28Aj4SC2cbQuySk7h5rhOshBMovGPtXXaIvd4SXa8/sE5gFFjAyLCKUb04tag stUjXRC+pKDM9oyQ3MTNH19DAWC83tbg4MT01JzGpWC85P3cTIzCsGIBgB2PjF6dDjJIcTEqi vDsrFkcK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuANuQmUEyxKTU+tSMvMAQY4TFqCg0dJhHffD aA0b3FBYm5xZjpE6hSjMceVK+u+MHFMObD9C5MQS15+XqqUOO9FkFIBkNKM0jy4QbDIu8QoKy XMywh0mhBPQWpRbmYJqvwrRnEORiVhXm+Qe3gy80rg9r0COoUJ6BRFwYUgp5QkIqSkGhg5S9+ +D+FZN/m50fGLx3jZ3SbVrmK/6VFVfaznU+ubl5WvW6Q+qFydxFSx8b7+BIOPYWmf7K6uflNa cvHq9RtNgtVcbG5Wd3gmrwmeMmH1WrfGpSUPs3d96ku0FtZaE5K+/ij7h73Lk86bzMrS0F17e Vpqe5DX2ydTeY4slZmy+6m8Msdr5f1ZSizFGYmGWsxFxYkADUkvsrcCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-31.messagelabs.com!1503910615!111979373!1 X-Originating-IP: [209.85.192.178] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62070 invoked from network); 28 Aug 2017 08:56:56 -0000 Received: from mail-pf0-f178.google.com (HELO mail-pf0-f178.google.com) (209.85.192.178) by server-8.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:56 -0000 Received: by mail-pf0-f178.google.com with SMTP id h75so14502296pfh.1 for ; Mon, 28 Aug 2017 01:56:56 -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=CK3WW8RxUoVEpZ5UMzdRikYESdsFXDtL/nQkFOdJcGQ=; b=I8teHis6t8b8nnFYDUXd4+EPpUpSiYD9/qM0OPTQVQq6PSsVQ3dy25m9C6hgfYPGYo y2t6W6ZC1rAp+ze8MeZgWUMOwRSAMCTslGy8V/UkMC+FO9UYO1S6OnG7w7bfQUbz5v9P 9vfY9MSLQiOaJcImZvggtlxxwEsLR8vDFQbZk= 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=CK3WW8RxUoVEpZ5UMzdRikYESdsFXDtL/nQkFOdJcGQ=; b=hDWlS+TWZB6WHpJTeFfg+Af2gRC1SvnWpZaJC7qzZd94h6srImF7+D0FiFVczj5wfn 3IQmCtO6fZDr0fSSQ94zhy6xS4eeMT2LdmAImtdwOuh0fmcrWFSWglVL1hsyfh8bcK3k WyRMxc1TMRvebosUfxOLmsN/WWsCATFitW5YRq8/frmoP5HjqAe9pGqfpj6iSSUM4Uyh EjETUILuAphCxKFuyEH/6AgO0nKWCyO5OMJ3A1pi0TY4f3p0X0oSgtYqNK8ow1IS8oVa W2Z49b1wlhvysZnxafW5cFsxyXBefdzPfB2Lo+js3flHzpOJgPIwr7V45SPDzDEXj9qt uQTw== X-Gm-Message-State: AHYfb5gSoGIFunVGy7nMQ6z0e8Zn5W3BZkW4WahqJWzC1j+BCSzHPhkb ogcXFfy3poUmHhui/aprmA== X-Received: by 10.84.132.76 with SMTP id 70mr7236165ple.291.1503910614742; Mon, 28 Aug 2017 01:56:54 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:54 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:54 +0530 Message-Id: <1503910570-24427-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/27 v8] xen/arm: vpl011: Add a new console_init function in xenconsole 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" This patch introduces a new console_init function. This function initializes the console structure. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 65 ++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a2a3496..1da08d7 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -655,20 +655,51 @@ static bool watch_domain(struct domain *dom, bool watch) return success; } - -static struct domain *create_domain(int domid) +static int console_init(struct console *con, struct domain *dom) { - struct domain *dom; char *s; + int err = -1; struct timespec ts; - struct console *con; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d", __FILE__, __FUNCTION__, __LINE__); - return NULL; + return err; } + con->master_fd = -1; + con->master_pollfd_idx = -1; + con->slave_fd = -1; + con->log_fd = -1; + con->ring_ref = -1; + con->local_port = -1; + con->remote_port = -1; + con->xce_pollfd_idx = -1; + con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; + con->d = dom; + con->xspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->xspath, strlen(con->xspath) + + strlen("/console") + 1); + if (s) { + con->xspath = s; + strcat(con->xspath, "/console"); + err = 0; + } + + return err; +} + +static void console_free(struct console *con) +{ + if (con->xspath) + free(con->xspath); +} + +static struct domain *create_domain(int domid) +{ + struct domain *dom; + struct console *con; + dom = calloc(1, sizeof *dom); if (dom == NULL) { dolog(LOG_ERR, "Out of memory %s:%s():L%d", @@ -677,28 +708,10 @@ static struct domain *create_domain(int domid) } dom->domid = domid; - con = &dom->console; - con->xspath = xs_get_domain_path(xs, dom->domid); - s = realloc(con->xspath, strlen(con->xspath) + - strlen("/console") + 1); - if (s == NULL) - goto out; - con->xspath = s; - strcat(con->xspath, "/console"); - - con->master_fd = -1; - con->master_pollfd_idx = -1; - con->slave_fd = -1; - con->log_fd = -1; - con->xce_pollfd_idx = -1; - con->d = dom; - - con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; - con->ring_ref = -1; - con->local_port = -1; - con->remote_port = -1; + if (console_init(con, dom)) + goto out; if (!watch_domain(dom, true)) goto out; @@ -710,7 +723,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->xspath); + console_free(con); free(dom); return NULL; } From patchwork Mon Aug 28 08:55:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111118 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548144qge; Mon, 28 Aug 2017 01:58:56 -0700 (PDT) X-Received: by 10.107.133.97 with SMTP id h94mr5903561iod.227.1503910736180; Mon, 28 Aug 2017 01:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910736; cv=none; d=google.com; s=arc-20160816; b=Xrs5abGIH51J1V438ivokycS+lqVTeUNpaTaubpMg7SlUF7oSTl5fkdEFEPMyjfoN+ GhjeuSHq/iJ0uUx4MaDTPQ/i0/tAH2/6dGtHKkKvN2WEewv2F7Tu5XpmAKljZD8cVCvn 0iOlA1F0nd2MMTICLx3WjUk5jL12A4Nw0kWVjJaU+37m9We1EWG9SicV0puibVejlK+C jtO2IrsKkyaG3ovR8zcnbeEDEsHo2XzaaY0wYW/xTtSkvh/2TeJn/sPmfRR8BttvpDqL wadPorFBrPooQuOCEEPMyo/0I6x29Fhu9zdRAo7QVwDkwtS06a0Ymn7bpxbgfUCTRCgE lZqw== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=RBIonTcOwRkHLeFjaA/5ZTqVDWSkdEy4IXZH98gtXnM=; b=OqLnE9HRYWLB6T3CwFN1meRO17B/8EkMTM/AhefVSIFXzKIW7KWOn+oiAcYqV3oCmb kXPqxIxcIUuPmTrrOeqdgmdw9otl4V0rKA4TSo1OtbzCOelbnrMl8yHePEDxfwUSgxJf ny6PNGO3qu/4fc3A7A4uCO+/YdbnYuhmh1LYa4PiFikB/whEJv+M2yXQmk4YYiGgYsNT 1q8jMKj90PBbs6liTSmm0Xvuis5ZvciKySSNoSgmCiIPPnTDpF+LW5wFPzyf2q0Ex848 /u/FkR4DSAAxs/6HVwXMHkWNXLEFnBIPZNW64MpYkXs7F0/5NSmhHI7ersCUdLsI36Pr SX8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EhCTRhrG; 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 9si11783525iob.323.2017.08.28.01.58.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:56 -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 header.s=google header.b=EhCTRhrG; 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 1dmFqv-00053J-WF; Mon, 28 Aug 2017 08:57:01 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqv-000529-Ay for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:01 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 39/89-01724-CDAD3A95; Mon, 28 Aug 2017 08:57:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRusp3v71uJ Ig2MfjS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy9l+8yF3zjqbj4fD1bA+NDri5GLg4hgZmM Ev0Hm9i7GDk5WATmMUv8PRMEkpAQ6GeV2DhrO2sXIweQkyYx5U48SI2EQIXEg0s7WEBsIQEti aOnZrNCDNrPJLF4/xewejYBE4lZHRIgNSICShL3Vk1mAqlhFpjPKNE0qZcNJCEsECOxf1IvI8 RiVYmjTyeDDeUV8JGY33mVHWKZnMTNc53MIDYnUHzH2rvsEIu9Jbpef2CdwCiwgJFhFaN6cWp RWWqRrpFeUlFmekZJbmJmjq6hgbFebmpxcWJ6ak5iUrFecn7uJkZgWNUzMDDuYDzV7HyIUZKD SUmUd2fF4kghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErxnbgLlBItS01Mr0jJzgAEOk5bg4FES4 f0AkuYtLkjMLc5Mh0idYtTlmHRg+xcmIZa8/LxUKXHehyBFAiBFGaV5cCNg0XaJUVZKmJeRgY FBiKcgtSg3swRV/hWjOAejkjDvQZApPJl5JXCbXgEdwQR0hKLgQpAjShIRUlINjFtXNa6NWaW wvm5T7/55D34qTVrC5pJR9MT3+aP4UxdeP2VLurtX0s+j3mSH3e1bcd6r9e1C7i09xVD252bk 9yuiK5kcXCNiJ9Z/YYn6b6Wc7rieJUQy1Y6fc2rlpqUWhppzDgexLHm0v67/hbLhJv87ooeD5 xRc9blkE78gwk0tcnryO7FyZSWW4oxEQy3mouJEAB+sDZGxAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-16.tower-31.messagelabs.com!1503910618!104284346!1 X-Originating-IP: [74.125.83.46] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3493 invoked from network); 28 Aug 2017 08:56:59 -0000 Received: from mail-pg0-f46.google.com (HELO mail-pg0-f46.google.com) (74.125.83.46) by server-16.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:59 -0000 Received: by mail-pg0-f46.google.com with SMTP id r133so22212466pgr.3 for ; Mon, 28 Aug 2017 01:56:59 -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=yB+nxIvgk8UjZRr/CwimK1H7zFddzpCzBRq7KGA1phI=; b=EhCTRhrGhRvxMUPqJxzS0QXqzF/rAMBE8EHf9XuBdXS6Ef1JHPXuo7OkY+qCR5tPkQ NKMjnEBOsP3Jh/qgTjg3w8AewcFDY7aO3fb8/XWD8LtN3p5Q5fySOFvVj4Zyuuu37Sh2 TOQJE6iSHF5o8mmZumKddCsS/XyNunGWn7L2Q= 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=yB+nxIvgk8UjZRr/CwimK1H7zFddzpCzBRq7KGA1phI=; b=Ms55g+by/mRNaZZ2isQhTvbrrdHXRtagdykxJT7P6aZ96nVYTp2y/EUj2WmKdq3TW1 TLmzvIJwKVYXxDxgO2/6EeiHuDMNTgvVvddJv1gXfK0c89xDRKIaAly/NJaBNprR8LxB Igxv25mwrtQmpCo5v0Hn3ub1+VP/64cUws1KZis1EV8eI8X5KIvRvYTppx7w0ybH8hJF 27/cIJjY/qRQz9nZ2b0sNFxXQwlCPlij/sferGZQCQQAu8xIqJPcSbTClq6MTX1Uq6R9 dSSGKmei9FNPEmm2+TOh5n1Jb2cClj2qFAmleuZsirCeyZl1LwGUVcY7w7MxkeCXLo4n YCQw== X-Gm-Message-State: AHYfb5hw4e6FcW55jGTItWpNn4S9jKB//tKaeH2DGhKmx4KNZU1u7SWn xGBgJezCR7aWLe95dCXXkw== X-Received: by 10.84.141.164 with SMTP id 33mr7401087plv.59.1503910618029; Mon, 28 Aug 2017 01:56:58 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:57 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:55 +0530 Message-Id: <1503910570-24427-13-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 12/27 v8] xen/arm: vpl011: Add a new buffer_available function in xenconsole 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" This patch introduces a new buffer_available function to check if more data is allowed to be buffered. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 1da08d7..0009bbe 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -163,6 +163,16 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } +static inline bool buffer_available(struct console *con) +{ + if (discard_overflowed_data || + !con->buffer.max_capacity || + con->buffer.size < con->buffer.max_capacity) + return true; + else + return false; +} + static void buffer_append(struct console *con) { struct buffer *buffer = &con->buffer; @@ -1120,9 +1130,7 @@ void handle_io(void) con->next_period < next_timeout) next_timeout = con->next_period; } else if (con->xce_handle != NULL) { - if (discard_overflowed_data || - !con->buffer.max_capacity || - con->buffer.size < con->buffer.max_capacity) { + if (buffer_available(con)) { int evtchn_fd = xenevtchn_fd(con->xce_handle); con->xce_pollfd_idx = set_fds(evtchn_fd, POLLIN|POLLPRI); From patchwork Mon Aug 28 08:55:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111116 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548109qge; Mon, 28 Aug 2017 01:58:53 -0700 (PDT) X-Received: by 10.107.145.2 with SMTP id t2mr4937546iod.160.1503910733542; Mon, 28 Aug 2017 01:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910733; cv=none; d=google.com; s=arc-20160816; b=sGj1XOnSKl9iYaI24oldyvJQp8jyaj7D96EwDPtLlBdfNbKbRjHPEnSSL7oEV803tQ lPWCqWfHpN13Ek9FSfpM9XOvLJ+P+2PlNJJOF5ZMKmvDnEQAq3gNWTS6OnRpJAX5W+wY ur9sv8Mhdu9wyU6T8yAb3aqdQRmMuaZ6IA86PCZFnLtnvf6Vn7MhlK9vevB2PbW4VsxE I69pag1Tt9nw/Wbfm5oHAP9iy1gDVIZj22Ua3iqPo2RLp+X+Mpmbr4L1EXbH6T3Rw0Hc NNaFihdAOBJsYD5rYXsey282+U/vDLxG1bFowVPFnf2Azz1OiKVQrCdUCJgREzZNBKAq D2Iw== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=EncVTiWfBbtIxylxnUk9+xT21OqnAVDQk2kqPlpQZiU=; b=OWdnK/c9pg1KSm15nNbPYfKz3lmzpK/ywN6p98gEzULAyuLpNqMuHAM+1ajosr2P5r WqlEGQjFixvlapYMpDVxW/UDvYz0dogPptS5F1nRThMFyxIr0dg4IJaO3I+V01/LMNsG H0QnIonA/z3pyZO8YO8sAsBRvjNcc6MJv/6AS0JYmOjjbjXPRaDqDmv6IqTRu9s5TlHm h3eMknKBWT6BoSnqDx9xnCgg9zz31elkfkhRu/EDbEv0gYgffy9H9vbQDJ9s/e8GD/Ai bgk8b3zShIJ3nrPduNKgXJFJ7WuPrtgpfIUrPGhjQ9B+8RB1+eagbWN/mLfXvHl9zUb6 nFIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=beGOR/aD; 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 s40si11733357ioi.361.2017.08.28.01.58.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:53 -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 header.s=google header.b=beGOR/aD; 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 1dmFqz-00057a-BH; Mon, 28 Aug 2017 08:57:05 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqx-00055W-Og for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:03 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id 6B/EE-03414-FDAD3A95; Mon, 28 Aug 2017 08:57:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRtsqHvv1uJ Ig+1/1Cy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozujTMYC7YIVTy8cJKtgbGfv4uRi0NIYCaj xMOdj9lAHBaBecwSE24sYwZxJAT6WSVmv/4KlOEEctIkHp3qZYewKyW6N95iAbGFBLQkjp6az Qoxaj+TxOMv+4AaODjYBEwkZnVIgNSICChJ3Fs1mQmkhllgPqNE06ResKHCAukSn88dAxvEIq Aq8XDZLLBeXgEfiQN3uSB2yUncPNfJDGJzAoV3rL3LDrHXW6Lr9QfWCYwCCxgZVjGqF6cWlaU W6VroJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEBhYDEOxgnH3Z/xCjJAeTkijv zorFkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeM/cBMoJFqWmp1akZeYAQxwmLcHBoyTC+wEkz VtckJhbnJkOkTrFqMsx6cD2L0xCLHn5ealS4rw+IEUCIEUZpXlwI2DxdolRVkqYlxHoKCGegt Si3MwSVPlXjOIcjErCvAdBpvBk5pXAbXoFdAQT0BGKggtBjihJREhJNTC2em1InWLTWNfzoeG +VtbBz2+OPJZRvGtW3ZHz027H78LSdeViD67GMWVK+S9MfeOv3+pvK7LloJdSu3evpEzrUa1/ tlURNmVHfZ7sOJK0oYVzcvPvl5ImzUd/sW7cXfbYravYaMnVLSFcrfNqBa76HdhkX3rpiqdCV k/A4vLyb3rTWlZrtSmxFGckGmoxFxUnAgD+4A3YsgIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-27.messagelabs.com!1503910621!108265385!1 X-Originating-IP: [74.125.83.49] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58043 invoked from network); 28 Aug 2017 08:57:02 -0000 Received: from mail-pg0-f49.google.com (HELO mail-pg0-f49.google.com) (74.125.83.49) by server-5.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:02 -0000 Received: by mail-pg0-f49.google.com with SMTP id t193so11124697pgc.1 for ; Mon, 28 Aug 2017 01:57:02 -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=+Jo1JpAkfFAajaOT3dp6fEfCx26fj20ZkRTJgD45A5A=; b=beGOR/aDSbxc5THvLpqRprlmI7HjGMj12Hcq0hQDYqT41yJ29KlMOP1/KBHFXUrf2a TptYUT0QfdEkdvwupBPmHubUG6hnIt8yv9L4fnm3Y4V2YLBWGoo8f4QwkuTrwJkvLvHx VcHz7GTVt0zd2vNzxiXTqjiV8BciUShX3O108= 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=+Jo1JpAkfFAajaOT3dp6fEfCx26fj20ZkRTJgD45A5A=; b=WODc1ldJAWKOJCCOUHQldCnEHmWYBUU/7NFZVeUTmPxJ+SRldZEly+1xxg2HN+knlR M7Wo+djaHfIYODXG1LGtmzjkh4vJFBCOv7wXNEtV6aD+ZIHQCwOc13CSVTtVb5x+CHsg /nobiXNnaJ9Mb/fW0dF0UmKMv4c6oLEtkd70k7L04Zxww55kkwqi03C+bEyGM9/GHG6t YKvBw/EqskpFrptn0zA7od4L1nkmjKHPvTNdkKvJt9kWPi6p8ubB5dG9Lz59kiBAek94 ZIk1lVJsgArpD8ifJuKo8v3LFNWWPHjBYNEjFTnnpdiVvJOv6vrNfrx2DEtZXOGpSPc0 vlnw== X-Gm-Message-State: AHYfb5j9MqJxREXk7aZ7BJk90rfofOU/NoLaqX9BhbpY7cCgJk0wNbiW dk0n9XEigTFIJakzl/xn6A== X-Received: by 10.84.216.81 with SMTP id f17mr7635770plj.176.1503910621065; Mon, 28 Aug 2017 01:57:01 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:00 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:56 +0530 Message-Id: <1503910570-24427-14-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 13/27 v8] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd function in xenconsole 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" This patch introduces a new maybe_add_console_evtchn_fd function. This function adds the console event channel FD to list of polled FDs. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v6: - Renamed add_console_evtchn_fd to maybe_add_console_evtchn_fd since it adds the FD to the poll list conditionally. Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 0009bbe..3483252 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1047,6 +1047,26 @@ static void reset_fds(void) memset(fds, 0, sizeof(struct pollfd) * current_array_size); } +static void maybe_add_console_evtchn_fd(struct console *con, void *data) +{ + long long next_timeout = *((long long *)data); + + if (con->event_count >= RATE_LIMIT_ALLOWANCE) { + /* Determine if we're going to be the next time slice to expire */ + if (!next_timeout || + con->next_period < next_timeout) + next_timeout = con->next_period; + } else if (con->xce_handle != NULL) { + if (buffer_available(con)) { + int evtchn_fd = xenevtchn_fd(con->xce_handle); + con->xce_pollfd_idx = set_fds(evtchn_fd, + POLLIN|POLLPRI); + } + } + + *((long long *)data) = next_timeout; +} + void handle_io(void) { int ret; @@ -1124,18 +1144,7 @@ void handle_io(void) for (d = dom_head; d; d = d->next) { struct console *con = &d->console; - if (con->event_count >= RATE_LIMIT_ALLOWANCE) { - /* Determine if we're going to be the next time slice to expire */ - if (!next_timeout || - con->next_period < next_timeout) - next_timeout = con->next_period; - } else if (con->xce_handle != NULL) { - if (buffer_available(con)) { - int evtchn_fd = xenevtchn_fd(con->xce_handle); - con->xce_pollfd_idx = set_fds(evtchn_fd, - POLLIN|POLLPRI); - } - } + maybe_add_console_evtchn_fd(con, (void *)&next_timeout); if (con->master_fd != -1) { short events = 0; From patchwork Mon Aug 28 08:55:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111122 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548181qge; Mon, 28 Aug 2017 01:58:58 -0700 (PDT) X-Received: by 10.107.38.206 with SMTP id m197mr6265161iom.157.1503910738818; Mon, 28 Aug 2017 01:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910738; cv=none; d=google.com; s=arc-20160816; b=R+R66V3xG8X/A/o1CRVSZKXAHHWOck02yBHtWZ3Pk5XTewVzz+yx1/5yIJrzIXN8c4 DPUkByDFCVvoTsWysV5Q5agd2WuRlarFK3tWcMz61Rvat75u9WIj+L2pJ9Wn4sUKMDhM bfdQMyxm8m+Cdp2VEBIEy0vI68ERAAB17FoGVYDkGew052iovbqqovfS2I18SyGlWNR8 OBVvZ3DsBhtoZoDob/DOjbr2HYEzw5varS1iB4Reujy55h2bkqgYNRtStvPPp5LIq+Su Xh2jurZlwhfvSzLWQGb0Gp+na+gm4IMwNTer3NibKV/pJrpPSYWL/t1Sga9kiDGseGk5 4NRg== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=EUocknFP1/4WLo8tbtI19J0u7VdgpEYuwErsmY6uzF0=; b=fh0OlHVknIIlW5m64WVYfmk25EvFKB1ZSLqgvT03KHOiF2zGjaur58w7SMgzFpHCpB du4L5nFLy9Pw0IyRRjA+p+vgq0Xmd+ewm655EvGh6mml8xev1zD8zPs7+cNiTfNK19mx mqpIV809FUUKtbhQCiPmYh+vI0XqO2YyJrUUtzVgGmzds9lVJtr+jIvVT9B+vgfaWLzc cc8bDn2MIuW4Hg4SCOPKCemVisbBLDAL6ij+cHXZwWL1BAnX+3AVh39E16L4a9zUmeQ1 hxDl1X1iNgl8pFxCxVqp41lSDQlJ9GpTdhQrwJCQF1KNAKqHWDOyaklEZTYLtR71gQ9d p8Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cLjGoelK; 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 36si9728250ios.28.2017.08.28.01.58.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:58 -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 header.s=google header.b=cLjGoelK; 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 1dmFr2-0005B7-Ig; Mon, 28 Aug 2017 08:57:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFr1-00059P-DA for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:07 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id BF/27-03406-2EAD3A95; Mon, 28 Aug 2017 08:57:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRusrfvo1uJ IgwmvOS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy32y6yFrQIVJyc+o+lgXE1bxcjF4eQwHRG iVuTutm7GDk5WATmMUsce5UNkpAQ6GeVOPbyDgtIQkIgTeLGrOdARRxAdqXE4RXiIGEhAS2Jo 6dms0IM2s8kMW/ZfrAaNgETiVkdEiA1IgJKEvdWTWYCqWEWmM8o0TSplw0kISyQIjFj9is2iM WqEsfP3gbbxSvgIzH36RRWiL1yEjfPdTKD2JxA8R1r77JDLPaW6Hr9gXUCo8ACRoZVjBrFqUV lqUW6hsZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBgcUABDsYvywLOMQoycGk JMq7s2JxpBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3jM3gXKCRanpqRVpmTnAEIdJS3DwKInwf gBJ8xYXJOYWZ6ZDpE4x6nJMOrD9C5MQS15+XqqUOK8PSJEASFFGaR7cCFi8XWKUlRLmZQQ6So inILUoN7MEVf4VozgHo5Iw70GQKTyZeSVwm14BHcEEdISi4EKQI0oSEVJSDYwWNpJvPt7I+2/ 0KM4v/oKly9MZcUIW4TKRec/yz1cVbar/VNRzcMYsrr2Pj95nuv9wZZ//LQY7RqOT89Y/vr/b fSP7gqXnM3ilO/SlFa15stskZAz2p0zX/WQRe/eD6h+NrL1n6o13RZpv6mCoUFTsMivp9nu/4 R5z9JSWDO5VSYVKbNPWXlRiKc5INNRiLipOBAADA8aisgIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-21.messagelabs.com!1503910625!76746335!1 X-Originating-IP: [74.125.83.43] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1102 invoked from network); 28 Aug 2017 08:57:06 -0000 Received: from mail-pg0-f43.google.com (HELO mail-pg0-f43.google.com) (74.125.83.43) by server-11.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:06 -0000 Received: by mail-pg0-f43.google.com with SMTP id t3so22362913pgt.0 for ; Mon, 28 Aug 2017 01:57:05 -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=1zZv5gMZFdWN6HyPnIRtGQbrCrYIkCirHr84Vy7ho9I=; b=cLjGoelK1lRngoWXTpXPkksjVk6o48Z3zhQ3Nj37ueOCJQtB2OTb1ocLkrYSUvd1nF pkQ5+UWx2LuZaQ2N8m7FfhAaakZOnDcUzkj4kj/VUB684/brXETZiUjEfH0oN4OXDt1D opoDmp9RbsVJJ9CxaXoQA++A3yY83EqQdPRqs= 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=1zZv5gMZFdWN6HyPnIRtGQbrCrYIkCirHr84Vy7ho9I=; b=np3GO/Y43VrTYzUw3zxBBBDPehhi6EG0qqFKE3gYRyIyNMda42OkUkofX/w1wPBEce YZLYogYSujHy3fmwlQGwOmp7nRt3cxvSzP2OwYSIgdfz+XDSpBIuOqmehx8jbnkencrX nQlBQZ8f2Km6PFKtTo81IetP0JsNYvO0aajKRVp5/xH1Yq2PB9cxR7YZF+in4loOOmZw dI9ym9wki8OUrd+RzcEk+OaV9Q8UOPOo5CyuWQzZ5f7EUK4Y5t0NdGT78NctdaZ8izZm KSM+KNHJTFYtN8SNgZkg3dQKULOWFI1nMHQb+ARn+ptDWItXSu34479i2+v0P3Rk2CQ6 rw6w== X-Gm-Message-State: AHYfb5jZzUQnxHFJ0KQTRX0xZjal1ssL/+wwKQHtwrdzABCU01Re0+dt MLgtAEJbQRomB99MxbsGhw== X-Received: by 10.98.103.206 with SMTP id t75mr944200pfj.318.1503910624463; Mon, 28 Aug 2017 01:57:04 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:03 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:57 +0530 Message-Id: <1503910570-24427-15-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 14/27 v8] xen/arm: vpl011: Add a new maybe_add_console_tty_fd function in xenconsole 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" This patch introduces a new maybe_add_console_tty_fd function. This function adds the tty fd to the list of polled fds. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v6: - Renamed add_console_tty_fd to maybe_add_console_tty_fd since it adds the tty FD to the poll list conditionally. - I have retained the reviewed-by tag as only the function name has been changed. Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 3483252..a0b35da 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1067,6 +1067,22 @@ static void maybe_add_console_evtchn_fd(struct console *con, void *data) *((long long *)data) = next_timeout; } +static void maybe_add_console_tty_fd(struct console *con) +{ + if (con->master_fd != -1) { + short events = 0; + if (!con->d->is_dead && ring_free_bytes(con)) + events |= POLLIN; + + if (!buffer_empty(&con->buffer)) + events |= POLLOUT; + + if (events) + con->master_pollfd_idx = + set_fds(con->master_fd, events|POLLPRI); + } +} + void handle_io(void) { int ret; @@ -1146,19 +1162,7 @@ void handle_io(void) maybe_add_console_evtchn_fd(con, (void *)&next_timeout); - if (con->master_fd != -1) { - short events = 0; - if (!d->is_dead && ring_free_bytes(con)) - events |= POLLIN; - - if (!buffer_empty(&con->buffer)) - events |= POLLOUT; - - if (events) - con->master_pollfd_idx = - set_fds(con->master_fd, - events|POLLPRI); - } + maybe_add_console_tty_fd(con); } /* If any domain has been rate limited, we need to work From patchwork Mon Aug 28 08:55:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111104 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4547912qge; Mon, 28 Aug 2017 01:58:40 -0700 (PDT) X-Received: by 10.36.91.7 with SMTP id g7mr5857096itb.62.1503910720650; Mon, 28 Aug 2017 01:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910720; cv=none; d=google.com; s=arc-20160816; b=MAOHJvdjfZg/h7gAurtEhSebijdmCgaXhEj563so1SYwbHKenYygAy70wlvL46gPQI Q9slJ3yf5M52DhlCth+GZ+i1tGtDKoIYI+SqiPgTx7n/x8Zu9wVxTDukl/KIjFdgw1tB QBoH29foYYMSbziN80y1tmJkSNdqhte3W4n00F1FMkObtqW2DnIdIvkV3+BctuSwiUwC d+3R1bs6wIZ0rXp52SNwHZac9Qe5DvSx3mrmr3ty6x1wfqaXicr1m4ctGBqlfY17oe7d 8TsYo2gmdkD37rICeo0pe2bG5/+Z1M4UCWnS5QYSdc9cfS+BUcN3vF1n9rsxPiN66xak 7CWA== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Q//ZvXSf6O3d1s0mYjwUQWsaeqGoT/sNc0NvqLgFwSc=; b=KmG5y2IOPXhy6yBIF50uhSh4Zejsng9JchqH5nodiy5MHJyqfP71HjKyXhMLhD/4Yw 13uBAVHAm5ppsNLLjz8wC7YnyagZwvxleFTWFX5PA3sqLBq0QfsOs2/c4SiZslaIV/OR k8nVitC8Pk7lyXU6l8GdYkmbut2lmW8/dr5BKVlcpT+HRerTPEkqtlDae3VY2PVPC5mc GEcgwQipA0DjyHPJkLyTPONkdirJ8kaDg4Lr+6VH8N245kbQqcKcrJ1NPj3LemSGYooj NyimyAQiLMm+k2z5uAAyQpx17myKANNvESPXbYXu3IR3Zr19gP2BO/1ubVWp1v2kYE8q YBWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VdVGH8AP; 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 k190si5462125itd.55.2017.08.28.01.58.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:40 -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 header.s=google header.b=VdVGH8AP; 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 1dmFr5-0005Es-Q6; Mon, 28 Aug 2017 08:57:11 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFr5-0005Dg-3H for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:11 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id E5/81-02962-6EAD3A95; Mon, 28 Aug 2017 08:57:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsVyMfTAet2ntxZ HGsw/qGnxfctkJgdGj8MfrrAEMEaxZuYl5VcksGYsfH2fuWC+RMXEPbcZGxh/C3cxcnEICcxk lPjSuJ8NxGERmMcssebMfhYQR0Kgn1Xi1vUexi5GTiAnTeJ/+zM2CLtK4tvvrUwgtpCAlsTRU 7NZIUbtZ5JYuGYncxcjBwebgInErA4JkBoRASWJe6smM4HUMAvMZ5RomtQLNkhYIFHiwNMTrC A2i4CqxKkFM1lAbF4BH4mfLzvZIZbJSdw818kMYnMCxXesvcsOsdhbouv1B9YJjAILGBlWMWo UpxaVpRbpGproJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEBhcDEOxgvL4x4BCj JAeTkijvzorFkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeENuAuUEi1LTUyvSMnOAYQ6TluDgU RLh/QCS5i0uSMwtzkyHSJ1iNOa4cmXdFyaOKQe2f2ESYsnLz0uVEud9CFIqAFKaUZoHNwgWf5 cYZaWEeRmBThPiKUgtys0sQZV/xSjOwagkzHsQZApPZl4J3L5XQKcwAZ2iKLgQ5JSSRISUVAM j74Z0lYXMc3JtRS0arkV+CMr4FBQreNIr2/XYDxcbv90MsT9Yom1WVFpXeWREfBbW7pBv4ylf dG3Zh5XLDAx/Nfwzn1JoxHDx9PHqzTcd2tPuS3XJWFUsC1R5VvZqjrmbpe/OW5bOR/Kff7Bpe puy0LLrO/vEHbuLjxxa8seTddHkXzuFfE2UWIozEg21mIuKEwExxP11ugIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-27.messagelabs.com!1503910628!108265412!1 X-Originating-IP: [209.85.192.175] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58547 invoked from network); 28 Aug 2017 08:57:09 -0000 Received: from mail-pf0-f175.google.com (HELO mail-pf0-f175.google.com) (209.85.192.175) by server-5.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:09 -0000 Received: by mail-pf0-f175.google.com with SMTP id c15so14537899pfm.2 for ; Mon, 28 Aug 2017 01:57:09 -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=6YGovVGluRqECYuWlBHwMmYrCh73aradxIet+Hw08pw=; b=VdVGH8APOpaP5CdB+D7SVHZWpjNT21JCkB8Y0OlpSvdYyL5sbuR1YnkQ9AKQ/3NHPi sSW9wMJI+FRyhVidE6sF+JiBZQmpItv+JSu3kS4XlyNbet8nO1PDWFAxfWAB/c67j/mP lvMwmkdyxUvq1pdum+j5XaJE5PLTSK47aZ7jc= 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=6YGovVGluRqECYuWlBHwMmYrCh73aradxIet+Hw08pw=; b=lnanEW+1OgCSzU/LQKHETCWu9xPNSgTPbDmKtpRI7AoIXjghvz9SBG5qIuiYxFZGYl j+OKsk5F94VDy9wUh6Qb0QKqMRq+uMiAdhyxvyoYa3S/QiANHZIptVKhroer4LOSxBUR 6v6PZYW4Gr2F55JMGV+1bSKelV9VDTDY5FLYH868u+VN+34/WYPK6Ifie96kGm9OuKpp sGGxxVCsfDt3IjO3EPzikxefaBJbSOpBVeSYu7xwERy2cL2k0D7IHSBRC5pqe4nnFhso fgSeb9DO7Vui8ehtMo98nLyjozjE9IJtW8x8SFEesLINGO4A4dlWkeAjLLPGSaduWDNH HIPA== X-Gm-Message-State: AHYfb5jPyJTVnkzndeNquJgwKBixZfprXAUMDXXVgMPG3IqzH4vlYuzv DmcJcMlW4LWaMHk6wk93BA== X-Received: by 10.99.43.144 with SMTP id r138mr6555959pgr.360.1503910627798; Mon, 28 Aug 2017 01:57:07 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:07 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:58 +0530 Message-Id: <1503910570-24427-16-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 15/27 v8] xen/arm: vpl011: Add a new console_evtchn_unmask function in xenconsole 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" This patch introduces a new console_evtchn_unmask function. This function unmasks the console event channel if it is masked for some timeout period. One optimization that has been done is to merge the two for loops. One for loop was used to iterate through all domains and unmask the domain event channels which had been rate limited for a specified duration. The other for loop was run to add the event channel fd and the tty fd to the poll list. These two for loops were merged so that the these operations can be done in one iteration instead of two iterations. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a0b35da..2dcaee6 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -117,6 +117,11 @@ struct domain { static struct domain *dom_head; +static inline bool console_enabled(struct console *con) +{ + return con->local_port != -1; +} + static int write_all(int fd, const char* buf, size_t len) { while (len) { @@ -908,6 +913,27 @@ static void handle_tty_write(struct console *con) } } +static void console_evtchn_unmask(struct console *con, void *data) +{ + long long now = (long long)data; + + if (!console_enabled(con)) + return; + + /* CS 16257:955ee4fa1345 introduces a 5ms fuzz + * for select(), it is not clear poll() has + * similar behavior (returning a couple of ms + * sooner than requested) as well. Just leave + * the fuzz here. Remove it with a separate + * patch if necessary */ + if ((now+5) > con->next_period) { + con->next_period = now + RATE_LIMIT_PERIOD; + if (con->event_count >= RATE_LIMIT_ALLOWANCE) + (void)xenevtchn_unmask(con->xce_handle, con->local_port); + con->event_count = 0; + } +} + static void handle_ring_read(struct domain *dom) { xenevtchn_port_or_error_t port; @@ -1142,23 +1168,7 @@ void handle_io(void) for (d = dom_head; d; d = d->next) { struct console *con = &d->console; - /* CS 16257:955ee4fa1345 introduces a 5ms fuzz - * for select(), it is not clear poll() has - * similar behavior (returning a couple of ms - * sooner than requested) as well. Just leave - * the fuzz here. Remove it with a separate - * patch if necessary */ - if ((now+5) > con->next_period) { - con->next_period = now + RATE_LIMIT_PERIOD; - if (con->event_count >= RATE_LIMIT_ALLOWANCE) { - (void)xenevtchn_unmask(con->xce_handle, con->local_port); - } - con->event_count = 0; - } - } - - for (d = dom_head; d; d = d->next) { - struct console *con = &d->console; + console_evtchn_unmask(con, (void *)now); maybe_add_console_evtchn_fd(con, (void *)&next_timeout); From patchwork Mon Aug 28 08:55:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111103 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4547869qge; Mon, 28 Aug 2017 01:58:36 -0700 (PDT) X-Received: by 10.107.158.6 with SMTP id h6mr4986005ioe.232.1503910716801; Mon, 28 Aug 2017 01:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910716; cv=none; d=google.com; s=arc-20160816; b=XTDzx2Di7UkTQBxqO/Nlb9UgIi4HrGupk3F8oPt4z8SeLQ3uJrzSXoL66QyCkvvihO K7VcgLmhZkof09ZxfuDA8APzW8mutKlaz5RfIuHu4Bcb8bcxRcqupgdV7GOqqCP9H1U8 pvA8zopb42Yqq8nkJ89TuCh4pbIJQ8eogWQ4n+zTFYwc+6t0kDCyC4PuffYRqlsPCsjr 3JCoSJOKflLeiYUt8g+qWCRijFYjm3leRHzhMtCOVa7ecBsleiJxeD4+gLmxWlyIB/c3 UB/UsPKCpbGiIVOWHKDnOYdhnpaT5fBCEWntTy8/dVJ0QWQ3aM3M8SQIMmcpMMyu6mHR 27cw== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=GCwa/gkQ+E7SKoiInGs++cf6PNAtsj+M23Bj3i/wbxA=; b=ThW9PkY6iCxiKmIY7KzdaqBqhlS8F15Pm26wkX8sXMKI1JZgU6vqr4PEDIfct2p2GP 8UBJxCyh8fY3NaOl2IreU8YU1q6PuQ9E9oChqJMe/QOl5W9cO1cSClWOl+aI04XWfk85 KBkGNSoLm9VLp6Z6EbHz08KLgnN7MDtEgxkxFXrjrNYOeMkq5aW2AkNa1WPXfTxzG5Ec VjBVneLVyKq9XT2tb+KmRqp4axtvZSgFF5ToewnYJi0jpU4dUm/8XVjqbUJIGvXKsUJd ixdJuMKH24f9E8fg77SRP5ywuZihLmIghfcNVV9Xdo1dfJvzF1hhmBbiWNpfADIlsGvH KhjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Tq5bRn1p; 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 i184si3663238itc.49.2017.08.28.01.58.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:36 -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 header.s=google header.b=Tq5bRn1p; 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 1dmFr8-0005I0-1A; Mon, 28 Aug 2017 08:57:14 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFr7-0005Gc-Ex for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:13 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id D8/CD-01736-8EAD3A95; Mon, 28 Aug 2017 08:57:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRusr/vi1uJ IgxNzBSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owLm3QLJotX7P/Qy9jA+FOoi5GLQ0hgJqPE yquP2EAcFoF5zBJbXzeydDFyckgI9LNKfJ7iAmGnSWxq38TexcgBZFdIfFrkCBIWEtCSOHpqN ivEoP1MEg3ntzKC1LAJmEjM6pAAqRERUJK4t2oyE0gNs8B8RommSb1sIAlhgXiJjp+9rCA2i4 CqxPU5S8DivAI+EptbVjNC7JWTuHmukxnE5gSK71h7lx1isbdE1+sPrBMYBRYwMqxi1ChOLSp LLdI1stRLKspMzyjJTczM0TU0MNXLTS0uTkxPzUlMKtZLzs/dxAgMq3oGBsYdjJe3+B1ilORg UhLl3VmxOFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBK8TMEyFBItS01Mr0jJzgAEOk5bg4FES4 f1wEyjNW1yQmFucmQ6ROsWoyzHpwPYvTEIsefl5qVLivA9BigRAijJK8+BGwKLtEqOslDAvIw MDgxBPQWpRbmYJqvwrRnEORiVh3nKQS3gy80rgNr0COoIJ6AhFwYUgR5QkIqSkGhg3LDq8+lL HvFA51zsadtLCces/XvlZ0/V4+n2eWZN2NOhN5nlsvOnuS+fQwNqPvYm3Axo3Tn8a8PyNmmze tld6GWd+bNtwqKJ+cv954xodv68xxfw5/0wT139alqi6f99xJo7tafPTK8zvsWy4vnJTfOLl1 zEsp66xxfK2ZE6aulgtQspd73GAEktxRqKhFnNRcSIAKQfq/rECAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-206.messagelabs.com!1503910631!109005071!1 X-Originating-IP: [74.125.83.47] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43616 invoked from network); 28 Aug 2017 08:57:12 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-8.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:12 -0000 Received: by mail-pg0-f47.google.com with SMTP id t193so11126018pgc.1 for ; Mon, 28 Aug 2017 01:57:12 -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=YOnVbf2KQHJUvnXkY+8NWwhSqgBo0gewN4GYDNIiV08=; b=Tq5bRn1pZhRIr3c523HFEqgqNb5js61yo6xhKuiobPLDkL24BOliCH8GeDiFQrmGZH bKT6Vzrj4N18f1E8v1A3j49dmghvy3lcDpkr+lrKdN9y0NIpz47e7rxNLKtMSpd7u1XL OXXhUe4CGFloBXYq3+sLE1qEgXPXjUllHASIw= 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=YOnVbf2KQHJUvnXkY+8NWwhSqgBo0gewN4GYDNIiV08=; b=gR5S8zk5KBxrOGt85q86TYFq4MhCqxiN1B1lajIADMomUugn742caSEJsGjB7xdB+/ l8N8ZW6n/fC13zldAsNbnmEzF+YHgl3nfNJw+rFSlIRq11ZalfX5tTlw7ihGl7LuOJvx 2STmx6zDDZUmYqZbQcyZ+YpwJ7nN9jTdTRtbIKyi40by9JUmRr7li+8a8eRiJ1lnL9Y8 hzc2oPudv6MvNnfa+P3RZsYbJRPvRPMd24+vMRmVkMT9p9XC/qotBI7z9oDUzCWe1D06 w8FJPIq7JGE31+ocw4ub8yQrdBggJ8xOvx6dkPNBV6yENCGzWWXh57+9beAj49PtdE7x 02wA== X-Gm-Message-State: AHYfb5in/hvp3oGTgMnK57YJjWLVhdbcGLjJUWBkgqGQz9BScnhFGVll +s2XfCPuY10eNCfmm6pjmQ== X-Received: by 10.98.44.18 with SMTP id s18mr6590565pfs.268.1503910630616; Mon, 28 Aug 2017 01:57:10 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:10 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:59 +0530 Message-Id: <1503910570-24427-17-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 16/27 v8] xen/arm: vpl011: Add a new handle_console_ring function in xenconsole 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" This patch introduces a new handle_console_ring function. This function reads the data from the ring buffer on receiving an event. The initialization of event channel poll fd to -1 is moved inside the handle_console_ring function as they are related. There should be no change in the behavior as there is no functional change. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 2dcaee6..c361b42 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -934,17 +934,23 @@ static void console_evtchn_unmask(struct console *con, void *data) } } -static void handle_ring_read(struct domain *dom) +static void handle_ring_read(struct console *con) { xenevtchn_port_or_error_t port; - struct console *con = &dom->console; - if (dom->is_dead) + if (con->d->is_dead) return; if ((port = xenevtchn_pending(con->xce_handle)) == -1) return; + if (port != con->local_port) { + dolog(LOG_ERR, + "Event received for invalid port %d, Expected port is %d\n", + port, con->local_port); + return; + } + con->event_count++; buffer_append(con); @@ -953,6 +959,21 @@ static void handle_ring_read(struct domain *dom) (void)xenevtchn_unmask(con->xce_handle, port); } +static void handle_console_ring(struct console *con) +{ + if (con->event_count < RATE_LIMIT_ALLOWANCE) { + if (con->xce_handle != NULL && + con->xce_pollfd_idx != -1 && + !(fds[con->xce_pollfd_idx].revents & + ~(POLLIN|POLLOUT|POLLPRI)) && + (fds[con->xce_pollfd_idx].revents & + POLLIN)) + handle_ring_read(con); + } + + con->xce_pollfd_idx = -1; +} + static void handle_xs(void) { char **vec; @@ -1236,15 +1257,8 @@ void handle_io(void) struct console *con = &d->console; n = d->next; - if (con->event_count < RATE_LIMIT_ALLOWANCE) { - if (con->xce_handle != NULL && - con->xce_pollfd_idx != -1 && - !(fds[con->xce_pollfd_idx].revents & - ~(POLLIN|POLLOUT|POLLPRI)) && - (fds[con->xce_pollfd_idx].revents & - POLLIN)) - handle_ring_read(d); - } + + handle_console_ring(con); if (con->master_fd != -1 && con->master_pollfd_idx != -1) { if (fds[con->master_pollfd_idx].revents & @@ -1261,7 +1275,7 @@ void handle_io(void) } } - con->xce_pollfd_idx = con->master_pollfd_idx = -1; + con->master_pollfd_idx = -1; if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Mon Aug 28 08:56:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111105 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4547947qge; Mon, 28 Aug 2017 01:58:43 -0700 (PDT) X-Received: by 10.36.53.71 with SMTP id k68mr5361357ita.10.1503910722968; Mon, 28 Aug 2017 01:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910722; cv=none; d=google.com; s=arc-20160816; b=wH+rvHxT+KcZryHFfCU4vtpBLAJpf5UD3qIhtNLFn06PH/KKgy+4HuVP7MugTLP1Q6 VbWdnefRr2UB6z/RDZwDK7IIo0kSM7vHkvDEKUu8Yk8tLMvppMV3PTIRMRpOB3bWdNuR smeNf//va/Z55JCbD8AIlSdXfC5XZEWmbYq5RDuTV1H6GTisipWb5ZVcghoMIy59jCiT qYUJB2Sjtln8eOCjgGK5fkZF8e0PGB65zpdm4wrm5JukyVp/SiwO1s0umiBPMl32sAB8 PzfCL46AqNCqlc7mJ7sdvdAG+2IWrtpqdJiwK95DwX7NfWg3DW+ZT8JV83LZaLpDeSUx uzXQ== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=H8RR8P9mLK0Yb6u6N61ymtzG/1SrqORpSqVSo+gXTcg=; b=jTpHVNZchfGTNLi0pWAGtASVGhZh6eAn+hVs/aU+ixHue4nL082PEYgCb6YWmNcT+r Q4x+K5rZOsNuE3kF0KKEeWuMZE/PNpXm5Qm+ZRY7Cu+3U4QzcpHtU+WHA2qmdabtN82H D0CeY2FDk9O9BGvaw7y5g9ULedGplg2BwmuU/y2Ws5+RVn+omnMHZjmnJHqKsJgQEtKO aNkMBMLZ06RP8A5uHdjKt1ajTkx2J8zSSynKH4Q/0ikzpNXHJ8mdXQ14UwEX7d2hDDS9 2pwZ8wyV+zoCUEEZe0xrdyYEN3TT7S3fynk2ZhGUa4esrgtCEif06CvrHck/wYi+G+Ep QULg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FVElzWjp; 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 37si12135437iop.51.2017.08.28.01.58.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:42 -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 header.s=google header.b=FVElzWjp; 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 1dmFrB-0005MW-8x; Mon, 28 Aug 2017 08:57:17 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFrA-0005Ks-Ea for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:16 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id F9/1D-09901-BEAD3A95; Mon, 28 Aug 2017 08:57:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsXiVRuso/v61uJ Igwf3OSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxZq66wFEwQqFjxdT9LA+MW3i5GTg4hgemM EpPfxnQxcnGwCMxjlvixcB0biCMh0M8qMXnCS3aQKgmBNIm3iz4wQdhVEhdaP7BCdGtJHD01m xWkQUhgP5PEywMrGLsYOTjYBEwkZnVIgNSICChJ3Fs1mQmkhllgPqNE06ReNpCEsECcxKJbk8 FsFgFViUe3NoAt4BXwkZj3/i3UMjmJm+c6mUFsTqD4jrV32SEWe0t0vf7AOoFRYAEjwypGjeL UorLUIl1Dc72kosz0jJLcxMwcXUMDM73c1OLixPTUnMSkYr3k/NxNjMDQYgCCHYy3NwYcYpTk YFIS5d1ZsThSiC8pP6UyI7E4I76oNCe1+BCjDAeHkgTvmZtAOcGi1PTUirTMHGCQw6QlOHiUR Hg/gKR5iwsSc4sz0yFSpxh1OSYd2P6FSYglLz8vVUqc1wekSACkKKM0D24ELOIuMcpKCfMyAh 0lxFOQWpSbWYIq/4pRnINRSZj3L8gUnsy8ErhNr4COYAI6QlFwIcgRJYkIKakGxiKZgKWcxf+ f/mng/HKOM/T15pJytsb/sTH/tG8GMF986DeLl89h57LExbNzdBeVn/XZd2Iie1rnwwWX4prm /Ix95v3p7SaWu0/WCyW+3nP8QV/nx9YPDxrr/O/92R9uWepilV6/S13LbsXOSdcP1D/VsVnwd cLBEvMQY2+fIg+9iVsNX3GUlimxFGckGmoxFxUnAgBjHgVGswIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-2.tower-27.messagelabs.com!1503910634!54195099!1 X-Originating-IP: [74.125.83.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22694 invoked from network); 28 Aug 2017 08:57:15 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-2.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:15 -0000 Received: by mail-pg0-f44.google.com with SMTP id t3so22364040pgt.0 for ; Mon, 28 Aug 2017 01:57:14 -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=cKW4VVAXHwcprLM7odui2WUoZIfS5KdXFh4XFIsCHUU=; b=FVElzWjpYsI+iOlb+ZT9hC9iqqHSNJOeKtRRukO0D6ZpHK8LcDrVxGNuWWc7jTy9gl nZKd1TGPhdoZlzq+ofSBbngRRrkDgtuGx8g2YeWj0wtoB8hmOb7fp4cXCYSMhF/o4ay3 pGaCaS7nXm150sqwY86C1NZ5pasQwhjPevdLI= 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=cKW4VVAXHwcprLM7odui2WUoZIfS5KdXFh4XFIsCHUU=; b=i6TBEtIaoMxSQSMXLRKcJXWhDqY7oh3raNaTHcv016AhkaexKHSDFh3wo/Bg/bWi8U XyI+k5IthdD6nPwTQvS9cVUr5hAkxEpv5UBZ0pX1MLBpuU9/8Y7FW+8q9pITVbqjf6NL 6m4akgDXKZQgePPM9jmvjjOyWUPIqHPKaC2AUPbZtDg3Hl4cELxLL67feBKwMqGz/qnE Etn+sKIrPsgn0OpdDp4ig94Bhhzl3FpnDmVGjvqKLXDmjol+J9TJ/fzoTckHd6nYnNJN aDuCULDFIBQfPL7MHc0HFiV5z/ia6tCZ5hb+jmi9snG7fiPketqoORhFpVe6hxLilkY5 xNzg== X-Gm-Message-State: AHYfb5j8QgiDhaVAMmZozCCuu6vGQmPsBnejeHsmitwJpR6dKHbMeyd6 IcpTfG1dzSS31IOAl0Ozzw== X-Received: by 10.99.44.150 with SMTP id s144mr6533785pgs.318.1503910633540; Mon, 28 Aug 2017 01:57:13 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:13 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:00 +0530 Message-Id: <1503910570-24427-18-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 17/27 v8] xen/arm: vpl011: Add a new handle_console_tty function in xenconsole 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" This patch introduces a new handle_console_tty function. This function performs read/write from/to console tty. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index c361b42..5c6da31 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1130,6 +1130,24 @@ static void maybe_add_console_tty_fd(struct console *con) } } +static void handle_console_tty(struct console *con) +{ + if (con->master_fd != -1 && con->master_pollfd_idx != -1) { + if (fds[con->master_pollfd_idx].revents & + ~(POLLIN|POLLOUT|POLLPRI)) + console_handle_broken_tty(con, domain_is_valid(con->d->domid)); + else { + if (fds[con->master_pollfd_idx].revents & + POLLIN) + handle_tty_read(con); + if (fds[con->master_pollfd_idx].revents & + POLLOUT) + handle_tty_write(con); + } + } + con->master_pollfd_idx = -1; +} + void handle_io(void) { int ret; @@ -1260,22 +1278,7 @@ void handle_io(void) handle_console_ring(con); - if (con->master_fd != -1 && con->master_pollfd_idx != -1) { - if (fds[con->master_pollfd_idx].revents & - ~(POLLIN|POLLOUT|POLLPRI)) - console_handle_broken_tty(con, - domain_is_valid(d->domid)); - else { - if (fds[con->master_pollfd_idx].revents & - POLLIN) - handle_tty_read(con); - if (fds[con->master_pollfd_idx].revents & - POLLOUT) - handle_tty_write(con); - } - } - - con->master_pollfd_idx = -1; + handle_console_tty(con); if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Mon Aug 28 08:56:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111111 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548018qge; Mon, 28 Aug 2017 01:58:47 -0700 (PDT) X-Received: by 10.107.57.132 with SMTP id g126mr5321825ioa.352.1503910727126; Mon, 28 Aug 2017 01:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910727; cv=none; d=google.com; s=arc-20160816; b=fBgRDFiDPw6LpjMgs/+GMfBODUeekknMKcYGZ8Nnt/DrB5UK9+9hRzzHEM9cbNbOEI zGP8SWVxfoCaCpuTbjz6ioOZsLEE1aruULwhIwLutqNvu9yrTRY0zSou59NxkJ3+VzYP sJxgSxvBQwDt7eHQHAsG1WuTwtA9KwUsNCRItvvBb6e1hJaJsYT2LQ4GS9Cj8SEcYpCq jYqJfjeqiQDjPGy43OYelypa8uBIzZAFzRMplEXDeMsymIacS0u/iy+uGfJKcpkdXrjs NuMHIUnNvZlfMHn2AgmLJx8cPs4gkG3ZZdhtzt/4nbsuOj3L/PgHBOdJUicganLC27vS BzZg== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Bg6fT8CW/IMdJdKHwnAiGPV2040T6kKQ60tEt4w7sHw=; b=aAi9DxK4jkwFi7nnkagoGfoW3kB4H1bdBdYlVA/ahpVDnFX4uVypbh9bEcju6vHlnf RICTVHmtCm+YUNrHjYXndpJdPfpWOizSLX4a0B94UygBOmJeWpaOdrcznFv43Oo7T6gF M3K82GzRF+cCYfH49hwsxyZrqr3+O0fgjo0z50TvrhpjsVEe1vgyxR4oRuGvjRH3FaX1 Vw791lq8kGE/OyVKTsLovbqhj507AghIBW6QYk+t1T+Z5jQWLjNx7y8ArR7+7NE4nQM5 IrLcU/Ud9X0/6VLG/5pEVd0N47Aco213M29Kkh3wlbtEJ1xOzMxmjiW26gDD7/PPgui4 hE2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TYQde5v2; 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 f1si11898949iof.45.2017.08.28.01.58.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:47 -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 header.s=google header.b=TYQde5v2; 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 1dmFrF-0005St-KR; Mon, 28 Aug 2017 08:57:21 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFrD-0005Py-Q8 for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:19 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 3B/B1-02962-FEAD3A95; Mon, 28 Aug 2017 08:57:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRusrfvu1uJ Igy8zlCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozja5exFmzmrpiwMrKB8RlnFyMXh5DAdEaJ rw/mMYE4LALzmCXuHzrHCOJICPSzSlxc94+ti5ETyEmTuPbwBjOEXS1xZMkdsLiQgJbE0VOzW SFG7WeSaLq6gKWLkYODTcBEYlaHBEiNiICSxL1Vk8E2MAvMZ5RomtQL1iwsEC2xe0cbI4jNIq AqsfpML9gCXgEfiQkrbrFDLJOTuHmuEyzOCRTfsfYuO8Rib4mu1x9YJzAKLGBkWMWoXpxaVJZ apGuol1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kRGFgMQLCDcedzp0OMkhxMSqK8 OysWRwrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4D1zEygnWJSanlqRlpkDDHGYtAQHj5II7weQN G9xQWJucWY6ROoUoy7HpAPbvzAJseTl56VKifM+BCkSACnKKM2DGwGLt0uMslLCvIxARwnxFK QW5WaWoMq/YhTnYFQS5j0IMoUnM68EbtMroCOYgI5QFFwIckRJIkJKqoHRuPO9a5igYN/U1L0 5XwV9LJInPXsb1cP8ZuqbhqqILQlbFv758nbBFMdE12VnZgjz7pj6IDtHl7Pp18yIYzPvlsrK 2aZ1PH6pIZBxw/LW/HTFKWuPz3xdckXnP+cWbXsjRd0Z7YK/3Xb8OmL662vK3rptRkFsf3YtV fujtd9VfdW6JTrrZI69UWIpzkg01GIuKk4EAOLxolayAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-27.messagelabs.com!1503910637!60894063!1 X-Originating-IP: [74.125.83.43] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 53866 invoked from network); 28 Aug 2017 08:57:18 -0000 Received: from mail-pg0-f43.google.com (HELO mail-pg0-f43.google.com) (74.125.83.43) by server-15.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:18 -0000 Received: by mail-pg0-f43.google.com with SMTP id t3so22364422pgt.0 for ; Mon, 28 Aug 2017 01:57:18 -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=ibyLFSz2OCW5sE3Ydz65ZRFcFBf596L9bo9Hcmr8ZFk=; b=TYQde5v2NVvbDFf4zHPRlXxtp2supnWr6P7PhavvgMCoe4ttxl3o+zwP7JOR3ptmvz o42D2AdT4gjbvMxYk9ubbLWBokSmoKQh4rWifkOIAqKe6YOG9tcS+D14oRgjDi1jpA1g B+VqSN46kmYGxZKUl04zpkKAw+2FcZIj6XbYU= 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=ibyLFSz2OCW5sE3Ydz65ZRFcFBf596L9bo9Hcmr8ZFk=; b=RLOmlo7yVyuPXz1YaKtYlWyX/xuW/1VHlW5z2vCLB4Aryl+uAvBcLH/Rsqw9I/LkfH SzlJ+7e5ociqbkNyNqVQSfJYuIiQRaXYj5wE3kgm6f33VEHtb9zxpkur6eH/je76pvec mAZb8roAB8rzDObbFUQwQN+p8bCQ1jUKfBd+OLDBUINkCidMMSdI7as5sava6N1qEnXF 8XIHRm1v2Wq5Us5+pUkw49bXHEEUphrm2rLxebEE1XtbQ3uC8OI7pn5oMQ6gWm24h8C4 qcRpSKGw1YEe6qF8s5TmqVnYcS5i8Nua3n59LthL3swudDgerO+/1IisEqJKC5MW+58Z UEtw== X-Gm-Message-State: AHYfb5j8SEx4nVnYs1DuT8LGUJK7GZUrqGfcpLYZXvc9gGW0UKiyjizn ptqpe8+bpPtVOkKsHIXsGQ== X-Received: by 10.99.110.129 with SMTP id j123mr6574316pgc.428.1503910636688; Mon, 28 Aug 2017 01:57:16 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:16 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:01 +0530 Message-Id: <1503910570-24427-19-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 18/27 v8] xen/arm: vpl011: Add a new console_cleanup function in xenconsole 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" This patch introduces a new console_cleanup function. This function frees up the console resources. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v6: - Removed a null pointer check before calling free() as free() already checks that. Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 5c6da31..ff69e52 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -768,12 +768,8 @@ static void remove_domain(struct domain *dom) } } -static void cleanup_domain(struct domain *d) +static void console_cleanup(struct console *con) { - struct console *con = &d->console; - - console_close_tty(con); - if (con->log_fd != -1) { close(con->log_fd); con->log_fd = -1; @@ -784,6 +780,15 @@ static void cleanup_domain(struct domain *d) free(con->xspath); con->xspath = NULL; +} + +static void cleanup_domain(struct domain *d) +{ + struct console *con = &d->console; + + console_close_tty(con); + + console_cleanup(con); remove_domain(d); } From patchwork Mon Aug 28 08:56:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111115 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548102qge; Mon, 28 Aug 2017 01:58:53 -0700 (PDT) X-Received: by 10.107.170.134 with SMTP id g6mr5372135ioj.327.1503910732932; Mon, 28 Aug 2017 01:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910732; cv=none; d=google.com; s=arc-20160816; b=BEXXggnWdswO7DtIQXTXrwZ4/U3FqjIvgfCKkaG6LhNEsfa1gNuoFJKvRaYXl/eo5p RXnQ9wfKEZgKuqfs5H+doob12Ywud3isrOlW3vVXQeJQaU3MFe8YyT/MZJJh+kAd+apx vKQm9P2+xuvjMnIeJuuzUJcrGzsbepEteoIyk9B1o3AgpNLRW9AHnhs2IWBw97wSPA/I ECx9J5sPGWPtFpkstmEBlANzmz6qUDMp9k7Cs+UADKXFR4sFWkjpqu5kt9iOYEV8ZQR0 IySlbKoRr9EIGrMCbuB8suU/yRfyR5e9c9rNBPt9PQM42VWjF+U8PCwQFrOF/ZrcHtK+ wVTQ== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Em6IOaAuN4l9Udc4AQQsj05f48nAJF1yHYv8gt15suE=; b=v3s5mvfLW9gXL3YmiIbEoFDRQ9cz5yn4A3mgarzM4PivoEknaVnpaTn1eR4IOkO9nk sAUQO2kz7Bvz1JrGwThAVeaIVyBH0c8jgmVRRn7MtGEJhZQaFtDjSVuEgUwRAJlHQON4 h0qzr/22z2cb0/52AE2EngnJ/q4rdlRoHWFkyW8nn1odHhaK6xVaExnrZC5ZflZdPNcQ +DfHcmK98locMx4mAkGiAbxvOnvESk+bySmojFNFZdYnLYMy1L6FvIeAod6AgXI9324X xHIFg9TX9LvHW7/4DrQkmcK73XEoR1DVrpEPl/R3YwzV9szK74JOHB1zH3QeCpjiXb/K /rNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BmlMHd4E; 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 x199si7179048itb.171.2017.08.28.01.58.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:52 -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 header.s=google header.b=BmlMHd4E; 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 1dmFrL-0005au-S4; Mon, 28 Aug 2017 08:57:27 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFrK-0005YK-Ds for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:26 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id D3/67-01712-5FAD3A95; Mon, 28 Aug 2017 08:57:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLIsWRWlGSWpSXmKPExsVyMfTARt2PtxZ HGjR9VLL4vmUykwOjx+EPV1gCGKNYM/OS8isSWDP+bulkLpjMXbFqwRamBsajnF2MXBxCAjMZ Je5e+cEM4rAIzGOW+PZwGRuIIyHQzypx5PI2IIcTyEmTeND8iR3CrpD4+OE1M4gtJKAlcfTUb FaIUfuZJPbeu8rYxcjBwSZgIjGrQwKkRkRASeLeqslMIDXMAvMZJZom9YINFRaIkXg0+yAjiM 0ioCqxcfIusDivgI9E05b3zBDL5CRunusEszmB4jvW3mWHWOwt0fX6A+sERoEFjAyrGDWKU4v KUot0DU31kooy0zNKchMzc3QNDUz1clOLixPTU3MSk4r1kvNzNzECg4sBCHYwNmz3PMQoycGk JMq7s2JxpBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3jM3gXKCRanpqRVpmTnAMIdJS3DwKInwf gBJ8xYXJOYWZ6ZDpE4xWnJcubLuCxPHhtXrgeSUA9u/MAmx5OXnpUqJ8z4EaRAAacgozYMbB4 vFS4yyUsK8jEAHCvEUpBblZpagyr9iFOdgVBLmPQgyhSczrwRu6yugg5iADlIUXAhyUEkiQkq qgXE980pzQQuGPxv+HBe4MTfskep0i00ql9Y9OjxjWtD8mf45EoZcuxl6XhYvCAw3iK3jDN/Q F1slv+1tgV3CjC0vGmUfqi37ufr6lym/I86+XmWScoFtctOhitDIAzYVe29V7FCIP+InUxP2X OboMsndSq2VzuJX505hc9t5QVI71++3YxV31DklluKMREMt5qLiRACOdU78wAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-206.messagelabs.com!1503910640!70320104!1 X-Originating-IP: [209.85.192.177] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62822 invoked from network); 28 Aug 2017 08:57:21 -0000 Received: from mail-pf0-f177.google.com (HELO mail-pf0-f177.google.com) (209.85.192.177) by server-14.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:21 -0000 Received: by mail-pf0-f177.google.com with SMTP id c15so14539387pfm.2 for ; Mon, 28 Aug 2017 01:57:21 -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=Czel33Q/wCzetrNTUKuMCaNrHbuXAUhTInKJVQs+Ekc=; b=BmlMHd4E8JLz8xc+1zPduxiC+6j4KzXJodX7ne+CEXF7Eh++x7Rt1SyTJGX2ol25UG VONOCS0WaQTiaOd7wRsqD8jMjEfr1biCaIahJC4pHnDL26ReMezyabLS7oPnH27DVoRa K17It6SIh6qN0YWMMiaO7D90qG1u8oy0HN0XM= 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=Czel33Q/wCzetrNTUKuMCaNrHbuXAUhTInKJVQs+Ekc=; b=H60vVdFYPg/ppLif8gccU2dMHie8bkGWfPRzW1hpVT0AjWq8IklgwG+O+9ttRSYYzl BTewKcMahk9MxwbHPLHHu6+fgvOpmanUXxv6quRkCni5KDeSqoUXztjlijb2xc26V3gf MIeYVcXpoQ8ktbcXQOVPSW5R0WJnD3sbDPtsQRjiDqY8uE2TixqL7NrapgIrKBb2v6cs H6KMGUIzz3EGT0euccWGs904Y3CS1QLyNJUAbKETEpXt0L9WrYj0459R14vISXTfF04C xW4MxUAyNQs+QmTRyy/MW6v8IdjnAF83BM7uhsKcEyQqWGwHWxaSk0HvU2mBnr65V2d8 JJKg== X-Gm-Message-State: AHYfb5gr6s0c0jeWsQuCToexfJJ7ZegyljctZ9fPPSahpHDrnPDg6fOD JL51NeG7aIQi1Eobnvzisg== X-Received: by 10.98.51.71 with SMTP id z68mr6834378pfz.307.1503910639665; Mon, 28 Aug 2017 01:57:19 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:19 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:02 +0530 Message-Id: <1503910570-24427-20-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 19/27 v8] xen/arm: vpl011: Add a new console_open_log function in xenconsole 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" This patch introduces a console_open_log console_cleanup function. This function opens the console log file. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index ff69e52..cfd7273 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1038,6 +1038,15 @@ static void handle_hv_logs(xenevtchn_handle *xce_handle, bool force) (void)xenevtchn_unmask(xce_handle, port); } +static void console_open_log(struct console *con) +{ + if (console_enabled(con)) { + if (con->log_fd != -1) + close(con->log_fd); + con->log_fd = create_console_log(con); + } +} + static void handle_log_reload(void) { if (log_guest) { @@ -1045,9 +1054,7 @@ static void handle_log_reload(void) for (d = dom_head; d; d = d->next) { struct console *con = &d->console; - if (con->log_fd != -1) - close(con->log_fd); - con->log_fd = create_console_log(con); + console_open_log(con); } } From patchwork Mon Aug 28 08:56:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111109 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4547990qge; Mon, 28 Aug 2017 01:58:45 -0700 (PDT) X-Received: by 10.107.37.207 with SMTP id l198mr5474124iol.146.1503910724951; Mon, 28 Aug 2017 01:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910724; cv=none; d=google.com; s=arc-20160816; b=uoJNgUy+QjfkOwY9GIigVlmP6Rt7BKa+IXrU9DavCDdOLIdDZ62q+KwHCAVHAZTblC AE1wcCoDWXV8sy0uTomoGyuq1gdZK7gDpfGp9drAkqsKThb0dorJ/6vdPCeP+qf6cHOM QEVPakYMcgJKZcojexolQbqKgTpUtqJaf1dt7+ol9Mk6SsC2yVPXup7b1Z5ICLHiMl0D 8oaeekFMyY21fqVCgjacMWnSvVX/spc6dgL75Z7x1nuNIxUw6FPgdpB7fsYXBqKKqqAA Hwtvulv8TxSW5Y4vI01mcI58fXw82gSGoeYnpQuzaFBB4tZb6dPhG7yZdFhfr3GehuXl SXZQ== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=B/iWbb165fhqROXYtc1SUPyns/TlpQEbmkL/vah2sQ4=; b=F6p1910wE8OmxOu0dUpmfweEfDKuBW3CO0yRdtuPCYqQNWCIHJHTL3pqGEDp0h7OY7 FLNpO9DU9iCWnujhS9bLBSbUCNQ9iyFF0iGDtKM8d7uITUn1mN8PIadG/eSpjuEHTu+6 sBFKvta95vKmkNazddDJ0QpKSoDZlLJvCFywgEwVFhFcLF67tOgCCsRji20Bnl0/4/X5 JQ3ggjGaLhxiaIFuQ2QHkj7u3FH/bxkZg/DT7wX4MorOAwuzo/C9m6aJokMOBCL6Z8yi tsZFBU7PwcLGYp1PrKkEaM5Fjq5von5boeAYYRUxGB8YiPyxmpYrT+yqOEvX7zO+Gsxw vJhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kGESc+5H; 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 i187si12183995ioi.400.2017.08.28.01.58.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:44 -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 header.s=google header.b=kGESc+5H; 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 1dmFrO-0005e6-3G; Mon, 28 Aug 2017 08:57:30 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFrM-0005bh-Q1 for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:28 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id A7/4C-02184-7FAD3A95; Mon, 28 Aug 2017 08:57:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsXiVRtsrPvl1uJ Ig6ffZS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozHZy4yFfzmqji6fD9rA+NRzi5GLg4hgemM El2Xr7GCOCwC85glNn16ywjiSAj0s0osXnwOyOEEctIkNi39zA5hV0m87L7ACmILCWhJHD01m xVi1H4mieYjG4CKODjYBEwkZnVIgNSICChJ3Fs1mQmkhllgPqNE06ReNpCEsECCxKK9h5lAbB YBVYnFd1azgNi8Aj4Sd6bugVosJ3HzXCcziM0JFN+x9i47xGJvia7XH1gnMAosYGRYxahenFp Ullqka66XVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKyXnJ+7iREYWgxAsIPx2GTnQ4ySHExK orw7KxZHCvEl5adUZiQWZ8QXleakFh9ilOHgUJLgPXMTKCdYlJqeWpGWmQMMcpi0BAePkgjvB 5A0b3FBYm5xZjpE6hSjLsekA9u/MAmx5OXnpUqJ8/qAFAmAFGWU5sGNgEXcJUZZKWFeRqCjhH gKUotyM0tQ5V8xinMwKgnz/gWZwpOZVwK36RXQEUxARygKLgQ5oiQRISXVwMj67uUV84CSmTM dqwNvaaddOnPUucL4nNOZm/laVadPXJO7WM7+v+VztQXzdH+n6RtfcnH1Ls212/nowCs3r5+B t7edzVVI3Hfty5Ky+AmMs/6c1udqmbth0urE40v/f9TfM/VL9wWrjXsXSDiY/eGW2TF7iUnlj U9zp1ew6JcK791v/jtnv6SeEktxRqKhFnNRcSIA8XAH8LMCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-206.messagelabs.com!1503910643!80713497!1 X-Originating-IP: [74.125.83.51] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2480 invoked from network); 28 Aug 2017 08:57:24 -0000 Received: from mail-pg0-f51.google.com (HELO mail-pg0-f51.google.com) (74.125.83.51) by server-10.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:24 -0000 Received: by mail-pg0-f51.google.com with SMTP id 83so22179586pgb.4 for ; Mon, 28 Aug 2017 01:57:24 -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=cCjDRmwTdHUYIQiYgejFMteqYI89juGj+je6V6CGGvI=; b=kGESc+5HWFGQ2iUwz2Wh86kINJ6cB7CKDCz0mw6QAdDZYyBMTQ9ikWN4WbFQHZWQRF 8EQ48qH2bbnUJ2A8AwzyQgKb5FqpN4WTabOa4BXPjgxluOS68F5HEu5hWguWNkgE1Brc p/Z6Tllq77z1g+iCvcko/zmCNeYdKwyFYUdAU= 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=cCjDRmwTdHUYIQiYgejFMteqYI89juGj+je6V6CGGvI=; b=EcHOvNMyNoJodSP5Km/GmDxVN8eQIG59kp5FwKciH6p0l++ZrV9zYyQDE/h4/abqq0 dMnA39OYmSDyHjVbAf0kMjel6VU7kna2IMPo/Vo8mpf5KRfKSrRvvP2Nd0shIumVajOM ca9eEnYtikFBqhZ01d7dQuc7kfCxQBSG8ScOrc+N34m91MNPbR7mUi5zrCYgZ31uvfpi K8fM8V29xcYwqifGr6oprTQO0JPRjXbMZhXQME88kHSpU8RHI3RCAUZj33hmu40PN143 mDb0xSJe9MrSK1HfW2/BNnKr4zbNnhcI75FgBEktoEZNWZ16MHbPVIjNetsuj2cZIMNP oseg== X-Gm-Message-State: AHYfb5iooVS7n68jqSHoTcdTEPCJwEf0W+T0FuXp2aKwcZTjFaQ3ChX3 vjBvwiI/HGYlBtwsSWSosA== X-Received: by 10.101.75.141 with SMTP id t13mr6872247pgq.269.1503910642820; Mon, 28 Aug 2017 01:57:22 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:22 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:03 +0530 Message-Id: <1503910570-24427-21-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 20/27 v8] xen/arm: vpl011: Add a new console_close_evtchn function in xenconsole 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" This patch introduces a console_close_evtchn function. This function closes the console event channel. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index cfd7273..71465a0 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -793,6 +793,14 @@ static void cleanup_domain(struct domain *d) remove_domain(d); } +static void console_close_evtchn(struct console *con) +{ + if (con->xce_handle != NULL) + xenevtchn_close(con->xce_handle); + + con->xce_handle = NULL; +} + static void shutdown_domain(struct domain *d) { struct console *con = &d->console; @@ -800,9 +808,7 @@ static void shutdown_domain(struct domain *d) d->is_dead = true; watch_domain(d, false); console_unmap_interface(con); - if (con->xce_handle != NULL) - xenevtchn_close(con->xce_handle); - con->xce_handle = NULL; + console_close_evtchn(con); } static unsigned enum_pass = 0; From patchwork Mon Aug 28 08:56:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111117 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548127qge; Mon, 28 Aug 2017 01:58:54 -0700 (PDT) X-Received: by 10.36.104.210 with SMTP id v201mr5930021itb.95.1503910734917; Mon, 28 Aug 2017 01:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910734; cv=none; d=google.com; s=arc-20160816; b=xM2RgcOFvbu67CZCjapAK0sYEXZ68YM7q9pKZEUdVMqIvIsTp4PiTnYN/hUBwvLRVM Wdv3TjqQ+x4WTuVjRJkWlxoL1yDhzih6G7ISqQ/LOXIv7DzusvB2mnJJqfIxjFXqqA6W EEI9djSlSculnOp9qikN3xaoISx+uiC04I1lz0280n6SyyZ11Bh3iJDK5HrTn/aUB8tq knvq+eHjZfGFtjkSPYPbqbHfo4o4utCvMuHqcAf94HL55yAX78p8fsyUycdeJfpfqhJS GSFhqZGJgNV7y0XOBqLB/kuCWvts/yXPaGh5R83dJcnOb9c6TV8PW5uSy7Sz6wwKJ5Tc 4zug== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=3aa+qutL86sgRqK48J9Q/2ZHC/CfX7KsDNhnQ0C9hCg=; b=BKLjpkPuu3mkirqLc8yJFLOa0L1mb6qeEh5ihAyBJSGgWL70flLo3Ec1FjSaQ6C/tL H5BeW+lAcrN5Ea72Lfd1hGhEi7eClMf/g+aAS9d6CCzVG+/7CQzBkMSTTy9/8ODFpYXz pVgt4uQ69cBHGbE1HmKK1AtLKVfpoy74fQAbvn+p1RvXARURIZdcDUSZJpxGpxGSF0F5 R4ocuOdoy1LJiZW2u32bKpard2Zbr8AnAKd27lRKBUsYpTiTIt9sPdfxJdOhw4hh4KRG 8CxPZLX3855E84+QZWmLW3Rjn910ihgzST3qPhLl+CIK+cM9vPWU8r03vew89gd5YhIz SeFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eFlk0+k9; 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 v19si4377187iov.262.2017.08.28.01.58.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:54 -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 header.s=google header.b=eFlk0+k9; 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 1dmFrO-0005ed-AT; Mon, 28 Aug 2017 08:57:30 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFrN-0005cB-7h for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:29 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 55/CC-03612-8FAD3A95; Mon, 28 Aug 2017 08:57:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRWlGSWpSXmKPExsXiVRtsqPv91uJ Ig73P9C2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owvpy8wFuzwrLi5uYmlgXGnTRcjJ4eQwHRG iaMnc7sYuThYBOYxS+z9cJsNxJEQ6GeVePToDStIlYRAmsSKhjXMEHaZxOdlq5ghurUkjp6az Qph72eSWNrH38XIwcEmYCIxq0MCJCwioCRxb9VkJpCZzALzGSWaJvWygSSEBaIkJqzYCzaHRU BVYu3qAywgvbwCPhL3NhZCrJKTuHmuE6yEEyi8Y+1ddohV3hJdrz+wTmAUWMDIsIpRvTi1qCy 1SNdCL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMKgYgGAH4+zL/ocYJTmYlER5 d1YsjhTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwXvmJlBOsCg1PbUiLTMHGN4waQkOHiUR3g8ga d7igsTc4sx0iNQpRl2OSQe2f2ESYsnLz0uVEud9CFIkAFKUUZoHNwIWa5cYZaWEeRmBjhLiKU gtys0sQZV/xSjOwagkzPsXZApPZl4J3KZXQEcwAR2hKLgQ5IiSRISUVAPjdqXdUetKFhT+Xtv K5e32aoJ8sNfOq5Hf2rjzSpt11yitW3A2YoZB6C3eV2I2XBamdi5r1OcknI5h+VVqmv7/KO9v /wlTGPak+P1Msr5T0OZVoHfFQVxMRp0j4RrfcTdRBYnZqpp1c/w4vvxq290cabs8VHaDSv+6Y pM9renx1fe9NeZeV1NiKc5INNRiLipOBABn5eHdsAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1503910646!104229659!1 X-Originating-IP: [74.125.83.49] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26254 invoked from network); 28 Aug 2017 08:57:27 -0000 Received: from mail-pg0-f49.google.com (HELO mail-pg0-f49.google.com) (74.125.83.49) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:27 -0000 Received: by mail-pg0-f49.google.com with SMTP id 83so22179991pgb.4 for ; Mon, 28 Aug 2017 01:57:27 -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=yN/dRo67pbmLqMoNSi7CzmRU3B/Bnu+PsAldLb+rZdk=; b=eFlk0+k9F5M98RYIJJtLbOBsHD1S2rOnhX2rCGzIXK5Fp19WxumM8JLrtHXGqMzqij oyeODIwSrRmSyVb3BEvlOYSzRwIDsfYVxyHRSK8PIrgB0NyWXNS6nRjTEATjGuHL+eaY hnS03wcr+qgJpdzWZcZwYlhLhmK0mComWCxSs= 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=yN/dRo67pbmLqMoNSi7CzmRU3B/Bnu+PsAldLb+rZdk=; b=bfVrkmYTioVjgf/KTO+fpBjTQHtsRpN9CH+ERsDK3IXb1uFpGazs4fku0vtMjE/z72 W2IpuGR6WYGkQ+vq0e62gsxaJjku/oRUMs0kZ93OJh3ryi+xZULcGiJXtyvg6TAZW/I0 hNkFLD5rCuF2msqj2mkUVNDo6iky84D2PsALsm60zyGQDKuyPR8t90bZowPphD8wQwT3 Ooayr/elgs5+9IVzJ8GS1mRnAirTat7fbKH4NDKSsa1GbX54/7kEDeDiyzEBCsfXuz36 IfvD73QNLZxJvu46HyadzJX9OTGwxMjkMJOtBY/sMRi2WUTobU49z4cj/QxGPmdegO86 Bycg== X-Gm-Message-State: AHYfb5i/n8OHq0XU2pdEcOu5+VVyKQjqdnmuhSop/48pRpRuE9s6Elil hhHgtzeeeJuVOzIdk7yjNQ== X-Received: by 10.99.48.7 with SMTP id w7mr6591589pgw.244.1503910646002; Mon, 28 Aug 2017 01:57:26 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:25 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:04 +0530 Message-Id: <1503910570-24427-22-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 21/27 v8] xen/arm: vpl011: Add support for multiple consoles in xenconsole 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" This patch adds the support for multiple consoles and introduces the iterator functions to operate on multiple consoles. The functions called by the iterators check that they are operating on valid I/O parameters. This ensures that if a particular console is not initialized then the functions will not do anything for that console type. This patch is in preparation to support a new vuart console. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this patch in multiple smaller patches. Changes since v4: - Changes to make event channel handling per console rather than per domain. Changes since v3: - The changes in xenconsole have been split into four patches. This is the third patch. tools/console/daemon/io.c | 160 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 126 insertions(+), 34 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 71465a0..a198dbb 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -90,12 +90,14 @@ struct buffer { }; struct console { + char *ttyname; int master_fd; int master_pollfd_idx; int slave_fd; int log_fd; struct buffer buffer; char *xspath; + char *log_suffix; int ring_ref; xenevtchn_handle *xce_handle; int xce_pollfd_idx; @@ -107,21 +109,109 @@ struct console { struct domain *d; }; +struct console_type { + char *xsname; + char *ttyname; + char *log_suffix; +}; + +static struct console_type console_type[] = { + { + .xsname = "/console", + .ttyname = "tty", + .log_suffix = "", + }, +}; + +#define NUM_CONSOLE_TYPE (sizeof(console_type)/sizeof(struct console_type)) + struct domain { int domid; bool is_dead; unsigned last_seen; struct domain *next; - struct console console; + struct console console[NUM_CONSOLE_TYPE]; }; static struct domain *dom_head; +typedef void (*VOID_ITER_FUNC_ARG1)(struct console *); +typedef int (*INT_ITER_FUNC_ARG1)(struct console *); +typedef void (*VOID_ITER_FUNC_ARG2)(struct console *, void *); +typedef int (*INT_ITER_FUNC_ARG3)(struct console *, + struct domain *dom, void **); + static inline bool console_enabled(struct console *con) { return con->local_port != -1; } +static inline void console_iter_void_arg1(struct domain *d, + VOID_ITER_FUNC_ARG1 iter_func) +{ + unsigned int i; + struct console *con = &d->console[0]; + + for (i = 0; i < NUM_CONSOLE_TYPE; i++, con++) { + iter_func(con); + } +} + +static inline void console_iter_void_arg2(struct domain *d, + VOID_ITER_FUNC_ARG2 iter_func, + void *iter_data) +{ + unsigned int i; + struct console *con = &d->console[0]; + + for (i = 0; i < NUM_CONSOLE_TYPE; i++, con++) { + iter_func(con, iter_data); + } +} + +static inline int console_iter_int_arg1(struct domain *d, + INT_ITER_FUNC_ARG1 iter_func) +{ + unsigned int i; + int ret; + struct console *con = &d->console[0]; + + for (i = 0; i < NUM_CONSOLE_TYPE; i++, con++) { + /* + * Zero return values means success. + * + * Non-zero return value indicates an error in which + * case terminate the loop. + */ + ret = iter_func(con); + if (ret) + break; + } + return ret; +} + +static inline int console_iter_int_arg3(struct domain *d, + INT_ITER_FUNC_ARG3 iter_func, + void **iter_data) +{ + unsigned int i; + int ret; + struct console *con = &d->console[0]; + + for (i = 0; i < NUM_CONSOLE_TYPE; i++, con++) { + /* + * Zero return values means success. + * + * Non-zero return value indicates an error in which + * case terminate the loop. + */ + ret = iter_func(con, d, iter_data); + if (ret) + break; + } + return ret; +} + static int write_all(int fd, const char* buf, size_t len) { while (len) { @@ -336,7 +426,9 @@ static int create_console_log(struct console *con) return -1; } - snprintf(logfile, PATH_MAX-1, "%s/guest-%s.log", log_dir, data); + snprintf(logfile, PATH_MAX-1, "%s/guest-%s%s.log", + log_dir, data, con->log_suffix); + free(data); logfile[PATH_MAX-1] = '\0'; @@ -488,7 +580,7 @@ static int console_create_tty(struct console *con) } free(path); - success = (asprintf(&path, "%s/tty", con->xspath) != -1); + success = (asprintf(&path, "%s/%s", con->xspath, con->ttyname) != -1); if (!success) goto out; success = xs_write(xs, XBT_NULL, path, slave, strlen(slave)); @@ -654,13 +746,13 @@ static bool watch_domain(struct domain *dom, bool watch) { char domid_str[3 + MAX_STRLEN(dom->domid)]; bool success; - struct console *con = &dom->console; + struct console *con = &dom->console[0]; snprintf(domid_str, sizeof(domid_str), "dom%u", dom->domid); if (watch) { success = xs_watch(xs, con->xspath, domid_str); if (success) - console_create_ring(con); + console_iter_int_arg1(dom, console_create_ring); else xs_unwatch(xs, con->xspath, domid_str); } else { @@ -670,11 +762,13 @@ static bool watch_domain(struct domain *dom, bool watch) return success; } -static int console_init(struct console *con, struct domain *dom) +static int console_init(struct console *con, struct domain *dom, void **data) { char *s; int err = -1; struct timespec ts; + struct console_type **con_type = (struct console_type **)data; + char *xsname, *xspath; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d", @@ -692,15 +786,21 @@ static int console_init(struct console *con, struct domain *dom) con->xce_pollfd_idx = -1; con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; con->d = dom; - con->xspath = xs_get_domain_path(xs, dom->domid); - s = realloc(con->xspath, strlen(con->xspath) + - strlen("/console") + 1); + con->ttyname = (*con_type)->ttyname; + con->log_suffix = (*con_type)->log_suffix; + xsname = (char *)(*con_type)->xsname; + xspath = xs_get_domain_path(xs, dom->domid); + s = realloc(xspath, strlen(xspath) + + strlen(xsname) + 1); if (s) { - con->xspath = s; - strcat(con->xspath, "/console"); + xspath = s; + strcat(xspath, xsname); + con->xspath = xspath; err = 0; } + (*con_type)++; + return err; } @@ -713,7 +813,7 @@ static void console_free(struct console *con) static struct domain *create_domain(int domid) { struct domain *dom; - struct console *con; + struct console_type *con_type = &console_type[0]; dom = calloc(1, sizeof *dom); if (dom == NULL) { @@ -723,9 +823,8 @@ static struct domain *create_domain(int domid) } dom->domid = domid; - con = &dom->console; - if (console_init(con, dom)) + if (console_iter_int_arg3(dom, console_init, (void **)&con_type)) goto out; if (!watch_domain(dom, true)) @@ -738,7 +837,7 @@ static struct domain *create_domain(int domid) return dom; out: - console_free(con); + console_iter_void_arg1(dom, console_free); free(dom); return NULL; } @@ -784,11 +883,9 @@ static void console_cleanup(struct console *con) static void cleanup_domain(struct domain *d) { - struct console *con = &d->console; + console_iter_void_arg1(d, console_close_tty); - console_close_tty(con); - - console_cleanup(con); + console_iter_void_arg1(d, console_cleanup); remove_domain(d); } @@ -803,12 +900,10 @@ static void console_close_evtchn(struct console *con) static void shutdown_domain(struct domain *d) { - struct console *con = &d->console; - d->is_dead = true; watch_domain(d, false); - console_unmap_interface(con); - console_close_evtchn(con); + console_iter_void_arg1(d, console_unmap_interface); + console_iter_void_arg1(d, console_close_evtchn); } static unsigned enum_pass = 0; @@ -1003,7 +1098,7 @@ static void handle_xs(void) /* We may get watches firing for domains that have recently been removed, so dom may be NULL here. */ if (dom && dom->is_dead == false) - console_create_ring(&dom->console); + console_iter_int_arg1(dom, console_create_ring); } free(vec); @@ -1058,9 +1153,7 @@ static void handle_log_reload(void) if (log_guest) { struct domain *d; for (d = dom_head; d; d = d->next) { - struct console *con = &d->console; - - console_open_log(con); + console_iter_void_arg1(d, console_open_log); } } @@ -1223,13 +1316,13 @@ void handle_io(void) /* Re-calculate any event counter allowances & unblock domains with new allowance */ for (d = dom_head; d; d = d->next) { - struct console *con = &d->console; - console_evtchn_unmask(con, (void *)now); + console_iter_void_arg2(d, console_evtchn_unmask, (void *)now); - maybe_add_console_evtchn_fd(con, (void *)&next_timeout); + console_iter_void_arg2(d, maybe_add_console_evtchn_fd, + (void *)&next_timeout); - maybe_add_console_tty_fd(con); + console_iter_void_arg1(d, maybe_add_console_tty_fd); } /* If any domain has been rate limited, we need to work @@ -1290,13 +1383,12 @@ void handle_io(void) } for (d = dom_head; d; d = n) { - struct console *con = &d->console; n = d->next; - handle_console_ring(con); + console_iter_void_arg1(d, handle_console_ring); - handle_console_tty(con); + console_iter_void_arg1(d, handle_console_tty); if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Mon Aug 28 08:56:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111126 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548240qge; Mon, 28 Aug 2017 01:59:01 -0700 (PDT) X-Received: by 10.107.59.22 with SMTP id i22mr5454568ioa.59.1503910741819; Mon, 28 Aug 2017 01:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910741; cv=none; d=google.com; s=arc-20160816; b=SiWCc42/EqibAPOnD40UKiCPeMfTv42Fj7yoo4hBFixQEGp8StmYSxiKl/CjLQOkWM kLBKfS2A4KNkUAxx+xxJPlGDIuLlvrcQFlFZDwt91SdfNCUqYiaP2WgV4YR7HycPXVBr KbgzOdnqDxqffs5BUPvBmWpXT/+FQbfUF5j5w0boDZDwoXEqfNJHd+48uo9oM1gsHkEG cRQq8Pv5AupXYpp1hT7X+4uVOeAxdzEGOty2O/lGoy0yJnJGnpMBchqExlvctqROs/ip kdfA6lMWT5B0d/u87R8H1A2pwHxJmkid2Abw1mNUpafDCF7pymyMyA7nbQxR5Lx3K4FZ YUPQ== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Trv1/zx6YeF/sP+fhifQcUyBhunmFBT3EKtTWs/eid8=; b=Lyd52NkhMMrpH/pt1o3z/2c8s/fnlbPMyi9bm9W2hBnL+syKqbZZgNJTzl6uKu9ryz k910ofMCuIaiwEXk/3IqOyBTH06CH9pmvltvNoOA37gsAxZw87rJ0qdGpyTf7lowJm2u zke7WYqObKWA1TQAevxXbhoVZBN9GrNrMizWi6/vjsepG65FyoOr0mlhselab12bBXw+ xc1UyHqRw0t4qAl7zOBRM8xecjj0AhPzgVCgk7NxN84dDzqMhg9ar+g+zdGf9E9LO8M+ 4D/UuhO+9wjgOFQ+8sJHsWvj8aIMnT4alfuTbE/iqVYAIqKgOUaRKHaqipWxAPMpb69B 5cBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KxTZJR8t; 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 r82si7511879itr.70.2017.08.28.01.59.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:59:01 -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 header.s=google header.b=KxTZJR8t; 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 1dmFrS-0005m3-Mr; Mon, 28 Aug 2017 08:57:34 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFrR-0005jh-D2 for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:33 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id FB/F7-03406-CFAD3A95; Mon, 28 Aug 2017 08:57:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsXiVRtspvvn1uJ Ig5OHuCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oylT38yFRxWqTj2ayNjA+N3uS5GLg4hgZmM EjsXr2cBcVgE5jFLbGs6B+ZICPSzSpx7fZWti5ETyEmT2HvlPiOEXSZx/f0eJhBbSEBL4uip2 awQo/YzSfRMuwzkcHCwCZhIzOqQAKkREVCSuLdqMhNIDbPAcyaJQxO+MoMkhAXCJLav284CYr MIqEq8/tHIDNLLK+Ajsft9GMQuOYmb5zrByjmBwjvW3mWH2Ost0fX6A+sERoEFjAyrGDWKU4v KUot0jUz1kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECQ4sBCHYwrloQeIhRkoNJ SZR3Z8XiSCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvGduAuUEi1LTUyvSMnOAQQ6TluDgURLh/ QCS5i0uSMwtzkyHSJ1itOTYsHr9FyaOSQe2A8kDM35+YxJiycvPS5US5/UBaRAAacgozYMbB4 vES4yyUsK8jEAHCvEUpBblZpagyr9iFOdgVBLm/QsyhSczrwRu6yugg5iADlIUXAhyUEkiQkq qgVF90/Kf666I2hYHOlybs3yVr4SZrV3VJL+gmHA7hQPuZ86vEFsjfovlrrid0OtdM27bpbJe 9PgplmvJG1VhEPHGuaGurPi4t9DWix4VtkIBG78Krar47LpfYm3YKeMFFscnGr4531baJjh3u /yd+VK9dqJ/crwNboic1qpPsamJ5+L50vDkqhJLcUaioRZzUXEiACloLlW/AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-16.tower-21.messagelabs.com!1503910650!67906207!1 X-Originating-IP: [74.125.83.54] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23056 invoked from network); 28 Aug 2017 08:57:31 -0000 Received: from mail-pg0-f54.google.com (HELO mail-pg0-f54.google.com) (74.125.83.54) by server-16.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:31 -0000 Received: by mail-pg0-f54.google.com with SMTP id r133so22216439pgr.3 for ; Mon, 28 Aug 2017 01:57:31 -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=iToIwGqkOk3EV+/SAzPt8OcAvVkxtUVktVFs4rj+kJc=; b=KxTZJR8tqjOGNK4G4BoOdw5njq4lVRpJbeUoCIZGhVOxgHKFbFJrJqWV6e8VXghaet UqsPGHQKoS1vEU4OYe1dFlg0xm7O1Meh40PTg3jVJek3rpT+ecD3m/8pdN4sHqF5ukfh C/n97BF8Klg6gauVkyS6bYTa24begZRaR6DJo= 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=iToIwGqkOk3EV+/SAzPt8OcAvVkxtUVktVFs4rj+kJc=; b=Umy+8fMbttTQQ0c77cvI9eIVkUeaSWFcqb2Rq8muYjFhzLpA2ZpjGMadVpDG3FXqOQ z1xKgXhLSy3drsNya0j5OmXKsTKV9K5XeBji24+996i6iXnuDX3N8KGBfYUOZz9fFv+L Y0eC2L6wh1K5Iid3fBhCHpDrCLwcSowrX8HM6r8RwXTceEzAXqfhv1h3h9KV15b2U1CG 0b7qSSTIXOjKdZjeHI7enKy+NHJX+A3Ik+By+UK32gdR68UeB6uHP+EnG3NMaQ3e55F5 FFnc1a5ZUtS2Sbum4Uq4i4ul7lpraqsIWG4sqW1Ap267wKHsM1rV3gLlbnkdTntu3QLW r+LQ== X-Gm-Message-State: AHYfb5g0UCIFoftl7xPMGD9+27WhqJIBd0Hpyf/AI21VOFJfBhygv2TZ ++MLbKFUTpLKPFMyrDt5Hw== X-Received: by 10.99.96.1 with SMTP id u1mr5205266pgb.121.1503910650305; Mon, 28 Aug 2017 01:57:30 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:29 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:05 +0530 Message-Id: <1503910570-24427-23-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 22/27 v8] xen/arm: vpl011: Add support for vuart console in xenconsole 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" This patch finally adds the support for vuart console. It adds two new fields in the console initialization: - optional - use_gnttab optional flag tells whether the console is optional. use_gnttab tells whether the ring buffer should be allocated using grant table. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Andrew Cooper CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall Changes since v6: - Renames prefer_gnttab to use_gnttab Changes since v4: - Renamed VUART_CFLAGS- to CFLAGS_vuart- in the Makefile as per the convention. config/arm32.mk | 1 + config/arm64.mk | 1 + tools/console/Makefile | 3 ++- tools/console/daemon/io.c | 30 ++++++++++++++++++++++++++++-- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/config/arm32.mk b/config/arm32.mk index f95228e..b9f23fe 100644 --- a/config/arm32.mk +++ b/config/arm32.mk @@ -1,5 +1,6 @@ CONFIG_ARM := y CONFIG_ARM_32 := y +CONFIG_VUART_CONSOLE := y CONFIG_ARM_$(XEN_OS) := y CONFIG_XEN_INSTALL_SUFFIX := diff --git a/config/arm64.mk b/config/arm64.mk index aa45772..861d0a4 100644 --- a/config/arm64.mk +++ b/config/arm64.mk @@ -1,5 +1,6 @@ CONFIG_ARM := y CONFIG_ARM_64 := y +CONFIG_VUART_CONSOLE := y CONFIG_ARM_$(XEN_OS) := y CONFIG_XEN_INSTALL_SUFFIX := diff --git a/tools/console/Makefile b/tools/console/Makefile index abe77b2..e7ff8ff 100644 --- a/tools/console/Makefile +++ b/tools/console/Makefile @@ -11,6 +11,7 @@ LDLIBS += $(SOCKET_LIBS) LDLIBS_xenconsoled += $(UTIL_LIBS) LDLIBS_xenconsoled += -lrt +CFLAGS_vuart-$(CONFIG_VUART_CONSOLE) = -DCONFIG_VUART_CONSOLE BIN = xenconsoled xenconsole @@ -28,7 +29,7 @@ clean: distclean: clean daemon/main.o: daemon/_paths.h -daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) +daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) $(CFLAGS_vuart-y) xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c)) $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_xenconsoled) $(APPEND_LDFLAGS) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a198dbb..90aea8a 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -107,12 +107,16 @@ struct console { xenevtchn_port_or_error_t remote_port; struct xencons_interface *interface; struct domain *d; + bool optional; + bool use_gnttab; }; struct console_type { char *xsname; char *ttyname; char *log_suffix; + bool optional; + bool use_gnttab; }; static struct console_type console_type[] = { @@ -120,7 +124,18 @@ static struct console_type console_type[] = { .xsname = "/console", .ttyname = "tty", .log_suffix = "", + .optional = false, + .use_gnttab = true, }, +#if defined(CONFIG_VUART_CONSOLE) + { + .xsname = "/vuart/0", + .ttyname = "tty", + .log_suffix = "-vuart0", + .optional = true, + .use_gnttab = false, + }, +#endif }; #define NUM_CONSOLE_TYPE (sizeof(console_type)/sizeof(struct console_type)) @@ -654,8 +669,17 @@ static int console_create_ring(struct console *con) "ring-ref", "%u", &ring_ref, "port", "%i", &remote_port, NULL); - if (err) + + if (err) { + /* + * This is a normal condition for optional consoles: they might not be + * present on xenstore at all. In that case, just return without error. + */ + if (con->optional) + err = 0; + goto out; + } snprintf(path, sizeof(path), "%s/type", con->xspath); type = xs_read(xs, XBT_NULL, path, NULL); @@ -669,7 +693,7 @@ static int console_create_ring(struct console *con) if (ring_ref != con->ring_ref && con->ring_ref != -1) console_unmap_interface(con); - if (!con->interface && xgt_handle) { + if (!con->interface && xgt_handle && con->use_gnttab) { /* Prefer using grant table */ con->interface = xengnttab_map_grant_ref(xgt_handle, dom->domid, GNTTAB_RESERVED_CONSOLE, @@ -788,6 +812,8 @@ static int console_init(struct console *con, struct domain *dom, void **data) con->d = dom; con->ttyname = (*con_type)->ttyname; con->log_suffix = (*con_type)->log_suffix; + con->optional = (*con_type)->optional; + con->use_gnttab = (*con_type)->use_gnttab; xsname = (char *)(*con_type)->xsname; xspath = xs_get_domain_path(xs, dom->domid); s = realloc(xspath, strlen(xspath) + From patchwork Mon Aug 28 08:56:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111123 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548201qge; Mon, 28 Aug 2017 01:58:59 -0700 (PDT) X-Received: by 10.36.163.140 with SMTP id p134mr5913823ite.64.1503910739617; Mon, 28 Aug 2017 01:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910739; cv=none; d=google.com; s=arc-20160816; b=Rp6wYHPsNYnjldQYNn5KKe3zrIak7A4rmDAQ6+oy8F9S5Mic9/FFtBWQ1sfLiYnu1K /ZEyZgGag4esxDmUV4hYgbfSe5WBF6UvbpLl04dP7kculS0ZPJIN/KZSul8VAVi1pjGy 703ObPhn5OtQa6KvVixYtgKgBcHXluh56ZO1IQ7r/KX4ax2Q0GbuXGFhS0eYR3FvKGux yKOMTr01ZPddJaehT/SiapdyKI3SAv5ENy+dB3+deWkv4fovuqbMt1FtmDiRqCOqWxha yKmTfEybDp1ynpNrJcSleQjdNawE3Hb2GcCjvPVJNdsaK2zG2EImg1uc0bV1ZGt0KvyI YcwQ== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=pJyNIWfhAVo2E2CgMcfI/HHFeP51uQR9/ksH+7RgARQ=; b=sRxX4cyNUBYEkLQbQfr1K4f/P/ykWaImLRPK555q28KMM3XR5bRIRJ0tkxy7TjCTCM 6k0kwPDHPbvw2Gc5IkLq6rQovjP2tRALZ5WUirwOybzgz2D/s85nB32qdae1fVmOrC32 uxD9jdJZx4wyS/O4ysXRjrgHjDTMmYVfYjXwt4GZZZmYv6udqq9dt97iL8V7l70yDDZF TYOO5sZSAua/dnZ9rQaubwtqDcp26Ge7n8pFHm9UI/51WdYKRjwuaqSWg98VeLcBjxKB t2C7HzNx/0OJpWyYgLI0N5p/8r/9eDigOIQ6o2dF1VUeWduO2ejMg3MQOROpQtyAQUSb /pSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=A7kLQhVL; 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 n63si12137480iod.303.2017.08.28.01.58.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:59 -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 header.s=google header.b=A7kLQhVL; 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 1dmFrY-0005uu-UK; Mon, 28 Aug 2017 08:57:40 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFrX-0005s9-DL for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:39 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id B7/19-01994-20BD3A95; Mon, 28 Aug 2017 08:57:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRusq/v/1uJ Ig81XWSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozGWavZCy6LVpxbuoG9gXG2YBcjF4eQwHRG iXNnFjKCOCwC85glnn25CuZICPSzSpzpOQfkcAA5aRKbd9p1MXICmVUSj7dPZQSxhQS0JI6em s0KMWk/k8T0CXdYQOrZBEwkZnVIgNSICChJ3Fs1mQmkhllgPqNE06ReNpCEsECMxO35H5hBbB YBVYkra+aD9fIK+EhMfpQMsUtO4ua5TrASTqDwjrV32SH2ekt0vf7AOoFRYAEjwypG9eLUorL UIl0jvaSizPSMktzEzBxdQwNTvdzU4uLE9NScxKRiveT83E2MwLBiAIIdjN//OB1ilORgUhLl 3VmxOFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO+Zm0A5waLU9NSKtMwcYIDDpCU4eJREeD+Ap HmLCxJzizPTIVKnGHU5Jh3Y/oVJiCUvPy9VSpz3IUiRAEhRRmke3AhYtF1ilJUS5mUEOkqIpy C1KDezBFX+FaM4B6OSMO9fkCk8mXklcJteAR3BBHSEouBCkCNKEhFSUg2Mkmwf92xYvfzZgW4 fjwmlIpyMe6yvxkqe1EqRD0+tFnS83LZlqX7GjWlWix42Xs86/mRex18Vt+IFW5xlj6oeNG/g +uPdPyWTLWx1W8jbA9MfTi/96cEt8be058/i9TuqQvS0LiycfrLnaXIhn+u3NYuO/t2QqXGO+ +68GGE2/Y0+Jm3Nb/t3KLEUZyQaajEXFScCAP+h5zmxAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-206.messagelabs.com!1503910653!70320157!1 X-Originating-IP: [74.125.83.45] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64234 invoked from network); 28 Aug 2017 08:57:34 -0000 Received: from mail-pg0-f45.google.com (HELO mail-pg0-f45.google.com) (74.125.83.45) by server-14.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:34 -0000 Received: by mail-pg0-f45.google.com with SMTP id 63so22245386pgc.2 for ; Mon, 28 Aug 2017 01:57:34 -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=HWroLNIkhQjYUcAWyd7ghBserWIB9IYYwUwfhZwGLVc=; b=A7kLQhVLzwmJ68Agz3vBd2BRWmjq3FEfUHoFsAaVhNL+nTqQ2nMSYInvwF8dmtd6us 3M2qCFjFN/kWPu3cpPU/YeI7vFjh7YGHLULJ9vYlL7XnaDB773vzBcuGFWdPR0bwen8q a9Z3EJYeH6QaWFMMkzbF53hNOZ8+NCDhWcN6I= 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=HWroLNIkhQjYUcAWyd7ghBserWIB9IYYwUwfhZwGLVc=; b=GfFg4aIngJkA/yduBVRC9dmFC1clfxq41j3mGBxHLsSNN5jI25j/dB63oKph8Fxjqn hsZOTh/NDJda7b+S4H+SxCzkyFyO9fdJ6E0MxPZQKk3qzASlDR9RFnZH/xGIoPKv8t+F M8Nk9CN/6d+HFJW9D6KrsZ0b9ZffMgyCys3E6hvkKbcxmcYp9763qgzeoW7ku8mS79Bc YGWSuV/4cmRN6m84crJkKf/yvVeX2Q5+Q7oEPipDDWTVwMPvR74YN6PUwMg0CVW3uSdX fIYmtW4xQ4jpxhdQh+xTsZ1/Iu77MUzZdWbhPRX8lRUEk46Y86noQh7H6zzYcUE4NQUZ m7Fg== X-Gm-Message-State: AHYfb5jyOX8B1sfmyYRwnPPIvCQFgRbswVnTbwIrvL4Q4K3uGzdckvsC 7AjGBcacg3p7lL/S1Lhddw== X-Received: by 10.98.198.210 with SMTP id x79mr6700743pfk.115.1503910653261; Mon, 28 Aug 2017 01:57:33 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:32 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:06 +0530 Message-Id: <1503910570-24427-24-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 23/27 v8] xen/arm: vpl011: Add a new vuart console type to xenconsole client 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 a new console type VUART to connect to guest's emualated vuart console. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Removed the vuart compile time flag so that vuart code is compiled always. Changes since v3: - The vuart console support is under CONFIG_VUART_CONSOLE option. - Since there is a change from last review, I have not included reviewed-by tag from Stefano and acked-by tag from Wei. tools/console/client/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index c340cb7..f92ad3d 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -76,7 +76,7 @@ static void usage(const char *program) { "\n" " -h, --help display this help and exit\n" " -n, --num N use console number N\n" - " --type TYPE console type. must be 'pv' or 'serial'\n" + " --type TYPE console type. must be 'pv', 'serial' or 'vuart'\n" " --start-notify-fd N file descriptor used to notify parent\n" , program); } @@ -264,6 +264,7 @@ typedef enum { CONSOLE_INVAL, CONSOLE_PV, CONSOLE_SERIAL, + CONSOLE_VUART, } console_type; static struct termios stdin_old_attr; @@ -344,6 +345,7 @@ int main(int argc, char **argv) char *end; console_type type = CONSOLE_INVAL; bool interactive = 0; + char *console_names = "serial, pv, vuart"; while((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) { switch(ch) { @@ -359,9 +361,12 @@ int main(int argc, char **argv) type = CONSOLE_SERIAL; else if (!strcmp(optarg, "pv")) type = CONSOLE_PV; + else if (!strcmp(optarg, "vuart")) + type = CONSOLE_VUART; else { fprintf(stderr, "Invalid type argument\n"); - fprintf(stderr, "Console types supported are: serial, pv\n"); + fprintf(stderr, "Console types supported are: %s\n", + console_names); exit(EINVAL); } break; @@ -437,6 +442,10 @@ int main(int argc, char **argv) else snprintf(path, strlen(dom_path) + strlen("/device/console/%d/tty") + 5, "%s/device/console/%d/tty", dom_path, num); } + if (type == CONSOLE_VUART) { + snprintf(path, strlen(dom_path) + strlen("/vuart/0/tty") + 1, + "%s/vuart/0/tty", dom_path); + } /* FIXME consoled currently does not assume domain-0 doesn't have a console which is good when we break domain-0 up. To keep us From patchwork Mon Aug 28 08:56:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111125 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548258qge; Mon, 28 Aug 2017 01:59:02 -0700 (PDT) X-Received: by 10.36.175.91 with SMTP id l27mr4568346iti.86.1503910742829; Mon, 28 Aug 2017 01:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910742; cv=none; d=google.com; s=arc-20160816; b=g0BXfchpk5Ag122W3UShieqUWHKv2FZccEywqcXgWvmsIKRPdSmm1x3uxkq609QMOp lozH+riAFN+6jWj2pdEuIAPcPDeQE2lgsm89AKzRSndNPT1A2JyV3Wdf2cMnV8hk7WhQ 2+SEkGt4RUspXcOBCT8GCbT1tuwOQEnrUTQRVcKzriR7fDq77sbEurdLZUONge9u+N+K thTZpsPGfO2gjU5Y3Luk59/NPjHIfVaok7wkN02otbebH+5kWuj/6LoJooRj9wwkCH2f ho2OukhCG9jhqFn55yV1sTVDAEQPhuvFR5t6p4Ldx1JPfNrfZc+QlrtYGnK5TloHp+Us rDjg== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=reEnHU+RFUemo9y4N2qY2JsFnDWqND/ps0F19rbkvow=; b=V9XBZ0i5VPQqUxV8GcXaxp0uVy4Jh755knb33in5ujTyqC2YFGmDJHiRsTSmDgzl2v LXB7M9/11FmoOxUSx8pSA9QA105cAJeZPv6MSkmbWDHvTUnZbpJKd6fWALZVgw3KYrwk G9ErrIc7RFmf9i66BVSJVPb9oplNvpZIJZRoEUXQ1G/RBAodQjoXSsXdNTwpT9zthWN1 N0w04BuEggnMCceRAQoi04k5LFKgeM8oEQGxC/Nt+BTNvZIHtgkxUkRYELkzqmaP9Ofj naJFxZIDLQ5wDbcNYZp+FW8gqndgk1fV/b1YYYrBeh5xHvjaIRoJjLdNaCHZBZ/WtTQn tscw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=f/SJ6wqd; 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 g198si11976800iog.12.2017.08.28.01.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:59:02 -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 header.s=google header.b=f/SJ6wqd; 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 1dmFrZ-0005vW-5q; Mon, 28 Aug 2017 08:57:41 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFrX-0005sO-IR for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:39 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id A6/30-03937-20BD3A95; Mon, 28 Aug 2017 08:57:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfTANl2m24s jDXou8Fh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmvp31hL5ihVtH72rWBsU+2i5GLQ0hgJqPE 9L8PWEAcFoF5zBIfJq1kBHEkBPpZJW4uPcHUxcgJ5KRJXNtwnQXCrpSY8PYvO4gtJKAlcfTUb FaIUfuZJPZ07AFyODjYBEwkZnVIgNSICChJ3Fs1mQmkhllgPqNE06ReNpCEsECMxLnbl8EWsA ioSpye/x4szivgI7HgVgsjxDI5iZvnOplBbE6g+I61d6EWe0t0vf7AOoFRYAEjwypG9eLUorL UIl1TvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MwMBiAIIdjNMv+x9ilORgUhLl 3VmxOFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO+Zm0A5waLU9NSKtMwcYIjDpCU4eJREeD+Ap HmLCxJzizPTIVKnGI05rlxZ94WJY8qB7V+YhFjy8vNSpcR5H4KUCoCUZpTmwQ2Cxd4lRlkpYV 5GoNOEeApSi3IzS1DlXzGKczAqCfMeBJnCk5lXArfvFdApTECnKAouBDmlJBEhJdXAqCm+Xai 4vqdu5gY1Ie52kbPiR+tla2bpeazysRLj4N3lNSf3PvMz5b3xj/foTLz14zWnQO+TuU9aDBx9 9JX+Fxxcf+Ps1Km2KtUC/45JP49ctbdaetMC3y4et30lRq0frFaKis5vPuDT3rhy8Z/I7bsea LZOXmlSW7S0Zc/VuFsP3tgxfXrgrsRSnJFoqMVcVJwIADWm01a4AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-27.messagelabs.com!1503910656!113454592!1 X-Originating-IP: [209.85.192.182] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2389 invoked from network); 28 Aug 2017 08:57:37 -0000 Received: from mail-pf0-f182.google.com (HELO mail-pf0-f182.google.com) (209.85.192.182) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:37 -0000 Received: by mail-pf0-f182.google.com with SMTP id h75so14507625pfh.1 for ; Mon, 28 Aug 2017 01:57:37 -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=dolSTdF8lhTDbVu9x2jD3Q8HkG3OVWOfLoo5sgv1UPc=; b=f/SJ6wqdmcagM2EZAm43qu2ajjJVrOsEHEjwYNFzsF67bSEAxOG45Hq/o7JIVe4bUQ CkQw9/Yfjz6VPxSWXv9/bxZavEkKqkPr8kCuxNM0WrAUvV0vyHfA+DLygFDsGY4IcvbJ Uy8xMJaO7gMylMQ8AxYgn2qdcvwh1zibocQAA= 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=dolSTdF8lhTDbVu9x2jD3Q8HkG3OVWOfLoo5sgv1UPc=; b=hq2+e0MeKTIUslDTjC5GFKd6nQeCDPZ3a0V4PHcUhlGetyZ9ayjfiaPc6rmNTAOHig P53XvKHx3h3SQhOiKFCj088K6a++eKKpz7Dj3Z0erHl+RjyqfuVquPFCC+VtogOMqa1q KAqnXJRFZM/zmZes4QzhtHQvb0Is34HKU/AliLJXy00VJTWLyQTjPvkB/gePr3N/TF0I xQEJoxSwLOkOEX6Hv8TgAFIOwAsBtcQTjVUZ6cC5kLAO/X7zDChz2hUWNp0OUzjPMwe/ dw30rojJPHL2OvReEWUMGXeaDrMR4uAQYXfGJKp52VrR1ueovch08VPTbvVmQU4JeeJk 1kGg== X-Gm-Message-State: AHYfb5geJyJGp18F/0MJLthGuthEqeUrxZJYb2ZmHEZwDqiBPhMaUBP8 oRU+WfSQWiei16ne7P96bw== X-Received: by 10.98.215.10 with SMTP id b10mr3574410pfh.119.1503910656161; Mon, 28 Aug 2017 01:57:36 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:35 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:07 +0530 Message-Id: <1503910570-24427-25-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 24/27 v8] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree 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" The SBSA UART node format is as specified in Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt and given below: ARM SBSA defined generic UART ------------------------------ This UART uses a subset of the PL011 registers and consequently lives in the PL011 driver. It's baudrate and other communication parameters cannot be adjusted at runtime, so it lacks a clock specifier here. Required properties: - compatible: must be "arm,sbsa-uart" - reg: exactly one register range - interrupts: exactly one interrupt specifier - current-speed: the (fixed) baud rate set by the firmware Currently the baud rate of 115200 has been selected as a default value, which is one of the valid baud rate settings. Higher baud rate was selected since an emulated pl011 can support any valid baud rate without any limitation of the hardware. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v7: - Added a TODO to avoid conflict between vpl011 irq and user specified irqs. - Used a new bool vuart_enabled to explicitly set whether pl011 UART is enabled/disabled. Changes since v6: - Added a comment explaining why user specified IRQ should not conflict with vpl011 SPI. - Checking the vuart type explicitly against vpl011 enum type. - Removed uart-compat string and using "arm,sbsa-uart" string directly. - I have retained the reviewed-by/acked-by tags as these are minor changes. tools/libxl/libxl_arm.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index b8147f0..c0e496f 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -43,11 +43,38 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, { uint32_t nr_spis = 0; unsigned int i; + uint32_t vuart_irq; + bool vuart_enabled = false; + + /* + * If pl011 vuart is enabled then increment the nr_spis to allow allocation + * of SPI VIRQ for pl011. + */ + if (d_config->b_info.arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) { + nr_spis += (GUEST_VPL011_SPI - 32) + 1; + vuart_irq = GUEST_VPL011_SPI; + vuart_enabled = true; + } for (i = 0; i < d_config->b_info.num_irqs; i++) { uint32_t irq = d_config->b_info.irqs[i]; uint32_t spi; + /* + * This check ensures the if user has requested pass-through of a certain irq + * which conflicts with vpl011 irq then it flags an error to indicate to the + * user that the specific HW irq cannot be used as it is dedicated for vpl011. + * + * TODO: + * The vpl011 irq should be assigned such that it never conflicts with user + * specified irqs thereby preventing its pass-through. This TODO is for + * implementing that logic in future. + */ + if (vuart_enabled && irq == vuart_irq) { + LOG(ERROR, "Physical IRQ %u conflicting with pl011 SPI\n", irq); + return ERROR_FAIL; + } + if (irq < 32) continue; @@ -590,6 +617,38 @@ static int make_hypervisor_node(libxl__gc *gc, void *fdt, return 0; } +static int make_vpl011_uart_node(libxl__gc *gc, void *fdt, + const struct arch_info *ainfo, + struct xc_dom_image *dom) +{ + int res; + gic_interrupt intr; + + res = fdt_begin_node(fdt, "sbsa-pl011"); + if (res) return res; + + res = fdt_property_compat(gc, fdt, 1, "arm,sbsa-uart"); + if (res) return res; + + res = fdt_property_regs(gc, fdt, ROOT_ADDRESS_CELLS, ROOT_SIZE_CELLS, + 1, + GUEST_PL011_BASE, GUEST_PL011_SIZE); + if (res) return res; + + set_interrupt(intr, GUEST_VPL011_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); + + res = fdt_property_interrupts(gc, fdt, &intr, 1); + if (res) return res; + + /* Use a default baud rate of 115200. */ + fdt_property_u32(fdt, "current-speed", 115200); + + res = fdt_end_node(fdt); + if (res) return res; + + return 0; +} + static const struct arch_info *get_arch_info(libxl__gc *gc, const struct xc_dom_image *dom) { @@ -889,6 +948,9 @@ next_resize: FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) ); FDT( make_hypervisor_node(gc, fdt, vers) ); + if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) ); From patchwork Mon Aug 28 08:56:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111128 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548359qge; Mon, 28 Aug 2017 01:59:08 -0700 (PDT) X-Received: by 10.107.20.143 with SMTP id 137mr5378068iou.96.1503910748673; Mon, 28 Aug 2017 01:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910748; cv=none; d=google.com; s=arc-20160816; b=xB1IIeRmYDlJwq2+oTnAhm1aQ1hd7CSQMjOZeKLqH5F4dG+0MxgI0RbCEEeoYRmXza sMkLIjcDWRVdApXR9Oro1ixeEB9XLXec/YxoHblLxVifFumkJsDNEP3/aR5ppFubk1bf LASS5swmUx8F8yTbEMCPnH2kpG+hPS5GAjqSgeqkr5mBjIXGaj6kcqAK2jnQXDnoScPl UxIGRXPLaFQ4RoXKhuKBku1N6dh7Wv5kS6RsLr9b+xAJNqybJb7jyjicW3qLEfPGudme fXr/kSTq9OhJt+3eBpaMzUgHVMpFXj4yxkexQXPfAjvYYtx1ZyDQcovvLKXSKuHfmnPP fiHg== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=g2paoFP36Z2G8Am70pAqGgJ28/fYBnKzt3PJ5DFmXqg=; b=wNsN3tqfU6DAD5aQz30D77Q/i76ItmbFLXlftg/FNp4zhDvhe0WPvWg7uGyXuVNr/F Dt3MkAiR6D61cQ5hdMIGQC8ooDbZ+iy43znFb39ID1pXraSEuoTS/6z3j3i/H8q51362 QyTp1ycMyU+mLbxf1wx9y0I5YJ3xZ6mHg/cVXBUHsoNHa6WBP36v1SCCkGHMAd8wKaN4 1ePKGU0Yi7r/f+dFrd3uu2tojt5LTA2Nrz3MzK5wzuLkv5SQlC00Ew+2rOoku89PVu7s EqVLFfSfllst4Dgwj5sKkiQnfqp7Qn8dbP3HgE4vZhelbnLExvS+04qRbXXlyWaLFGls VSqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KRSIU8OI; 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 n13si8269332iti.61.2017.08.28.01.59.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:59:08 -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 header.s=google header.b=KRSIU8OI; 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 1dmFrc-00060f-Db; Mon, 28 Aug 2017 08:57: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 1dmFrb-0005zJ-SF for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:43 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id CA/ED-09901-70BD3A95; Mon, 28 Aug 2017 08:57:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsVyMfTAWl2224s jDTY0qVl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnTjrSzFHRoVrw/sJylgXGDUhcjF4eQwExG iaunrrOBOCwC85glvr14zAjiSAj0s0q8+XuDvYuRE8hJk1i6+CIbhF0qcaX9MZgtJKAlcfTUb FYIez+TxMZtrl2MHBxsAiYSszokQMIiAkoS91ZNZgKxmQWeM0lMu6QDYgsLREps6ljFCGKzCK hKfPpyFGwkr4CPxMmFe6HWykncPNfJDGJzAsV3rL3LDrHKW6Lr9QfWCYwCCxgZVjGqF6cWlaU W6ZroJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEhhUDEOxg7L7sf4hRkoNJSZR3 Z8XiSCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvCE3gXKCRanpqRVpmTnAAIdJS3DwKInw/rgBl OYtLkjMLc5Mh0idYjTmuHJl3RcmjikHtn9hEmLJy89LlRLn9QGZJABSmlGaBzcIFnmXGGWlhH kZgU4T4ilILcrNLEGVf8UozsGoJMzrDTKFJzOvBG7fK6BTmIBOURRcCHJKSSJCSqqBsXK3mG9 6xqHTK+VEd20/WP9Mmul+5mMBY+a+y19eLfGpXhLk8W5KYVnhvJeblO8fdHn0POC5LVecNt+d bV+5Nhro6/2NC0mXsXms5tM84V5ypOUhw74FvxNZBb3P6e9coDFf33qFjva2r1vCYkNnL1Gv/ fOIJWtZRPXhvTqr0qLagvg7DZ/yK7EUZyQaajEXFScCAI7QFhy3AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-27.messagelabs.com!1503910661!101313179!1 X-Originating-IP: [209.85.192.173] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5105 invoked from network); 28 Aug 2017 08:57:42 -0000 Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by server-14.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:42 -0000 Received: by mail-pf0-f173.google.com with SMTP id r62so14501053pfj.0 for ; Mon, 28 Aug 2017 01:57:42 -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=cSHu2U1ZfxFQQTkLTiZ5BW3g3nAvizN7zbMQVfp8XzY=; b=KRSIU8OIqvVkvWaWDovUFu3Af8sLF3Dt3iTsWgrs67s7FQUhiS+RnqPAKtBEvMvFIM qzTC+Zeo9U0JUN1U7Az8vgTvSb7A33LVarC8ubD1/BaSRxVXyyMV4Wuwbwdz5TnQy1VY 5x0ANrF+Bk7h2jzlwxHBEoljDZ8mJoITAYpzQ= 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=cSHu2U1ZfxFQQTkLTiZ5BW3g3nAvizN7zbMQVfp8XzY=; b=pNcKLKNeJ4kVmq6wuhawVQqzEzziuep6hOZftVPgiM8h+KOZ/NdfVolY/jAOnqiEdC q18PP4GKiFM9Rowfshb3epp8oZR+1rD2QDsIO+wx/q0kiJj8fq5FUzoKbA5xHm5gnZdJ WFvCYjvfGaqo7dP7AHgv8SUnaXXVW14gcwtQyOrpu0ts9cffy6v5FoHwNdLkymaF8Pwm DUcsVLRphX0c6jX1pl5K/dZWpOaWrEKDF7LwvzWc2a3/aAb1WXYipk2xtIuGLz9Hz4EB jyawAIyZTevmral0tCds9G1nQUn+Pa/MabRNVfsizne4585e/1BtSSxaYcBWHLktcQh2 aXhg== X-Gm-Message-State: AHYfb5gSHfanXEUEYk7LU2UEFFe+dX+d4XHeTetvx+HBT5zNxxuCv0MR ewjRZy9zwfuvfJgIxQ5CiA== X-Received: by 10.99.2.72 with SMTP id 69mr6767736pgc.42.1503910660747; Mon, 28 Aug 2017 01:57:40 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:40 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:08 +0530 Message-Id: <1503910570-24427-26-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 25/27 v8] xen/arm: vpl011: Update documentation for vuart console support 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" 1. Update documentation for a new vuart option added. 2. Update documentation about SPI irq reserved for vuart. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Andrew Cooper CC: George Dunlap CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Julien Grall Changes since v6: - Added a new section for vuart usage. - I have retained the reviewed-by/acked-by tags as this is a limited change. Kindly review. Changes since v4: - Minor change to rename "pl011" to "sbsa_uart". Since it is a minor change I have retained the reviewed-by and acked-by tags. docs/man/xl.cfg.pod.5.in | 12 ++++++++++++ docs/misc/console.txt | 44 +++++++++++++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in index 79cb2ea..8a38cf7 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -1105,6 +1105,9 @@ Allow a guest to access specific physical IRQs. It is recommended to only use this option for trusted VMs under administrator's control. +If vuart console is enabled then irq 32 is reserved for it. See +L to know how to enable vuart console. + =item B Limit the guest to using at most N event channels (PV interrupts). @@ -2171,6 +2174,15 @@ the domain was created. This requires hardware compatibility with the requested version, either natively or via hardware backwards compatibility support. +=item B + +To enable vuart console, user must specify the following option in the +VM config file: + +vuart = "sbsa_uart" + +Currently, only the "sbsa_uart" model is supported for ARM. + =back =head3 x86 diff --git a/docs/misc/console.txt b/docs/misc/console.txt index 16da805..d081acc 100644 --- a/docs/misc/console.txt +++ b/docs/misc/console.txt @@ -19,7 +19,20 @@ The first PV console path in xenstore remains: /local/domain/$DOMID/console -the other PV consoles follow the conventional xenstore device path and +The virtual UART console path in xenstore is defined as: + +/local/domain/$DOMID/vuart/0 + +The vuart console provides access to a virtual SBSA UART on ARM systems. +To enable vuart the following line has to be added to the guest configuration +file: + +vuart = "sbsa_uart" + +In Linux you can select the virtual SBSA UART by using the "ttyAMA0" +console instead of "hvc0". + +The other PV consoles follow the conventional xenstore device path and live in: /local/domain/$DOMID/device/console/$DEVID. @@ -61,6 +74,14 @@ output = pty The backend will write the pty device name to the "tty" node in the console frontend. +For the PV console the tty node is added at + +/local/domain/$DOMID/console/tty + +For the virtual UART console the tty node is added at + +/local/domain/$DOMID/vuart/0/tty + If the toolstack wants a listening Unix domain socket to be created at path , a connection accepted and data proxied to the console, it will write: @@ -79,8 +100,8 @@ For example: ioemu The supported values are only xenconsoled or ioemu; xenconsoled has -several limitations: it can only be used for the first PV console and it -can only connect to a pty. +several limitations: it can only be used for the first PV or virtual UART +console and it can only connect to a pty. Emulated serials are provided by qemu-dm only to hvm guests; the number of emulated serials depends on how many "-serial" command line options @@ -90,14 +111,15 @@ xenstore in the following path: /local/domain/$DOMID/serial/$SERIAL_NUM/tty -xenconsole is the tool to connect to a PV console or an emulated serial -that has a pty as output. Xenconsole takes a domid as parameter plus an -optional console type (pv for PV consoles or serial for emulated -serials) and console number. Depending on the type and console -number, xenconsole will look for the tty node in different xenstore -paths, as described above. If the user doesn't specify the console type -xenconsole will try to guess: if the guest is a pv guest it defaults to -PV console, if the guest is an hvm guest it defaults to emulated serial. +xenconsole is the tool to connect to a PV or virtual UART console or an +emulated serial that has a pty as output. Xenconsole takes a domid as +parameter plus an optional console type (pv for PV consoles, vuart for +virtual UART or serial for emulated serials) and console number. +Depending on the type and console number, xenconsole will look for the tty +node in different xenstore paths, as described above. If the user doesn't +specify the console type xenconsole will try to guess: if the guest is a pv +guest it defaults to PV console, if the guest is an hvm guest it defaults to +emulated serial. By default xl creates a pv console for hvm guests, plus an emulated serial if the user specified 'serial = "pty"' in the VM config file. From patchwork Mon Aug 28 08:56:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111127 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548292qge; Mon, 28 Aug 2017 01:59:04 -0700 (PDT) X-Received: by 10.36.26.131 with SMTP id 125mr6225312iti.78.1503910744492; Mon, 28 Aug 2017 01:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910744; cv=none; d=google.com; s=arc-20160816; b=Z1UThNn0bsl1nfM0NMz2Rs4nrQHa3acjFwrsXmJGXc0jjx3PDiBOG5+LuXDY96hxoT pBpBAN1eab3nwY2Cw5gI67G+67Vop0MPLUlQqUltZh1d0wns4AW0PBAM8fAjeqjkv2FW X9lJVIPO7qwl4QGAOXsO5W/NBOaXM8js9TpkMjCM3hTXcBsbCK66llUhcuZ8KWH4AYHi IJTKBhdbzK6FGCscNM++/4DwkkKlHYLioB6nmwFUDiJHr8D4PcONTvoB8nGQAHnEkH00 cgKwVR9btN41zUgfMORqaRknXhpzchFlihQBQ0CFM+gwhBup3ZiX8uz7BWeH+id7KQzV ZSUw== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=QHN7WJBkgSb35czeRNEEwvqa/sOsUmpV0SgO3oR4Xes=; b=g9acRA0pkUlBe2rdWnIPoNhBOrO2bY9FJ7brOgnwOKUmr45a3NRRfRxXQ/3LizKPxc 1owAx8cvBdqa5YrpD8HgmoqmtKoOi1geoGS3NPAOr8lbCKGzDqv4+dG+JOxs4k9SfzlG QrrUhhd90auU9hhfd8xnh40Zunldqlfd1lsPBft5mpRpqiD6Oown90UyEfsh0hXCxQ3n 23k1S5/bzrbtysYwYGobe2tFgZBDTYTYZHL3AqiiwqHXmxqSEbFbdVXmB3cWcK/bpL6E FTn/SIiXDMWxTW91n8EwHdv133YkVKhfnZmelQ3AU0vPPxMf/0vAQiLzl/F5Wbl1gi5C 0VLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LCs5SCbO; 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 a65si514261itb.25.2017.08.28.01.59.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:59:04 -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 header.s=google header.b=LCs5SCbO; 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 1dmFrf-000663-Pb; Mon, 28 Aug 2017 08:57:47 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFre-000640-PQ for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:46 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id 8E/E4-01732-A0BD3A95; Mon, 28 Aug 2017 08:57:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRWlGSWpSXmKPExsXiVRtsoMt5e3G kwZ6dchbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aOjtcsBU2yFVe3L2ZsYHwj1sXIxSEkMJ1R 4kjvDLYuRk4OFoF5zBIT58eDJCQE+lklXi3ZwQiSkBBIk2if8JYdwq6W+LZvNzOILSSgJXH01 GxWiEn7mSQ23fsO5HBwsAmYSMzqkACpERFQkri3ajITiM0sUC+x7dwvRpASYYE8ic/nVSH2qk r0T20HG8kr4COxuX8P1Fo5iZvnOsHinEDxHWvvskOs9Zboev2BdQKjwAJGhlWM6sWpRWWpRbo WeklFmekZJbmJmTm6hgamermpxcWJ6ak5iUnFesn5uZsYgUHFAAQ7GA82Ox9ilORgUhLl3Vmx OFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO+Zm0A5waLU9NSKtMwcYHjDpCU4eJREeD+ApHmLC xJzizPTIVKnGHU5Jh3Y/oVJiCUvPy9VSpz3IUiRAEhRRmke3AhYrF1ilJUS5mUEOkqIpyC1KD ezBFX+FaM4B6OSMO9BkCk8mXklcJteAR3BBHSEouBCkCNKEhFSUg2Mwszp55iyfL84fy2M/3v lzNltpVLnWoKWPbfacp09sdJMrGLjUsvf/Y8rbA4J/RCKZ6hmOWE+ldNqOfuy1dv3eYWe2RdQ wsjnb6XV3rXHcf8tebaL/I/nCzDK6l5rvuZ64yTXCpbQzcYejIJZ11bwXyr17KvdHBsa8rjb5 q6g68fL7xn4/u5QYinOSDTUYi4qTgQAgm3dW7ACAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-206.messagelabs.com!1503910664!88019028!1 X-Originating-IP: [74.125.83.48] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28547 invoked from network); 28 Aug 2017 08:57:45 -0000 Received: from mail-pg0-f48.google.com (HELO mail-pg0-f48.google.com) (74.125.83.48) by server-11.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:45 -0000 Received: by mail-pg0-f48.google.com with SMTP id 83so22182263pgb.4 for ; Mon, 28 Aug 2017 01:57:45 -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=ru488eqnUG9k+hwFsDMdo4vA5QD8i26TWlWnwk6dwgg=; b=LCs5SCbOnlnHiqHaMmZ6TPQlUpeQHYV2h/9YRnZ0rUqLZHUyp/7iF9XICGB/9vIYNW yh02KqLzfyb6o9JVqK6U2HhrcrIH9g62b+k9PZ2R+Zv/JUBHTZczIpanbQc2mhjhe4DC FB/878qwslj7on1gE55WR3UqELCtVUSmxtMr4= 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=ru488eqnUG9k+hwFsDMdo4vA5QD8i26TWlWnwk6dwgg=; b=alW9hl8XVnber9mMY2uSJ7R9FTAiZyiEAVIMdDAWihQeoksp+33THRFgz5bhFP4YIB 20Gqh4vHc24En9FaBLQtgYQrrBqo9UTWQvHSuV+2H35A73fcgDWqfHp+b34ADGb1nUCK 4at/amhjGpkiFd5IFawClKwfZocDw8x0eTD61sAB6Tsqf0liUWJDP+avNvaFskQO/nkJ TQb/QnfLmrwe14Lhdx84b/Ziyk6e8f50RdWYZDJ5Um/9+fujuptFCaQ0UjA6qztEDvZ0 YfF97QyxgwxuT7kWlF6u/ovdccH9X553oQXnU6keYoNs1IPrngS/NP5pnz/SyaJHswYw PFsA== X-Gm-Message-State: AHYfb5gzQWytCM8ZBBLQAh5XnSD0fDzY9PK5ssgBhM3XjPTzGqxI8pZc efwg3AA1u3wIEzmcuC4AcA== X-Received: by 10.99.105.136 with SMTP id e130mr6898659pgc.422.1503910663630; Mon, 28 Aug 2017 01:57:43 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:43 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:09 +0530 Message-Id: <1503910570-24427-27-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Andre Przywara , Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 26/27 v8] xen/arm: vpl011: Correct the logic for asserting/de-asserting SBSA UART TX interrupt 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" This patch fixes the issue observed when pl011 patches were tested on the junos hardware by Andre/Julien. It was observed that when large output is generated such as on running 'find /', output was getting truncated intermittently due to OUT ring buffer getting full. This issue was due to the fact that the SBSA UART driver expects that when a TX interrupt is asserted then the FIFO queue should be atleast half empty and that it can write N bytes in the FIFO, where N is half the FIFO queue size, without the bytes getting dropped due to FIFO getting full. This requirement is as per section 3.4.2 of [1], which is: ------------------------------------------------------------------------------- UARTTXINTR If the FIFOs are enabled and the transmit FIFO reaches the programmed trigger level. When this happens, the transmit interrupt is asserted HIGH. The transmit interrupt is cleared by writing data to the transmit FIFO until it becomes greater than the trigger level, or by clearing the interrupt. ------------------------------------------------------------------------------- The SBSA UART fifo size is 32 bytes and so it expects that space for 16 bytes should be available when TX interrupt is asserted. The pl011 emulation logic was asserting the TX interrupt as soon as any space became available in the FIFO and the SBSA UART driver tried to write more data (upto 16 bytes) in the FIFO expecting that there is enough space available. The fix was to ensure that the TX interriupt is raised only when there is space available for 16 bytes or more in the FIFO. [1] http://infocenter.arm.com/help/topic/com.arm.doc.ddi0183f/DDI0183.pdf Signed-off-by: Bhupinder Thakur --- CC: Julien Grall CC: Andre Przywara CC: Stefano Stabellini xen/arch/arm/vpl011.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 56d9cbe..1e72fca 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -152,12 +152,20 @@ static void vpl011_write_data(struct domain *d, uint8_t data) else gprintk(XENLOG_ERR, "vpl011: Unexpected OUT ring buffer full\n"); - if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) == - sizeof (intf->out) ) - { - vpl011->uartfr |= TXFF; + /* + * Ensure that there is space for atleast 16 bytes before asserting the + * TXI interrupt status bit because the SBSA UART driver may write + * 16 bytes (i.e. half the SBSA UART fifo size of 32) on getting + * a TX interrupt. + */ + if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) <= + (sizeof (intf->out) - 16) ) + vpl011->uartris |= TXI; + else if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) != + sizeof (intf->out) ) vpl011->uartris &= ~TXI; - } + else + vpl011->uartfr |= TXFF; vpl011->uartfr |= BUSY; @@ -368,7 +376,16 @@ static void vpl011_data_avail(struct domain *d) if ( out_ring_qsize != sizeof(intf->out) ) { vpl011->uartfr &= ~TXFF; - vpl011->uartris |= TXI; + + /* + * Ensure that there is space for atleast 16 bytes before asserting the + * TXI interrupt status bit because the SBSA UART driver may write upto + * 16 bytes (i.e. half the SBSA UART fifo size of 32) on getting + * a TX interrupt. + */ + if ( out_ring_qsize <= (sizeof(intf->out) - 16) ) + vpl011->uartris |= TXI; + if ( out_ring_qsize == 0 ) { vpl011->uartfr &= ~BUSY; From patchwork Mon Aug 28 08:56:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111129 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548368qge; Mon, 28 Aug 2017 01:59:09 -0700 (PDT) X-Received: by 10.107.15.19 with SMTP id x19mr5033965ioi.53.1503910749103; Mon, 28 Aug 2017 01:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910749; cv=none; d=google.com; s=arc-20160816; b=rrgbf/+WwPxCbIet/Sxb0a6UOe9Zdq1igRe2LUQ2yGuz75XvaHfQWm+peoPNzJyNsq I37UVjcLcom/MByifBHWJ3k6guBaAtFvffaIxH3UbKWGURa0FUQ9J2wZphlkRuXVVEl3 fgn/y3ylkX2MKXrrm/WFCU5cwFemBJo2jvXWB5Y3EmouBa16QNfBun5XCM80BdN14V0W sD97UV5aQBRACVs5KlmD3z57rYZdY4WfgJXE4Y6LkbzS2kkUOz5zIMfxOt1Fu6NZpGoI L5Tqm4O7c6tcujIuI55tDP0RPXZf34OVUTvUCz6csWodqmvdxpmsSOi1Z4SPmFrOHjMg AiYw== 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:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=sFFp6VP1sf3ZlBdGWyS0p3+25MwNuA3IeS1vbrWaL74=; b=RQeYnqxB9ybSRTCBCWuwSZ8Wxm0zCl6vrViGjLts8jdmIbdR4Il/0jGECbR2WIm7k1 hU4p3gcx29trjTn+EUeMo5hEDVn2MAKLmwLoa6xAy7tXu8hyfO0LIVSEsbAmimmW1JbK +UzmauqBB/gwBOac1H4Mvan8ILWIlV6KJqmHdFeOD7W2gS+E/Cp6EPvH3k7W40S53pZp RhKWeJyYWozpMY8YLFdguCKjeQwSsYLz9+HWxf8AT3UgTjqfQJ05pBBstaelj3AhCfYQ SEI00ui88yDy97SB1E0rYi4Ddp1l6n74I3rO4PtqSEjqERwiaWVnUhe1GrhL8kDP+Vi6 qNwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ATXLxXns; 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 3si11506734iow.301.2017.08.28.01.59.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:59:09 -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 header.s=google header.b=ATXLxXns; 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 1dmFrj-0006Ax-0q; Mon, 28 Aug 2017 08:57:51 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFrh-00068V-Pi for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:49 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 25/57-01862-D0BD3A95; Mon, 28 Aug 2017 08:57:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRuspctze3G kQdM+JYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePSxhOMBfeFK+Y9v83UwHiTr4uRi0NIYDqj RP+JpUwgDovAPGaJ+5/3M4M4EgL9rBL/rp5m62LkBHLSJOYemMQIYZdJXHg8gQXEFhLQkjh6a jYrxKj9TBJT2o8DdXNwsAmYSMzqkACpERFQkri3ajITiM0sUC+x7dwvsDnCAmESN+59YAexWQ RUJa6v+gI2k1fAR+LE9YWsELvkJG6e62QGsTmB4jvW3mWH2Ost0fX6A+sERoEFjAyrGDWKU4v KUot0jSz0kooy0zNKchMzc3QNDYz1clOLixPTU3MSk4r1kvNzNzECQ6uegYFxB2P7Cb9DjJIc TEqivDsrFkcK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuA9cxMoJ1iUmp5akZaZAwxymLQEB4+SC O8HkDRvcUFibnFmOkTqFKMxx6QD278wcXx5sfkXkxBLXn5eqpQ4rw9IqQBIaUZpHtwgWPRdYp SVEuZlZGBgEOIpSC3KzSxBlX/FKM7BqCTM+xdkCk9mXgncvldApzABnaIouBDklJJEhJRUA6P m6qWs/U72cnr/m1u840psvZaqT/J//fFestqsO3tMmedWah0L+By3Xqz1Xemhv21Kv1ancy2e 9nBu5LTVRaIfs1mXJlxQE92iYnf5S0ji+686+6ZZG+lP45dJyXr0Ne2svn3kxFXSZXXCGYoNL S/SNt1+s/TkjKKSwwzvlCcuzUuQFUn+2avEUpyRaKjFXFScCADA0p6vuQIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-12.tower-31.messagelabs.com!1503910667!95097134!1 X-Originating-IP: [74.125.83.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10492 invoked from network); 28 Aug 2017 08:57:48 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-12.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:57:48 -0000 Received: by mail-pg0-f42.google.com with SMTP id 83so22182596pgb.4 for ; Mon, 28 Aug 2017 01:57:48 -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=p2H/mstPPQb8H1R6aw7jrvNqtjUuRaSxOfyW5yP0N/A=; b=ATXLxXnsJURpjc9I+8mljWvuy45KPjAEjkoCFJEfwFmzNaNafSKbYD3v0aUi6jcqsQ 2mk9xEfd4ne+GESBUTLTu8+hvrSE4ptjhye7SSQCZPWNYzQtE+o1Ejcmm+oUpA67TKNL P6T4EOr/7L1QRiibxPGhD816kLcbCI9lbDTQU= 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=p2H/mstPPQb8H1R6aw7jrvNqtjUuRaSxOfyW5yP0N/A=; b=dyjIesD0Gx0Hu6QfsFSX4CdfIppi3Lic3V+JhVclf9+tVqBO/iZ4IZQTAbv0Oq/oT2 p8r/VNiCljLS/gWieMzKPPil7RrUlssG+861yO6P2YVQbEbaYb5rpBB+8749tNkWloBk AvHdvKxOAgP7pERpzY9zP/BM7aTQtQP/x5flhIq4lZ0u/DdSl++h8EyCNfhxH7RCM7gz uRI/EjFhDb2ptQYUJDCl7d7xwhFgGXrUHhFeJpJQsfoUqECMgR+NvpboC/+ttUtv2h2Q c3Vde4b6xBzu0TH2Z6lMlbPGhICUYIf53oWBk/qRHbBT/wj69z0v5xlO+cCctI8X6E0d vGSw== X-Gm-Message-State: AHYfb5jgkU8xApsm9p00OR19kqgbBSoXa29FsMyZ99IvMCpQWEx6CWnK NH2al86+OvXxVSBQFthZIA== X-Received: by 10.99.50.4 with SMTP id y4mr6910200pgy.238.1503910666582; Mon, 28 Aug 2017 01:57:46 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.57.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:57:45 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:26:10 +0530 Message-Id: <1503910570-24427-28-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Andre Przywara , Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 27/27 v8] xen/arm: vpl011: Fix the slow early console SBSA UART output 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" The early console output uses pl011_early_write() to write data. This function waits for BUSY bit to get cleared before writing the next byte. In the SBSA UART emulation logic, the BUSY bit was set as soon a one byte was written in the FIFO and it remained set until the FIFO was emptied. This meant that the output was delayed as each character needed the BUSY to get cleared. Since the SBSA UART is getting emulated in Xen using ring buffers, it ensures that once the data is enqueued in the FIFO, it will be received by xenconsole so it is safe to set the BUSY bit only when FIFO becomes full. This will ensure that pl011_early_write() is not delayed unduly to write the data. Signed-off-by: Bhupinder Thakur --- CC: Julien Grall CC: Andre Przywara CC: Stefano Stabellini xen/arch/arm/vpl011.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 1e72fca..375581d 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -165,9 +165,17 @@ static void vpl011_write_data(struct domain *d, uint8_t data) sizeof (intf->out) ) vpl011->uartris &= ~TXI; else + { vpl011->uartfr |= TXFF; - vpl011->uartfr |= BUSY; + /* + * This bit is set only when FIFO becomes full. This ensures that + * the SBSA UART driver can write the early console data as fast as + * possible, without waiting for the BUSY bit to get cleared before + * writing each byte. + */ + vpl011->uartfr |= BUSY; + } vpl011->uartfr &= ~TXFE; @@ -378,6 +386,13 @@ static void vpl011_data_avail(struct domain *d) vpl011->uartfr &= ~TXFF; /* + * Clear the BUSY bit as soon as space becomes avaliable + * so that the SBSA UART driver can start writing more data + * without any further delay. + */ + vpl011->uartfr &= ~BUSY; + + /* * Ensure that there is space for atleast 16 bytes before asserting the * TXI interrupt status bit because the SBSA UART driver may write upto * 16 bytes (i.e. half the SBSA UART fifo size of 32) on getting @@ -388,7 +403,6 @@ static void vpl011_data_avail(struct domain *d) if ( out_ring_qsize == 0 ) { - vpl011->uartfr &= ~BUSY; vpl011->uartfr |= TXFE; } }