From patchwork Mon Aug 7 08:52: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: 109522 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481848obb; Mon, 7 Aug 2017 01:55:42 -0700 (PDT) X-Received: by 10.107.173.89 with SMTP id w86mr11791995ioe.2.1502096142813; Mon, 07 Aug 2017 01:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096142; cv=none; d=google.com; s=arc-20160816; b=B2W88LNG4hRT6kA0QKCOEL+6/CnyN/2+aHyJXn2zcWsGTpRR9+M5gPgmy8N9F0Vz7x llJCjUzFM0F/50cZ2Uc0Sufz2FTCAvm1GtA/sW6MD19ikjVFVPQjDPqp2i/sTUSVjhTg 4MHhWRvkV/DCKJQnYUCPGQYMT46kjTsEiay7KAyokKVi3nNwgNoYAd/Jbc4bzwL1OVXf DZgd5EXjlWFnKAT+Gx8FPh0zRH+yNwx83JUqUU+rhSokJhdpo4mLoRWROnZ3+SjJveL2 SPkZJt/jKchc+qTpTIh+39uUZYLjJz/E2X654QCUV1sylIc0isGj7q5sTQD1Ct8vlPOJ 6kXQ== 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=tBWNCpjoCOcFq6/moysQc9BFDAcEhPjBl9xOH7j8mQKuNC8YO212qLUuJCFAadLhgt rYBkowv2UvxhPZEUHYhT4bchnHzoxuOvp6sPPsP4tCydmPMGWRPB/hjsdR3y3+7crmeF Hv3U7DD6VEaayLJ5PrpD75Jf7HdWuFBowUgFIzc7mXg5cpoUqpGOs1PWVUNc7K2sJQt7 B60xg3wUyIRmRs5Fq8sFLEyg1+acEIKA0SdWBa9zu8buk11QUE73IaYq3soNcNRHvBsT xgAHmfsfdtVaoiKfiKHa76ofHfwtuU5bMdMpp7GGIPpdWUX95oi9SXSgAzp6joSF6mAn XQrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Fu8va02h; 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 f184si8005980itg.1.2017.08.07.01.55.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:42 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Fu8va02h; 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 1dedn4-0004Ey-1J; Mon, 07 Aug 2017 08:53:34 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedn2-0004Eh-M0 for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:53:32 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 99/F2-01724-B8A28895; Mon, 07 Aug 2017 08:53:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRWlGSWpSXmKPExsXiVRtsqtut1RF p8OwUm8X3LZOZHBg9Dn+4whLAGMWamZeUX5HAmnHv5U+mglaBiiNT/RoYG/i6GLk4hARmMEp8 3HeOsYuRk4NFYB6zxO/HViC2hEA/q8Tvg14QdprE42v/WLsYOYDsSok5a/xBwkICWhJHT81mh ZjTxiTxbulDRpAaNgETiVkdEiA1IgJKEvdWTWYCqWEWuMAoMfPvczaQhLBAksSyPxPYIfaqSq w7NIEFxOYV8JZ49eg9K8ReOYmb5zqZQWxOAR+J85fesEAs9pa4fayPcQKjwAJGhlWMGsWpRWW pRbpGJnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIFBVc/AwLiD8dVxv0OMkhxM SqK88SvaIoX4kvJTKjMSizPii0pzUosPMcpwcChJ8CZodkQKCRalpqdWpGXmAMMbJi3BwaMkw vtCHSjNW1yQmFucmQ6ROsVoybFh9fovTByTDmwHkq8m/P/GJMSSl5+XKiXOew5kngBIQ0ZpHt w4WAxeYpSVEuZlZGBgEOIpSC3KzSxBlX/FKM7BqCTMOwlkCk9mXgnc1ldABzEBHfQmsRXkoJJ EhJRUA2NSz6LEkpibOnr+haaLHKPfvG9cHCD5QUP1x+SjiXfCv9p8rz2R0bdywu5gG9Z7P554 fO77INUsOPnUAadILl1Zv1WfW0Njw+OV+Ju/+QQ8WNuwr8Hxz8ulmb0bG5XDza89XBF/yzmwb v2j/PBNmozZe7XuzdwUU8F3kPFv5kqRicVvFbZOYVNiKc5INNRiLipOBAASJlJlvAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-31.messagelabs.com!1502096009!108174893!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 18962 invoked from network); 7 Aug 2017 08:53:30 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-10.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:53:30 -0000 Received: by mail-pg0-f53.google.com with SMTP id l64so31596189pge.5 for ; Mon, 07 Aug 2017 01:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hEkKGCPm47FMsgYwL/NrMZbix4eTUybWDHit8lEDoDc=; b=Fu8va02hKPIVIuB4ZVop+qAafrH7LY18UBOZcmmVVH4B36oYu9xoa1GfausRlz0YQu sLrHSze/j+hsErYPmUH4qDzNrWP84TbKcBpeET/PTIn6yADww94M1r45Xb6DZDT5VXoz cxpqF92w4fodS1SWH948f33rP8neI9MlnUIGg= 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=FjvAPeyGf9W7PIcRwxscI1GAB7cEX5Zisg9X33ou2kp2gK05GaUFfwsL8es/PCMmky nP8fMnRsVsYXXBkxGmwjU7gYZBRJXSp8vndjno2DLQcwdQ4qK3/6k05/BY7dBGaqRqk1 enOQwxmpMK1KrmzWCT72fR+XSTI5gni9VbrRf8AWV79Rt0Q3aoALU1dg2cB3K4/RwvIb i2Vt09UMe7YsY3W87SVNhYvoVaqADVUCLdUUt56ntebabfRVjMWQtTmJPQGBF49FxKGK skABhOQXi35zbc6kieafIBlDHZIWeXMvoyzbxPzSNi+FLco88JCH/gMMiBhERBoBZqJX KUNQ== X-Gm-Message-State: AIVw1117Y25MAo9oKXGtYzYgkKLHxT49TCIn2SU6vunJ2rlGVzSj5CqX LFRPoS3BGsHLKGHbljnNnQ== X-Received: by 10.101.91.70 with SMTP id y6mr10780458pgr.122.1502096009114; Mon, 07 Aug 2017 01:53:29 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:53:28 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:22:53 +0530 Message-Id: <1502095997-31219-2-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 01/25 v7] xen/arm: vpl011: Define common ring buffer helper functions in console.h X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" DEFINE_XEN_FLEX_RING(xencons) defines common helper functions such as xencons_queued() to tell the current size of the ring buffer, xencons_mask() to mask off the index, which are useful helper functions. pl011 emulation code will use these helper functions. io/console.h includes io/ring.h which defines DEFINE_XEN_FLEX_RING. In console/daemon/io.c, string.h had to be included before io/console.h because ring.h uses string functions. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Split this change in a separate patch. tools/console/daemon/io.c | 2 +- xen/include/public/io/console.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 7e474bb..e8033d2 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -21,6 +21,7 @@ #include "utils.h" #include "io.h" +#include #include #include #include @@ -29,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/xen/include/public/io/console.h b/xen/include/public/io/console.h index e2cd97f..5e45e1c 100644 --- a/xen/include/public/io/console.h +++ b/xen/include/public/io/console.h @@ -27,6 +27,8 @@ #ifndef __XEN_PUBLIC_IO_CONSOLE_H__ #define __XEN_PUBLIC_IO_CONSOLE_H__ +#include "ring.h" + typedef uint32_t XENCONS_RING_IDX; #define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1)) @@ -38,6 +40,8 @@ struct xencons_interface { XENCONS_RING_IDX out_cons, out_prod; }; +DEFINE_XEN_FLEX_RING(xencons); + #endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */ /* From patchwork Mon Aug 7 08:52: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: 109526 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481896obb; Mon, 7 Aug 2017 01:55:46 -0700 (PDT) X-Received: by 10.36.228.134 with SMTP id o128mr143683ith.89.1502096146740; Mon, 07 Aug 2017 01:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096146; cv=none; d=google.com; s=arc-20160816; b=oiLV/B3b27boOw51R7W6P4HKfeMWEi52+4kkNksQYDGpV1iSe+H1wruDJS9QVJ9cBY sEPyXvg6kC/RMWQehRmN4L9NSrvNFWG14OxlMqHvGViH1yJTYpOl9qETDxxyVUOgOqbl lFL/Ig1iGWYal8h4lgX6jKH2hqBFNMvO6k7pNKWdnKgJfMklcbQFgZ7dyGJigIQEa4tw uc1o+uN4NtcuMU0HWyxc2+CHM/39gM5YWSsUSFUL07AC8sUCWk8fKe/gH7d1OeBfzef1 6Oo8L8EznCCwWjq3bBBp1m6SG5AR3I4M5bt3hsRsZgB+QXhDwN28G2WqH2q/M2X0VNQT xQvA== 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=46/EfXGB+JDwmoN4CpNcwBhK8j6UHTYNzRRn8ovCa6o=; b=ydG90O5nUCvHA1edMvHw56DRASxxae2jB928/PgWFxj91yqRy+fMj1XhZTBL3G1scc loGt13S0fZDO+Xc5wcn4NFeT+5Jrn8L0KVmfcGIkAXsGnj2LhCp9Yn2bymS1XUpviWqJ EXTr61lBbnzwHUVih8ZFAR1jDYVtuLf4tGoKSIDiVQXeYXMurcYK7fI8OK9P0Wpu9DzO UPRlI9SFFZpSeRv03FGuLqRhVXQHgSS0zZDoYlhZAi5yv6hoGwyMVy76eebeESVy7iMj iLp5y6kXiY4hfkUq0aQcXhKiFj7/+VdP4bYfcYVlAc57VT+0TAtfTTwVIdzAmkbv/9Yy tZpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kAZP+swE; 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 h2si8334326itg.75.2017.08.07.01.55.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:46 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kAZP+swE; 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 1dedn9-0004HF-BO; Mon, 07 Aug 2017 08:53:39 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedn7-0004GC-RN for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:53:38 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id F4/2D-03044-19A28895; Mon, 07 Aug 2017 08:53:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsVyMfTAet1+rY5 IgxM9Fhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aGpxIFHSsYK76uVW9gbG5k7GLk4hASmMko sWvXJiCHk4NFYB6zxJRZkiAJCYF+VomTc16zgSQkBNIk7ndcZepi5ACyKyTmzxIDCQsJaEkcP TWbFcJuY5I4vTUFpIRNwERiVocESFhEQEni3qrJTCAjmQUmMkss+HGcHSQhLOApsfXSLlaIva oSV+e9BbuBV8Bb4n3fHmaItXISN891gtmcAj4S5y+9YYHY5S1x+1gf4wRGgQWMDKsYNYpTi8p Si3SNDfSSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQLDigEIdjD+XRt4iFGSg0lJ lDd+RVukEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneRxodkUKCRanpqRVpmTnAAIdJS3DwKInwv lAHSvMWFyTmFmemQ6ROMbpyXLmy7gsTx4KeDUByyoHtQPLVhP/fmDiavn/8ziTEkpeflyolzv sGZLYASHNGaR7caFh0XmKUlRLmZQQ6VoinILUoN7MEVf4VozgHo5Iwb5gm0BSezLwSuAteAR3 HBHTcm8RWkONKEhFSUg2MEw6Js2s2dTr9bLmTUfX17LHzb/LLDi4PWcn7gbH5QZnz2aaQRC9e P6X2+VlX+S9/unF3Zdvddxs2vZk8yzy8PZ4nfdXrRU72k0SPLqrI/dpR18e3wzh2jtR61pvv2 8pEUm24Ltq5Lr78QsYkatJ5gy1GIaoqMcp3mBtW1gks3yyzIn7254b9SizFGYmGWsxFxYkADw QYGMkCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-21.messagelabs.com!1502096014!73625188!1 X-Originating-IP: [209.85.192.175] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24664 invoked from network); 7 Aug 2017 08:53:35 -0000 Received: from mail-pf0-f175.google.com (HELO mail-pf0-f175.google.com) (209.85.192.175) by server-11.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:53:35 -0000 Received: by mail-pf0-f175.google.com with SMTP id t86so31415103pfe.2 for ; Mon, 07 Aug 2017 01:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1fygk/iD4lDx2NtEmhdDChWeD8mwATvhZLL0+YuABJ8=; b=kAZP+swEOMZbnUR4pyTnuK2zsWuFPGssm7ge0AQ6+fMKWlRI2k/if+1cfshwlNl/Yo g2S6SsDd2nJs/MsA7n5a+HptZycHwXCFezSG3+t+PNLKVOMCAu/WTsRVZ7k1ZRiq8ZMN mPrnQUFpSGksvC87eW2TrfH36WwNzS77p4gTc= 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=1fygk/iD4lDx2NtEmhdDChWeD8mwATvhZLL0+YuABJ8=; b=KxFkrN7LUK03xxJMmXaspCALtEnvJwWYvHLJY99geE9HtJX/eCgSaLNbYKK+OSnjuD IXypTbR9yGWQPzExlHaoXd8gohFbmBvUmuqp1fmN/mJ89k3L6REw9M//oADR3wZ3Qae7 4/lV1zG68i+TY8QkAcQvnWfYuIu4yZCsnOuzUAlRxp7XkjpdbW2GC9pC64hN60nwU7Lm N9tqnzLoWXTfhyvayaGJ8BUOYazxGA9UlXk7cFcARoku9BI0MLxacI3HeE5AOVL0l2CE 4eMqMKWb4r8du7b05K2iglVW7u91NRZGOrNPdThkG1f8acZPiJmKFdJ/6+IMbVEcWVoY Urpg== X-Gm-Message-State: AIVw113h0FqS8oiof7BuWbX3E/ofcPgo2krXml0wGvuTu+8wBijHucRk OtXwbZZa37zF2SSSa/WYhA== X-Received: by 10.99.161.9 with SMTP id b9mr10800681pgf.144.1502096013862; Mon, 07 Aug 2017 01:53:33 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:53:33 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:22:54 +0530 Message-Id: <1502095997-31219-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Andre Przywara Subject: [Xen-devel] [PATCH 02/25 v7] xen/arm: vpl011: Add SBSA UART emulation in Xen X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add emulation code to emulate read/write access to pl011 registers and pl011 interrupts: - Emulate DR read/write by reading and writing from/to the IN and OUT ring buffers and raising an event to the backend when there is data in the OUT ring buffer and injecting an interrupt to the guest when there is data in the IN ring buffer - Other registers are related to interrupt management and essentially control when interrupts are delivered to the guest This patch implements the SBSA Generic UART which is a subset of ARM PL011 UART. The SBSA Generic UART is covered in Appendix B of https://static.docs.arm.com/den0029/a/Server_Base_System_Architecture_v3_1_ARM_DEN_0029A.pdf Signed-off-by: Bhupinder Thakur Acked-by: Julien Grall Reviewed-by: Stefano Stabellini --- CC: Andrew Cooper CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall CC: Andre Przywara Changes since v6: - Removed freeing of mmio_handlers in vpl011_deinit() as the handlers get freed when a domain is destroyed. Since this is a minor change, I have included the reviewed-by and acked-by tags. Changes since v5: - use instead of for including arm specific header files. - renamed shadow_uartris to shadow_uartmis to indicate that it is masked interrupt status. - use smp_mb() instead of smp_rmb() in vpl011_write_data(). Changes since v4: - Renamed vpl011_update() to vpl011_update_interrupt_status() and added logic to avoid raising spurious interrupts. - Used barrier instructions correctly while reading/writing data to the ring buffer. - Proper lock taken before reading ring buffer indices. Changes since v3: - Moved the call to DEFINE_XEN_FLEX_RING from vpl011.h to public/console.h. This macro defines standard functions to operate on the ring buffer. - Lock taken while updating the interrupt mask and clear registers in mmio_write. - Use gfn_t instead of xen_pfn_t. - vgic_free_virq called if there is any error in vpl011 initialization. - mmio handlers freed if there is any error in vpl011 initialization. - Removed vpl011->initialized flag usage as the same check could be done using vpl011->ring-ref. - Used return instead of break in the switch handling of emulation of different pl011 registers. - Renamed vpl011_update_spi() to vpl011_update(). Changes since v2: - Use generic vreg_reg* for read/write of registers emulating pl011. - Use generic ring buffer functions defined using DEFINE_XEN_FLEX_RING. - Renamed the SPI injection function to vpl011_update_spi() to reflect level triggered nature of pl011 interrupts. - The pl011 register access address should always be the base address of the corresponding register as per section B of the SBSA document. For this reason, the register range address access is not allowed. Changes since v1: - Removed the optimiztion related to sendiing events to xenconsole - Use local variables as ring buffer indices while using the ring buffer xen/arch/arm/Kconfig | 7 + xen/arch/arm/Makefile | 1 + xen/arch/arm/vpl011.c | 454 +++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/domain.h | 6 + xen/include/asm-arm/pl011-uart.h | 2 + xen/include/asm-arm/vpl011.h | 72 +++++++ xen/include/public/arch-arm.h | 6 + 7 files changed, 548 insertions(+) create mode 100644 xen/arch/arm/vpl011.c create mode 100644 xen/include/asm-arm/vpl011.h diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index d46b98c..f58019d 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -50,6 +50,13 @@ config HAS_ITS prompt "GICv3 ITS MSI controller support" if EXPERT = "y" depends on HAS_GICV3 +config SBSA_VUART_CONSOLE + bool "Emulated SBSA UART console support" + default y + ---help--- + Allows a guest to use SBSA Generic UART as a console. The + SBSA Generic UART implements a subset of ARM PL011 UART. + endmenu menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 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..56d9cbe --- /dev/null +++ b/xen/arch/arm/vpl011.c @@ -0,0 +1,454 @@ +/* + * arch/arm/vpl011.c + * + * Virtual PL011 UART + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Since pl011 registers are 32-bit registers, all registers + * are handled similarly allowing 8-bit, 16-bit and 32-bit + * accesses except 64-bit access. + */ +static bool vpl011_reg32_check_access(struct hsr_dabt dabt) +{ + return (dabt.size != DABT_DOUBLE_WORD); +} + +static void vpl011_update_interrupt_status(struct domain *d) +{ + struct vpl011 *vpl011 = &d->arch.vpl011; + uint32_t uartmis = vpl011->uartris & vpl011->uartimsc; + + /* + * This function is expected to be called with the lock taken. + */ + ASSERT(spin_is_locked(&vpl011->lock)); + + /* + * TODO: PL011 interrupts are level triggered which means + * that interrupt needs to be set/clear instead of being + * injected. However, currently vGIC does not handle level + * triggered interrupts properly. This function needs to be + * revisited once vGIC starts handling level triggered + * interrupts. + */ + + /* + * Raise an interrupt only if any additional interrupt + * status bit has been set since the last time. + */ + if ( uartmis & ~vpl011->shadow_uartmis ) + vgic_vcpu_inject_spi(d, GUEST_VPL011_SPI); + + vpl011->shadow_uartmis = uartmis; +} + +static uint8_t vpl011_read_data(struct domain *d) +{ + unsigned long flags; + uint8_t data = 0; + struct vpl011 *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + XENCONS_RING_IDX in_cons, in_prod; + + VPL011_LOCK(d, flags); + + in_cons = intf->in_cons; + in_prod = intf->in_prod; + + smp_rmb(); + + /* + * It is expected that there will be data in the ring buffer when this + * function is called since the guest is expected to read the data register + * only if the TXFE flag is not set. + * If the guest still does read when TXFE bit is set then 0 will be returned. + */ + if ( xencons_queued(in_prod, in_cons, sizeof(intf->in)) > 0 ) + { + data = intf->in[xencons_mask(in_cons, sizeof(intf->in))]; + in_cons += 1; + smp_mb(); + intf->in_cons = in_cons; + } + else + gprintk(XENLOG_ERR, "vpl011: Unexpected IN ring buffer empty\n"); + + if ( xencons_queued(in_prod, in_cons, sizeof(intf->in)) == 0 ) + { + vpl011->uartfr |= RXFE; + vpl011->uartris &= ~RXI; + } + + vpl011->uartfr &= ~RXFF; + + vpl011_update_interrupt_status(d); + + VPL011_UNLOCK(d, flags); + + /* + * Send an event to console backend to indicate that data has been + * read from the IN ring buffer. + */ + notify_via_xen_event_channel(d, vpl011->evtchn); + + return data; +} + +static void vpl011_write_data(struct domain *d, uint8_t data) +{ + unsigned long flags; + struct vpl011 *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + XENCONS_RING_IDX out_cons, out_prod; + + VPL011_LOCK(d, flags); + + out_cons = intf->out_cons; + out_prod = intf->out_prod; + + smp_mb(); + + /* + * It is expected that the ring is not full when this function is called + * as the guest is expected to write to the data register only when the + * TXFF flag is not set. + * In case the guest does write even when the TXFF flag is set then the + * data will be silently dropped. + */ + if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) != + sizeof (intf->out) ) + { + intf->out[xencons_mask(out_prod, sizeof(intf->out))] = data; + out_prod += 1; + smp_wmb(); + intf->out_prod = out_prod; + } + else + gprintk(XENLOG_ERR, "vpl011: Unexpected OUT ring buffer full\n"); + + if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) == + sizeof (intf->out) ) + { + vpl011->uartfr |= TXFF; + vpl011->uartris &= ~TXI; + } + + vpl011->uartfr |= BUSY; + + vpl011->uartfr &= ~TXFE; + + vpl011_update_interrupt_status(d); + + VPL011_UNLOCK(d, flags); + + /* + * Send an event to console backend to indicate that there is + * data in the OUT ring buffer. + */ + notify_via_xen_event_channel(d, vpl011->evtchn); +} + +static int vpl011_mmio_read(struct vcpu *v, + mmio_info_t *info, + register_t *r, + void *priv) +{ + struct hsr_dabt dabt = info->dabt; + uint32_t vpl011_reg = (uint32_t)(info->gpa - GUEST_PL011_BASE); + struct vpl011 *vpl011 = &v->domain->arch.vpl011; + struct domain *d = v->domain; + unsigned long flags; + + switch ( vpl011_reg ) + { + case DR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + *r = vreg_reg32_extract(vpl011_read_data(d), info); + return 1; + + case RSR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + /* It always returns 0 as there are no physical errors. */ + *r = 0; + return 1; + + case FR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + *r = vreg_reg32_extract(vpl011->uartfr, info); + VPL011_UNLOCK(d, flags); + return 1; + + case RIS: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + *r = vreg_reg32_extract(vpl011->uartris, info); + VPL011_UNLOCK(d, flags); + return 1; + + case MIS: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + *r = vreg_reg32_extract(vpl011->uartris & vpl011->uartimsc, + info); + VPL011_UNLOCK(d, flags); + return 1; + + case IMSC: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + *r = vreg_reg32_extract(vpl011->uartimsc, info); + VPL011_UNLOCK(d, flags); + return 1; + + case ICR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + /* Only write is valid. */ + return 0; + + default: + gprintk(XENLOG_ERR, "vpl011: unhandled read r%d offset %#08x\n", + dabt.reg, vpl011_reg); + return 0; + } + + return 1; + +bad_width: + gprintk(XENLOG_ERR, "vpl011: bad read width %d r%d offset %#08x\n", + dabt.size, dabt.reg, vpl011_reg); + domain_crash_synchronous(); + return 0; + +} + +static int vpl011_mmio_write(struct vcpu *v, + mmio_info_t *info, + register_t r, + void *priv) +{ + struct hsr_dabt dabt = info->dabt; + uint32_t vpl011_reg = (uint32_t)(info->gpa - GUEST_PL011_BASE); + struct vpl011 *vpl011 = &v->domain->arch.vpl011; + struct domain *d = v->domain; + unsigned long flags; + + switch ( vpl011_reg ) + { + case DR: + { + uint32_t data = 0; + + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + vreg_reg32_update(&data, r, info); + data &= 0xFF; + vpl011_write_data(v->domain, data); + return 1; + } + + case RSR: /* Nothing to clear. */ + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + return 1; + + case FR: + case RIS: + case MIS: + goto write_ignore; + + case IMSC: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + vreg_reg32_update(&vpl011->uartimsc, r, info); + vpl011_update_interrupt_status(v->domain); + VPL011_UNLOCK(d, flags); + return 1; + + case ICR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + vreg_reg32_clearbits(&vpl011->uartris, r, info); + vpl011_update_interrupt_status(d); + VPL011_UNLOCK(d, flags); + return 1; + + default: + gprintk(XENLOG_ERR, "vpl011: unhandled write r%d offset %#08x\n", + dabt.reg, vpl011_reg); + return 0; + } + +write_ignore: + return 1; + +bad_width: + gprintk(XENLOG_ERR, "vpl011: bad write width %d r%d offset %#08x\n", + dabt.size, dabt.reg, vpl011_reg); + domain_crash_synchronous(); + return 0; + +} + +static const struct mmio_handler_ops vpl011_mmio_handler = { + .read = vpl011_mmio_read, + .write = vpl011_mmio_write, +}; + +static void vpl011_data_avail(struct domain *d) +{ + unsigned long flags; + struct vpl011 *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + XENCONS_RING_IDX in_cons, in_prod, out_cons, out_prod; + XENCONS_RING_IDX in_ring_qsize, out_ring_qsize; + + VPL011_LOCK(d, flags); + + in_cons = intf->in_cons; + in_prod = intf->in_prod; + out_cons = intf->out_cons; + out_prod = intf->out_prod; + + smp_rmb(); + + in_ring_qsize = xencons_queued(in_prod, + in_cons, + sizeof(intf->in)); + + out_ring_qsize = xencons_queued(out_prod, + out_cons, + sizeof(intf->out)); + + /* Update the uart rx state if the buffer is not empty. */ + if ( in_ring_qsize != 0 ) + { + vpl011->uartfr &= ~RXFE; + if ( in_ring_qsize == sizeof(intf->in) ) + vpl011->uartfr |= RXFF; + vpl011->uartris |= RXI; + } + + /* Update the uart tx state if the buffer is not full. */ + if ( out_ring_qsize != sizeof(intf->out) ) + { + vpl011->uartfr &= ~TXFF; + vpl011->uartris |= TXI; + if ( out_ring_qsize == 0 ) + { + vpl011->uartfr &= ~BUSY; + vpl011->uartfr |= TXFE; + } + } + + vpl011_update_interrupt_status(d); + + VPL011_UNLOCK(d, flags); +} + +static void vpl011_notification(struct vcpu *v, unsigned int port) +{ + vpl011_data_avail(v->domain); +} + +int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info) +{ + int rc; + struct vpl011 *vpl011 = &d->arch.vpl011; + + if ( vpl011->ring_buf ) + return -EINVAL; + + /* Map the guest PFN to Xen address space. */ + rc = prepare_ring_for_helper(d, + gfn_x(info->gfn), + &vpl011->ring_page, + &vpl011->ring_buf); + if ( rc < 0 ) + goto out; + + rc = vgic_reserve_virq(d, GUEST_VPL011_SPI); + if ( !rc ) + { + rc = -EINVAL; + goto out1; + } + + rc = alloc_unbound_xen_event_channel(d, 0, info->console_domid, + vpl011_notification); + if ( rc < 0 ) + goto out2; + + vpl011->evtchn = info->evtchn = rc; + + spin_lock_init(&vpl011->lock); + + register_mmio_handler(d, &vpl011_mmio_handler, + GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL); + + return 0; + +out2: + vgic_free_virq(d, GUEST_VPL011_SPI); + +out1: + destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page); + +out: + return rc; +} + +void domain_vpl011_deinit(struct domain *d) +{ + struct vpl011 *vpl011 = &d->arch.vpl011; + + if ( !vpl011->ring_buf ) + return; + + free_xen_event_channel(d, vpl011->evtchn); + destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 8dfc1d1..1a1145d 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -11,6 +11,7 @@ #include #include #include +#include struct hvm_domain { @@ -145,6 +146,11 @@ struct arch_domain struct { uint8_t privileged_call_enabled : 1; } monitor; + +#ifdef CONFIG_SBSA_VUART_CONSOLE + struct vpl011 vpl011; +#endif + } __cacheline_aligned; struct arch_vcpu diff --git a/xen/include/asm-arm/pl011-uart.h b/xen/include/asm-arm/pl011-uart.h index 123f477..57e9ec7 100644 --- a/xen/include/asm-arm/pl011-uart.h +++ b/xen/include/asm-arm/pl011-uart.h @@ -49,6 +49,8 @@ /* FR bits */ #define TXFE (1<<7) /* TX FIFO empty */ #define RXFE (1<<4) /* RX FIFO empty */ +#define TXFF (1<<5) /* TX FIFO full */ +#define RXFF (1<<6) /* RX FIFO full */ #define BUSY (1<<3) /* Transmit is not complete */ /* LCR_H bits */ diff --git a/xen/include/asm-arm/vpl011.h b/xen/include/asm-arm/vpl011.h new file mode 100644 index 0000000..1b583da --- /dev/null +++ b/xen/include/asm-arm/vpl011.h @@ -0,0 +1,72 @@ +/* + * include/xen/vpl011.h + * + * Virtual PL011 UART + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + */ + +#ifndef _VPL011_H_ +#define _VPL011_H_ + +#include +#include +#include +#include + +/* helper macros */ +#define VPL011_LOCK(d,flags) spin_lock_irqsave(&(d)->arch.vpl011.lock, flags) +#define VPL011_UNLOCK(d,flags) spin_unlock_irqrestore(&(d)->arch.vpl011.lock, flags) + +struct vpl011 { + void *ring_buf; + struct page_info *ring_page; + uint32_t uartfr; /* Flag register */ + uint32_t uartcr; /* Control register */ + uint32_t uartimsc; /* Interrupt mask register*/ + uint32_t uarticr; /* Interrupt clear register */ + uint32_t uartris; /* Raw interrupt status register */ + uint32_t shadow_uartmis; /* shadow masked interrupt register */ + spinlock_t lock; + evtchn_port_t evtchn; +}; + +struct vpl011_init_info { + domid_t console_domid; + gfn_t gfn; + evtchn_port_t evtchn; +}; + +#ifdef CONFIG_SBSA_VUART_CONSOLE +int domain_vpl011_init(struct domain *d, + struct vpl011_init_info *info); +void domain_vpl011_deinit(struct domain *d); +#else +static inline int domain_vpl011_init(struct domain *d, + struct vpl011_init_info *info) +{ + return -ENOSYS; +} + +static inline void domain_vpl011_deinit(struct domain *d) { } +#endif +#endif /* _VPL011_H_ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index bd974fb..85ab665 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -410,6 +410,10 @@ typedef uint64_t xen_callback_t; #define GUEST_ACPI_BASE 0x20000000ULL #define GUEST_ACPI_SIZE 0x02000000ULL +/* PL011 mappings */ +#define GUEST_PL011_BASE 0x22000000ULL +#define GUEST_PL011_SIZE 0x00001000ULL + /* * 16MB == 4096 pages reserved for guest to use as a region to map its * grant table in. @@ -444,6 +448,8 @@ typedef uint64_t xen_callback_t; #define GUEST_TIMER_PHYS_NS_PPI 30 #define GUEST_EVTCHN_PPI 31 +#define GUEST_VPL011_SPI 32 + /* PSCI functions */ #define PSCI_cpu_suspend 0 #define PSCI_cpu_off 1 From patchwork Mon Aug 7 08:52: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: 109519 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481725obb; Mon, 7 Aug 2017 01:55:34 -0700 (PDT) X-Received: by 10.36.93.16 with SMTP id w16mr160075ita.170.1502096134386; Mon, 07 Aug 2017 01:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096134; cv=none; d=google.com; s=arc-20160816; b=maoP21v8+KK5DZYZmPgrydxKuPN2j3WsRu6dC29sVOhK6gZ1JpebX4jvtoN2Pes5wp xjl/mrrPjyQ21Q/pGOJ654tjGmpD+20gOMxjRXTpZdcDltKP3jblsDtbynv0PSQbCsZp KUqzYTeTfT2+plt71go59mlM0L6gn2VB2P2I5NrgE9dNhinukXfebsV8DowEqOsznsLj t1/vZcZGC9mev6It1Z1qi2QnANWkLkjqoIg0sqSjTXpx75chf6Ijeqfg84PHpY3cnzjq kxNwH6Fc9Br4eBnOG2pb0OfOkiaZe1IAv7p3YCE354XpzP6Ag1MlLJLIthVkHq6Li06H 7lLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=d23F1O6qb/I6F+2OFIqAHgS6mjWuJ06gCWICNNt5+jg=; b=IFLgifbVa+VruNPSXus6Sp5EI4jmmJr2Zd9Su3GOePU2XEML/HIttAWYdgUyX+YM7l fQETCwqeFxBV0t4wFaJkoBkWzlGRptJy+/ow5STYFdyCH/lStP3frg6hdeU3wI82OQFx zyNzAcP/eOCg0bkRvTI0P2TgrlqA4fCar4ao+cvkEuuj7m5+9IHp/S1R/Abqbq6g7G3L +MeDpRjT/+aiDQDulwvSqMUD74GOiK8ravQSWiLR23Uk9kzYBFDvONj5UscgUASjkrf5 GJ1m/tXoHFnj4pS1VkzKGayeeyp/yaDK31tnhe0XnSh3VKhaBfB0T4CzmlfP+41LDnCE tMvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=IMF8O629; 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 n62si5015150ioe.148.2017.08.07.01.55.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55: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=IMF8O629; 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 1dednB-0004IS-IL; Mon, 07 Aug 2017 08:53:41 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednA-0004I2-Ur for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:53:41 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id EA/9F-02962-49A28895; Mon, 07 Aug 2017 08:53:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXiVRusoztZqyP S4OdhOYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWP7izPsBa8kK6as2cTcwHhHtIuRi0NIYDqj xLbrP1i6GDk5WATmMUvMna8EkpAQ6GeVmH29hwkkISGQJrF07wk2CLtKouXjbUYQW0hAS+Loq dmsEJPamCT+b5sPNImDg03ARGJWhwRIjYiAksS9VZOZQGqYBeYzSjRN6gUbJCwQIbHs/XMmiM 2qEvePzWIHsXkFvCXOXJrJArFMTuLmuU5mEJtTwEfi/KU3LBCLvSVuH+tjnMAosICRYRWjenF qUVlqka6JXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGYGAxAMEOxu7L/ocYJTmY lER541e0RQrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4E3Q7IgUEixKTU+tSMvMAYY4TFqCg0dJh PeFOlCat7ggMbc4Mx0idYrRmGPSge1fmDheTfj/jUmIJS8/L1VKnPccyCQBkNKM0jy4QbDYu8 QoKyXMywh0mhBPQWpRbmYJqvwrRnEORiVh3jCQKTyZeSVw+14BncIEdMqbxFaQU0oSEVJSDYy 5RZMd7ite7HfekX1Vb9Jz5Wzlmty9b/2ls191heySN65e7mSm+15LvTbVPSn9+Nu8v35NJ7S+ inQ//vOXL8TlgsZzh0cb/sc8050bybg4Oeb4ksgZz+wLl8ist/p3KcNLy41RhbPXQbSTbfp7Z bEVWq5VGWnXZPrfLGjluLzm77Wd5y6v91ViKc5INNRiLipOBACItC4PuAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-27.messagelabs.com!1502096018!110814068!1 X-Originating-IP: [74.125.83.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14007 invoked from network); 7 Aug 2017 08:53:39 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-6.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:53:39 -0000 Received: by mail-pg0-f44.google.com with SMTP id u5so31658935pgn.0 for ; Mon, 07 Aug 2017 01:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l6qPJ2j2XHzH4tm5SO40ctm3ZgjV1/opafjwCKIt+cs=; b=IMF8O629+wVkJk8+rBS5IrYoasBXJs0CGNe9lcDG9evxGp4j2h16kQ2a21+2VBQiPk 1v6A2GIjAN/PtIW6lwgMPp0sgFzafvInqZpqXRDM2NZmcqdNkbFjdzTeeFJzSDDsupzT tvuGcyE2qJ2Ww5f7Vn7jKbGPLhtHRRXYHnVk4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l6qPJ2j2XHzH4tm5SO40ctm3ZgjV1/opafjwCKIt+cs=; b=k32eZfOQvdH007fkZs8VekqrnBYQAGeaUOqMDwLWhW+n6VfckqygLvLEP8jwWAlkyO WQeUrECDESqUiu623Fo2IfavyIk6nRXwFBBCrEdwNumomXtM+mVK3nzMI5RY6SPSnbBl RcMDVwuXp+DZMQeHohliY3fQtdaKZKQELnvjMGcOnt8wCIdHzdnHwwO3AmarwIWTa42z Xsigj2f4fx26cXfnnoUxNxP/DfcYh/woH0MKpf1/hisJeSahhXHGeDkUwGj4EJnRXpxw gKBU7gKqrqw81HkFrqqdTVqlyil5KHHItfofBtcLlmzFGRKHLLoYya9LTp/PyIM4Nr52 dpxw== X-Gm-Message-State: AIVw111bXUGRwd/oEHRiFELV/K2QKNwA7UN3xlF01pNuVoi27t8ycBwz hdmwLwlaxqmpsQohSBZl6Q== X-Received: by 10.99.151.17 with SMTP id n17mr10701590pge.157.1502096016700; Mon, 07 Aug 2017 01:53:36 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:53:36 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:22:55 +0530 Message-Id: <1502095997-31219-4-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 03/25 v7] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Allocate a new gfn to be used as a ring buffer between xenconsole and Xen for sending/receiving pl011 console data. Signed-off-by: Bhupinder Thakur Acked-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Removed xc_get_vuart_gfn() as it is not required since the vpl011 initialization function which used this API has been moved to after gfn is allocated. - I have included the reviewed-by and acked-by tags as there is no change in the logic. Changes since v3: - Added a new helper function xc_get_vuart_gfn() to return the GFN allocated for vpl011. - Since a new function has been added in this patch, I have not included Stefano's reviewed-by and Wei's acked-by tags. Changes since v2: - Removed the DOMCTL call to set the GFN as now this information is passed in the DOMCTL call to initialize vpl011 emulation. tools/libxc/include/xc_dom.h | 2 ++ tools/libxc/xc_dom_arm.c | 5 ++++- tools/libxc/xc_dom_boot.c | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index ce47058..6e06ef1 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -216,6 +216,8 @@ struct xc_dom_image { /* Extra SMBIOS structures passed to HVMLOADER */ struct xc_hvm_firmware_module smbios_module; + + xen_pfn_t vuart_gfn; }; /* --- pluggable kernel loader ------------------------------------- */ diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index e7d4bd0..c981b7a 100644 --- a/tools/libxc/xc_dom_arm.c +++ b/tools/libxc/xc_dom_arm.c @@ -26,10 +26,11 @@ #include "xg_private.h" #include "xc_dom.h" -#define NR_MAGIC_PAGES 3 +#define NR_MAGIC_PAGES 4 #define CONSOLE_PFN_OFFSET 0 #define XENSTORE_PFN_OFFSET 1 #define MEMACCESS_PFN_OFFSET 2 +#define VUART_PFN_OFFSET 3 #define LPAE_SHIFT 9 @@ -85,10 +86,12 @@ static int alloc_magic_pages(struct xc_dom_image *dom) dom->console_pfn = base + CONSOLE_PFN_OFFSET; dom->xenstore_pfn = base + XENSTORE_PFN_OFFSET; + dom->vuart_gfn = base + VUART_PFN_OFFSET; xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_pfn); xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_pfn); xc_clear_domain_page(dom->xch, dom->guest_domid, base + MEMACCESS_PFN_OFFSET); + xc_clear_domain_page(dom->xch, dom->guest_domid, base + VUART_PFN_OFFSET); xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CONSOLE_PFN, dom->console_pfn); xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_STORE_PFN, diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c index c3b44dd..8a376d0 100644 --- a/tools/libxc/xc_dom_boot.c +++ b/tools/libxc/xc_dom_boot.c @@ -226,6 +226,8 @@ int xc_dom_boot_image(struct xc_dom_image *dom) return rc; if ( (rc = clear_page(dom, dom->xenstore_pfn)) != 0 ) return rc; + if ( (rc = clear_page(dom, dom->vuart_gfn)) != 0 ) + return rc; /* start info page */ if ( dom->arch_hooks->start_info ) From patchwork Mon Aug 7 08:52:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109523 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481864obb; Mon, 7 Aug 2017 01:55:44 -0700 (PDT) X-Received: by 10.107.142.211 with SMTP id q202mr11341949iod.100.1502096144152; Mon, 07 Aug 2017 01:55:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096144; cv=none; d=google.com; s=arc-20160816; b=KK5hAdJxBdfuAwUK30GSJuG/rQ38tZGq23RTBaF0qCvq7O5BTTJUWoQZbXwJwEHZH4 63fZoCwVA0dTAoKQWlwvJYWP5jjJ6Qnb8GP7EAE8FMHU+sC5RvbRknVI4jwg9wjkEI6n SlI7sRd6VOM/b8KK18mkWLDA4tyd3kbWCN/P6tbDVg44NX4uFV1xgBZ0qq9EgNEx2slX zD/rW3vDrVuYIYJ1SbQh5mj/vR36vKpdkoFpY+9W0s7shFjHYnim1Bc9AIWa9XlJN8BL r54N/hWkAQnIGMltY1lxw+jyz/wnc3h5VRAScRLA9ctqGsl6aQNUtIClbfkFwF+cSdPf C74g== 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=r0t8+JK0AAtSZJZf7YgUtfJDHbLkTHbEAkvS+EVbudw=; b=jteeQbH3atxSwJAmgK0CAcE9+kb2ngMj46BHyJkoEglVEDGu+8Eip86jVOehd83A0D aRil3ypCkkG1q/k/c0iODhsdjggmthTuszczjbSsXpCsJ1VNa2hSRP1Ui2B5hTl23dTY oAhI+fkAxdV4TjoL/WlvWrQLXN+xXZV2gry27RxQVh/hoe//UVeVjENzvHQsKjhxd68a AQXX9JUOb2pW2LWszgfLaaokYySAGpl+KYGyUPuQSWWKMf61B6chf0PAPKyUMDFIyDib 08ZgfwVPK6MCg206wC01QHJJpqRvIn4jx8OWyfB3guKDPQI5uOe8a+kgAaIuhHFs/l/N Eyag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=c1XgSyk7; 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 83si1504296itb.180.2017.08.07.01.55.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:44 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=c1XgSyk7; 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 1dednK-0004NL-49; Mon, 07 Aug 2017 08:53: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 1dednJ-0004Mg-3A for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:53:49 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 71/D9-02177-C9A28895; Mon, 07 Aug 2017 08:53:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsXiVRtspjtVqyP S4McBWYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePV+j/MBSeNK47Pu8fYwNio2cXIxSEkMJNR onHTWWYQh0VgHrNEz5puNhBHQqCfVWLJ3YssXYycQE6axNG+newQdoVET88zsLiQgJbE0VOzW SFGtTFJnD+5Acjh4GATMJGY1SEBUiMioCRxb9VkJpAaZoH5jBJNk3rZQBLCAp4SD3uugNksAq oSnQ3TwRbwCnhLTPv8jhVimZzEzXOdzCA2p4CPxPlLb6AWe0vcPtbHOIFRYAEjwypG9eLUorL UIl0jvaSizPSMktzEzBxdQwNTvdzU4uLE9NScxKRiveT83E2MwNBiAIIdjN//OB1ilORgUhLl jV/RFinEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgjdBsyNSSLAoNT21Ii0zBxjkMGkJDh4lEd4X6 kBp3uKCxNzizHSI1ClGS44Nq9d/YeKYdGA7kHw14f83JiGWvPy8VClx3hyQeQIgDRmleXDjYJ F4iVFWSpiXEehAIZ6C1KLczBJU+VeM4hyMSsK8k0Cm8GTmlcBtfQV0EBPQQW8SW0EOKklESEk 1MIZP+DDliuqVLz352gFuf+dFPGqJ1OpUdpRYyu77V+RXWNvUvu4PMcqzF59rfiBgrSn/tm3B H64ulvgLVSr7dNdeOFt/80P1vL/vSpd8C+zj5nx87yl7ROTcrenvrncId0c752m7lRWsenZ7+ VF+x9fJRX/1pvB5vP7pd5Bp6jtHt3p+0/UZEkosxRmJhlrMRcWJAIL8lGm/AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-206.messagelabs.com!1502096020!102550544!1 X-Originating-IP: [74.125.83.54] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39974 invoked from network); 7 Aug 2017 08:53:41 -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; 7 Aug 2017 08:53:41 -0000 Received: by mail-pg0-f54.google.com with SMTP id u185so31674123pgb.1 for ; Mon, 07 Aug 2017 01:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WRF4L0RX9AJ0NU5W9nsXFUgxUZEALDK1XU2zcXnoVlg=; b=c1XgSyk7UfTi0+4j4q7zQxc+utn4gXyKaKc4OwuwhLfaLCprUjB1a3lSVpoQl8H5rl rRhRgjO2gjfPZpwu7nEoYQZV8quuy9sAL56raP+kJGs1mLyI7fjtk6d1QZKpoXXAkAIH vshePSMbw+PArKI4hWQlY9bQFRlm9R5rGODhw= 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=WRF4L0RX9AJ0NU5W9nsXFUgxUZEALDK1XU2zcXnoVlg=; b=KINhID3gi+BWygkFHeafz9BBq2HZ8at01FJppMuc4XhBqKX14gpvOHZS9vuHRMnVqe /GqNXi1x1YkRk7WXzqoN1nv9IYYs8lJcuHLSUg0pkRhPbccrwHIZ/zQybT/LrpZfc7Cc NdTfclOw6cISFYto/+vWEV+DA4bycLggRsMUfNOaUz/BBTpycp+46VDmmKsYzJmM9DG3 SDL/qDDTkOj4w0a66Qzg5Tuv32exFSZNk102W2ZurclUwTOZGf1G6jJ9ErzvMsOYtgid qhuiL5jRpqSfDzTyuXbyipAEvm/HN0wzyZ0NwgU0LFydTSrygWnKzRGXvFg/KcpefuRU VOIg== X-Gm-Message-State: AIVw111xRjU72IX7E8yahLGOOQAq44JNaxMH4CLt3GkJsejOrG+Z4U06 Vg4SxgNzDQ5IgWf/hBuIYQ== X-Received: by 10.84.241.3 with SMTP id a3mr13010051pll.160.1502096019657; Mon, 07 Aug 2017 01:53:39 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:53:39 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:22:56 +0530 Message-Id: <1502095997-31219-5-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 04/25 v7] xen/arm: vpl011: Add support for vuart in libxl X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" An option is provided in libxl to enable/disable SBSA vuart while creating a guest domain. Libxl now supports a generic vuart console and SBSA uart is a specific type. In future support can be added for multiple vuart of different types. User can enable SBSA vuart by adding the following line in the guest configuration file: vuart = "sbsa_uart" Signed-off-by: Bhupinder Thakur Acked-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Renamed "pl011" to "sbsa_uart". Changes since v3: - Added a new config option CONFIG_VUART_CONSOLE to enable/disable vuart console support. - Moved libxl_vuart_type to arch-arm part of libxl_domain_build_info - Updated xl command help to mention new console type - vuart. Changes since v2: - Defined vuart option as an enum instead of a string. - Removed the domain creation flag defined for vuart and the related code to pass on the information while domain creation. Now vpl011 is initialized independent of domain creation through new DOMCTL APIs. tools/libxl/libxl.h | 5 +++++ 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, 32 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 229e289..90eaa20 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -306,6 +306,11 @@ #define LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE 1 /* + * LIBXL_HAVE_VUART indicates that the toolstack 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 7247509..6b38453 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1139,6 +1139,9 @@ typedef struct { uint32_t num_vmemranges; xc_domain_configuration_t config; + + xen_pfn_t vuart_gfn; + evtchn_port_t vuart_port; } libxl__domain_build_state; _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid, diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 6e80d36..9959efb 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -105,6 +105,7 @@ libxl_console_type = Enumeration("console_type", [ (0, "UNKNOWN"), (1, "SERIAL"), (2, "PV"), + (3, "VUART"), ]) libxl_disk_format = Enumeration("disk_format", [ @@ -240,6 +241,11 @@ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [ (2, "COLO"), ]) +libxl_vuart_type = Enumeration("vuart_type", [ + (0, "unknown"), + (1, "sbsa_uart"), + ]) + # # Complex libxl types # @@ -581,6 +587,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), + ("vuart", libxl_vuart_type), ])), # Alternate p2m is not bound to any architecture or guest type, as it is # supported by x86 HVM and ARM support is planned. diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 2c71a9f..3094bce 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -133,7 +133,7 @@ struct cmd_spec cmd_table[] = { &main_console, 0, 0, "Attach to domain's console", "[options] \n" - "-t console type, pv or serial\n" + "-t console type, pv , serial or vuart\n" "-n console number" }, { "vncviewer", diff --git a/tools/xl/xl_console.c b/tools/xl/xl_console.c index 0508dda..4e65d73 100644 --- a/tools/xl/xl_console.c +++ b/tools/xl/xl_console.c @@ -27,6 +27,7 @@ int main_console(int argc, char **argv) uint32_t domid; int opt = 0, num = 0; libxl_console_type type = 0; + char *console_names = "pv, serial, vuart"; SWITCH_FOREACH_OPT(opt, "n:t:", NULL, "console", 1) { case 't': @@ -34,8 +35,10 @@ int main_console(int argc, char **argv) type = LIBXL_CONSOLE_TYPE_PV; else if (!strcmp(optarg, "serial")) type = LIBXL_CONSOLE_TYPE_SERIAL; + else if (!strcmp(optarg, "vuart")) + type = LIBXL_CONSOLE_TYPE_VUART; else { - fprintf(stderr, "console type supported are: pv, serial\n"); + fprintf(stderr, "console type supported are: %s\n", console_names); return EXIT_FAILURE; } break; diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 5c2bf17..71588de 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -918,6 +918,14 @@ void parse_config_data(const char *config_source, if (!xlu_cfg_get_long (config, "maxvcpus", &l, 0)) b_info->max_vcpus = l; + if (!xlu_cfg_get_string(config, "vuart", &buf, 0)) { + if (libxl_vuart_type_from_string(buf, &b_info->arch_arm.vuart)) { + fprintf(stderr, "ERROR: invalid value \"%s\" for \"vuart\"\n", + buf); + exit(1); + } + } + parse_vnuma_config(config, b_info); /* Set max_memkb to target_memkb and max_vcpus to avail_vcpus if From patchwork Mon Aug 7 08:52:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109518 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481701obb; Mon, 7 Aug 2017 01:55:32 -0700 (PDT) X-Received: by 10.36.0.77 with SMTP id 74mr150973ita.155.1502096132036; Mon, 07 Aug 2017 01:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096132; cv=none; d=google.com; s=arc-20160816; b=nzXIk3efbdG6oTFonXrzKWVUVl6wUxbk7qzXzyQtm188of5uY4EgfzebBO79/p8FUM V7tdUtR5gvI7/JyPeYZ/1PMDnOyn2D2H45HpaYzf5QDYUrDKk4Iro2g1KDqqzvHz+jIM QeQgyXSohW0XPmAuWkOuAWkl52A2fzGXuToAAuetYyAV59XASSouWRyJKMgr/SwLmnz/ xJT9m/n9D6Xkp3UYA3PsSk+Z6Jkj/xsiqZz171ot+IXyhX92J45ntDshgzob2eUXcN/K 4EGeJep2wbAjvzXM4hE+M+jSkeygpSeHZOJO8oqA72Qn9DX1zd1JZu+Vex/gWSBPYiqT xAaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=mV9Hngypj1Q3cb4StM0ZIyrwNRJbKGcsu6meTYrpf88=; b=uNyS0CcTDmZGwlZZy9DdhfYPrrgJJ/zFdFh500Z+tonSQQWgqGEXpI/Vp1pPPX61hH FEX04J5pq6MUSMgohMVMuAfrqgmOJFXX4AusyDxeK3tZ9cyySYlwZODOirdGU+XWekT7 Aw/o3vDujIOMj4bS7gmydpTZ6GarqeLW/oE2g5+d1CzXb4/4pB9XZZid8FEfpTcD8op2 dssJDHgPpDifDGPbuwN0aFX9+XExMmeQ8tOuq6JmnX28+ony3PgpT6OyFI5qz7RAIfHX 7iMQP96adMFCXFE0OyJztvy5dFa2zB/soK2DqNrFLLgKyukQVfY2zlENoUIKdaTrUXXj /4bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=k3/fdr8g; 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 76si7578630ios.259.2017.08.07.01.55.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55: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=k3/fdr8g; 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 1dednF-0004L9-TC; Mon, 07 Aug 2017 08:53: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 1dednF-0004Kd-2J for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:53:45 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id EB/B7-01862-89A28895; Mon, 07 Aug 2017 08:53:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIIsWRWlGSWpSXmKPExsVyMfTAat3pWh2 RBke3alp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkLdnWzF1xirzh8dBZzA+Ntti5GLg4hgZmM EmtPH2YEcVgE5jFLPFqzmQnEkRDoZ5XYe/4hexcjB5CTJrH1ZF4XIyeQWSnxe0sTE4gtJKAlc fTUbFaISW1MErevPmMBqWcTMJGY1SEBUiMioCRxb9VksHpmgVCJqX8fsIDYwgJZEj0HHjKC2C wCqhJTJm8Eq+EV8JbYOX0BK8QuOYmb5zqZQWxOAR+J85fesEDs9Za4fayPcQKjwAJGhlWMGsW pRWWpRbpGRnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIGBVc/AwLiDceoJv0OM khxMSqK88SvaIoX4kvJTKjMSizPii0pzUosPMcpwcChJ8CZodkQKCRalpqdWpGXmAEMcJi3Bw aMkwvtCHSjNW1yQmFucmQ6ROsVoz3HlyrovTBxNH7YAySkHtgPJVxP+f2MSYsnLz0uVEufNAZ kqANKWUZoHNxQWk5cYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfOGgUzhycwrgdv9CugsJqC z3iS2gpxVkoiQkmpgjFwTNM/xyCIdlpivL2eqTHgl8unYjWYu+7WvE2XLlu0x+ujj/dlu2Qmb loWs3qnMpUIbNLtuN+Xx3LbqMJKye2XGpMxmY6b3q+/l+0StcNesC7XOefJKlXejJ4SZn9kV1 fX123HzvO4ZogdSXObJTc6dtZixiMv18O3jAeE5RWf+Tf3WeEpLiaU4I9FQi7moOBEAwl3ess QCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-31.messagelabs.com!1502096022!53392028!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 19109 invoked from network); 7 Aug 2017 08:53:43 -0000 Received: from mail-pf0-f171.google.com (HELO mail-pf0-f171.google.com) (209.85.192.171) by server-9.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:53:43 -0000 Received: by mail-pf0-f171.google.com with SMTP id c28so30680990pfe.3 for ; Mon, 07 Aug 2017 01:53: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=nFTNxZDC2qp97HE4gxLCge8kPmvOQujiAaRxzy3SoOk=; b=k3/fdr8gt3Ga/RUCki+aeEa5ayk5foZdByoaK01B/dbSk6/5EsGchxTGnZwpFhiH6J 8Qwl61WyPazKJNeup12dRqyhJesBJQ+gPbzHSl6RBxboyimbGPoMBpHmzjjdLCRePM10 IIMIiY7ts63PrdRBKY6NbuXjE6UE4Nhn9rhOA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nFTNxZDC2qp97HE4gxLCge8kPmvOQujiAaRxzy3SoOk=; b=e600vFmHzLLLz53OSiOOsC1tJULEOw1HSZw9j19DLdsFE8Jg7zZfYC/IFMdPNY35Mi wXbAAo/03O0R6Wn8vz21d1LEfnVhKpYSYyTfBgoLrF0Fl41f8K27x1H2Bk9yt2Sd5ZcM MK7ktEG7JB5vV5cijVQU5M18CsYZLG9HyTBA9ApuMQTOkKnxltEUKtQnQBD5dyXN+DKS tC2DV9Mq7FAc6keWYvo69rrrSuH5LH+690Ytl8cZ2mwMWTEMh3GaQWM0fqyc19tUhHfg agY9YyAe+mW9Inh0D6/CbholTXQ8mXXinOuGtatPcQ5/HeRXi29zUgNFjct0+yFYg0le La2Q== X-Gm-Message-State: AIVw110dn0zf6kioRSdhkC5sl4UD7HkXXzc4oMPrYC2PJv+nCHl4RHzn gvAbeBfiqGVP9CSdebk7gA== X-Received: by 10.84.230.132 with SMTP id e4mr13237170plk.36.1502096021984; Mon, 07 Aug 2017 01:53:41 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:53:41 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:22:57 +0530 Message-Id: <1502095997-31219-6-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 05/25 v7] xen/arm: vpl011: Rearrange xen header includes in alphabetical order in domctl.c X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Rearrange xen header includes in alphabetical order in domctl.c. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Reviewed-by: Julien Grall --- CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Corrected include of in alphabetical order. xen/arch/arm/domctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index 971caec..db6838d 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -4,12 +4,12 @@ * Copyright (c) 2012, Citrix Systems */ -#include -#include #include -#include #include #include +#include +#include +#include #include #include From patchwork Mon Aug 7 08:52:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109539 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482151obb; Mon, 7 Aug 2017 01:56:05 -0700 (PDT) X-Received: by 10.107.47.88 with SMTP id j85mr2904880ioo.237.1502096165065; Mon, 07 Aug 2017 01:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096165; cv=none; d=google.com; s=arc-20160816; b=Ib3e43EYKG24MeC2lfgU94X7uJ8K6tzoQAZ+TLCfzeo2IAcdNQ8RB4zUL+UhWFgg72 E1JYJHivUsbBXUpxnqNgRM+EbTeV5Ug7KHA1LwWRzGYI3jdsa5bfn7CfSzQiZK6cCbcE 6V5AvAk8RFPzD7v4jxdy4ToZBgQGGAs/0CjvEmoUrrrKzVVCT6EVpdkd1kkDuBZZ4CdY P55+uwtgHK3Py+L5ivU7a98taA600fdUIu2mqu1JFNDAwWz2CIA8gW+HzuXT8E4q9bWd 0qMZe92k4RFsGwfOllmMr/jxPSrPhPcZ92Bmdy0ruw5R9mnAwFPA7ciE2cCjWTHRioGA hPLA== 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=CPxYznH69fdgOobVlyoqR6a0ot/k4zD3i/t34izLbqA=; b=O7jZzA2zoND4beU40nlEmw6maUG6OWBsdEVJgju/HrZzIwLCLn7ATBFLHLFI67D6OE VuBQdOz8oIJlLmx5khl9gRWgGO2ea4Wwc0o4r+ssCKMpt1WS9ylE3cxaOePP+/xa6kMr 6vtA9U8mgjYD8ZuSyGj5E89F2Ck7B5mti1W9YFi+amKX0/KLdqUswSRL5221KgNzVEpT rCSKFQkm277/TbOCTmwAkhJZS+wsfgr6t82+uTOg6merx40pGg5s/MwISp6FpHYwaTca j+9x6lp+IbgK7mgAiClo29DUDbRbkcDbrBaGLij+BS1BF0Ta3DKnfDsqtiryd7PftL+M hLcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RDbCojoz; 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 n188si7773628itg.74.2017.08.07.01.56.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:56:05 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RDbCojoz; 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 1dednM-0004Of-B2; Mon, 07 Aug 2017 08:53: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 1dednK-0004NB-6h for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:53:50 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id CF/34-02033-D9A28895; Mon, 07 Aug 2017 08:53:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXiVRusrTtHqyP SYPVBVYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP7AamCQ0kVLcdOMTYwdrh1MXJxCAnMZJT4 s/IvG4jDIjCPWaL702pmEEdCoJ9V4nbnXqAMJ5CTJnHnxiZWCLtKYtOKw2BxIQEtiaOnZrNCj Gpjklj3+CJQNwcHm4CJxKwOCZAaEQEliXurJjOB2MwCz5kkpl3SAbGFBUIkFl84CzaHRUBVYt LMt8wgNq+At8SVy1sZIXbJSdw81wkW5xTwkTh/6Q0LxF5vidvH+hgnMAosYGRYxahenFpUllq ka6mXVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKyXnJ+7iREYVgxAsINxbavzIUZJDiYlUd74 FW2RQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4czQ6IoUEi1LTUyvSMnOAAQ6TluDgURLhfaEOl OYtLkjMLc5Mh0idYjTmmHRg+xcmjlcT/n9jEmLJy89LlRLnjQeZJABSmlGaBzcIFnmXGGWlhH kZgU4T4ilILcrNLEGVf8UozsGoJMwrrQk0hSczrwRu3yugU5iATnmT2ApySkkiQkqqgVGPoYd nzt0bPo0W2xhz9k/qLv7qeE92pffn53MTwpODHb6kmQfX6gl8Pj07ILGB+dfdR/MiDPX/7o6b oWN54oWvvkk5B2v5qWNVsdvOv2ANapj+bWPbvvLQnzELhUIePeWfUTbvrK/A3q8PuhoCtJ9VL 2m1KlZyvzb781XXY/MC0pYx2lRFmiixFGckGmoxFxUnAgBKS4TLtwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1502096027!90633190!1 X-Originating-IP: [74.125.83.43] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23066 invoked from network); 7 Aug 2017 08:53:48 -0000 Received: from mail-pg0-f43.google.com (HELO mail-pg0-f43.google.com) (74.125.83.43) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:53:48 -0000 Received: by mail-pg0-f43.google.com with SMTP id y129so31665265pgy.4 for ; Mon, 07 Aug 2017 01:53:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P99lhC/VHf9apWOH12//GRVyn6KxAQYQrwrmuE3DjLA=; b=RDbCojozAv4QpGxtHna50FMAq6hsONb5GHZTMFKo/sDwuAKpn/9orVoZNHl+NIBW0m jtAInxY6Z8a/uYYwcCf8yp92JqB18D/h6t3uF5qcQzZXCvYeh5ez/6fg4t3jW+kbqSc5 tr5GplPnPCTGJEqHasOsIHF67ia0SHYvzZelc= 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=P99lhC/VHf9apWOH12//GRVyn6KxAQYQrwrmuE3DjLA=; b=bvVoi5Tn2K212r0ASzxPBYIX+pFB7+egisjnA7FMPqqnZMWeAefUyYhvgGQCVcBg3h sp28ZAeD1EYj+0jJWI7g97MvfTieAOdryqDmfx3s0zFmQFpPk3ixzJWTMBd+yQiBPyWL vOjl5gPstNOeApwKKyxYDWKx57hXWpgBSHT7ZJ8OwR/YWwFdmids2bhRzAVPVbMb4LOR M21ItZniJb9tVNzPAHttbWPOxVocE8xLit1CGfxYwbQweDHPJg8tEs/5WV4yKpqZwmhO Z3muxNJ+LX78/ADTOe6ftWlvA2zE2LAcms25Lt/IhbvFFGI5dENctX39e+a9HcljKQCR +zXQ== X-Gm-Message-State: AIVw110Je+SOs6fmCqr2LJyL3D5u2IdO4HcSZqB9W/QG52wRX4jM2S28 fzXAvbX2TJ38rsf6DvCoxg== X-Received: by 10.84.234.15 with SMTP id m15mr13460340plk.247.1502096026355; Mon, 07 Aug 2017 01:53:46 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:53:45 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:22:58 +0530 Message-Id: <1502095997-31219-7-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add a new domctl API to initialize vpl011. It takes the GFN and console backend domid as input and returns an event channel to be used for sending and receiving events from Xen. Xen will communicate with xenconsole using GFN as the ring buffer and the event channel to transmit and receive pl011 data on the guest domain's behalf. Signed-off-by: Bhupinder Thakur --- CC: Ian Jackson CC: Wei Liu CC: Andrew Cooper CC: George Dunlap CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Julien Grall Changes since v6: - Renamed the vuart initialization function to a generic name xc_dom_vuart_init - Used domid_t as a type instead of uint32_t for domid - Checking the vuart type explicitly against vpl011 enum value Changes since v5: - xc_dom_vpl011_init() will be compiled for both x86/arm architectures as there is nothing architecture specific in this function. This function will return error when called for x86. - Fixed coding style issues in libxl. Changes since v4: - Removed libxl__arch_domain_create_finish(). - Added a new function libxl__arch_build_dom_finish(), which is called at the last in libxl__build_dom(). This function calls the vpl011 initialization function now. Changes since v3: - Added a new arch specific function libxl__arch_domain_create_finish(), which calls the vpl011 initialization function. For x86 this function does not do anything. - domain_vpl011_init() takes a pointer to a structure which contains all the required information such as console_domid, gfn instead of passing parameters separately. - Dropped a DOMCTL API defined for de-initializing vpl011 as that should be taken care when the domain is destroyed (and not dependent on userspace libraries/applications). Changes since v2: - Replaced the DOMCTL APIs defined for get/set of event channel and GFN with a set of DOMCTL APIs for initializing and de-initializing vpl011 emulation. tools/libxc/include/xenctrl.h | 20 ++++++++++++++++++++ tools/libxc/xc_domain.c | 25 +++++++++++++++++++++++++ tools/libxl/libxl_arch.h | 7 +++++++ tools/libxl/libxl_arm.c | 21 +++++++++++++++++++++ tools/libxl/libxl_dom.c | 4 ++++ tools/libxl/libxl_x86.c | 8 ++++++++ xen/arch/arm/domain.c | 6 ++++++ xen/arch/arm/domctl.c | 42 ++++++++++++++++++++++++++++++++++++++++++ xen/include/public/domctl.h | 21 +++++++++++++++++++++ 9 files changed, 154 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index c7710b8..35bbb3b 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -886,6 +886,26 @@ int xc_vcpu_getcontext(xc_interface *xch, vcpu_guest_context_any_t *ctxt); /** + * This function initializes the vuart emulation and returns + * the event to be used by the backend for communicating with + * the emulation code. + * + * @parm xch a handle to an open hypervisor interface + * #parm type type of vuart + * @parm domid the domain to get information from + * @parm console_domid the domid of the backend console + * @parm gfn the guest pfn to be used as the ring buffer + * @parm evtchn the event channel to be used for events + * @return 0 on success, negative error on failure + */ +int xc_dom_vuart_init(xc_interface *xch, + uint32_t type, + domid_t domid, + domid_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn); + +/** * This function returns information about the XSAVE state of a particular * vcpu of a domain. If extstate->size and extstate->xfeature_mask are 0, * the call is considered a query to retrieve them and the buffer is not diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 3bab4e8..899bbd4 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -343,6 +343,31 @@ int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid, return 0; } +int xc_dom_vuart_init(xc_interface *xch, + uint32_t type, + domid_t domid, + domid_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn) +{ + DECLARE_DOMCTL; + int rc = 0; + + domctl.cmd = XEN_DOMCTL_vuart_op; + domctl.domain = (domid_t)domid; + domctl.u.vuart_op.cmd = XEN_DOMCTL_VUART_OP_INIT; + domctl.u.vuart_op.type = type; + domctl.u.vuart_op.console_domid = console_domid; + domctl.u.vuart_op.gfn = gfn; + + if ( (rc = do_domctl(xch, &domctl)) < 0 ) + return rc; + + *evtchn = domctl.u.vuart_op.evtchn; + + return rc; +} + int xc_domain_getinfo(xc_interface *xch, uint32_t first_domid, unsigned int max_doms, diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h index 5e1fc60..784ec7f 100644 --- a/tools/libxl/libxl_arch.h +++ b/tools/libxl/libxl_arch.h @@ -44,6 +44,13 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, libxl_domain_build_info *info, struct xc_dom_image *dom); +/* perform any pending hardware initialization */ +_hidden +int libxl__arch_build_dom_finish(libxl__gc *gc, + libxl_domain_build_info *info, + struct xc_dom_image *dom, + libxl__domain_build_state *state); + /* build vNUMA vmemrange with arch specific information */ _hidden int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc, diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..a33d3c9 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1038,6 +1038,27 @@ 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 == LIBXL_VUART_TYPE_SBSA_UART) { + ret = xc_dom_vuart_init(CTX->xch, + XEN_DOMCTL_VUART_TYPE_VPL011, + dom->guest_domid, + dom->console_domid, + dom->vuart_gfn, + &state->vuart_port); + if (ret < 0) + LOG(ERROR, "xc_dom_vuart_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..2ff8f43 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -862,6 +862,12 @@ int domain_relinquish_resources(struct domain *d) if ( ret ) return ret; + /* + * Release the resources allocated for vpl011 which were + * allocated via a DOMCTL call XEN_DOMCTL_vuart_op. + */ + domain_vpl011_deinit(d); + d->arch.relmem = RELMEM_xen; /* Fallthrough */ diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index db6838d..c7f650e 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,46 @@ 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 ) + { + if (vuart_op->type == XEN_DOMCTL_VUART_TYPE_VPL011) + { + 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 = -EINVAL; + } + 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 0669c31..be2d874 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -36,6 +36,7 @@ #include "grant_table.h" #include "hvm/save.h" #include "memory.h" +#include "event_channel.h" #define XEN_DOMCTL_INTERFACE_VERSION 0x0000000e @@ -1148,6 +1149,24 @@ struct xen_domctl_psr_cat_op { uint32_t target; /* IN */ uint64_t data; /* IN/OUT */ }; + +struct xen_domctl_vuart_op { +#define XEN_DOMCTL_VUART_OP_INIT 0 + uint32_t cmd; /* XEN_DOMCTL_VUART_OP_* */ + domid_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); @@ -1228,6 +1247,7 @@ struct xen_domctl { #define XEN_DOMCTL_monitor_op 77 #define XEN_DOMCTL_psr_cat_op 78 #define XEN_DOMCTL_soft_reset 79 +#define XEN_DOMCTL_vuart_op 80 #define XEN_DOMCTL_gdbsx_guestmemio 1000 #define XEN_DOMCTL_gdbsx_pausevcpu 1001 #define XEN_DOMCTL_gdbsx_unpausevcpu 1002 @@ -1290,6 +1310,7 @@ struct xen_domctl { struct xen_domctl_psr_cmt_op psr_cmt_op; struct xen_domctl_monitor_op monitor_op; struct xen_domctl_psr_cat_op psr_cat_op; + struct xen_domctl_vuart_op vuart_op; uint8_t pad[128]; } u; }; From patchwork Mon Aug 7 08:52:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109530 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481976obb; Mon, 7 Aug 2017 01:55:52 -0700 (PDT) X-Received: by 10.36.80.10 with SMTP id m10mr173832itb.52.1502096152738; Mon, 07 Aug 2017 01:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096152; cv=none; d=google.com; s=arc-20160816; b=rOS9hNoMm7mumg6JORjgs5HexeEhlvWEIxHFQCu8kt+4ef1pfjG5g/XdsSX9d4smrR K2XlcVyUx5maxrM7d3FTKuiVcgqy0LcwebtziymvxnREE8OSWVLG67pxUfZbtYBIwNAh 1t94j1eJ2xmKJr30nNdaln0AfNkd5anZHtheL9/fDnMWNTs0vMrWGSNl7oAeoPA1owDU grwKnnpsOmRXw/2Bs3zr5cm14C/fY5SlrNJsfh9hmz6gwh+N+wKPOV6X+3GRSJPfHdYn C4s+NlMi32hZN3LkIklbnaDqOIgyqRAWJ2PnosKtEccsXfOwPaA5GJ2srK8fODNUYEd1 AWrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=T1W83F6O6Kc21Vb9shMnui2lDzQnYqH2DbtyX6bjXBg=; b=vCXq6hiJg5FAlit5IKtijGWT+ye+N+JeZFoG9wqef6khizj+D4BBAqO3IgMXUmoehf CscmJL57a+6vB58mmQTVLTdCsRm9CsuHAk4j3EGTsTl2a7rxcy+LC7wSTMUJQ+UUPaww zcs3aSm4N7RXKZq3AQRrTzuKS6tQeUrUbWBAB2K2i7roFpoVBvDmiwLFI/X6McVoLZil L0DdzZzP3IwdeaNsguI+u2L1CfzQofh9C2pPWD9dqmxLV4CgxrpI7O92OyC0bpsn/CH5 KihOyXO6aVQLlKcpM4qm1nBw2K4QBPu4kA8+ZZ/jD1VDaRwZZ1qLsyWijfobSg1bVlrP OaBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LKb5fY9V; 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 m42si6778543iti.29.2017.08.07.01.55.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:52 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LKb5fY9V; 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 1dednN-0004QU-Ls; Mon, 07 Aug 2017 08:53:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednM-0004OS-GU for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:53:52 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id E8/77-03557-F9A28895; Mon, 07 Aug 2017 08:53:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsVyMfTAGt35Wh2 RBg3TWSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxl028yF3RYV9y5N4e9gXGNbhcjF4eQwExG iU87DjKBOCwC85glVm5cCeZICPSzSuy8sp65i5ETyEmTWH/4IjuEXSOx8P9bsLiQgJbE0VOzW SFGtTFJTH+7CijBwcEmYCIxq0MCpEZEQEni3qrJYEOZBeYzSjRN6mUDqREW8JeYcsERpIZFQF Wi++BCJhCbV8Bb4u/P1YwQu+Qkbp7rBNvFKeAjcf7SGxaIvd4St4/1MU5gFFjAyLCKUb04tag stUjXVC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzCwGIBgB+P0y/6HGCU5mJRE eeNXtEUK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuBN0OyIFBIsSk1PrUjLzAGGOExagoNHSYT3h TpQmre4IDG3ODMdInWK0ZLjypV1X5g4phzYDiRfTfj/jUmIJS8/L1VKnDcHZJ4ASENGaR7cOF gcXmKUlRLmZQQ6UIinILUoN7MEVf4VozgHo5Iw7ySQKTyZeSVwW18BHcQEdNCbxFaQg0oSEVJ SDYxL4rZPdfZRK9/ba63u6/buU23exd/95kd8dy3hrVkc7nNp1WX7t4vP7pf//+XQrtB1s09+ 7VnPfq+w8ZamV9lDlmML+E8++eA1u3jpy+9RH5lvVZu7HgqaqySWdm25zdJQL7NpLWXihzcH3 f15Onvzxu0LAid+OL1iodaiKz39t/5aXJDnXM1Rq8RSnJFoqMVcVJwIACMQEnq+AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-21.messagelabs.com!1502096029!68756384!1 X-Originating-IP: [209.85.192.172] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29796 invoked from network); 7 Aug 2017 08:53:50 -0000 Received: from mail-pf0-f172.google.com (HELO mail-pf0-f172.google.com) (209.85.192.172) by server-5.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:53:50 -0000 Received: by mail-pf0-f172.google.com with SMTP id o86so31429291pfj.1 for ; Mon, 07 Aug 2017 01:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u7iNqMhDSt45oYpw7rX/c6FW4ApFInM/Yj9vI6RxQMI=; b=LKb5fY9VAhyr5EzscaFbUOt/wBzz0xGQkk7LnK1xXbzroBSHqo4fBKdBFkMtdMCw4q Ojh6WuJLLNze23APe3rj4mdmxgZR+v5B6GLJ66TB61JW5T56n1u9m9TchkequPxDKanL +wVyfX80W2McmQnTmG0lqxpuMO7LyPRUZMFgs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u7iNqMhDSt45oYpw7rX/c6FW4ApFInM/Yj9vI6RxQMI=; b=Cyiig2/XvMAsiWXsyurCKw3kE7CZSq/nMJJ+/ZP+ADT39n86eQhAjlkDtbq2ahwWJj sCHXWbRxm6dBqh3+BVKsiwdvHxLWMPR2myriGNJqRVBKtF1ZUfJxu0jbP7kFNEL7sqnr EHEWr6rnajAi4ymvlY8jKaqrZ0Irl3CjkQjg/N+aPt5hWv/yxO+QG3DHirQdod6z5MQh k3J0aC0d3BH7t9dKF1VaM0zgyk4fYQtYzLCJPQf+7vVFkEj8UZqaGKyegExb3ozNqgNJ mWt0UhSw+KBkogFOADr54sH9kcNQNktAHpmRR9TGf4sfd/XcBFBvxCZ/2l7RAqaDQd35 3VzA== X-Gm-Message-State: AIVw1121UsvFc84R5t28UCDx4D8EeF9qfNwEym9JqU1jGIgqih6Bp3W8 iqtK35rkEX2fTj/PyJ+Baw== X-Received: by 10.98.208.196 with SMTP id p187mr11232311pfg.320.1502096029061; Mon, 07 Aug 2017 01:53:49 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:53:48 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:22:59 +0530 Message-Id: <1502095997-31219-8-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 07/25 v7] xen/arm: vpl011: Add a new vuart node in the xenstore X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add a new vuart console node to xenstore. This node is added at /local/domain/$DOMID/vuart/0. The node contains information such as the ring-ref, event channel, buffer limit and type of console. Xenconsole reads the node information to setup the ring buffer and event channel for sending/receiving vuart data. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - vuart_device moved inside libxl__device_vuart_add() as a local variable. Changes since v3: - Added a backend node for vpl011. - Removed libxl__device_vuart_add() for HVM guest. It is called only for PV guest. tools/libxl/libxl_console.c | 44 ++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_create.c | 9 +++++++- tools/libxl/libxl_device.c | 9 ++++++-- tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_types_internal.idl | 1 + 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 853be15..cdaf7fd 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -344,6 +344,50 @@ out: return rc; } +int libxl__device_vuart_add(libxl__gc *gc, uint32_t domid, + libxl__device_console *console, + libxl__domain_build_state *state) +{ + libxl__device device; + flexarray_t *ro_front; + flexarray_t *back; + int rc; + + ro_front = flexarray_make(gc, 16, 1); + back = flexarray_make(gc, 16, 1); + + device.backend_devid = console->devid; + device.backend_domid = console->backend_domid; + device.backend_kind = LIBXL__DEVICE_KIND_VUART; + device.devid = console->devid; + device.domid = domid; + device.kind = LIBXL__DEVICE_KIND_VUART; + + flexarray_append(back, "frontend-id"); + flexarray_append(back, GCSPRINTF("%d", domid)); + flexarray_append(back, "online"); + flexarray_append(back, "1"); + flexarray_append(back, "state"); + flexarray_append(back, GCSPRINTF("%d", XenbusStateInitialising)); + flexarray_append(back, "protocol"); + flexarray_append(back, LIBXL_XENCONSOLE_PROTOCOL); + + flexarray_append(ro_front, "port"); + flexarray_append(ro_front, GCSPRINTF("%"PRIu32, state->vuart_port)); + flexarray_append(ro_front, "ring-ref"); + flexarray_append(ro_front, GCSPRINTF("%lu", state->vuart_gfn)); + flexarray_append(ro_front, "limit"); + flexarray_append(ro_front, GCSPRINTF("%d", LIBXL_XENCONSOLE_LIMIT)); + flexarray_append(ro_front, "type"); + flexarray_append(ro_front, "xenconsoled"); + + rc = libxl__device_generic_add(gc, XBT_NULL, &device, + libxl__xs_kvs_of_flexarray(gc, back), + NULL, + libxl__xs_kvs_of_flexarray(gc, ro_front)); + return rc; +} + int libxl__init_console_from_channel(libxl__gc *gc, libxl__device_console *console, int dev_num, diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 1158303..6c3acb3 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1367,7 +1367,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, } case LIBXL_DOMAIN_TYPE_PV: { - libxl__device_console console; + libxl__device_console console, vuart; libxl__device device; for (i = 0; i < d_config->num_vfbs; i++) { @@ -1375,6 +1375,13 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, libxl__device_vkb_add(gc, domid, &d_config->vkbs[i]); } + if (d_config->b_info.arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) { + init_console_info(gc, &vuart, 0); + vuart.backend_domid = state->console_domid; + libxl__device_vuart_add(gc, domid, &vuart, state); + libxl__device_console_dispose(&vuart); + } + init_console_info(gc, &console, 0); console.backend_domid = state->console_domid; libxl__device_console_add(gc, domid, &console, state, &device); diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 00356af..3b10c58 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -26,6 +26,9 @@ static char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device) if (device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0) return GCSPRINTF("%s/console", dom_path); + if (device->kind == LIBXL__DEVICE_KIND_VUART) + return GCSPRINTF("%s/vuart/%d", dom_path, device->devid); + return GCSPRINTF("%s/device/%s/%d", dom_path, libxl__device_kind_to_string(device->kind), device->devid); @@ -170,7 +173,8 @@ retry_transaction: * historically contained other information, such as the * vnc-port, which we don't want the guest fiddling with. */ - if (device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0) + if ((device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0) || + (device->kind == LIBXL__DEVICE_KIND_VUART)) xs_set_permissions(ctx->xsh, t, frontend_path, ro_frontend_perms, ARRAY_SIZE(ro_frontend_perms)); else @@ -800,7 +804,8 @@ void libxl__devices_destroy(libxl__egc *egc, libxl__devices_remove_state *drs) dev->domid = domid; dev->kind = kind; dev->devid = atoi(devs[j]); - if (dev->backend_kind == LIBXL__DEVICE_KIND_CONSOLE) { + if (dev->backend_kind == LIBXL__DEVICE_KIND_CONSOLE || + dev->backend_kind == LIBXL__DEVICE_KIND_VUART) { /* Currently console devices can be destroyed * synchronously by just removing xenstore entries, * this is what libxl__device_destroy does. diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 6b38453..3f7cff9 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1206,6 +1206,9 @@ _hidden int libxl__device_console_add(libxl__gc *gc, uint32_t domid, libxl__device_console *console, libxl__domain_build_state *state, libxl__device *device); +_hidden int libxl__device_vuart_add(libxl__gc *gc, uint32_t domid, + libxl__device_console *console, + libxl__domain_build_state *state); /* Returns 1 if device exists, 0 if not, ERROR_* (<0) on error. */ _hidden int libxl__device_exists(libxl__gc *gc, xs_transaction_t t, diff --git a/tools/libxl/libxl_types_internal.idl b/tools/libxl/libxl_types_internal.idl index 7dc4d0f..c463c33 100644 --- a/tools/libxl/libxl_types_internal.idl +++ b/tools/libxl/libxl_types_internal.idl @@ -26,6 +26,7 @@ libxl__device_kind = Enumeration("device_kind", [ (9, "VUSB"), (10, "QUSB"), (11, "9PFS"), + (12, "VUART"), ]) libxl__console_backend = Enumeration("console_backend", [ From patchwork Mon Aug 7 08:53:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109542 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482223obb; Mon, 7 Aug 2017 01:56:10 -0700 (PDT) X-Received: by 10.36.242.196 with SMTP id j187mr145137ith.57.1502096170279; Mon, 07 Aug 2017 01:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096170; cv=none; d=google.com; s=arc-20160816; b=iWIauMooB/nmGxOgvg65DFKG6hCXP61ihzsHY22EzycnNpLcnIKYBKd8mamrwDXCP3 CM+OAtYwgihtAeQyfuSio5sP8u+t26f2pkC9GSjzZ32Uh54VUECRJNrmtFHUTMUA11aa ZswOGskFVyfQAmcvmKEUr8UNuGvhbpTqKFF21aNnNRKeg4WxoqG+FJ35QIl54j9HstLn ka37C3zufTpkexYBJGQiR5+YbP8bP2DrqKyVknY9qjZ7vsb1re3JIadr7Kpj9Ht2YC/r kNRpekDg/SJv4q0NCZu0dFZ64lXNY+iejxvxsllN3cFDiUSSadYIt0qKT/ecTn5ehtoR cPxw== 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=Tb2i6PEj7miUxc4VgMzjrbl+u+Cf7m5nalvOJbQvNdkUaNTPWDLihfgO+PyXVrLmpB BgpMXVKUQBxxg77XKPB4VDZDb+i1dUE2ZfVsK5KZqE7RO0YPAXfU6fSFvZ4Q+9FzNXo0 WSMhcqdtWWVRyQwftc9gSfPwlXEcsM/gaGeqsQaNbNjF/HvJscTa3G+gOx1UTZ3m+nHd mkJLD6orvIA8LeRXnQW4PcyYVg+0O1mW3/BPHe3tpunLFaD99OFmOJMseu6tDxQBUeUx LpUU5zz+nUOLYAgz0AmbWDB+WuA3eF+p14rP58YUdVjAtoyMSUXCvh0Iohycz3L38GVo Fzaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=aI6v6+WC; 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 l127si8463155iof.104.2017.08.07.01.56.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:56:10 -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=aI6v6+WC; 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 1dednQ-0004Sr-Tg; Mon, 07 Aug 2017 08:53:56 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednP-0004Ry-Q6 for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:53:56 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 98/3B-18997-2AA28895; Mon, 07 Aug 2017 08:53:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRWlGSWpSXmKPExsXiVRusp7tQqyP SoHWijcX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvHn5g2WgkWLGSvOrT7J3MC4pIWxi5GLQ0hg BqPEwWl97CAOi8A8Zombn3cwgTgSAv2sEnNvT2PpYuQEctIkpq7ZzwphV0kc+rqaCcQWEtCSO HpqNivEqDYmif+v7jJ3MXJwsAmYSMzqkACpERFQkri3ajLYUGaB+YwSTZN62UASwkBDv7y9Cz aURUBV4v7bCWA2r4C3xLHzjUwQy+Qkbp7rZAaxOQV8JM5fesMCsdhb4vaxPsYJjAILGBlWMao XpxaVpRbpWuolFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQmFesl5+duYgSGFwMQ7GBc2+p8iFGS g0lJlDd+RVukEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneHI2OSCHBotT01Iq0zBxgoMOkJTh4l ER4X6gDpXmLCxJzizPTIVKnGC05Nqxe/4WJY9KB7UDy1YT/35iEWPLy81KlxHnjQeYJgDRklO bBjYNF4yVGWSlhXkagA4V4ClKLcjNLUOVfMYpzMCoJ80prAk3hycwrgdv6CuggJqCD3iS2ghx UkoiQkmpglP9dHbhL9JVEl8Ds5wWmqgebyn48b+ITmHKmKJWVS/ZM0dFkPc/lM/l7z55xmHCK 1ThJQNBJ+AXvpbqv8x9OWnKyNmai4MWLDTxZDy4uPeC959fUvppJ17qFmPzPr/LZMPPOmaSep jsBvEsmTd4sUb9g/1XNUye23rVKffVpvQB7nb32qSsa/EosxRmJhlrMRcWJAGMQi43BAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-7.tower-206.messagelabs.com!1502096032!103247006!1 X-Originating-IP: [74.125.83.46] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13867 invoked from network); 7 Aug 2017 08:53:53 -0000 Received: from mail-pg0-f46.google.com (HELO mail-pg0-f46.google.com) (74.125.83.46) by server-7.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:53:53 -0000 Received: by mail-pg0-f46.google.com with SMTP id v77so31635653pgb.3 for ; Mon, 07 Aug 2017 01:53:53 -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=aI6v6+WCzs1ubu89/TeYxHbE7L2P92sEzIpnkFeySqOdBVVy54YOYZhu6JwgAQxhBn 0m41WGLHEfAXPlYdi2Y+VKTREn89xZMEb4RxBgVn4jiTIqw9VER3PqPJdqmTZcFmHj6Z 9krThk2MCf48qnipWVKMS6JyKzXH3ErSdWQVs= 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=PDGruo6jjxC+MM2uM/jGaAu8pMGj0Preufaj5pnL2BzmPMXxpeZ0Cgwb84nemqLbON EGL1UtQrOavBjUirVzwajiw96EasVihIOcTJkswOnLDdFbagIKTTFm/5L613BrBFh1Fb mNWpHUiWxEiunIIaVorX8Od7e1VBUOUxpTmpwvsf5FHBEWxAecq4Q22a2951nTPNgb3x G2MIWemvxGv2rAH6CdT0SBxqcvx5jUObENtEBTfGxo6PZGI5p6GtLkntzQTrniNhgjpi 1zTZxGd1xSll8Cpr5hdow0H/bKNT25N+y+vE557o3XiPqG1rwb9xKY3i81Ei5PJhxlYT NYxw== X-Gm-Message-State: AIVw111/uKNS3vp5WdV8i+OrjiaHa8IsfkZr6sR3i1cugzmQhrIa9KMv bIhuIg2KZ6+CPW7wmR01QA== X-Received: by 10.98.204.10 with SMTP id a10mr11457179pfg.332.1502096031913; Mon, 07 Aug 2017 01:53:51 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:53:51 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:00 +0530 Message-Id: <1502095997-31219-9-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 08/25 v7] xen/arm: vpl011: Modify xenconsole to define and use a new console structure X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Xenconsole uses a domain structure which contains console specific fields. This patch defines a new console structure, which would be used by the xenconsole functions to perform console specific operations like reading/writing data from/to the console ring buffer or reading/writing data from/to console tty. This patch is in preparation to support multiple consoles to support vuart console. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Moved the following fields from the struct domain to struct console: ->xenevtchn_handle *xce_handle; ->int xce_pollfd_idx; ->int event_count; ->long long next_period; Changes since v3: - The changes in xenconsole have been split into four patches. This is the first patch which modifies the xenconsole to use a new console structure. Changes since v2: - Defined a new function console_create_ring() which sets up the ring buffer and event channel a new console. domain_create_ring() uses this function to setup a console. - This patch does not contain vuart specific changes, which would be introduced in the next patch. - Changes for keeping the PV log file name unchanged. Changes since v1: - Split the domain struture to a separate console structure - Modified the functions to operate on the console struture - Replaced repetitive per console code with generic code tools/console/daemon/io.c | 299 +++++++++++++++++++++++++--------------------- 1 file changed, 165 insertions(+), 134 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index e8033d2..30cd167 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -89,25 +89,30 @@ struct buffer { size_t max_capacity; }; -struct domain { - int domid; +struct console { int master_fd; int master_pollfd_idx; int slave_fd; int log_fd; - bool is_dead; - unsigned last_seen; struct buffer buffer; - struct domain *next; char *conspath; int ring_ref; - xenevtchn_port_or_error_t local_port; - xenevtchn_port_or_error_t remote_port; xenevtchn_handle *xce_handle; int xce_pollfd_idx; - struct xencons_interface *interface; int event_count; long long next_period; + xenevtchn_port_or_error_t local_port; + xenevtchn_port_or_error_t remote_port; + struct xencons_interface *interface; + struct domain *d; +}; + +struct domain { + int domid; + bool is_dead; + unsigned last_seen; + struct domain *next; + struct console console; }; static struct domain *dom_head; @@ -160,9 +165,10 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, static void buffer_append(struct domain *dom) { - struct buffer *buffer = &dom->buffer; + struct console *con = &dom->console; + struct buffer *buffer = &con->buffer; XENCONS_RING_IDX cons, prod, size; - struct xencons_interface *intf = dom->interface; + struct xencons_interface *intf = con->interface; cons = intf->out_cons; prod = intf->out_prod; @@ -187,22 +193,22 @@ static void buffer_append(struct domain *dom) xen_mb(); intf->out_cons = cons; - xenevtchn_notify(dom->xce_handle, dom->local_port); + xenevtchn_notify(con->xce_handle, con->local_port); /* Get the data to the logfile as early as possible because if * no one is listening on the console pty then it will fill up * and handle_tty_write will stop being called. */ - if (dom->log_fd != -1) { + if (con->log_fd != -1) { int logret; if (log_time_guest) { logret = write_with_timestamp( - dom->log_fd, + con->log_fd, buffer->data + buffer->size - size, size, &log_time_guest_needts); } else { logret = write_all( - dom->log_fd, + con->log_fd, buffer->data + buffer->size - size, size); } @@ -338,14 +344,16 @@ static int create_domain_log(struct domain *dom) static void domain_close_tty(struct domain *dom) { - if (dom->master_fd != -1) { - close(dom->master_fd); - dom->master_fd = -1; + struct console *con = &dom->console; + + if (con->master_fd != -1) { + close(con->master_fd); + con->master_fd = -1; } - if (dom->slave_fd != -1) { - close(dom->slave_fd); - dom->slave_fd = -1; + if (con->slave_fd != -1) { + close(con->slave_fd); + con->slave_fd = -1; } } @@ -418,11 +426,12 @@ static int domain_create_tty(struct domain *dom) char *data; unsigned int len; struct termios term; + struct console *con = &dom->console; - assert(dom->slave_fd == -1); - assert(dom->master_fd == -1); + assert(con->slave_fd == -1); + assert(con->master_fd == -1); - if (openpty(&dom->master_fd, &dom->slave_fd, NULL, NULL, NULL) < 0) { + if (openpty(&con->master_fd, &con->slave_fd, NULL, NULL, NULL) < 0) { err = errno; dolog(LOG_ERR, "Failed to create tty for domain-%d " "(errno = %i, %s)", @@ -430,7 +439,7 @@ static int domain_create_tty(struct domain *dom) return 0; } - if (tcgetattr(dom->slave_fd, &term) < 0) { + if (tcgetattr(con->slave_fd, &term) < 0) { err = errno; dolog(LOG_ERR, "Failed to get tty attributes for domain-%d " "(errno = %i, %s)", @@ -438,7 +447,7 @@ static int domain_create_tty(struct domain *dom) goto out; } cfmakeraw(&term); - if (tcsetattr(dom->slave_fd, TCSANOW, &term) < 0) { + if (tcsetattr(con->slave_fd, TCSANOW, &term) < 0) { err = errno; dolog(LOG_ERR, "Failed to set tty attributes for domain-%d " "(errno = %i, %s)", @@ -446,7 +455,7 @@ static int domain_create_tty(struct domain *dom) goto out; } - if ((slave = ptsname(dom->master_fd)) == NULL) { + if ((slave = ptsname(con->master_fd)) == NULL) { err = errno; dolog(LOG_ERR, "Failed to get slave name for domain-%d " "(errno = %i, %s)", @@ -454,18 +463,18 @@ static int domain_create_tty(struct domain *dom) goto out; } - success = asprintf(&path, "%s/limit", dom->conspath) != + success = asprintf(&path, "%s/limit", con->conspath) != -1; if (!success) goto out; data = xs_read(xs, XBT_NULL, path, &len); if (data) { - dom->buffer.max_capacity = strtoul(data, 0, 0); + con->buffer.max_capacity = strtoul(data, 0, 0); free(data); } free(path); - success = (asprintf(&path, "%s/tty", dom->conspath) != -1); + success = (asprintf(&path, "%s/tty", con->conspath) != -1); if (!success) goto out; success = xs_write(xs, XBT_NULL, path, slave, strlen(slave)); @@ -473,7 +482,7 @@ static int domain_create_tty(struct domain *dom) if (!success) goto out; - if (fcntl(dom->master_fd, F_SETFL, O_NONBLOCK) == -1) + if (fcntl(con->master_fd, F_SETFL, O_NONBLOCK) == -1) goto out; return 1; @@ -519,29 +528,32 @@ static int xs_gather(struct xs_handle *xs, const char *dir, ...) static void domain_unmap_interface(struct domain *dom) { - if (dom->interface == NULL) + struct console *con = &dom->console; + + if (con->interface == NULL) return; - if (xgt_handle && dom->ring_ref == -1) - xengnttab_unmap(xgt_handle, dom->interface, 1); + if (xgt_handle && con->ring_ref == -1) + xengnttab_unmap(xgt_handle, con->interface, 1); else - munmap(dom->interface, XC_PAGE_SIZE); - dom->interface = NULL; - dom->ring_ref = -1; + munmap(con->interface, XC_PAGE_SIZE); + con->interface = NULL; + con->ring_ref = -1; } static int domain_create_ring(struct domain *dom) { int err, remote_port, ring_ref, rc; char *type, path[PATH_MAX]; + struct console *con = &dom->console; - err = xs_gather(xs, dom->conspath, + err = xs_gather(xs, con->conspath, "ring-ref", "%u", &ring_ref, "port", "%i", &remote_port, NULL); if (err) goto out; - snprintf(path, sizeof(path), "%s/type", dom->conspath); + snprintf(path, sizeof(path), "%s/type", con->conspath); type = xs_read(xs, XBT_NULL, path, NULL); if (type && strcmp(type, "xenconsoled") != 0) { free(type); @@ -550,77 +562,77 @@ static int domain_create_ring(struct domain *dom) free(type); /* If using ring_ref and it has changed, remap */ - if (ring_ref != dom->ring_ref && dom->ring_ref != -1) + if (ring_ref != con->ring_ref && con->ring_ref != -1) domain_unmap_interface(dom); - if (!dom->interface && xgt_handle) { + if (!con->interface && xgt_handle) { /* Prefer using grant table */ - dom->interface = xengnttab_map_grant_ref(xgt_handle, + con->interface = xengnttab_map_grant_ref(xgt_handle, dom->domid, GNTTAB_RESERVED_CONSOLE, PROT_READ|PROT_WRITE); - dom->ring_ref = -1; + con->ring_ref = -1; } - if (!dom->interface) { + if (!con->interface) { /* Fall back to xc_map_foreign_range */ - dom->interface = xc_map_foreign_range( + con->interface = xc_map_foreign_range( xc, dom->domid, XC_PAGE_SIZE, PROT_READ|PROT_WRITE, (unsigned long)ring_ref); - if (dom->interface == NULL) { + if (con->interface == NULL) { err = EINVAL; goto out; } - dom->ring_ref = ring_ref; + con->ring_ref = ring_ref; } /* Go no further if port has not changed and we are still bound. */ - if (remote_port == dom->remote_port) { + if (remote_port == con->remote_port) { xc_evtchn_status_t status = { .dom = DOMID_SELF, - .port = dom->local_port }; + .port = con->local_port }; if ((xc_evtchn_status(xc, &status) == 0) && (status.status == EVTCHNSTAT_interdomain)) goto out; } - dom->local_port = -1; - dom->remote_port = -1; - if (dom->xce_handle != NULL) - xenevtchn_close(dom->xce_handle); + con->local_port = -1; + con->remote_port = -1; + if (con->xce_handle != NULL) + xenevtchn_close(con->xce_handle); /* Opening evtchn independently for each console is a bit * wasteful, but that's how the code is structured... */ - dom->xce_handle = xenevtchn_open(NULL, 0); - if (dom->xce_handle == NULL) { + con->xce_handle = xenevtchn_open(NULL, 0); + if (con->xce_handle == NULL) { err = errno; goto out; } - rc = xenevtchn_bind_interdomain(dom->xce_handle, + rc = xenevtchn_bind_interdomain(con->xce_handle, dom->domid, remote_port); if (rc == -1) { err = errno; - xenevtchn_close(dom->xce_handle); - dom->xce_handle = NULL; + xenevtchn_close(con->xce_handle); + con->xce_handle = NULL; goto out; } - dom->local_port = rc; - dom->remote_port = remote_port; + con->local_port = rc; + con->remote_port = remote_port; - if (dom->master_fd == -1) { + if (con->master_fd == -1) { if (!domain_create_tty(dom)) { err = errno; - xenevtchn_close(dom->xce_handle); - dom->xce_handle = NULL; - dom->local_port = -1; - dom->remote_port = -1; + xenevtchn_close(con->xce_handle); + con->xce_handle = NULL; + con->local_port = -1; + con->remote_port = -1; goto out; } } - if (log_guest && (dom->log_fd == -1)) - dom->log_fd = create_domain_log(dom); + if (log_guest && (con->log_fd == -1)) + con->log_fd = create_domain_log(dom); out: return err; @@ -630,16 +642,17 @@ static bool watch_domain(struct domain *dom, bool watch) { char domid_str[3 + MAX_STRLEN(dom->domid)]; bool success; + struct console *con = &dom->console; snprintf(domid_str, sizeof(domid_str), "dom%u", dom->domid); if (watch) { - success = xs_watch(xs, dom->conspath, domid_str); + success = xs_watch(xs, con->conspath, domid_str); if (success) domain_create_ring(dom); else - xs_unwatch(xs, dom->conspath, domid_str); + xs_unwatch(xs, con->conspath, domid_str); } else { - success = xs_unwatch(xs, dom->conspath, domid_str); + success = xs_unwatch(xs, con->conspath, domid_str); } return success; @@ -651,6 +664,7 @@ static struct domain *create_domain(int domid) struct domain *dom; char *s; struct timespec ts; + struct console *con; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d", @@ -667,25 +681,26 @@ static struct domain *create_domain(int domid) dom->domid = domid; - dom->conspath = xs_get_domain_path(xs, dom->domid); - s = realloc(dom->conspath, strlen(dom->conspath) + + con = &dom->console; + con->conspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->conspath, strlen(con->conspath) + strlen("/console") + 1); if (s == NULL) goto out; - dom->conspath = s; - strcat(dom->conspath, "/console"); + con->conspath = s; + strcat(con->conspath, "/console"); - dom->master_fd = -1; - dom->master_pollfd_idx = -1; - dom->slave_fd = -1; - dom->log_fd = -1; - dom->xce_pollfd_idx = -1; + con->master_fd = -1; + con->master_pollfd_idx = -1; + con->slave_fd = -1; + con->log_fd = -1; + con->xce_pollfd_idx = -1; - dom->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; + con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; - dom->ring_ref = -1; - dom->local_port = -1; - dom->remote_port = -1; + con->ring_ref = -1; + con->local_port = -1; + con->remote_port = -1; if (!watch_domain(dom, true)) goto out; @@ -697,7 +712,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(dom->conspath); + free(con->conspath); free(dom); return NULL; } @@ -729,30 +744,34 @@ static void remove_domain(struct domain *dom) static void cleanup_domain(struct domain *d) { + struct console *con = &d->console; + domain_close_tty(d); - if (d->log_fd != -1) { - close(d->log_fd); - d->log_fd = -1; + if (con->log_fd != -1) { + close(con->log_fd); + con->log_fd = -1; } - free(d->buffer.data); - d->buffer.data = NULL; + free(con->buffer.data); + con->buffer.data = NULL; - free(d->conspath); - d->conspath = NULL; + free(con->conspath); + con->conspath = NULL; remove_domain(d); } static void shutdown_domain(struct domain *d) { + struct console *con = &d->console; + d->is_dead = true; watch_domain(d, false); domain_unmap_interface(d); - if (d->xce_handle != NULL) - xenevtchn_close(d->xce_handle); - d->xce_handle = NULL; + if (con->xce_handle != NULL) + xenevtchn_close(con->xce_handle); + con->xce_handle = NULL; } static unsigned enum_pass = 0; @@ -782,7 +801,8 @@ static void enum_domains(void) static int ring_free_bytes(struct domain *dom) { - struct xencons_interface *intf = dom->interface; + struct console *con = &dom->console; + struct xencons_interface *intf = con->interface; XENCONS_RING_IDX cons, prod, space; cons = intf->in_cons; @@ -812,7 +832,8 @@ static void handle_tty_read(struct domain *dom) ssize_t len = 0; char msg[80]; int i; - struct xencons_interface *intf = dom->interface; + struct console *con = &dom->console; + struct xencons_interface *intf = con->interface; XENCONS_RING_IDX prod; if (dom->is_dead) @@ -825,7 +846,7 @@ static void handle_tty_read(struct domain *dom) if (len > sizeof(msg)) len = sizeof(msg); - len = read(dom->master_fd, msg, len); + len = read(con->master_fd, msg, len); /* * Note: on Solaris, len == 0 means the slave closed, and this * is no problem, but Linux can't handle this usefully, so we @@ -841,7 +862,7 @@ static void handle_tty_read(struct domain *dom) } xen_wmb(); intf->in_prod = prod; - xenevtchn_notify(dom->xce_handle, dom->local_port); + xenevtchn_notify(con->xce_handle, con->local_port); } else { domain_close_tty(dom); shutdown_domain(dom); @@ -851,37 +872,39 @@ static void handle_tty_read(struct domain *dom) static void handle_tty_write(struct domain *dom) { ssize_t len; + struct console *con = &dom->console; if (dom->is_dead) return; - len = write(dom->master_fd, dom->buffer.data + dom->buffer.consumed, - dom->buffer.size - dom->buffer.consumed); + len = write(con->master_fd, con->buffer.data + con->buffer.consumed, + con->buffer.size - con->buffer.consumed); if (len < 1) { dolog(LOG_DEBUG, "Write failed on domain %d: %zd, %d\n", dom->domid, len, errno); domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); } else { - buffer_advance(&dom->buffer, len); + buffer_advance(&con->buffer, len); } } static void handle_ring_read(struct domain *dom) { xenevtchn_port_or_error_t port; + struct console *con = &dom->console; if (dom->is_dead) return; - if ((port = xenevtchn_pending(dom->xce_handle)) == -1) + if ((port = xenevtchn_pending(con->xce_handle)) == -1) return; - dom->event_count++; + con->event_count++; buffer_append(dom); - if (dom->event_count < RATE_LIMIT_ALLOWANCE) - (void)xenevtchn_unmask(dom->xce_handle, port); + if (con->event_count < RATE_LIMIT_ALLOWANCE) + (void)xenevtchn_unmask(con->xce_handle, port); } static void handle_xs(void) @@ -948,9 +971,11 @@ static void handle_log_reload(void) if (log_guest) { struct domain *d; for (d = dom_head; d; d = d->next) { - if (d->log_fd != -1) - close(d->log_fd); - d->log_fd = create_domain_log(d); + struct console *con = &d->console; + + if (con->log_fd != -1) + close(con->log_fd); + con->log_fd = create_domain_log(d); } } @@ -1059,48 +1084,52 @@ void handle_io(void) /* Re-calculate any event counter allowances & unblock domains with new allowance */ for (d = dom_head; d; d = d->next) { + struct console *con = &d->console; + /* CS 16257:955ee4fa1345 introduces a 5ms fuzz * for select(), it is not clear poll() has * similar behavior (returning a couple of ms * sooner than requested) as well. Just leave * the fuzz here. Remove it with a separate * patch if necessary */ - if ((now+5) > d->next_period) { - d->next_period = now + RATE_LIMIT_PERIOD; - if (d->event_count >= RATE_LIMIT_ALLOWANCE) { - (void)xenevtchn_unmask(d->xce_handle, d->local_port); + if ((now+5) > con->next_period) { + con->next_period = now + RATE_LIMIT_PERIOD; + if (con->event_count >= RATE_LIMIT_ALLOWANCE) { + (void)xenevtchn_unmask(con->xce_handle, con->local_port); } - d->event_count = 0; + con->event_count = 0; } } for (d = dom_head; d; d = d->next) { - if (d->event_count >= RATE_LIMIT_ALLOWANCE) { + struct console *con = &d->console; + + if (con->event_count >= RATE_LIMIT_ALLOWANCE) { /* Determine if we're going to be the next time slice to expire */ if (!next_timeout || - d->next_period < next_timeout) - next_timeout = d->next_period; - } else if (d->xce_handle != NULL) { + con->next_period < next_timeout) + next_timeout = con->next_period; + } else if (con->xce_handle != NULL) { if (discard_overflowed_data || - !d->buffer.max_capacity || - d->buffer.size < d->buffer.max_capacity) { - int evtchn_fd = xenevtchn_fd(d->xce_handle); - d->xce_pollfd_idx = set_fds(evtchn_fd, + !con->buffer.max_capacity || + con->buffer.size < con->buffer.max_capacity) { + int evtchn_fd = xenevtchn_fd(con->xce_handle); + con->xce_pollfd_idx = set_fds(evtchn_fd, POLLIN|POLLPRI); } } - if (d->master_fd != -1) { + if (con->master_fd != -1) { short events = 0; if (!d->is_dead && ring_free_bytes(d)) events |= POLLIN; - if (!buffer_empty(&d->buffer)) + if (!buffer_empty(&con->buffer)) events |= POLLOUT; if (events) - d->master_pollfd_idx = - set_fds(d->master_fd, + con->master_pollfd_idx = + set_fds(con->master_fd, events|POLLPRI); } } @@ -1163,33 +1192,35 @@ void handle_io(void) } for (d = dom_head; d; d = n) { + struct console *con = &d->console; + n = d->next; - if (d->event_count < RATE_LIMIT_ALLOWANCE) { - if (d->xce_handle != NULL && - d->xce_pollfd_idx != -1 && - !(fds[d->xce_pollfd_idx].revents & + if (con->event_count < RATE_LIMIT_ALLOWANCE) { + if (con->xce_handle != NULL && + con->xce_pollfd_idx != -1 && + !(fds[con->xce_pollfd_idx].revents & ~(POLLIN|POLLOUT|POLLPRI)) && - (fds[d->xce_pollfd_idx].revents & + (fds[con->xce_pollfd_idx].revents & POLLIN)) handle_ring_read(d); } - if (d->master_fd != -1 && d->master_pollfd_idx != -1) { - if (fds[d->master_pollfd_idx].revents & + if (con->master_fd != -1 && con->master_pollfd_idx != -1) { + if (fds[con->master_pollfd_idx].revents & ~(POLLIN|POLLOUT|POLLPRI)) domain_handle_broken_tty(d, domain_is_valid(d->domid)); else { - if (fds[d->master_pollfd_idx].revents & + if (fds[con->master_pollfd_idx].revents & POLLIN) handle_tty_read(d); - if (fds[d->master_pollfd_idx].revents & + if (fds[con->master_pollfd_idx].revents & POLLOUT) handle_tty_write(d); } } - d->xce_pollfd_idx = d->master_pollfd_idx = -1; + con->xce_pollfd_idx = con->master_pollfd_idx = -1; if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Mon Aug 7 08:53:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109529 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481966obb; Mon, 7 Aug 2017 01:55:51 -0700 (PDT) X-Received: by 10.36.228.202 with SMTP id o193mr185343ith.130.1502096151286; Mon, 07 Aug 2017 01:55:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096151; cv=none; d=google.com; s=arc-20160816; b=hyYfEh+vKPB9AVaEUICozSUqG3Cm9KtdtHlqbT6UXYuzDcEBDzjd+UMMr9K4oDPTLZ 3l13X2xCatZfV9yDqTLFQX1U8lMl8rDvAlCO/8kr9XZJ4MtHPHeengqZX4dxlsCLv5HK YSahyl0u0VgffkVwgd7zpVw25cIlQdBEbIsQtut3eKf62KA91tO4wbTKTIUvL9CWDdhD XanK2RsdmxWU1Ayj2widEky3Ls1VorbKmv8LAe0851ZnHeSQg/zAzITrvd7zTnYEI6Ow hj8/gWLAQMk0vpozrSJjsOVlvGYpCf+jd4OTbCkO186mm+XeRGc0c0IFdVpBa2Jpjv0+ qNiw== 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=qSuFX3Y+edOMVpMBKu8yeSv1xefNwLGHFnLhEKJa2KEsbH7IP3FeOgJQ9yU9T7q9IA UEUmktRSCH0AnVSwyKHiwJJpg22pnDZ0qFyTaGf4t3CQF7SAm61KezKAk8pB2pFLAiS0 x3kh9xKj1tlPOrTfHHoWxBUB0Wee0om6M5GUAitM1tuzbH7pHXCeasHFQnGkjc4OlrMK Fn0JOJudAHMSqi83Qk1C2vCZclpMKoYXRvi4rlxfPt4wRvWD8oLxWnoJpWw/L3YDvNi1 k/en/ePLMZnZUDya9BmV3XeALlQ7N5ue8pZVJmb1Hi3uIT/4YLeQ/rQTIIFoRogLQ/Mc peig== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=ZWNsmvUA; 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 g189si7887970ith.181.2017.08.07.01.55.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:51 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=ZWNsmvUA; 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 1dednT-0004VX-8T; Mon, 07 Aug 2017 08:53:59 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednS-0004Tn-57 for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:53:58 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id C9/B0-02962-5AA28895; Mon, 07 Aug 2017 08:53:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsVyMfTAet0lWh2 RBte26Vp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkXXveyF/yVrthw8z9rA+N+8S5GLg4hgZmM EhOWXmUBcVgE5jFLzOn+xwriSAj0s0rc3bkPyOEEctIkXv15zgxhl0k0nfjKBmILCWhJHD01m xViVBuTxPcXU5i6GDk42ARMJGZ1SIDUiAgoSdxbNZkJpIZZYD6jRNOkXrBmYYEEifWLdjKC2C wCqhJnZ7xiArF5BXwkmudOZodYJidx81wn2GJOoPj5S29YIBZ7S9w+1sc4gVFgASPDKkb14tS istQiXRO9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYzA0GIAgh2M3Zf9DzFKcjAp ifLGr2iLFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBm6DZESkkWJSanlqRlpkDDHKYtAQHj5II7 wt1oDRvcUFibnFmOkTqFKMlx5Ur674wcUw5sB1Ivprw/xuTEEtefl6qlDjvOZB5AiANGaV5cO NgkXiJUVZKmJcR6EAhnoLUotzMElT5V4ziHIxKwrxhIFN4MvNK4La+AjqICeigN4mtIAeVJCK kpBoYOwNEjoWymVhPuXGkTDv5Fk/f090ckmb/k0NPp7vzLOricuyLVzL3Yk6cJ/eyNXnvrRs8 0ke+13HpzmKJPvKmz7Wr0U3qcNPZ2Y8DV7HedlhdI+q70+R//JJdKj/cVGZaqzidf/w8omH/y bNvzzw17ZMX/OHK5jjXuanlyFqzQwL/pscL3VZUYinOSDTUYi4qTgQAOfu5Kb8CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-12.tower-21.messagelabs.com!1502096035!76733769!1 X-Originating-IP: [209.85.192.175] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7264 invoked from network); 7 Aug 2017 08:53:56 -0000 Received: from mail-pf0-f175.google.com (HELO mail-pf0-f175.google.com) (209.85.192.175) by server-12.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:53:56 -0000 Received: by mail-pf0-f175.google.com with SMTP id h68so17543492pfk.0 for ; Mon, 07 Aug 2017 01:53:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AGHJrnwneXKl3Z1bjGKh+k5Ixw7YK+0ghFT9u/p0sak=; b=ZWNsmvUAFyJQ58eqvLvwgDIfkmFzFuYdHIO9YTgzKZFsEZnMVDhzVVH+IpSczRR4ki gvXJu4wU3DTG+YoEi3yrTjuK4tRaDJmLmrU4apRpLH19Uow3yM8An4waDXFU9WJDhmNN yN/SKWW8ZnAK0XXdSmjjNBoScj9GaL98f2pTY= 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=rIXOrMJQct2pyc9lASCayU1LWGJkVbMP1HrpKxe6PQ2rnzrH35JXEqYvDcZsbY9USJ 0qDajWI7VzbwvG2W4kCwzI2oL2Ix5BYSGqS/HeIdUNm0QtGt5D1axdYek+kAlhAiiGaR QukyS6jAAIWp+PAu2DMI0TWs3Wxtq2vjQ99sL7S5fUJL4HNt5fLH3ffhMdafcIjMrP/R BqpXZ9Dtgp46AhbHgS9dwNfrN9zqCYVF5Cw39j7KzJEattpaRF3KqwGWoBlHlJrH9Fe7 QfnwuzKyeiP7Uv1K5VgwxuAAdlJxrmzP84vH9+l+1ATk/EucK7M3Yby57zeCwthhu/4b zSXg== X-Gm-Message-State: AIVw110vdhQPgwF/kDBmUnL2PMNokRuNDVR+aDL12X38k+nAfhkT2WbE vSD2QQQVCBA1cVvjcZgneg== X-Received: by 10.98.31.7 with SMTP id f7mr11337916pff.27.1502096034943; Mon, 07 Aug 2017 01:53:54 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:53:54 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:01 +0530 Message-Id: <1502095997-31219-10-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 09/25 v7] xen/arm: vpl011: Rename the console structure field conspath to xspath X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The console->conspath name is changed to console->xspath as it is clear from the name that it is referring to xenstore path. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Split this change in a separate patch. tools/console/daemon/io.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 30cd167..6f5c69c 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -95,7 +95,7 @@ struct console { int slave_fd; int log_fd; struct buffer buffer; - char *conspath; + char *xspath; int ring_ref; xenevtchn_handle *xce_handle; int xce_pollfd_idx; @@ -463,7 +463,7 @@ static int domain_create_tty(struct domain *dom) goto out; } - success = asprintf(&path, "%s/limit", con->conspath) != + success = asprintf(&path, "%s/limit", con->xspath) != -1; if (!success) goto out; @@ -474,7 +474,7 @@ static int domain_create_tty(struct domain *dom) } free(path); - success = (asprintf(&path, "%s/tty", con->conspath) != -1); + success = (asprintf(&path, "%s/tty", con->xspath) != -1); if (!success) goto out; success = xs_write(xs, XBT_NULL, path, slave, strlen(slave)); @@ -546,14 +546,14 @@ static int domain_create_ring(struct domain *dom) char *type, path[PATH_MAX]; struct console *con = &dom->console; - err = xs_gather(xs, con->conspath, + err = xs_gather(xs, con->xspath, "ring-ref", "%u", &ring_ref, "port", "%i", &remote_port, NULL); if (err) goto out; - snprintf(path, sizeof(path), "%s/type", con->conspath); + snprintf(path, sizeof(path), "%s/type", con->xspath); type = xs_read(xs, XBT_NULL, path, NULL); if (type && strcmp(type, "xenconsoled") != 0) { free(type); @@ -646,13 +646,13 @@ static bool watch_domain(struct domain *dom, bool watch) snprintf(domid_str, sizeof(domid_str), "dom%u", dom->domid); if (watch) { - success = xs_watch(xs, con->conspath, domid_str); + success = xs_watch(xs, con->xspath, domid_str); if (success) domain_create_ring(dom); else - xs_unwatch(xs, con->conspath, domid_str); + xs_unwatch(xs, con->xspath, domid_str); } else { - success = xs_unwatch(xs, con->conspath, domid_str); + success = xs_unwatch(xs, con->xspath, domid_str); } return success; @@ -682,13 +682,13 @@ static struct domain *create_domain(int domid) dom->domid = domid; con = &dom->console; - con->conspath = xs_get_domain_path(xs, dom->domid); - s = realloc(con->conspath, strlen(con->conspath) + + con->xspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->xspath, strlen(con->xspath) + strlen("/console") + 1); if (s == NULL) goto out; - con->conspath = s; - strcat(con->conspath, "/console"); + con->xspath = s; + strcat(con->xspath, "/console"); con->master_fd = -1; con->master_pollfd_idx = -1; @@ -712,7 +712,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->conspath); + free(con->xspath); free(dom); return NULL; } @@ -756,8 +756,8 @@ static void cleanup_domain(struct domain *d) free(con->buffer.data); con->buffer.data = NULL; - free(con->conspath); - con->conspath = NULL; + free(con->xspath); + con->xspath = NULL; remove_domain(d); } From patchwork Mon Aug 7 08:53:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109540 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482164obb; Mon, 7 Aug 2017 01:56:06 -0700 (PDT) X-Received: by 10.107.20.215 with SMTP id 206mr11159276iou.163.1502096166027; Mon, 07 Aug 2017 01:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096166; cv=none; d=google.com; s=arc-20160816; b=f1JWd8C7jA7Tj2UFMbtRWCvFEh0TBQmE04eqkXxgAS5zLUCFuIRsav6dIWywCCFZLE YwX2TahOCtJqeAE0sBJSkZlzOk+JkAURdqObVAM/im1flIU/oUsI0385Y81+2Bqn1tNz WLW+VymKsN4oXd/5bwHunrM3K1TKXVg+FpTtQEjdi28BBu8IthQCAeDWGat/X3UXdQKv XtP0oD76hUrSD6DRWRKARNQQNis4T7IJ2LjOxIuDU7qtrpkN2uzkIDt1DCd7C68FkN9q VR9v5QnJCPCZPmbXyoGv1fkoIhcaL9udefuS07uy04v3d/akGxV+fVILWaF6d7OZFMea AInQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=WXsVKFtSEvooh/gQViJFmbABTRKBe0u52bhIWXyD934=; b=Nr5Y9aLYSXWTgYB0/DeJ3BvoqWysdcFefoxPlSIcKSWfuY4n9uAud2gwdT/AD18KQq V4enXhrK18GS6PRW9cYlqrEbKRd99+ijkThyqFlz6Si9eWDdEzsN1OdKCect4MXxJ5du l8RGkIpUtX5kgOqAUl11hZXMrzhcPFPcoZ8oGfNA2X9tkXgu92sV/pN9b/RfmLVVqbMF qdN3ue9c6+00PqTSXD0prIzLWNuIX67cDNNKgh2kX+K1Jfoh5RpZuVdEwN5iXGA4so7y zTsrjTo5qz+RLsGFcXqHSwb0r6zjIXnLPzO4fuDUWzubp5CGo27ky7gmDGDRP1atPjiy 3UsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KICTwXQv; 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 71si8197016itf.139.2017.08.07.01.56.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:56:06 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KICTwXQv; 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 1dednW-0004Yq-FZ; Mon, 07 Aug 2017 08:54:02 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednV-0004XE-Df for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:01 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id DC/C4-01862-8AA28895; Mon, 07 Aug 2017 08:54:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRusp7tcqyP S4Od2bYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNaPhxFnmgreeFV2HdjA2MP616WLk4hASmM4o cbfnHAuIwyIwj1niwL/JYI6EQD+rxLTbLYxdjJxATprEmafH2SHsSok5y2+C2UICWhJHT81mh RjVxiSxrfUTcxcjBwebgInErA4JkBoRASWJe6smM4HUMAvMZ5RomtTLBpIQFsiU2Hj3BQuIzS KgKvF/xx8wm1fAR+LN0U4WiGVyEjfPdTKD2JxA8fOX3rBALPaWuH2sj3ECo8ACRoZVjBrFqUV lqUW6RgZ6SUWZ6RkluYmZObqGBsZ6uanFxYnpqTmJScV6yfm5mxiBwVXPwMC4g7H5hN8hRkkO JiVR3vgVbZFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHgTNDsihQSLUtNTK9Iyc4BhDpOW4OBRE uF9oQ6U5i0uSMwtzkyHSJ1iNOaYdGD7FyaOVxP+f2MSYsnLz0uVEufNAZkkAFKaUZoHNwgWf5 cYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfNOApnCk5lXArfvFdApTECnvElsBTmlJBEhJdX AqKJ1/b7I/7fX9FZ5H9GsEFu+VDx+/ZTlL7Tz9+b8EGNdXH3lmq9LubZCwe7J098zLOY+FTq7 qTN+DcNSRW7ppeJrX8qZHZFIy7Z5/T7NokwwQvgi8+7Henelbvicn7y1ITN2Z+Zh09WMlz9bl Ed1u/CuuC0d62mmuytg8qmyjL/HtjqzHeS7rsRSnJFoqMVcVJwIAF0YggK6AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-31.messagelabs.com!1502096038!108865269!1 X-Originating-IP: [74.125.83.46] 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 29532 invoked from network); 7 Aug 2017 08:53:59 -0000 Received: from mail-pg0-f46.google.com (HELO mail-pg0-f46.google.com) (74.125.83.46) by server-3.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:53:59 -0000 Received: by mail-pg0-f46.google.com with SMTP id u5so31662233pgn.0 for ; Mon, 07 Aug 2017 01:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/c87JD9XyWkvHP2iWascyeQ5IUSzbfWQc11J8Ir9N+k=; b=KICTwXQvDR5clzqioWd2gnJw5YModWElm+Fpjhe3DaULDVqw1zbDVRP6478lDsKrRg AZuOQMn92rZaTjV8xV/KsqGvKHOWZphOtnPOml1GGkPjCyFKNyZNM3hniaxLw/JQrgh3 YLdeAlSR+/Wy/8gK7bW5IZgNMyypLoY27RMXE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/c87JD9XyWkvHP2iWascyeQ5IUSzbfWQc11J8Ir9N+k=; b=oy4kx2f06EgAAKlE955x0+MjduhktaC1pIL2jdgZEBHWY7j7SPk5MKJiUKvrLXR5fX rZGSaKgeLF6dnfI3T/aglq37yWa162yZLmM4VxdNiwvuuNx8wgFe8Q33kbjAn2vb6tUd u/iK04yeAUW++9BpSRBo1I5WV/AbfIlnfayr5oHBYElL10uCmXVidRt1YGaDjCOf4M8O 9w9CcDLph/7nAVBfVq0h/doO39PTqM1cP/57bOH9jyTARzajT+dADlzaq91qV/Q0raGc VXDK24RQhPzN/hhgSKzkzZFHUZbGbY0J/VaM6/0aSHS+3knYvW7mSUIpQbkWH775/egs iaMw== X-Gm-Message-State: AIVw112DCowa6it1jkD03FeiWM1w8wk0TQaY1UG9IZ8lrDImOlAdZJw+ wYFg8Gpi+xejiT75+GMR+A== X-Received: by 10.99.42.72 with SMTP id q69mr10895353pgq.449.1502096037782; Mon, 07 Aug 2017 01:53:57 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:53:57 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:02 +0530 Message-Id: <1502095997-31219-11-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 10/25 v7] xen/arm: vpl011: Modify xenconsole functions to take console structure as input X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Xenconsole functions take domain structure as input. These functions shall be modified to take console structure as input since these functions typically perform console specific operations. Also the console specific functions starting with prefix "domain_" shall be modified to "console_" to indicate that these are console specific functions. This patch is in preparation to support multiple consoles to support vuart console. Signed-off-by: Bhupinder Thakur Acked-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v3: - The changes in xenconsole have been split into multiple patches. This is the second patch. tools/console/daemon/io.c | 79 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 6f5c69c..a2a3496 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -163,10 +163,10 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } -static void buffer_append(struct domain *dom) +static void buffer_append(struct console *con) { - struct console *con = &dom->console; struct buffer *buffer = &con->buffer; + struct domain *dom = con->d; XENCONS_RING_IDX cons, prod, size; struct xencons_interface *intf = con->interface; @@ -296,12 +296,13 @@ static int create_hv_log(void) return fd; } -static int create_domain_log(struct domain *dom) +static int create_console_log(struct console *con) { char logfile[PATH_MAX]; char *namepath, *data, *s; int fd; unsigned int len; + struct domain *dom = con->d; namepath = xs_get_domain_path(xs, dom->domid); s = realloc(namepath, strlen(namepath) + 6); @@ -342,10 +343,8 @@ static int create_domain_log(struct domain *dom) return fd; } -static void domain_close_tty(struct domain *dom) +static void console_close_tty(struct console *con) { - struct console *con = &dom->console; - if (con->master_fd != -1) { close(con->master_fd); con->master_fd = -1; @@ -417,7 +416,7 @@ void cfmakeraw(struct termios *termios_p) } #endif /* __sun__ */ -static int domain_create_tty(struct domain *dom) +static int console_create_tty(struct console *con) { const char *slave; char *path; @@ -426,7 +425,7 @@ static int domain_create_tty(struct domain *dom) char *data; unsigned int len; struct termios term; - struct console *con = &dom->console; + struct domain *dom = con->d; assert(con->slave_fd == -1); assert(con->master_fd == -1); @@ -487,7 +486,7 @@ static int domain_create_tty(struct domain *dom) return 1; out: - domain_close_tty(dom); + console_close_tty(con); return 0; } @@ -526,10 +525,8 @@ static int xs_gather(struct xs_handle *xs, const char *dir, ...) return ret; } -static void domain_unmap_interface(struct domain *dom) +static void console_unmap_interface(struct console *con) { - struct console *con = &dom->console; - if (con->interface == NULL) return; if (xgt_handle && con->ring_ref == -1) @@ -540,11 +537,11 @@ static void domain_unmap_interface(struct domain *dom) con->ring_ref = -1; } -static int domain_create_ring(struct domain *dom) +static int console_create_ring(struct console *con) { int err, remote_port, ring_ref, rc; char *type, path[PATH_MAX]; - struct console *con = &dom->console; + struct domain *dom = con->d; err = xs_gather(xs, con->xspath, "ring-ref", "%u", &ring_ref, @@ -563,7 +560,7 @@ static int domain_create_ring(struct domain *dom) /* If using ring_ref and it has changed, remap */ if (ring_ref != con->ring_ref && con->ring_ref != -1) - domain_unmap_interface(dom); + console_unmap_interface(con); if (!con->interface && xgt_handle) { /* Prefer using grant table */ @@ -621,7 +618,7 @@ static int domain_create_ring(struct domain *dom) con->remote_port = remote_port; if (con->master_fd == -1) { - if (!domain_create_tty(dom)) { + if (!console_create_tty(con)) { err = errno; xenevtchn_close(con->xce_handle); con->xce_handle = NULL; @@ -632,7 +629,7 @@ static int domain_create_ring(struct domain *dom) } if (log_guest && (con->log_fd == -1)) - con->log_fd = create_domain_log(dom); + con->log_fd = create_console_log(con); out: return err; @@ -648,7 +645,7 @@ static bool watch_domain(struct domain *dom, bool watch) if (watch) { success = xs_watch(xs, con->xspath, domid_str); if (success) - domain_create_ring(dom); + console_create_ring(con); else xs_unwatch(xs, con->xspath, domid_str); } else { @@ -695,6 +692,7 @@ static struct domain *create_domain(int domid) con->slave_fd = -1; con->log_fd = -1; con->xce_pollfd_idx = -1; + con->d = dom; con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; @@ -746,7 +744,7 @@ static void cleanup_domain(struct domain *d) { struct console *con = &d->console; - domain_close_tty(d); + console_close_tty(con); if (con->log_fd != -1) { close(con->log_fd); @@ -768,7 +766,7 @@ static void shutdown_domain(struct domain *d) d->is_dead = true; watch_domain(d, false); - domain_unmap_interface(d); + console_unmap_interface(con); if (con->xce_handle != NULL) xenevtchn_close(con->xce_handle); con->xce_handle = NULL; @@ -799,9 +797,8 @@ static void enum_domains(void) } } -static int ring_free_bytes(struct domain *dom) +static int ring_free_bytes(struct console *con) { - struct console *con = &dom->console; struct xencons_interface *intf = con->interface; XENCONS_RING_IDX cons, prod, space; @@ -816,30 +813,30 @@ static int ring_free_bytes(struct domain *dom) return (sizeof(intf->in) - space); } -static void domain_handle_broken_tty(struct domain *dom, int recreate) +static void console_handle_broken_tty(struct console *con, int recreate) { - domain_close_tty(dom); + console_close_tty(con); if (recreate) { - domain_create_tty(dom); + console_create_tty(con); } else { - shutdown_domain(dom); + shutdown_domain(con->d); } } -static void handle_tty_read(struct domain *dom) +static void handle_tty_read(struct console *con) { ssize_t len = 0; char msg[80]; int i; - struct console *con = &dom->console; struct xencons_interface *intf = con->interface; + struct domain *dom = con->d; XENCONS_RING_IDX prod; if (dom->is_dead) return; - len = ring_free_bytes(dom); + len = ring_free_bytes(con); if (len == 0) return; @@ -853,7 +850,7 @@ static void handle_tty_read(struct domain *dom) * keep the slave open for the duration. */ if (len < 0) { - domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); + console_handle_broken_tty(con, domain_is_valid(dom->domid)); } else if (domain_is_valid(dom->domid)) { prod = intf->in_prod; for (i = 0; i < len; i++) { @@ -864,15 +861,15 @@ static void handle_tty_read(struct domain *dom) intf->in_prod = prod; xenevtchn_notify(con->xce_handle, con->local_port); } else { - domain_close_tty(dom); + console_close_tty(con); shutdown_domain(dom); } } -static void handle_tty_write(struct domain *dom) +static void handle_tty_write(struct console *con) { ssize_t len; - struct console *con = &dom->console; + struct domain *dom = con->d; if (dom->is_dead) return; @@ -882,7 +879,7 @@ static void handle_tty_write(struct domain *dom) if (len < 1) { dolog(LOG_DEBUG, "Write failed on domain %d: %zd, %d\n", dom->domid, len, errno); - domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); + console_handle_broken_tty(con, domain_is_valid(dom->domid)); } else { buffer_advance(&con->buffer, len); } @@ -901,7 +898,7 @@ static void handle_ring_read(struct domain *dom) con->event_count++; - buffer_append(dom); + buffer_append(con); if (con->event_count < RATE_LIMIT_ALLOWANCE) (void)xenevtchn_unmask(con->xce_handle, port); @@ -925,7 +922,7 @@ static void handle_xs(void) /* We may get watches firing for domains that have recently been removed, so dom may be NULL here. */ if (dom && dom->is_dead == false) - domain_create_ring(dom); + console_create_ring(&dom->console); } free(vec); @@ -975,7 +972,7 @@ static void handle_log_reload(void) if (con->log_fd != -1) close(con->log_fd); - con->log_fd = create_domain_log(d); + con->log_fd = create_console_log(con); } } @@ -1121,7 +1118,7 @@ void handle_io(void) if (con->master_fd != -1) { short events = 0; - if (!d->is_dead && ring_free_bytes(d)) + if (!d->is_dead && ring_free_bytes(con)) events |= POLLIN; if (!buffer_empty(&con->buffer)) @@ -1208,15 +1205,15 @@ void handle_io(void) if (con->master_fd != -1 && con->master_pollfd_idx != -1) { if (fds[con->master_pollfd_idx].revents & ~(POLLIN|POLLOUT|POLLPRI)) - domain_handle_broken_tty(d, + console_handle_broken_tty(con, domain_is_valid(d->domid)); else { if (fds[con->master_pollfd_idx].revents & POLLIN) - handle_tty_read(d); + handle_tty_read(con); if (fds[con->master_pollfd_idx].revents & POLLOUT) - handle_tty_write(d); + handle_tty_write(con); } } From patchwork Mon Aug 7 08:53:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109533 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482043obb; Mon, 7 Aug 2017 01:55:57 -0700 (PDT) X-Received: by 10.36.246.5 with SMTP id u5mr199042ith.82.1502096157521; Mon, 07 Aug 2017 01:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096157; cv=none; d=google.com; s=arc-20160816; b=R8DVY0T1HRFkAYgFq70ILimjytUy0FrewLi48dmRK5dz+Nc6m+DUX1yZdHNL0DNghq hy30safzyA52gE+zv6GjFzIjmxHe5x85qBxI+Wp7EM+eNZteiwog2efxgZg9u1wbAxJ0 tHoOBhTOPny36v9rEHnRxhztEwhXXn3qZ3NT7bGbBFjnD1MUwT873XYNTkds/3VsYU+E cdZhoL8ZmR7XA6JCfxplIDKeToIIqL3vnimu7Hkn7cwangRNiqBEdnQUxIezi+HHQLnE Id/sgKiY2qzT74ToYqv+O1tDCVyufRZn0Al2sAe5hb58NA7z1C/nEdwIR0Nu1hWPunld K2Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=+uFY/pVc8SURBInWhEretAHlX4Js5xxDKWVSHnOsbQU=; b=gQNX6xsb2B82446iTOw2NZ8uilMhJNg7s24f0SSdzr/40bnTrngrsru+FsX1GxMZpg cX01hbCZbYfdXoT6gMcaGTSw+htokwsQ5YIqK6GcEmS+8+utI/K92zTAoVq/AKTxLEbW 7mRio94HeNBQezUHoINqORmxdC2D+cS6MWO8BCvc3cjrv/0n8MGTczbT//GV+Ah6IrcS bqvSuORkBCePvgLjIlDdJNP0YB70xjTi2cbTyhdsoCUSyA83wvpkjpy8KL1kiiiOcvfL p19UqjW9EP7/Qvi2Tgt3adokL1Qdll2l8r674hYoMpZDCwv7wAHodLWuxLVJbQQdmrVB 9LGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=VBWOIu3R; 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 e41si7732711ioj.242.2017.08.07.01.55.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:57 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=VBWOIu3R; 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 1dednZ-0004bo-Mn; Mon, 07 Aug 2017 08:54:05 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednX-0004a0-S9 for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:03 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id E6/00-03582-BAA28895; Mon, 07 Aug 2017 08:54:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLIsWRWlGSWpSXmKPExsVyMfTABt1VWh2 RBl231Cy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyH19YzFTSIV+xYu56tgXGacBcjF4eQwExG iW9TephAHBaBecwSZ54dBXMkBPpZJTpazgI5nEBOmsS6P6/YIewqiYPbb7KA2EICWhJHT81mh RjVxiRxYf1PIIeDg03ARGJWhwRIjYiAksS9VZPBhjILzGeUaJrUywaSEBaIkFjSOw9sAYuAqs TZ/nesIDavgI/EzK9rWSCWyUncPNfJDGJzAsXPX3oDtdhb4vaxPsYJjAILGBlWMWoUpxaVpRb pGhnpJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEBhcDEOxgXDM/8BCjJAeTkihv /Iq2SCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvAmaHZFCgkWp6akVaZk5wDCHSUtw8CiJ8L5QB 0rzFhck5hZnpkOkTjFacly5su4LE8eUA9uB5KsJ/78xCbHk5eelSonz5oDMEwBpyCjNgxsHi8 VLjLJSwryMQAcK8RSkFuVmlqDKv2IU52BUEuadBDKFJzOvBG7rK6CDmIAOepPYCnJQSSJCSgo Y3X9Tpt6KleTxYPNedmHnin+R5mtn6q2IeV4ornz8++Fu8+VsB3dvfq8VyvMhN8Iyv0iGpzZc RPxCuSN3kM9V3jlTLedN4aw/Fn2koG230L59Ov62kYznK6tTZxXF24qdffq++45krdcbZlFPk eSgotUTvY3WXD3yI/W4ZM25+CtrnW4GinQosRRnJBpqMRcVJwIAi6MkZ8ACAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-4.tower-27.messagelabs.com!1502096041!109840954!1 X-Originating-IP: [209.85.192.176] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41796 invoked from network); 7 Aug 2017 08:54:02 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-4.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:02 -0000 Received: by mail-pf0-f176.google.com with SMTP id o86so31431064pfj.1 for ; Mon, 07 Aug 2017 01:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CK3WW8RxUoVEpZ5UMzdRikYESdsFXDtL/nQkFOdJcGQ=; b=VBWOIu3RT6fe8WFaMiPll+qbLxVCHpC3ft+EM1Q6bqJx7s8BZHwktW5xmudQjgcz4Z 3aHg3TJJFt9LL4f+PVUuL1jNxgWtqzIoc4MY1IkOzpPVd1R1JYWjwNR6CGLlcXBnJ1Qr bb6s61IZ3L1koHLjB/gai0jimfjtZYdkigMwo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CK3WW8RxUoVEpZ5UMzdRikYESdsFXDtL/nQkFOdJcGQ=; b=Xdta8Zdqkwf3xIGOLs5ItizYMv8XWB4swHieN5oXv4gVi58YIEyGCjuZZU8+QQdwmc NTAo2Of+jhlV6KGhF2HOxXY9bP9zmM538d+xp3+oHFLOT2eBmWOqE+464OweT7uN1eqJ h3xQ7iqL+zcmv6ozOcFTqViBNzjqpfbQZ25h6hZkkzbNiUiTWZ43iSrP4pCNHRKTWRMK MMF85Xc9LEx6OkFzLLZowk3fywz2esM/XFidABfuhcZ5BB5QwUyZWFYp4/Smg/GYryuF 7Zw2Wy6dLU73n750TgwLeMh6XFpPUmfBiJ4oKsgevHkmmlBjF5Ud/fpmhXrttzt3UPOH WjHQ== X-Gm-Message-State: AIVw111vLBKxpCsmucXKuH6q2z0WO/LJCqQCjbh9aaA7gx6x5CwZLeWQ itD7Fqr9i/l+/CC59ZJL7A== X-Received: by 10.99.181.29 with SMTP id y29mr10825393pge.135.1502096040742; Mon, 07 Aug 2017 01:54:00 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:00 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:03 +0530 Message-Id: <1502095997-31219-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/25 v7] xen/arm: vpl011: Add a new console_init function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a new console_init function. This function initializes the console structure. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 65 ++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a2a3496..1da08d7 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -655,20 +655,51 @@ static bool watch_domain(struct domain *dom, bool watch) return success; } - -static struct domain *create_domain(int domid) +static int console_init(struct console *con, struct domain *dom) { - struct domain *dom; char *s; + int err = -1; struct timespec ts; - struct console *con; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d", __FILE__, __FUNCTION__, __LINE__); - return NULL; + return err; } + con->master_fd = -1; + con->master_pollfd_idx = -1; + con->slave_fd = -1; + con->log_fd = -1; + con->ring_ref = -1; + con->local_port = -1; + con->remote_port = -1; + con->xce_pollfd_idx = -1; + con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; + con->d = dom; + con->xspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->xspath, strlen(con->xspath) + + strlen("/console") + 1); + if (s) { + con->xspath = s; + strcat(con->xspath, "/console"); + err = 0; + } + + return err; +} + +static void console_free(struct console *con) +{ + if (con->xspath) + free(con->xspath); +} + +static struct domain *create_domain(int domid) +{ + struct domain *dom; + struct console *con; + dom = calloc(1, sizeof *dom); if (dom == NULL) { dolog(LOG_ERR, "Out of memory %s:%s():L%d", @@ -677,28 +708,10 @@ static struct domain *create_domain(int domid) } dom->domid = domid; - con = &dom->console; - con->xspath = xs_get_domain_path(xs, dom->domid); - s = realloc(con->xspath, strlen(con->xspath) + - strlen("/console") + 1); - if (s == NULL) - goto out; - con->xspath = s; - strcat(con->xspath, "/console"); - - con->master_fd = -1; - con->master_pollfd_idx = -1; - con->slave_fd = -1; - con->log_fd = -1; - con->xce_pollfd_idx = -1; - con->d = dom; - - con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; - con->ring_ref = -1; - con->local_port = -1; - con->remote_port = -1; + if (console_init(con, dom)) + goto out; if (!watch_domain(dom, true)) goto out; @@ -710,7 +723,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->xspath); + console_free(con); free(dom); return NULL; } From patchwork Mon Aug 7 08:53:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109531 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482017obb; Mon, 7 Aug 2017 01:55:56 -0700 (PDT) X-Received: by 10.107.172.1 with SMTP id v1mr5806985ioe.126.1502096156086; Mon, 07 Aug 2017 01:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096156; cv=none; d=google.com; s=arc-20160816; b=vPzM0JN+q5FL5MKAdifE4lWN00msuK6bnKDt93mPuLdW5o2oy4zveFFrtNaeFfa9aC yLsPF/r3KNm66lXAAiGjpA0GDZaMsxsOKFKpD+pEyYRjcAVN0QhfHR2hPdf5qnZHx33d LTrNSZpgPNEiUPk/+t3w1ge/7Ez3m0vRV0+4GzaJECthmSZlH2x8T2y764rtHS+0QVt4 WVwYts+uOBoEqnbRwL2O/10DcGy0F3VpkqOX0+xY4xmw0hhD4OUE4mMzC96pJ01MFwAF 1tD3lWymQ2h0QPnCHCsbygkC4n4oDzEvdL5TMAaw3QObKMwdWW+nBf6BAuPuTP/sNSPg bhUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=RBIonTcOwRkHLeFjaA/5ZTqVDWSkdEy4IXZH98gtXnM=; b=gGKmjvGPte/o6PocXYbnXDYmdZ1xSxQ824R0lhHKWKJHcZ6g+DfM8bTgenk+VjRMZW EDP1rqxcCeh+MeiOQbt1bURYoDhOR9fgNlvCnrffQXivORn7Au6mVjuWM4LDf/dUb10O 31uJBEzCDQpY/W+sCS/tSZUWUq02VljcnhcL8telkvl2W5plAcHaTybTAVsboADA5oip eefAro+ZTOK4QCO4aBdV/BTaesW4oQFG1+NhW90KyIeKtqE9HM0O/hXvSi4CRqnUkA0m MHP8KJR1z9EytUiF4CQXEKUpZmiDesgXIvdo8PzySnGpi5NGivSRHZBRKxugJsWRmzek Vvjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=gGhW/U6E; 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 l21si7818389ioi.369.2017.08.07.01.55.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:56 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=gGhW/U6E; 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 1dednb-0004e5-U8; Mon, 07 Aug 2017 08:54:07 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedna-0004cg-QC for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:06 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id D9/FD-27137-EAA28895; Mon, 07 Aug 2017 08:54:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXiVRtspLtWqyP S4NI9IYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPv5bvMBd94Ki4+X8/WwPiQq4uRi0NIYDqj xOb+BSwgDovAPGaJY+/us4M4EgL9rBIf591i7GLkBHLSJI5duMAEYVdI/L59HywuJKAlcfTUb FaIUW1MEk+/dgF1c3CwCZhIzOqQAKkREVCSuLdqMhNIDbPAfEaJpkm9bCAJYYEYiR8nLrKB1L MIqEq0flUECfMK+EisnHOIGWKXnMTNc51gNidQ/PylNywQe70lbh/rY5zAKLCAkWEVo3pxalF ZapGuqV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmBgMQDBDsbpl/0PMUpyMCmJ 8savaIsU4kvKT6nMSCzOiC8qzUktPsQow8GhJMH7WbMjUkiwKDU9tSItMwcY4jBpCQ4eJRHeF +pAad7igsTc4sx0iNQpRmOOSQe2f2HieDXh/zcmIZa8/LxUKXHecyCTBEBKM0rz4AbBYu8So6 yUMC8j0GlCPAWpRbmZJajyrxjFORiVhHnPg0zhycwrgdv3CugUJqBT3iS2gpxSkoiQkmpg3KF VUPmylaH/dptTz/bcJUuc5p9b+y3fuMboVOEFJn7d9/tFJm6ubfd8VneQaVtK2vvCecnhB+el bZi9cR3HBoYQRu5TmlfLmCclzuFZPN/dReaMDovl0WwpH2+JfDtxlmPn59Rvz12VNdtl872mo /Yz3a+1nuU+u/SNs6sTg9iC7dO+pOf5KLEUZyQaajEXFScCAFSd93K4AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-27.messagelabs.com!1502096044!57774556!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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23824 invoked from network); 7 Aug 2017 08:54:05 -0000 Received: from mail-pg0-f50.google.com (HELO mail-pg0-f50.google.com) (74.125.83.50) by server-15.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:05 -0000 Received: by mail-pg0-f50.google.com with SMTP id u5so31663226pgn.0 for ; Mon, 07 Aug 2017 01:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yB+nxIvgk8UjZRr/CwimK1H7zFddzpCzBRq7KGA1phI=; b=gGhW/U6EeLvZ0ym58RYyB1lPeSbhPo28noGy0QUsKiQJs80Wrzw+haKrNNTbNdjJhE nNA0zKc+Iu3OcqiSFC/rz6E7kq+9f1kR3xjrJBMZX+YRMVLwaSfu0NvqFpcPfZ96jf1q siZp70Tcuj4/k+i37LSBCiivWbsxKuCp9anQc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yB+nxIvgk8UjZRr/CwimK1H7zFddzpCzBRq7KGA1phI=; b=J90mvSxjzd/CgXy3biPY+ZOkGT35cfHVXeREb9MeRkEyhbAUhPZXn6ATsMBERCmWX2 ato9420LJ9Z2Lqqu4JSCCzYa7OBogl+j1uq5We/vOvlrvauYsYiMJaCVnwwwV/kmoa29 9Ak4Q42Na+AuS97H6jfVo/iu+0kEI3Ljpb6J4WGqT0AWtpI/z8GMLW1D/ktta6Qi4uhF JWQ91XYbs7qiYYjpPkZGQ6c+mJ+Ee6jeKK7BI0Dpw8GYRYgiQsDqHa17udN1Po3DAtLV C9lWwBCmbwyG9X+jurWMrF3/S4cWHq9/zCHtTLm7DbV9cbSXkuNOTg2RsspI1g9fXDk9 2mGw== X-Gm-Message-State: AIVw112QZ7RUVaLlZp7cNvZSQJYG2rqm4M3kXPGYd5Tgh1f0fyUqEGcG D9e8ufNGaxpzgtoOFL1Qvw== X-Received: by 10.84.241.70 with SMTP id u6mr12969748plm.96.1502096043621; Mon, 07 Aug 2017 01:54:03 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:03 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:04 +0530 Message-Id: <1502095997-31219-13-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 12/25 v7] xen/arm: vpl011: Add a new buffer_available function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a new buffer_available function to check if more data is allowed to be buffered. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 1da08d7..0009bbe 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -163,6 +163,16 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } +static inline bool buffer_available(struct console *con) +{ + if (discard_overflowed_data || + !con->buffer.max_capacity || + con->buffer.size < con->buffer.max_capacity) + return true; + else + return false; +} + static void buffer_append(struct console *con) { struct buffer *buffer = &con->buffer; @@ -1120,9 +1130,7 @@ void handle_io(void) con->next_period < next_timeout) next_timeout = con->next_period; } else if (con->xce_handle != NULL) { - if (discard_overflowed_data || - !con->buffer.max_capacity || - con->buffer.size < con->buffer.max_capacity) { + if (buffer_available(con)) { int evtchn_fd = xenevtchn_fd(con->xce_handle); con->xce_pollfd_idx = set_fds(evtchn_fd, POLLIN|POLLPRI); From patchwork Mon Aug 7 08:53:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109532 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482032obb; Mon, 7 Aug 2017 01:55:56 -0700 (PDT) X-Received: by 10.36.94.15 with SMTP id h15mr146344itb.71.1502096156570; Mon, 07 Aug 2017 01:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096156; cv=none; d=google.com; s=arc-20160816; b=sDBtskMGMKzNgCHR0e2T2C4aLLquIUIbofberVeFlk427Z78AJvXJChvLfTF+QPgOR eadDpf4WMfVHlHFz5REzemBjEQvXMq0zJEtYbUI8pg8/F5O1OMEC5gbZl1jYaMpi9mXF b8IUrqo60m6CKp6zsCKhzLTPmgQNjNq3rWMTcYojHiC9ahumbroNDXYe2FnnIlfTcYVT mkAOOQaOuLeFsViXw8RZioaxYXoUQtp4xg11TyQyTEHqe6EqHLYHeO3gGYtSheIHpYOZ suByXWBXiAgJ+gJGlYJdclOqzb38LvRsH5bKWDbwc7yYclkxWnAkLJWkS8Y7NKpPAOyZ 6WGg== 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=5z9Ztp0OKuAOgvcCHhoZoPcLJXRoZ+2uvx1F0USE4xw=; b=C81AhURWyzNfSwaM8pFF5MCzt7qgbygqAYcGfm/S5U1x5ndxUlX7FmHD9KL0fnPRjJ noOCPvgQx+6YPxWPr7vz4C/fxJuxLGes6a6gfemAhBl5rXZA0q//R6upTrhUmmVnTIfm aJmbKiv+aPe2a+a8KynbJdf0HvcBdIYPQMsJyRxj15c6XKPu1D9cKtY0PFFgjx4D96Gw bZMG02wszJI882L/RfmdWo3+bNFWOtEJkgY75jwNXCwabY+Uxz398kPojga2wGach6lx qXliHF9L5IQCzRrakRjPQc1HYbptFLjboIcE0MEc/sTQE4oNuuHDvRBTqQzA591+NkTd Gocw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=aLwSAhmk; 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 m193si7580116iom.33.2017.08.07.01.55.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:56 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=aLwSAhmk; 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 1dedne-0004h6-8l; Mon, 07 Aug 2017 08:54:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednd-0004cg-9C for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:09 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id F8/2E-27137-1BA28895; Mon, 07 Aug 2017 08:54:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRusq7tBqyP S4MxCCYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWP72lWsBT1CFa+/3GJpYHzN18XIxSEkMINR 4s3nZ+wgDovAPGaJ++eWgzkSAv2sEqsnd7F0MXICOWkSx6+1s0LY5RLTlpxmBLGFBLQkjp6az Qoxqo1J4tiDPUAOBwebgInErA4JkBoRASWJe6smM4HUMAvMZ5RomtTLBpIQFkiXuLtkJxOIzS KgKjHhWTcziM0r4CNxumUrI8QyOYmb5zrB4pxA8fOX3rBALPaWuH2sj3ECo8ACRoZVjBrFqUV lqUW6xkZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBwcUABDsYT68LPMQoycGk JMobv6ItUogvKT+lMiOxOCO+qDQntfgQowwHh5IEb4JmR6SQYFFqempFWmYOMMxh0hIcPEoiv C/UgdK8xQWJucWZ6RCpU4zGHJMObP/CxPFqwv9vTEIsefl5qVLivDkgkwRASjNK8+AGweLvEq OslDAvI9BpQjwFqUW5mSWo8q8YxTkYlYR5pUGm8GTmlcDtewV0ChPQKW8SW0FOKUlESEk1MJY ZlldyX98bKV5VmJ++sHf2B7H2FazdmXfDr795e7mjm+lB0/Qrki8PFzVHRoS7VAR4mEhuFft8 5sC++09UO068XXp9WVdQ0qTFtYyfqk3/Lq9raZ0qcM//y8ajDPX6k960+FxR2etlz7GyNkrg6 t21qVbcj9g+ysvsOu0ZsLVgf2FOU6J4ixJLcUaioRZzUXEiACPAXO+6AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-27.messagelabs.com!1502096047!57774562!1 X-Originating-IP: [74.125.83.45] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24183 invoked from network); 7 Aug 2017 08:54:08 -0000 Received: from mail-pg0-f45.google.com (HELO mail-pg0-f45.google.com) (74.125.83.45) by server-15.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:08 -0000 Received: by mail-pg0-f45.google.com with SMTP id v77so31638035pgb.3 for ; Mon, 07 Aug 2017 01:54:08 -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=kIvT37WxW74x5LZwxVmzvwX5NhdHwJ/aVM8On5pSpLI=; b=aLwSAhmk62nQdOFQ950UN2j6ZV/HRWOtgNlpasrYJefrfchsE1TAnigcahfXWMf7WG 7XT9U7+AkRGmhoYexjWZYAM7KUBZuZm3IFCfglJvlz+QVnTekV5ivp1SyuFCYfxr9VIq ab/JBdniSxDzRYiSG4/6dxqRtXVFVbCj6beGA= 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=kIvT37WxW74x5LZwxVmzvwX5NhdHwJ/aVM8On5pSpLI=; b=ueN+wz8JOyEu0rEZ0iJzOEmyFe7UnmRxM29Ce7ErOFAyNOdww7x6Tz6zzPgXhxw71l CyTTnLiFHH7BSxbY7HIqW228ggw9j1WnaJ1X0FRYYXZs1cXg5Vw3Wx6yJ33veD+oJs4M HB/A8RaZpdExg88GOHd2LFqy+E61IuajUBH7RdBBjBpOYmdiGZngc/xNwVNXQv12oG36 L+hPxbfFwSnJY3cwaxxJ4CftzqBVVIr6e4X6qghEGqbOvkKwJuJLoSOWJLkZ2j4nQfAp 0yfQIitxi3Goqzdu2xUQ79MCNVSkuBb6YZNs2oM2cN/c3mCKmAq4fr/NWa7pTphC8JxE C+jQ== X-Gm-Message-State: AIVw113X7sLn+yimlflz/sIjLTZ2CHtGHTfhYmOah52DkRo71PiG5Y/K wFlZ/KHo7nrVJmu+OmzasQ== X-Received: by 10.84.138.3 with SMTP id 3mr13498090plo.272.1502096046803; Mon, 07 Aug 2017 01:54:06 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:06 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:05 +0530 Message-Id: <1502095997-31219-14-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 13/25 v7] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a new maybe_add_console_evtchn_fd function. This function adds the console event channel FD to list of polled FDs. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v6: - Renamed add_console_evtchn_fd to maybe_add_console_evtchn_fd since it adds the FD to the poll list conditionally. Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 0009bbe..3483252 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1047,6 +1047,26 @@ static void reset_fds(void) memset(fds, 0, sizeof(struct pollfd) * current_array_size); } +static void maybe_add_console_evtchn_fd(struct console *con, void *data) +{ + long long next_timeout = *((long long *)data); + + if (con->event_count >= RATE_LIMIT_ALLOWANCE) { + /* Determine if we're going to be the next time slice to expire */ + if (!next_timeout || + con->next_period < next_timeout) + next_timeout = con->next_period; + } else if (con->xce_handle != NULL) { + if (buffer_available(con)) { + int evtchn_fd = xenevtchn_fd(con->xce_handle); + con->xce_pollfd_idx = set_fds(evtchn_fd, + POLLIN|POLLPRI); + } + } + + *((long long *)data) = next_timeout; +} + void handle_io(void) { int ret; @@ -1124,18 +1144,7 @@ void handle_io(void) for (d = dom_head; d; d = d->next) { struct console *con = &d->console; - if (con->event_count >= RATE_LIMIT_ALLOWANCE) { - /* Determine if we're going to be the next time slice to expire */ - if (!next_timeout || - con->next_period < next_timeout) - next_timeout = con->next_period; - } else if (con->xce_handle != NULL) { - if (buffer_available(con)) { - int evtchn_fd = xenevtchn_fd(con->xce_handle); - con->xce_pollfd_idx = set_fds(evtchn_fd, - POLLIN|POLLPRI); - } - } + maybe_add_console_evtchn_fd(con, (void *)&next_timeout); if (con->master_fd != -1) { short events = 0; From patchwork Mon Aug 7 08:53:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109543 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482232obb; Mon, 7 Aug 2017 01:56:10 -0700 (PDT) X-Received: by 10.36.142.131 with SMTP id h125mr172947ite.7.1502096170802; Mon, 07 Aug 2017 01:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096170; cv=none; d=google.com; s=arc-20160816; b=Ke5+PgHhjI6E9LB6GqtCbvxJjNNmy8DDKzLoozbGP5bWZtEwNOs3VUOhvLhD8UwgZS NvwaDufsr3b7dMTQeMso/LJYxseR24JUb3VoFJlLbW3BtofJSrIedY+JjDY1Mz+cxuca af0mDxBw9+OwgEAtbxMQNAHUsxtPaqfRuZ9He8XTznju1gzCbNkKK24rn1YlhTiBzHWh MocqTvPfZBAM7uy8VBJVG0rLjlpJpbuGrIjfMA+idctSZw0eQ3YQwO/3jp3yeCl7rVfg KeOBQdDBZTn8otNPsrHLyrtfH/i/XzmFpnGc1ckU3J9Y2dWsSg+i4HjmI91IbRzoycJX KZAA== 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=4HmeNHSctFtvf+CVS0U2qVgUjTt688zOnJbR8kHkIhU=; b=H6zPpvuw7Wx8QTrrfOnInwPoxGuRR+O2e3op8IQVv3x2HRNezO9UgEGQhYVkPKVW0M WfKajrAhLbzklQD/KPAdB6YfK4+i0sdyEdGF0ZpsnC9Gccbtk6BptR3VwS8WkIED041c fjS6prk3I/STv4AFrg0jCSibOG7dctFc/wBCBxeQMJyrI85H4kAtutUHCIm4gVTpNOm7 8s61mqtVtpck+XplynZDqgWNhoF6np0PqA8fS1CKZhYCohmoqk/ABL3p1Dgnqrj+xKiV jg0HZ6Gfvmo++S5syjJ1YPzyGbOqHWMailvBmpp0JBkHGt74BvsBvlizdqvZR/Ak2atv vqww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=LUd5rWKn; 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 x124si8181721iod.149.2017.08.07.01.56.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:56:10 -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=LUd5rWKn; 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 1dedni-0004m4-Fz; Mon, 07 Aug 2017 08:54:14 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedng-0004ja-Uq for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:13 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id A8/34-02176-3BA28895; Mon, 07 Aug 2017 08:54:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRuso7tZqyP S4NwWaYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPDww2MBXf4K3ZOPcfSwNjO28XIxSEkMJNR YuWt3UwgDovAPGaJxxdusYM4EgL9rBIb329m7GLkBHLSJHa+P88EYVdKTLr1BMwWEtCSOHpqN ivEqDYmiQkbFwElODjYBEwkZnVIgNSICChJ3Fs1GWwDs8B8RommSb1sIAlhgRSJBa8XsIPYLA KqEicnfWQFsXkFfCRuNkxkh1gmJ3HzXCcziM0JFD9/6Q0LxGJvidvH+hgnMAosYGRYxahRnFp Ullqka2Sml1SUmZ5RkpuYmaNraGCsl5taXJyYnpqTmFSsl5yfu4kRGFz1DAyMOxgb9vodYpTk YFIS5Y1f0RYpxJeUn1KZkVicEV9UmpNafIhRhoNDSYI3QbMjUkiwKDU9tSItMwcY5jBpCQ4eJ RHeF+pAad7igsTc4sx0iNQpRmOOSQe2f2HieDXh/zcmIZa8/LxUKXHeHJBJAiClGaV5cINg8X eJUVZKmJeRgYFBiKcgtSg3swRV/hWjOAejkjDvJJApPJl5JXD7XgGdwgR0ypvEVpBTShIRUlI NjD2rmYLVnrL9vO3KqJLAf/8496bWVbdf32Plv9tdv/XbJ28xEbYls78vfmrezbtK+Iae1Fb5 Ip3ZVz8d0FrxzVh2SmKUu7MHy1NWKUPef4rVBh2z79xcOoEhKYVzy6yYdcVtU4qPL6sN+Ttt7 vQ/dpcmlT0ouf6hsVXz33OeGq8pYVNYdfeaHFNiKc5INNRiLipOBAAKcjUvugIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-31.messagelabs.com!1502096050!108710543!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 32456 invoked from network); 7 Aug 2017 08:54:11 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-14.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:11 -0000 Received: by mail-pg0-f44.google.com with SMTP id y129so31668983pgy.4 for ; Mon, 07 Aug 2017 01:54:11 -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=mYozS+nQ1yf9epDA8ZcGc8wJCUO5kNWx++UC3Kttf7g=; b=LUd5rWKnbgymAoIDBt73vYDqDna92q4WoczCvdMGN28IrcU84+sFGvsgSArLz3AF8G zZrtc04s8PPxaVXvKKIjmHm5DppyO26znDeicI+oStzjihAqGHlHprtAuH7+8qE+S5MZ 4E+rEkNnNyWTuk0LczWHZC2LJSjNZMCgHZshg= 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=mYozS+nQ1yf9epDA8ZcGc8wJCUO5kNWx++UC3Kttf7g=; b=tQxxWmq0mLgECaxon37yMqX1YelskpEwLDgm7QfMzgiztupKXF4T3urZCa34/C6juC aDSTBZ6xUAbARpBfVMPWEStL5YsyE869xFmOI1RqYQjl2vjexYy12mIB8IzLPSt0CXil IRevyrFBCi3jWw5qPpm6K84x80Q01LwhrxXmU3TC97PaH0qvMoS4Gz5j9GsUxtUzrbRu XGpw+1MsRojfGLRr7ZnwAL+6qrALbwXNuHj79G0h9RYK9ljKwp8KoMuVE9yqUTWGT76j OFOHREr2G3QZCj8nFXd76sdqveAnMxw0Z+WPgr0K7wTwmApD8/n4Ghl4zVS8WSS5boxx kJuw== X-Gm-Message-State: AIVw111BN7FIXEy1Ts0CgZzPa3sgFX6rmMYHLCT6oS7/uQfzImb0T6Vo p1v92DCiY4rBnpMyRB8mxw== X-Received: by 10.84.130.108 with SMTP id 99mr12864756plc.76.1502096049772; Mon, 07 Aug 2017 01:54:09 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:09 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:06 +0530 Message-Id: <1502095997-31219-15-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 14/25 v7] xen/arm: vpl011: Add a new maybe_add_console_tty_fd function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a new maybe_add_console_tty_fd function. This function adds the tty fd to the list of polled fds. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v6: - Renamed add_console_tty_fd to maybe_add_console_tty_fd since it adds the tty FD to the poll list conditionally. - I have retained the reviewed-by tag as only the function name has been changed. Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 3483252..a0b35da 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1067,6 +1067,22 @@ static void maybe_add_console_evtchn_fd(struct console *con, void *data) *((long long *)data) = next_timeout; } +static void maybe_add_console_tty_fd(struct console *con) +{ + if (con->master_fd != -1) { + short events = 0; + if (!con->d->is_dead && ring_free_bytes(con)) + events |= POLLIN; + + if (!buffer_empty(&con->buffer)) + events |= POLLOUT; + + if (events) + con->master_pollfd_idx = + set_fds(con->master_fd, events|POLLPRI); + } +} + void handle_io(void) { int ret; @@ -1146,19 +1162,7 @@ void handle_io(void) maybe_add_console_evtchn_fd(con, (void *)&next_timeout); - if (con->master_fd != -1) { - short events = 0; - if (!d->is_dead && ring_free_bytes(con)) - events |= POLLIN; - - if (!buffer_empty(&con->buffer)) - events |= POLLOUT; - - if (events) - con->master_pollfd_idx = - set_fds(con->master_fd, - events|POLLPRI); - } + maybe_add_console_tty_fd(con); } /* If any domain has been rate limited, we need to work From patchwork Mon Aug 7 08:53:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109521 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481791obb; Mon, 7 Aug 2017 01:55:39 -0700 (PDT) X-Received: by 10.36.173.91 with SMTP id a27mr162505itj.130.1502096139421; Mon, 07 Aug 2017 01:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096139; cv=none; d=google.com; s=arc-20160816; b=Z4GggjjHKccGVY+b9stTL58YKqGW4mEZFqrpTNixnTDlljQPIRtGj9aZPSIjYvEowj REfE380WXWJO5kDBRlWkzGlbilHyZhOXkYuEzA/xVj+EYM3Mqb9lwIIH4AHWh6iNwpIk dSo2hRbx9EMN9nO15S1oU72/XMoWbzCC7gt/Vm3mXri8H+rgNmAaBofypRgihRseX0Uc 2o+bkYGqAS0XAgkszjbLp9GUqaQspDjUbyaIISlsw8Hb3iGncletoR4yOCKxasKlrr6S WfTP54SES8XQeLVjtu4acF7MPD75zdaS6Qx3rWvAzH24kejOX+2vAd/s6WG8vzfYgpZW DZDQ== 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=D5+2goXUtH/2O/ZiCc3q8lfrUcyZJNg5eC8EdxaPfsU=; b=Xx+YhjykuG7GHCJuILvDPYuPtsU2j3p3JP6RYs5oWuEs4D6ypzHmp93cDb6Cqfv5z0 8qi4ognCw2tu40sJN3kjvKcEK0GD0k6gueGSJdJWGtd5Bb/siW+Naf3FiMW7WPUiurJC 3Kz6eOLMgjLmgNnWKp+dvTlb+I9Ohx2VPqf+reoh9Da9ZkPqn54lnND9s7tpphnjHKwx nP12eOCLdfo2VG3glYcWuJAUU5NIh2RclKbVK95z/AayLN1REflOhd2u4jJ6ysAee6xD lbPVXMjorkoM96aFi0G6AjySE2rSbh2/jYReF+c5lgG5Yn7DSe6cetfhHXxtyYi2tTpZ bnLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=WcQeAqY9; 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 e126si8478638itg.33.2017.08.07.01.55.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55: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=WcQeAqY9; 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 1dednl-0004qN-NU; Mon, 07 Aug 2017 08:54:17 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednj-0004nR-O0 for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:15 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id A3/58-03612-7BA28895; Mon, 07 Aug 2017 08:54:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsVyMfTAWt1tWh2 RBg2L5C2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ox9+5pZC/6LV/Te2cfawHhfuIuRi0NIYCaj xKfF+1lAHBaBecwSEz59ZgZxJAT6WSVOX1nG1sXICeSkSZy5cIq1i5EDyK6QuLnbFiQsJKAlc fTUbFaISW1MEjuu94DVsAmYSMzqkACpERFQkri3ajITSA2zwHxGiaZJvWAzhQUSJQ7vmMMEYr MIqEr8nj+BEcTmFfCR6Hr+gRFir5zEzXOdzCA2J1D8/KU3LBCLvSVuH+tjnMAosICRYRWjRnF qUVlqka6hhV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmBoMQDBDsabGwMOMUpy MCmJ8savaIsU4kvKT6nMSCzOiC8qzUktPsQow8GhJMGboNkRKSRYlJqeWpGWmQMMcpi0BAePk gjvC3WgNG9xQWJucWY6ROoUoyXHlSvrvjBxTDmwHUi+mvD/G5MQS15+XqqUOG8OyDwBkIaM0j y4cbBIvMQoKyXMywh0oBBPQWpRbmYJqvwrRnEORiVh3kkgU3gy80rgtr4COogJ6KA3ia0gB5U kIqSkGhgnCfzycWY/8+XUutV1Lm+LhOd/4t12Wu3lhdQcqaryh07/9Eznc0eduG/CeqTc03tF gYGF7/bvu4uuLgzb/IDJ2dFXYUKqTdL7XZ2/Nz6MEz/24szipOcsD2bzs2c6brQ4cERZL1Lv/ wo93ZXXWPQ7qzNdti2s3x0VJSvrybDm79Wm7ZOvRE5VYinOSDTUYi4qTgQAUFHyP78CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-21.messagelabs.com!1502096053!76598926!1 X-Originating-IP: [209.85.192.173] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 32272 invoked from network); 7 Aug 2017 08:54:14 -0000 Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by server-15.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:14 -0000 Received: by mail-pf0-f173.google.com with SMTP id h68so17546321pfk.0 for ; Mon, 07 Aug 2017 01:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=18Ge6a9O/Pp9Crt+qmm0kz9rAVp/MTv6jUoUgCTXZWo=; b=WcQeAqY9jMfFODfN388RnH3RTNFHHHdlHGA/8eqO+XiBjoVvQwMfU9AZ0DO5yxHsBz AmNCB6YrSoakboEGsLILF0kGsC0ew/t+T2fr+MVEr4hNtDoVVexMs7xQGnHlKY60HfIf OO10JdCM6pjnYwevOnFBf8Jgd8fl4LV1inK3Y= 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=18Ge6a9O/Pp9Crt+qmm0kz9rAVp/MTv6jUoUgCTXZWo=; b=eYEA8SdCJV3Pe6AykTPMTvWWLSHInsTWgOvrgq0/LHI7sEUDJEZHXMsWmNroF5lun2 YH6IVNxt1xEE3CsQsYmqA0ViiCb39lm/D0am2qIbxTedSKlOQs4+5DYycSztpP5dj27P IwJR16o31GkzKh/GlI6TaFR9io2z4rZxvE5/ceQFe0azUNz5JVU+QnJj01osp78iUlrw S2NlE3pLk5CpmjG/5HrCXfq8TJR5cSqpvF7/KAEbjyOFix+HRCR/e5iVzEUXYlqoL3P6 QbeRoJxinbwpmIIUjuXLA0q3lGwx9TDBiRTbKizkIZ0R+Nu8h79XJTB/SkAO2cdYqLct L6AA== X-Gm-Message-State: AIVw110Lm0JG+QZ9iPkSQB7dGsWGKOOpAAxAEq714e8/3JlfZs3ZhvJ8 UnC+Xek0qOKm+zlzJewo4Q== X-Received: by 10.98.205.8 with SMTP id o8mr11048719pfg.241.1502096052584; Mon, 07 Aug 2017 01:54:12 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:12 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:07 +0530 Message-Id: <1502095997-31219-16-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 15/25 v7] xen/arm: vpl011: Add a new console_evtchn_unmask function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a new console_evtchn_unmask function. This function unmasks the console event channel if it is masked for some timeout period. One optimization that has been done is to merge the two 'for' loops. One 'for' loop was used to iterate through all domains and unmask the domain event channels which had been rate limited for a specified duration. The other 'for' loop was run to add the event channel fd and the tty fd to the poll list. These two 'for' loops were merged so that the these operations can be done in one iteration instead of two iterations. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a0b35da..2dcaee6 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -117,6 +117,11 @@ struct domain { static struct domain *dom_head; +static inline bool console_enabled(struct console *con) +{ + return con->local_port != -1; +} + static int write_all(int fd, const char* buf, size_t len) { while (len) { @@ -908,6 +913,27 @@ static void handle_tty_write(struct console *con) } } +static void console_evtchn_unmask(struct console *con, void *data) +{ + long long now = (long long)data; + + if (!console_enabled(con)) + return; + + /* CS 16257:955ee4fa1345 introduces a 5ms fuzz + * for select(), it is not clear poll() has + * similar behavior (returning a couple of ms + * sooner than requested) as well. Just leave + * the fuzz here. Remove it with a separate + * patch if necessary */ + if ((now+5) > con->next_period) { + con->next_period = now + RATE_LIMIT_PERIOD; + if (con->event_count >= RATE_LIMIT_ALLOWANCE) + (void)xenevtchn_unmask(con->xce_handle, con->local_port); + con->event_count = 0; + } +} + static void handle_ring_read(struct domain *dom) { xenevtchn_port_or_error_t port; @@ -1142,23 +1168,7 @@ void handle_io(void) for (d = dom_head; d; d = d->next) { struct console *con = &d->console; - /* CS 16257:955ee4fa1345 introduces a 5ms fuzz - * for select(), it is not clear poll() has - * similar behavior (returning a couple of ms - * sooner than requested) as well. Just leave - * the fuzz here. Remove it with a separate - * patch if necessary */ - if ((now+5) > con->next_period) { - con->next_period = now + RATE_LIMIT_PERIOD; - if (con->event_count >= RATE_LIMIT_ALLOWANCE) { - (void)xenevtchn_unmask(con->xce_handle, con->local_port); - } - con->event_count = 0; - } - } - - for (d = dom_head; d; d = d->next) { - struct console *con = &d->console; + console_evtchn_unmask(con, (void *)now); maybe_add_console_evtchn_fd(con, (void *)&next_timeout); From patchwork Mon Aug 7 08:53:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109524 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481876obb; Mon, 7 Aug 2017 01:55:45 -0700 (PDT) X-Received: by 10.36.74.212 with SMTP id k203mr173682itb.14.1502096145139; Mon, 07 Aug 2017 01:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096145; cv=none; d=google.com; s=arc-20160816; b=f4da/eoOVU1V9Wc1xgNihT8BqVVP4szYAHhxbanr2BKSZ/8Hse5d7h3vhT7ISUjCLc wB5WDdn5MnFGQFpVj3f8sPJxYO+A3wpM6EldSIVODEV8plSteIB4HM6kuKz78CSUK8NH ThCBBkqhhUjX9G16TU0S60Qd65DiVCkRg1jpYJielT5ilFX0sTYShiusvLEW6c4ibAtq EuQwSDEkMJZpRtnX+rWAF6YOP5tx6fejzqWNSIOAZRnBawzi25waGvNPEN05Unj6ur4Y 92Ao8LH3nxMevREhElj4M6eTwPWgYKdMclx87ioLnrdSPLxQSQ/U0ZXi3mjZFzCHMapN enjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=B+cPD5qQMh06VI+WfJwSqbQcFlWwQTyCV+SgzWjo05o=; b=dLnaBVkngEst77cCX1BzC2Hr0LmQeY9GcbV+4Ub0DI/ZUXPCyq2GaXVOmJLc1YL/e5 NVeQ/XacuiSoNxN6TAf+1YoOTvQrTQB2inqKrAuQvtuU0mCe/N5WQC2b1WR6JDF4mDhI p1s9I3Se4QT1Yaqlpt8x86oq4nmAYRwIJ7O40dqA5Ryy0hUcIjSOppnZisRwMpsLOCSn ClERYdt1CqbH7eyRXMeLxjyIhou0HbD63qMI1zfZgPJfTf0prWQHjERtw9qI7PaJaVER 15vooc9OJJimy4xIu4gWK29FzlSWhIzRGOPFDAHGuXxdoDlfDKwYwohmezfnGDaDf/CL dsAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=XEd/qOts; 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 o6si7960151ith.171.2017.08.07.01.55.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:45 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=XEd/qOts; 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 1dedno-0004uZ-6L; Mon, 07 Aug 2017 08:54: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 1dednm-0004rg-QO for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:18 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 1C/BC-03368-ABA28895; Mon, 07 Aug 2017 08:54:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRtspLtTqyP SoOejpMX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmnH832q2gtdiFb967zI1MF4V6mLk5BASmMEo sXarURcjFweLwDxmiZVHzzKBOBIC/awSy18sZQepkhBIk5h+YgILhF0p0fFoKzNEt5bE0VOzW UEahATamCSOvj7O1sXIwcEmYCIxq0MCpEZEQEni3qrJYEOZBeYzSjRN6mUDSQgLxEvcmPsVzG YRUJXY1viaEcTmFfCR2LRnOxPEMjmJm+c6wZZxAsXPX3rDArHYW+L2sT7GCYwCCxgZVjFqFKc WlaUW6RqZ6yUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBIYWAxDsYFy8NvAQoyQH k5Iob/yKtkghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKEryfNTsihQSLUtNTK9Iyc4BBDpOW4OBRE uF9oQ6U5i0uSMwtzkyHSJ1iNOaYdGD7FyaOVxP+f2MSYsnLz0uVEuc9BzJJAKQ0ozQPbhAs+i 4xykoJ8zICnSbEU5BalJtZgir/ilGcg1FJmDcMZApPZl4J3L5XQKcwAZ3yJrEV5JSSRISUVAO j0db1Woejkxr+x9yJarXtlzbZuDqf+1TA0vfT4j03aAq/TZ32p+uC2EvthIqcnkJDwT0rqrVv BaQVGHh/OmzU47N9gvjXxQ6h8w8bz1+W1i+6zGVz8JPzRdv+LWviz9eazBix7c4Z06oMFcs9x 3N2bstx1L5lcEs47eNE7+1FMtc2Zkcd996uxFKckWioxVxUnAgA5i0shrkCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-27.messagelabs.com!1502096056!110339820!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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33473 invoked from network); 7 Aug 2017 08:54:17 -0000 Received: from mail-pg0-f50.google.com (HELO mail-pg0-f50.google.com) (74.125.83.50) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:17 -0000 Received: by mail-pg0-f50.google.com with SMTP id l64so31603584pge.5 for ; Mon, 07 Aug 2017 01:54:17 -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=PIjElh5iZCANBxQx6NqiqNqyIkPe3CusSbv427/MqCw=; b=XEd/qOts50kBhgUIQWw/kX+wQrhzS6W/5WcOPzXPIcxS6a7LzW/n63L4Z8CSZfei5b J2RpropvRyMAB/Yi/xpyzGoAaycWzYStamrZ7sAyQ1Yd6421LLPUiX7LffycQf2E5aPk dKnyQNKideg6UDTPknCJ8DRAJg31oC+TrAXWY= 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=PIjElh5iZCANBxQx6NqiqNqyIkPe3CusSbv427/MqCw=; b=gYPDLnybbsY4sI3s6s2ekNYvo4eFlhG7fbKUHUFWZGpG/3eoKFzB0r+ZLmoqrKG9kk lZvO5iP894qOzus2i3vAjjw0xGIU865etmtMcQGBe4vHzozHUFX9WmHnQ5ycvuGjUN5u P+WJShgb0IfQgvEbpz1867J1iv31BpnRG5bhUtzHEjHD+XQq5BgpOCRHse1ZO1Mbdsbr 2ivRvSS73NiTJHxLvOR0BpvqLmktCG61atpmZOxP78um6ffa7kVsN+eu1yoOzbf4+iic I6QnHOno4JrrEr2AHhmM6Ol6/Cs089TRmQ1P+IiXAqBpcbxEXq3Xv60mdDi5Qo7v8QnI hEKw== X-Gm-Message-State: AIVw113AlhXmkl/OC0FdE7tIOXvScxxMHy4qcvlvTEcPoQNrs16VwQw1 80DIOYr8gXU/eYlUi/GeGw== X-Received: by 10.98.27.65 with SMTP id b62mr11172589pfb.258.1502096055465; Mon, 07 Aug 2017 01:54:15 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:15 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:08 +0530 Message-Id: <1502095997-31219-17-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 16/25 v7] xen/arm: vpl011: Add a new handle_console_ring function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a new handle_console_ring function. This function reads the data from the ring buffer on receiving an event. The initialization of event channel poll fd to -1 is moved inside the handle_console_ring function as they are related. There should be no change in the behavior as there is no functional change. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 2dcaee6..c361b42 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -934,17 +934,23 @@ static void console_evtchn_unmask(struct console *con, void *data) } } -static void handle_ring_read(struct domain *dom) +static void handle_ring_read(struct console *con) { xenevtchn_port_or_error_t port; - struct console *con = &dom->console; - if (dom->is_dead) + if (con->d->is_dead) return; if ((port = xenevtchn_pending(con->xce_handle)) == -1) return; + if (port != con->local_port) { + dolog(LOG_ERR, + "Event received for invalid port %d, Expected port is %d\n", + port, con->local_port); + return; + } + con->event_count++; buffer_append(con); @@ -953,6 +959,21 @@ static void handle_ring_read(struct domain *dom) (void)xenevtchn_unmask(con->xce_handle, port); } +static void handle_console_ring(struct console *con) +{ + if (con->event_count < RATE_LIMIT_ALLOWANCE) { + if (con->xce_handle != NULL && + con->xce_pollfd_idx != -1 && + !(fds[con->xce_pollfd_idx].revents & + ~(POLLIN|POLLOUT|POLLPRI)) && + (fds[con->xce_pollfd_idx].revents & + POLLIN)) + handle_ring_read(con); + } + + con->xce_pollfd_idx = -1; +} + static void handle_xs(void) { char **vec; @@ -1236,15 +1257,8 @@ void handle_io(void) struct console *con = &d->console; n = d->next; - if (con->event_count < RATE_LIMIT_ALLOWANCE) { - if (con->xce_handle != NULL && - con->xce_pollfd_idx != -1 && - !(fds[con->xce_pollfd_idx].revents & - ~(POLLIN|POLLOUT|POLLPRI)) && - (fds[con->xce_pollfd_idx].revents & - POLLIN)) - handle_ring_read(d); - } + + handle_console_ring(con); if (con->master_fd != -1 && con->master_pollfd_idx != -1) { if (fds[con->master_pollfd_idx].revents & @@ -1261,7 +1275,7 @@ void handle_io(void) } } - con->xce_pollfd_idx = con->master_pollfd_idx = -1; + con->master_pollfd_idx = -1; if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Mon Aug 7 08:53:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109525 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481899obb; Mon, 7 Aug 2017 01:55:47 -0700 (PDT) X-Received: by 10.107.143.136 with SMTP id r130mr10454046iod.227.1502096147017; Mon, 07 Aug 2017 01:55:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096147; cv=none; d=google.com; s=arc-20160816; b=V/e2+bi9civDLvG8h3iIt+51uDkR6ATx0NqQ4u/cwQbVm2fokykx7Lin7YTxyFx4co 7KxW12Nj4ybpU+ZLbPTZjhNdATmy2ohrikDusBCB64Ts090p1oTbe/bGsU+dJPaKtGvZ BePnY0Nr3YuGwG/UyFkrzR7eKJwvUWHP9nRA9KXdFeVeY8RwhuHbSgHzBGtAfILeNGM1 lGB2r3fkuvPgn/W7VqhT3gDobGzBVS9vv57pipSpPhXr2scJRheBRZO5N+LfRI6f2EnS dGks7W5q7ByRaS4DNUQgz+6CjcNxqr9mNzivDieYW8/+/XdQho8r8suoQSN2NHyZBo9B 6+jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=H8RR8P9mLK0Yb6u6N61ymtzG/1SrqORpSqVSo+gXTcg=; b=Kr8Ks/MKp6rHPM15BzJclJkHl75Cath4jwOi4kRJW/qxwLJk5t3blxerqHgzgEswq3 01T0Bu8P+ea1iR9cdOtEOomoFAsf/O7j1jIpkg6JkqA9xQKINOhcQBDLCcLG5wdas2yB HPhO+46JaZwjAs/CnTapWB0KCUuKSZc29BoOhdYGlKwd5Z+1iaQ9+3a8dTwOgH4S0D2F me1M5K867xCgfUNfvXwAhNLe2yhM4cyeiB8bUw72lU1qqS9VOhdj73TQUwp55X9nlzJG lf0skne65FO/eug3Z9GlTA1ji3Y3jsbzMwJViEfXlWDitH+67ajF2c5wlNnyk08pXcSq 02Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Ov0yX3aN; 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 m18si9137882ioo.193.2017.08.07.01.55.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:47 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Ov0yX3aN; 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 1dednq-0004yd-HJ; Mon, 07 Aug 2017 08:54:22 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednp-0004wT-Ld for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:21 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id F0/29-03557-DBA28895; Mon, 07 Aug 2017 08:54:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRusp7tHqyP S4OMzEYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPWqissBRMEKlZ83c/SwLiFt4uRi0NIYAaj xK9JfUwgDovAPGaJVVMnM4M4EgL9rBKnpixj7GLkBHLSJF6tfQZlV0nc2PyaBcQWEtCSOHpqN ivEqDYmiUUL2oASHBxsAiYSszokQGpEBJQk7q2aDLaBWWA+o0TTpF42kISwQJzEzkWLWEFsFg FViVtfr4HFeQV8JC4fOMAMsUxO4ua5TjCbEyh+/tIbqMXeEreP9TFOYBRYwMiwilGjOLWoLLV I19BML6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMLgYgGAH4/2NAYcYJTmYlER5 41e0RQrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4H2k0REpJFiUmp5akZaZAwxzmLQEB4+SCO8Ld aA0b3FBYm5xZjpE6hSjMcekA9u/MHG8mvD/G5MQS15+XqqUOG+OJlCpAEhpRmke3CBY/F1ilJ US5mUEOk2IpyC1KDezBFX+FaM4B6OSMK8WyD08mXklcPteAZ3CBHTKm8RWkFNKEhFSUg2Mktz uex1b1DJy6uYZfua3XRIf67LtU71W2u2e+JuvRFjvi7AG9a+UL2E94HGEvWiKpuXuZcfDP8/P D9R7s++u9Nk++87XjIapjDasB5mP2ezaafI9LafJL36P7DOFVbuKuIylGNurfXyE5XvuvWZPv eMfO0n+rxn71GMpeimv3fun7mM/LqzEUpyRaKjFXFScCACDtf41ugIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-21.messagelabs.com!1502096059!73625359!1 X-Originating-IP: [74.125.83.46] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31648 invoked from network); 7 Aug 2017 08:54:20 -0000 Received: from mail-pg0-f46.google.com (HELO mail-pg0-f46.google.com) (74.125.83.46) by server-11.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:20 -0000 Received: by mail-pg0-f46.google.com with SMTP id v77so31639938pgb.3 for ; Mon, 07 Aug 2017 01:54:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cKW4VVAXHwcprLM7odui2WUoZIfS5KdXFh4XFIsCHUU=; b=Ov0yX3aNbcYyz3rEkxC7Jj24UXoXKQTV1heD8+VZdmoc8aaHE20p4h/dwzspHr9W3S IRffSSg0oBmHrqX4BlB2Zvrs/E1JAESa0JPcwUaLgdQd/lgkuWKQl/ms+ZSwHrwdLIRd /sfaw6kWeyLJ1IqBzQefxDFljiNSHb0nGhgkY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cKW4VVAXHwcprLM7odui2WUoZIfS5KdXFh4XFIsCHUU=; b=q/QjqV/z2GnFxEnhwLt8z9+t4Ht6EtcTg0ojUYp597vO/I02CqA6Z0mG60P+aajFQC sFa6Rze0ARUXMPte61h7Av220p74KWCA4i+0YXdi9dK05cozTyrb7kayWvI9M+FjbnZj nwWUugPQt0wvNaPvUZmlZb4XKLXGHBuHXxeVsi/IgrG77a4lZGVZA5EMcXIBSirYthsD Jhqih/NAgzvDLFPHd16iWMxz22j4U6bBcBfcSZww0YUAjKGtB066GbVxsVllivbyAdxp ZSQRpfk/0S6Kxj3IaAKbm/rPbFhEdPE/GvXUYjsdTaLz4mbNz4mICZv7Xa8GDnAX1yyL rStg== X-Gm-Message-State: AIVw113pkc1BpPSy3Grf+MzEs21r4Q9UB0fNrKOL9eXKzQQ3lJ2tVeqw tTxtS95OrHPaZ7mbamTjNQ== X-Received: by 10.84.234.15 with SMTP id m15mr13461607plk.247.1502096058582; Mon, 07 Aug 2017 01:54:18 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:18 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:09 +0530 Message-Id: <1502095997-31219-18-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 17/25 v7] xen/arm: vpl011: Add a new handle_console_tty function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a new handle_console_tty function. This function performs read/write from/to console tty. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index c361b42..5c6da31 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1130,6 +1130,24 @@ static void maybe_add_console_tty_fd(struct console *con) } } +static void handle_console_tty(struct console *con) +{ + if (con->master_fd != -1 && con->master_pollfd_idx != -1) { + if (fds[con->master_pollfd_idx].revents & + ~(POLLIN|POLLOUT|POLLPRI)) + console_handle_broken_tty(con, domain_is_valid(con->d->domid)); + else { + if (fds[con->master_pollfd_idx].revents & + POLLIN) + handle_tty_read(con); + if (fds[con->master_pollfd_idx].revents & + POLLOUT) + handle_tty_write(con); + } + } + con->master_pollfd_idx = -1; +} + void handle_io(void) { int ret; @@ -1260,22 +1278,7 @@ void handle_io(void) handle_console_ring(con); - if (con->master_fd != -1 && con->master_pollfd_idx != -1) { - if (fds[con->master_pollfd_idx].revents & - ~(POLLIN|POLLOUT|POLLPRI)) - console_handle_broken_tty(con, - domain_is_valid(d->domid)); - else { - if (fds[con->master_pollfd_idx].revents & - POLLIN) - handle_tty_read(con); - if (fds[con->master_pollfd_idx].revents & - POLLOUT) - handle_tty_write(con); - } - } - - con->master_pollfd_idx = -1; + handle_console_tty(con); if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Mon Aug 7 08:53:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109527 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481914obb; Mon, 7 Aug 2017 01:55:48 -0700 (PDT) X-Received: by 10.36.57.17 with SMTP id l17mr193365ita.58.1502096148428; Mon, 07 Aug 2017 01:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096148; cv=none; d=google.com; s=arc-20160816; b=mv15KfJQkKzEoOJBDUQiW8iPdXbvI+FGjBZGBxGVT0QD0tiWKmtuN+G0vcfdtkkRdu yTlE4eqiLu/cw2awptJhV0OVPN63IOzsl0RalP1nuk+fL74hOhmUtNzXZqcGKrbe2cLj HdXqHpRuD1M/MpsDCOV2UlxM9yM5e4g2YBFjtAAdnC2PP0w/eKJaeROUarSsJEZ8+wzV gictQ7ox2SXuyPI5yiMe0CSpk5C1tlfWadERp69mMaXQkQyNCuiYs4W+kSt66DZuhQUe 2vV/wFWiCnEBt2rpj7/QXGbM/T8+5bX/uHDkF7IVQ6XLLyv7snEVDC5idnb/tSvgkwPk 9agA== 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=zUtGRR3i6i6+dbz3QYT1cWiEyBKZBcfsv+JWrPA6amk=; b=kg9cfgE4kxtPmP7iWtwb7/HRpYjwfaMpNClF2FjSTwW8oHaFuS6+Jr+EYkNv0Yi2b5 gykg6vxySFDjUtpI2lS2lhcRQJjNKIcJd1D6D2T7Eh1pjecobn/rGXFOgVPWyPSOlro7 yDwQOmI45ijuhD3eDLnKNwjkOBsS9JxP21p6cg6Zd2mPMR02HqBD59RoqlPKqSKPiSzU +69vMGY+XfZuF0EKWgt8HsbaLT52F1/DEs0yx8WHNVRcThkb35kEXHmznVeB0Y1iS4Wh 6POcYhb/2CZAXh1errN8wz/9WdpHNfgKgT5rjRXS4rpnk5yjHJpbsm5iT6S8cCKLru0L Q7aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=TimVGmdv; 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 69si7523113ite.25.2017.08.07.01.55.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:48 -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=TimVGmdv; 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 1dednt-00053b-PQ; Mon, 07 Aug 2017 08:54:25 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedns-000518-O0 for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:24 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id CF/94-02176-0CA28895; Mon, 07 Aug 2017 08:54:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsVyMfTAat39Wh2 RBsuPCVl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmPfh5kK+jmrtjwZSF7A+Mhzi5GLg4hgZmM EkvX7mYCcVgE5jFLtM1aD+ZICPSzSvS/nQjkcAI5aRI3lm1igbCrJJqbToPZQgJaEkdPzWaFG NXGJDH7zyqgBg4ONgETiVkdEiA1IgJKEvdWTQYbyiwwn1GiaVIvG0hCWCBaYu7pbnaQehYBVY mde8JAwrwCPhI/vp5nhNglJ3HzXCcziM0JFD9/6Q3UXm+J28f6GCcwCixgZFjFqFGcWlSWWqR rbKCXVJSZnlGSm5iZo2toYKyXm1pcnJiempOYVKyXnJ+7iREYWvUMDIw7GDtP+B1ilORgUhLl jV/RFinEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgvezZkekkGBRanpqRVpmDjDIYdISHDxKIrxOw EAX4i0uSMwtzkyHSJ1itOS4cmXdFyaOKQe2A8lXE/5/YxJiycvPS5US5z0HMk8ApCGjNA9uHC wSLzHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5uUAWcuTmVcCt/UV0EFMQAe9SWwFOagkESE l1cCoyfRz7gJVJ5853+NrGNhZr6fdv+A9fXblg+ySTYu2N8d4qR/J+Rf5evvDKcVuGayGh7Pd frtPD963vraqIqKbJWoVe928jevP3XPRn3pbQeHNrP2ru5q9f5QdX3q21P/Ab1FR/6Xeaqeu2 GivvVnLFdOy6vLRJU7umdsWRoQ2s0+8cUzget9jJZbijERDLeai4kQAtx8ms78CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-31.messagelabs.com!1502096062!108950681!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 2565 invoked from network); 7 Aug 2017 08:54:23 -0000 Received: from mail-pf0-f171.google.com (HELO mail-pf0-f171.google.com) (209.85.192.171) by server-8.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:23 -0000 Received: by mail-pf0-f171.google.com with SMTP id c28so30687064pfe.3 for ; Mon, 07 Aug 2017 01:54:23 -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=O+v6KVnLDkCOtfqAGafxBkX1DdQ/QTAA5Uo5XO7DMl0=; b=TimVGmdv7mTmMAZGsyNZQXFC/ZpyEVRNo7fu1v5LWq6RRk0fWOIHVXZpyMBnMtwesB H0orOtDWGz4dkZrH7JBTCfGCJOldErRBUhQLi8HN4J9qQH5IM7V5cyGdn+oXkTW7Rtbw fD+4oSbIi7b+O9HkplMXFVgZgOOepchjq4904= 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=O+v6KVnLDkCOtfqAGafxBkX1DdQ/QTAA5Uo5XO7DMl0=; b=g0esA8Vv2vkskBQlFfbxXy5M9B++QNrQFWx1e1zPIjq6ALOnb50+aETVDWm1aRokYL MvUG9yi6hB8lhI59LVneOZxrBZvpCgKo5RBk3vrbesr5vfy7QBsfQ5fX+jRwxZlOGc7A rUKmYWZJSVr1XD8esFfc1H0spItOOnJSDoPtjbUC2HutrW+CdyI3+U6DeKPwbLCd9pgh o68gn8BaTjYvyYUPb0BFjHJeUQbh8FBp65a1/RunDJ2zNhUabeh/MxbRP3nPqbGrlOZp NIrIbgXtoobY43dyG2DO0XxuMZ57nGd+JjlPGrTICKqklQxacm20n6OINzB2gMz6QiGj nuxQ== X-Gm-Message-State: AIVw1107uDWyu+RPamE6YdVT4ByHqBCc8TmonLwFLGpKuD7aPXFMT17p 76k2L67aQbyofiGRAA51CQ== X-Received: by 10.84.217.23 with SMTP id o23mr13217857pli.243.1502096061581; Mon, 07 Aug 2017 01:54:21 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:21 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:10 +0530 Message-Id: <1502095997-31219-19-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 18/25 v7] xen/arm: vpl011: Add a new console_cleanup function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a new console_cleanup function. This function frees up the console resources. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v6: - Removed a null pointer check before calling free() as free() already checks that. Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 5c6da31..ff69e52 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -768,12 +768,8 @@ static void remove_domain(struct domain *dom) } } -static void cleanup_domain(struct domain *d) +static void console_cleanup(struct console *con) { - struct console *con = &d->console; - - console_close_tty(con); - if (con->log_fd != -1) { close(con->log_fd); con->log_fd = -1; @@ -784,6 +780,15 @@ static void cleanup_domain(struct domain *d) free(con->xspath); con->xspath = NULL; +} + +static void cleanup_domain(struct domain *d) +{ + struct console *con = &d->console; + + console_close_tty(con); + + console_cleanup(con); remove_domain(d); } From patchwork Mon Aug 7 08:53:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109528 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2481945obb; Mon, 7 Aug 2017 01:55:49 -0700 (PDT) X-Received: by 10.36.65.74 with SMTP id x71mr187789ita.102.1502096149529; Mon, 07 Aug 2017 01:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096149; cv=none; d=google.com; s=arc-20160816; b=xb0jXL6AW9JE+3++t6u3YpGFPbk/q7fkDXD/togUTfeLRN7w7RcGuUNDPYs63f13xt y+rNEwoARHJ2f1vz6eRKYWanq+oOmHjbX06N0/N9MwfV+DxC1hQMjjjMpc9AhB7uaIxI Qz04p07nJJQ2e6fbFJ9rRDRXXKygWpSmQVa9/COpsge21UAv23+pRSfEXbQPr6yeTYjs Y9mJkrSal5nbUIGkLAtRLsWjQD0QpGSmJMumfOpHrGK9nZV5Cjlv1aqjrKB6niaJ/gjy +Dks2egCWjltyCjL3ti3+M9FMBEBvHlCk5FK7zwjY30MLfTn7c9UVjvUDKFQUKMOmww0 yP6w== 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=0WTlf5TnOy6YP/0aRdpmJMniNmgkZDVENM8RygHZIr0=; b=ueJBcHo43u0gkjBbFByip0PzVhVuBFbuQkyYQeLsUMTpeAiZ4VHe+Na90rmCAI2ixE Twi4KX4L6a7xPdGaFXUAjehS64DQGJKHPnlkIHAP+EJ2SfOcOzpxG5aspQMlomAiNZ4T 1l4HL0l1LREMfiAKBrLaXSyQmvv7tEiUM96TF7/iZVDXYFo3B0N5Rn38CZ0dm+2jmWph T8Mye44D9ZMZQY6NySSDKGNd5vqrsSgB6koxpsb8A/HkfaagsV+Ax+jwHPyDpPVrYSwt X5Vv2gwFPxGgRUTYCbWd3AgkjzVfgFRycfpswWLGjOuGbUb8C8m4la9upCfMgP66JtBd 36MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kYC2Ju6U; 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 i200si7837645ita.137.2017.08.07.01.55.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:49 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kYC2Ju6U; 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 1dedny-00059y-1J; Mon, 07 Aug 2017 08:54:30 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednw-00056c-5T for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:28 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id BD/29-01859-3CA28895; Mon, 07 Aug 2017 08:54:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLIsWRWlGSWpSXmKPExsXiVRtsqHtIqyP SYMNtI4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPOx6+MBa+5Kl6se8vawLiQs4uRi0NIYAaj xOf2c+wgDovAPGaJtRMXsIE4EgL9rBKrVy0EynACOWkSv7/eYoawKyWeb3rNBGILCWhJHD01m xViVBuTxJKl24G6OTjYBEwkZnVIgNSICChJ3Fs1mQmkhllgPqNE06ReNpCEsECMxNeuF2ALWA RUJV4t/AUW5xXwkZjStpkRYpmcxM1znWCLOYHi5y+9YYFY7C1x+1gf4wRGgQWMDKsYNYpTi8p Si3SNDPSSijLTM0pyEzNzdA0NjPVyU4uLE9NTcxKTivWS83M3MQKDq56BgXEHY/MJv0OMkhxM SqK88SvaIoX4kvJTKjMSizPii0pzUosPMcpwcChJ8CZodkQKCRalpqdWpGXmAMMcJi3BwaMkw vtCHSjNW1yQmFucmQ6ROsVoybFh9fovTByTDmwHkq8m/P/GJMSSl5+XKiXOmwMyTwCkIaM0D2 4cLBYvMcpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLmnQQyhSczrwRu6yugg5iADnqT2ApyUEk iQkqqgbFb0faqlHjfDq0LjHcUH3L9jJz9TbRJ+Pfu5VJ3FUUq51QEdG2bcaK4wLWsXn62fEDm lwPd+SnvxOq3+9d1qC74+6xVJ35LhcUf+2zjCW1nghz+vbum8cZVfbVCx76OOukrp1anG71sM mp+77dBv+OdyRez6CDjZ90FGzzOCH8I01TSCezxVGIpzkg01GIuKk4EAKQVmE7AAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-31.messagelabs.com!1502096065!108865371!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 40986 invoked from network); 7 Aug 2017 08:54:26 -0000 Received: from mail-pg0-f49.google.com (HELO mail-pg0-f49.google.com) (74.125.83.49) by server-3.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:26 -0000 Received: by mail-pg0-f49.google.com with SMTP id v77so31641023pgb.3 for ; Mon, 07 Aug 2017 01:54:26 -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=mMQ/Oj6uICvCOt7w/LqlESqBMq7zC7kLronMiZ9p9+o=; b=kYC2Ju6UsMTgHUA7VN0HRZSwskvGzHgL0STv6dDHZSjkdafq2WN02CIvZXlxPS0PMy V/qxnvtcr8g2rBXClL85uCXexN5mlxPgSMWtmetUbyAzblTWjgP0WwaVij2TKx2tV6Is 6jag5ndGjCpS7JELkTs83CP50zyxkARRtz8LM= 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=mMQ/Oj6uICvCOt7w/LqlESqBMq7zC7kLronMiZ9p9+o=; b=m3Cd4Hv5h+oZn5pvNEQMB1uNlTRR81IwC6Ks8CFastWMSiZsANhxcHr8TsMl2Kt486 MpqXT8ZFAgSA7sWl7ILaul3NfFdeuBjvuZf2nKm57Py6OpSsAFY4bi49zB4+tRPz0k3F OrBXcgB66snMXvxxJdfWh+bANYdFcINVe1u6NxyQ1hBBJ1zOBz2Iyfv3hUFNxRH3eT/P v/w9kIclte3DslrbahFoQBW+N68a/LiLrdyAsrihVJVQcgslVRKMjDsq53SMUN4G+L3R ZbMJAxR2bDBtdm0vdaJ0o2H5lVfvpi3YlFJQcvYODlAhJQjg8os6ThHA9uQwQwo4730i b7Sg== X-Gm-Message-State: AIVw1102Kvc4u6poNH0uC8uFkkHAUMe5gXoeqRwLAZY0fbpJ+AbwHvf5 77gaHn8cqLRIHwaLZRVP2A== X-Received: by 10.99.43.87 with SMTP id r84mr10786055pgr.314.1502096064870; Mon, 07 Aug 2017 01:54:24 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:24 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:11 +0530 Message-Id: <1502095997-31219-20-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 19/25 v7] xen/arm: vpl011: Add a new console_open_log function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a console_open_log console_cleanup function. This function opens the console log file. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index ff69e52..cfd7273 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -1038,6 +1038,15 @@ static void handle_hv_logs(xenevtchn_handle *xce_handle, bool force) (void)xenevtchn_unmask(xce_handle, port); } +static void console_open_log(struct console *con) +{ + if (console_enabled(con)) { + if (con->log_fd != -1) + close(con->log_fd); + con->log_fd = create_console_log(con); + } +} + static void handle_log_reload(void) { if (log_guest) { @@ -1045,9 +1054,7 @@ static void handle_log_reload(void) for (d = dom_head; d; d = d->next) { struct console *con = &d->console; - if (con->log_fd != -1) - close(con->log_fd); - con->log_fd = create_console_log(con); + console_open_log(con); } } From patchwork Mon Aug 7 08:53:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109538 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482139obb; Mon, 7 Aug 2017 01:56:04 -0700 (PDT) X-Received: by 10.107.137.142 with SMTP id t14mr10901269ioi.215.1502096164176; Mon, 07 Aug 2017 01:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096164; cv=none; d=google.com; s=arc-20160816; b=BbX1SKHJlIYoh/X0j1DxavOaP8m5mwFN0CzH2cTfE9H5P2j4tfpO3vqlf3cJ2/eSXY sbAZ5bSgSV8hUXOB+5fzZgDfYRssxbdVmt87/e+5rDhddS/6kNAWQkkf0xSDQar+VP0x wMV6z0Ygsp3WuUCmK7bpxo75F0L6yj2yap9f6WUWSmTu/EcgzM8d1+AGABd+I5t90tkI DDe6Txe5+RnO88FAYYqD9reRRYKa1I/5ik5JANlHfRKbM+7zBm03gQ7XAozWUrjaCBLM H50Ey2k4eSQG5TLl3QTjLAaaydKqwygoGn19sxOpR3Alt2QzpHZm7C89TtPRdr0Rgwgp v16g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=B/iWbb165fhqROXYtc1SUPyns/TlpQEbmkL/vah2sQ4=; b=Gk1l8l2HKArqgfEun7y25cVJ4WUJTQW4XHiCMNo5oE3teyO3+g41CXc8Nq+FJhxEea IQCWoHD252o9pZlP6SEtZrD9kaRFlHKSWP1ufR4t6eGq+5CU5bBohWbKwXB+mz8IPe36 wtkwazbyItAfkIHxBh9uUKMChxzxreA5Vl5+wQIaLTXq6N37+XVUGQDZ4CcCSzxvCUA/ lJW7x2JoXdEcIVRQdrI9O0s5LJtopM6wrlPVoXAIoNF/bV+YYhwdMjOKyj7wF1aTBV6A 0Yah6CoVbDTmE6YIwbCQmc9g+7c/wkKc5X+aaonEhY4jIugJfEPNErhs+odoVtjjc5KP xhKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=WXD9WVn5; 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 f14si7892156ioe.144.2017.08.07.01.56.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:56:04 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=WXD9WVn5; 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 1dedo0-0005D2-8t; Mon, 07 Aug 2017 08:54:32 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednz-0005Au-0r for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:31 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 44/CC-22472-6CA28895; Mon, 07 Aug 2017 08:54:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRusrXtUqyP SYM1xDYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePxmYtMBb+5Ko4u38/awHiUs4uRi0NIYDqj RMPxp+wgDovAPGaJ/b17wRwJgX5WicefL7N0MXICOWkSDa03GCHsconOY6eYQGwhAS2Jo6dms 0KMamOS2HT0G1A3BwebgInErA4JkBoRASWJe6smM4HUMAvMZ5RomtTLBpIQFkiQOLNzEdhQFg FViWnnpoLZvAI+EgfuNDBBLJOTuHmukxnE5gSKn7/0hgVisbfE7WN9jBMYBRYwMqxi1ChOLSp LLdI1MtZLKspMzyjJTczM0TU0MNbLTS0uTkxPzUlMKtZLzs/dxAgMrnoGBsYdjH17/Q4xSnIw KYnyxq9oixTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwZug2REpJFiUmp5akZaZAwxzmLQEB4+SC O8LdaA0b3FBYm5xZjpE6hSjMcekA9u/MHG8mvD/G5MQS15+XqqUOO8bDaBSAZDSjNI8uEGw+L vEKCslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZg3DOQensy8Erh9r4BOYQI65U1iK8gpJYkIKak GRpVT9rcyy3/Ity/4U8n07MeX1/OfstYXL9gWPS+jZGV4v7FFrkqGz4LswicBM3Ilpu5kNNnD +1lGx7rkUqTXQ09bL5l67xKxkvzH9k8ecrVE7n7Ru63dxu+SwCcZDaF/W2WajTewlCXdvX1h3 4P4rkjBsmhz1QBR5i+WL+o+iMWv/5p7lmOyEktxRqKhFnNRcSIAnIZmmroCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-31.messagelabs.com!1502096068!104821608!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 52828 invoked from network); 7 Aug 2017 08:54:29 -0000 Received: from mail-pg0-f43.google.com (HELO mail-pg0-f43.google.com) (74.125.83.43) by server-15.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:29 -0000 Received: by mail-pg0-f43.google.com with SMTP id u5so31667309pgn.0 for ; Mon, 07 Aug 2017 01:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cCjDRmwTdHUYIQiYgejFMteqYI89juGj+je6V6CGGvI=; b=WXD9WVn56hgV+NZQqAJvcTDTWtYKr4iwtSnEKq++tEHPnVtbeqyElDgvP7u2J8RlXM bmNBlrxtWw1GCsFTgiu9sOgKefibSDjXHBt2tNM8+bCa+3Ij9vEsE3aAr/ylsjfNPu7i yBda73Fv9c5TTB7uqX6t7HkZILwxzx94LNeqs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cCjDRmwTdHUYIQiYgejFMteqYI89juGj+je6V6CGGvI=; b=clntuZOA0XYQgJrRxYvdy9ZXU0nNLsd8g6k1ZXLa9jrB3o7vQoarj5Fl9AfC1WlbYd ua3xi+82hekBOndnDSvT/409HXf0vJOW71z0hLn+tpODzEW1uhx6XbGgVFXdb7FMV1/c gsBuCF0vI/VCvkscbIFQUgVf/AOQuD7rLq5iCCqsedst31P1ACkWhtvnxCxoIzuFDwb5 iVQyITY/Iasw/SXIdgCG0VcRiU1w9JV2EzCi2ndf58la7UHTVbJ3kfxTmXg93SID0jA/ sHH81bbIBlbHB5PPVhM6rHnusYyG4/tsRFEP5SRQ7/bInDOHVja0s1olcYVYNEWcdPkR uTtA== X-Gm-Message-State: AHYfb5jn5oS+orYReEmnZrvZL71bYxkX6zJM9rR6u8wdwBU1ddWTKP5r 805XVHgxBRZJQbFyFrea+g== X-Received: by 10.84.236.71 with SMTP id h7mr855428pln.348.1502096067705; Mon, 07 Aug 2017 01:54:27 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:27 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:12 +0530 Message-Id: <1502095997-31219-21-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 20/25 v7] xen/arm: vpl011: Add a new console_close_evtchn function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a console_close_evtchn function. This function closes the console event channel. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index cfd7273..71465a0 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -793,6 +793,14 @@ static void cleanup_domain(struct domain *d) remove_domain(d); } +static void console_close_evtchn(struct console *con) +{ + if (con->xce_handle != NULL) + xenevtchn_close(con->xce_handle); + + con->xce_handle = NULL; +} + static void shutdown_domain(struct domain *d) { struct console *con = &d->console; @@ -800,9 +808,7 @@ static void shutdown_domain(struct domain *d) d->is_dead = true; watch_domain(d, false); console_unmap_interface(con); - if (con->xce_handle != NULL) - xenevtchn_close(con->xce_handle); - con->xce_handle = NULL; + console_close_evtchn(con); } static unsigned enum_pass = 0; From patchwork Mon Aug 7 08:53:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109534 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482068obb; Mon, 7 Aug 2017 01:55:59 -0700 (PDT) X-Received: by 10.36.122.70 with SMTP id a67mr142730itc.147.1502096159232; Mon, 07 Aug 2017 01:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096159; cv=none; d=google.com; s=arc-20160816; b=RfRBw12MOYnI6Pem3GaM/Nejdjfu4Vv6e4hkMcqGAY5X0J4DQHDhs+cDl5NcghlzZ5 NnMaqi5+E5os8ZTLG5375O1NqN4BefW50N6Gr6QEToSC+xBPHvQUNTUBn+wVi0R6ohRg o5W2usSnQwwCqD7CIyjkzYdVClqlEaWADtKrD/mXyGYnRBIg4ZIFn0EtBPm/9paVeSLc RQHCIIUEcf7o3ObXKQIf5FKIMyYVqC/Qw37GVFLWuc8P3NlyWfkmjYuMQLBfiQREFvJW 6BmyBqVSB0U8fiXOCdt7evWtVl5uABhmlYsaiv3S/kz3w6YsXrXqoO1v2nZY1ut1uJ8B utYA== 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=oandYAEYp7SK8JP4njapFL8pi5te2QJ5hv730ed/TMg=; b=vZzIOHu6ya+TF7LWCIjq/E7O3MdKYAmgB71q9fBA0L+hD9ic4FcuRIu4ooRbP6Z7ir Uk8eifZAL9iBwvAFsbprFjHqm/iFxYYjf6PbC1EK5ZO705shw/4fSICw+RY0wn91/Jqd 18+qlXdrhEbgEVdf8QYSRpPltjN9Ux/yGGlgGl/L7Gkl+Pkdgz+OVV13eGrThPn8Hw0c Vg385aLcd91pHvwylkhUt7Xg0Njw9nQtcGtcitzTG8txjjxrym4i16uBZAm6FS4dDVtR I6CYwdtWtvOzbs9w+CQMlSLPp7qeT0v0GfRMx/Aara8Rh4KLwqGOB9ZfkpY5RomNskaT hl5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=YAVTKJoG; 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 f78si7977531iof.88.2017.08.07.01.55.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:59 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=YAVTKJoG; 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 1dedo3-0005Hm-G7; Mon, 07 Aug 2017 08:54:35 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedo2-0005FN-2E for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:34 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id BC/BF-03937-9CA28895; Mon, 07 Aug 2017 08:54:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsVyMfTAJt0TWh2 RBl+vKVt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmXfq9mL5jmXrFkHnsD4z2rLkYuDiGBmYwS /f2HGEEcFoF5zBJ9y9awgjgSAv2sElOXXGHrYuQEctIkps7dywxhV0nMefCcEcQWEtCSOHpqN ivEqDYmiVP71wMlODjYBEwkZnVIgNSICChJ3Fs1mQmkhllgPqNE06ResKHCAlESl5f8ZQKxWQ RUJZ58fsEKYvMK+EhMXPIOarGcxM1znWCLOYHi5y+9YYFY7C1x+1gf4wRGgQWMDKsY1YtTi8p Si3Qt9JKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpOK9ZLzczcxAgOLAQh2MM6+7H+IUZKDSUmU N35FW6QQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd5HGh2RQoJFqempFWmZOcAQh0lLcPAoifC+U AdK8xYXJOYWZ6ZDpE4xWnJcubLuCxPHlAPbgeSrCf+/MQmx5OXnpUqJ874BmScA0pBRmgc3Dh aHlxhlpYR5GYEOFOIpSC3KzSxBlX/FKM7BqCTMG6YJNIUnM68EbusroIOYgA56k9gKclBJIkJ KqoFR6P7p/XaH/avTamIuOl/ld4870Slts+DL4bhPIb8W/gk3fOwvdzqiOHe2ftVy17hzQfoG J17x8PRd4DO4xyF4WF91+yah9xNNPmZ97GsL+l7Wt3lR/Wv2WU9vmOk5m9heXfrO/eDh2iTxs AM8tsqcDawPkpV8ln3zO+Rwcmnk6TPJH3fpCjorsRRnJBpqMRcVJwIAcVnHx74CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-21.messagelabs.com!1502096071!53698472!1 X-Originating-IP: [209.85.192.178] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42497 invoked from network); 7 Aug 2017 08:54:32 -0000 Received: from mail-pf0-f178.google.com (HELO mail-pf0-f178.google.com) (209.85.192.178) by server-6.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:32 -0000 Received: by mail-pf0-f178.google.com with SMTP id h68so17548959pfk.0 for ; Mon, 07 Aug 2017 01:54:32 -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=d43ELejxQWSRtSCIZ+3JiGeDUd/hSVHCbb3tNhT51wE=; b=YAVTKJoGrHtynUNrO+L+oCpgedwTn7rJPYkw8itJMA74mJXCH1bas0XcT00iYfxg18 619iIqLWeCjSlEC7o93rQo2mCDJYSXQ8P6AUgRCFj/6a8ss340egvtpCEw7p8BkpD+Lh JzQyQT9bt3ZyKWGEbB719YvYx0Dq9T47ovY5I= 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=d43ELejxQWSRtSCIZ+3JiGeDUd/hSVHCbb3tNhT51wE=; b=sj2ORxAwkYOHkBLdepnTo1S+p9yb730eTslPGmDEPldzR7Ffywh61za6c1AsFEudAK Vkztxn5miwAqaqQr0r4p7I1e7NbJ6ZhQUvV6/wHfIyk3rIN9rrse0amCiXIhi1rwnNwO fesaSLZVFGfsREPrLeN/loTcoIb+KCSgKWuDPpQSXWmMvw0FfNNZMtpqZ9fdJUSu2Swq FboCpWJZqNWgKE216ffOJEHIu5YzwPqabQL4T3Ud8lh+SwAupZSfesKZM006ZLbZ24Tr FhospQAfYW0gK+19d8G7kawremblFtOf18JFrwGxIaEYLqhj02XX8oHPNDtrK63mfBxn FgmA== X-Gm-Message-State: AIVw112bihVEouZNr65zWRkmN1tbUqUZVIkmLfi0Io1q28EP6I9l/TTv pYcY9KvydDXISXgfN8f7/g== X-Received: by 10.84.216.93 with SMTP id f29mr12924982plj.447.1502096070665; Mon, 07 Aug 2017 01:54:30 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:30 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:13 +0530 Message-Id: <1502095997-31219-22-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 21/25 v7] 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 | 156 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 122 insertions(+), 34 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 71465a0..f60312d 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -90,12 +90,14 @@ struct buffer { }; struct console { + char *ttyname; int master_fd; int master_pollfd_idx; int slave_fd; int log_fd; struct buffer buffer; char *xspath; + char *log_suffix; int ring_ref; xenevtchn_handle *xce_handle; int xce_pollfd_idx; @@ -107,21 +109,107 @@ struct console { struct domain *d; }; +struct console_data { + char *xsname; + char *ttyname; + char *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 +424,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 +576,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 +742,13 @@ static bool watch_domain(struct domain *dom, bool watch) { char domid_str[3 + MAX_STRLEN(dom->domid)]; bool success; - struct console *con = &dom->console; + struct console *con = &dom->console[0]; snprintf(domid_str, sizeof(domid_str), "dom%u", dom->domid); if (watch) { success = xs_watch(xs, con->xspath, domid_str); if (success) - console_create_ring(con); + console_iter_int_arg1(dom, console_create_ring); else xs_unwatch(xs, con->xspath, domid_str); } else { @@ -670,11 +758,13 @@ static bool watch_domain(struct domain *dom, bool watch) return success; } -static int console_init(struct console *con, struct domain *dom) +static int console_init(struct console *con, struct domain *dom, void **data) { char *s; int err = -1; struct timespec ts; + struct console_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", @@ -692,15 +782,21 @@ static int console_init(struct console *con, struct domain *dom) con->xce_pollfd_idx = -1; con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; con->d = dom; - con->xspath = xs_get_domain_path(xs, dom->domid); - s = realloc(con->xspath, strlen(con->xspath) + - strlen("/console") + 1); + con->ttyname = (*con_data)->ttyname; + con->log_suffix = (*con_data)->log_suffix; + 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); + con->xspath = xspath; err = 0; } + (*con_data)++; + return err; } @@ -713,7 +809,7 @@ static void console_free(struct console *con) static struct domain *create_domain(int domid) { struct domain *dom; - struct console *con; + struct console_data *con_data = &console_data[0]; dom = calloc(1, sizeof *dom); if (dom == NULL) { @@ -723,9 +819,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)) @@ -738,7 +833,7 @@ static struct domain *create_domain(int domid) return dom; out: - console_free(con); + console_iter_void_arg1(dom, console_free); free(dom); return NULL; } @@ -784,11 +879,9 @@ static void console_cleanup(struct console *con) static void cleanup_domain(struct domain *d) { - struct console *con = &d->console; + console_iter_void_arg1(d, console_close_tty); - console_close_tty(con); - - console_cleanup(con); + console_iter_void_arg1(d, console_cleanup); remove_domain(d); } @@ -803,12 +896,10 @@ static void console_close_evtchn(struct console *con) static void shutdown_domain(struct domain *d) { - struct console *con = &d->console; - d->is_dead = true; watch_domain(d, false); - console_unmap_interface(con); - console_close_evtchn(con); + console_iter_void_arg1(d, console_unmap_interface); + console_iter_void_arg1(d, console_close_evtchn); } static unsigned enum_pass = 0; @@ -1003,7 +1094,7 @@ static void handle_xs(void) /* We may get watches firing for domains that have recently been removed, so dom may be NULL here. */ if (dom && dom->is_dead == false) - console_create_ring(&dom->console); + console_iter_int_arg1(dom, console_create_ring); } free(vec); @@ -1058,9 +1149,7 @@ static void handle_log_reload(void) if (log_guest) { struct domain *d; for (d = dom_head; d; d = d->next) { - struct console *con = &d->console; - - console_open_log(con); + console_iter_void_arg1(d, console_open_log); } } @@ -1223,13 +1312,13 @@ void handle_io(void) /* Re-calculate any event counter allowances & unblock domains with new allowance */ for (d = dom_head; d; d = d->next) { - struct console *con = &d->console; - console_evtchn_unmask(con, (void *)now); + console_iter_void_arg2(d, console_evtchn_unmask, (void *)now); - maybe_add_console_evtchn_fd(con, (void *)&next_timeout); + console_iter_void_arg2(d, maybe_add_console_evtchn_fd, + (void *)&next_timeout); - maybe_add_console_tty_fd(con); + console_iter_void_arg1(d, maybe_add_console_tty_fd); } /* If any domain has been rate limited, we need to work @@ -1290,13 +1379,12 @@ void handle_io(void) } for (d = dom_head; d; d = n) { - struct console *con = &d->console; n = d->next; - handle_console_ring(con); + console_iter_void_arg1(d, handle_console_ring); - handle_console_tty(con); + console_iter_void_arg1(d, handle_console_tty); if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Mon Aug 7 08:53:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109536 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482088obb; Mon, 7 Aug 2017 01:56:00 -0700 (PDT) X-Received: by 10.107.12.70 with SMTP id w67mr11900449ioi.295.1502096160741; Mon, 07 Aug 2017 01:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096160; cv=none; d=google.com; s=arc-20160816; b=iKYVHMtdtYT1XOPTYl/JlXsxjfsUPT9K35YgF5TGugYR/J8USgXedsz7tKau9oGxvq y1ubfCD/u/+9gooXKLKK5ZRwUYCLihKvl5xd/MV/RkCnXsxbombX+eUmph9SS8xtyxsB /2UiMiaVEAichK1fDVM4YFvGuFf9h/3NNyoCmysd6pPvZGsetsSjo7gqXjz30dvqq2Ek S1G9UE3FQYPAq9m69Pdc5EBh4SBAC23VCnSevXQQn0VtyWJsPzl0Ej7+i96ICQDoxNS+ kmoZvjNK7bSgKBFw+yv7Pj6fB+mJ7mZSk8yyLI3kerENrGreOSHxPvS+qm9mT1USfpZC HV5Q== 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=dFaAVEtC/wucdnrx770nGZm5d1Bc8+DQY2pmCpzvj3I=; b=E1qy+dKyU1YshRem7WsL++HFbQOOJ6lRbHThWpYDXJglEAju83Nu+a0rzL+Wc3dR3L y1f1NrFLos+Cv0TWpq6IU4cxoPe1E6KvEy6HHAz6heg/tAQLcwSJYFwifVjLOmrSrbv4 UTwufD54JuY5EYGyKnY+5M7Ae8/lx3cA96ySvUpef3H6OETqzP3ooNvqh4wj26x4f8t5 Mo/WVWXeIxgbgMpp8jnFAL685NydgALlvYaf+4M6c7x+GeZU/32GKPJJZYbRR7oHGALK 8OAQUC3E4aRxNPvl+wWQVVKthST7PzxJ5SKrEalRzNdVLEneTgkKK0SFqYyShfBzvG7V G10g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EdBJA43H; 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 f63si7746353ith.203.2017.08.07.01.56.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:56:00 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EdBJA43H; 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 1dedo6-0005Nv-Qq; Mon, 07 Aug 2017 08:54:38 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedo5-0005L8-VO for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:38 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id AC/50-03044-DCA28895; Mon, 07 Aug 2017 08:54:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRWlGSWpSXmKPExsXiVRtsrHtGqyP S4NE2dYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPvux7GgiUqFT+7PzA2MF6S62Lk5BASmMEo cfKzeBcjFweLwDxmif3T3zGDJCQE+lkl2i5rdDFyANlpElf3akCEKyTudqxghujVkjh6ajYrS K+QQBuTxK8z7xhB6tkETCRmdUiA1IgIKEncWzWZCaSGWeA5k8ShCV/BmoUFwiT2f3rJCGKzCK hK/Hx9iQ3E5hXwkXjQt5AVYpmcxM1znWD1nEDx85fesEAs9pa4fayPcQKjwAJGhlWMGsWpRWW pRbqGBnpJRZnpGSW5iZk5QJ6ZXm5qcXFiempOYlKxXnJ+7iZGYFgxAMEOxuPv4w4xSnIwKYny xq9oixTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwftIoyNSSLAoNT21Ii0zBxjgMGkJDh4lEd4X6 kBp3uKCxNzizHSI1ClGe44Nq9d/YeKYdGA7kDww4+c3Jo5XE/5/YxJiycvPS5US583RBGoTAG nLKM2DGwqLyEuMslLCvIxAZwrxFKQW5WaWoMq/YhTnYFQS5g0DmcKTmVcCt/sV0FlMQGe9SWw FOaskESEl1cBYN+HK7iUXw232/d7ufzX6t9a1VT8KfL9HbV17t6A5aPFNE5a5/Pxp8YFfo79I 6XeLekzI/Per0Uv/fdPKpOKUffmOfZ2Hvr1aHbqS+b7e8qlKNb4+GyfaJPz9u5d3QoHdb7O2T 63xFQ9nzz75b8v1xtgrBeu2flSIvb8n/07H0Yw38TtvLq27oMRSnJFoqMVcVJwIAB8t4qzDAg AA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-12.tower-21.messagelabs.com!1502096075!76733911!1 X-Originating-IP: [74.125.83.51] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13581 invoked from network); 7 Aug 2017 08:54:36 -0000 Received: from mail-pg0-f51.google.com (HELO mail-pg0-f51.google.com) (74.125.83.51) by server-12.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:36 -0000 Received: by mail-pg0-f51.google.com with SMTP id v77so31642673pgb.3 for ; Mon, 07 Aug 2017 01:54:36 -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=zVH6KyQrrz8OkJqrrrsR5qmT1qXgUwYYk2D0Hy3dshM=; b=EdBJA43HiUIDZTVGa6HOmrsdi9KAnoOUMf5g8RwttHtXv/EmWqhPST+PLIBlZQrUBL iHOkfPIUbYeK9DGZyutkYmpV+hTuqIA5o1qv/uCYdnDXkaY8R+pnsgibT1wi1khidtZm IA/ESfnX5mYf3tUnQffbgDvJs79znKScYp+8k= 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=zVH6KyQrrz8OkJqrrrsR5qmT1qXgUwYYk2D0Hy3dshM=; b=EjAcCEz/l0drKHD31JenDW+jfh5Lau7K9nXjEzsuVI6dIjc1IaTo9h53+49q0nSd10 PYNR+M3Yj+ZNolrlLTutfwmwCKq9WcjS+sFJJRFokjymo1I2RVzWFSSnDxJBkIWt7sp0 2r1vKrC8HE+vOIBgk9Dp+0bvQzjYcDv/H8V76yCo2FHhaBPMYgXkmPIwqvA9AJ0hFMjX 00abhXAbjMPNAZCqOas5AcTc6G9xTq3rnPMqPdhOjAI/dqkOo1ioiWhVz4m8lJ9xN+Tg cN5v9lT20lOnrX4CksO7Y+vfmTe7h3LTVu27NYC2v046mOSK8D2x7eA5hkqR1UZawVsM E18Q== X-Gm-Message-State: AHYfb5jX20q+ImOQ88A7VXbAFd0kheh6q+B7Z3te90rGqC1piy4trXqi lBFsO4U/gPw3bo5K70uojA== X-Received: by 10.98.150.75 with SMTP id c72mr4251535pfe.58.1502096074787; Mon, 07 Aug 2017 01:54:34 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:34 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:14 +0530 Message-Id: <1502095997-31219-23-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 22/25 v7] xen/arm: vpl011: Add support for vuart console in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch finally adds the support for vuart console. It adds two new fields in the console initialization: - optional - use_gnttab optional flag tells whether the console is optional. use_gnttab tells whether the ring buffer should be allocated using grant table. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Andrew Cooper CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall Changes since v6: - Renames prefer_gnttab to use_gnttab Changes since v4: - Renamed VUART_CFLAGS- to CFLAGS_vuart- in the Makefile as per the convention. config/arm32.mk | 1 + config/arm64.mk | 1 + tools/console/Makefile | 3 ++- tools/console/daemon/io.c | 32 ++++++++++++++++++++++++++++++-- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/config/arm32.mk b/config/arm32.mk index f95228e..b9f23fe 100644 --- a/config/arm32.mk +++ b/config/arm32.mk @@ -1,5 +1,6 @@ CONFIG_ARM := y CONFIG_ARM_32 := y +CONFIG_VUART_CONSOLE := y CONFIG_ARM_$(XEN_OS) := y CONFIG_XEN_INSTALL_SUFFIX := diff --git a/config/arm64.mk b/config/arm64.mk index aa45772..861d0a4 100644 --- a/config/arm64.mk +++ b/config/arm64.mk @@ -1,5 +1,6 @@ CONFIG_ARM := y CONFIG_ARM_64 := y +CONFIG_VUART_CONSOLE := y CONFIG_ARM_$(XEN_OS) := y CONFIG_XEN_INSTALL_SUFFIX := diff --git a/tools/console/Makefile b/tools/console/Makefile index abe77b2..e7ff8ff 100644 --- a/tools/console/Makefile +++ b/tools/console/Makefile @@ -11,6 +11,7 @@ LDLIBS += $(SOCKET_LIBS) LDLIBS_xenconsoled += $(UTIL_LIBS) LDLIBS_xenconsoled += -lrt +CFLAGS_vuart-$(CONFIG_VUART_CONSOLE) = -DCONFIG_VUART_CONSOLE BIN = xenconsoled xenconsole @@ -28,7 +29,7 @@ clean: distclean: clean daemon/main.o: daemon/_paths.h -daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) +daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) $(CFLAGS_vuart-y) xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c)) $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_xenconsoled) $(APPEND_LDFLAGS) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 067eeb5..2817a49 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -107,12 +107,16 @@ struct console { xenevtchn_port_or_error_t remote_port; struct xencons_interface *interface; struct domain *d; + bool optional; + bool use_gnttab; }; struct console_data { char *xsname; char *ttyname; char *log_suffix; + bool optional; + bool use_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, + .use_gnttab = true, }, +#if defined(CONFIG_VUART_CONSOLE) + { + .xsname = "/vuart/0", + .ttyname = "tty", + .log_suffix = "-vuart0", + .optional = true, + .use_gnttab = false, + }, +#endif }; #define MAX_CONSOLE (sizeof(console_data)/sizeof(struct console_data)) @@ -650,8 +665,17 @@ static int console_create_ring(struct console *con) "ring-ref", "%u", &ring_ref, "port", "%i", &remote_port, NULL); - if (err) + + if (err) { + /* + * This is a normal condition for optional consoles: they might not be + * present on xenstore at all. In that case, just return without error. + */ + if (con->optional) + err = 0; + goto out; + } snprintf(path, sizeof(path), "%s/type", con->xspath); type = xs_read(xs, XBT_NULL, path, NULL); @@ -665,7 +689,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->use_gnttab) { /* Prefer using grant table */ con->interface = xengnttab_map_grant_ref(xgt_handle, dom->domid, GNTTAB_RESERVED_CONSOLE, @@ -784,6 +810,8 @@ static int console_init(struct console *con, struct domain *dom, void **data) con->d = dom; con->ttyname = (*con_data)->ttyname; con->log_suffix = (*con_data)->log_suffix; + con->optional = (*con_data)->optional; + con->use_gnttab = (*con_data)->use_gnttab; xsname = (char *)(*con_data)->xsname; xspath = xs_get_domain_path(xs, dom->domid); s = realloc(xspath, strlen(xspath) + From patchwork Mon Aug 7 08:53:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109537 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482107obb; Mon, 7 Aug 2017 01:56:01 -0700 (PDT) X-Received: by 10.36.7.65 with SMTP id f62mr175264itf.28.1502096161895; Mon, 07 Aug 2017 01:56:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096161; cv=none; d=google.com; s=arc-20160816; b=UAqgOCIOMBXm6iBwtOXFzTRd+dBok+WGTRxZ8GugWJfK4na6591RX3t/Pnxh4INRRx RBMa+uaWib4yRqwUx8wcyZPoIV/7f5J2Pz2JL7eX2FPSOoEWisIVDFnJSRQEFZwn0/sW +nRHxQev09M79rJQaA2tqLWbqu4f6jMH51w9CD/VWM+zjiRRmFJLf6aA0SY+RzMzD1m8 GGiX7SGhio0beZpV7Q5zm7BZ+5KdiHxd0pusdcEl1BNCzqOnjLmKUnWjW3e0jSMgQr8m QS9tV3Z//V55N/8M01nByUKlgZEPdIo47V1ShlFIwchVZmmqi4aWumV1Dnqn/bdhXDH8 7law== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=pJyNIWfhAVo2E2CgMcfI/HHFeP51uQR9/ksH+7RgARQ=; b=ja6Z6BexAER72TfQ9yEz2MJ0oIUfHNs0U1su+9WFsK+agtR7BOEmi6LGjojqHVRhgG dqFg0vOrFy9rBp8FuQoLVboTbg6FFLuzyreiAKnkFmIdWFBxG9neKRjii5kjbOWbIBQJ CKEOuZ50hTIjur/bgGmAiTCgxPHaNPaV5mb1oAnp4CtaIayrAS3boa+rFA7J14+0hnrt uRZqwKMaAiehCi3Cy9h/M85QJ2f8nLRPkjD2lgDjEaVoVNLRlV/8S2I2VHvs7y6Hj1SW s/aB0Ch0aznBqyB3nlwxFroX0jmFiy4dGj55Wd1i2CgKJMD5hWENrPWGnhi/2h3Iuoo7 l/8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=kGgfdwsE; 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 n102si8474829ioo.9.2017.08.07.01.56.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:56:01 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=kGgfdwsE; 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 1dedoA-0005Sm-2S; Mon, 07 Aug 2017 08:54:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedo8-0005Qi-SU for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:40 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 63/2B-03406-0DA28895; Mon, 07 Aug 2017 08:54:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXiVRtsqHteqyP S4OtrZYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNaNx1mr2gsuiFeeWbmBvYJwt2MXIySEkMJNR 4uFV/S5GLg4WgXnMEk9e9DCBOBIC/awSk1+3AjkcQE6axJbtSiANEgLVEi3PJzFDNGtJHD01m xWkXkigjUli3+4ZYPVsAiYSszokQGpEBJQk7q2aDDaTWWA+o0TTpF42kISwQIzEzeuNjCA2i4 CqxLa+32A2r4CPxO31+9kglslJ3DzXCbaMEyh+/tIbFojF3hK3j/UxTmAUWMDIsIpRvTi1qCy 1SNdEL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMKwYgGAHY/dl/0OMkhxMSqK8 8SvaIoX4kvJTKjMSizPii0pzUosPMcpwcChJ8CZodkQKCRalpqdWpGXmAAMcJi3BwaMkwvtCH SjNW1yQmFucmQ6ROsVozDHpwPYvTByvJvz/xiTEkpeflyolznsOZJIASGlGaR7cIFjkXWKUlR LmZQQ6TYinILUoN7MEVf4VozgHo5IwbxjIFJ7MvBK4fa+ATmECOuVNYivIKSWJCCmpBsbIPvN FK0/ds21quqD5e/k179Nr2b9OnjCDq+m0glt/AtukfwYnxFP5rI8ccq4PXvLp1NLsv8s9rDod np3bvlI+5pJPybIcx2YvX6PsqJW7rFe/MFh26W3i1XkzHf03LNQ+Mv/p9zfHC7dcduuMPtJtc ycny/xR88vd3Y+X3zxwPTOtqLVPJG+GEktxRqKhFnNRcSIA/01g5bcCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-16.tower-27.messagelabs.com!1502096078!110307531!1 X-Originating-IP: [74.125.83.49] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4982 invoked from network); 7 Aug 2017 08:54:39 -0000 Received: from mail-pg0-f49.google.com (HELO mail-pg0-f49.google.com) (74.125.83.49) by server-16.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:39 -0000 Received: by mail-pg0-f49.google.com with SMTP id y129so31673896pgy.4 for ; Mon, 07 Aug 2017 01:54:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HWroLNIkhQjYUcAWyd7ghBserWIB9IYYwUwfhZwGLVc=; b=kGgfdwsE9sqNvN/buQoPv1v1h81W6ainbfNSL9O5djLbY0ZlVDcO9UHCal/XwAK3va 20hOVCzYdcm7xlur/gY+ljP4hKREjt89zJurR/DgM4pdYgWNXUiHi8vsA+eUgNx77nMs Dg/8/XyCRgeWYEQ4DAoYUd469XQCivQRiaZsI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HWroLNIkhQjYUcAWyd7ghBserWIB9IYYwUwfhZwGLVc=; b=ssG7Iiw7RECgv5QPMbRZOltt7gy6oERHjhPVvdGG8OK6mcZG2iAmLwKisa4rSBn80b gKfkckPeTCxe8FcaR86rtSFuFd6T4XPNZ0avw170KVehqd0Y6uArt+J4/y7UoHtNlAwp 6y45VhnBj9sw9Zj8nKkALy8vk5n56l2zdEu6uYlUTsS3Z6nEdu9dIuQhWrX8UFxEgYYX um6sebb/ZMfyL+gh3WLQ6k7S8fl5LdFVUHNfapBKIkrhptkMfR/Ybt6ykIoXt5rwyysb P3BhQl5BVxyJopLvetk6zqQ8OESmDlxxAXovHzw4DrCbd9G31dn+iQuBJ7LVgPr8ZzRL qo4w== X-Gm-Message-State: AIVw1138Ii+vy9cyaVmeuGOXiLmF+c6r1glLCT2ly42Q3o9wGAb6T6GX JR/Q4rmjD5IxMcyMLMWH/w== X-Received: by 10.99.97.129 with SMTP id v123mr10651258pgb.337.1502096077823; Mon, 07 Aug 2017 01:54:37 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:37 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:15 +0530 Message-Id: <1502095997-31219-24-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 23/25 v7] xen/arm: vpl011: Add a new vuart console type to xenconsole client X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add a new console type VUART to connect to guest's emualated vuart console. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Removed the vuart compile time flag so that vuart code is compiled always. Changes since v3: - The vuart console support is under CONFIG_VUART_CONSOLE option. - Since there is a change from last review, I have not included reviewed-by tag from Stefano and acked-by tag from Wei. tools/console/client/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index c340cb7..f92ad3d 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -76,7 +76,7 @@ static void usage(const char *program) { "\n" " -h, --help display this help and exit\n" " -n, --num N use console number N\n" - " --type TYPE console type. must be 'pv' or 'serial'\n" + " --type TYPE console type. must be 'pv', 'serial' or 'vuart'\n" " --start-notify-fd N file descriptor used to notify parent\n" , program); } @@ -264,6 +264,7 @@ typedef enum { CONSOLE_INVAL, CONSOLE_PV, CONSOLE_SERIAL, + CONSOLE_VUART, } console_type; static struct termios stdin_old_attr; @@ -344,6 +345,7 @@ int main(int argc, char **argv) char *end; console_type type = CONSOLE_INVAL; bool interactive = 0; + char *console_names = "serial, pv, vuart"; while((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) { switch(ch) { @@ -359,9 +361,12 @@ int main(int argc, char **argv) type = CONSOLE_SERIAL; else if (!strcmp(optarg, "pv")) type = CONSOLE_PV; + else if (!strcmp(optarg, "vuart")) + type = CONSOLE_VUART; else { fprintf(stderr, "Invalid type argument\n"); - fprintf(stderr, "Console types supported are: serial, pv\n"); + fprintf(stderr, "Console types supported are: %s\n", + console_names); exit(EINVAL); } break; @@ -437,6 +442,10 @@ int main(int argc, char **argv) else snprintf(path, strlen(dom_path) + strlen("/device/console/%d/tty") + 5, "%s/device/console/%d/tty", dom_path, num); } + if (type == CONSOLE_VUART) { + snprintf(path, strlen(dom_path) + strlen("/vuart/0/tty") + 1, + "%s/vuart/0/tty", dom_path); + } /* FIXME consoled currently does not assume domain-0 doesn't have a console which is good when we break domain-0 up. To keep us From patchwork Mon Aug 7 08:53:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109535 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482080obb; Mon, 7 Aug 2017 01:55:59 -0700 (PDT) X-Received: by 10.107.4.142 with SMTP id 136mr10728692ioe.251.1502096159891; Mon, 07 Aug 2017 01:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096159; cv=none; d=google.com; s=arc-20160816; b=aSZZTHV/neTGBQtDEHVPU5vcCilKkerUXnsFuvP5rdXKfWZHmF9om7IlWL9rkb6b6M FUk9jXE33KcD4nrSKkpQAdyB+y57/YmDlSLMEsRR9KejeHr9JEmJuEHVmkbzDgz0vLoW XHq6nGNzx93IkpBdK162xdUzfFv4PIlIbHoDNA3/eR1pDJmJ5ErBnB10ZGP4HYn0TJFH NrRTfV9SwK4hAILXYopEGKB37W5r/WHgDKfug90f9AYE27UlkmrvFogGoKUK0e+xZlhH WxkLDuA6woTQ1AozsTrvcUWFuG/G6FBxl33SSiTI+idf2KFcyvjf04Se2NjBpOEuubgq FK4Q== 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=9tqeqthSHgi7Mj0AvcKB8TrGTzttOz/kx3TurC+OQV0=; b=Gzzsv4hgTUA3O8UXOR8k8JCNEt+3gOSQ/LX22j39BlOuTQUb1bgF6eklw1C5COSWZX BqmEDZW46cFzy2kqk38XGFjOKBpaT2LlY3DSznTjJQIvUpuLHg6UTssTtXLr8rTzOJUz OPKBfvxIOVBxI1OYULiirfqkmdB8plY1SY0GSxeRP201VI+Yk4cI77Oi644lkAH2coNf hMTxaM2Xb0klXwQR5ElpucjDuTqtDKxn/bBkpfIv1N0dIRrCmO3OcT2S0QPP1FJGkCRq wIsnW8Z98JKmb65I1TPpNBS01SLOTUDo+brwKieWSuA7UIgtLgoOdiNG3UdKOY8BUtqe 2bLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=K1x/V4hB; 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 h66si8105603iod.181.2017.08.07.01.55.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:59 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=K1x/V4hB; 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 1dedoD-0005Y3-9X; Mon, 07 Aug 2017 08:54:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedoB-0005V1-Kx for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:43 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 94/EA-09901-3DA28895; Mon, 07 Aug 2017 08:54:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRuspXtJqyP S4MItCYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP434fsBb8VK562rmBsYOyQ6mLk4hASmMko 8aj5HyuIwyIwj1nix4G5bCCOhEA/q8Tsj2uZuxg5gZw0iU+zZ7BC2JUSp+d0s4PYQgJaEkdPz WaFGNXGJPFt5i2mLkYODjYBE4lZHRIgNSICShL3Vk1mAqlhFpjPKNE0qZcNJCEsECPxu+sPmM 0ioCox7d4lNpBeXgEfialLoHbJSdw81wl2AydQ+PylNywQe70lbh/rY5zAKLCAkWEVo0ZxalF ZapGukZFeUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZgaDEAwQ7GNfMDDzFKcjAp ifLGr2iLFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBm6DZESkkWJSanlqRlpkDDHKYtAQHj5II7 wt1oDRvcUFibnFmOkTqFKMxx6QD278wcbya8P8bkxBLXn5eqpQ4bw7IJAGQ0ozSPLhBsOi7xC grJczLCHSaEE9BalFuZgmq/CtGcQ5GJWHeSSBTeDLzSuD2vQI6hQnolDeJrSCnlCQipKQaGOe t3/H6j82WSR+1V9yYlOkVwHCzQE/8yeypktI7FFUZH2kGv3klki61blmYE1vuIemX4vabtMtD FitsPrYmZouZ+J1KPdXPvCtXWpU9a72eqHGk08J0wZyA504f9dMUQ65m3901/cXZNMGaKJW01 T1tPj+4rHVdJrV5mTk1deTJtsTq/De5rcRSnJFoqMVcVJwIAPFBup+5AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-21.messagelabs.com!1502096081!53698507!1 X-Originating-IP: [74.125.83.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43996 invoked from network); 7 Aug 2017 08:54:42 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-6.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:42 -0000 Received: by mail-pg0-f42.google.com with SMTP id u185so31684069pgb.1 for ; Mon, 07 Aug 2017 01:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0kBNhxW6fBT1xKvZKCjrmuLQDg2QR/CDj1OEhFL/+AE=; b=K1x/V4hBdqYK/RMykFeJkv1K9Do8fFN2mfzqq2GkI01s0XuEbb0gexyh9K5pYkpClp Js4ATjx8D4EXwX/ty8Dr5unDY4WlMRHtThHF9TNt+s3KSUvFZku4seG6EB9yU8U5Neax fx7A9JajU2F9tQsIQdRIr6nzSlW66YPuDM0ro= 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=0kBNhxW6fBT1xKvZKCjrmuLQDg2QR/CDj1OEhFL/+AE=; b=FztIwBXQqzlJyCETy3V0yfey0ltuySOZ6/l7BmXUjOZVXdtTyjft6puPNCvkJJ8BG8 ouP9tSHmSNE/B6FTWFj1FZl0w3a1Pso1l6hfJV5c/Ly+wx/EFtymnP/xJ+ItqjWkxnlT OzxrImhb/IOjewwrzdm5HhdYzalfFNdL4W8sFHy+599eLVk1YZ5Tb3IuSanMaSCy2tJq pULirECTlWe6nY7akFvY4BVzlxRZpfKvAESPzVv2akRo2V0tzYw1jeNOojCK5QkyV2P2 7gS3hohQcsSN6cTE0MuQyDxlcHvKSHVLndd3upOZWiwnvs3aF5Z16cJpfK5zxz4RyGz3 XCnw== X-Gm-Message-State: AIVw111/L3CBmrCOM64LBh6izIyGFRXJmRNRW0n4Mdyzy+kK/tfCOebI 0qadni0VVw7jpfjRRn+fvw== X-Received: by 10.99.62.75 with SMTP id l72mr10685220pga.316.1502096080670; Mon, 07 Aug 2017 01:54:40 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:40 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:16 +0530 Message-Id: <1502095997-31219-25-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 24/25 v7] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The SBSA UART node format is as specified in Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt and given below: ARM SBSA defined generic UART ------------------------------ This UART uses a subset of the PL011 registers and consequently lives in the PL011 driver. It's baudrate and other communication parameters cannot be adjusted at runtime, so it lacks a clock specifier here. Required properties: - compatible: must be "arm,sbsa-uart" - reg: exactly one register range - interrupts: exactly one interrupt specifier - current-speed: the (fixed) baud rate set by the firmware Currently the baud rate of 115200 has been selected as a default value, which is one of the valid baud rate settings. Higher baud rate was selected since an emulated pl011 can support any valid baud rate without any limitation of the hardware. A check is added to ensure that user specified irq does not conflict with the SPI assgined to vpl011. If there is a conflict then it flags an error. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v6: - Added a comment explaining why user specified IRQ should not conflict with vpl011 SPI. - Checking the vuart type explicitly against vpl011 enum type. - Removed uart-compat string and using "arm,sbsa-uart" string directly. - I have retained the reviewed-by/acked-by tags as these are minor changes. tools/libxl/libxl_arm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index a33d3c9..6629852 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -43,11 +43,29 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, { uint32_t nr_spis = 0; unsigned int i; + uint32_t vuart_irq = 0; + + /* + * If pl011 vuart is enabled then increment the nr_spis to allow allocation + * of SPI VIRQ for pl011. + */ + if (d_config->b_info.arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) { + nr_spis += (GUEST_VPL011_SPI - 32) + 1; + vuart_irq = GUEST_VPL011_SPI; + } for (i = 0; i < d_config->b_info.num_irqs; i++) { uint32_t irq = d_config->b_info.irqs[i]; uint32_t spi; + /* + * The user specified irq should not conflict with the vpl011 irq. + */ + if (irq == vuart_irq) { + LOG(ERROR, "Physical IRQ %u conflicting with pl011 SPI\n", irq); + return ERROR_FAIL; + } + if (irq < 32) continue; @@ -590,6 +608,38 @@ static int make_hypervisor_node(libxl__gc *gc, void *fdt, return 0; } +static int make_vpl011_uart_node(libxl__gc *gc, void *fdt, + const struct arch_info *ainfo, + struct xc_dom_image *dom) +{ + int res; + gic_interrupt intr; + + res = fdt_begin_node(fdt, "sbsa-pl011"); + if (res) return res; + + res = fdt_property_compat(gc, fdt, 1, "arm,sbsa-uart"); + if (res) return res; + + res = fdt_property_regs(gc, fdt, ROOT_ADDRESS_CELLS, ROOT_SIZE_CELLS, + 1, + GUEST_PL011_BASE, GUEST_PL011_SIZE); + if (res) return res; + + set_interrupt(intr, GUEST_VPL011_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); + + res = fdt_property_interrupts(gc, fdt, &intr, 1); + if (res) return res; + + /* Use a default baud rate of 115200. */ + fdt_property_u32(fdt, "current-speed", 115200); + + res = fdt_end_node(fdt); + if (res) return res; + + return 0; +} + static const struct arch_info *get_arch_info(libxl__gc *gc, const struct xc_dom_image *dom) { @@ -889,6 +939,9 @@ next_resize: FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) ); FDT( make_hypervisor_node(gc, fdt, vers) ); + if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) ); From patchwork Mon Aug 7 08:53:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109541 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482208obb; Mon, 7 Aug 2017 01:56:09 -0700 (PDT) X-Received: by 10.36.34.135 with SMTP id o129mr152584ito.85.1502096168960; Mon, 07 Aug 2017 01:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096168; cv=none; d=google.com; s=arc-20160816; b=n+Te19YTMB638OloGCta85rcv98hUP1fa74j+h1nTOn114G3vZe7nZDAR5tJxd01gT o2RpBYADrw1vnKDhQa4+LQRmZuBKeD4uNzmuC/Jj5qvbcVV0pBb51SP9Q9fMx+lLWi+J qfjpus4aI8tkS3AftE1Fl4HUsSASJeLrv6fuU1OcUFcGbSZbrtPx38i0JVz+O6jDYX13 HCXQ7GL6vEddQIOjiMIhDUV3zRhVkfcz13SkED70W3MGcTWEtgbSOrhLDyYmWSX/6xXC x16NY6k6ReTt3FCXs5caXzWJ+oTrH2UYNRWhkt7SYGbWjdOB9s+ybjcj+R0lsLd3T3vK VOHA== 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=w9ftdLy5hSB18PgKuJ32Jy06KLtxJkgHOsurivVhjzU=; b=Eunj/afF/OWpC7Stz+ueSbPfXoj//IyxjjWRXI/c8OPrm6BijF9CydKQnpuD93so8+ fsBrjiaTqvK0v1HY9RGvfoxgtvsVhvrLsH+v8rQm2/5YwDVlq1aBDuWsO9AVaFPgesWR 7zAUpN5ajbzC+cjyjecb7JP+hHnnm9Fop5q0H2wenUWdgkLhghGeuNFKutwugca/Qc4K 5/3VSZIfLf+HRvZzBrI3kMkfpxSGSnJZuzXYuvX/vUc8olJbrXw4Bn24sf5dZI9FqFm8 wVmISFu5iCqQXNQjk1gCLYuuaEaW/AQkHXWvnLO2Igs+/l2XRKa0P6tZUR8+LTKlDzTe 3kRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=iJFm1+6l; 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 12si8037524iod.182.2017.08.07.01.56.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:56:08 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=iJFm1+6l; 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 1dedoH-0005dp-IZ; Mon, 07 Aug 2017 08:54:49 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedoG-0005c9-LW for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:48 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 92/77-02033-7DA28895; Mon, 07 Aug 2017 08:54:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRtsrHtdqyP SoGMZn8X3LZOZHBg9Dn+4whLAGMWamZeUX5HAmnHk6Ue2gtmaFWeXnmNvYDyg1MXIxSEkMJNR Yn3jRlYQh0VgHrPElss32EAcCYF+VolNTxsZuxg5gZw0iRl790PZlRJf9rwHs4UEtCSOnprNC jGqjUni4fJ2IIeDg03ARGJWhwRIjYiAksS9VZOZQGxmgedMEtMu6YDYwgKREm++dbKD2CwCqh JTvj9kA7F5BXwkVi9/wQ6xS07i5rlOZhCbEyh+/tIbFoi93hK3j/UxTmAUWMDIsIpRozi1qCy 1SNfQQi+pKDM9oyQ3MTNH19DAVC83tbg4MT01JzGpWC85P3cTIzC0GIBgB2PTds9DjJIcTEqi vPEr2iKF+JLyUyozEosz4otKc1KLDzHKcHAoSfAmaHZECgkWpaanVqRl5gCDHCYtwcGjJML7Q h0ozVtckJhbnJkOkTrFaMwx6cD2L0wcryb8/8YkxJKXn5cqJc6bAzJJAKQ0ozQPbhAs+i4xyk oJ8zICnSbEU5BalJtZgir/ilGcg1FJmFcaZApPZl4J3L5XQKcwAZ3yJrEV5JSSRISUVANjb/x 2re2fTeOjZuVcd9r2acWFz1Enm/21VXb6H7mzQbFk0poLRdEftHhqld0Wcaz7sCUk2cI6Usvv TcebdI6YNQ5dpq9CJ1qULvjFz/tE/W/c5TIXi7uhx45flnz9/Xh/w6cvXUdZ9qpsmfFcqmav3 /nFC6Y8Dxe5IsetqMvdJm5cVh92ro9TiaU4I9FQi7moOBEASEGeOrkCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-206.messagelabs.com!1502096086!103296258!1 X-Originating-IP: [74.125.83.51] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64451 invoked from network); 7 Aug 2017 08:54:46 -0000 Received: from mail-pg0-f51.google.com (HELO mail-pg0-f51.google.com) (74.125.83.51) by server-6.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:46 -0000 Received: by mail-pg0-f51.google.com with SMTP id y129so31675153pgy.4 for ; Mon, 07 Aug 2017 01:54: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=/YU+lh7b+xjfpV/n67+Fd1NKvfR4PopWuB/GOGrHOw4=; b=iJFm1+6lVaZahes8SMQqUoWF9hRLkJfVqioolugQ+1Uv7e2vCxw9Cwy/fenu9HHicV jWRykzb6fxhVAt5L2uD1cJ/k8yguh49Z/c60qUFYDWWnGxF4qWHBywyOgy8cxYRViOom fBbKlH1Tj8D+wCzgnRHGtZv0k7G3yACS8A02U= 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=/YU+lh7b+xjfpV/n67+Fd1NKvfR4PopWuB/GOGrHOw4=; b=C4aYsTmFBOiitW4jxyDUsEsMx2ZOvBG/IR6kzfN69GAT+logpBAMDEGleXCen9qTUO JnV6aFzkW16xZ2rJ9NCRlKI7OI7+5f37fHeTd34OZ/TR5Th4zmgctNwxMo1ydMkqnIUL e5Uebftgj5PKg9tMR1M4/c2I0Sb4NPgi8t1nRRlH8bbzQ9GUHqn943iqE0zxY6V1l8hL r/RLU4vZg5+3kjFQqlfHhwGSM4GAG2kXBZlU18dNpA4OT5Twrvtq3Adf65/7dmR3OfMG K9QY4G9ZmgcL4M+tRPcAIDI0+Vv93uML34eIW5+zVxYKlrA7sPXMqcHfc5XD3xp51Gyt B74g== X-Gm-Message-State: AIVw113wTPnm1UCNJ7e7DQ8H3/n90VzYgaIkDiCjG5gwp1ve2CuScr0U J4daAp5DAW9HYON3IQU+yg== X-Received: by 10.84.217.70 with SMTP id e6mr13634070plj.414.1502096085342; Mon, 07 Aug 2017 01:54:45 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:44 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:17 +0530 Message-Id: <1502095997-31219-26-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 25/25 v7] xen/arm: vpl011: Update documentation for vuart console support X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 1. Update documentation for a new vuart option added. 2. Update documentation about SPI irq reserved for vuart. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Andrew Cooper CC: George Dunlap CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Julien Grall Changes since v6: - Added a new section for vuart usage. - I have retained the reviewed-by/acked-by tags as this is a limited change. Kindly review. Changes since v4: - Minor change to rename "pl011" to "sbsa_uart". Since it is a minor change I have retained the reviewed-by and acked-by tags. docs/man/xl.cfg.pod.5.in | 12 ++++++++++++ docs/misc/console.txt | 44 +++++++++++++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in index 79cb2ea..8a38cf7 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -1105,6 +1105,9 @@ Allow a guest to access specific physical IRQs. It is recommended to only use this option for trusted VMs under administrator's control. +If vuart console is enabled then irq 32 is reserved for it. See +L to know how to enable vuart console. + =item B Limit the guest to using at most N event channels (PV interrupts). @@ -2171,6 +2174,15 @@ the domain was created. This requires hardware compatibility with the requested version, either natively or via hardware backwards compatibility support. +=item B + +To enable vuart console, user must specify the following option in the +VM config file: + +vuart = "sbsa_uart" + +Currently, only the "sbsa_uart" model is supported for AArch32 and AARCH64. + =back =head3 x86 diff --git a/docs/misc/console.txt b/docs/misc/console.txt index 16da805..d081acc 100644 --- a/docs/misc/console.txt +++ b/docs/misc/console.txt @@ -19,7 +19,20 @@ The first PV console path in xenstore remains: /local/domain/$DOMID/console -the other PV consoles follow the conventional xenstore device path and +The virtual UART console path in xenstore is defined as: + +/local/domain/$DOMID/vuart/0 + +The vuart console provides access to a virtual SBSA UART on 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.