From patchwork Mon Jul 17 13:06:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107936 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4494945qge; Mon, 17 Jul 2017 06:09:21 -0700 (PDT) X-Received: by 10.107.148.135 with SMTP id w129mr18922384iod.234.1500296961030; Mon, 17 Jul 2017 06:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296961; cv=none; d=google.com; s=arc-20160816; b=0sGY7un0NbKz09vVxk1r4XD+6pKUYiBdgqnoRQrVzPubAbMQIws7u0hh5cIlv0zCbk Q0g9UbQ1jpVDxnpOtqoQZRgp/rsUPP4Gqwu0RWXzrFpBn3Xn1YpuACVcOrApQj2jQhf+ /91zetV6XFCL9kUF1cufx6osrHVcFF2yjhAHyik3iy7QkvsykSxlysCX1gN1oJ3VxDsX rF/63pumV8XLKBtLnxcJI/t9A1MmfqAvHVL5OD+5ZVORhN+OCRChDdOgV5o18O0gY78R 16Lr0WfhmwoNYphq9mMp1+aDq1A0cu+qAb9FeAxGCtysgYeCDHVqbj4etHTEEUzA1yE9 IohA== 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=YNFc0j298QkY4YurCpxHociBErhivLtYglP/V6PUGwQF9hLaTarQxsRoRmkukrD4zE 1AXVHcs6tLIqozu4jHgWpDeRzAMm1zsEE8j1Fo4iPHgKWSU7VbBRbs9uDdQhWsNi1wbg a7p/C9GmxurV4rgHeF3FZ7XSVjJN52tDjtKcRKkkHN8oPfOSwiPDhX3Mt+2zFrBuiT7q T7pevPwKJPebo8F7H85Q70y+jitUy2RFGhmzW+tZJ4yWt5Zp+/FcfOwF8qGbvATgY1NO i5vl/NAFwKj1HgBbdPFfK9jxhlyQ70KoNlY94rsNjp7Tf7DVl8hpQJotPWTlNHW7rLNZ y5ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=FLLD+A3m; 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 k18si16970101ioi.265.2017.07.17.06.09.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:21 -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.b=FLLD+A3m; 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 1dX5jy-00047P-Eb; Mon, 17 Jul 2017 13:07:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5jx-00047D-9O for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:09 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id FC/D6-01735-C76BC695; Mon, 17 Jul 2017 13:07:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPIsWRWlGSWpSXmKPExsVyMfTAOt3qbTm RButu61l83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBn3Xv5kKmgVqDgy1a+BsYGvi5GLQ0hgBqPE rm2N7CAOi8A8Zokpi1uZuhg5OSQE+lkljv3W7WLkALLTJG78ioYIV0i8+/WXFcQWEtCSOHpqN ivEoFYmicufl7KC1LMJmEjM6pAAqRERUJK4t2oyE0gNs8AFRomZf5+zgSSEBZIkVk54zQRSzy KgKnHqsBFImFfAW2Jhz0p2iF1yEjfPdTKD2JwCPhJnNqxmgtjrLXHzyESmCYwCCxgZVjFqFKc WlaUW6Roa6iUVZaZnlOQmZuboGhqY6uWmFhcnpqfmJCYV6yXn525iBAYVAxDsYFzZ7nyIUZKD SUmU9yJbdqQQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV73rTmRQoJFqempFWmZOcDwhklLcPAoi fAygqR5iwsSc4sz0yFSpxjtOa5cWfeFiWPD6vVAcsqB7UDy1YT/35iEWPLy81KlxHn1QNoEQN oySvPghsLi8RKjrJQwLyPQmUI8BalFuZklqPKvGMU5GJWEeT9tAZrCk5lXArf7FdBZTEBnCfu CnVWSiJCSamCsXznxmEoc2xO7j3djeif/v3FL+s0djukGX9ZdVnv18Vrys/xlOxfM0XIM1r8g Wson2X4/8hHj5GNNXkvzN6+21fFeHxMWzL7Y6ZVnl1yI6JGEELM0EdkzS5o95sYWJ+fVuL7n+ 6DtqfxhSWL8lx/f+L2D7+TeTBB/X3iO13pmwWaBvX3/Th9VYinOSDTUYi4qTgQA41n1EMICAA A= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-16.tower-206.messagelabs.com!1500296826!87352006!1 X-Originating-IP: [209.85.192.174] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21472 invoked from network); 17 Jul 2017 13:07:07 -0000 Received: from mail-pf0-f174.google.com (HELO mail-pf0-f174.google.com) (209.85.192.174) by server-16.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:07 -0000 Received: by mail-pf0-f174.google.com with SMTP id e26so8413843pfd.0 for ; Mon, 17 Jul 2017 06:07:07 -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=FLLD+A3msfMYDRFdEk9l7Hzyi4YQVi9KkBejo5URLwxjtrKQnYKuELzU5b5BSqn9QU ubuR0ISZZWvMUqxLqPb6lbm3WY3gM6CjXIrTpFQiDmhQr+Dtj1Uafg9K13KvPHOzUk3w JXuJjJtx/1Y7uAyVOE8P/2moYRZnq20ugogag= 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=txEXg348U9CZKdydU1Ago+FSgDZbgdTbmthJOVbu7RCGTZIp+6X0JI6nBiK4VzZk+i XFKy23s687E3s8oko0t69WP9WsEUTy5krDpmgjOVibO2phuwYlwVQ7yeTB6vL3weOS3E P99qbwaWxqfN1jR0cDJgiLAA6H0MVBP79+DSCcufajNziHymNlliYMi9YnTtRYpt/+BQ EY8yNfra3e7FJZceAcMhwvfieb7RoqTFGetCT1vF+oY3H2fJZgYdJBuRO2OKL3E8UxjF nif7GwjENrjroIn73aWToR5E+GSLvfsHakSp6HFuhBdReKJdFygUgurFVpSRLzRoed7c XmNA== X-Gm-Message-State: AIVw111mew8pNWfx7ViV6kYjfdsbR1wo905/hzoEHiofl7+kxPgRWBxG 001tRngGKA4y7rLm7RaswQ== X-Received: by 10.98.38.68 with SMTP id m65mr10482267pfm.47.1500296826020; Mon, 17 Jul 2017 06:07:06 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:05 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:31 +0530 Message-Id: <1500296815-10243-2-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 01/25 v6] 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 Jul 17 13:06:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107948 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495268qge; Mon, 17 Jul 2017 06:09:33 -0700 (PDT) X-Received: by 10.107.186.9 with SMTP id k9mr21733013iof.242.1500296973498; Mon, 17 Jul 2017 06:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296973; cv=none; d=google.com; s=arc-20160816; b=IjX5vF52Nxp0UxQqYdBpnHVKe9Ctbg7uUdEpFaDknPJeMsq0wjPaTPclANgr3a4Tqi ao1Trc8M6k871xXdf0uQkh4ogwcfkcVR8KqwuBs7/CeS+fzRP/F63jZByp4VMiIoG6LI q8CePsgKu210lq14raHmR+FtcrndbwKpv/KAiG9N/Ar6dM3t0HUbfPjl5SFZZYSt8FJE o7KZgMiIl1/nEn69y90spCtyiHvaEJPbq0zTJ2cWBBxILlvGCIs1+M0Sg1rOVe2cBrTK /EBe2En8b7WS6UOkdMYPHH3tbajF62CD00ZuKaEgaw5psZYIuRghO4NEdsw2Cz7pQmcs JhWQ== 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=nPvTYQKXI0oQL6tDTSTNGjj3GXKRhQOoqYpWAgJdlT4=; b=V4ZQoj42zdsU7v2SnAPkwxPDqlbHurS4ZgsuXMePvJpqVqRhDZhhLf4lSogWGv2M5T DZZzkINkDwcpqqPb6JVElcvvZLJ7vmpCGubeYPfs5H1a3wZI/lRMn/hMf+Do4jAE8+Yn KVSa9ltdV/DFNQYVYOS8x80h6du3C3+YPZmltskuQy0tYF6+0vDOqzlNVVZPMk59m3K5 bZ0PgAn4+GMkP96+lMy8QbOcYxKJV3xNSAsdRhmT/2hkIU7OFmAkpIkc/V5UMr+t1G5I R0IgNDssmY/mpUhy9MIScAKf60gm6Za06FAT+kakQyo4ATYMEQPRwi4PgSZoPlr9q2rW TVKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=dEQVuKvm; 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 x184si10008428itg.62.2017.07.17.06.09.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:33 -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.b=dEQVuKvm; 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 1dX5k2-00047u-ME; Mon, 17 Jul 2017 13:07:14 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5k0-00047g-RO for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:13 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 4C/3B-03582-086BC695; Mon, 17 Jul 2017 13:07:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRWlGSWpSXmKPExsVyMfTAVt36bTm RBv23WSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxj620KLi9mrHh66QB7A+OU2i5GLg4hgVmM EvdO7mUDcVgE5jFL3PjSwtrFyMkhIdDPKrF5hTeEnSaxu+8QYxcjB5BdKbHtdCJIWEhAS+Loq dmsEHYrk8SHAwIgJWwCJhKzOiRAwiICShL3Vk1mArGZBeolFm3axgJiCwt4Siz4/g0sziKgKn H76wawOK+At8SEXRNZILbKSdw818kMYnMK+Eic2bCaCWKVt8TNIxOZJjAKLGBkWMWoUZxaVJZ apGtkppdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJERhUDECwg/HMgsBDjJIcTEqi vBfZsiOF+JLyUyozEosz4otKc1KLDzHKcHAoSfC6b82JFBIsSk1PrUjLzAGGN0xagoNHSYS3G iTNW1yQmFucmQ6ROsXoynHlyrovTBwLejYAySkHtgPJVxP+f2PiaPr+8TuTEEtefl6qlDivHk izAEhzRmke3GhYbF5ilJUS5mUEOlaIpyC1KDezBFX+FaM4B6OSMK8uyBSezLwSuAteAR3HBHS csC/YcSWJCCmpBsbu7JcSUVtvW1VOis8QvHilsXAZy7m+l/fzE0sthJ1tJppManhtJPl0QlF5 n2Gu1opDDy6ZMvDv7FIs52/4PK1Dyo03kPWv235zW52+BemTtT+FN3ev+fjDXE9ZmO/zZIcgU ZsWdccNv6qUfxyzdc2c8D5KhU+wbltRZMzeuML3upHy+Rs/KLEUZyQaajEXFScCAEfg0gvIAg AA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-2.tower-27.messagelabs.com!1500296829!47958275!1 X-Originating-IP: [209.85.192.181] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57348 invoked from network); 17 Jul 2017 13:07:10 -0000 Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by server-2.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:10 -0000 Received: by mail-pf0-f181.google.com with SMTP id e199so15180796pfh.2 for ; Mon, 17 Jul 2017 06:07:10 -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=Wgq0eghTgL9H3uLCQcEgBMHv6QAxYy4TonxDwMTsSNU=; b=dEQVuKvmZxdZCdq5VOn7QXgCdeqMaBhMNTV22NzfEbYeX5T+zON/A8Jk/+2BNdUg7l LaLt7M9bJx9thnFgcd5H5Q0r9y6rfNaY8meEju2ESR8j6TaR6ZUBDqTlayJl9n9DTVnc UcGjCMTEqboDLyLnddgEYRNY9mZ+qjwpURxrc= 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=Wgq0eghTgL9H3uLCQcEgBMHv6QAxYy4TonxDwMTsSNU=; b=VhHW3Rdsa73fNgD3zxBlWd0mAnuQvNPFYVsPJ31+OJmiozrBkHYg8n+gvAN4oj1rhi AxXQMVxP3LcGahcCRnlJUhyo5SNUwCK3VUssiV7SdxwZii2qsSiqiza62krPdsaHXRuz lLp97ZpmdMEQClS5VEoiH9pMmXqhYEfqQIFJBKeZ9+ub1UdX5rqwGxHlql9jhzl2m6Vr E4toJq1OoJBk69ewDTR3Bh7f0eSnzkvvHTtvv7QgiAhxRrYwa2LbgOdAsZlaJmnC4xIQ JGbkzbMqqrR3r74xoL5IlB8boVa0HYBR691CE4hYbso9lwMkGEm2zGGVocZVoMZqqIGu jgIA== X-Gm-Message-State: AIVw111JnS8q9VF92cTEb6DhTpZlE3URuVD/GA5eMfryMXoTagizJUJI jBIqEX4n0lGpsHoSlCmlVA== X-Received: by 10.98.70.206 with SMTP id o75mr18722638pfi.60.1500296828786; Mon, 17 Jul 2017 06:07:08 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:08 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:32 +0530 Message-Id: <1500296815-10243-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Andre Przywara , Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 02/25 v6] 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: Stefano Stabellini CC: Julien Grall CC: Andre Przywara 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 | 455 +++++++++++++++++++++++++++++++++++++++ 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, 549 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 49e1fb2..d9c6ebf 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -50,6 +50,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..dc98490 --- /dev/null +++ b/xen/arch/arm/vpl011.c @@ -0,0 +1,455 @@ +/* + * 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); + xfree(d->arch.vmmio.handlers); +} + +/* + * 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..0439e64 --- /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 { + uint32_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 Jul 17 13:06:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107949 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495277qge; Mon, 17 Jul 2017 06:09:33 -0700 (PDT) X-Received: by 10.36.129.138 with SMTP id q132mr5519221itd.62.1500296973798; Mon, 17 Jul 2017 06:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296973; cv=none; d=google.com; s=arc-20160816; b=WNoEB3HrfyMogSzPykV9ohWSESgdxJRAqkShQpjkNk8gFwvGD5JwD9eIpgl7ZzkgjE l40Xe3BIwFg2CYYK9YpnGY7d8+NmUnf4z6VxT0aNdm13pyFSCM5eI0P4m//wDaMIFMsU kKK7aSVPOkwl7/qgxq9Rt7ORYc/pPOzE2kyzQiOVfbXuGTMB3eHkQybaGSXJlV2y2izw 9Hz3vumZvlCMEqwBAhoEyy6/mDdTiSYX+tHaayCqwSRkPy57PCDwMUQPtXrkruUzbVwG rphp92NRBMvTnAdWKb6a/UND4vxIipQDscVc79i7Smp4Sb5ihp/Zz75mOZIzn6vDGq2x USzg== 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=IR3pYMGe+i4pQDy3V1alln/C+VQau8iOfedqYqbSPxM=; b=WFT9rOjyCIr3kkH6xB7tKIiyAASwrubh5tNmMfUNfvCwqJMXjSGrUMMdowtIFxSZUI qAVKXTAtm5+8w8KuE1IPRjttt4Fl1KrvXVxKRVqpdCac4btvdH6EVpE52+c7DQNychjc WKlCdZzIHe7eEQFL/NnY67O1AVj4QFsqARKzZaFmoh3ArZJRDLjL7IKdXZcNPkADYn5U Lat8WIktIoblL8qM3Dz7kII8LXnc3/ieEj9J+/taNUC8qVwJtf66Y0JIpBUVgXiaxmZ9 YZM0kkN3ApLSFJkoGAtdM1LDG7/AX1rSbAUmD3DfmiRWCWSmUfeJSMRrAkh3An+OFkPx wblQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=g1i/hu1J; 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 b3si9945441itd.139.2017.07.17.06.09.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:33 -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.b=g1i/hu1J; 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 1dX5k4-00048X-2O; Mon, 17 Jul 2017 13:07:16 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5k2-00047t-UA for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:15 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 9D/C2-03612-286BC695; Mon, 17 Jul 2017 13:07:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsVyMfTAJt3GbTm RBofuy1l83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBk/D7EW9ElXnFi7hK2B8aFYFyMXh5DADEaJ N3fesoI4LALzmCWeN09mAXEkBPpZJV4cusHcxcgJ5KRJrOi5DJTgALKrJDqa2UHCQgJaEkdPz WaFmNTKJHF73UkmkBo2AROJWR0SIDUiAkoS91ZNZgKpYRaYzyjRNKmXDSQhLBAh8WDzJTCbRU BV4vr2DywgNq+At8TelkcsEHvlJG6e6wS7gVPAR+LMhtVMEIu9JW4emcg0gVFgASPDKkaN4tS istQiXWMjvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MwMBiAIIdjKfXBR5ilORg UhLlvciWHSnEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgtd9a06kkGBRanpqRVpmDjDEYdISHDxKI rxdW4DSvMUFibnFmekQqVOMlhxXrqz7wsQx5cB2IPlqwv9vTEIsefl5qVLivHog8wRAGjJK8+ DGweLwEqOslDAvI9CBQjwFqUW5mSWo8q8YxTkYlYR5dUGm8GTmlcBtfQV0EBPQQcK+YAeVJCK kpBoYW7ZXMLeXM08EpoqVzpd/rZrr9nu2dOcy4blpnZFixlc/O3/vkPHYyXyh+PCcR1VN5V/U 59quOtMx8VV9wc/PYW1fN5pIX1OTrpU/tUl7pvvLlOn7vRS2B5fsTnqpZ3rV26fT9b5iqm5pv 5P8MmnF8gNfdlR7Fd6Mr0jwkwg4z/Bk5d26rD4lluKMREMt5qLiRAB+YtYEvgIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-27.messagelabs.com!1500296832!95082588!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51412 invoked from network); 17 Jul 2017 13:07:13 -0000 Received: from mail-pf0-f178.google.com (HELO mail-pf0-f178.google.com) (209.85.192.178) by server-14.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:13 -0000 Received: by mail-pf0-f178.google.com with SMTP id e26so8415263pfd.0 for ; Mon, 17 Jul 2017 06:07:13 -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=ApzB1RQ44i/zDRxK/ABxhhWVVjRsJPkZLhhcrB5okWY=; b=g1i/hu1J2oZBowq/rgfOd1jyZP16LESyh172GKi0Z6XQt2DmBM7h1Jmvy/hZW+TzMt Q24OGABTYmoxQg0Tk6BYk2dfIbN1EAV3BzLToipMryAp+pRfo6AC+Ff+olc5siKdFQzI j/TLlr0aQRXBU1W+/UGevout/GYxenoUqanfE= 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=ApzB1RQ44i/zDRxK/ABxhhWVVjRsJPkZLhhcrB5okWY=; b=LEIV7E3AanLo5XgBIBVCNjWsIR9WX5msrd+ZUvGef5vsPlEMMgzhiqivEBrCWxE/8h I1ecoW82yyJFI/Z/sejE4MUtNjvH2AIfcsN0w4zj/avsc8LH6tKevK0sDJHeA2FbLSmL azZr1gNyeLieg1nNhDZFg0W9mjLhCuITZGseUy8GOrNTIQWlzLB+Q5VK7+PdFQ9Z3RTO 4Tn/o7U5brpY261XcnENTK/Fk7GCnRTKYQn6cGOqiw+/SdEYStykZrYal6l0tOhHL9m4 vl6sFdm4SXHvctep7aFXznY9V3pjMHDXgtbqoj5AHOvt4x8XWwHteqUlF8QQr5QwXKHs LJ1w== X-Gm-Message-State: AIVw111PhvtScfJAKBbixYr6FAQXGthwrDAUmVKT7HwVaZKjJe/Dyy5m 8/3cUi72++VataPWPWk/Mw== X-Received: by 10.98.158.29 with SMTP id s29mr19376938pfd.126.1500296831781; Mon, 17 Jul 2017 06:07:11 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:11 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:33 +0530 Message-Id: <1500296815-10243-4-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 03/25 v6] 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(-) 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 Jul 17 13:06:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107943 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495130qge; Mon, 17 Jul 2017 06:09:27 -0700 (PDT) X-Received: by 10.36.0.147 with SMTP id 141mr5495435ita.113.1500296967245; Mon, 17 Jul 2017 06:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296967; cv=none; d=google.com; s=arc-20160816; b=T/m+M6MN/msocBOq/l3v+uIcPz2oITjOK3CgW8FNbkU3yjyNJpmNar9TpZnvvExnCE IedWyMjjKfd1W94EhinNOaRR4lVba9ZLadfSNkMq1IbrnoouL44qDAPibLyHRTszelVb q2scsEwOkSnJz535XhrO/btnUmQOEEyBGzdHT4GstLk/qPtMfWDmsLbABKWwnHisfDPW mC7LjusceNq0+b0pcCIqC/ylyKm1dgI10vA8s+LDhsPp+Af9HVEC5Nx759b4V6cg2zLG 2YMX55F/0jGVEa7fj94mttAGmdnmmB9B8EdPlGeXG15PjU9RLfiCAFPrXpywmmaV1iQx zvxA== 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=QmtpWvg2Z8XkujNNe2IyBIoWGYUzbLT3iOWO/kpIeCU=; b=ARiuz5DnB0tBeVMjnzu/IUBVBYHYB8SmpWIGQjcXs9jnWUIEQzF0Q8vTtbkubLIa6T wS5HS2dkimOTeBnghYlhBs/gwaLzL3pxV8HF26OKAXQ2HnMZmdxAQC8EZnIEFAp1pj9n rb7DMzpfzrfvLJmmLDne/7Qkj/Kcq5F+Qh7IrRFTEfRuQ6Hg2pOGxJ/B3PdGkCcj7fGs 7rbwUaH5LNuIYXwkyg3a56ggg1h0uODUJwkp9XpjvpZCP25qde+/JKiGFMH29mTWIkdC PZUwO6cR4HA1vSbaEYD+dB6v6lY4XOja1i6Z4r2wNq01eaxcIjgOrJ6AmjPjGagizk2Y 83RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=eN/mFstp; 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 c195si10258395itc.73.2017.07.17.06.09.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:27 -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.b=eN/mFstp; 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 1dX5k8-00049S-9p; Mon, 17 Jul 2017 13:07:20 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5k7-000491-0O for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:19 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 20/4F-02176-686BC695; Mon, 17 Jul 2017 13:07:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRWlGSWpSXmKPExsVyMfTAVt2WbTm RBjuXKVp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkX/6xhLbhoXDHt0DfGBsYOzS5GLg4hgVmM Egv3zmcGcVgE5jFL7F5zhh3EkRDoZ5XYt/sLUIYTyEmTuPzxGhOEXS6x4dVVVhBbSEBL4uip2 awQo1qZJA41XmLpYuTgYBMwkZjVIQFSIyKgJHFv1WQmkBpmgfmMEk2TetlAEsICnhK/Pv1gBL FZBFQlDl2/DBbnFfCW6D+2mwVimZzEzXOdYEdwCvhInNmwmglisbfEzSMTmSYwCixgZFjFqF6 cWlSWWqRroZdUlJmeUZKbmJmja2hgqpebWlycmJ6ak5hUrJecn7uJERhaDECwg/Fgs/MhRkkO JiVR3ots2ZFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHg3b82JFBIsSk1PrUjLzAEGOUxagoNHS YS3GiTNW1yQmFucmQ6ROsVoz3HlyrovTBwbVq8HklMObAeSryb8/8YkxJKXn5cqJc67AqRNAK QtozQPbigsKi8xykoJ8zICnSnEU5BalJtZgir/ilGcg1FJmDcTZApPZl4J3O5XQGcxAZ0l7At 2VkkiQkqqgdF5S3ao+NSKiMDXrMVm/+d2v2Trc93Ua3QnKnHJw5NXi8SPX6penJI+64x49AG5 86H6gq/kuyWl1q/+MnHG638XfFrex/DsS7pcs//cTTEeE5WNu5VtuiP1uHUPdMULTbPucCpLK tls67wn7h1z87PgdwG961n1Dtwr2XbILvqF4vk/mt9PvlRiKc5INNRiLipOBADvTnfSxQIAAA == X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1500296835!87727918!1 X-Originating-IP: [209.85.192.181] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54590 invoked from network); 17 Jul 2017 13:07:16 -0000 Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:16 -0000 Received: by mail-pf0-f181.google.com with SMTP id e199so15182305pfh.2 for ; Mon, 17 Jul 2017 06:07:16 -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=zxCQEP2S+qRM1pFuzBzRoacu5/OV6mKvJcdj0YqjayE=; b=eN/mFstpnM406T/gTu+aSqxOTR1T9D17eZQKwhIcctDRhgOyTgqb2chxcI9GSR8b7u wVAQIZr6N0YUJ7W3lZf8k3odJifX3ku2zrewupEMhng1YuZrP/ZxR60AFyfS4HpSmT9R ayAJZXP9V45wH2QnTwsAViWBaTQI10jaC+p0o= 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=zxCQEP2S+qRM1pFuzBzRoacu5/OV6mKvJcdj0YqjayE=; b=Y7odk6H7gG7LkYEU7OBsyflV0+hEwWCX9cCj584cn7ZWSZumUJJqa+ecgXKP30qcva C/tf6Zbb29yc4Pmhh6H/gU2W52v2CkihISGcRSDLJfVvTSy/6DnMNkMUXf2gBfyliqQ1 B/xpVD31CwgDRpEqSvawZm2UGF4DpGXCMYh+FsF8yEyGVqLJyz43Zg0e6W8fRSXZurhN YgcqQ9XmHmvlZz+VefrHGUkpk4SdmoqWHUx07XxG9D/TW8BY5H5OJkhVaWdGCG5rGSAN GVNn5oU9g+nsFjM9BNA2nNARsn3nSb0OthqPWA2r8rQSoKahb3nEgM25K3jpm4wdLnYF YdTw== X-Gm-Message-State: AIVw113ga9umrwN8kKXkPOXOic0I56cul9qByiFeyRDvZ9YhxhnReBf4 sJh9qhJVFJewQxKTZZ2joA== X-Received: by 10.84.173.4 with SMTP id o4mr4259325plb.180.1500296834596; Mon, 17 Jul 2017 06:07:14 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:14 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:34 +0530 Message-Id: <1500296815-10243-5-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 04/25 v6] 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 suppots 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 7cf0f31..892ed35 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_VUART indicates that xenconsole/client supports + * virtual uart. + */ +#define LIBXL_HAVE_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 afe6652..d0d50c3 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 8a9849c..728cc56 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 30eb93c..9f91651 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 Jul 17 13:06:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107942 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495110qge; Mon, 17 Jul 2017 06:09:26 -0700 (PDT) X-Received: by 10.107.41.15 with SMTP id p15mr19289199iop.178.1500296966429; Mon, 17 Jul 2017 06:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296966; cv=none; d=google.com; s=arc-20160816; b=EMc8r2YyGBwcFtpXyE8jb1rgCwjmhLazClcBG6pzU5LqzgDt44/eMwhfKrGl3d7KGe rTxqpeMsMo+wv0Kf2KPI5k5Sn9ywGXEesncSX1Oc/fBeXUpphyjhC8j9oaBSmceTplz9 X9h9GNMjIj6l4Uv8+ohZccWkvYggMDGuoVngeBQvG4cLJQY9KUnDw4oEVn+9VwG7/Z5k vWsRjcpJicg+GAhfQojvtfTSbbpGNMrjtpNe3ENuLV5PBqGAWNw96L62fVpLQtzt7daA MPJvP23IFAIt/aqwRoQdusFurm6SH923Hr6aA3Gi5SpsmWdGayA6bzC36nay+QmVlCA4 V++w== 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=6NzJqfhndrWHQuuNb1Jka7GrUdzKaSNXW49J+ZvQpYA=; b=bCCPsYLMdIiO+hum/IUp9Q+ZrFoqWgdUI15IOphb89+jNAXr6DVthuzznQ+FeDWDW2 XV20xCw+4KUPxB1dldB8BVFGcK+cnJZiCr8MKZTBNpokIUCWehVN7nNUkGAuADY/5U9F pUusP6U6wmZwCNNclxbjAoU38ji4cWNEslVNH6KC53XNPxpjQs5Q9O70vKA3wUFxnYLU s5Q2kK5XnJxA18ax4d5kVpp7cgGqfFvBcwsNP7Zz5o1Juz0y78AzFUDJUmKEIg8xwgrh l+djBmpn2Nb59S1mOUJqdobY0ynkE/G81LaM0xnFTw19kl179Ez/Eucy84hRl+BkBWuX Um7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=IWYDr5XJ; 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 b2si6413110itf.39.2017.07.17.06.09.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:26 -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.b=IWYDr5XJ; 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 1dX5k8-00049h-H9; Mon, 17 Jul 2017 13:07:20 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5k7-00049C-R5 for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:19 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id B5/31-03406-786BC695; Mon, 17 Jul 2017 13:07:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFIsWRWlGSWpSXmKPExsXiVRtsotu2LSf SoPmQgsX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmrHq/mv2goXsFctmzWRvYFzH1sXIxSEkMINR 4lb3PkYQh0VgHrPExh0vmboYOTkkBPpZJVZs4YSw0yQmP7rPBmFXSnQ+nMkCYgsJaEkcPTWbF cJuZZK4vEWti5GDg03ARGJWhwRIWERASeLeqslgI5kFQiWm/n0A1ioskCWx4+pWMJtFQFXiVv tzMJtXwFtiyrevzBCr5CRunusEszkFfCTObFjNBLHKW+LmkYlMExgFFjAyrGLUKE4tKkst0jU 20EsqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECAwrBiDYwfh3beAhRkkOJiVR3ots 2ZFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHg3b82JFBIsSk1PrUjLzAEGOExagoNHSYR3K0iat 7ggMbc4Mx0idYrRkqPpw5YvTByTDmwHkq8m/P/GJMSSl5+XKiXOuwKkQQCkIaM0D24cLAovMc pKCfMyAh0oxFOQWpSbWYIq/4pRnINRSZg3E2QKT2ZeCdzWV0AHMQEdJOwLdlBJIkJKqoFRdlr p+osflgrw/xRhOnLPwYTfwOzUtXjLinIPgV2poRO3efH/57V0yv22R0fuyIfVS6LeXq6LUDR9 tX3bz9qJEqFeZVcfHH3hG/BwNq98yPNVIbmrrNkXXptb6+aQfXgV57x11oemFLaVsLa/KOXau 6jCeu/qS38usJs8fd+2gmfKZLPplbtFlFiKMxINtZiLihMBsfF6I70CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-21.messagelabs.com!1500296837!66956881!1 X-Originating-IP: [74.125.83.52] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52581 invoked from network); 17 Jul 2017 13:07:18 -0000 Received: from mail-pg0-f52.google.com (HELO mail-pg0-f52.google.com) (74.125.83.52) by server-14.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:18 -0000 Received: by mail-pg0-f52.google.com with SMTP id k14so79605125pgr.0 for ; Mon, 17 Jul 2017 06:07: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=ARxrJO2PpUTAu3cuxDb/LqKpgkms1E7Fbz99YDqPx5M=; b=IWYDr5XJJYnjm0as8NjjHzTmI1GCV33iUjtYDRypnLGXxFmPnainJa3V8A/TPGVYA6 cQ86vmYZHeGZ/zg6e7cDeLj6LSTSIHmrlwtDT+Psk8q+o9aU3/NTNvSxYTtF/Xxuao0O Lu5m3cNLaVRDuOJUnPgSp+0H2JQtwHU9gPV+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=ARxrJO2PpUTAu3cuxDb/LqKpgkms1E7Fbz99YDqPx5M=; b=f29OZz9JrO6ewmRaLrQ8BOaoor5qY0PaMoYO3A8AfMB/GXlqQahi5tP/m0vP1o7muE S7lmnHCbQhkiH64HqMTxKmtJbwCZez59YMVeo1G/Qs9jDfFWJiqbrBJdh6QIe00Ka7n3 PIIrvRrqo2hS6yR20ir/Rmcvz8jsvsS9w9+HS2HkwPfyauhgOEeWYF+YIsYEzYVYUuyH mKfo0A2Z5oV1YGrZ/b+u721qoeHaQ67rpI36oIiRaIQydHU43bus0oEcDjbDGnFJ3lh9 fV9hrIdN8PxNqA57YYwQv+DIK3yMxkN2uCuM9x0CeNIgpPB+zJyuK5Ehr5kzAMSH1FWM 9tVA== X-Gm-Message-State: AIVw1130ofCn6tG7bIVflMXZwC1YV9yi0dRK0wPak1kozga6/ZpIYkoB kuwWmMobdl7LsLeKp3RXpg== X-Received: by 10.84.218.139 with SMTP id r11mr2824500pli.25.1500296836924; Mon, 17 Jul 2017 06:07:16 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:16 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:35 +0530 Message-Id: <1500296815-10243-6-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 05/25 v6] 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 Jul 17 13:06:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107940 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495061qge; Mon, 17 Jul 2017 06:09:25 -0700 (PDT) X-Received: by 10.36.173.27 with SMTP id c27mr5278464itf.75.1500296965044; Mon, 17 Jul 2017 06:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296965; cv=none; d=google.com; s=arc-20160816; b=i/trzi59LWnEpbfNQQ3UT/ixY5BDlvVC16IfwAY1K8aXKA2+X9l7W2FqripI/H5e0Y A6fm8nPtjzDVJH3+lPDQ0Tm6tTC6Y4qTbmbkTPXlwNLw61meZ2CkcFs2ADQBDKLyaxeg YkWh0hhE3AeuCo9gcG4SiUpeV7TJs/e9hswGIDViqb2FbZo3wS9D9pOrGAqV82EcDY5M k70ONSxtCh6PH7mTlU6Lkhp2nnQOnan95A3ScdOEQfkMOo89u8eA3HRgpnGhLNpGPC5P 6bvmiXFd7t7f6eqyP/g4RUMWJ0GA9x0KNPqBtQffgN+RjvzPreyv8dFXf8F6H+Y/oueN 37eg== 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=hXytFh27rUNj1GP62FlvKzAI9K1Nt+JRkd9wjVtSAGA=; b=QsR6JzIwYmIsfOKf4u0vpKFqHRxAZtpT5cizgHDNNMh8wv+cc6wAN21JVZB1SuJfNl ua7hlXNl9hMzn48PDazQGCoKHYSAr+73J1S/x8PsjVLXpIxOLYkKxoMGXP+c1JMf8eDp R78Pl0v5AMhvFfOAF9dVYlxTDOXYzkgzBjCty1FsUQujz3uSO1w3hrjNTu54em8ce8v4 SGI/aC3F50RWC4FafRP+ZqTbZST2MwSN10qGNxovjD1AwouUUdGfeDqM2ZrF4GlxhBsq xqAFmRTJ3lgUn0nzwl2O/MMibnxQKz1JjaVwExbb0ACa0JkTps8dP4J9GvFyUxawKB5V ozQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=bsuH9uOz; 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 h200si17065241ioe.211.2017.07.17.06.09.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:25 -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.b=bsuH9uOz; 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 1dX5kC-0004Ck-RJ; Mon, 17 Jul 2017 13:07:24 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kB-0004Ac-8L for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:23 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id AA/53-02177-A86BC695; Mon, 17 Jul 2017 13:07:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRtsqNu5LSf S4NJ3PYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePikw7Ggj3RFY+PbWdrYHzh2MXIxSEkMJ1R 4kbbC3YQh0VgHrPEh+67LF2MnBwSAv2sEh92O0PYaRL3L65khrDLJS78XQJWIySgJXH01GxWi EmtTBLn/u4Hcjg42ARMJGZ1SIDUiAgoSdxbNZkJpIZZYD6jRNOkXjaQhLBAiMSp87vZQWwWAV WJFVvugS3gFfCW6FoygwlimZzEzXOdYHFOAR+JMxtWM0Es9pa4eWQi0wRGgQWMDKsYNYpTi8p Si3SNjPSSijLTM0pyEzNzdA0NTPVyU4uLE9NTcxKTivWS83M3MQJDq56BgXEH4552v0OMkhxM SqK8F9myI4X4kvJTKjMSizPii0pzUosPMcpwcChJ8LpvzYkUEixKTU+tSMvMAQY5TFqCg0dJh PfQFqA0b3FBYm5xZjpE6hSjMcekA9u/MHG8mvD/G5MQS15+XqqUOK8eyCQBkNKM0jy4QbDou8 QoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmPcTyEKezLwSuH2vgE5hAjpF2BfslJJEhJRUA6O XKsP8ZX+D4llU2KwSulb31wlOfTlF4Or03VF6xnkKbQwGmVPNPTZNkZrwZ0GntcGzAz/t/feu u7fhaYz13WeV6/k87oWK5/e4u310FF7btrfDtGiJxaW1e3tkoguCP75vX7TE46xP/MWEnxMXN Ad5zlSJ//nh7adrGWcd954M7BI/F+Z9okKJpTgj0VCLuag4EQDMeeODuQIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-4.tower-206.messagelabs.com!1500296840!103204778!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49466 invoked from network); 17 Jul 2017 13:07:21 -0000 Received: from mail-pg0-f49.google.com (HELO mail-pg0-f49.google.com) (74.125.83.49) by server-4.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:21 -0000 Received: by mail-pg0-f49.google.com with SMTP id 123so6564917pgj.1 for ; Mon, 17 Jul 2017 06:07: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=y2xkiONuPxxkYlQzekCxF6v688VdQe2freIyeNe27ec=; b=bsuH9uOzwp7hR0DJntFsbyqLLZChEe0LyS86wZmFOTTlc1Q57Bs6Rwpkct3GQ9o+MM O8kYzI7RH9TxaKG4as3m62Rc7a0ykEj9Ch0dBAAokoWmpMlM+H4T5tI1abuRUcXxdLjV H6NEYypydGy/d5SgKa8WR0i+8ijD6PBiH8EdM= 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=y2xkiONuPxxkYlQzekCxF6v688VdQe2freIyeNe27ec=; b=q3KkMyZZ+qrLscHtKSeMIgLD5/zEXYmsDjT0oe3LjkZFo1fIAMcO/RGqmHoCzmdOHS SX3WVe9iUdp+ncJhv/2q7ZCT65/8+lPwus6HVJvz/TX7UXj5CqhmTYvE1CnqwFCeQZ+F h9eicQmcvMlhq1DiKgg73NHNqP6exV6b8uAYlyu5TN4ZQhTyF0hHqnVIQVqVp6376/4m buF7xyJws9iEZJSmWjIF46KLN3vZGUF8ul7OU207RanMkD4IXyKFnszxMLfEnlSrKkZk WsItD/iq3vwxIQgbkzTx6Xfk1Tw08FOcPexZ3Cfj2d4k7mpNXBOVvoGeoz8dT+gLkgsu IFTA== X-Gm-Message-State: AIVw1113FEbxen9hRPpRzgMkfBKIlf86vnfiEjiBWBAmMwo451/a55NW oN4ktLbaAiPP+dmzStLDyw== X-Received: by 10.84.254.7 with SMTP id b7mr6405117plm.132.1500296839927; Mon, 17 Jul 2017 06:07:19 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:19 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:36 +0530 Message-Id: <1500296815-10243-7-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 06/25 v6] 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: Stefano Stabellini CC: Julien Grall 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 | 18 ++++++++++++++++++ tools/libxc/xc_domain.c | 24 ++++++++++++++++++++++++ tools/libxl/libxl_arch.h | 6 ++++++ tools/libxl/libxl_arm.c | 20 ++++++++++++++++++++ tools/libxl/libxl_dom.c | 4 ++++ tools/libxl/libxl_x86.c | 8 ++++++++ xen/arch/arm/domain.c | 5 +++++ xen/arch/arm/domctl.c | 37 +++++++++++++++++++++++++++++++++++++ xen/include/public/domctl.h | 21 +++++++++++++++++++++ 9 files changed, 143 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index c51bb3b..423c6f3 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -886,6 +886,24 @@ int xc_vcpu_getcontext(xc_interface *xch, vcpu_guest_context_any_t *ctxt); /** + * This function initializes the vpl011 emulation and returns + * the event to be used by the backend for communicating with + * the emulation code. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the domain to get information from + * @parm console_domid the domid of the backend console + * @parm gfn the guest pfn to be used as the ring buffer + * @parm evtchn the event channel to be used for events + * @return 0 on success, negative error on failure + */ +int xc_dom_vpl011_init(xc_interface *xch, + domid_t domid, + uint32_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..fab3c5e 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -343,6 +343,30 @@ int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid, return 0; } +int xc_dom_vpl011_init(xc_interface *xch, + domid_t domid, + uint32_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn) +{ + DECLARE_DOMCTL; + int rc = 0; + + domctl.cmd = XEN_DOMCTL_vuart_op; + domctl.domain = (domid_t)domid; + domctl.u.vuart_op.cmd = XEN_DOMCTL_VUART_OP_INIT; + domctl.u.vuart_op.type = XEN_DOMCTL_VUART_TYPE_VPL011; + domctl.u.vuart_op.console_domid = console_domid; + domctl.u.vuart_op.gfn = gfn; + + if ( (rc = do_domctl(xch, &domctl)) < 0 ) + return rc; + + *evtchn = domctl.u.vuart_op.evtchn; + + return rc; +} + int xc_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..118b92c 100644 --- a/tools/libxl/libxl_arch.h +++ b/tools/libxl/libxl_arch.h @@ -44,6 +44,12 @@ 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 */ +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..e3e5791 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1038,6 +1038,26 @@ 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 ret = 0; + + if (info->arch_arm.vuart) { + ret = xc_dom_vpl011_init(CTX->xch, + dom->guest_domid, + dom->console_domid, + dom->vuart_gfn, + &state->vuart_port); + if (ret < 0) + LOG(ERROR, "xc_dom_vpl011_init failed\n"); + } + + return ret; +} + 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 2dc8b0a..a1cf0b3 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -672,6 +672,11 @@ fail: void arch_domain_destroy(struct domain *d) { + /* + * vpl011 is initialized via a DOMCTL call XEN_DOMCTL_vuart_op. + */ + domain_vpl011_deinit(d); + /* IOMMU page table is shared with P2M, always call * iommu_domain_destroy() before p2m_teardown(). */ diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index db6838d..64a4366 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 @@ -119,6 +121,41 @@ 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: + + if ( !d->creation_finished ) + { + struct vpl011_init_info info; + + info.console_domid = vuart_op->console_domid; + info.gfn = _gfn(vuart_op->gfn); + + rc = domain_vpl011_init(d, &info); + if ( !rc ) + { + vuart_op->evtchn = info.evtchn; + rc = __copy_to_guest(u_domctl, domctl, 1); + } + } + else + rc = - EPERM; + + break; + + default: + rc = -EINVAL; + break; + } + + return rc; + } default: { int rc; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index ff39762..f70b7a4 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 @@ -1146,6 +1147,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_* */ + uint32_t console_domid; /* IN */ +#define XEN_DOMCTL_VUART_TYPE_VPL011 0 + uint32_t type; /* IN - type of vuart. + * Currently only vpl011 supported. + */ + xen_pfn_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. + */ +}; + typedef struct xen_domctl_psr_cat_op xen_domctl_psr_cat_op_t; DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cat_op_t); @@ -1226,6 +1245,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 @@ -1288,6 +1308,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 Jul 17 13:06:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107956 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495464qge; Mon, 17 Jul 2017 06:09:40 -0700 (PDT) X-Received: by 10.107.53.147 with SMTP id k19mr20448458ioo.29.1500296980593; Mon, 17 Jul 2017 06:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296980; cv=none; d=google.com; s=arc-20160816; b=0ZIptt9Iu68EHG5YL1ySwk4W24Fbw7MJz31vNUEqTD9ZUEKKqKtqiUcMXozXiEwPq3 UEveLIlEYWgVkEu/agV9tV6Yd53C+ho0ftQ0YYqTAvjf2Ci9+F38BOT0UUNCAhRLtmmn rj7d4AGg5sqAwfTNxzTTRe0UuGHRaq+tIcoxT6+CQGdhtULy6vmq3J4K+pRtQwDzhY0V 8QpTvHbcqJ461eD9H9TwzUN4TcTSBrKka19eo8U4NDrchzGJmB6Kkkjd2l8f1OxqZyLP WvlU0FzJABASi9bRJkE+8mKmm61qUXYGz+L4dYduCc6huGzscL2SWEneoinz8htKZAUY WU9Q== 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=SW2aq9zzjCQ18TTi2INZoESwSgSHxe1QjXzpP3p1BT8=; b=XcTLwnsBhGPz/usOeFMZlfZDE73L/26IWVXd0mlH90ionMBUiDpflKD7iECioasxc6 kVVFy2Y8kRkS6QEIUeZUS2CijRhrDs1APQagOoO1CMfJfrpcfEHNViSKeFzgVZkpNtO2 ANjgNZiwZOctkcvVIZuLKR05Al2Zd7opnoHGAIea5MXK569/ygSLnUubZOqC/k8HbzsI xbRbjzpdrB0qwrnaNjbfMzMrghFBY+WrT5zxECh6zo4cd3p2hROiRUj8J0KF+At89AdH nbf81bcYLe9HqelCCGFDHrjybo49755+EJSos6dtkOTw1tDqPjQuljuMHfpU7h5CazSh XNjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=NpTqQKVk; 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 l128si9989101itd.82.2017.07.17.06.09.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09: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.b=NpTqQKVk; 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 1dX5kG-0004Gl-6N; Mon, 17 Jul 2017 13:07:28 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kE-0004FV-VY for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:27 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id F8/E9-03044-E86BC695; Mon, 17 Jul 2017 13:07:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRtsrNu7LSf SoO+GtMX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvHxxy+WgldWFecbVzA2ME7Q7WLk4hASmM4o 0Tv1CiuIwyIwj1nizZ2LjF2MnBwSAv2sEnvX2kHYaRLNV5axQ9jVEhcWzQKzhQS0JI6ems0KM amVSaL162Igh4ODTcBEYlaHBEiNiICSxL1Vk5lAapgF5jNKNE3qZQNJCAv4S5w42QO2jEVAVW LhshfMIDavgLfEwqW/2SCWyUncPNcJFucU8JE4s2E1E8Rib4mbRyYyTWAUWMDIsIpRozi1qCy 1SNfQTC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzC0GIBgB+P9jQGHGCU5mJRE eS+yZUcK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuB135oTKSRYlJqeWpGWmQMMcpi0BAePkgjvV pA0b3FBYm5xZjpE6hSjMcekA9u/MHG8mvD/G5MQS15+XqqUOO8KkFIBkNKM0jy4QbDou8QoKy XMywh0mhBPQWpRbmYJqvwrRnEORiVhXl2QKTyZeSVw+14BncIEdIqwL9gpJYkIKakGxppbEQy JJoYlHLcfdi33vBqTcjBTYuPGPMEU9cUPF8w+X7BgPsNEw0Czx1cWSBq1TIzfahTbf3/66slJ 8y1SpHZfnxArqtH1P2/Cd4NVZ9a5LN/HonFotxJT2L5yzx9RMf2JzndCnzTf5MiaJZjFN9dmq fU7xcJyN4tM3wuxie/b16ZGr0leqsRSnJFoqMVcVJwIAENnvSm5AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-21.messagelabs.com!1500296844!73509524!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35644 invoked from network); 17 Jul 2017 13:07:25 -0000 Received: from mail-pg0-f51.google.com (HELO mail-pg0-f51.google.com) (74.125.83.51) by server-8.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:25 -0000 Received: by mail-pg0-f51.google.com with SMTP id u5so17082261pgq.3 for ; Mon, 17 Jul 2017 06:07:25 -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=JNqQYeEdszEh9zL1K9j6W7Wj0clHDjwgfUgP8JcRPG4=; b=NpTqQKVkGnPkKip3m3QO4gHthbap1ssbsiYLUhTZLIDnTK+VHxIVN2MB3/y1x+dNW7 zYgkaqsHePBp6YmpT8oYFFe4uf1YqXdxSRirrBhshDwT9Yh9qTrg9MdcUnwdQHDqSz4l KVSJJRrecywJe7O8F5D015MUoXJR8sjI1C6uc= 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=JNqQYeEdszEh9zL1K9j6W7Wj0clHDjwgfUgP8JcRPG4=; b=ITRWwHbfIwapBkdIJcBHMdrAn2AO/pFuY/oQcfpb2+12UEqdIm+njDAULWYRzuNO8v h4W2OyiSXMlfd5ypXl5vpvpZPRz7WtzFqCad/YlYIJogrsj2iDAwYrNT7HqKzqd8vHpu JRNs828bA69c0t+02hVaH8A+J8NzXn9h6oF3D9gsWm4pDKDHr/zViaucBD+KCNzShZXs 7MC6ujLL1d7Ubiqx3YRwn2jkqpvTSU81zK22JCy9u4hTyPRikDQg3qpdt4hPQVSCzNvq JaO2sJylq08rvlPSTs7YniPC1dRHeQY0RodKJc5Sd6lqc3MBLyDiDaNcgXt5zSud1TxC 5qfA== X-Gm-Message-State: AIVw112kL8AeTHwI1qZ7TSA5iFPEjLHSPQ18Sf9s6SoIc72vwM3W45BD XKnyMc4fQzIuTfn03CecOQ== X-Received: by 10.99.42.141 with SMTP id q135mr28595980pgq.175.1500296843544; Mon, 17 Jul 2017 06:07:23 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:23 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:37 +0530 Message-Id: <1500296815-10243-8-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 07/25 v6] 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..54bc191 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) { + 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 d0d50c3..2b3f4e1 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 Jul 17 13:06:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107950 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495289qge; Mon, 17 Jul 2017 06:09:34 -0700 (PDT) X-Received: by 10.36.7.202 with SMTP id f193mr5239543itf.80.1500296973944; Mon, 17 Jul 2017 06:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296973; cv=none; d=google.com; s=arc-20160816; b=VO0l/XQVbZ+CrOqYL+uOI2sNSawXa2G4m8Vw9vq29bXYHfcIgUBZVxKKj+4pBdLS6d z57+Tzsnl6Pj29795xixrxHvtBr3jhH/PA9Gmx+JTCIdeqTxb3vnuNSHCeHbsx/I98xL 2qtcmnPV6xa6CHfmjCrSdQRhoTMWZq7AgH6qo1MdCg+HPLnrRJOCs39fztwp9P1RqPqr RqFKkBzP3q2X6CLYx6wD/JQk+wJjzARK/BbyHJc0uV+xEJHXrOadFABK38N7NgTYYUyV dYSDl630pJa+2jsw2OVMd4UtZwditnxs2QhztvlkTfC+z2frn1QhHc2IZ7hzgrmaWkUT sM6A== 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=HemsB7VmasPwm2npY0R13yYFKIHhAYNJ3M9H4Hz7gNkaZlPOfOO1+ynP2QP9/TNHQm BN3mgISyzjP2hG2CUKhz9tlxCrVD7zoNWfTTyL60OOa4Ihl2C4AKOjq9wtntgsBkrREY xtwp6bdsizHahductyIaxX7iYM5OoryWwMtOF4Vs2bQSVoOt7Y7E72VTXwo9Tx4DI0EB 9WoNzfcmxcGFrQuLUJSHOPfPvxd99fGgU1vPLemDzZf0djX7t4dqmIobqMc+eNnpXfWZ qhxFIMvCavPaSYsr/CedR6wk1RipkBGbLVl22XoilQVN13+JacWe7t4I/jMEOIHG6rpM xIaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=ZrRqPU39; 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 y4si10559103itg.74.2017.07.17.06.09.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:33 -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.b=ZrRqPU39; 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 1dX5kJ-0004Iv-EA; Mon, 17 Jul 2017 13:07:31 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kI-0004II-SV for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:31 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id A9/47-01729-296BC695; Mon, 17 Jul 2017 13:07:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsXiVRusqTtxW06 kwa05nBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8afmzdYChYtZqw4t/okcwPjkhbGLkYuDiGB GYwSP36+ZQdxWATmMUt8Xf6QuYuRk0NCoJ9VYvJOcwg7TaL5+j+gOAeQXSXR81kPJCwkoCVx9 NRsVohBrUwSfXe+g9WwCZhIzOqQAKkREVCSuLdqMhNIDbPAfEaJpkm9bCAJYaCZ949cYwWpZx FQlbj4LgMkzCvgLXGu9TMLxFo5iZvnOsHO4RTwkTizYTUTxF5viZtHJjJNYBRYwMiwilGjOLW oLLVI19BCL6koMz2jJDcxM0fX0MBULze1uDgxPTUnMalYLzk/dxMjMLQYgGAHY9N2z0OMkhxM SqK8F9myI4X4kvJTKjMSizPii0pzUosPMcpwcChJ8LpvzYkUEixKTU+tSMvMAQY5TFqCg0dJh HcrSJq3uCAxtzgzHSJ1itGSY8Pq9V+YOCYd2A4kX034/41JiCUvPy9VSpxXD6RBAKQhozQPbh wsEi8xykoJ8zICHSjEU5BalJtZgir/ilGcg1FJmHc5yBSezLwSuK2vgA5iAjpI2BfsoJJEhJR UA2PLsfQpn//LyIYuipkeWbTZQdrpK6/skaX7I+JWtmzcoqTTxzola1E938Kf1uGbWWc/0r3o u7T4SP29upwC2Xn6haLbVzAfunCPu3Hp9Z/+ItK5r3vSkuZ6vzdjYdh+pOYqUyDLSYbNYl+3m 3nNurXKyIWF22Ly1myev7fXq1cs2uOV8n7unrNKLMUZiYZazEXFiQAQGxsEvwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-206.messagelabs.com!1500296847!103036717!1 X-Originating-IP: [74.125.83.41] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50262 invoked from network); 17 Jul 2017 13:07:28 -0000 Received: from mail-pg0-f41.google.com (HELO mail-pg0-f41.google.com) (74.125.83.41) by server-6.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:28 -0000 Received: by mail-pg0-f41.google.com with SMTP id k14so79607388pgr.0 for ; Mon, 17 Jul 2017 06:07:28 -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=ZrRqPU39phMFut5V8KjXrbc0OgWQg0KJFWRQGX/DZTmBOaXf4/ZErAdvA3hqDcY54B fF3ATmLgFI59DCQY2pSFfiDTXjOzx6L54MM9NRyvl45LreNn20g1Aiy5RyMWIbu3/BKp EkA9kfpnIbXaXmc/OGJs1oBLFo2fooNqqe03E= 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=cOW1laCmuNlo4+iVfbfgJWoqQp/JaNwOc1yY+BybtaN/y/wrwh2L5iDt1hiiduqDC8 UVznXAQLoAM0PnmBSIFubRXFkc5jqQqpMR6BDaJmvVu5s+WBFZ5y8Fa1unkl8GnQAy3j 46sS+57sa2+LG9Qf74BaJJ4brtrYtmOFOTEwAJIJkx5MYtFhP3AWpgjBm+64fD8m6YqV EIYn0nUIqYUwvzdxGdLpuZlaxsceUjArhB2f2HpiJEbopA6zqPpwOh10SlUFMeiktuq/ CrohHzKmS1N1bMw+p6Cd4Z3qo09QUbMLNftVm+krvstUkdBtHJvsKsT2B3gVtg1J2YQ/ iyOA== X-Gm-Message-State: AIVw111X3gUMgeleDr9/myE8c1nm1gmsZb13B6rpkw3bsNQaVDMRTgbz XGQndEeF9Xst0swLZS2WCQ== X-Received: by 10.98.209.76 with SMTP id t12mr19102827pfl.190.1500296847062; Mon, 17 Jul 2017 06:07:27 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:26 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:38 +0530 Message-Id: <1500296815-10243-9-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 08/25 v6] 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 Jul 17 13:06:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107945 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495209qge; Mon, 17 Jul 2017 06:09:30 -0700 (PDT) X-Received: by 10.36.150.2 with SMTP id z2mr5072457itd.6.1500296970921; Mon, 17 Jul 2017 06:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296970; cv=none; d=google.com; s=arc-20160816; b=g1jwYxL8DGVzOx83c3HJ+3m98Ob0jSBIAc97IO4c2M0C9IWzOCFRb4JEoU8HWiaOSw 27maq5Fu5z8zVa6ahzHx6HTmsufG/kDPz4jKvKcYrYCI7PL1c1xD5vHf2j/OB24owbCx +cVaDLuvpRxlV8wM6EP3lwda0T7lZBGv1SC2toLIBQZN5RoKCfWs3bqdLFvsyRkCJRvo qm6pcTbZqVnGz9p3YVLKBGaIsdDYaqA6x6pSHlG/JQ91nxJuGjQrJYFDZWrCy4Od64QL HbkpiAKACZKGHUQE0G3WC4SWFy/vMil2+Q8lWwJnz+HMzMgw6UI182aT2QW3saS9pqM5 b98g== 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=fgYnVAMew++XyqT6dW/26a4RXH+wdUaSQEfJ7w5O3NJHRNNcjAx//HRDIGiLyzOdTc 1o6nCOnEIlgK2CkNMSBP9zS0AjatFeOdDGAUrr5a5svBrCfQCo0zsvNJL1btSJMI6BFc Oz0jHRk3sN0rbmU2qU7MDZzT4EQbldovItKHl/5vNOxmcf7bq3bzr0OzP827gd1Yc/0y kOCDdPdRaF/VeMzZr7phNM1Zi39MnWW4//xhDO+k4GnPCDoQgB88bgejzvxfhgaeI219 /0wAnVabHFH8uST28M9oifhCxZNGOSglTf1tuTnYH9SLATSjbogOYVWiJdjcxCcwNePr gCBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Hj6NJee/; 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 k81si19418317ioo.264.2017.07.17.06.09.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:30 -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.b=Hj6NJee/; 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 1dX5kL-0004LL-SB; Mon, 17 Jul 2017 13:07:33 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kL-0004KZ-2t for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:33 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id E6/93-03368-496BC695; Mon, 17 Jul 2017 13:07:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRuspTt5W06 kwa7/yhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aF173sBX+lKzbc/M/awLhfvIuRi0NIYCaj xOKPN1i6GDk5WATmMUt8npEMkpAQ6GeVWLr5HVhCQiBNYtbMRcwQdrnEvK3HWUFsIQEtiaOnZ rNCTGplknj7/QxbFyMHB5uAicSsDgmQGhEBJYl7qyYzgdQwC8xnlGia1MsGkhAWSJDYMvcUK8 RmVYm1R7+B2bwCPhKTuz8zQiyTk7h5rhNsMSdQ/MyG1UwQi70lbh6ZyDSBUWABI8MqRo3i1KK y1CJdI2O9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYzA0GIAgh2Mf+YHHmKU5GBS EuW9yJYdKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mC131rTqSQYFFqempFWmYOMMhh0hIcPEoiv FtB0rzFBYm5xZnpEKlTjMYckw5s/8LE8WrC/29MQix5+XmpUuK8eiClAiClGaV5cINg0XeJUV ZKmJcR6DQhnoLUotzMElT5V4ziHIxKwrzLQabwZOaVwO17BXQKE9Apwr5gp5QkIqSkGhg9fSc oxuRVpPz9oc/AejB4ztSkTx8/TGJ/dCBERHiJ7eS2xc0T9ZSzoj83idlqPrkmcOJv+67VsecE vvpkVHSk9Qnl/FCQWrC7veONPRvzphVqxgdLvAxuZeZL2jPeOnvi54HCU58/1nx2UjZ4ZHptr 7kEA8ua/1sLv61P7ml96tHdM+drqIsSS3FGoqEWc1FxIgCheHmduQIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-12.tower-21.messagelabs.com!1500296850!73601689!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56406 invoked from network); 17 Jul 2017 13:07:31 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-12.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:31 -0000 Received: by mail-pg0-f42.google.com with SMTP id v190so21520742pgv.2 for ; Mon, 17 Jul 2017 06:07: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=AGHJrnwneXKl3Z1bjGKh+k5Ixw7YK+0ghFT9u/p0sak=; b=Hj6NJee/MK53sC8Nbi8hjLbU3HNTt2UP0ksFgBkAcQ/Eu4wgGHiX4nJO3ZSOBVFRwW yrcu6jib0UVlesJPChBE6J1rOgU/UWtsMEsowPXqUebVXMIjaWBsnJKNNm0UvhupmWN3 y9ogJnJZccZRlIXui814Dbr8f13JQ7cy/i9uQ= 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=QVEvUPMCd1IbQ21EvT7yICOslqlcmmMZ3MpuQmh9IHJeqnwtyNd2ncIw1JBYXaOTHZ 7zdhsADkqaK8be++0xUH+hxBaquP4vYtoaUCxRKkKEPrYKo8i4uB3digNTZ57GCGA3p/ X48UlYt7xfVgtSn7zGDFcFMNnmfGDkGCXPLvmlwJzDCALG1GLdLiPWGJME9POVEEdf+o uU0EpFYzosIpGNL+sz82vj5T0LxVtQfLHmv4ywSsz2DuM5YauJoFvETR0E3fWcwS2Cer 8xYfCSzUOwbrsdK5mjUDTqBGowM9qH6vGhN2+MW4UEuO7rQFYtY2bqoKWw8XmNbZlKAt j/mg== X-Gm-Message-State: AIVw1131NHJqH4sQ95mn9vNj0FjKPRfclNWrnBuykCw/l+at4W96s4XX xvSg5bxKg2z/ont0Wm4Lpw== X-Received: by 10.84.254.7 with SMTP id b7mr6406013plm.132.1500296849929; Mon, 17 Jul 2017 06:07:29 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:29 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:39 +0530 Message-Id: <1500296815-10243-10-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 09/25 v6] 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 Jul 17 13:06:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107955 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495449qge; Mon, 17 Jul 2017 06:09:40 -0700 (PDT) X-Received: by 10.107.178.13 with SMTP id b13mr18800917iof.148.1500296980020; Mon, 17 Jul 2017 06:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296980; cv=none; d=google.com; s=arc-20160816; b=XZ9pSCIgFc6X4RTZtMhqn/jidxZZWHMQVUnMS/yJR6BDty8gSL0R9W3cwhgXjU3aKy qooe8A+x9z3ZMTKPfmroUbqmuwcpYYDk+qoJ9nl1P/K3qCQikXdlkj3joTw1jAn/Mlcj QTL1eK3wBrjkdJlxeDKGBo3M0Z1SegdEqjSTss0bC8xLkkFuD72zvZk+70K3GmEtkeQ3 mBDj2P/jXcZAUvd67CGL88IxgkwjKrta18BC6f89dVgc+r2Jw6mL+VQlB98gDDWIyLOj HkohjpVXlS9rb0uf2KVvljpKghw9VHKerfu3EVkr5Xe/uUAqoiCtHgHdpZqMyFyU/KC9 q8KQ== 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=hVr1E6WHtOIO3krkzIkYYPaA6oEC/W+CUnM47gTbzTI=; b=XHLDCP3PB5GpMCISLmdAv8ghFXVtxgzoa+mENX5StmgbTk7m8ugqcwHoB4jrVDWK6s vKdb5HsSVsVfspouTOoLhGfWcCaWGnIKXjWVLXJojMoyumfrQ26+VAXhB2dC4hSSyD+o /H3pgRgr7z00BuO90axl9rxnmKuWL89KnBc4PV7ZbiHTNTaRo1fPPwZyEk9Nn2kseQgw 1jhlKfbF4DSlCMkEcAmHFrHEwMt15PI88JWbce2VvF6szT9aMnzDYi0nN1piJoETlnpP yAd/owCdgSGQ+7TKT1jLWL4h9TjbR8k89eRLaViiokADEtwr8nKKJSbN11zw5unbBNQp ilXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=bWusymcm; 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 d138si9639542itd.84.2017.07.17.06.09.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09: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.b=bWusymcm; 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 1dX5kQ-0004OS-3Z; Mon, 17 Jul 2017 13:07:38 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kO-0004Mr-AB for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:36 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 2A/10-02176-796BC695; Mon, 17 Jul 2017 13:07:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFIsWRWlGSWpSXmKPExsVyMfTAZt1p23I iDbqnW1h83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkrrm1mLnjpWTFt+R3mBsafNl2MXBxCAjMZ JRZf+cfaxcjJwSIwj1li898ckISEQD+rxOLtOxlBEhICaRItz/8xQdiVEl+XTgKzhQS0JI6em s0KMamVSeLnnxlADRwcbAImErM6JEBqRASUJO6tmswEUsMsMJ9RomlSLxtIQlggU2L10W52kH oWAVWJlf+yQcK8Aj4St7a9YYbYJSdx81wnmM0JFD+zYTXUXm+Jm0cmMk1gFFjAyLCKUb04tag stUjXXC+pKDM9oyQ3MTNH19DAVC83tbg4MT01JzGpWC85P3cTIzCsGIBgB+Oxyc6HGCU5mJRE eS+yZUcK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuB135oTKSRYlJqeWpGWmQMMcJi0BAePkghvN Uiat7ggMbc4Mx0idYrRkuPKlXVfmDimHNgOJF9N+P+NSYglLz8vVUqcVw+kQQCkIaM0D24cLA ovMcpKCfMyAh0oxFOQWpSbWYIq/4pRnINRSZg3E2QKT2ZeCdzWV0AHMQEdJOwLdlBJIkJKqoE x4UBua5V364+avtboisLVus8Omxwte7/Qjfv3goILZ9V8750/FtgWupzhyrNZ3XvK4tfJty48 VZCRzR2cW2a34JaOJ8PD0xFBNjfL0t5MVUgoVV0QzeTavNls7/lFLfYytkc/CrucUb6tmO14b P9GvklvtYM2Sp132RptWHL2X3r0IUX31P1KLMUZiYZazEXFiQDDV289vQIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-206.messagelabs.com!1500296853!83443924!1 X-Originating-IP: [209.85.192.179] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25997 invoked from network); 17 Jul 2017 13:07:34 -0000 Received: from mail-pf0-f179.google.com (HELO mail-pf0-f179.google.com) (209.85.192.179) by server-11.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:34 -0000 Received: by mail-pf0-f179.google.com with SMTP id q85so76278138pfq.1 for ; Mon, 17 Jul 2017 06:07: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=WSHRE73rlFnr9/xtlikbDFcIrZmN20tjTuPY4716tKY=; b=bWusymcmfWM+uIOJw4vEid0ZyrpcMxGKNNqLzXMO9jv7e2u1kUZodVHk+r3TD9Yw9p j3NywyedD3Q2S3//nmG77uRfZoINFRF6rnKyE5nBwqKt47xtFDa31s5EVv8QD6FQJe2a jUFLnrYbuOy+ltHA4lFzxOrBAnGHUUoFJ/SkE= 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=WSHRE73rlFnr9/xtlikbDFcIrZmN20tjTuPY4716tKY=; b=q/YV/tPTYmbezPJCyvN6YAZmQPtq9/FUHPXuD4s4Rhdm2fUeNWamG64kQoh9avKykr 1rMLPyBcekri4r04KZoKkZWW6hyd8i7mLAPV5zxvXE2hfgz/cYjlpENrIeW6h4dfYu1l mrI50N+Debh4d8C19v8HRZ9hU5qehYL5ApUT7FIilzt6J7x96nr69X6aniNxnqZ1nlsj a8fNLjQl3LlAXtxs8XWu2OI1jnr3dlq/kh1qxZGIJtO3KDV/XVpwRW9iXULFqiZ9bVbh 6BKYNbiCYRAv5bLPxZ2hbkfZmVg6KNcUNZSDNUuAP/OwIhUiumMmYMr/YlhAxRl4PbUV /r+A== X-Gm-Message-State: AIVw112Mxx8LfVW5QVILoxKkO8s71EGoQNwoNNso6H4XWNe00RJplQ4M 6DI1fKOnvONHUh12RoqOAQ== X-Received: by 10.99.166.17 with SMTP id t17mr29246058pge.60.1500296852979; Mon, 17 Jul 2017 06:07:32 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:32 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:40 +0530 Message-Id: <1500296815-10243-11-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 10/25 v6] 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 four 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 Jul 17 13:06:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107937 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495001qge; Mon, 17 Jul 2017 06:09:23 -0700 (PDT) X-Received: by 10.36.91.20 with SMTP id g20mr5676211itb.113.1500296963019; Mon, 17 Jul 2017 06:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296963; cv=none; d=google.com; s=arc-20160816; b=q0VUlI3kUql5NccX48yE9/JYJx2XvG/tFteoVp9sK2uHZQfD/RC6+LnK0i7XgCme7f 0mZ1meKAqOFIj8tZ/lKvM6iRIb3g6zQniAb6EcwR3aLT9dIum1BgfpQp8AtFhkXBvA2m AkGWcJsZPCdENfqDLhlm30S1ZB71YMKCgFt/0djq4prcdD09c82GHu7/zuMq1yhF+vqN BwO1UVVnOD2GbucRSLTZb8M768/80FG7CcBLHMe865GWL1rvXyLMKTsNJC+dbxBsF1Z+ RCJ4/tHrRW8DRwhh4tcBNQX2ZfAEqLYdf6idwanF8cQEyQMh9vfeZzFj9MZKHqw0qWoC zNvA== 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=y50pSFgLghEJgiQ48wLZ2wTjoOUf4Z4edg2+h1CIhl8=; b=pmxx8MR6JJyyC+L42V1vSiltGeRB9RTPm5QeTc8NKROPhrg2BQPIKXYFXxtlrAa7YZ kxCOoRl2Z7wiPhNXziu13MkXmaMAYlpNv0xCaqVwItmZ+IR9T8sKclBGg+swyC10nsh4 r+tUIvzj6fICGFe1c6HolXd/zy3IANAYhx0C08xLbXLcYlHcM3qPDzF38vc554PRoH3u S/Im77qwijT6u7wTMqJwaPa6MIjlm0O+9f4x+LoubpQzkJ38aCt6PZjBx5pqYt3aIEoF bQMlNVhTpVJpWFHx7eQgVxM2uNr3Oprjw9i38+j1Oy7JnGtS4Bqrmr0sybBMhZmPIU6g 2B1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=a2+XmI5J; 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 l20si16354875ioe.171.2017.07.17.06.09.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:23 -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.b=a2+XmI5J; 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 1dX5kS-0004QO-Al; Mon, 17 Jul 2017 13:07:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kQ-0004Ox-Su for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:38 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 62/D5-27137-A96BC695; Mon, 17 Jul 2017 13:07:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRusoztzW06 kwapDYhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aHbQ/ZCtrEKxYumMnSwLhYuIuRi0NIYDqj xKQ3ZxhBHBaBecwS3S1nwRwJgX5WiSs7rrB3MXICOWkS2/YsYoSwKyR2nmsEiwsJaEkcPTWbF WJUK5PE3rmzgBwODjYBE4lZHRIgNSICShL3Vk1mAqlhFpjPKNE0qZcNJCEsECGxvmkT2FAWAV WJpYf+s4DYvAI+Eqf79kAtk5O4ea6TGcTmBIqf2bCaCWKxt8TNIxOZJjAKLGBkWMWoUZxaVJZ apGtkqJdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJERhcDECwg/HPsoBDjJIcTEqi vBfZsiOF+JLyUyozEosz4otKc1KLDzHKcHAoSfC6b82JFBIsSk1PrUjLzAGGOUxagoNHSYS3G iTNW1yQmFucmQ6ROsVozDHpwPYvTByvJvz/xiTEkpeflyolzqsHUioAUppRmgc3CBZ/lxhlpY R5GYFOE+IpSC3KzSxBlX/FKM7BqCTMuxxkCk9mXgncvldApzABnSLsC3ZKSSJCSqqB0UXihfe +UwfP7i86GJSk/au6V+mQu3H16sdxs/e6F0Wa6D/70XWJ22xPpmldTXNnVMd/gUk1U9buCC9/ 8m39//jlkzw2vle6d+JsH2/Yn4hWyf74rL9qx3fpJk3IErTOOFF80+h/fhlDhQe7aMuPtXObC xlNI4Tv/Mv02HLrfdCuLUJXDwSlKLEUZyQaajEXFScCAADrWFS6AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1500296856!107623548!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30171 invoked from network); 17 Jul 2017 13:07:37 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:37 -0000 Received: by mail-pg0-f44.google.com with SMTP id 123so6568556pgj.1 for ; Mon, 17 Jul 2017 06:07: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=6B3hwzMdVFS42UPpfp85EMbOcIpuHsakwVd0ckhk56Q=; b=a2+XmI5J+Ak/a3O+OYPAb9xg+BGxKhMVcNvNMzZO2HBLhFE4xiEYj1oaOvuz9cQSnE cd4Qh8u45U/hwG65gGq0+YfpA/0zcFxY7FXq1oDblR6CR7/qvN++Dj7LKa0a2s3nYWM/ Zi7z3O89Npu9ZqDHmq4osMmzIbzoQQvObr2WA= 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=6B3hwzMdVFS42UPpfp85EMbOcIpuHsakwVd0ckhk56Q=; b=SL7MZXG8CSyuXWt0f6uLaGMw7SjS1c/O+Kg2zawIZWrs8edn5UiasoTpP+kYOtLdV3 veJqIzNRMNFDrls3wDTkbEjSyp6LgWcbd/otVs4ZIta2j2EXyvVgIMYxb6FBEPLyUb8E r4+1xiPQB+N8gmBRWnCfja5KeMh9NehMBNbudhOM7mtvxOuoYFhxFZ+5jy24zHBMgvl1 bQ9igR3fyrlcif/dGyLmqsDBLMv7RJDrGDKaWlfYipAkAZCj1au+7sQv+UZTlfo8dOTV piBAoXi8ghdX5j8CaMg9lYiEYfhauv1gdncExKBQTHJDT7kIJf+bnRjJDErY6YJiWBdq 7A0Q== X-Gm-Message-State: AIVw110DIt6NeeAAVEUCj87/5fgxFmFsmios6wM5plLu+hMpTMEL46x2 7RmGY0rHtsMdRq1Qeo64xQ== X-Received: by 10.99.177.6 with SMTP id r6mr18880492pgf.106.1500296855756; Mon, 17 Jul 2017 06:07:35 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:35 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:41 +0530 Message-Id: <1500296815-10243-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/25 v6] 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 --- 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 | 64 +++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a2a3496..9e92097 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -655,13 +655,10 @@ 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; 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", @@ -669,6 +666,41 @@ static struct domain *create_domain(int domid) return NULL; } + 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; + char *s; + struct console *con; + dom = calloc(1, sizeof *dom); if (dom == NULL) { dolog(LOG_ERR, "Out of memory %s:%s():L%d", @@ -677,28 +709,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 +724,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->xspath); + console_free(con); free(dom); return NULL; } From patchwork Mon Jul 17 13:06:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107953 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495405qge; Mon, 17 Jul 2017 06:09:38 -0700 (PDT) X-Received: by 10.107.199.70 with SMTP id x67mr4893272iof.113.1500296978755; Mon, 17 Jul 2017 06:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296978; cv=none; d=google.com; s=arc-20160816; b=DuoHuD+2RPKa3XqHZZLk5LyqX48tTOIqBvP5Jl4ywxHv0E94vRhRrbVA70dDtsZMYf MOpGjImxoiQh3JyRZ+pcdBFcRxiGLOMu29GA3l+xqXKcYsCnitovH+KHSddEjuRB2KsD jeV/6ok8ddwS9H7mZtX5n0E6bf6QyUKjxQlRjL7hERFyinBGEOkaNiwN50j1PfEM3MrG z0ZRfvvT7mm67OWUT+5mYs6zp9wtCVGyBP6Fb5+1UBn2ut85/COFIhVqRY74nJr5GOal DVirHV59O9i4k2FazaCfN6dNTDzyVZbpI0EpljFWnT3f+1ys6o+JM6ovE85d3lUVS90a aflw== 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=76uW/On4uo+MGDexRuA/NlYGr03xCtPcEII7BLo8F7o=; b=yRBMzTGpx0gJ5qCVyl8Ef/xDXR7/IE1iJwb3t8eFAhIFjtCshdpe7eVqLFRjkfQNJp wREJZ1Q+Q+ZEepb6vVGGQS9iM2sOVBs5jKKS6aWrZENoIyoHGsSgytJ74Gm1rc5cTy/1 6zZwfCi1LewtvfA3IrxSsoSwBWxQZtzIkNws2XV/9/0H1rosdsaX8opcvUSI/8z/s4LO HfojFyi1QrndCoww5elG6DioCQ+QyvuyytCJ+hEgicUkTjbe7fs0GYCHh/iixhralLeK 1LxexmT89syaRyHcw0tO5gfS2bc+BaIBK9NtQc6HFYHuGyAl57w8YUBVOAw8B0rCj+uS Ud3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=f7VUbHxR; 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 71si17264762iok.161.2017.07.17.06.09.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:38 -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.b=f7VUbHxR; 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 1dX5kU-0004TF-I2; Mon, 17 Jul 2017 13:07:42 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kT-0004Rq-Jc for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:41 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 55/2B-01862-C96BC695; Mon, 17 Jul 2017 13:07:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRWlGSWpSXmKPExsVyMfTAZt0523I iDfb+E7P4vmUykwOjx+EPV1gCGKNYM/OS8isSWDOen1zBVDCVp2LdjsAGxg6uLkYuDiGBmYwS 1x6vZO9i5ORgEZjHLNHQxgqSkBDoZ5U43rGGCSQhIZAmcejGSUYIu1ri74keZhBbSEBL4uip2 awQk1qZJJ7+PgCU4OBgEzCRmNUhAVIjIqAkcW/VZCaQGmaB+YwSTZN62UASwgIxErtuHmKD2K wqcXvZFXaQXl4BH4nrJ8sgdslJ3DzXCbaLEyh8ZsNqJoi93hI3j0xkmsAosICRYRWjenFqUVl qka6RXlJRZnpGSW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGYFDVMzAw7mA81ex8iFGSg0lJ lPciW3akEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQle9605kUKCRanpqRVpmTnA8IZJS3DwKInwV oOkeYsLEnOLM9MhUqcYLTmuXFn3hYljyoHtQPLVhP/fmIRY8vLzUqXEefVAGgRAGjJK8+DGwW LwEqOslDAvIwMDgxBPQWpRbmYJqvwrRnEORiVh3kyQKTyZeSVwW18BHcQEdJCwL9hBJYkIKak GxtpbnvGKV11LGQznrzOYEqHr0+22ZfsP96ef7iZxrLgy260n3fnB9E8feIUF3hx9lPHHo/1K iHrRPbev/ZVKWgsTF0TaXKqMElgQsc33QU16zXOtiYZ5KXOaH51c7Ll01/ETzy6Y+ZhmSvzie vLo2TqD8BfRAg37Zd8X7nl36kzzftu5YeKd2kosxRmJhlrMRcWJALamZhC8AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-31.messagelabs.com!1500296859!102568778!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64310 invoked from network); 17 Jul 2017 13:07:40 -0000 Received: from mail-pf0-f179.google.com (HELO mail-pf0-f179.google.com) (209.85.192.179) by server-5.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:40 -0000 Received: by mail-pf0-f179.google.com with SMTP id q86so76270839pfl.3 for ; Mon, 17 Jul 2017 06:07: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=Bp2KeyISDm8F00CWkRPVKLBIMQo3xxEHTOTb71G7vEM=; b=f7VUbHxR92oJdVnc752dK0QkPl9Ao69ObW9zmYjygVw9eGqHff1PxCJA6KXuIBgIfQ g94InrOJTQSVq9m9rZ0dg7Ic7hVvjfOEkNkXHEVqlTJDf7S9Srv9ZlGMrAcCFwyulofA XUXBiAqbkayTGifJ4s6lDHjQC/az+txhGIdkU= 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=Bp2KeyISDm8F00CWkRPVKLBIMQo3xxEHTOTb71G7vEM=; b=WCOp8CjWZMKiFV2HPbwg+GqeH1sNmACwK1bgrGBNvhCM4GiENDRHOq/1Y8kVVotXXv 1Dce1webopu1azWeoGGP9TzaCvYffYHTe1uUrBMXgXNMiYSUq+nB0gH2XzTbF+dLzh9a oeM7i76mgiATY29K8pE7WG+3OtKu1no8BuSQgm1l9sqPs5lyvPITDv84K1BVizeBSsxb IxHLEQgLMD2ZHL3OhXYWXRcN/jIaZwQk562bGajtQGzdk7FG81z19SHln4Ai/fE9qpPq TlWJwnDLwc7cMhf+KM1l+QVv8xPH2Vd+D0z+16UONdqtBr1wA5q8lTk1L7BqTPTwIZ+t Y9+w== X-Gm-Message-State: AIVw113I1fRpd6b+Ft15lg5em3KaPRMB2pxCh/hrH+xHSjPWxRqxMIBV PFoGbGuRONPYJj2V4RERww== X-Received: by 10.99.42.141 with SMTP id q135mr28597285pgq.175.1500296858703; Mon, 17 Jul 2017 06:07:38 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:38 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:42 +0530 Message-Id: <1500296815-10243-13-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 12/25 v6] 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 Acked-by: Wei Liu Reviewed-by: Stefano Stabellini --- 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 9e92097..e4882e2 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; @@ -1121,9 +1131,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 Jul 17 13:06:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107951 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495310qge; Mon, 17 Jul 2017 06:09:34 -0700 (PDT) X-Received: by 10.107.62.212 with SMTP id l203mr22403312ioa.162.1500296974927; Mon, 17 Jul 2017 06:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296974; cv=none; d=google.com; s=arc-20160816; b=cC2CZngZDAyBlgnEybYtNzQYXMlxh/IlZC05Rgz1MPFY2QdAFOl9Y0xPhW65Bc3gH0 DC9Cul2L8KbBuyHP3rGKiXev9YtxyFq3OUy7DntgXH1DZ08Dpex6VvM65AUx1SF/hoZZ ng4GS48pMUrYs38wvgtXZR6g/Du90jBWz47RI/hYc521O/C8X5mgSR3Tix94p9fEQt/X sXzmH2+cxYu71gCKUk5XEQxlM5e0xZARNh1Oh54gvJ5Md/+4hq2L05u2t5HKG4WubdEe zbG/nj3SB88V7QX5lsuho0ejnY9QtZZ9wIXClGeEoC7KzWU0mhvBOG5lk9cmbxl3UCcn fBfw== 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=SuDvKpAyYJtzewclbCuh8T9UybaQKqE4/6eNlguqOtQ=; b=ev2r127sPalpa2PZa+sT5aVMDWGE23i0jErSyW4aeBpkzV9JUAzWfiEQys0LuyFYXi BULXFf3bboKTEKdwpktBTdj7piBHywDqTdsFQ17hn8CSXM93hxglHVgZGXyA44/4ipkZ H3SLyi8qLY+6qSPyCEIQ9fds0OyR05KY7QQfC/XrSdnmgBApPUwgKgfehxr2HhQWg5oh b1wqBQN2CplKGvyfkuV/pixHIY4Af/wbYNytiAkmSjM6Wqqsj/QuWQznqPId+OjEWSc0 YMsuv+NV18iakAZzSVXoMNNok2uBekoQuQQ+KGc7zNrOZYzKPVfpUUbfUlEuCps5UsMQ Gb4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=VoNq4npU; 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 o123si16136354iof.26.2017.07.17.06.09.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:34 -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.b=VoNq4npU; 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 1dX5kX-0004XV-VJ; Mon, 17 Jul 2017 13:07:45 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kW-0004Vf-LN for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:44 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 23/CA-22472-F96BC695; Mon, 17 Jul 2017 13:07:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsVyMfTAZt3523I iDX5uFbH4vmUykwOjx+EPV1gCGKNYM/OS8isSWDM+9D5hKfgtUPG4awNzA+Nz3i5GTg4hgRmM EisO53YxcnGwCMxjljh8+RYriCMh0M8qsXfFAXaQKgmBNIkDF1YxQ9hlErM/LWKC6NaSOHpqN liDkEArk8TFPe+BEhwcbAImErM6JEBqRASUJO6tmswEUsMsMJ9RomlSLxtIjbBAosSXmVUgNS wCqhJXZ7eCzecV8JGYsuw61C45iZvnOsFsTqD4mQ2rofZ6S9w8MpFpAqPAAkaGVYwaxalFZal FuoYmeklFmekZJbmJmTm6hgbGermpxcWJ6ak5iUnFesn5uZsYgYHFAAQ7GFds9zzEKMnBpCTK e5EtO1KILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO/mrTmRQoJFqempFWmZOcAQh0lLcPAoifBuB UnzFhck5hZnpkOkTjFacly5su4LE8eUA9uB5KsJ/78xCbHk5eelSonzrgBpEABpyCjNgxsHi8 NLjLJSwryMQAcK8RSkFuVmlqDKv2IU52BUEuZdDjKFJzOvBG7rK6CDmIAOEvYFO6gkESEl1cA 4c++xNOeyqP2as7bI/5TdZ/rx7Q+b4rCNrE5TuYUfTVr89sHvRb+PH1+c+mfPeqnEnOSJbLOF DlrH6sY0Kp/Z1G/3octLaFd48fywENuTaaeO5swuE7599opCYpZWw6T+7B+vFYxnL39ieJrtj 6maY3hUis27Iz+q/8ts2n5O1rvC4chLgZ+dSizFGYmGWsxFxYkAafMppL4CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-31.messagelabs.com!1500296862!102568789!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 65144 invoked from network); 17 Jul 2017 13:07:43 -0000 Received: from mail-pf0-f179.google.com (HELO mail-pf0-f179.google.com) (209.85.192.179) by server-5.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:43 -0000 Received: by mail-pf0-f179.google.com with SMTP id e26so8422108pfd.0 for ; Mon, 17 Jul 2017 06:07: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=37oZi0nu7UAyMXiV7hqqdTBmxWHw3BJBPX8/0GlkuXE=; b=VoNq4npU//veoODrJKoAdD5iYxy/TvNhkzYnt0CE5b9Rynv5HVYfcJebbXYUqNLnD8 lOaB1SGkwTbDdlxlD4w6w0pnRkgdoQgwfYYyPIVvB2DHvMP1vOmgfVMisWwffP04HhUL VOq0iZgI7h2unMTr9yJgtq+Xv5mwoJ7yJNnCk= 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=37oZi0nu7UAyMXiV7hqqdTBmxWHw3BJBPX8/0GlkuXE=; b=ZX98peAWjq6kJAcLg5jixK8Wggg7qxZSL/jortjtLfMNsHl5RacrOY4Rw3upMCQGUr Su8oL3SGw/U9W45hH1ScVO8RLwLz0aH6y8LQbktC6m4BAGYh14l+ljsCT7pGnXtHZGrK J/lZC5mQO6oUj5lq8ZPclXJnkTTw88I8d6+Zg6HZN10tAYq47Sr1CcNXLj5e1Kkp9JEt Hp34jUREDQ8Q/5HdcNIclKuSxCQM7802ZvOU0LSKKGRn8uasXQgUFhP19M08GRCagtXm kW7fg0hvHNEoHqZQ9vIxj0xNbMUGHNpEztyiK3875cx2WIsDqeRfcZ5tXD6Fy3ke9xPb EChw== X-Gm-Message-State: AIVw113zMroAnCPeQnjpX+YN48xCVSm2LuZdqmFzHewdUhLLSeJ7A45s yj5c8phHLbeBBGmt0TE3qA== X-Received: by 10.84.229.1 with SMTP id b1mr593518plk.273.1500296861670; Mon, 17 Jul 2017 06:07:41 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:41 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:43 +0530 Message-Id: <1500296815-10243-14-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 13/25 v6] xen/arm: vpl011: Add a new 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 add_console_evtchn_fd function. This function adds the console event channel FD to list of polled FDs. Signed-off-by: Bhupinder Thakur --- 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 | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index e4882e2..dc96203 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1048,6 +1048,27 @@ static void reset_fds(void) memset(fds, 0, sizeof(struct pollfd) * current_array_size); } +static void 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; @@ -1125,18 +1146,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); - } - } + add_console_evtchn_fd(con, (void *)&next_timeout); if (con->master_fd != -1) { short events = 0; From patchwork Mon Jul 17 13:06: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: 107934 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4494898qge; Mon, 17 Jul 2017 06:09:18 -0700 (PDT) X-Received: by 10.107.145.132 with SMTP id t126mr4635555iod.127.1500296958869; Mon, 17 Jul 2017 06:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296958; cv=none; d=google.com; s=arc-20160816; b=MXW7SYmAVrDpT7YxqSyvJvW8dBX6drumod9kjg5Qn8mtwDHvjI4wHQR8SEXN4l+6oi D72z4ZTHzngsI97ggEXNIUoXV8rfMeoBd6TTGvlWuC2Ye6urBUZt21HP+I6oJaPFZ605 ucsmUUxnYvrhMndpHipEDbB2ZpSemzZ3ilbUmPeBhDzQ5XR6mpkzVIGuA8rlmxdguKre OXzAgrR+VrEKwTgPJqYGHyW0fgclgVYIvubX8HQSxHCrtqmGlVwbQfreHmnpMkMeiIff YeN1+BKTG06iPNw8z5mMkEXi56ZfmdhP77IkjsGlRT/4UVd4iAoiywHt+nToKbhbpVIj 3sMA== 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=WlEyFl9DG9m8dLSRc3GfM3gemuMFCIDZJjq8bSCnu2k=; b=ZOBDBojhbGvq5QQRPBkPu8HWbR54+HgwA0jDgtCIR7X/ESd74CHC4XEC+8+EJi2Ux5 6K9eeU1/KCuClWiuLYy/0m8Qbw3e1A1ar31M24lZ2Gg1d4rsb6u5Z9rByp9mbLJWkpbL L9XSgOiULWY1itcnr0bJjTs8ewrhyh2vBbXHcGdbPD3INGep46HWNDpsNnu082TTKGoC f81pS0ypMx6f/RF7nrY5TFVneJkZNTGFX8TiL5XcYOpFOT8FL0UTNfCqwRTQhHE+78Gi O/gk7JJciLqXXU5C/oeqBuZ4Xnv61JnD8eTY3F9JSjNa1hUlEWI3NxflXfFm3sCGmO0T Vdjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Kd6I00N8; 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 p63si15846774iop.13.2017.07.17.06.09.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:18 -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.b=Kd6I00N8; 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 1dX5kc-0004cS-6g; Mon, 17 Jul 2017 13:07:50 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kb-0004aq-6C for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:49 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id DC/FB-01732-4A6BC695; Mon, 17 Jul 2017 13:07:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRtsprtoW06 kwZujihbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b/tj+sBSt5K15tEm9gbODuYuTiEBKYySix YtczZhCHRWAes8TcfR/BHAmBflaJmZ+62LsYOYGcNIlvkzYzQdiVEhvfrWMBsYUEtCSOnprNC jGqlUni2KQfjF2MHBxsAiYSszokQGpEBJQk7q2azARSwywwn1GiaVIvG0hCWCBO4sfS6awgNo uAqsSaa98YQWxeAR+JnV9nQi2Wk7h5rpMZxOYEip/ZsJoJYrG3xM0jE5kmMAosYGRYxahRnFp Ullqka2isl1SUmZ5RkpuYmaNraGCql5taXJyYnpqTmFSsl5yfu4kRGFoMQLCD8d82z0OMkhxM SqK8F9myI4X4kvJTKjMSizPii0pzUosPMcpwcChJ8G7emhMpJFiUmp5akZaZAwxymLQEB4+SC O9WkDRvcUFibnFmOkTqFKMxx6QD278wcbya8P8bkxBLXn5eqpQ47wqQUgGQ0ozSPLhBsOi7xC grJczLCHSaEE9BalFuZgmq/CtGcQ5GJWHeTJApPJl5JXD7XgGdwgR0irAv2CkliQgpqQZGNTe NtcUfWPgtX2RH2d6pevtXqjLCs4/h491pvq5XOQ6x7iiViBX7/dHxzN40HS0bkVdtLxPn1JU8 qBZMVF4yPUvnNhunympPUatSiT0psU8yJhqZfZv8P2z1JWaRpEVnq8tO3ouzFj+y6XfM/YqbY VV+qvOjtzX+W3yKu75qycROpSC5AH8lluKMREMt5qLiRADx7jnpuQIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-206.messagelabs.com!1500296865!99644104!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13156 invoked from network); 17 Jul 2017 13:07:46 -0000 Received: from mail-pg0-f54.google.com (HELO mail-pg0-f54.google.com) (74.125.83.54) by server-3.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:46 -0000 Received: by mail-pg0-f54.google.com with SMTP id v190so21524030pgv.2 for ; Mon, 17 Jul 2017 06:07: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=K3DWX8wlmctzvNAdmVkRyZxAZgZLbbj8ag0TSca/pNM=; b=Kd6I00N8UQOX0mQe/BCjMiX8UWR7yQvgmogaA/9vMKN3hBRghbSbP3GE+XE5y5UHto RUsLZyZcunUwo7AjDE+If9uM0wofGxce/OwEQHarwsWsqKovanDpxet3Fdf+mmxnnLxi vCix/Eruh5xwgUxs0voQKdyV7esrmXWzr2Aps= 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=K3DWX8wlmctzvNAdmVkRyZxAZgZLbbj8ag0TSca/pNM=; b=L8uHZ++1gPNlKS8/X9jVeYlsi0pM/2SNX4aD3xPCXNWb1TkPRNeMEC02ryomAhg0uJ LtB3sL3+GWysZwE3YpInDWcML2C5Z03ZCWqvtIEzwV3aUTTDOOd3R29A92CRveeTXvDk ZQWLjJLcOTCXntuCXjW/eIni9PG0tY6luLadhca6mx5hds8mH1tTCG4TrF4Ny8RFsVyQ zyZ3pwyuq+F86l233DZmAwMGfc9eCmk0UZGppxcRp1DK45gyKBlJggDXsE1rVLYj12cx nKldLr03hYPQWlh85Y2Wr9cWbl5QzlsBi9G/hz9tsAGlpzxs8sY27rn/9vpwv+iv1sHJ E+lQ== X-Gm-Message-State: AIVw110IEDb6mhFzb2hFiKoxPUUz5w1iPaaAzCp9tTLqzEaNj/VR7cLZ YEXEOUp+QX0wtsgC4HA94Q== X-Received: by 10.99.166.17 with SMTP id t17mr29247071pge.60.1500296864922; Mon, 17 Jul 2017 06:07:44 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:44 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:44 +0530 Message-Id: <1500296815-10243-15-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 14/25 v6] xen/arm: vpl011: Add a new 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 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 --- 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 | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index dc96203..6321d78 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1069,6 +1069,22 @@ static void add_console_evtchn_fd(struct console *con, void *data) *((long long *)data) = next_timeout; } +static void 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; @@ -1148,19 +1164,7 @@ void handle_io(void) 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); - } + add_console_tty_fd(con); } /* If any domain has been rate limited, we need to work From patchwork Mon Jul 17 13:06: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: 107935 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4494905qge; Mon, 17 Jul 2017 06:09:19 -0700 (PDT) X-Received: by 10.107.12.97 with SMTP id w94mr18274679ioi.153.1500296959086; Mon, 17 Jul 2017 06:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296959; cv=none; d=google.com; s=arc-20160816; b=M36coECuBdfzFc/4J5XDunGOJMx+YTC3WP/s0Y5LVQ3Imxcd2+bV39lOLGyvF0Rvzf 7jlS9R3o7FW2ibXruuTqqmCsaA23UVbWMXAtQ5/4/wzyD2D4D6vYDmJDjj9+dJZFDlmL TiyqdxJo86X7KBeslvgXPqbbiEhJxG4erF2Pp2MqJgQArpH9iueSd2CTn3SCzgzDAdtI gbEQxAe03m7c6Ne3Uqt0mstQGbtllNYVMLoo1U8mxrAt11XKFbodBAyOLQ9B0z0TzUU8 /aH+IwPJHqtFdnX27FTv/4ZlkraDG6LIisjlK2yCsujFFEHCHHyK0iHjvF0aU5D10WDw xGEQ== 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=Hn3ajf98UmHDe/5Dks/kCt42evGuV66meW+O8r5bYQQ=; b=TpNlGlr+gUUJuR3eTlYzPcmPzcBTVeCfoOVYA/BeVZZ9ZMbdakXS1KyTezdlfBkZoZ RIqmBiaKPIbTIs1vOCRwy3lcrzTWilG1AIKjDJlB68xKyQlCByC15EE2mj1ycyP/snZy KkCA3SGSCSuixUL8ya59sk78QEH2rNxSKCaMpHAZXh6cStQ+8O+zDp3YykGJ1TUgIUiX xcmfNSQjNkbzFmXfM8JGWVAj5Yaro0LRCAlzPZfK3T7JMKk7dcUF1dXLGUUfhxVByBy1 KOkBfrccEelNbJhwpxycUNd3d2FHytwLn4SyHqY4t+H/GyzenWYMBOoR5jynaZEkb/uy TS/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=ezVHte+W; 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 o130si16755145ioe.98.2017.07.17.06.09.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:19 -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.b=ezVHte+W; 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 1dX5ke-0004ez-Dt; Mon, 17 Jul 2017 13:07:52 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kc-0004cp-RF for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:50 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 80/D0-02176-6A6BC695; Mon, 17 Jul 2017 13:07:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXiVRusqbt0W06 kwZZzUhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bfh+tZCs6KVNxZINHA2CDYxcjFISQwnVHi 9OxTzCAOi8A8ZolTnzeBORIC/awSrZPesXUxcgI5aRI3PnWwQthVEnc/XWUGsYUEtCSOnprNC jGqlUni1d3T7F2MHBxsAiYSszokQGpEBJQk7q2azARSwywwn1GiaVIv2FBhgUSJ7Vv/MILYLA KqEseP3gFbwCvgIzH/yS5miGVyEjfPdYLZnEDxMxtWM0Es9pa4eWQi0wRGgQWMDKsY1YtTi8p Si3SN9ZKKMtMzSnITM3N0DQ1M9XJTi4sT01NzEpOK9ZLzczcxAgOLAQh2MO7953SIUZKDSUmU 9yJbdqQQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV73rTmRQoJFqempFWmZOcAQh0lLcPAoifBWg 6R5iwsSc4sz0yFSpxiNOSYd2P6FiePVhP/fmIRY8vLzUqXEefVASgVASjNK8+AGwWLvEqOslD AvI9BpQjwFqUW5mSWo8q8YxTkYlYR5M0Gm8GTmlcDtewV0ChPQKcK+YKeUJCKkpBoYQ47/PHN +AtuSVKuXh+sCivpMWzIvf7s85Qzj4cLzIZ++vLAtYpO/7sAjy2yez95nXHkyZYHNB+63t51X LNRP317y95v+24rTN/Y6Roov6bx/Uf7xTKce4WoRh/Luu+bvprcm+iWeNkx893h5ha4ov/zvN QbsLRuffJCtvDt1Q0flr5leRY7flFiKMxINtZiLihMBd6yz+rgCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-12.tower-206.messagelabs.com!1500296868!66950070!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4367 invoked from network); 17 Jul 2017 13:07:49 -0000 Received: from mail-pg0-f41.google.com (HELO mail-pg0-f41.google.com) (74.125.83.41) by server-12.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:49 -0000 Received: by mail-pg0-f41.google.com with SMTP id u5so17087770pgq.3 for ; Mon, 17 Jul 2017 06:07: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=B0Rdu55YhR3X+417VyorRwdTJIn2jgYynzblJ6Vef3U=; b=ezVHte+WJHfmzgeCtYTtVB7WEA+NLnnAh1f0PtTzojCoXNuoktGwLSeHuRYWKlgG/k P54yXI2jOrEaqIgVImh8vONX/CEBEOu9jJJry3G/1Y/0UKEg8DPWGK7sWA/M0jcmN6KR n/5rK6X/owBeAs2fTqc7SHSNkf1nNXJbs7vCc= 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=B0Rdu55YhR3X+417VyorRwdTJIn2jgYynzblJ6Vef3U=; b=W/KQtSspmihH2O8xkxV6xOLzljbgwoaJcpB7KVfnWqFvEnbL3kiD5cW39LvhrfJMLn JuY62QWX92o52CAhV9zBTayLnAs3RvzUp3F4HvXLGOuVOW9w1uw3QrQr+2ytFoTALPKY cyR6ndEIzRckzqx8auJZuyjDDe/rkHOagjxLqj+nT55BxzpNCidG0Fv9D43pAYNrVtJs agfoxNZ0QXmvRRBN4YlDXp5w+TsAOZ5kVLUk6cSIZEnibMtwjx4ueYAnakSZS29PJxMC yt+vJtmTFiwRgQBBlHAEEvRpVTwuNeRVT8T+OmzORwpUP8eVY0o5EgnjcOXktsVFyNst lkgQ== X-Gm-Message-State: AIVw111nyUwGdX/uh4Dee+ZFGXifIu9GeA3lxyx/5KXs5//x2fi5vkh9 7FI3NFJyt2t76zHTBotv5A== X-Received: by 10.101.90.197 with SMTP id d5mr28052521pgt.223.1500296867629; Mon, 17 Jul 2017 06:07:47 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:47 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:45 +0530 Message-Id: <1500296815-10243-16-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 15/25 v6] 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. Signed-off-by: Bhupinder Thakur --- 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 6321d78..c272fe6 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) { @@ -909,6 +914,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; @@ -1144,23 +1170,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); add_console_evtchn_fd(con, (void *)&next_timeout); From patchwork Mon Jul 17 13:06: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: 107958 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495495qge; Mon, 17 Jul 2017 06:09:41 -0700 (PDT) X-Received: by 10.36.150.68 with SMTP id z65mr5362402itd.106.1500296981692; Mon, 17 Jul 2017 06:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296981; cv=none; d=google.com; s=arc-20160816; b=CcV9taluVzOHHLDuVv4Cvda6y83r01mk2uXPzdWbBDwJu+ux4L4klCxYHG1IM95UGR XVkG7657CDTMvC+ogola5z3o3eiioCAEA2ZoFyJNrOtm2B9hH5BJq4q3itfv3jlHXKe2 4/yKOTgwY65hA3ewaVxBKQa9V1GG3z9W8bJ++E/zaFKvoZ5bxV6J0l4+bCHzk679luU6 R/4ilgUOQP3FICv8W3UCZGf6cqG5WIfFeBYyZPRFUPVn/J5VK1Kkk9QV7NWSz55r2cmk xQPaztaSFykhhPs4vtSmgNtGmGHIL5PzWqRuXYNquOCFpwkiDDc1+MNpsVm0xxuRUTXZ vJIQ== 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=Gh1DpGkWdpSjHKMchcG0rDLjIQAyo/IwSuWfUITwHp4=; b=Bq5bsddHdlzgNPnnrbQj398K3V/IYjT8ReY/xp2Vjwn0C+9XrzvmiIPadE8VvwXFz6 1+tyejjLLvYzHBclV7DQkzy3hPJ8Aekm2CQBjeCkTC1dlQI1dp//JqB5SxLrPFBW4ysQ UL+ePD9dAqeOsPCx299f+KKc0d//pyI8jxL0nppBvCL926GTGnA71VyRAKTU0ThesXTR zwMFKw/iHhb6xSM+1nlD8otnoYCu5DMBcO4OAfw1FkHwLw1YZ2mTRTQRFD7Fy5s50FDY dYr8kr6txLoT6Fq9OgKL6UzTRpbSkgSpAv25tFZNzQaMAxuMIEKILcw1e9X12yyWwU5J jfmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=jG1xkMuT; 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 q98si15809980ioi.217.2017.07.17.06.09.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:41 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=jG1xkMuT; 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 1dX5kg-0004iZ-Lt; Mon, 17 Jul 2017 13:07:54 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kf-0004ff-6n for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:53 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 7F/2B-03044-8A6BC695; Mon, 17 Jul 2017 13:07:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLIsWRWlGSWpSXmKPExsVyMfTAat0V23I iDd42sFt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnLLh1iLvgoUvH1/gbWBsb/Al2MXBxCAjMY JW7s7GcEcVgE5jFLTLi9nBXEkRDoZ5X4/6GLuYuRE8hJk3j96hsThF0hcbh9CiOILSSgJXH01 GxWiFGtTBLfD3SwdDFycLAJmEjM6pAAqRERUJK4t2oyE0gNs8B8RommSb1sIAlhgXiJo8tngQ 1iEVCV2LN2ByuIzSvgI3H92iV2iGVyEjfPdYIdwQkUP7NhNRPEYm+Jm0cmMk1gFFjAyLCKUaM 4tagstUjXyFAvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMwuBiAYAfjn2UBhxgl OZiURHkvsmVHCvEl5adUZiQWZ8QXleakFh9ilOHgUJLgdd+aEykkWJSanlqRlpkDDHOYtAQHj 5IIbzVImre4IDG3ODMdInWK0ZLjypV1X5g4phzYDiRfTfj/jUmIJS8/L1VKnFcPpEEApCGjNA 9uHCwWLzHKSgnzMgIdKMRTkFqUm1mCKv+KUZyDUUmYdznIFJ7MvBK4ra+ADmICOkjYF+ygkkS ElFQDo+Ieha9TlSS3HpvawpgiPX3f3dPNk+uL//87HXunZX/2le6dQaev3J5ayes6I5wlYoca g+CMd6anJNLNp85cIdCvv3hrWHZJvhJX+PvZZ9Yk6a+eHmlSfn/Ohnnv95g57Qj74eJz1HkWe /HxvWvdOXXYzRXNpc49K3qtEMos4HBsT8ot+7DFckosxRmJhlrMRcWJAOR7crLAAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-21.messagelabs.com!1500296871!73515966!1 X-Originating-IP: [209.85.192.171] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21542 invoked from network); 17 Jul 2017 13:07:51 -0000 Received: from mail-pf0-f171.google.com (HELO mail-pf0-f171.google.com) (209.85.192.171) by server-11.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:51 -0000 Received: by mail-pf0-f171.google.com with SMTP id e26so8424035pfd.0 for ; Mon, 17 Jul 2017 06:07:51 -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=hzmcOSYjiiJgJAccV8p6wWGv0Dmdfz68OU0DsA0Zna0=; b=jG1xkMuTh23L+/3JRk3IZ3oAr40Lb5Ma8l8InnxErSB4drur0Aocm1DGuhYle085EK 5k6fAQXFW9q+gwqECPq3AiDScOOjcPl7plarajGWlPdv/Hri7yiMxNDQRt7MvV0fh6rr K6ci/sCeOndiVB0KlR7s9pwtHFAbFBjaB/6iA= 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=hzmcOSYjiiJgJAccV8p6wWGv0Dmdfz68OU0DsA0Zna0=; b=N32i/6eg6AuBa5TQy8hEYkpmlQuu6YuAy0fDeSA00Lvh1tqNDp5Gji7W69ubFQTCVm 03Kk8799W/HHq60sNKRCO52CMArtRmmBZ42veSwWKFhrw5fJfy6tbWhB5D2xx3HF48Qa Xgkeha/dDX0ZrAiprudpnMOUOOz3HNzdZU67ty+s741Ut/Ze2/SEBW/UZp/Zw/imPT3D eho/DaZ2kjg/myrYUZUKxu0u5yajJhjrvYK0xBaAWZKgfcIXySMuKib1bdIO1LOqaTrs PyBtfn5swuBiCRGU+yJzrmhiuMMsFCn+GZAV173vdJepYJpsrjCjxRtP6GyvkPm9E42X QLQw== X-Gm-Message-State: AIVw110ZB9VRR7fRs7qYJqdvSAG4vFWdhytHsaee4J2BNWKNFRg7Q5BQ z3RqrAuFN+DcWdkCwonSog== X-Received: by 10.99.177.6 with SMTP id r6mr18881711pgf.106.1500296870511; Mon, 17 Jul 2017 06:07:50 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:50 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:46 +0530 Message-Id: <1500296815-10243-17-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 16/25 v6] 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. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini --- 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 | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index c272fe6..775fb04 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -935,17 +935,24 @@ 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); @@ -954,6 +961,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; @@ -1238,15 +1260,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 & @@ -1263,7 +1278,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 Jul 17 13:06: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: 107938 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495023qge; Mon, 17 Jul 2017 06:09:23 -0700 (PDT) X-Received: by 10.36.0.147 with SMTP id 141mr5495157ita.113.1500296963848; Mon, 17 Jul 2017 06:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296963; cv=none; d=google.com; s=arc-20160816; b=UaHly6rTUmMRzoKOlex86rUG4y+6ANWMQOyqqDuqvkf4rJk/s8x1A0aQ0m1UyOCywu 1G3Uf7vmdtbifpa/3pjr+pB/FUXUyyXO31p9gLW/PD0cZv8kPX1Q8xVHC8ZgLndCariL zY4sn9QIkHtesXboX+hBsIn6PH5/STZRpO3Wf9IPaL513/rNChli+W8MdhdmmeZ8FNL8 wSn5T1ei7UZMy7R+1zwYU5AIBshGzV0nzYzoCIj43H5OgFJ1lKqBFXTHudVSgI3fYFmg NPUpwejIc1rsQ/kcJTnSJ2/DqmdrfhVKhReZnShcI0sKFp/7EBmWcDU8hj3W1Y4txMcf MYHw== 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=j3o3LzdrlXsGpbUJYw71jHwY3+feWpnbG2FZ42yXrB4=; b=KDunuoqUMcB5ogpYCIYW/vmMpO6/jDfPUWCts8lNM8gvwTj2NpeE48lHaU9E8NyLq4 8ilSWjiq5nEOgfRVk0fPOtdTdbheLYys1jZdK/jxsZM1nUeCgJCdQwiyZwYksOHHL7zX xE7odjnI3P6TEmfXrty1eM/3b/4qDvxrx6+D47rpfZgveO0k1MxqdCGoNVnZ5jc35RAX 5XdD030B7tHeUvYxapfOIxnOw/RJpvOlAAZp8IezPICc/ILE5J+vpFGGsrrQdgRrtfbw 4Y/Gg1HKjbCmKQDgq5/cxsxVcSKVMBhCKlq7C/I6NiY3A6fNu70RpdEzQGjWabGshyee IDEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=WlfS7K5f; 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 i41si17184702ioo.203.2017.07.17.06.09.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:23 -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.b=WlfS7K5f; 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 1dX5ki-0004m7-Up; Mon, 17 Jul 2017 13:07: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 1dX5ki-0004kb-6x for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:56 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 9C/D6-27137-BA6BC695; Mon, 17 Jul 2017 13:07:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRtsqrt6W06 kwdY5TBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8ab0/UFK/krHiy5xN7AeJWni5GLQ0hgOqPE x49v2EEcFoF5zBJzX/SzgDgSAv2sEl9OzwLKcAI5aRIPN21jgbCrJL7MeglmCwloSRw9NZsVY lQrk8S1J8+BHA4ONgETiVkdEiA1IgJKEvdWTWYCqWEWmM8o0TSplw0kISwQJ7Gp7SjYAhYBVY m3rRfBhvIK+Ej0951ghlgmJ3HzXCeYzQkUP7NhNRPEYm+Jm0cmMk1gFFjAyLCKUaM4tagstUj X0FQvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMwtBiAYAfjt2UBhxglOZiURHkv smVHCvEl5adUZiQWZ8QXleakFh9ilOHgUJLg3bw1J1JIsCg1PbUiLTMHGOQwaQkOHiUR3q0ga d7igsTc4sx0iNQpRmOOSQe2f2HieDXh/zcmIZa8/LxUKXHeFSClAiClGaV5cINg0XeJUVZKmJ cR6DQhnoLUotzMElT5V4ziHIxKwryZIFN4MvNK4Pa9AjqFCegUYV+wU0oSEVJSDYyyx5Z5vd0 qP+O7zJrAmqy68AfPL3Tnl+j9vnsz9v37bTfmdE12eHm5RmSu7KtvH7itPH2fZb89/zoqzYrv r/7vAiH1ZXO2nXBdIOnQ0fMs4omKklRx9CK//VueKE29NSFgy7nHHqrCTBJO2aYfVadeMZDev 1jjnR8bi1FY3cliw4X/frSkap1VYinOSDTUYi4qTgQAlHw/h7kCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1500296874!97992867!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43691 invoked from network); 17 Jul 2017 13:07:54 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:54 -0000 Received: by mail-pg0-f53.google.com with SMTP id 123so6572432pgj.1 for ; Mon, 17 Jul 2017 06:07:54 -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=JHD4TzvomNM6NaYwRVbF1nslo77q0LGaKotBxN/IgzA=; b=WlfS7K5fkAJ2R8AnNtfSsNscTaFC4n64DSU+Xl22Znv/MosO9i2qVY6OzLeFpFaP/S DhVuftB3qkepX8phriytCKcOU7tUchFnWZMn8s3NFPkMSui1vIB9WDjgda5qBSpUBLai Z2eQJlcLJlKExiSUG/B3/r1xbcjmavXp0ii+k= 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=JHD4TzvomNM6NaYwRVbF1nslo77q0LGaKotBxN/IgzA=; b=DnR1nDS21kR3PTnuxrKVNJZPtYL87MLGTtV3TjeTEsu5cwaXnZ81qGsMIEXCdR7ul+ LjUjjMa8cTOnqKRVBbIL1nwei97A9ozp1VPDk0n0OsU3phQYw1VqtR7WYPSjtE5z0m+d WIWT4sxO4NT5UaTxWwwBFDfmlcXYfIzHaVT8B4PyaNdCc9mL4OO42LxkR0385G7jfZtj IT9Vl12imvvkRV4QJAJrw0h1hbJyCkmROBKs/qqTu2EkhMJ9G+WI0K+uTfrEgogcbRNb R2Bi4HT1/bn0i4uuMsND+Dp4XcJRlPV/tpebNf5reMZryeMWND2+3o6S6IVIXSPEoF5P /zdw== X-Gm-Message-State: AIVw1119F0kaLyRdv9K1uZbP4S9sARYeDW+WFsdQkd2KtjBe1TWPAjlf zi1aLENbtbgikSZAqTk72Q== X-Received: by 10.98.69.219 with SMTP id n88mr18806284pfi.192.1500296873419; Mon, 17 Jul 2017 06:07:53 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:53 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:47 +0530 Message-Id: <1500296815-10243-18-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 17/25 v6] 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 Acked-by: Wei Liu Reviewed-by: Stefano Stabellini --- 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 775fb04..4097673 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1133,6 +1133,24 @@ static void 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; @@ -1263,22 +1281,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 Jul 17 13:06: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: 107933 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4494886qge; Mon, 17 Jul 2017 06:09:18 -0700 (PDT) X-Received: by 10.36.74.8 with SMTP id k8mr397226itb.100.1500296958392; Mon, 17 Jul 2017 06:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296958; cv=none; d=google.com; s=arc-20160816; b=TFkgXxOApaOWMw5dJ6uOzi942XSWZGt8a/2eYysc+QuPElQYy5b4qXBAKXSzjFtPqW vjCqlGmyEJCBgHEWzQfOB0O2w4go7ibgvle9JzSonVVsrKRFFmOB8E8VE9P45CLFvRRl 6URpnusWmJ7EOj4MNJLxOFUa/IY3ve/coqNoImswIZn6ZVqPxPTQHXNUDtdGzM76I/r8 maiydNRKe/RpjOmYerQEMShE9Fo0cydi0wLBFKTUZT6JdC9b38Ei8EZCbzjuRzrq2wS6 fOUtuPp2+TdGsbvnEmXaRxFBhzn6u9O44q4WBCjGbcPzHqDrc5lV9+RENvINRRyAiTsq YCog== 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=z4thRx17Dab7ELCkMHlVa9kcD1d7nuCdFQbSwrYuggc=; b=W5oziO2/KPmxrrntlAhofH+HLCKY1Whd8Xk/L5KKflmceAyuDi30+7xoCjPkuwpf+A +/8xVH8JeTYXO7IMKLdnWgXqxROQ/+C4WJb8i6gZWmn8n9gAKVbkyKitNUa/L68zlT1m xVADUi0yERwfliK/1OKcXJ7oUV0oD+i13M+rhcUv9k3Bj0R2VlyxU8QysUwSRrC/5vwS g3sseQGK42JV1ah4JBc1KJ3VhWJhBkTEwoch5U0Qj4w1cgw0q3myk03ksPKWoQPcwF5h xzHbOXxi74x/TjjrMJ9qGiWHUV2qFDhE2ayHUCJCMu2GnN0IzxWYVdy3DDbpR80PMvRu bpuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=dDcPEHI7; 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 c202si9044783itb.58.2017.07.17.06.09.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:18 -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.b=dDcPEHI7; 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 1dX5km-0004r2-Au; Mon, 17 Jul 2017 13:08:00 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kl-0004p8-BG for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:59 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id 40/1D-01732-EA6BC695; Mon, 17 Jul 2017 13:07:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXiVRusrbtuW06 kwbvbzBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b54xwFk7grjn/sZ21gPMjZxcjJISQwnVHi wxX7LkYuDhaBecwSG88+YgVxJAT6WSXuLvzEDlIlIZAm8WXRHiYIu0pi//RLTBDdWhJHT80Ga xASaGWSOP//PJDDwcEmYCIxq0MCpEZEQEni3qrJTCA1zALzGSWaJvWygSSEBaIlFu+fzgpisw ioSpz88R1sKK+Aj8TpBX1sEMvkJG6e62QGsTmB4mc2rIZa7C1x88hEpgmMAgsYGVYxahSnFpW lFukaGeglFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQmFesl5+duYgQGVj0DA+MOxsbZfocYJTmY lER5L7JlRwrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4HXfmhMpJFiUmp5akZaZAwxxmLQEB4+SC G81SJq3uCAxtzgzHSJ1itGYY9KB7V+YOF5N+P+NSYglLz8vVUqcdwVIqQBIaUZpHtwgWOxdYp SVEuZlZGBgEOIpSC3KzSxBlX/FKM7BqCTMuxxkCk9mXgncvldApzABnSLsC3ZKSSJCSqqBcdq 19/OUU/u9TodZHQ9/yaa5LDjC8JI6+5azxm/+8Z0/+tFm3wd7iztr0yfsvFXdWi90OmlZpMPT TLlHyVM57/NoVl/qZK0v+tGcERLsm7Gn7eIxNWWWL9cbb048GPN7j12240wt0QOyh924TKpTV zPP7b2cMffSdu/nQUnf95yXKYzbG3D4nBJLcUaioRZzUXEiAJ9H6+y4AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-206.messagelabs.com!1500296877!103036825!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56810 invoked from network); 17 Jul 2017 13:07:57 -0000 Received: from mail-pg0-f43.google.com (HELO mail-pg0-f43.google.com) (74.125.83.43) by server-6.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:57 -0000 Received: by mail-pg0-f43.google.com with SMTP id u5so17089925pgq.3 for ; Mon, 17 Jul 2017 06:07:57 -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=409tjuZ3qKHf2TBRBmScW1+QhqA0AVFI0dMys/7Oouo=; b=dDcPEHI7q0F+KbIcPU/e271Q+JRs/w74HDfw2OD+G7Ikw1VrYSw+wfrMJBy/nzZeLD R/sddOd3KQLUlXGFjARGi26QvyRj25F2WRtdvoEOV6ZeBNR9Ft80CMppw4Qm0+O/gq7p o76rIM8qM8Eo6uhI9Yi5irAS/PlZaX9wf9e9I= 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=409tjuZ3qKHf2TBRBmScW1+QhqA0AVFI0dMys/7Oouo=; b=ExDlMRtcxBPsnOieyY3JMhvI8vx4bFi1vDwqkccTHL3b76CmVsSCxclxrGFKgi+cs+ BYmTbF++w10WpkkDwgT/HAcg0EOcHsbGhVWITV+zcBdlE74jyAdO70FtouYDnX4IkE30 AYl135rbnFWBFpHDpNbCDFLDlTzNj9EcUgRRywFI6XSLKDjbBTSE3UUEglt27UjQNFw0 Scnf7E6KmxyToD2QlurOGKHkRbIsh5sXVXZgarh9h8TmEFEHb0WywGZMBkVaOKINszTd H+08QmgE6DIsDBEaCB8DjlF4/RPhIjqz9R7rHEyWgDh0rsdyGgHNjnEGw//3wH8kaXoc EkYQ== X-Gm-Message-State: AIVw112HOUxzxSqriVJvk14BJXr0UgO3nUAV7lxqbWgin2squzwLfWtC mCeRIXFXhFh+nduXS4tlFA== X-Received: by 10.99.61.201 with SMTP id k192mr19006238pga.57.1500296876427; Mon, 17 Jul 2017 06:07:56 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:56 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:48 +0530 Message-Id: <1500296815-10243-19-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 18/25 v6] 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 --- 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 | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 4097673..d004687 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -769,22 +769,33 @@ 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; } - free(con->buffer.data); - con->buffer.data = NULL; + if (con->buffer.data) + { + free(con->buffer.data); + con->buffer.data = NULL; + } + + if (con->xspath) + { + free(con->xspath); + con->xspath = NULL; + } +} + +static void cleanup_domain(struct domain *d) +{ + struct console *con = &d->console; + + console_close_tty(con); - free(con->xspath); - con->xspath = NULL; + console_cleanup(con); remove_domain(d); } From patchwork Mon Jul 17 13:06: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: 107944 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495194qge; Mon, 17 Jul 2017 06:09:30 -0700 (PDT) X-Received: by 10.36.5.136 with SMTP id 130mr4999287itl.68.1500296970172; Mon, 17 Jul 2017 06:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296970; cv=none; d=google.com; s=arc-20160816; b=yYIIdK5ApjAgYO1D2R/2YL3eYTo6jNROK3cYMKioexIOcaclbdgo4MFD6utxE7oaUJ O5MfqGg1nDNtwvH7eBcvPlsoChG91M7CO4Qd+S95LZ/ZkMES3I68C3Wr0XWw3RPlKsWo F9wIKbw55f9t/v2Cm9eLoBA4w2+G1ZTWq508xi4eHS+NOycjt3f+4m3F/fg4Od8rx/om S3OuuutbgEfw8XsAcAAnijH+Tm+iPs/1RjBdWK9rqT+w7xO0G58NOol9V0cct7ngig/S 8FsuOY1UiqDVCB8GlEsr2C3DXVdrDk5LH35WE8GHu2JTZHM7XiSRPshPe7bOG2D+rHXH hXPA== 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=nKZ7PRUuSwFUP8OuyrkTbvUzmHs0cskj3M0GxYrAILk=; b=odUEjSFBtf+ESfgPd3C25TXVvBu4CIYTVUN756jeSi9fc+v+yaAeFgJ/t7axhf0iC2 +dPPZRs/sU/kBSp2MgUxMeiMqtl0taLA8q7lW8fwo9dFPHel4EQmP8k3dXN3Zv8ck9VS B43POzBZKytFRXZgP2QQ3hveqFXWakgI1aJBwrP9wUqEeXzrSvIK8dNGVAuE/RQN6PIJ rKwPLfjPFAX52YMZVUXqsDnGMC0T/DCTMElwhJbQ7OM8v/EfoYUe2Pt+rhDzITnskdph W0qF0et5pcCCi2EB9GrOgcHsGNDv8wasJHUZpS7efTROov6+yyVdtwzfzX987uxkMEDu skMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=kqGskaqu; 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 z84si16418819ioi.40.2017.07.17.06.09.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:30 -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.b=kqGskaqu; 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 1dX5kp-0004vm-JB; Mon, 17 Jul 2017 13:08:03 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5ko-0004tF-25 for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:08:02 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id B2/3C-01736-1B6BC695; Mon, 17 Jul 2017 13:08:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLIsWRWlGSWpSXmKPExsXiVRtsqrthW06 kQfMUc4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNePqph3sBVu5Kvbc/MTUwPiOo4uRi0NIYCaj xOF7O5hBHBaBecwSx078ZAJxJAT6WSUu7djK2MXICeSkSRyff5gFwq6UuPvkJxuILSSgJXH01 GxWiFGtTBLvltwHKuLgYBMwkZjVIQFSIyKgJHFv1WSwocwC8xklmib1gjULC8RI7L01lRnEZh FQlVg0bTE7iM0r4COx9vZ9ZohlchI3z3WC2ZxA8TMbVjNBLPaWuHlkItMERoEFjAyrGDWKU4v KUot0jSz1kooy0zNKchMzc3QNDUz1clOLixPTU3MSk4r1kvNzNzECg6uegYFxB+PlLX6HGCU5 mJREeS+yZUcK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuB135oTKSRYlJqeWpGWmQMMc5i0BAePk ghvNUiat7ggMbc4Mx0idYrRkmPD6vVfmDgmHdgOJF9N+P+NSYglLz8vVUqcVw+kQQCkIaM0D2 4cLBYvMcpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLmzQSZwpOZVwK39RXQQUxABwn7gh1Ukoi QkmpgtJrqUex7aG+VeLhBfPb8vEWritauMp/xfvsKixyV8ysOz5u0xpTPi1Pt0uwDEqrLryrf OyOhy+A7SzblUY9ZLPOkuMKlwtHerrHp/y/OzU7MPilyQejXbgG+PO+nZnu91vjJ1rXptVXO6 /5vx77pdtHi1T+nhlW78PBanumJ2BD8X8ZHTFxGiaU4I9FQi7moOBEA3cfcf8ACAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-206.messagelabs.com!1500296879!103036836!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57144 invoked from network); 17 Jul 2017 13:08:00 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-6.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:08:00 -0000 Received: by mail-pg0-f53.google.com with SMTP id v190so21527359pgv.2 for ; Mon, 17 Jul 2017 06:08:00 -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=wNE42O/N0pQjC9jFpODEWb7HEXgWVKOfEIu88E/ZDT4=; b=kqGskaquabnw0bkeHCKvLAg40uLm4KPAtTi62lR79Y7jlBDy/cWiZYsei+a898aLNT qH6IE2wgW+t5VmvoonVlvDezsV+q5zq4LGnj98YnJPKyCqr7V3pu/F/y3i9PdamDRpkO hcXzBPPK4smdUysUqs+3ipyGgO1uLbj8F7lm4= 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=wNE42O/N0pQjC9jFpODEWb7HEXgWVKOfEIu88E/ZDT4=; b=YSdLYpEIv/dZez5JP/FeJRGFF8ppMFey2dlDCIvFuqi7XFp6IaFi+Oqr+PN5ZL9Rbj ThTXXkuvRkqIT4kKTZqsHm9YIXEmX1NePg/F4e2W/GgToOI6b+ePgbiX7xAJHCSTMWZC mtqZ+d8p7CwO127RthqBDBAPvkipdzuHRtc+WMeJvdXFsdu53OLyvHKVDE+W5dbPDd7Z PiNd127eWhSgKdHzQOiy+EyLJ/ArwEV9l0AtIXfDBA8P2wIPL4dUOmIC4cx1ShkuYtRJ /ZLozlt9cl8VBfXZ2xF7ek0e7DloGqi8krGvOGnnznpShOHrM7t35tTEnKZikVTe8JaM 2e+w== X-Gm-Message-State: AIVw111s/68Izj9wGvlRxKHEeNY0lQlzR++cjfQszSvvMcN/1jdFJEK2 53xfya4W+YghI9QCWZWr4g== X-Received: by 10.84.140.235 with SMTP id 98mr29602559plt.26.1500296879270; Mon, 17 Jul 2017 06:07:59 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:58 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:49 +0530 Message-Id: <1500296815-10243-20-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 19/25 v6] 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 --- 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 d004687..93fc8cc 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1046,6 +1046,16 @@ 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) { @@ -1053,9 +1063,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 Jul 17 13:06: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: 107939 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495041qge; Mon, 17 Jul 2017 06:09:24 -0700 (PDT) X-Received: by 10.36.131.132 with SMTP id d126mr5456866ite.75.1500296964450; Mon, 17 Jul 2017 06:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296964; cv=none; d=google.com; s=arc-20160816; b=fwmSYeajLN97u4ea9r8qE6vh8fIf4g5fS33Fspy/L/5S/3zI5MlH4PcO3GjCyRca3M OwwyCWI1ID/9U2SSdRmMHOlDj7zUiYNq5VKvS1/Wv/b3f3yotiNfj7Ao/CjBI2mBYmT4 RNaw/GVUO7H5Q/plja76fIYr9JBtiDFTWd3TPXym8v96GsLaU1QiroPpWiujnUIJ/OZc hsP+JBCJeF7/AXWLXQcHGGsUeDzuV6t1FCvWE2SfDyY+BORUWwJUdHQxkGVuiP11q/+g pswjzeZeLZSDR1TBuEanFBt7lZIKJdXtweWuEd5wJBYZjG0NDJZDlMY7ffrcOkZwV/9b JpSw== 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=3CvYTK1j6/qZ9PYRTcmy7ZGklpqCJQwKPVWeazvnlTU=; b=d5kSJMPvok0RusFyJrjpM/AjGG7id95rWtcgGoJmbAbznMeROClWtU2faAmG++ss/G HY6cU/z0tvYTuVCxGKdBtm+nt1pNklZ0W9niiaKELJuVMAHwvPj8bgkc2kaiOAmBEt1I FriBkV08AN6jwueY3RXbgSAmYNWjSHwKvq60qT5YrC5UlDPGE4gOgPC3DFqBGO2c0uWH Bq5EphfjkNmE6eCNGjcGMNdh5XKLcoGqPgefaXUPw0ZIEd43gTddVBzsBPOca/ONDA9D IvwLe5B04RAdE4qguAoy4CAf4xl5xpo4wfeOFUu8n1aQiTyZm8nlS7cTEkUu5C73tWSe EgHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=i+sDl4dB; 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 o71si4783213itb.93.2017.07.17.06.09.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:24 -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.b=i+sDl4dB; 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 1dX5ku-00052B-RW; Mon, 17 Jul 2017 13:08:08 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kt-0004zv-Ae for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:08:07 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id A9/BC-01732-6B6BC695; Mon, 17 Jul 2017 13:08:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXiVRtsortlW06 kwbEudovvWyYzOTB6HP5whSWAMYo1My8pvyKBNePFxjmMBau4Ks5ufcHUwPibo4uRi0NIYDqj RNPBDWwgDovAPGaJOacOM4E4EgL9rBIHjj1h7mLkBHLSJPa3rWeHsMsl9pzeDRYXEtCSOHpqN ivEqFYmiYNXW4BGcXCwCZhIzOqQAKkREVCSuLdqMthQZoH5QOsm9YLVCAskSCzr0QQxWQRUJf bu1wUp5xXwkViwcyfUWjmJm+c6wWxOoPiZDauZINZ6S9w8MpFpAqPAAkaGVYwaxalFZalFuka meklFmekZJbmJmTm6hgamermpxcWJ6ak5iUnFesn5uZsYgYFVz8DAuINxV7vfIUZJDiYlUd6L bNmRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR43bfmRAoJFqWmp1akZeYAQxwmLcHBoyTCWw2S5 i0uSMwtzkyHSJ1iNOaYdGD7FyaOVxP+f2MSYsnLz0uVEufVAykVACnNKM2DGwSLvUuMslLCvI wMDAxCPAWpRbmZJajyrxjFORiVhHmXg0zhycwrgdv3CugUJqBThH3BTilJREhJNTA6XOc78ee i5ysOxY3L/PqSZpReFfk4RZyx94jwze8zQ//0v9/bs7vSXtilo0HVzH5pY/Qs9qtFczsSo0zL OwuiMv+fdAjh3vuuuX+LsXlT8FvOPK6kzgNZDmZVAeyRN3bU5N2VE1IS5ImIzPeT/10yZUe5r j33ZVeF4Fv/Tbb8rVP8FSZ+SYmlOCPRUIu5qDgRAIX4kFi4AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-206.messagelabs.com!1500296882!74793349!1 X-Originating-IP: [74.125.83.52] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17497 invoked from network); 17 Jul 2017 13:08:03 -0000 Received: from mail-pg0-f52.google.com (HELO mail-pg0-f52.google.com) (74.125.83.52) by server-10.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:08:03 -0000 Received: by mail-pg0-f52.google.com with SMTP id u5so17091301pgq.3 for ; Mon, 17 Jul 2017 06:08:03 -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=U3ndLwUH19y+eRWKnmI/WlxLGI0ItXAAuC4yu98lPA0=; b=i+sDl4dBIdtFBz+x2V4EUYttpFUHWwfErqnMCkfoYUMXjhdTrB2l4L8Y2rzQFnK/4k 6os+B6iIsrsQzK57NrIUGPiojpjw5DMOIAKG58jksBbhhWNk5z/f6mJw8TEoB3tSvLrQ 0vxYD8lrNG+5qoLjp5MCu5+kCTuF6msjLIyuE= 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=U3ndLwUH19y+eRWKnmI/WlxLGI0ItXAAuC4yu98lPA0=; b=Uub6oKWHMH7cswGcYlJT/CJy2JbcfAdlEyBNFz/W+mSD3dUOlQP434wTYs4qAJZ1Hk LlCdhfzDnZb7W469wGuW4SGVjpif416Z+raDzYkEn29JQrFwtNLmaRsDqq9SkwYSMrJV 2t4vOpWhEbnlE2rahbyGV0VjtyZEyX5ZVdGDJfVKxq04KJYqMdb5Jtn310ehH4E7HR9D 3OgHYgchKIw+VWpYuH4S96UzeTxlzwVJKjHlyJ+NfH5ALp90Hq+82ORO85NqlLDQfY8o xDfVZW3bOpziiMDdKwaIvjp9AnFpHYFXEbBhaNNB4eXIU5Xck1ljJQekI02438PeMr1N K3eA== X-Gm-Message-State: AIVw110hrEbkk8whn+iMFOXY10sPLT/eQGzBEbk4YC7XYQ0TEkOoKTZP PSFnsvk5Rd8t+HwXgnuCKw== X-Received: by 10.84.143.1 with SMTP id 1mr25211965ply.103.1500296882216; Mon, 17 Jul 2017 06:08:02 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:08:01 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:50 +0530 Message-Id: <1500296815-10243-21-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 20/25 v6] 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 console_cleanup function. This function closes the console event channel. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu Reviewed-by: Stefano Stabellini --- 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 93fc8cc..54c91aa 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -800,6 +800,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; @@ -807,9 +815,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 Jul 17 13:06: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: 107946 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495238qge; Mon, 17 Jul 2017 06:09:32 -0700 (PDT) X-Received: by 10.107.17.19 with SMTP id z19mr21220368ioi.35.1500296972241; Mon, 17 Jul 2017 06:09:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296972; cv=none; d=google.com; s=arc-20160816; b=Z753zeKbeGwxnb5Y6Pxc6CHDmiYl3/GtnVO5cQ3J65scC/riLIkHLCrX33bIDKUeux xvofokMMXm8wyGr3HlbfskmGK9jAbQ5bQyFv37RlGYfoZNI4Fsg3UCJzPhCWwgXKlX46 f8UPKzfr1gJfmv6IAjhtreIuZL+Ivi2D4IeN4EzzENZdpcWYAnemotB0Jz5oY4nPsobL XFO/CqgP5agW9GubnIxxvgHY+lg9ZarwVx6kRA79sNTtTKYVjdX+PeGG8AWb2rJNPUm/ 4kJiB/E4IdRxiuPC4u/5ekA8OoISbs3XIxB3TTVHMWJgmh8EqJ7kzlS7EYbJkpO5X4gH eQ1g== 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=f+WzRQ5K2Rj4DxXeNa8tVzBYuRVZC/VEyjGd7RSB54U=; b=GR8qsQ81za5WTFJd+8KAW/YY1f2WXLWC9Nds7HEqkShJZzSzDvsC1UWROwZCzwYd09 o+/D751V67DfOUYwEt1sm7purQVmtsvQig002gxanMKLmoTMDbwI2nRigqbIUzkREEgy x1Usy5UQL4WS+AFYScfrWUodKmg0z5Nzwpmf8A/lbZsHokXbdte6/Q4N1XzulvdBgPY0 BnpZrGvM3Ln+6lDxEz+g7x96vi2z42XzNlDM3CI7dFh+oq3ZbwTGiddKhduB1ANtU63S ACVGbqGeB7Wd+FCKufSSibMfl97Lq80ofqZ3n6jLKil32cwRbz5DPgErbEXWMBYiLoRk kRRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=WXvdsxS6; 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 n15si5615159iti.0.2017.07.17.06.09.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:32 -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.b=WXvdsxS6; 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 1dX5kw-00054Z-2W; Mon, 17 Jul 2017 13:08:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kv-00052t-LN for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:08:09 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id 82/8D-01732-8B6BC695; Mon, 17 Jul 2017 13:08:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRusq7t9W06 kwdOLAhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bbl1NZC5Z5V7x98Y2pgbHLrouRi0NIYAaj xIGWhewgDovAPGaJzX17mUEcCYF+Vok7X64BZTiBnDSJ1V8nMkLYZRKdD06ygNhCAloSR0/NZ oUY1cokce71WaAGDg42AROJWR0SIDUiAkoS91ZNZgKpYRaYzyjRNKmXDSQhLBAl0Xd6ETNIPY uAqkTLWUOQMK+Aj8Syw/uYIHbJSdw818kMYnMCxc9sWM0Esddb4uaRiUwTGAUWMDKsYtQoTi0 qSy3SNbLUSyrKTM8oyU3MzNE1NDDVy00tLk5MT81JTCrWS87P3cQIDK16BgbGHYyXt/gdYpTk YFIS5b3Ilh0pxJeUn1KZkVicEV9UmpNafIhRhoNDSYLXfWtOpJBgUWp6akVaZg4wyGHSEhw8S iK81SBp3uKCxNzizHSI1ClGY45JB7Z/YeJ4NeH/NyYhlrz8vFQpcV49kFIBkNKM0jy4QbDou8 QoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmDcTZApPZl4J3L5XQKcwAZ0i7At2SkkiQkqqgVH vd9iiJ4vm+79xfpXEFvM8WbGaTfdJ8Az7hNiuX+sNNk/Wmy3ccU17Ymd2Oc/vEy/UKiM0/NYn 223eI3/X8ckdPse0hgS3yHeHj0k69SbcsDs9Ve1ZcsSduoNLBHoN6xannvwyS3O/dupk6cmBT +/M7be8qjb7xvzq9Lq3d2bMCJL05tn3rFmJpTgj0VCLuag4EQA0FjswuQIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-16.tower-206.messagelabs.com!1500296885!87352218!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40267 invoked from network); 17 Jul 2017 13:08:06 -0000 Received: from mail-pg0-f45.google.com (HELO mail-pg0-f45.google.com) (74.125.83.45) by server-16.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:08:06 -0000 Received: by mail-pg0-f45.google.com with SMTP id k14so79616263pgr.0 for ; Mon, 17 Jul 2017 06:08:06 -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=bLlwdLZyhIA8r8opV3rmI2mAwTLjPhffokI3TyD1a+8=; b=WXvdsxS6MpnBlDCPirkQSfsUZ3BCq0FWi/3X+htjeU/U5L6lviNI/3gV0e85hCG4D6 iwuQhIZM2ScMwec/BI5ZDFSf4Lm1THtG0kUKReHIWgX+Njk+4ZpwyRyGB5MaDXQ6/oBR 3vmiXyI4jbRTvzjdsztACyfDxL448IST6OAMY= 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=bLlwdLZyhIA8r8opV3rmI2mAwTLjPhffokI3TyD1a+8=; b=PSookro3FWh+VZXG2sfew66h9LLOtM8aUSG+6YtxAmxGnm1Ep1AMALD2bpYA4mEBHB MojdHwxt8spfG68cZbonNr43Fbo6AWNSEMYvDKojMi/zyN4e7gZvsbmowlG9SDRMxpaT gXgJMjddUJ50TqM5WjCrwSwEudUAjZLPUOlmTHriHexyq9v0ySk83iulZFGPepBC96Y8 azn+qfKW8XWMYiLaZRAEr3VUNLrYgvHIICqiyE4G286WW9lUtmUHbiGaFviwPaoKf3ef BdVJKDNvwfHMH2LOTONfaiU+mw5N+AGCySwznF8Kvtzb9e86uSW6h6jGZYQt+Iri2Dxg ZP8g== X-Gm-Message-State: AIVw110b2DOWxK2GGOzeR2lgU2E6A4XyAJvvBArOBuNprxXAU4DvluBz 9u+f5D3kK8C7lQwwu1LYXg== X-Received: by 10.84.229.1 with SMTP id b1mr595529plk.273.1500296885217; Mon, 17 Jul 2017 06:08:05 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.08.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:08:04 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:51 +0530 Message-Id: <1500296815-10243-22-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 21/25 v6] 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. This patch is in preparation to support a new vuart console. Signed-off-by: Bhupinder Thakur --- 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 | 174 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 134 insertions(+), 40 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 54c91aa..49f085c 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -90,12 +90,14 @@ struct buffer { }; struct console { + const char *const ttyname; int master_fd; int master_pollfd_idx; int slave_fd; int log_fd; struct buffer buffer; - char *xspath; + const char *const xspath; + const char *const log_suffix; int ring_ref; xenevtchn_handle *xce_handle; int xce_pollfd_idx; @@ -107,21 +109,112 @@ struct console { struct domain *d; }; +struct console_data { + const char *const xsname; + const char *const ttyname; + const char *const log_suffix; +}; + +static struct console_data console_data[] = { + { + .xsname = "/console", + .ttyname = "tty", + .log_suffix = "", + }, +}; + +#define MAX_CONSOLE (sizeof(console_data)/sizeof(struct console_data)) + struct domain { int domid; bool is_dead; unsigned last_seen; struct domain *next; - struct console console; + struct console console[MAX_CONSOLE]; }; static struct domain *dom_head; +typedef void (*VOID_ITER_FUNC_ARG1)(struct console *); +typedef bool (*BOOL_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) +{ + int i = 0; + struct console *con = &d->console[0]; + + for (i = 0; i < MAX_CONSOLE; i++, con++) + { + iter_func(con); + } +} + +static inline void console_iter_void_arg2(struct domain *d, + VOID_ITER_FUNC_ARG2 iter_func, + void *iter_data) +{ + int i = 0; + struct console *con = &d->console[0]; + + for (i = 0; i < MAX_CONSOLE; i++, con++) + { + iter_func(con, iter_data); + } +} + +static inline bool console_iter_bool_arg1(struct domain *d, + BOOL_ITER_FUNC_ARG1 iter_func) +{ + int i = 0; + struct console *con = &d->console[0]; + + for (i = 0; i < MAX_CONSOLE; i++, con++) + { + if (iter_func(con)) + return true; + } + return false; +} + +static inline int console_iter_int_arg1(struct domain *d, + INT_ITER_FUNC_ARG1 iter_func) +{ + int i = 0; + struct console *con = &d->console[0]; + + for (i = 0; i < MAX_CONSOLE; i++, con++) + { + if (iter_func(con)) + return 1; + } + return 0; +} + +static inline int console_iter_int_arg3(struct domain *d, + INT_ITER_FUNC_ARG3 iter_func, + void **iter_data) +{ + int i = 0; + struct console *con = &d->console[0]; + + for (i = 0; i < MAX_CONSOLE; i++, con++) + { + if (iter_func(con, d, iter_data)) + return 1; + } + return 0; +} + static int write_all(int fd, const char* buf, size_t len) { while (len) { @@ -336,7 +429,7 @@ 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 +581,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 +747,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,15 +763,18 @@ 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_data **con_data = (struct console_data **)data; + char *xsname, *xspath; 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; @@ -691,30 +787,37 @@ 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); + *(char **)&con->ttyname = (char *)(*con_data)->ttyname; + *(char **)&con->log_suffix = (char *)(*con_data)->log_suffix; + con->optional = (*con_data)->optional; + con->prefer_gnttab = (*con_data)->prefer_gnttab; + xsname = (char *)(*con_data)->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); + *(char **)&con->xspath = xspath; err = 0; } + (*con_data)++; + return err; } static void console_free(struct console *con) { if (con->xspath) - free(con->xspath); + free((char *)con->xspath); } static struct domain *create_domain(int domid) { struct domain *dom; - char *s; - struct console *con; + struct console_data *con_data = &console_data[0]; dom = calloc(1, sizeof *dom); if (dom == NULL) { @@ -724,9 +827,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_data)) goto out; if (!watch_domain(dom, true)) @@ -739,7 +841,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,18 +886,16 @@ static void console_cleanup(struct console *con) if (con->xspath) { - free(con->xspath); - con->xspath = NULL; + free((char *)con->xspath); + *(char **)&con->xspath = (char *)NULL; } } static void cleanup_domain(struct domain *d) { - struct console *con = &d->console; - - console_close_tty(con); + console_iter_void_arg1(d, console_close_tty); - console_cleanup(con); + console_iter_void_arg1(d, console_cleanup); remove_domain(d); } @@ -810,12 +910,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; @@ -1011,7 +1109,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); @@ -1067,9 +1165,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); } } @@ -1233,13 +1329,12 @@ 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); - add_console_evtchn_fd(con, (void *)&next_timeout); + console_iter_void_arg2(d, add_console_evtchn_fd, (void *)&next_timeout); - add_console_tty_fd(con); + console_iter_void_arg1(d, add_console_tty_fd); } /* If any domain has been rate limited, we need to work @@ -1300,13 +1395,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 Jul 17 13:06: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: 107941 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495076qge; Mon, 17 Jul 2017 06:09:25 -0700 (PDT) X-Received: by 10.107.142.134 with SMTP id q128mr21313771iod.100.1500296965443; Mon, 17 Jul 2017 06:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296965; cv=none; d=google.com; s=arc-20160816; b=fAFOMqPGDXAPcqbmPSUDwiXPJocjURFmmGeTJUrD9iwRpsI+notYw9btwHD88kUtDK Aypz4/oRcP93K9YRf9zngMpNbC53hv+ooG/MhFqIyxLh7NqZcHPP5xIbc0FeaBfAbJ3r WpvsKjuYzXi9U4yE8rHYCLJFjFuhNBjM9dqTsFpW5MfweFZdpw84iHdoAzrPwEKN/kQS ilr4gHPeEv1Pjt8pWmYrVfwNj0aSYYIaxOUISEJUIUk8n0Ev9YBdRSS+PPKhBQO+/M3t UMnEEcW0r5hymgW7PsS8u8S3aH+3U8y37HILo5nBfIkn2cILohg9z3/98zV2A8r/TPW1 Aexw== 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=exgRzTz/ntV7+EJi5PhCoWo0J0//TiFr5TjYCcPyf1o=; b=Uu5uRKVSpccz1hfm5ibVDjI8hIPkbg2E1A2hVyo8hudVCSSpSTVxwRhM/INR4ZuJz+ jTy2ubteHIK4Z/uAwYhfUf3t9b80ua1LL+omnfxUsDggNKRbgE7wqS+fGd53MSG4Udyn laY48aJNK6d2GGshNYLEuILB4WB5b7k34ibaEINKIEgAg224HCdMXdlnBNJsXZKHxP4d Fh65vhs17gH1N65zyWX1h5596pFyEI5BRDDEf3qZjej8S5ouw5v4o89bknuxzvdu7GP9 qnGFG3UId+FesICMtIZ8C/gDZwzWenUuj52iYdCa4C3D+OmRl4mbh9ERLpUMJ3v22+s+ 2veQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Le0brRSc; 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 c3si17683343iof.196.2017.07.17.06.09.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:25 -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.b=Le0brRSc; 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 1dX5kz-00059z-E4; Mon, 17 Jul 2017 13:08:13 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5ky-00057l-5R for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:08:12 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 63/58-01862-BB6BC695; Mon, 17 Jul 2017 13:08:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIIsWRWlGSWpSXmKPExsXiVRusrbtzW06 kwdJJZhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aHBwvZC9bIV0y5doCtgXG1VBcjJ4eQwAxG if7bsV2MXBwsAvOYJc5/e8oKkpAQ6GeVmHBZBMJOk9h6aD0zhF0p8eLTb3aIZi2Jo6dms4I0C wm0MkmcfLWTpYuRg4NNwERiVocESI2IgJLEvVWTmUBqmAXmM0o0TeplA0kIC4RJtPz5CWazCK hKXL2zhAXE5hXwkbh9op8FYpmcxM1znWCLOYHiZzasZoJY7C1x88hEpgmMAgsYGVYxahSnFpW lFukaGuglFWWmZ5TkJmbmAHnGermpxcWJ6ak5iUnFesn5uZsYgYFVz8DAuINxW5fzIUZJDiYl Ud6LbNmRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4N2/NiRQSLEpNT61Iy8wBhjhMWoKDR0mEd ytImre4IDG3ODMdInWK0Z5jw+r1X5g4Jh3YDiQPzPj5jYnj1YT/35iEWPLy81KlxHlXgLQJgL RllObBDYXF5CVGWSlhXkYGBgYhnoLUotzMElT5V4ziHIxKwrzLQabwZOaVwO1+BXQWE9BZwr5 gZ5UkIqSkGhhljYScV7LH79l6IvH0ox2T854UJvVtk6rjtz09WalIwWK+cDGDbXjRJ53rUVX1 uuoOhc5blr0QmHHcsHJ5bO2uyTlfs42PlHeX23zWV9K8bvjcr9CsTeuMC9//NAH/8Cr7PZX10 ev8Jpp/CZX5yXrk65MpsR4qmW8ll169t7Z0u82B/KcKZUosxRmJhlrMRcWJAC0Jfx7EAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-31.messagelabs.com!1500296888!50324038!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19851 invoked from network); 17 Jul 2017 13:08:09 -0000 Received: from mail-pg0-f43.google.com (HELO mail-pg0-f43.google.com) (74.125.83.43) by server-9.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:08:09 -0000 Received: by mail-pg0-f43.google.com with SMTP id k14so79617024pgr.0 for ; Mon, 17 Jul 2017 06:08: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=N6sVxicO5qTH+BZf2uWHkrAr++66JtvflVzqa+gSOOs=; b=Le0brRScJG/7BMCi2GY9M73CMrJmmEFVoT0x/wubDOKZJsMVVmAGnjZQpmIj4f/IVG 5MBprd4w85hIUxdoB0lLiiyUcNtX7YhWaoEkZhT+yXZTX18w8nx5FyrfpuEWl47wOLX+ DeOcjE9a9Wn74/Qlr6M3phh2xpm2pFGksGVOY= 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=N6sVxicO5qTH+BZf2uWHkrAr++66JtvflVzqa+gSOOs=; b=dEgVEhOnMxjqChAiTO50ogKxsT/5WLmMRPPMCAnzEn9Y7ldYVlT0C+xj9c/cQxvIHL EQgAj9v5hlIiKmTxbaJeq3fuA1Iv3qSpZPGUOFwpUR5iWls/cI5iiDoURhG2vV5vS6IA h6wxWhGJHbe/qhpO+VbY+HeQ9bp+kBDa5yZz6YPPoRpuvmrEoGXjKGL4chLT049IUAPG /M9MiXZ+iA0VXo6YxRh4zVAAFjbX/fhc7UY60KOO2vyG86iwKN4FXBo9kpsaA/GA0EyU G+ArejkcOYl0XxgmYXsPaiEdBnk5P78N+VUkwihv7IIcZs7NpDm1vhVr+dtX5+8KR3ri BWJw== X-Gm-Message-State: AIVw113fflk09QHeHDeFentFLd/WqTHy4zhk0wILE3Cd6vrIsp64b23Y FnvuwOm+HPBcqvLZi4zHGA== X-Received: by 10.98.64.129 with SMTP id f1mr18802954pfd.225.1500296888185; Mon, 17 Jul 2017 06:08:08 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.08.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:08:07 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:52 +0530 Message-Id: <1500296815-10243-23-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 22/25 v6] 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 - prefer_gnttab optional flag tells whether the console is optional. prefer_gnttab tells whether the ring buffer should be allocated using grant table. Signed-off-by: Bhupinder Thakur --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall 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 | 29 ++++++++++++++++++++++++++++- 4 files changed, 32 insertions(+), 2 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 c8b0300..1cddb6e 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 49f085c..c6d4cae 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 prefer_gnttab; }; struct console_data { const char *const xsname; const char *const ttyname; const char *const log_suffix; + bool optional; + bool prefer_gnttab; }; static struct console_data console_data[] = { @@ -120,7 +124,18 @@ static struct console_data console_data[] = { .xsname = "/console", .ttyname = "tty", .log_suffix = "", + .optional = false, + .prefer_gnttab = true, }, +#if defined(CONFIG_VUART_CONSOLE) + { + .xsname = "/vuart/0", + .ttyname = "tty", + .log_suffix = "-vuart0", + .optional = true, + .prefer_gnttab = false, + }, +#endif }; #define MAX_CONSOLE (sizeof(console_data)/sizeof(struct console_data)) @@ -655,8 +670,18 @@ static int console_create_ring(struct console *con) "ring-ref", "%u", &ring_ref, "port", "%i", &remote_port, NULL); + 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); @@ -670,7 +695,9 @@ 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->prefer_gnttab) { /* Prefer using grant table */ con->interface = xengnttab_map_grant_ref(xgt_handle, dom->domid, GNTTAB_RESERVED_CONSOLE, From patchwork Mon Jul 17 13:06: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: 107954 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495437qge; Mon, 17 Jul 2017 06:09:39 -0700 (PDT) X-Received: by 10.36.86.139 with SMTP id o133mr5266200itb.50.1500296979514; Mon, 17 Jul 2017 06:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296979; cv=none; d=google.com; s=arc-20160816; b=JOhZp94RWBU+fFYqYj9AR6ccqfpvuAwmI35u4UQ8psKoMBubKksdTwUduPhvdZHHj7 jq9NeYtqFlEPvRfhP3oUMACaLPDiPM+OWrxp4kTn0//O8wn2bZemxUJ3ZV+rKr0W8jfd Cyk8Bg1p1GulLH6b73zPnJr+bHXSLrq1V8JdjKlxD5x1JPz/z82Srbb0DzXgiE03I0dn IVHTRVA/VMqW4K0mfAOyn4N8tVWmcF36QIJcrH/krogCPoTak2tAsLqAiEobU4n/p/KF 9Qtc3QJl3giHEHF0RsX+ysGe6QnyTmWbxrIxN7Fz+y+eNLGExQW4Y+/LYugF9GojQ28M R7fA== 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=8BGq/DBn8VTv/hjSG7e/HGS6h2bkqgmm8FvySAO4c4s=; b=FiRnkgB5e/Yhmc/qlAu7Ag8U6jnuYr+oA/XCkrBjAXJ0jmRshi0dmx//XlpQ0+e9IY 24izqAhyk1WtHWo4Q9cdexdm2gNyLHJS51I73XfpoTCP+rBamDoIYnsLRofCK79+jIEb yxHC0FepA10ryH3mdmpYrS5ortInwtsXV+IgOdYu6e+/2AhcHjWLOyf3nGl42bwNxdpM mbQX9B/Sr1uVb6SmTIHNgnXGhqt74+aSKOCxJWx4XKYSmo71Rx151mwJ4MSK33/LeFMY h1zk9imInTsNXNL2o8ovOqIPU/6S///HuCPKDMIEdVm5h7HeRWxRYZz0Mgjq9ZGSA/zO RSSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=RhB0U9v4; 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 5si9686691itj.50.2017.07.17.06.09.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:39 -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.b=RhB0U9v4; 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 1dX5l1-0005DR-Lh; Mon, 17 Jul 2017 13:08:15 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5l0-0005Al-AO for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:08:14 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 99/5F-02175-DB6BC695; Mon, 17 Jul 2017 13:08:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXiVRtsqLt3W06 kwYMtjBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aC9qvsBcdEK9YdWsXSwDhZsIuRi0NIYDqj xOY5u5hAHBaBecwS7378ZgFxJAT6WSUWrbjO1sXICeSkSUx8uIMVwq6SODPxD5gtJKAlcfTUb FaIUa1MEjca+4EaODjYBEwkZnVIgNSICChJ3Fs1GWwDs8B8RommSb1gNcICMRL7u9JBalgEVC WaP7xmBrF5BXwkds7dxwyxS07i5rlOMJsTKH5mw2omiL3eEjePTGSawCiwgJFhFaN6cWpRWWq RrpFeUlFmekZJbmJmjq6hgalebmpxcWJ6ak5iUrFecn7uJkZgYDEAwQ7G73+cDjFKcjApifJe ZMuOFOJLyk+pzEgszogvKs1JLT7EKMPBoSTB6741J1JIsCg1PbUiLTMHGOIwaQkOHiUR3q0ga d7igsTc4sx0iNQpRmOOSQe2f2HieDXh/zcmIZa8/LxUKXFePZBSAZDSjNI8uEGw2LvEKCslzM sIdJoQT0FqUW5mCar8K0ZxDkYlYd7lIFN4MvNK4Pa9AjqFCegUYV+wU0oSEVJSDYwhEcY3dVl fcppkHWj51O7W81jYeFn/tT2KbG+vX+Zmj9BoYmVs3r7AK+T+fSWhhwHLeCs52G042EPzF7Sk rT5tmGpwjm02h/y9VbqZNqu7tOdd/HHiK5/LfTEtbVV/n3dJu591dmYd6p1yOz/gU+0GHmnpJ dujmlNUV8+4sLGi3f1M4L8HhUosxRmJhlrMRcWJAGjYCGO4AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-206.messagelabs.com!1500296891!89221333!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54464 invoked from network); 17 Jul 2017 13:08:12 -0000 Received: from mail-pg0-f49.google.com (HELO mail-pg0-f49.google.com) (74.125.83.49) by server-15.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:08:12 -0000 Received: by mail-pg0-f49.google.com with SMTP id u5so17093502pgq.3 for ; Mon, 17 Jul 2017 06:08: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=ephcjrO7kt4QMlplx6Rz9VJrp+MAMSYZdXySOrB8r5s=; b=RhB0U9v4JQdEpljt6BP2xxOnAAFO2kkYPN0wiwCB/n8TwNf2Z6ElRa9gYmElOjKHpB 2shNzaOta35ECs70qBONOTRO699hGG3mp/f54LaLL8O27XxzoBPY2yWJTzRBxeazvW6Q hZfY1ft9dJ3G6wh7BIi46G+VyDbgYGK58EGOo= 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=ephcjrO7kt4QMlplx6Rz9VJrp+MAMSYZdXySOrB8r5s=; b=Fh4cUEQt9MH+daCut3fLSHMj1hY6rE2jlixHOkebdXOFRgQPPG+m6ohtFr+Ft+XDBp 9gQzfsUNvalMl9amCEb8Pop8VnQc428lb7wJ9zSvDtAQDOnGmxmZhBXnwo4q8ClHWVVa 1uvPM/9mVhNueRQNpwEQiWB83LWc9kzsHwrREEZfQ9XLGChtjwZL2wqJOaJxWuQ3iN7v zEDjACzFV3/6IA0WU9Ne1br4JWBAhHuI7sCSQkg59OnveTgsQ1t41fBez5FETf4MSfFz jBzXPunv5htnHqBidghJQqVZL6wRRzgO6G8neDBNKjesSU0ZURu8CFOVeRvnplEL/62W UAfQ== X-Gm-Message-State: AIVw1107/Ru9NUCj05/AYodbOsoD0nhRHU81o3YkbEuawKe89bdKgYvp ZNePxZ+Cm94g/6mDktYn0w== X-Received: by 10.98.26.211 with SMTP id a202mr19411858pfa.30.1500296891263; Mon, 17 Jul 2017 06:08:11 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.08.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:08:10 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:53 +0530 Message-Id: <1500296815-10243-24-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 23/25 v6] 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 977779f..f7139b3 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; @@ -343,6 +344,7 @@ int main(int argc, char **argv) char *end; console_type type = CONSOLE_INVAL; bool interactive = 0; + char *console_names = "serial, pv, vuart"; if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) interactive = 1; @@ -361,9 +363,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; @@ -436,6 +441,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 Jul 17 13:06: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: 107957 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495472qge; Mon, 17 Jul 2017 06:09:41 -0700 (PDT) X-Received: by 10.36.222.215 with SMTP id d206mr5684715itg.63.1500296981065; Mon, 17 Jul 2017 06:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296981; cv=none; d=google.com; s=arc-20160816; b=h5ZRPfACfZMI1/dKsaMCYYNs9qOUjxgZY8giIBRKF+Jbqlc9TK8jUk9/PA99NlbW4A tQta7fhuHZscurnQw1xnQeCU5qp/yESNQfxiUoFBY+o0SMpp6I2hUrgnQBN8tDzGHDz2 UfdxDUsej2JweiElemEAukzk/LyKjCikCmUxOirbWeLMaAk7sNQtuYjA4WbM+pKOhfJc VjX8gJ6xOCobGMx0LCjsfWfgqjbhcNx7sDHrJ/iDLmM9exRpIV1/v27yKmxku8fKckQj h133ZY3XiyT+Gf5YB02dKn8mPEWGMrc52E0EdYeYxbZUajoU1kOmh3SnztC60ooS1E7h PjQw== 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=h2L/JqMbyNus1hEDb2PS6+YbB4xyOWEm5Y//U2coDmo=; b=G7ayQyRmv7mjRWbtaSsA/eiy4aNG7W63RPQodtjctMu/suvETvpyCR3DCwOHEWbvZ2 R5fdE1ZiuNaNR472E0XPhMTHyIXe+6WCZ9iEGlmn8qXKlO9kXWWevdLdHwOM75QKL1vZ nd6Kq0/lQkEeOkZYee8FeboQ4MyHOsNFtjtBLsGoazaYMA+EjosTORG4sYeWOHdQG5Ae Zl851BmhpXpTd+oIzzAtRvs14wfEo75wJP22Azbzk1Zaf1BbHJRQsLc5O0P7sKvfy+F/ v1PCmz15mmK/9Ybq2w1A8s1brv+4IMN2hr1U25z18G1OSYiEd6Nd+ErikbZMC8iKVUMc kuIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=QZTpAuCP; 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 f76si9843302ita.144.2017.07.17.06.09.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:41 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=QZTpAuCP; 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 1dX5l4-0005J9-Ta; Mon, 17 Jul 2017 13:08:18 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5l3-0005G8-HJ for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:08:17 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id D5/8F-02177-0C6BC695; Mon, 17 Jul 2017 13:08:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXiVRuso3tgW06 kwYdZjBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8ako6uZCs4qVLTf/snewDhLsouRi0NIYAaj xK5jB1hBHBaBecwSF1f/ZAJxJAT6WSWm/Wxi7GLkBHLSJK523GCGsKslXj6cyQZiCwloSRw9N ZsVwm5lkrh5SamLkYODTcBEYlaHBEhYREBJ4t6qyWAzmQXmM0o0TeplA6kRFoiR2HvbB6SGRU BVovflLCYQm1fAR+LWlkYmiFVyEjfPdYKt5QSKn9mwmglilbfEzSMTmSYwCixgZFjFqF6cWlS WWqRrqpdUlJmeUZKbmJmja2hgrJebWlycmJ6ak5hUrJecn7uJERhW9QwMjDsYL391OsQoycGk JMp7kS07UogvKT+lMiOxOCO+qDQntfgQowwHh5IE7+atOZFCgkWp6akVaZk5wACHSUtw8CiJ8 FaDpHmLCxJzizPTIVKnGI05Jh3Y/oWJ49WE/9+YhFjy8vNSpcR5V4CUCoCUZpTmwQ2CRd4lRl kpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK8y0Gm8GTmlcDtewV0ChPQKcK+YKeUJCKkpBoYN4u sVJxnt7TD/67n61a1u/f4fU4e8nh4ovTN9zJnpbnvzgUKrm55L3a0fIHnX52cm4mGx27OSL51 ms/D8kJX7HnHb8dTjCVuhhX21x+/X+Elm7OF85t7nOJJtQ9l5ziXHgpJ6L2yfpp8VsC2xNraU w/YXRtcZqz8LVObeuTghLAPidF3e2T2KrEUZyQaajEXFScCAPtvd7S3AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-7.tower-31.messagelabs.com!1500296894!98249672!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 46890 invoked from network); 17 Jul 2017 13:08:15 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-7.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:08:15 -0000 Received: by mail-pg0-f44.google.com with SMTP id k14so79618485pgr.0 for ; Mon, 17 Jul 2017 06:08:15 -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=qeIH6mri6baDhY7Yk2iqtbCBeVmFW4zSmk2Zg4YVBBo=; b=QZTpAuCP6HOB2sRTkEia8Q1Fpj1l/bcxdXezYnbhJ5AFXtknA4SFUkogFI9cki4buu QwN0vbEH6HxKR8VcflSfHJi+B6ZPF7+8IaBqOoyCnFiDsGi2XSJrrYWf7JrWUx4Nt3Po Cg9vceEVahWXXxIuWSso8d/NdGZqDSaz+aPjQ= 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=qeIH6mri6baDhY7Yk2iqtbCBeVmFW4zSmk2Zg4YVBBo=; b=XY5UF0YXCX/O9W93fEuPtFlmeqEYIhrLxaWBUbjK6ej1lKyQimqtbX+h5kwTT6qqPk JjA8MpuUPeF3U45p6YPQnqPTL84q+udmUhC7ScNvRQsbMLpiR70FqUQ65oBL/BrW+pwL XPPeGkyCELLWWoECYQtRZChDqTObNJxWxO9kTY+dmTYyc98NO7n3YIF1gzcuU4oGCBDa TZuSzX+ZL2DbiGoSOMNZavoZp3PpXzy10NYFu8pEYOeQ9hWbLRsXIkt4oVo0qqHI/LB+ 7D7+YocO9EnRwkCIa48hwW/t3hifbpm+6EFK0rxEU5b6i58Nds8sNaALAxoPgSHbgWrV Qodw== X-Gm-Message-State: AIVw11059zBYJUpxlskfSmAtoHIHhXwR680UeZLfOU7hWqgGvqVgzXll 0GQQ3yyTRWvye4gtXdLD9w== X-Received: by 10.99.97.212 with SMTP id v203mr14884576pgb.188.1500296894198; Mon, 17 Jul 2017 06:08:14 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.08.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:08:13 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:54 +0530 Message-Id: <1500296815-10243-25-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 24/25 v6] 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 setttings. 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 tools/libxl/libxl_arm.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index e3e5791..9eee50c 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -44,10 +44,22 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, uint32_t nr_spis = 0; unsigned int i; + /* + * 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) + nr_spis += (GUEST_VPL011_SPI - 32) + 1; + for (i = 0; i < d_config->b_info.num_irqs; i++) { uint32_t irq = d_config->b_info.irqs[i]; uint32_t spi; + if (d_config->b_info.arch_arm.vuart && (irq == GUEST_VPL011_SPI)) { + LOG(ERROR, "Physical IRQ %u conflicting with pl011 SPI\n", irq); + return ERROR_FAIL; + } + if (irq < 32) continue; @@ -130,9 +142,10 @@ static struct arch_info { const char *guest_type; const char *timer_compat; const char *cpu_compat; + const char *uart_compat; } arch_info[] = { - {"xen-3.0-armv7l", "arm,armv7-timer", "arm,cortex-a15" }, - {"xen-3.0-aarch64", "arm,armv8-timer", "arm,armv8" }, + {"xen-3.0-armv7l", "arm,armv7-timer", "arm,cortex-a15", "arm,sbsa-uart" }, + {"xen-3.0-aarch64", "arm,armv8-timer", "arm,armv8", "arm,sbsa-uart" }, }; /* @@ -590,6 +603,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, ainfo->uart_compat); + 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 +934,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) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) ); From patchwork Mon Jul 17 13:06: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: 107952 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495398qge; Mon, 17 Jul 2017 06:09:38 -0700 (PDT) X-Received: by 10.107.24.68 with SMTP id 65mr18851424ioy.184.1500296978235; Mon, 17 Jul 2017 06:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296978; cv=none; d=google.com; s=arc-20160816; b=MjE6JZ2K9Z9vwLO3Uf6ujnXhhyWMK9oyRek82TD7ha2On3AbpovQTtL6uxuEOvuliv YS6S8rIBCuGARmyCmqipajXZMR1TKmXi7rSUNoRqSoHCYqTWs621c9Sgknsj8qlf/khD ungdPcfuinFuXjtMBCMChkn6IA4vsCttmZ/hImHECfA88QB3ZsJrV4QD+kVRS7Vnzc/V 1PFFH5tHeGczEMGnhN0cOB2ZVCnKzJEN+fwIFeIkIuHjPCkLWmJI/wsTawfV7ZqlYSOe zgCxoz0R/HW3xKS2cQNXWj32tRuCA+df7+9YEAiEVU6aL2WVMzwpB5i74hYoT5AYxwil 4KBw== 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=ji3FxMgTduKhjNydxMLQQr8ShIhH5O30PoP4cjEuhpE=; b=QrsJ/JPV4avbWM++mixng1G1MKpPD0tQXnYB8aWmTFNgYCIKqTWae9sqfZD6sfYdkW F4ChngWyYQh9s5cXjo9bpppwZv1YcsuXu5VqOtNeY7v/8KMf8dcJrLM0vOVxSAJEoO5x uYGOHWmkAr4WB2gMAd2tk7oOPWFyk4LHeCQ+0alA5mtzl8UkG2IJyyE+saUOHFyoZcuV zsuQfth47VOuLBuJdoAVazai6u0HrlLNeuKRFN6nTn8KFDYVUWXbkL7K8Wmb/1/Xp0vs EekiPltdTlBcRW8S6SJHv7CjQrClCwUkElt8Bnm6jjQTEjghGIStQV2jPK595KrvAacK ZTLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Bt5PphZ8; 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 h84si16345833ioa.194.2017.07.17.06.09.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:38 -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.b=Bt5PphZ8; 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 1dX5l8-0005Ns-5t; Mon, 17 Jul 2017 13:08:22 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5l6-0005Ll-T3 for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:08:21 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id BE/8F-01732-4C6BC695; Mon, 17 Jul 2017 13:08:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRWlGSWpSXmKPExsXiVRtspHt4W06 kQed+fovvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPPtissBedUKq4sVm9gPCnXxcjJISQwnVGi /1ZAFyMXB4vAPGaJpeuesYMkJAT6WSUm9LhC2GkSixe0s0HY5RJ31zWzQjRrSRw9NZsVpFlIo JVJ4ubW3UxdjBwcbAImErM6JEBqRASUJO6tmswEUsMsMJ9RomlSL9ggYYFIia9LHjCC2CwCqh Kb121mB+nlFfCReNbJAbFLTuLmuU5mEJsTKHxmw2omiL3eEjePTGSawCiwgJFhFaNGcWpRWWq RrqGFXlJRZnpGSW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGYFDVMzAw7mD8fdrzEKMkB5OS KO9FtuxIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8m7fmRAoJFqWmp1akZeYAwxsmLcHBoyTCW w2S5i0uSMwtzkyHSJ1iNOaYdGD7FyaOVxP+f2MSYsnLz0uVEuddAVIqAFKaUZoHNwgWd5cYZa WEeRkZGBiEeApSi3IzS1DlXzGKczAqCfN+2gI0hSczrwRu3yugU5iAThH2BTulJBEhJdXAyH3 YkvdB/6kNvxgs4z5LJavpyak9V16REhP1NcUz5vAcDv5w9/aIfcG+PT7t/38p21180fv1tSzz 89sqzGWTbsz/yJDhe07dOe1EaYdyxD3v9zw3JrPzZPMsnpS3vHXu4zv/LTadWTeLXzAjfdvi9 X8+3j2qK/T1IZtDzxTBTk2rI9+e/VkvqMRSnJFoqMVcVJwIAIUzkXi2AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-31.messagelabs.com!1500296897!105653538!1 X-Originating-IP: [74.125.83.50] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39704 invoked from network); 17 Jul 2017 13:08:18 -0000 Received: from mail-pg0-f50.google.com (HELO mail-pg0-f50.google.com) (74.125.83.50) by server-14.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:08:18 -0000 Received: by mail-pg0-f50.google.com with SMTP id u5so17094770pgq.3 for ; Mon, 17 Jul 2017 06:08: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=8w66EsmXPT9pb3sTCRbxsiTS4cM7vEwLM/tUk51OCcU=; b=Bt5PphZ8A+l+Ta9vjCazvKRwm95xZPmA4Hct43kmaUvQrbycAlqTub9ClEF/o0eM68 lBzmt5a4UlvmRN0GFbgqTE7HFyjg7udqEmPnAWL2rfyl5y/XLIx+7euybrcbZIrJH6X3 c61cbKS/Sv6JVF8OhkkZK3t4N2Vei0q/pMB3w= 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=8w66EsmXPT9pb3sTCRbxsiTS4cM7vEwLM/tUk51OCcU=; b=C/k6HYoi6WoIpTr6mq3vvAEuqmb6r2YdaK0ZyGTo+RXnGaRBhPMrlEurWNXKto9yrD 5NHya92ntsLJCzXCVoMSTQQmpTEsDiQmcGWMxDeJwExBVL+WTCQD5rbyFKDXyA9QsGEO f3+nETs3UmP0qYvjJenKNP/G6YLLPUcyijukDSEyHiqpeOn1Q+0n2gChllve+PvVtsRT Hld0m2m2EUYk/LtwdrCSS84AWONvNUPZxbl8gV10vPQZ9BObrYtZQc5FdNRgG0JSnEtm kk9wXcwyAl87OoH7+ScKmrSNSzWHw1rKF3FNwNMesW+SQcPQK+kf639HioGZQtheFu2X Jqfw== X-Gm-Message-State: AIVw112PuJSL6AwMj5F45vB6fxOTdQNMWw1eVdeDm6z02LJl+2iwgW9w Rxcgzcv7IAmwB8R5DAFdXg== X-Received: by 10.84.254.7 with SMTP id b7mr6410086plm.132.1500296897140; Mon, 17 Jul 2017 06:08:17 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.08.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:08:16 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:55 +0530 Message-Id: <1500296815-10243-26-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 25/25 v6] 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: Stefano Stabellini CC: Julien Grall 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 | 9 +++++++++ docs/misc/console.txt | 44 +++++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in index 79cb2ea..75f9169 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -1105,6 +1105,15 @@ Allow a guest to access specific physical IRQs. It is recommended to only use this option for trusted VMs under administrator's control. +If the virtual uart is enabled then irq 32 is reserved for it. By +default, it is disabled. If the user specifies the following option in +the VM config file then the vuart gets enabled. Today, only the +"sbsa_uart" model is supported. + +vuart = "sbsa_uart" + +Currently vuart console is available only for ARM64. + =item B Limit the guest to using at most N event channels (PV interrupts). 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 ARM64 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.