From patchwork Thu Jun 22 07:38:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106159 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327080qgd; Thu, 22 Jun 2017 00:41:09 -0700 (PDT) X-Received: by 10.107.137.224 with SMTP id t93mr916414ioi.215.1498117269026; Thu, 22 Jun 2017 00:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117269; cv=none; d=google.com; s=arc-20160816; b=ZqP0h3MaJ/gEL+6PlCdbkbx5hSZRsncQUPJ44nuYpTZZ2qFRE+5DO7fSwav8MH34TY 4c+CfW9EU1leJ7NTWBQqJxSd8SS6cvr8SoBriGzCFDfel5VQlAfETkEdOfoFD1FFhqcm fQaqRt1DQky9gXQvaZoD7dfZmc/GlwaIJS7dFvDYkYgAwW64j3Fdgd1IKUA4nj0ba03/ YpIn3UUoVPtaHpsbNN038ONqEZg6NHfz68k9UVypx5aUQmFZcXsP4xKgj3NZM4eza2mi tc3kmgcNJwVhL6CiJJkz33eWuTeTD4EioTZfaxozyRfQOTWfk0HJhRydTNIF67lsoa+u 0o9g== 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=K8MepCcWbaM1v7rUHMhIbWsr2ssUwnQcCfbsxoUIq5g=; b=rhZvgSn6mdmTwJoNf2n23MwXl6YrtA3Ec/pZQIQTcXJJVxbWMPRQveobxVWhXLEJTw CcnbRcLs9cjHqX/cExEKBeEWzaHIWbXt8rNYnsML02s+m6m6yrTe7rxImmLe5EWv4DS0 I7cXpqDbUFAbVb0YblSSHI/9iuV8oo4E5W7FJY4Ong8bJqTBnBxa9xZi9XztgWDvLHaH s7L/h5LfMarxc2ykAQiBBwbSFN2E78cXreIqBnZVOaoNg/UkXJIFpKHqvbgzB7l0JQZr ocn4K9nQrbKZ3pbFr81bbFsKIV6XhwIlY5vat6Rr1yFuzmAtA38rFzdUU7seZOxmQjFp Te8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=UYDxRs1W; 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 g66si384987ite.33.2017.06.22.00.41.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:09 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=UYDxRs1W; 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 1dNwhn-0005M5-10; Thu, 22 Jun 2017 07:39: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 1dNwhl-0005Lx-LP for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:05 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id F4/75-03587-9147B495; Thu, 22 Jun 2017 07:39:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRtsqite4h1 pcLtR0eL7lslMDowehz9cYQlgjGLNzEvKr0hgzbgy9SZbwaOYiqbH/cwNjA26XYxcHEIC0xkl Ns46zNzFyMnBIjCPWeL+5hKQhIRAP6vE/3mTWEASEgJpEhdn9jNC2KUSVzZ8YAKxhQS0JI6em s0KMWkfk8SWuS+BGjg42ARMJGZ1SIDUiAgoSdxbNRmsnlkgVGLq3wdgM4UFIiQu3X7FDrFYVe LM+V9gNq+At8T+xY+hdslJ3DzXCXYcp4CPxIodC9kh9npL7DozmWUCo8ACRoZVjBrFqUVlqUW 6hhZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBgcUABDsYb24MOMQoycGkJMr7 P887UogvKT+lMiOxOCO+qDQntfgQowwHh5IEr3IxUE6wKDU9tSItMwcY4jBpCQ4eJRHeFpBW3 uKCxNzizHSI1ClGXY5JB7Z/YRJiycvPS5US5xUFmSEAUpRRmgc3AhZvlxhlpYR5GYGOEuIpSC 3KzSxBlX/FKM7BqCTMq18ENIUnM68EbtMroCOYgI54ccQD5IiSRISUVANjaUTKO9tzFu1/Lvz Tst1QwqnaxVx16/HeJblZTlNfrBT4+c/igcwJnjITpStPo5eG5N/xNj5d8FLuXJudbfx8//Y2 hx/OJq53GY8IfIw5sHXTLKVznSnqThGLPy5a/ztJovxw7rJneUcu5X6bbayW+ZPj+JfZvxj7s m66fxb43Xllnuu7D5O/KLEUZyQaajEXFScCADpW1xGyAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-27.messagelabs.com!1498117142!108617873!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27297 invoked from network); 22 Jun 2017 07:39:03 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:03 -0000 Received: by mail-pg0-f53.google.com with SMTP id 132so4595069pgb.2 for ; Thu, 22 Jun 2017 00:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ergX24LkDyucmW8DNUkM0l5+x6mXgADMjGmtE43wGx8=; b=UYDxRs1WX3I4uZHA9yvMW6Nr6oqMPnwDn7Ks4xycx5GrYDdgpL+X8sOw5q+8RPITvR zxg9+2GO3fIAd2EiaCBAU12TdBGAXIoAI8uUDRXBK8g78N3VE9RfB0a+N6RW35gO2ivQ nelKI/qQ5h65H9BsMYLJW/fCpY482n06Hvxos= 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=ergX24LkDyucmW8DNUkM0l5+x6mXgADMjGmtE43wGx8=; b=AQRAV2yqHBBQXuMQTL19DY7OWOHJbbSILZVQ92mnA0M7Y6wC3FF72JGJ2eJE+Hppb7 o8mRWuGKBgFqG78E9rf3f/HTLp3LsSx3YRNdlNeL0AlYPNJwy7EbebueHzTxNP3s8efX RM7+nXZsuu6+Dhh5d/TsHc5ZaEuNCM0DRwwNMjF1+j/5CEcvrDmOGK20GvCzNlJcjS/E cTQcQhy7zA70jAj2Qg6bcVmws6Pix/3RmKanUBHKBxbdKOboVFupavrwCC9uHMLjP6GC mye75D3yuKz+inMbmcGqNR15BCr0ydmKBXJpnCh7ul7ybfUIGr3+H/+2cVVlmB6glHWG rEMw== X-Gm-Message-State: AKS2vOxZd9fR6tx5JWmf5phlwKZtzP1i2kCRyBj+maVQfaE/ewGnCou6 hMAyRtEQcUDIH9WuSam0Sw== X-Received: by 10.84.231.9 with SMTP id f9mr1426242plk.5.1498117141598; Thu, 22 Jun 2017 00:39:01 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.38.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:01 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:36 +0530 Message-Id: <1498117132-27139-2-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 01/17 v5] xen/arm: vpl011: Move vgic register access functions to vreg.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" These functions are generic in nature and can be reused by other emulation code in Xen. vGICv3 ITS and SBSA UART emulation code, would use these functions to operate on their registers. This patch moves the register access function definitions from vgic.h to vreg.h. Signed-off-by: Bhupinder Thakur Acked-by: Julien Grall --- CC: Stefano Stabellini CC: Julien Grall Changes since v3: - Moved the macro call VGIC_REG_HELPERS to vreg.h from vgic.h. xen/include/asm-arm/vgic.h | 111 +-------------------------------------------- xen/include/asm-arm/vreg.h | 110 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 110 deletions(-) diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index 9ff713c..d4ed23d 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -20,6 +20,7 @@ #include #include +#include struct pending_irq { @@ -182,116 +183,6 @@ static inline int REG_RANK_NR(int b, uint32_t n) } } -#define VGIC_REG_MASK(size) ((~0UL) >> (BITS_PER_LONG - ((1 << (size)) * 8))) - -/* - * The check on the size supported by the register has to be done by - * the caller of vgic_regN_*. - * - * vgic_reg_* should never be called directly. Instead use the vgic_regN_* - * according to size of the emulated register - * - * Note that the alignment fault will always be taken in the guest - * (see B3.12.7 DDI0406.b). - */ -static inline register_t vgic_reg_extract(unsigned long reg, - unsigned int offset, - enum dabt_size size) -{ - reg >>= 8 * offset; - reg &= VGIC_REG_MASK(size); - - return reg; -} - -static inline void vgic_reg_update(unsigned long *reg, register_t val, - unsigned int offset, - enum dabt_size size) -{ - unsigned long mask = VGIC_REG_MASK(size); - int shift = offset * 8; - - *reg &= ~(mask << shift); - *reg |= ((unsigned long)val & mask) << shift; -} - -static inline void vgic_reg_setbits(unsigned long *reg, register_t bits, - unsigned int offset, - enum dabt_size size) -{ - unsigned long mask = VGIC_REG_MASK(size); - int shift = offset * 8; - - *reg |= ((unsigned long)bits & mask) << shift; -} - -static inline void vgic_reg_clearbits(unsigned long *reg, register_t bits, - unsigned int offset, - enum dabt_size size) -{ - unsigned long mask = VGIC_REG_MASK(size); - int shift = offset * 8; - - *reg &= ~(((unsigned long)bits & mask) << shift); -} - -/* N-bit register helpers */ -#define VGIC_REG_HELPERS(sz, offmask) \ -static inline register_t vgic_reg##sz##_extract(uint##sz##_t reg, \ - const mmio_info_t *info)\ -{ \ - return vgic_reg_extract(reg, info->gpa & offmask, \ - info->dabt.size); \ -} \ - \ -static inline void vgic_reg##sz##_update(uint##sz##_t *reg, \ - register_t val, \ - const mmio_info_t *info) \ -{ \ - unsigned long tmp = *reg; \ - \ - vgic_reg_update(&tmp, val, info->gpa & offmask, \ - info->dabt.size); \ - \ - *reg = tmp; \ -} \ - \ -static inline void vgic_reg##sz##_setbits(uint##sz##_t *reg, \ - register_t bits, \ - const mmio_info_t *info) \ -{ \ - unsigned long tmp = *reg; \ - \ - vgic_reg_setbits(&tmp, bits, info->gpa & offmask, \ - info->dabt.size); \ - \ - *reg = tmp; \ -} \ - \ -static inline void vgic_reg##sz##_clearbits(uint##sz##_t *reg, \ - register_t bits, \ - const mmio_info_t *info) \ -{ \ - unsigned long tmp = *reg; \ - \ - vgic_reg_clearbits(&tmp, bits, info->gpa & offmask, \ - info->dabt.size); \ - \ - *reg = tmp; \ -} - -/* - * 64 bits registers are only supported on platform with 64-bit long. - * This is also allow us to optimize the 32 bit case by using - * unsigned long rather than uint64_t - */ -#if BITS_PER_LONG == 64 -VGIC_REG_HELPERS(64, 0x7); -#endif -VGIC_REG_HELPERS(32, 0x3); - -#undef VGIC_REG_HELPERS - enum gic_sgi_mode; /* diff --git a/xen/include/asm-arm/vreg.h b/xen/include/asm-arm/vreg.h index ed2bd6f..348584f 100644 --- a/xen/include/asm-arm/vreg.h +++ b/xen/include/asm-arm/vreg.h @@ -107,4 +107,114 @@ static inline bool vreg_emulate_sysreg64(struct cpu_user_regs *regs, union hsr h #endif +#define VGIC_REG_MASK(size) ((~0UL) >> (BITS_PER_LONG - ((1 << (size)) * 8))) + +/* + * The check on the size supported by the register has to be done by + * the caller of vgic_regN_*. + * + * vgic_reg_* should never be called directly. Instead use the vgic_regN_* + * according to size of the emulated register + * + * Note that the alignment fault will always be taken in the guest + * (see B3.12.7 DDI0406.b). + */ +static inline register_t vgic_reg_extract(unsigned long reg, + unsigned int offset, + enum dabt_size size) +{ + reg >>= 8 * offset; + reg &= VGIC_REG_MASK(size); + + return reg; +} + +static inline void vgic_reg_update(unsigned long *reg, register_t val, + unsigned int offset, + enum dabt_size size) +{ + unsigned long mask = VGIC_REG_MASK(size); + int shift = offset * 8; + + *reg &= ~(mask << shift); + *reg |= ((unsigned long)val & mask) << shift; +} + +static inline void vgic_reg_setbits(unsigned long *reg, register_t bits, + unsigned int offset, + enum dabt_size size) +{ + unsigned long mask = VGIC_REG_MASK(size); + int shift = offset * 8; + + *reg |= ((unsigned long)bits & mask) << shift; +} + +static inline void vgic_reg_clearbits(unsigned long *reg, register_t bits, + unsigned int offset, + enum dabt_size size) +{ + unsigned long mask = VGIC_REG_MASK(size); + int shift = offset * 8; + + *reg &= ~(((unsigned long)bits & mask) << shift); +} + +/* N-bit register helpers */ +#define VGIC_REG_HELPERS(sz, offmask) \ +static inline register_t vgic_reg##sz##_extract(uint##sz##_t reg, \ + const mmio_info_t *info)\ +{ \ + return vgic_reg_extract(reg, info->gpa & offmask, \ + info->dabt.size); \ +} \ + \ +static inline void vgic_reg##sz##_update(uint##sz##_t *reg, \ + register_t val, \ + const mmio_info_t *info) \ +{ \ + unsigned long tmp = *reg; \ + \ + vgic_reg_update(&tmp, val, info->gpa & offmask, \ + info->dabt.size); \ + \ + *reg = tmp; \ +} \ + \ +static inline void vgic_reg##sz##_setbits(uint##sz##_t *reg, \ + register_t bits, \ + const mmio_info_t *info) \ +{ \ + unsigned long tmp = *reg; \ + \ + vgic_reg_setbits(&tmp, bits, info->gpa & offmask, \ + info->dabt.size); \ + \ + *reg = tmp; \ +} \ + \ +static inline void vgic_reg##sz##_clearbits(uint##sz##_t *reg, \ + register_t bits, \ + const mmio_info_t *info) \ +{ \ + unsigned long tmp = *reg; \ + \ + vgic_reg_clearbits(&tmp, bits, info->gpa & offmask, \ + info->dabt.size); \ + \ + *reg = tmp; \ +} + +/* + * 64 bits registers are only supported on platform with 64-bit long. + * This is also allow us to optimize the 32 bit case by using + * unsigned long rather than uint64_t + */ +#if BITS_PER_LONG == 64 +VGIC_REG_HELPERS(64, 0x7); +#endif +VGIC_REG_HELPERS(32, 0x3); + +#undef VGIC_REG_HELPERS + #endif /* __ASM_ARM_VREG__ */ From patchwork Thu Jun 22 07:38:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106170 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327160qgd; Thu, 22 Jun 2017 00:41:25 -0700 (PDT) X-Received: by 10.107.19.148 with SMTP id 20mr964724iot.0.1498117285170; Thu, 22 Jun 2017 00:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117285; cv=none; d=google.com; s=arc-20160816; b=pLXHC94a3tiMYG1X+EKrc0qwRE95unlYpTI9Q+tcc6wQvz2XMpItPwAorAlOsJpHdW XP0m1lOXnmXJ+g8hG8IPdROhtSGDpf8D4eF5CzZxYq1cvyWS3sK+xteTiIWFmnsIzljB c/p+vZJh8ZkmkOXh1qfrF3dHzt4aRWFXZyKmS1qMfX2lOt43YdZ4yZyiUQFecVmDvgZH MCL+q32ZSay/kbOp6LDdLxDiZwbgpuOflLQMNrvMTK0kRDh/+hziUpagJbI8dGY8knWo Us6Sr6RDEaLxVJGy4COJNO706iss3KjiBTwSgHZ2zgj/YW4pjTAjaCpVIbKHlAHLEX6i UfhQ== 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=Vl3DWcFSST8F85MnHTHa1ftrovwNf7FIhyBPybSObvA=; b=j5pwlzlbT+nbrf0kFNaAML2WCMPJLbF2WW8GiMg50qFGRd1VjnsTJxDBH+zMxL+npV ivb5OHzyyKnGNtCZDANgsJktKwBCJvS2FRkF/nHqadGNdfbffD6Ls/1FHAGb8y33ykXX Wchf7WOQIBwRfrXR41UNGWLD8KKAOdU+Ab10ndyBuYuZBuCNPZcwVYR61eI6NCg7Ty5c Bf6z4TMs6hM/osBEowqV1wU3tqS0B1FOgjqrMjXJGrqZysneiB4pDd0w30Bi8hFox3SP L439QyrtqTOKTlaFdLWIEUQpWzwrfiY9+NJZV30UGLpWtgFy7t6dX0jxq3VrYCRktyvm wc4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=jwZLlCma; 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 81si697784ioc.142.2017.06.22.00.41.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:25 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=jwZLlCma; 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 1dNwhp-0005Mv-C8; Thu, 22 Jun 2017 07:39:09 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwho-0005MY-3G for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:08 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 2F/F9-31580-B147B495; Thu, 22 Jun 2017 07:39:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsVyMfTANl2pEu9 Ig99vpSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owpa0+yF0x6xFhxdvsrxgbGR3MYuxi5OIQE pjNKrHg9iQnEYRGYxyzx7f5k5i5GTg4JgX5WiVObhCDsNIkjS2azQdiVEq2X9rKA2EICWhJHT 81mhZi0j0ni8oJfQJM4ONgETCRmdUiA1IgIKEncWzWZCcRmFqiXWLRpG1ivsECGxMLTm8BsFg FViY1XdoLV8Ap4S5y/3MYIsUtO4ua5TrB7OAV8JFbsWMgOsddbYteZySwTGAUWMDKsYtQoTi0 qSy3SNbLUSyrKTM8oyU3MzNE1NDDWy00tLk5MT81JTCrWS87P3cQIDK56BgbGHYxNe/0OMUpy MCmJ8v7P844U4kvKT6nMSCzOiC8qzUktPsQow8GhJME7rwgoJ1iUmp5akZaZAwxzmLQEB4+SC G8LSCtvcUFibnFmOkTqFKMxx5Ur674wcUw5sP0LkxBLXn5eqpQ472yQSQIgpRmleXCDYPF3iV FWSpiXkYGBQYinILUoN7MEVf4VozgHo5Iwrz7IFJ7MvBK4fa+ATmECOuXFEQ+QU0oSEVJSDYz TntkuYrK9mM20a+PM4j2OHd5liVKO+/MFdkQlv1D20g5j67rzJz31fB2b8h2Nu1cXLlA3Mmjk WzFXb4+BaNhcJcFYg0/Rf3fsuaL7j+XKws3vXa7y/LuRpSTwg+uyVOSHVIsXXuGXXX+riiga/ K18sL1f4MMUy3X667ZvOX8nLlzv1+NmJ2slluKMREMt5qLiRABSDNaYugIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-2.tower-31.messagelabs.com!1498117145!95151093!1 X-Originating-IP: [209.85.192.182] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 59286 invoked from network); 22 Jun 2017 07:39:05 -0000 Received: from mail-pf0-f182.google.com (HELO mail-pf0-f182.google.com) (209.85.192.182) by server-2.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:05 -0000 Received: by mail-pf0-f182.google.com with SMTP id e7so5149663pfk.0 for ; Thu, 22 Jun 2017 00:39: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=0StoeHQ4k8aiQ/S/1JJwZXbWs9VjN2VDxa7jM98mO0w=; b=jwZLlCmachMnIEhu6h4N2TuhFFvWQAOlI0+IhiihkiRwQ0QbBub9Fe1R4akDQFe4ul WbjMwNfBrOAaX2fPqrA4IEXqBvmmRt1FnqUA+ncrI4QGhg1yx3/1hECy21+260UL1C9E xQOJBcSy67B2fxXCKmlkLC6H4YKhnHikPK7fo= 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=0StoeHQ4k8aiQ/S/1JJwZXbWs9VjN2VDxa7jM98mO0w=; b=iQHAaiSCGai9fca8Bphk6V8VcSDkmEoDaW0jbzJWctrvmG2RUvA3EZksP8kuk9pW8d 4GxB+XoZWKa0cE5G4N+Z/+qOGfyKc0M8Y49353SuDOGn6Osogukz7aKIsyshCjPAUrA/ fGXD6Vagm45dRwaXOW4KRghP3eAftej5toNaripHr9LzLru8gVmhNxl71R7TKnDmkmft J1SSW2USMMW+5QXcTmvGm5a1e0wVh/98kfazCdWI7QAnsXuW3cYzG8ifPqTCOlsQu4Z0 +fhzoUPq//2JolHemi65eOLAtDREAx2q+wMEwhoTa4KqF/WaphFhB3/Pod5Jxeujz6fv VCQw== X-Gm-Message-State: AKS2vOycPTAxVbEepHJnK+t0FznDBdkY34Js8kJkRi8iH3Dg+nV7a4CR 3z+yHyVwau2SmBELcSrWjg== X-Received: by 10.84.164.106 with SMTP id m39mr1407686plg.92.1498117144341; Thu, 22 Jun 2017 00:39:04 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:03 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:37 +0530 Message-Id: <1498117132-27139-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Andre Przywara , Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 02/17 v5] xen/arm: vpl011: Rename vgic_reg* functions definitions and calls to vreg_reg* 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 renames the vgic_reg* access functions defined in vreg.h to vreg_reg* and replaces all calls to vgic_reg* functions in vgic/its emulation code to vreg_reg*. vreg_reg* are generic functions, which can be used to operate on 32/64-bit registers. SBSA UART emulation code will also use vreg_reg* access functions for accessing emulated pl011 registers. Signed-off-by: Bhupinder Thakur Reviewed-by: Julien Grall --- CC: Stefano Stabellini CC: Julien Grall CC: Andre Przywara Changes since v4: - Renamed the vgic_reg* calls in ITS code to vreg_reg*. Changes since v3: - Renamed DEFINE_VREG_REG_HELPERS to VREG_REG_HELPERS. xen/arch/arm/vgic-v2.c | 28 +++++++++++++------------- xen/arch/arm/vgic-v3-its.c | 28 +++++++++++++------------- xen/arch/arm/vgic-v3.c | 50 +++++++++++++++++++++++----------------------- xen/include/asm-arm/vreg.h | 46 +++++++++++++++++++++--------------------- 4 files changed, 76 insertions(+), 76 deletions(-) diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index eb5f354..cf4ab89 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -179,7 +179,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info, case VREG32(GICD_CTLR): if ( dabt.size != DABT_WORD ) goto bad_width; vgic_lock(v); - *r = vgic_reg32_extract(v->domain->arch.vgic.ctlr, info); + *r = vreg_reg32_extract(v->domain->arch.vgic.ctlr, info); vgic_unlock(v); return 1; @@ -194,7 +194,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info, | DIV_ROUND_UP(v->domain->arch.vgic.nr_spis, 32); vgic_unlock(v); - *r = vgic_reg32_extract(typer, info); + *r = vreg_reg32_extract(typer, info); return 1; } @@ -205,7 +205,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info, * XXX Do we need a JEP106 manufacturer ID? * Just use the physical h/w value for now */ - *r = vgic_reg32_extract(0x0000043b, info); + *r = vreg_reg32_extract(0x0000043b, info); return 1; case VRANGE32(0x00C, 0x01C): @@ -226,7 +226,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info, rank = vgic_rank_offset(v, 1, gicd_reg - GICD_ISENABLER, DABT_WORD); if ( rank == NULL) goto read_as_zero; vgic_lock_rank(v, rank, flags); - *r = vgic_reg32_extract(rank->ienable, info); + *r = vreg_reg32_extract(rank->ienable, info); vgic_unlock_rank(v, rank, flags); return 1; @@ -235,7 +235,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info, rank = vgic_rank_offset(v, 1, gicd_reg - GICD_ICENABLER, DABT_WORD); if ( rank == NULL) goto read_as_zero; vgic_lock_rank(v, rank, flags); - *r = vgic_reg32_extract(rank->ienable, info); + *r = vreg_reg32_extract(rank->ienable, info); vgic_unlock_rank(v, rank, flags); return 1; @@ -262,7 +262,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info, vgic_lock_rank(v, rank, flags); ipriorityr = ACCESS_ONCE(rank->ipriorityr[rank_index]); vgic_unlock_rank(v, rank, flags); - *r = vgic_reg32_extract(ipriorityr, info); + *r = vreg_reg32_extract(ipriorityr, info); return 1; } @@ -280,7 +280,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info, vgic_lock_rank(v, rank, flags); itargetsr = vgic_fetch_itargetsr(rank, gicd_reg - GICD_ITARGETSR); vgic_unlock_rank(v, rank, flags); - *r = vgic_reg32_extract(itargetsr, info); + *r = vreg_reg32_extract(itargetsr, info); return 1; } @@ -299,7 +299,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info, icfgr = rank->icfg[REG_RANK_INDEX(2, gicd_reg - GICD_ICFGR, DABT_WORD)]; vgic_unlock_rank(v, rank, flags); - *r = vgic_reg32_extract(icfgr, info); + *r = vreg_reg32_extract(icfgr, info); return 1; } @@ -424,7 +424,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info, if ( dabt.size != DABT_WORD ) goto bad_width; /* Ignore all but the enable bit */ vgic_lock(v); - vgic_reg32_update(&v->domain->arch.vgic.ctlr, r, info); + vreg_reg32_update(&v->domain->arch.vgic.ctlr, r, info); v->domain->arch.vgic.ctlr &= GICD_CTL_ENABLE; vgic_unlock(v); @@ -454,7 +454,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info, if ( rank == NULL) goto write_ignore; vgic_lock_rank(v, rank, flags); tr = rank->ienable; - vgic_reg32_setbits(&rank->ienable, r, info); + vreg_reg32_setbits(&rank->ienable, r, info); vgic_enable_irqs(v, (rank->ienable) & (~tr), rank->index); vgic_unlock_rank(v, rank, flags); return 1; @@ -465,7 +465,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info, if ( rank == NULL) goto write_ignore; vgic_lock_rank(v, rank, flags); tr = rank->ienable; - vgic_reg32_clearbits(&rank->ienable, r, info); + vreg_reg32_clearbits(&rank->ienable, r, info); vgic_disable_irqs(v, (~rank->ienable) & tr, rank->index); vgic_unlock_rank(v, rank, flags); return 1; @@ -509,7 +509,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info, gicd_reg - GICD_IPRIORITYR, DABT_WORD)]; priority = ACCESS_ONCE(*ipriorityr); - vgic_reg32_update(&priority, r, info); + vreg_reg32_update(&priority, r, info); ACCESS_ONCE(*ipriorityr) = priority; vgic_unlock_rank(v, rank, flags); @@ -532,7 +532,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info, if ( rank == NULL) goto write_ignore; vgic_lock_rank(v, rank, flags); itargetsr = vgic_fetch_itargetsr(rank, gicd_reg - GICD_ITARGETSR); - vgic_reg32_update(&itargetsr, r, info); + vreg_reg32_update(&itargetsr, r, info); vgic_store_itargetsr(v->domain, rank, gicd_reg - GICD_ITARGETSR, itargetsr); vgic_unlock_rank(v, rank, flags); @@ -554,7 +554,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info, rank = vgic_rank_offset(v, 2, gicd_reg - GICD_ICFGR, DABT_WORD); if ( rank == NULL) goto write_ignore; vgic_lock_rank(v, rank, flags); - vgic_reg32_update(&rank->icfg[REG_RANK_INDEX(2, gicd_reg - GICD_ICFGR, + vreg_reg32_update(&rank->icfg[REG_RANK_INDEX(2, gicd_reg - GICD_ICFGR, DABT_WORD)], r, info); vgic_unlock_rank(v, rank, flags); diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index bfc5acc..9ef792f 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -1015,13 +1015,13 @@ static int vgic_v3_its_mmio_read(struct vcpu *v, mmio_info_t *info, if ( have_cmd_lock ) spin_unlock(&its->vcmd_lock); - *r = vgic_reg32_extract(reg, info); + *r = vreg_reg32_extract(reg, info); break; } case VREG32(GITS_IIDR): if ( info->dabt.size != DABT_WORD ) goto bad_width; - *r = vgic_reg32_extract(GITS_IIDR_VALUE, info); + *r = vreg_reg32_extract(GITS_IIDR_VALUE, info); break; case VREG64(GITS_TYPER): @@ -1031,7 +1031,7 @@ static int vgic_v3_its_mmio_read(struct vcpu *v, mmio_info_t *info, reg |= (sizeof(struct vits_itte) - 1) << GITS_TYPER_ITT_SIZE_SHIFT; reg |= (its->evid_bits - 1) << GITS_TYPER_IDBITS_SHIFT; reg |= (its->devid_bits - 1) << GITS_TYPER_DEVIDS_SHIFT; - *r = vgic_reg64_extract(reg, info); + *r = vreg_reg64_extract(reg, info); break; case VRANGE32(0x0018, 0x001C): @@ -1044,7 +1044,7 @@ static int vgic_v3_its_mmio_read(struct vcpu *v, mmio_info_t *info, case VREG64(GITS_CBASER): if ( !vgic_reg64_check_access(info->dabt) ) goto bad_width; spin_lock(&its->its_lock); - *r = vgic_reg64_extract(its->cbaser, info); + *r = vreg_reg64_extract(its->cbaser, info); spin_unlock(&its->its_lock); break; @@ -1053,7 +1053,7 @@ static int vgic_v3_its_mmio_read(struct vcpu *v, mmio_info_t *info, /* CWRITER is only written by the guest, so no extra locking here. */ reg = its->cwriter; - *r = vgic_reg64_extract(reg, info); + *r = vreg_reg64_extract(reg, info); break; case VREG64(GITS_CREADR): @@ -1066,7 +1066,7 @@ static int vgic_v3_its_mmio_read(struct vcpu *v, mmio_info_t *info, * progress. */ reg = read_u64_atomic(&its->creadr); - *r = vgic_reg64_extract(reg, info); + *r = vreg_reg64_extract(reg, info); break; case VRANGE64(0x0098, 0x00F8): @@ -1075,14 +1075,14 @@ static int vgic_v3_its_mmio_read(struct vcpu *v, mmio_info_t *info, case VREG64(GITS_BASER0): /* device table */ if ( !vgic_reg64_check_access(info->dabt) ) goto bad_width; spin_lock(&its->its_lock); - *r = vgic_reg64_extract(its->baser_dev, info); + *r = vreg_reg64_extract(its->baser_dev, info); spin_unlock(&its->its_lock); break; case VREG64(GITS_BASER1): /* collection table */ if ( !vgic_reg64_check_access(info->dabt) ) goto bad_width; spin_lock(&its->its_lock); - *r = vgic_reg64_extract(its->baser_coll, info); + *r = vreg_reg64_extract(its->baser_coll, info); spin_unlock(&its->its_lock); break; @@ -1097,7 +1097,7 @@ static int vgic_v3_its_mmio_read(struct vcpu *v, mmio_info_t *info, case VREG32(GITS_PIDR2): if ( info->dabt.size != DABT_WORD ) goto bad_width; - *r = vgic_reg32_extract(GIC_PIDR2_ARCH_GICv3, info); + *r = vreg_reg32_extract(GIC_PIDR2_ARCH_GICv3, info); break; case VRANGE32(0xFFEC, 0xFFFC): @@ -1258,7 +1258,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmio_info_t *info, spin_lock(&its->its_lock); ctlr = its->enabled ? GITS_CTLR_ENABLE : 0; reg32 = ctlr; - vgic_reg32_update(®32, r, info); + vreg_reg32_update(®32, r, info); if ( ctlr ^ reg32 ) its->enabled = vgic_v3_verify_its_status(its, @@ -1295,7 +1295,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmio_info_t *info, } reg = its->cbaser; - vgic_reg64_update(®, r, info); + vreg_reg64_update(®, r, info); sanitize_its_base_reg(®); its->cbaser = reg; @@ -1309,7 +1309,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmio_info_t *info, spin_lock(&its->vcmd_lock); reg = ITS_CMD_OFFSET(its->cwriter); - vgic_reg64_update(®, r, info); + vreg_reg64_update(®, r, info); its->cwriter = ITS_CMD_OFFSET(reg); if ( its->enabled ) @@ -1344,7 +1344,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmio_info_t *info, } reg = its->baser_dev; - vgic_reg64_update(®, r, info); + vreg_reg64_update(®, r, info); /* We don't support indirect tables for now. */ reg &= ~(GITS_BASER_RO_MASK | GITS_BASER_INDIRECT); @@ -1381,7 +1381,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmio_info_t *info, } reg = its->baser_coll; - vgic_reg64_update(®, r, info); + vreg_reg64_update(®, r, info); /* No indirect tables for the collection table. */ reg &= ~(GITS_BASER_RO_MASK | GITS_BASER_INDIRECT); reg |= (sizeof(coll_table_entry_t) - 1) << GITS_BASER_ENTRY_SIZE_SHIFT; diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index 4287ae1..48c7682 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -178,7 +178,7 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info, if ( dabt.size != DABT_WORD ) goto bad_width; spin_lock_irqsave(&v->arch.vgic.lock, flags); - *r = vgic_reg32_extract(!!(v->arch.vgic.flags & VGIC_V3_LPIS_ENABLED), + *r = vreg_reg32_extract(!!(v->arch.vgic.flags & VGIC_V3_LPIS_ENABLED), info); spin_unlock_irqrestore(&v->arch.vgic.lock, flags); return 1; @@ -186,7 +186,7 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info, case VREG32(GICR_IIDR): if ( dabt.size != DABT_WORD ) goto bad_width; - *r = vgic_reg32_extract(GICV3_GICR_IIDR_VAL, info); + *r = vreg_reg32_extract(GICV3_GICR_IIDR_VAL, info); return 1; case VREG64(GICR_TYPER): @@ -208,7 +208,7 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info, if ( v->domain->arch.vgic.has_its ) typer |= GICR_TYPER_PLPIS; - *r = vgic_reg64_extract(typer, info); + *r = vreg_reg64_extract(typer, info); return 1; } @@ -244,7 +244,7 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info, if ( !vgic_reg64_check_access(dabt) ) goto bad_width; vgic_lock(v); - *r = vgic_reg64_extract(v->domain->arch.vgic.rdist_propbase, info); + *r = vreg_reg64_extract(v->domain->arch.vgic.rdist_propbase, info); vgic_unlock(v); return 1; @@ -257,7 +257,7 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info, if ( !vgic_reg64_check_access(dabt) ) goto bad_width; spin_lock_irqsave(&v->arch.vgic.lock, flags); - *r = vgic_reg64_extract(v->arch.vgic.rdist_pendbase, info); + *r = vreg_reg64_extract(v->arch.vgic.rdist_pendbase, info); *r &= ~GICR_PENDBASER_PTZ; /* WO, reads as 0 */ spin_unlock_irqrestore(&v->arch.vgic.lock, flags); return 1; @@ -283,7 +283,7 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info, case VREG32(GICR_SYNCR): if ( dabt.size != DABT_WORD ) goto bad_width; /* RO . But when read it always returns busy bito bit[0] */ - *r = vgic_reg32_extract(GICR_SYNCR_NOT_BUSY, info); + *r = vreg_reg32_extract(GICR_SYNCR_NOT_BUSY, info); return 1; case 0x00C8: @@ -310,7 +310,7 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info, case VREG32(GICR_PIDR2): if ( dabt.size != DABT_WORD ) goto bad_width; - *r = vgic_reg32_extract(GICV3_GICR_PIDR2, info); + *r = vreg_reg32_extract(GICV3_GICR_PIDR2, info); return 1; case 0xFFEC ... 0xFFFC: @@ -354,7 +354,7 @@ read_reserved: return 1; read_unknown: - *r = vgic_reg64_extract(0xdeadbeafdeadbeaf, info); + *r = vreg_reg64_extract(0xdeadbeafdeadbeaf, info); return 1; } @@ -553,7 +553,7 @@ static int __vgic_v3_rdistr_rd_mmio_write(struct vcpu *v, mmio_info_t *info, if ( !(v->domain->arch.vgic.rdists_enabled) ) { reg = v->domain->arch.vgic.rdist_propbase; - vgic_reg64_update(®, r, info); + vreg_reg64_update(®, r, info); reg = sanitize_propbaser(reg); v->domain->arch.vgic.rdist_propbase = reg; } @@ -576,7 +576,7 @@ static int __vgic_v3_rdistr_rd_mmio_write(struct vcpu *v, mmio_info_t *info, if ( !(v->arch.vgic.flags & VGIC_V3_LPIS_ENABLED) ) { reg = v->arch.vgic.rdist_pendbase; - vgic_reg64_update(®, r, info); + vreg_reg64_update(®, r, info); reg = sanitize_pendbaser(reg); v->arch.vgic.rdist_pendbase = reg; } @@ -690,7 +690,7 @@ static int __vgic_v3_distr_common_mmio_read(const char *name, struct vcpu *v, rank = vgic_rank_offset(v, 1, reg - GICD_ISENABLER, DABT_WORD); if ( rank == NULL ) goto read_as_zero; vgic_lock_rank(v, rank, flags); - *r = vgic_reg32_extract(rank->ienable, info); + *r = vreg_reg32_extract(rank->ienable, info); vgic_unlock_rank(v, rank, flags); return 1; @@ -699,7 +699,7 @@ static int __vgic_v3_distr_common_mmio_read(const char *name, struct vcpu *v, rank = vgic_rank_offset(v, 1, reg - GICD_ICENABLER, DABT_WORD); if ( rank == NULL ) goto read_as_zero; vgic_lock_rank(v, rank, flags); - *r = vgic_reg32_extract(rank->ienable, info); + *r = vreg_reg32_extract(rank->ienable, info); vgic_unlock_rank(v, rank, flags); return 1; @@ -727,7 +727,7 @@ static int __vgic_v3_distr_common_mmio_read(const char *name, struct vcpu *v, ipriorityr = ACCESS_ONCE(rank->ipriorityr[rank_index]); vgic_unlock_rank(v, rank, flags); - *r = vgic_reg32_extract(ipriorityr, info); + *r = vreg_reg32_extract(ipriorityr, info); return 1; } @@ -743,7 +743,7 @@ static int __vgic_v3_distr_common_mmio_read(const char *name, struct vcpu *v, icfgr = rank->icfg[REG_RANK_INDEX(2, reg - GICD_ICFGR, DABT_WORD)]; vgic_unlock_rank(v, rank, flags); - *r = vgic_reg32_extract(icfgr, info); + *r = vreg_reg32_extract(icfgr, info); return 1; } @@ -787,7 +787,7 @@ static int __vgic_v3_distr_common_mmio_write(const char *name, struct vcpu *v, if ( rank == NULL ) goto write_ignore; vgic_lock_rank(v, rank, flags); tr = rank->ienable; - vgic_reg32_setbits(&rank->ienable, r, info); + vreg_reg32_setbits(&rank->ienable, r, info); vgic_enable_irqs(v, (rank->ienable) & (~tr), rank->index); vgic_unlock_rank(v, rank, flags); return 1; @@ -798,7 +798,7 @@ static int __vgic_v3_distr_common_mmio_write(const char *name, struct vcpu *v, if ( rank == NULL ) goto write_ignore; vgic_lock_rank(v, rank, flags); tr = rank->ienable; - vgic_reg32_clearbits(&rank->ienable, r, info); + vreg_reg32_clearbits(&rank->ienable, r, info); vgic_disable_irqs(v, (~rank->ienable) & tr, rank->index); vgic_unlock_rank(v, rank, flags); return 1; @@ -841,7 +841,7 @@ static int __vgic_v3_distr_common_mmio_write(const char *name, struct vcpu *v, ipriorityr = &rank->ipriorityr[REG_RANK_INDEX(8, reg - GICD_IPRIORITYR, DABT_WORD)]; priority = ACCESS_ONCE(*ipriorityr); - vgic_reg32_update(&priority, r, info); + vreg_reg32_update(&priority, r, info); ACCESS_ONCE(*ipriorityr) = priority; vgic_unlock_rank(v, rank, flags); return 1; @@ -857,7 +857,7 @@ static int __vgic_v3_distr_common_mmio_write(const char *name, struct vcpu *v, rank = vgic_rank_offset(v, 2, reg - GICD_ICFGR, DABT_WORD); if ( rank == NULL ) goto write_ignore; vgic_lock_rank(v, rank, flags); - vgic_reg32_update(&rank->icfg[REG_RANK_INDEX(2, reg - GICD_ICFGR, + vreg_reg32_update(&rank->icfg[REG_RANK_INDEX(2, reg - GICD_ICFGR, DABT_WORD)], r, info); vgic_unlock_rank(v, rank, flags); @@ -1105,7 +1105,7 @@ static int vgic_v3_distr_mmio_read(struct vcpu *v, mmio_info_t *info, case VREG32(GICD_CTLR): if ( dabt.size != DABT_WORD ) goto bad_width; vgic_lock(v); - *r = vgic_reg32_extract(v->domain->arch.vgic.ctlr, info); + *r = vreg_reg32_extract(v->domain->arch.vgic.ctlr, info); vgic_unlock(v); return 1; @@ -1132,14 +1132,14 @@ static int vgic_v3_distr_mmio_read(struct vcpu *v, mmio_info_t *info, typer |= (v->domain->arch.vgic.intid_bits - 1) << GICD_TYPE_ID_BITS_SHIFT; - *r = vgic_reg32_extract(typer, info); + *r = vreg_reg32_extract(typer, info); return 1; } case VREG32(GICD_IIDR): if ( dabt.size != DABT_WORD ) goto bad_width; - *r = vgic_reg32_extract(GICV3_GICD_IIDR_VAL, info); + *r = vreg_reg32_extract(GICV3_GICD_IIDR_VAL, info); return 1; case VREG32(0x000C): @@ -1232,7 +1232,7 @@ static int vgic_v3_distr_mmio_read(struct vcpu *v, mmio_info_t *info, irouter = vgic_fetch_irouter(rank, gicd_reg - GICD_IROUTER); vgic_unlock_rank(v, rank, flags); - *r = vgic_reg64_extract(irouter, info); + *r = vreg_reg64_extract(irouter, info); return 1; } @@ -1250,7 +1250,7 @@ static int vgic_v3_distr_mmio_read(struct vcpu *v, mmio_info_t *info, case VREG32(GICD_PIDR2): /* GICv3 identification value */ if ( dabt.size != DABT_WORD ) goto bad_width; - *r = vgic_reg32_extract(GICV3_GICD_PIDR2, info); + *r = vreg_reg32_extract(GICV3_GICD_PIDR2, info); return 1; case VRANGE32(0xFFEC, 0xFFFC): @@ -1313,7 +1313,7 @@ static int vgic_v3_distr_mmio_write(struct vcpu *v, mmio_info_t *info, vgic_lock(v); - vgic_reg32_update(&ctlr, r, info); + vreg_reg32_update(&ctlr, r, info); /* Only EnableGrp1A can be changed */ if ( ctlr & GICD_CTLR_ENABLE_G1A ) @@ -1419,7 +1419,7 @@ static int vgic_v3_distr_mmio_write(struct vcpu *v, mmio_info_t *info, if ( rank == NULL ) goto write_ignore; vgic_lock_rank(v, rank, flags); irouter = vgic_fetch_irouter(rank, gicd_reg - GICD_IROUTER); - vgic_reg64_update(&irouter, r, info); + vreg_reg64_update(&irouter, r, info); vgic_store_irouter(v->domain, rank, gicd_reg - GICD_IROUTER, irouter); vgic_unlock_rank(v, rank, flags); return 1; diff --git a/xen/include/asm-arm/vreg.h b/xen/include/asm-arm/vreg.h index 348584f..1253753 100644 --- a/xen/include/asm-arm/vreg.h +++ b/xen/include/asm-arm/vreg.h @@ -107,99 +107,99 @@ static inline bool vreg_emulate_sysreg64(struct cpu_user_regs *regs, union hsr h #endif -#define VGIC_REG_MASK(size) ((~0UL) >> (BITS_PER_LONG - ((1 << (size)) * 8))) +#define VREG_REG_MASK(size) ((~0UL) >> (BITS_PER_LONG - ((1 << (size)) * 8))) /* * The check on the size supported by the register has to be done by - * the caller of vgic_regN_*. + * the caller of vreg_regN_*. * - * vgic_reg_* should never be called directly. Instead use the vgic_regN_* + * vreg_reg_* should never be called directly. Instead use the vreg_regN_* * according to size of the emulated register * * Note that the alignment fault will always be taken in the guest * (see B3.12.7 DDI0406.b). */ -static inline register_t vgic_reg_extract(unsigned long reg, +static inline register_t vreg_reg_extract(unsigned long reg, unsigned int offset, enum dabt_size size) { reg >>= 8 * offset; - reg &= VGIC_REG_MASK(size); + reg &= VREG_REG_MASK(size); return reg; } -static inline void vgic_reg_update(unsigned long *reg, register_t val, +static inline void vreg_reg_update(unsigned long *reg, register_t val, unsigned int offset, enum dabt_size size) { - unsigned long mask = VGIC_REG_MASK(size); + unsigned long mask = VREG_REG_MASK(size); int shift = offset * 8; *reg &= ~(mask << shift); *reg |= ((unsigned long)val & mask) << shift; } -static inline void vgic_reg_setbits(unsigned long *reg, register_t bits, +static inline void vreg_reg_setbits(unsigned long *reg, register_t bits, unsigned int offset, enum dabt_size size) { - unsigned long mask = VGIC_REG_MASK(size); + unsigned long mask = VREG_REG_MASK(size); int shift = offset * 8; *reg |= ((unsigned long)bits & mask) << shift; } -static inline void vgic_reg_clearbits(unsigned long *reg, register_t bits, +static inline void vreg_reg_clearbits(unsigned long *reg, register_t bits, unsigned int offset, enum dabt_size size) { - unsigned long mask = VGIC_REG_MASK(size); + unsigned long mask = VREG_REG_MASK(size); int shift = offset * 8; *reg &= ~(((unsigned long)bits & mask) << shift); } /* N-bit register helpers */ -#define VGIC_REG_HELPERS(sz, offmask) \ -static inline register_t vgic_reg##sz##_extract(uint##sz##_t reg, \ +#define VREG_REG_HELPERS(sz, offmask) \ +static inline register_t vreg_reg##sz##_extract(uint##sz##_t reg, \ const mmio_info_t *info)\ { \ - return vgic_reg_extract(reg, info->gpa & offmask, \ + return vreg_reg_extract(reg, info->gpa & offmask, \ info->dabt.size); \ } \ \ -static inline void vgic_reg##sz##_update(uint##sz##_t *reg, \ +static inline void vreg_reg##sz##_update(uint##sz##_t *reg, \ register_t val, \ const mmio_info_t *info) \ { \ unsigned long tmp = *reg; \ \ - vgic_reg_update(&tmp, val, info->gpa & offmask, \ + vreg_reg_update(&tmp, val, info->gpa & offmask, \ info->dabt.size); \ \ *reg = tmp; \ } \ \ -static inline void vgic_reg##sz##_setbits(uint##sz##_t *reg, \ +static inline void vreg_reg##sz##_setbits(uint##sz##_t *reg, \ register_t bits, \ const mmio_info_t *info) \ { \ unsigned long tmp = *reg; \ \ - vgic_reg_setbits(&tmp, bits, info->gpa & offmask, \ + vreg_reg_setbits(&tmp, bits, info->gpa & offmask, \ info->dabt.size); \ \ *reg = tmp; \ } \ \ -static inline void vgic_reg##sz##_clearbits(uint##sz##_t *reg, \ +static inline void vreg_reg##sz##_clearbits(uint##sz##_t *reg, \ register_t bits, \ const mmio_info_t *info) \ { \ unsigned long tmp = *reg; \ \ - vgic_reg_clearbits(&tmp, bits, info->gpa & offmask, \ + vreg_reg_clearbits(&tmp, bits, info->gpa & offmask, \ info->dabt.size); \ \ *reg = tmp; \ @@ -211,10 +211,10 @@ static inline void vgic_reg##sz##_clearbits(uint##sz##_t *reg, \ * unsigned long rather than uint64_t */ #if BITS_PER_LONG == 64 -VGIC_REG_HELPERS(64, 0x7); +VREG_REG_HELPERS(64, 0x7); #endif -VGIC_REG_HELPERS(32, 0x3); +VREG_REG_HELPERS(32, 0x3); -#undef VGIC_REG_HELPERS +#undef VREG_REG_HELPERS #endif /* __ASM_ARM_VREG__ */ From patchwork Thu Jun 22 07:38:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106163 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327108qgd; Thu, 22 Jun 2017 00:41:14 -0700 (PDT) X-Received: by 10.36.46.210 with SMTP id i201mr673281ita.77.1498117274743; Thu, 22 Jun 2017 00:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117274; cv=none; d=google.com; s=arc-20160816; b=U7Lcwv2YH/cxh0Vci0I3+IAHVaPPjxCSF4t6fhIi4F73fXIuf+RbAhzDrTxD0ZPGh+ MkpIo3sPmIn1w4yN2z/hCegUVLkqzRHtcjCkWxfGlqAju+8rYq3urE8tTriAv027eG/4 +1kmG51NcrY3uqBXgRkA2YE4dr3LJ2+zYJAtyUqPBkCyGlQ8uxD4BoARuR0x/GOHLF1I LQbdQUUhc+EYWinkl3W4i/zVDjD1T/hPGyedhkhlmVarDTsdHAku3FcqDPRtFrwJO17r wmdPKYa1hIY4XbkGqsbYAdWEa466TYRqU5owORN1KyI8+xuXfKBrv65SY6qLs9Owae5p OTGw== 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=LqHhFkknXFR4Dg6bBrC/Piodwx58G/y6IoavXVL7oTs=; b=UixAkw594mUnGO5XledPFXTfi1c4ONvuQ6K+Rk1FVAUNZtNd5AA3k+Oz8G/q11DUkr iOI6rfWW2PsT5myS95lHFNuC59ukSFLFN1k3YKgBNKmLpsWoSqMQ0OAxOH35me3b6NPT Y2Nli9TnN9gyuCJP9d3oe9/AdCAt2z3C/t91r8B0VViIoAP8mlX+qV9rx1kz01D4ukXQ r9i08vj9369mLB9O/Z79UZeGnZzrqnIO4TPdB6uabDOqHUTSVJebUdjVPXeaPJbrH/lf mwbJATRUz8LwpazpH1hCkIcGkWzn/vWFHuZhaqIZP9bfvF4FYtTTHsIf0mIctA6BnHe8 UDRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=h2FcZeOS; 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 p73si380887itg.4.2017.06.22.00.41.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:14 -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=h2FcZeOS; 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 1dNwhr-0005Nk-O1; Thu, 22 Jun 2017 07:39:11 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwhq-0005NB-Jp for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:10 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 00/64-03620-D147B495; Thu, 22 Jun 2017 07:39:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsVyMfTANl3ZEu9 Ig0OrJSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owTW74wFSzmrzg17xZ7A+My3i5GLg4hgRmM Ei/OnmEHcVgE5jFLPD3wiQnEkRDoZ5V4fOAzcxcjJ5CTJrG0u40Rwq6U+NG9HcwWEtCSOHpqN ivEqH1MEpsmvgdyODjYBEwkZnVIgNSICChJ3Fs1GWwos8AFRomZf5+zgSSEBZIktqz/zA5Szy KgKvH9lzhImFfAW+Lg/ntQe+Ukbp7rBLM5BXwkVuxYyA6x11ti15nJLBMYBRYwMqxi1ChOLSp LLdI1tNRLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAgMLQYg2MH4Y1nAIUZJDiYl Ud7/ed6RQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4lYuBcoJFqempFWmZOcAgh0lLcPAoifC2g LTyFhck5hZnpkOkTjFacly5su4LE8eG1euB5JQD278wCbHk5eelSonzioLMEwBpyCjNgxsHi8 RLjLJSwryMQAcK8RSkFuVmlqDKv2IU52BUEubVLwKawpOZVwK39RXQQUxAB7044gFyUEkiQkq qgbFLcHqxy3x2UVWX+Zz9zVf1vq4In7f++uzM026MRyXWfZC4njplp9CEzCOJBlFh0prFKX9c XbiFxDWfPKxM5S61XdB3OlQiTj1evGyXXEzXhC2/Nr2TWq0mcMo995fTnI+KxVMEinuDL9+Y+ OD8lK3f/r3y3vFk1aP7JypPppcwHWh/lMAsvk6JpTgj0VCLuag4EQCnAT00vwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-2.tower-27.messagelabs.com!1498117148!49350367!1 X-Originating-IP: [209.85.192.182] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63132 invoked from network); 22 Jun 2017 07:39:09 -0000 Received: from mail-pf0-f182.google.com (HELO mail-pf0-f182.google.com) (209.85.192.182) by server-2.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:09 -0000 Received: by mail-pf0-f182.google.com with SMTP id s66so5117056pfs.1 for ; Thu, 22 Jun 2017 00:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YEwV4bXwOQaqrhMbEmQHrtWStXWS41PA5Oyrxmf+y5I=; b=h2FcZeOSTOCjLOwGBB7qv8ZxV4S+V1QdygKDCWh21VnsXy2EcWdDBbMkmuMoQAoiSf jRX2RwGnqyvETxeQ2+Su/nau/NvyN/6k8if5TZ5v1CoY+8jd58myxTDpvUlwfSgieOqv 1FiFMEPqO4TEXmaozTFaRuMmegXYRX+yFKruM= 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=YEwV4bXwOQaqrhMbEmQHrtWStXWS41PA5Oyrxmf+y5I=; b=r7dHI1zboDUzqHkqi0IxVyQcll8hjrSZry6xx8v7h8w37RF7zWVDMcSzDxKmEhXhth HyL4YFh/3isSBHhRO7l7FGowH6ndnmzGTIghql9TQVLSe3dEcfiACg6K3LS0U2N2o2TX FSzJBWLMXbGN+VHhtPSQeY9TYMpCycZqlF9mIKVvCZt75Z/FPhsOssj2kke+nPOnh+UY AmYT3/I1GLyk7WMivXtajmSjasBKuo1Z44fows2cCOdw7ew6TDSCoUUPYVbHfMHUh692 +iXAynIu6ujRbaXevHitlyCtyv9kxIhUZYGa44v/fXlBN9kyoISsyPsVUH1/+KiRwEzy R7rA== X-Gm-Message-State: AKS2vOwiCpwb5hmZkjNtaHDyRB31aTMFjAZvq2MyvKyOaJMtxNHXFA1S Dn6sUDMhcZXsIvXEiOVuXg== X-Received: by 10.99.123.17 with SMTP id w17mr1271022pgc.100.1498117147538; Thu, 22 Jun 2017 00:39:07 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:07 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:38 +0530 Message-Id: <1498117132-27139-4-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 03/17 v5] 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/consol.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 Thu Jun 22 07:38:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106171 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327167qgd; Thu, 22 Jun 2017 00:41:26 -0700 (PDT) X-Received: by 10.107.198.82 with SMTP id w79mr919821iof.121.1498117286232; Thu, 22 Jun 2017 00:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117286; cv=none; d=google.com; s=arc-20160816; b=RzwqOd8TRNYhMV66sxxmHhebYRp/yhDJ8+C0Ey9LujBAE4xQ3x1KufB1EDjpDK3UWO sCgTxmiTkYyn8221p+ys1r3LklWkBmAgGhEyDUHuvZlGM1EDppz524KheY3JhUkz+Z5x t37pfLlLt3GlnzW45MowCxCi9VE9jTOrcBVjw/xc6MkiTIQHcyGzmh3huiO5AWo6q+xD LkTMBT0GRb94jr3JaVq0YAOhZ7K55JcfKnNGmt+ZYgANsJvEkSg/VDKD8+Cevt1uR59P xLhELWq+JxxaHYFsRCm/FzshNsV9UQhyMN5/7R1pFmqFKzoaCYd+kNrCmSak9yl/Vo9q 306w== 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=6gAP3QxnfZI5yX4bwiCcArBK34KKD1gPPGlW2JyfVCE=; b=LQHVUS+Q5/Fi3819Pe66Q4CD8akfjaCWumOqw1aa+m9aj+xcr3U9ndsdTsDUAFceHi X438FNN6qPDxsnw4woSNx6qICuT8HvOWOhmWxyVR3papviESAv3cPdUwdyw+vqIaHzR2 YJ577YNzVBeusDmKXgDip5MW/qzueoabrhCDgkMB+71DqrMjfIj4kMDxqsyc6JBQ8Ld3 0/ZkFlhVEr1mzdwl/5J8RD32Tyouv4wMFKsLcfBMeruveOqHTWlxXRK1g/I7bNEaQWOP Bz313mlcWzmI6wFcfTwkylr67OLHKjuim2EosT5gUEDRG5//V2rQOl/JHOx8ACMwkou0 gacw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=h0D5qg8g; 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 x139si697001iod.260.2017.06.22.00.41.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:26 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=h0D5qg8g; 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 1dNwhv-0005Ph-VA; Thu, 22 Jun 2017 07:39:15 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwhu-0005OP-EH for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:14 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 51/81-26106-1247B495; Thu, 22 Jun 2017 07:39:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsVyMfTAVl2FEu9 Ig0VX1S2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owtM3pZCxYsZKy4c24jYwPjwuouRi4OIYEZ jBK/T5xiBXFYBOYxS8yd9oUJxJEQ6GeVaJq9AcjhBHLSJA78/cXcxcgBZFdKrFriBxIWEtCSO HpqNivEpH1MEut6d7CD1LAJmEjM6pAAqRERUJK4t2oy2BhmgXqJRZu2sYDYwgKeEs2HlrKD2C wCqhIPr51gBrF5BbwlJi1+wQqxVk7i5rlOsDingI/Eih0L2SH2ekvsOjOZZQKjwAJGhlWM6sW pRWWpRbomeklFmekZJbmJmTm6hgbGermpxcWJ6ak5iUnFesn5uZsYgYHFAAQ7GBu/OB1ilORg UhLl/Z/nHSnEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgle5GCgnWJSanlqRlpkDDHGYtAQHj5IIb wtIK29xQWJucWY6ROoUoyXHlSvrvjBxLOjZACSnHNj+hUmIJS8/L1VKnFcUZJ4ASENGaR7cOF gcXmKUlRLmZQQ6UIinILUoN7MEVf4VozgHo5Iwr34R0BSezLwSuK2vgA5iAjroxREPkINKEhF SUg2M3QFeN34fqxS3133vclj+y7U3jjzHGRKf1PMvctgyWytz2du22uunZZfxa+//ME916oYl dpmht8WTJ0yXl18dHLC7okB30eqIa3mfbk4IkV3Hw6jiHro8U5HdM2bt69qMPcs1ti8NqS8TO DPlzoJpy43ebuOeHapvGN3PkXOg5Mc0Z91Hxz1nK7EUZyQaajEXFScCAKwFnX6+AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-2.tower-31.messagelabs.com!1498117151!95151114!1 X-Originating-IP: [209.85.192.181] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60615 invoked from network); 22 Jun 2017 07:39:12 -0000 Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by server-2.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:12 -0000 Received: by mail-pf0-f181.google.com with SMTP id c73so5127495pfk.2 for ; Thu, 22 Jun 2017 00:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SYus2VzS1W1QLSxmuZVinB5br9mxGYeJ5LHMDqjFKzo=; b=h0D5qg8ggx86W75xqdtbcV+g3hyxfxvqd9kM6pRW6oa99zqbU4x/3ylQ58kHDYyEq3 MZ+PDhOFR/GdLAoPSOCNiNLzAlsRAQWU7aZXV/gUFZjw4T+5TO0A2DtxvFnYJ4+68j0w 3e0diCSdEatgz9dYXX3muF8HVGyETqJgplUA0= 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=SYus2VzS1W1QLSxmuZVinB5br9mxGYeJ5LHMDqjFKzo=; b=eseHLWasT+49YXSqgANZ6y14aLk+jre3L9dZ5I7SS3M09bhE5yiDmojkuBYpPrrJ0V ZvHgWtKTlXKt93WIRzNIVQqoGC3QyUc6r9uwVMZ8cA+fP5kElTkIYL8u7JsL/owilIf8 LRSVQYQPcdB1Qh95cx6NZvsu2nUvrl0VhZOo1vCkLoChVn4ITPpno0/J0W3ZSHhh0Gpa /cDX+JHsOAUxP81NhdXHtaHWwEL4hMo+tt/+kzf00HbvPVkGKNDjoCL+I615/DbfC7qK JKk0PWyyfnlEO6pjO/tjiNm3ZU1/fDkYEWc7lPpvywz82HG+HClfcZKEdyUbd4aOdzMV 8clA== X-Gm-Message-State: AKS2vOz/DRtWrairOQqud0vDI62Ud+O1nL6dWhZjSZX2uC3zzkNWq20M lBbvPM3VLDGRFPwAYncTkg== X-Received: by 10.101.88.13 with SMTP id g13mr1255065pgr.180.1498117150574; Thu, 22 Jun 2017 00:39:10 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:10 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:39 +0530 Message-Id: <1498117132-27139-5-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Andre Przywara , Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 04/17 v5] 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 --- CC: Stefano Stabellini CC: Julien Grall CC: Andre Przywara 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 | 449 +++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/domain.h | 6 + xen/include/asm-arm/pl011-uart.h | 2 + xen/include/asm-arm/vpl011.h | 73 +++++++ xen/include/public/arch-arm.h | 6 + 7 files changed, 544 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..db8651c --- /dev/null +++ b/xen/arch/arm/vpl011.c @@ -0,0 +1,449 @@ +/* + * 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 interrupt_status = vpl011->uartris & vpl011->uartimsc; + + /* + * 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 ( interrupt_status & ~vpl011->shadow_uartris ) + vgic_vcpu_inject_spi(d, GUEST_VPL011_SPI); + + vpl011->shadow_uartris = interrupt_status; +} + +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_rmb(); + + /* + * 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); + vpl011_write_data(v->domain, data); + return 1; + } + case RSR: /* Nothing to clear. */ + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + return 1; + + case FR: + case RIS: + case MIS: + goto write_ignore; + + case IMSC: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + vreg_reg32_update(&vpl011->uartimsc, r, info); + vpl011_update_interrupt_status(v->domain); + VPL011_UNLOCK(d, flags); + return 1; + + case ICR: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + vreg_reg32_clearbits(&vpl011->uartris, r, info); + vpl011_update_interrupt_status(d); + VPL011_UNLOCK(d, flags); + return 1; + + default: + gprintk(XENLOG_ERR, "vpl011: unhandled write r%d offset %#08x\n", + dabt.reg, vpl011_reg); + return 0; + } + +write_ignore: + return 1; + +bad_width: + gprintk(XENLOG_ERR, "vpl011: bad write width %d r%d offset %#08x\n", + dabt.size, dabt.reg, vpl011_reg); + domain_crash_synchronous(); + return 0; + +} + +static const struct mmio_handler_ops vpl011_mmio_handler = { + .read = vpl011_mmio_read, + .write = vpl011_mmio_write, +}; + +static void vpl011_data_avail(struct domain *d) +{ + unsigned long flags; + struct vpl011 *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + XENCONS_RING_IDX in_cons, in_prod, out_cons, out_prod; + XENCONS_RING_IDX in_ring_qsize, out_ring_qsize; + + VPL011_LOCK(d, flags); + + in_cons = intf->in_cons; + in_prod = intf->in_prod; + out_cons = intf->out_cons; + out_prod = intf->out_prod; + + smp_rmb(); + + in_ring_qsize = xencons_queued(in_prod, + in_cons, + sizeof(intf->in)); + + out_ring_qsize = xencons_queued(out_prod, + out_cons, + sizeof(intf->out)); + + /* Update the uart rx state if the buffer is not empty. */ + if ( in_ring_qsize != 0 ) + { + vpl011->uartfr &= ~RXFE; + if ( in_ring_qsize == sizeof(intf->in) ) + vpl011->uartfr |= RXFF; + vpl011->uartris |= RXI; + } + + /* Update the uart tx state if the buffer is not full. */ + if ( out_ring_qsize != sizeof(intf->out) ) + { + vpl011->uartfr &= ~TXFF; + vpl011->uartris |= TXI; + if ( out_ring_qsize == 0 ) + { + vpl011->uartfr &= ~BUSY; + vpl011->uartfr |= TXFE; + } + } + + vpl011_update_interrupt_status(d); + + VPL011_UNLOCK(d, flags); +} + + +static void vpl011_notification(struct vcpu *v, unsigned int port) +{ + vpl011_data_avail(v->domain); +} + +int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info) +{ + int rc; + struct vpl011 *vpl011 = &d->arch.vpl011; + + if ( vpl011->ring_buf ) + return -EINVAL; + + /* Map the guest PFN to Xen address space. */ + rc = prepare_ring_for_helper(d, + gfn_x(info->gfn), + &vpl011->ring_page, + &vpl011->ring_buf); + if ( rc < 0 ) + goto out; + + rc = vgic_reserve_virq(d, GUEST_VPL011_SPI); + if ( !rc ) + { + rc = -EINVAL; + goto out1; + } + + rc = alloc_unbound_xen_event_channel(d, 0, info->console_domid, + vpl011_notification); + if ( rc < 0 ) + goto out2; + + vpl011->evtchn = info->evtchn = rc; + + spin_lock_init(&vpl011->lock); + + register_mmio_handler(d, &vpl011_mmio_handler, + GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL); + + return 0; + +out2: + vgic_free_virq(d, GUEST_VPL011_SPI); + +out1: + destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page); + +out: + return rc; +} + +void domain_vpl011_deinit(struct domain *d) +{ + struct vpl011 *vpl011 = &d->arch.vpl011; + + if ( !vpl011->ring_buf ) + return; + + free_xen_event_channel(d, vpl011->evtchn); + destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page); + xfree(d->arch.vmmio.handlers); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 8dfc1d1..1a1145d 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -11,6 +11,7 @@ #include #include #include +#include struct hvm_domain { @@ -145,6 +146,11 @@ struct arch_domain struct { uint8_t privileged_call_enabled : 1; } monitor; + +#ifdef CONFIG_SBSA_VUART_CONSOLE + struct vpl011 vpl011; +#endif + } __cacheline_aligned; struct arch_vcpu diff --git a/xen/include/asm-arm/pl011-uart.h b/xen/include/asm-arm/pl011-uart.h index 123f477..57e9ec7 100644 --- a/xen/include/asm-arm/pl011-uart.h +++ b/xen/include/asm-arm/pl011-uart.h @@ -49,6 +49,8 @@ /* FR bits */ #define TXFE (1<<7) /* TX FIFO empty */ #define RXFE (1<<4) /* RX FIFO empty */ +#define TXFF (1<<5) /* TX FIFO full */ +#define RXFF (1<<6) /* RX FIFO full */ #define BUSY (1<<3) /* Transmit is not complete */ /* LCR_H bits */ diff --git a/xen/include/asm-arm/vpl011.h b/xen/include/asm-arm/vpl011.h new file mode 100644 index 0000000..f1c6716 --- /dev/null +++ b/xen/include/asm-arm/vpl011.h @@ -0,0 +1,73 @@ +/* + * 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_uartris; /* shadowed Raw interrupt status register */ + uint32_t uartmis; /* Masked interrupt register */ + spinlock_t lock; + evtchn_port_t evtchn; +}; + +struct vpl011_init_info { + uint32_t console_domid; + gfn_t gfn; + evtchn_port_t evtchn; +}; + +#ifdef CONFIG_SBSA_VUART_CONSOLE +int domain_vpl011_init(struct domain *d, + struct vpl011_init_info *info); +void domain_vpl011_deinit(struct domain *d); +#else +static inline int domain_vpl011_init(struct domain *d, + struct vpl011_init_info *info) +{ + return -ENOSYS; +} + +static inline void domain_vpl011_deinit(struct domain *d) { } +#endif +#endif + +/* + * 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 Thu Jun 22 07:38:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106165 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327112qgd; Thu, 22 Jun 2017 00:41:15 -0700 (PDT) X-Received: by 10.36.211.69 with SMTP id n66mr692577itg.36.1498117275887; Thu, 22 Jun 2017 00:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117275; cv=none; d=google.com; s=arc-20160816; b=bhbU0f89j5lbqe0hO9lFWrPyZYiiZDa6mZx0k+hDncolGZuEU8wbnwEANccFKv0MdT fDEYLv0fWsSA9PQo98VEywqjRDlYHnrGBvUUj0zgwh2qDXnmMkUkUVgRfcoCjoJK+kXX e2REVleufJvuuY2VN5vxx+4woAAn7Y3InqqBOg28f+lzcuvrDE6+Eg6vcbXvBPD0tQt7 Hxh+o7Nt0c9jUfWsr5ZxIWnn3MGuivATz27S4y5Mur8LP8HD2Ig82GyZoIJ9Tm5OJR9G pk4r7USf0Wn/2Fi3fO2Rz+ArIbAWVcgoC/dfSchS7HbFgpMsgJJrK/B4tp0c3EBc0L4Q OA2w== 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=OSwzg/DeDMFg2t33LUvAGMgu0IAnJboOURL9aVIvv+tS98hVNjH1HjTptN/efZ8UY1 cexz7dMY0F6GPrRG+Qn5BdOPSNHPj5rB788O8ttHF+dJe1FV4kAJnAE14gs5VS/NrbaI eIiVAzLu1e1ydTXb7YX5TTx7epA/ee9AZuQrQrzEiT7ue/H6dLRBsAQbdcCUeps9qVyZ cLJCsZBelcfcQ2WoixnqSrYamV/tF2f6LHFJQ4pGmSUJEp4iw4t4H6h6GVFKE3/7sWSz qFZVK9got+w7c50RH7oS/AvwvrhVXe21Sx3U9OCfhPdRdCuUD5tV5hAW5nqsxeMYlqCS jAtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=L3aG+0AU; 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 v66si712786iof.177.2017.06.22.00.41.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:15 -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=L3aG+0AU; 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 1dNwhx-0005RQ-As; Thu, 22 Jun 2017 07:39:17 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwhw-0005Pg-DI for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:16 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id B2/9A-02022-3247B495; Thu, 22 Jun 2017 07:39:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsXiVRtsqqtc4h1 p8GQri8X3LZOZHBg9Dn+4whLAGMWamZeUX5HAmrH9xRn2gleSFVPWbGJuYLwj2sXIxSEkMJ1R Yve5N0wgDovAPGaJJ/fesoI4EgL9rBITDz9h6WLkBHLSJLZseMcMYVdIrJq4hRHEFhLQkjh6a jYrxKh9TBL7Vt1j62Lk4GATMJGY1SEBUiMioCRxb9VksA3MAvMZJZom9bKBJIQFIiQWLtnDCm KzCKhKfO1uYAbp5RXwlph3Lh5il5zEzXOdYHs5BXwkVuxYyA6x11ti15nJLBMYBRYwMqxi1Ch OLSpLLdI1NtBLKspMzyjJTczM0TU0MNXLTS0uTkxPzUlMKtZLzs/dxAgMrXoGBsYdjBNW+R1i lORgUhLl/Z/nHSnEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgle5GCgnWJSanlqRlpkDDHKYtAQHj 5IIbwtIK29xQWJucWY6ROoUoy7HpAPbvzAJseTl56VKifOKgswQACnKKM2DGwGLuEuMslLCvI wMDAxCPAWpRbmZJajyrxjFORiVhHn1i4Cm8GTmlcBtegV0BBPQES+OeIAcUZKIkJJqYFyvLxs 3nWdulPrBLcazX36Kaps0STNcRfKXBvOkvkRvMfOCF68Euxe4dcvbVqRPbUhQ/DupXoDRN0Tg 0etL7bkvzT/1X0/Till8nSE2yDn0hfdp+RfH/iQavLm9iiVgSmPyI8cXU1I5w+IfTRa6uEFBz zD47S1Bjtnz/L+vbTC7sPsw6wEeLSWW4oxEQy3mouJEAHRdepizAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-206.messagelabs.com!1498117154!76094795!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18348 invoked from network); 22 Jun 2017 07:39:14 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-10.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:14 -0000 Received: by mail-pg0-f53.google.com with SMTP id u62so4581647pgb.3 for ; Thu, 22 Jun 2017 00:39: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=l6qPJ2j2XHzH4tm5SO40ctm3ZgjV1/opafjwCKIt+cs=; b=L3aG+0AUs3ZIO7f+qOpxTGAZFrOjChgcRTboNevDNa0cX3EFanw/X6bXJ/iF2UOolZ rTxl5PGeOglNYKUMNMALWKB+VpT+jMWjzDHt75Krx8V5pjFzRoNM3m2NySwD5vSudcIA V71t9WZI65BGZip6MJLjbC1O7mjH2YHwhWR9k= 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=mFmz1XuiDpRNSGCzCq7enrQ7AWGjDJomxfsNdI0uf7ndd6dLlMBY8MApV2OmbQJ1ud Lft5wSEbsAyI8f1dO4kMcFP3OYpg//U7xZy47uHpCs6t3ytLPBq3sBkh71EGq+MQch1L +orGYi0RcZWJsdeE5z0UF0PFAzJZEavzO4HWPJOmPFwE1GraIzEJbF6rDpXjJJMqTRfl Khb6vBai///gbTcjNHVWKu/IdstLmb/Q1DhY57IKM0+PCSD0X6CnMlT6q5XamJdnkkjn DRusp5fbZPfi96THYwnC6Pr85MyTfyAC1vc+0NcUIsK8ilzkCxVCk8Mw3PsWe+da4o4G AbbA== X-Gm-Message-State: AKS2vOzN9VouYq7+w4vGSjV7m5f1iIvxUABpvG5I9Ox22ZS9NIqEX3bT 6r0DUncFyMTAJyQNCzs5dQ== X-Received: by 10.98.69.219 with SMTP id n88mr1202762pfi.93.1498117153416; Thu, 22 Jun 2017 00:39:13 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:13 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:40 +0530 Message-Id: <1498117132-27139-6-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 05/17 v5] 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 Thu Jun 22 07:38:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106168 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327135qgd; Thu, 22 Jun 2017 00:41:21 -0700 (PDT) X-Received: by 10.36.200.5 with SMTP id w5mr701357itf.118.1498117281092; Thu, 22 Jun 2017 00:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117281; cv=none; d=google.com; s=arc-20160816; b=mU8mwNtRQwoiLfLnqbMEV34ytGQFChrHUk/PDuz0M8w7L5wWZuY02IkGYfVHdxlJHR 7ya3RCiwf86xIkalaABTDgOxQAsWoF8FHFFeR67qJjWT6P8qsyYfncKP55+phxHjqUiC XOkjVXdupOylIgiyMzxWzvyPcA5CaD42atI4mJFYsw1j+UppJIzM6tIV/E8um0JjxYRn DeVGkf0U73mXKOlqOyBMQXt3Gcaqw2b3qagd+4OM1OdvSnroph/P3W8676yjvPLwzpLX scp+mnG7BNTOP29QnVdlMBJVjPO387aoATH48PAg20mcayRQUj/i0F1c1LvDdHcno1At TLEw== 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=gNskO8Jm9DOHb+AnNGPQaSpiqlpwMQWA6w7jOb4kOYM=; b=rpRz8pEhMlh2RiR3T4J2rDwCeONrwFyIi9tUvQi6Lr5+JWG4YLQOPKAmkxpwzDUkL3 cx/zmXoag1ld/VGxuiixqsmPa+tZAKe+LMlsUdXjf4rBzUAOFrba+xg+Tdp6WhE9aQn2 yV31LcrO81OHEhRKyV0a0PCPKsivixEo6M8d0yEDFFEO9SMB6mzz9uO1Q9gCSW1jasAJ TIscRztd2/p/73N8ErpKzjUFd2/G6d00LfMmbjcVyz6ycgCp+/s0ynOm99LDL296qhXv rmnoEqRimSV3RpqhxVzmF76ib065urhOOV/hbLdQXZgSO/HtdgHKBpnW+hwkQhGAuILZ uI7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=QuICFmhg; 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 r82si381504itc.37.2017.06.22.00.41.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:21 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=QuICFmhg; 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 1dNwi0-0005U6-I8; Thu, 22 Jun 2017 07:39: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 1dNwhz-0005TJ-UN for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:20 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 5F/16-03587-7247B495; Thu, 22 Jun 2017 07:39:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXiVRtspKtW4h1 psGirisX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmtG2ZidLwWejirt/v7E3MG7S6GLk4hASmM4o 0dO4nRHEYRGYxyzRf/ATUxcjJ4eEQD+rxJ9mTwg7TaJhWRsbhF0p0brqNzOILSSgJXH01GxWC Hsfk0T7ZPsuRg4ONgETiVkdEiBhEQEliXurJjOBzGcWmM8o0TSpF2yOsICnxLsnW9lBbBYBVY lNf5aD7eUV8Jb4+nYbC8QuOYmb5zrBdnEK+Eis2LGQHWKXt8SuM5NZJjAKLGBkWMWoUZxaVJZ apGtorpdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJERhYDECwg/H2xoBDjJIcTEqi vP/zvCOF+JLyUyozEosz4otKc1KLDzHKcHAoSfDOKwLKCRalpqdWpGXmAEMcJi3BwaMkwtsC0 spbXJCYW5yZDpE6xWjMsWH1+i9MHJMObP/CJMSSl5+XKiXOK1oMVCoAUppRmgc3CBZ7lxhlpY R5GYFOE+IpSC3KzSxBlX/FKM7BqCTMqw9yD09mXgncvldApzABnfLiiAfIKSWJCCmpBkYX3Tn flD+fWshzYW+/3okvLP+axOOTqpfM4WBc3xi1+f8KvZUuOYzaa89vKenbdX+J2daYS44qPX+z BENvx5oEz94m4svHqCJy59qUcKZ554O5rm4ws/i0m5X91uOCTy//6HEu9vrpnn5M6/6dssKlS izKlc5rTrk17/efZv/g5Rz5+c7OhvpKLMUZiYZazEXFiQBgFge7uAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1498117157!109018048!1 X-Originating-IP: [74.125.83.50] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10404 invoked from network); 22 Jun 2017 07:39:18 -0000 Received: from mail-pg0-f50.google.com (HELO mail-pg0-f50.google.com) (74.125.83.50) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:18 -0000 Received: by mail-pg0-f50.google.com with SMTP id u62so4582020pgb.3 for ; Thu, 22 Jun 2017 00:39:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=za749e5OPxqDcF25FG8ySj4s2PVd2DrfzUsMhwQ4CRQ=; b=QuICFmhgqpVClWP9GvFj6WkYkaeUxiY5DlUhy9eJXqxNJ+QP6jS4EHS3EkJgVnDNjd 3l6NUyTxRd2p+BgXORFWAZRAhiL733qm3a9rUOZ92LjW+fU+00CjSeJooBucBCPENjoW 3pKlxBCysNxgrDg3s5Lwx/QRGxkw7Z3MGagbs= 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=za749e5OPxqDcF25FG8ySj4s2PVd2DrfzUsMhwQ4CRQ=; b=ZmQi6k2heLAfN0ouh0evFBDnUvxQHAfAVHmM1hyrKf9bKXs5GyzAp6Qpfhk7mf+8VB vZaCLSbGRzu6L0HBn4TWS1TIWayCwz36TyzRbeYLQyWTiETo8vnzrv1Ld576K6f3y1oM S3dPUXGqCMKn7nroa7aVdSKNkPU5EQJyfxqg7BC1L2e+ejAD4rr48q2NwL7LmFHN1TU6 FjsgbBFuzNzWmW6zPqcXONdquXf7aBJwkr4J1dzj3T4GiqIHyhNSWrok9a+YOY+MzVi4 m4AtOyIrhvt8Rbj6cxNOFNHahXUuRggCxlAI1IPmaTFsK6EzFcBo6SsK7uFbtmpBTsef YctA== X-Gm-Message-State: AKS2vOy4HPCh7scLq3rjuNwikrYw8qcuNCsJAPRxf6NaZHcMSU9jzgze B6vRMQi0KAHlNeRjVNiHdg== X-Received: by 10.98.32.153 with SMTP id m25mr1270752pfj.111.1498117156717; Thu, 22 Jun 2017 00:39:16 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:16 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:41 +0530 Message-Id: <1498117132-27139-7-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 06/17 v5] xen/arm: vpl011: Add support for vuart in libxl X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" An option is provided in libxl to enable/disable sbsa vuart while creating a guest domain. Libxl now suppots a generic vuart console and sbsa uart is a specific type. In future support can be added for multiple vuart of different types. User can enable sbsa vuart by adding the following line in the guest configuration file: vuart = "sbsa_uart" Signed-off-by: Bhupinder Thakur Acked-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Renamed "pl011" to "sbsa_uart". Changes since v3: - Added a new config option CONFIG_VUART_CONSOLE to enable/disable vuart console support. - Moved libxl_vuart_type to arch-arm part of libxl_domain_build_info - Updated xl command help to mention new console type - vuart. Changes since v2: - Defined vuart option as an enum instead of a string. - Removed the domain creation flag defined for vuart and the related code to pass on the information while domain creation. Now vpl011 is initialized independent of domain creation through new DOMCTL APIs. tools/libxl/libxl.h | 6 ++++++ tools/libxl/libxl_console.c | 3 +++ tools/libxl/libxl_dom.c | 1 + tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_types.idl | 7 +++++++ tools/xl/xl_cmdtable.c | 2 +- tools/xl/xl_console.c | 5 ++++- tools/xl/xl_parse.c | 8 ++++++++ 8 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index cf8687a..bcfbb6c 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -306,6 +306,12 @@ #define LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE 1 /* + * LIBXL_HAVE_VUART indicates that xenconsole/client supports + * virtual uart. + */ +#define LIBXL_HAVE_VUART 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 446e766..853be15 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -67,6 +67,9 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, case LIBXL_CONSOLE_TYPE_SERIAL: cons_type_s = "serial"; break; + case LIBXL_CONSOLE_TYPE_VUART: + cons_type_s = "vuart"; + break; default: goto out; } diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 5d914a5..c98af60 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -788,6 +788,7 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid, if (xc_dom_translated(dom)) { state->console_mfn = dom->console_pfn; state->store_mfn = dom->xenstore_pfn; + state->vuart_gfn = dom->vuart_gfn; } else { state->console_mfn = xc_dom_p2m(dom, dom->console_pfn); state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index afe6652..d0d50c3 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1139,6 +1139,9 @@ typedef struct { uint32_t num_vmemranges; xc_domain_configuration_t config; + + xen_pfn_t vuart_gfn; + evtchn_port_t vuart_port; } libxl__domain_build_state; _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid, diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 2204425..d492b35 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 # @@ -580,6 +586,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), + ("vuart", libxl_vuart_type), ])), # Alternate p2m is not bound to any architecture or guest type, as it is # supported by x86 HVM and ARM support is planned. diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 30eb93c..9f91651 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -133,7 +133,7 @@ struct cmd_spec cmd_table[] = { &main_console, 0, 0, "Attach to domain's console", "[options] \n" - "-t console type, pv or serial\n" + "-t console type, pv , serial or vuart\n" "-n console number" }, { "vncviewer", diff --git a/tools/xl/xl_console.c b/tools/xl/xl_console.c index 0508dda..4e65d73 100644 --- a/tools/xl/xl_console.c +++ b/tools/xl/xl_console.c @@ -27,6 +27,7 @@ int main_console(int argc, char **argv) uint32_t domid; int opt = 0, num = 0; libxl_console_type type = 0; + char *console_names = "pv, serial, vuart"; SWITCH_FOREACH_OPT(opt, "n:t:", NULL, "console", 1) { case 't': @@ -34,8 +35,10 @@ int main_console(int argc, char **argv) type = LIBXL_CONSOLE_TYPE_PV; else if (!strcmp(optarg, "serial")) type = LIBXL_CONSOLE_TYPE_SERIAL; + else if (!strcmp(optarg, "vuart")) + type = LIBXL_CONSOLE_TYPE_VUART; else { - fprintf(stderr, "console type supported are: pv, serial\n"); + fprintf(stderr, "console type supported are: %s\n", console_names); return EXIT_FAILURE; } break; diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 856a304..37581ef 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -916,6 +916,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 Thu Jun 22 07:38:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106167 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327127qgd; Thu, 22 Jun 2017 00:41:19 -0700 (PDT) X-Received: by 10.107.148.6 with SMTP id w6mr1141987iod.108.1498117279411; Thu, 22 Jun 2017 00:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117279; cv=none; d=google.com; s=arc-20160816; b=AoiewGe3B/KitE3JQg+Du/E1ORR0F4LUhXUTTiPv44jZAQSz0xnxJuhPuU5rTmL9Kq 2OuOToHqJl64dIItDl1jbGq3z7g4NxeyQABJNFAiLGzp9UnF0RSVLbgOdglmwkTRcr/m wsY/nQKXlO0aJg+Xc3DXdZoE1LJZ7WdhZqKQg8/A39yOPWwdfMBBggZTB7sutTAfPnbO AnUjwMr1mGF/zWNKOM/jn6Qeax5UJfJLiWHnCCAbEWRDrjQWojvxrYwTl7/kHBItq7di ZCLrVyJSGnUHFjqVcFDv1q59zmkn6w2uobPpEtaI1JM/4f1XhTgHGBsyEBVSe9O2iK2V 91PA== 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=uMXhArYYW44Jp4bNw/GiV80SqC/eHHNSP82IYadQ8QQ=; b=whO8jyjyOu1nxAfG/Tx5Jd1sTxPdT5ZqtEHvdYCSrKZlHuZq5lPJfxMQsC9Q5d4T2y wCo93KiwV9pzTM5RIGB+G47B3E8/5QqihjpTj4pxRuHLIR7qOHzuOAsiO4tkFObVXhz0 rc+jLoNPkobL0qabIAm+nsHxEFKcfVR2NxwOSayDv1gc4+p2cTVUwa6+oIPp1zLaIu+7 aBtnTKuec6gABsbmukGqSDLIOx8YU6aTb5XQP6SS7UfInaK+qMI8wJPbSIsG0KCR/ygM nODqd9HyS4oPZ/NXbNHtibjJOQU7aT6fnhi0kcwmxyhQSfdoKRQPXEDCfsw400lXY4pC rhLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=HUHg9ckZ; 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 w84si744543iof.29.2017.06.22.00.41.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:19 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=HUHg9ckZ; 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 1dNwi3-0005WT-Pe; Thu, 22 Jun 2017 07:39:23 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwi2-0005VO-Ll for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:22 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 32/7C-02196-9247B495; Thu, 22 Jun 2017 07:39:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFIsWRWlGSWpSXmKPExsVyMfTAal3NEu9 Ig3Mb+S2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyHb6awF9xgrXh0/iVjA+M/li5GLg4hgRmM Eq133zCDOCwC85gl5k5uYe1i5OSQEOhnlfg5jwvCTpPYdGYJE4RdKdHf+oIdxBYS0JI4emo2K 8SkfUwSe25uARrLwcEmYCIxq0MCpEZEQEni3qrJYL3MAqESU/8+YAGxhQWyJI5MvcQIYrMIqE psOPwbLM4r4C1x8fo+ZohdchI3z3WC2ZwCPhIrdiyE2ustsevMZJYJjAILGBlWMaoXpxaVpRb pmuolFWWmZ5TkJmbm6BoaGOvlphYXJ6an5iQmFesl5+duYgSGVT0DA+MOxstfnQ4xSnIwKYny bi72jhTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwasMkhMsSk1PrUjLzAEGOExagoNHSYS3JQ8oz VtckJhbnJkOkTrFaMlx5cq6L0wcTR+2AMkpB7Z/YRJiycvPS5US5xUFmScA0pBRmgc3DhaFlx hlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMCoJ8+oXAU3hycwrgdv6CuggJqCDXhzxADmoJBEhJdX A2O901nlq4LQgOdZ9oRfOv8iZop+fYxm0Tmj2EUvVMo1lESGTjj6rKRIXvMjOeFfni4W+Ynp5 R13qgQsnjp07m7Q7mOny25rIwluOvJY19gwW1SGW/yZw7zz//vRfi6NVajnTc3u2pTpd+uh8Q fd6UoRF1AQzwT+JXrsjXDzu8/Rt603fa5ynxFKckWioxVxUnAgAu35y4r0CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-31.messagelabs.com!1498117159!101988755!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 53842 invoked from network); 22 Jun 2017 07:39:21 -0000 Received: from mail-pf0-f171.google.com (HELO mail-pf0-f171.google.com) (209.85.192.171) by server-5.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:21 -0000 Received: by mail-pf0-f171.google.com with SMTP id q86so5107469pfl.3 for ; Thu, 22 Jun 2017 00:39: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=YR6Rh9jyIvB+P8TT2kMqnKsQyIRS16OsO1hisASPRVQ=; b=HUHg9ckZF8kyoVWDncZHJlonihLpaO9Ejc/DTbzoeBDuJYUyUZMzZKIlWslLtEFHM2 TnMElzaLLdkFOv/9SqluThA0KEp1c2bEgcCOXRQWBUW6OVACjI2nNvUPpE5x+Df0ik3O sUer3YNMNWvLtiUh/QO85oWLhS56fzWnUt74M= 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=YR6Rh9jyIvB+P8TT2kMqnKsQyIRS16OsO1hisASPRVQ=; b=UGqek43tdXlaUG1elvM+xcp3CGRSwJ3QFTy0IPM811LRIplvz5CFUfhBLUO2fGQXT0 9SZoMHYaflNwjdC7VewuP+TJSRmnJnOb4N20NEIQddIDEmge1y+X6gYS5LEWyweoUNJ8 cR7mcY1E6SO9h9ZGbPeBtP9c1za+zRj6eg9kQgaoutJCCowpoIaAjMPLzOfWLnFub0Ug Jsa3WH2TOAxQIMCLo4BMhsroQ0EiKXiCyDkASpqDzfZRKQUabiLFAc/v2pbdmDtYxF2X stxXPJ8zTz6t1acKeN0xjJEigJWCxISFkKlTvMR1KVJjS5yeA8vTKDGdLqemKHOdXarl uXjA== X-Gm-Message-State: AKS2vOw58rdz9wrzG4TS1QPuymcW5gVa32v9MVsu4MBm1pOBOUsbAFNL Lbyh30Gj5OY12/iZF0VLMw== X-Received: by 10.84.232.15 with SMTP id h15mr1421896plk.168.1498117159415; Thu, 22 Jun 2017 00:39:19 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:19 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:42 +0530 Message-Id: <1498117132-27139-8-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 07/17 v5] 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 --- CC: Stefano Stabellini CC: Julien Grall xen/arch/arm/domctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index 971caec..86fa102 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -5,11 +5,11 @@ */ #include -#include #include -#include #include #include +#include +#include #include #include From patchwork Thu Jun 22 07:38:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106164 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327117qgd; Thu, 22 Jun 2017 00:41:16 -0700 (PDT) X-Received: by 10.36.123.86 with SMTP id q83mr696983itc.65.1498117276490; Thu, 22 Jun 2017 00:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117276; cv=none; d=google.com; s=arc-20160816; b=T5BtP+UY3wMucYoQ9NgYO2osecrmeOaCDV0QlNY1LOcBV5lCLHzIVxfImf/GG0jPg6 VYBAz7C7BC8qdspWTDdN1jxGkQ4l/J1eL8BgtGE78dvb5gktaplNrlt5Pql93NQAUNW/ yryxP5d1aP3gJsVUU+NkQKb06PoxToG21u0JGzJlhGumzd6RH5PNuDRH2w/2OCTdwJRn n9kjgsnGlBrrVmKiVygVm2RIxcL1PZY9yCACgtTIe1gw7J6wVxpTaFKarih/wwznW7vS ILh7YdS9nEDFdHsCOgPnPmc3jk6QJgzMUUSh25a4MJKc2H/QKfv+Iq/hjlWPLthhVyEJ Kgww== 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=FpfuG3rpGi65cDXjkBDgJgs8ljiHilg5rEghskoJkjc=; b=z0Oapnbv6Og5goJ0sBmG+jjRo2CQIt7N9u2Ip+eRitO8iUek/b+sC8HwAWZ5VdHvLo M7NHf030tnZhLZjHgk8Ywl6hPW+yA8xOaVaG1mVDRLc5G/CetxEyqB39TVopOLQib8pj Z0kz84dI9HjZMv1ZDFpeC2sLtIuHANu0nt8vQEHjxBCtXIoFR5PSctpNRFEN03wUFPZE PU91G4zQvtVqfit2a8BH79919HyWSR3gJXAHO6mdec29kEPZyv0qCS3T+oAL4RRAtqFO fcHAUZBMXFdgn3YofTMxVp9jcYgGTCrIOyncEXponBJH9vgi9NbxKOeZH0Xvhpph6EF7 mZgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=LJMVqb6H; 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 w2si370678itf.83.2017.06.22.00.41.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:16 -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=LJMVqb6H; 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 1dNwi8-0005ZE-0p; Thu, 22 Jun 2017 07:39:28 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwi6-0005Xv-9i for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:26 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id E8/E9-03696-D247B495; Thu, 22 Jun 2017 07:39:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsVyMfTASl2dEu9 Ig3NrLS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozrq7+zFMwKq7i6/QdjA2OLfRcjF4eQwAxG iV1njjGCOCwC85glZn/qYAFxJAT6WSXm9K0AynACOWkSM/r2skPY5RL/F6wGs4UEtCSOnprNC mHvY5L4/ku5i5GDg03ARGJWhwRIWERASeLeqslMIDOZBeYzSjRN6mUDSQgLhEicbm0G62URUJ WYvOYY2C5eAW+JZa9fMkPskpO4ea4TzOYU8JFYsWMh1F5voKsns0xgFFjAyLCKUaM4tagstUj XyFwvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMwtBiAYAfj4rWBhxglOZiURHn/ 53lHCvEl5adUZiQWZ8QXleakFh9ilOHgUJLgnVcElBMsSk1PrUjLzAEGOUxagoNHSYS3BaSVt 7ggMbc4Mx0idYrRmOPKlXVfmDimHNj+hUmIJS8/L1VKnFe0GKhUAKQ0ozQPbhAs+i4xykoJ8z ICnSbEU5BalJtZgir/ilGcg1FJmFcf5B6ezLwSuH2vgE5hAjrlxREPkFNKEhFSUg2Mm8Vctsx 3Mb6lwzV1q4JSy9eSvYGu7gmMW37qKDpNnOxxnXnfbP+PNV8nzQ7cOJch1H9uJ1/jg2t9BU6u lY5WTA+Emzp/GvzoPLZh0wuDH+rh+zSZuy5MCOSTqpaavvQgt9LaeYu3MJQv+X2g2rK41d5TW fF+kdm+x2eumMW+F1l+NO+K4b9TSizFGYmGWsxFxYkAjeu1urkCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1498117163!109018071!1 X-Originating-IP: [209.85.192.169] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11513 invoked from network); 22 Jun 2017 07:39:24 -0000 Received: from mail-pf0-f169.google.com (HELO mail-pf0-f169.google.com) (209.85.192.169) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:24 -0000 Received: by mail-pf0-f169.google.com with SMTP id s66so5119268pfs.1 for ; Thu, 22 Jun 2017 00:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OHe+jEk0KfLdo3wQD0Hbms4XIlaFN8a09YH5SErCB4o=; b=LJMVqb6H8PWSv6kgE9MVXxaEMcCNeAaOSSmsj8JCU3eVWpysci+8Y/OR3pOcSgNLa/ VXJE4nqCt1RRo0RCA9R7LQAzl+kePAq51j7Qgazp5U7JfqQusvzqPCrqvuifnZJHm0wT FY9nGPeD/EqFd0mQg+YnUCLzTlJDA2bMUWC6E= 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=OHe+jEk0KfLdo3wQD0Hbms4XIlaFN8a09YH5SErCB4o=; b=mlwinYulG08sPWrWxo6hM3vNN19v8/ZVS7xgB8qDRvEnztpIpTlfkUpRnOAEerKZe6 MuM29TWnjPL/n41UaJJLZ/scpleyqGCCNMkkQmiW7v/mnImMfza3QWGTI6w2hy5XNA0G 3o2XihRu9P2XdE7xapNNp1gOwKj9juA925Rvcq8pcSOusHVH9fi0xGf29DcubBCq1Tyk VoAhr3eq8katF6wuREM7HAzM1V9W4oryVdioHrIewYpDim3kCSJrxeUV1E2zSkYK3OeQ cOzWbGLGKdgW2WULtAOEZNpbH0Nxex1SBECaT4JG3z1eVYJjhfgJrtIiEFBCt8a/f7Jr lI4Q== X-Gm-Message-State: AKS2vOxXFQxB/10hDWcoizG7bBmm2m+QE0aOqxIOirUVXfJTom22xBPh icB8LNLEsfFUO9Q2V70aBg== X-Received: by 10.84.224.8 with SMTP id r8mr1413406plj.235.1498117162899; Thu, 22 Jun 2017 00:39:22 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:22 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:43 +0530 Message-Id: <1498117132-27139-9-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 08/17 v5] xen/arm: vpl011: Add a new domctl API to initialize vpl011 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add a new domctl API to initialize vpl011. It takes the GFN and console backend domid as input and returns an event channel to be used for sending and receiving events from Xen. Xen will communicate with xenconsole using GFN as the ring buffer and the event channel to transmit and receive pl011 data on the guest domain's behalf. Signed-off-by: Bhupinder Thakur --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since 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 | 6 ++++++ tools/libxl/libxl_arm.c | 22 ++++++++++++++++++++++ tools/libxl/libxl_dom.c | 4 ++++ tools/libxl/libxl_x86.c | 8 ++++++++ xen/arch/arm/domain.c | 5 +++++ xen/arch/arm/domctl.c | 37 +++++++++++++++++++++++++++++++++++++ xen/include/public/domctl.h | 12 ++++++++++++ 9 files changed, 139 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 1629f41..26f3d1e 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -885,6 +885,26 @@ int xc_vcpu_getcontext(xc_interface *xch, uint32_t vcpu, vcpu_guest_context_any_t *ctxt); +#if defined (__arm__) || defined(__aarch64__) +/** + * This function initializes the vpl011 emulation and returns + * the event to be used by the backend for communicating with + * the emulation code. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the domain to get information from + * @parm console_domid the domid of the backend console + * @parm gfn the guest pfn to be used as the ring buffer + * @parm evtchn the event channel to be used for events + * @return 0 on success, negative error on failure + */ +int xc_dom_vpl011_init(xc_interface *xch, + uint32_t domid, + uint32_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn); +#endif + /** * This function returns information about the XSAVE state of a particular * vcpu of a domain. If extstate->size and extstate->xfeature_mask are 0, diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 5d192ea..55de408 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; } +#if defined (__arm__) || defined(__aarch64__) +int xc_dom_vpl011_init(xc_interface *xch, + uint32_t domid, + uint32_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn) +{ + DECLARE_DOMCTL; + int rc = 0; + + domctl.cmd = XEN_DOMCTL_vuart_op; + domctl.domain = (domid_t)domid; + domctl.u.vuart_op.cmd = XEN_DOMCTL_VUART_OP_INIT_VPL011; + domctl.u.vuart_op.console_domid = console_domid; + domctl.u.vuart_op.gfn = gfn; + + if ( (rc = do_domctl(xch, &domctl)) < 0 ) + return rc; + + *evtchn = domctl.u.vuart_op.evtchn; + + return rc; +} +#endif + int xc_domain_getinfo(xc_interface *xch, uint32_t first_domid, unsigned int max_doms, diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h index 5e1fc60..118b92c 100644 --- a/tools/libxl/libxl_arch.h +++ b/tools/libxl/libxl_arch.h @@ -44,6 +44,12 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, libxl_domain_build_info *info, struct xc_dom_image *dom); +/* perform any pending hardware initialization */ +int libxl__arch_build_dom_finish(libxl__gc *gc, + libxl_domain_build_info *info, + struct xc_dom_image *dom, + libxl__domain_build_state *state); + /* build vNUMA vmemrange with arch specific information */ _hidden int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc, diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..9d6448e 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1038,6 +1038,28 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, return 0; } +int libxl__arch_build_dom_finish(libxl__gc *gc, + libxl_domain_build_info *info, + struct xc_dom_image *dom, + libxl__domain_build_state *state) +{ + int ret = 0; + + if ( info->arch_arm.vuart ) { + ret = xc_dom_vpl011_init(CTX->xch, + dom->guest_domid, + dom->console_domid, + dom->vuart_gfn, + &state->vuart_port); + if ( ret < 0 ) + { + LOG(ERROR, "xc_dom_vpl011_init failed\n"); + } + } + + return ret; +} + int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc, uint32_t domid, libxl_domain_build_info *info, diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index c98af60..9b42205 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -687,6 +687,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 76310ed..f1b24cc 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -665,6 +665,11 @@ fail: void arch_domain_destroy(struct domain *d) { + /* + * vpl011 is initialized via a DOMCTL call XEN_DOMCTL_vuart_op. + */ + domain_vpl011_deinit(d); + /* IOMMU page table is shared with P2M, always call * iommu_domain_destroy() before p2m_teardown(). */ diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index 86fa102..280c412 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -6,9 +6,11 @@ #include #include +#include #include #include #include +#include #include #include #include @@ -119,6 +121,41 @@ long arch_do_domctl(struct xen_domctl *domctl, struct domain *d, d->disable_migrate = domctl->u.disable_migrate.disable; return 0; + case XEN_DOMCTL_vuart_op: + { + int rc; + struct xen_domctl_vuart_op *vuart_op = &domctl->u.vuart_op; + + switch(vuart_op->cmd) + { + case XEN_DOMCTL_VUART_OP_INIT_VPL011: + + if ( !d->creation_finished ) + { + struct vpl011_init_info info; + + info.console_domid = vuart_op->console_domid; + info.gfn = _gfn(vuart_op->gfn); + + rc = domain_vpl011_init(d, &info); + if ( !rc ) + { + vuart_op->evtchn = info.evtchn; + rc = __copy_to_guest(u_domctl, domctl, 1); + } + } + else + rc = - EPERM; + + break; + + default: + rc = -EINVAL; + break; + } + + return rc; + } default: { int rc; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index f7cbc0a..0da8aa6 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 @@ -1138,6 +1139,15 @@ struct xen_domctl_psr_cat_op { uint32_t target; /* IN */ uint64_t data; /* IN/OUT */ }; + +struct xen_domctl_vuart_op { +#define XEN_DOMCTL_VUART_OP_INIT_VPL011 0 + uint32_t cmd; /* XEN_DOMCTL_VUART_OP_* */ + uint32_t console_domid; /* IN */ + xen_pfn_t gfn; /* IN */ + evtchn_port_t evtchn; /* OUT */ +}; + typedef struct xen_domctl_psr_cat_op xen_domctl_psr_cat_op_t; DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cat_op_t); @@ -1218,6 +1228,7 @@ struct xen_domctl { #define XEN_DOMCTL_monitor_op 77 #define XEN_DOMCTL_psr_cat_op 78 #define XEN_DOMCTL_soft_reset 79 +#define XEN_DOMCTL_vuart_op 80 #define XEN_DOMCTL_gdbsx_guestmemio 1000 #define XEN_DOMCTL_gdbsx_pausevcpu 1001 #define XEN_DOMCTL_gdbsx_unpausevcpu 1002 @@ -1280,6 +1291,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 Thu Jun 22 07:38:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106162 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327102qgd; Thu, 22 Jun 2017 00:41:13 -0700 (PDT) X-Received: by 10.36.120.72 with SMTP id p69mr723435itc.19.1498117273490; Thu, 22 Jun 2017 00:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117273; cv=none; d=google.com; s=arc-20160816; b=vH5njtC216vcjWPdE51/0P4wlcAcBQaeqDhvDrKvp7CIAOppQn5sNqqOEY/t2/J9m5 9DPQovTGeT3604i7/IRB5R50vYTu39yKaYXJtUq/MCpvKbHU74rbUuRz+t4ynHwJ4IWm 3GK4PCsLdO6HVjgvhLWgPL3SDqVniO9PdIzM0SB2Naq2z3ZOYqB3l9A8Q14/kMRITyXM k2DwJ66zzjB8VNTcMJIBdS+vMwb3My2NAJlFE9OVdUQM4ux3LMhMWLLzCYPMeN9D9nv2 0NKL86H6EykTDRGg+YJ/U887gT4YjmuNGD+LniC8oisVDW0HP6TyZLUZx8cfKCWA+cUP Tt2w== 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=kU4vXamHYE4CFySHyywyKE5/PfjSCyj3dywqMUu7ZyA=; b=qOWT49NeOAxlZBOIJsMw5qMjFOhf+tTC+889aNcYPoU3l3YQs9RmmVLkXJ/nCFIaf2 2gz9Gr9QUUOGdDAIDLV82ZK2/so1HSaKZ9+mbxL4PxIKt1CWAEwn5snQ/v4BOELa3OT9 mEzTGUyT4M8wlomiaMm3Gkgu2FkO8k18jn965b98OB3rbu1GYYa7ZpRQzuCV0QkK4Q3d pTh8kn0kmyR8WQ2rkoC8azFdcl7rIOnRDj+emRpp0lGikFaoubDRnPBYC4eigO896AbE qZQwiippD6O4XjHuMyxSFUeP0gRPswSMKeEFtHgeja59e0e/3ou0ZlJIwJD1ufObU3Pg LQcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=egjua/fe; 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 n138si363846itn.73.2017.06.22.00.41.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:13 -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=egjua/fe; 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 1dNwiA-0005bg-Cf; Thu, 22 Jun 2017 07:39:30 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwi8-0005aH-Rx for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:28 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 61/F8-03557-0347B495; Thu, 22 Jun 2017 07:39:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsXiVRtsoKtf4h1 pcP6tksX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmrHt1UPmgklWFcde72RqYNyp08XIySEkMJ1R 4tM1pi5GLg4WgXnMEhM/7WIGcSQE+lkl2npnMoJUSQikSaz52skOYZdJXNj1kA2iW0vi6KnZr CANQgL7mCR2zJ4ElODgYBMwkZjVIQFSIyKgJHFv1WSwDcwC8xklmib1gjULC/hL9D6exwJisw ioSvTNmA1m8wr4SLxffIEJYpmcxM1zncwgNidQfMWOhewQi70ldp2ZzDKBUWABI8MqRo3i1KK y1CJdY0O9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYzA0GIAgh2MTYsCDzFKcjAp ifJuLvaOFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBOwMkJ1iUmp5akZaZAwxymLQEB4+SCG9LH lCat7ggMbc4Mx0idYpRl2PSge1fmIRY8vLzUqXEedtBZgiAFGWU5sGNgEXcJUZZKWFeRqCjhH gKUotyM0tQ5V8xinMwKgnz6hcBTeHJzCuB2/QK6AgmoCNeHPEAOaIkESEl1cDIedBLe1brXxO TuVWOYSITuo0CJJPDGws4ewIeJcq9nn4lJbXihH3LlpItlVGWPGWbIvu27tbovbomoY5l76fq Ld+6Qg9LfvBqzD7aHPB936JG5rxLuz3Xhcmrv9p0JtG5TSN+YdTSrSffloisXiUm87aBbVGWl M5SX62JyRd3l/97yll1t1yJpTgj0VCLuag4EQAaMlaoswIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-12.tower-27.messagelabs.com!1498117166!107418873!1 X-Originating-IP: [74.125.83.48] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13103 invoked from network); 22 Jun 2017 07:39:27 -0000 Received: from mail-pg0-f48.google.com (HELO mail-pg0-f48.google.com) (74.125.83.48) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:27 -0000 Received: by mail-pg0-f48.google.com with SMTP id u62so4583085pgb.3 for ; Thu, 22 Jun 2017 00:39:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sXKovx9+9I1xBpizrIdSwnnHB+yomwhuD/tQ8AJHAlg=; b=egjua/feyyox2GMu7Y0ztwuAmWwISmz56GZRWJLQ3BsnURZ6/PgyV1WYd0OY33pNua z0ayl2F0iLAAjix0hyLNKloi/v9hv58N1EkYvs9CrH1DFwbnhxg5P7A6DuVugZuxnMbn n25JRrmdXDTYKsmBBXoJTJ5Ub9WVsuAUh2Uj8= 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=sXKovx9+9I1xBpizrIdSwnnHB+yomwhuD/tQ8AJHAlg=; b=qdCAXGNreSRIfh6FGVmDAlLztUPADcsb6sEheywuwi9lEjHtMgXHR4FDFPgJHGaVVb M717bR7t6sKNw49VdTna+jMBnVmLcSg3zInvc6/5ez+EFKIacLwegOjo4s8JtoPr64KQ NPcUHuSOZVCOqsRXi5XbY38s5ZUoRCDT9PFlQTXa0OmtbgWKQr5C7lwHanGgOSv0NAfI KhrjqD9gfyKt0SDISaEPnaXubtu7+7B8OuEgZpWhmXdAypWgujCGY5+z9BuvIhcwcODs vJvwciv18TQUzDDph9n3MwG97q6Qbxc+cXREm6jGdtjpOIIRWPQ5ToQ5wHpA5YEkDxSO NoJw== X-Gm-Message-State: AKS2vOz75Wo9IQBzuqz0slZisrvfxB4M1bCD+KuxXK6V1j6zCRQQEdVu 8TC5cdWxiCHYQBd8b24igA== X-Received: by 10.84.138.1 with SMTP id 1mr1437314plo.188.1498117165818; Thu, 22 Jun 2017 00:39:25 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:25 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:44 +0530 Message-Id: <1498117132-27139-10-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 09/17 v5] 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 | 10 +++++++- tools/libxl/libxl_device.c | 9 ++++++-- tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_types_internal.idl | 1 + 5 files changed, 64 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 bffbc45..cfd85ec 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,14 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, libxl__device_vkb_add(gc, domid, &d_config->vkbs[i]); } + if (d_config->b_info.arch_arm.vuart) + { + init_console_info(gc, &vuart, 0); + vuart.backend_domid = state->console_domid; + libxl__device_vuart_add(gc, domid, &vuart, state); + libxl__device_console_dispose(&vuart); + } + init_console_info(gc, &console, 0); console.backend_domid = state->console_domid; libxl__device_console_add(gc, domid, &console, state, &device); diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 00356af..3b10c58 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -26,6 +26,9 @@ static char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device) if (device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0) return GCSPRINTF("%s/console", dom_path); + if (device->kind == LIBXL__DEVICE_KIND_VUART) + return GCSPRINTF("%s/vuart/%d", dom_path, device->devid); + return GCSPRINTF("%s/device/%s/%d", dom_path, libxl__device_kind_to_string(device->kind), device->devid); @@ -170,7 +173,8 @@ retry_transaction: * historically contained other information, such as the * vnc-port, which we don't want the guest fiddling with. */ - if (device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0) + if ((device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0) || + (device->kind == LIBXL__DEVICE_KIND_VUART)) xs_set_permissions(ctx->xsh, t, frontend_path, ro_frontend_perms, ARRAY_SIZE(ro_frontend_perms)); else @@ -800,7 +804,8 @@ void libxl__devices_destroy(libxl__egc *egc, libxl__devices_remove_state *drs) dev->domid = domid; dev->kind = kind; dev->devid = atoi(devs[j]); - if (dev->backend_kind == LIBXL__DEVICE_KIND_CONSOLE) { + if (dev->backend_kind == LIBXL__DEVICE_KIND_CONSOLE || + dev->backend_kind == LIBXL__DEVICE_KIND_VUART) { /* Currently console devices can be destroyed * synchronously by just removing xenstore entries, * this is what libxl__device_destroy does. diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index d0d50c3..2b3f4e1 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1206,6 +1206,9 @@ _hidden int libxl__device_console_add(libxl__gc *gc, uint32_t domid, libxl__device_console *console, libxl__domain_build_state *state, libxl__device *device); +_hidden int libxl__device_vuart_add(libxl__gc *gc, uint32_t domid, + libxl__device_console *console, + libxl__domain_build_state *state); /* Returns 1 if device exists, 0 if not, ERROR_* (<0) on error. */ _hidden int libxl__device_exists(libxl__gc *gc, xs_transaction_t t, diff --git a/tools/libxl/libxl_types_internal.idl b/tools/libxl/libxl_types_internal.idl index 7dc4d0f..c463c33 100644 --- a/tools/libxl/libxl_types_internal.idl +++ b/tools/libxl/libxl_types_internal.idl @@ -26,6 +26,7 @@ libxl__device_kind = Enumeration("device_kind", [ (9, "VUSB"), (10, "QUSB"), (11, "9PFS"), + (12, "VUART"), ]) libxl__console_backend = Enumeration("console_backend", [ From patchwork Thu Jun 22 07:38:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106172 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327175qgd; Thu, 22 Jun 2017 00:41:27 -0700 (PDT) X-Received: by 10.107.162.68 with SMTP id l65mr951150ioe.90.1498117287577; Thu, 22 Jun 2017 00:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117287; cv=none; d=google.com; s=arc-20160816; b=S2ehnvZg0C3wdBejleJJoB2D+80g8ZYN2Xqu5zkL24g9UXvGFc0O5igY6bG7Z26Uwu tVBChuW7yUlAMb5yv4aKKVgTMgaKR8qgTyP5kmSol/DdzkzqecNPnzcb4AcX7fG4dcSr Zc13FRmpOtta7FFn8lvqqfcU1SVvf0BIpfV/fTlZgwC4iskhvZBbgG0IVkCW1xDkzB0x BLo/5bvJerMRfOaYgX3rk/4RDiGXLqfy0O2UBvwQGLArF4oho9YAeOnLLdd9O/jky9NK e5AWhF7t4BjD2bhVziM16rbZaNo00Te+u12Iq03gh/+nLkoD5owgt3UFZ4/AZHaNWPWF arVQ== 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=9j2CIR2UowR/bP9ITuWANcIF+NUCsjo+M3ieqGVAHIc=; b=UgoFZ/plazpVZuLbgXBir2O8BHssRTynNZ5x7l1tRedzna1XQZvOm6gyyD8ZDwI0It Xox9VbebcUXCBNKui2jzzpH/SFbaM9Psk2M/MDLv96dfUIqMxXIZcZvQZKUUBy6u5u/g o0kHLfrMcxsutkX9vWF0jr60x58p73Lc2LGQdOwo9+k16QRh9WZSTy++HR7oP6qbhKJZ jCn4ZZdquHNaFjNoSz3TU9mlA0DWuv2H4abH6I3TdG3JERDjrAv9P8fZlwMR29rSX3I7 x18UBW0YAfdvshAo8+QSLlIVqU7fg/MJ7m/aDA3A+F4TwgUwhZ/x1ImdnnafA6Rszqr4 W5PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=AmLNcOVV; 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 p12si775071ioo.242.2017.06.22.00.41.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:27 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=AmLNcOVV; 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 1dNwiF-0005gK-L0; Thu, 22 Jun 2017 07:39:35 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwiE-0005fT-St for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:35 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id F3/A8-01735-6347B495; Thu, 22 Jun 2017 07:39:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRWlGSWpSXmKPExsVyMfTAVl3TEu9 Igzn/+Sy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxlvX+YCw4uYqw40b+NvYHxdDNjFyMXh5DA dEaJhnsTmUAcFoF5zBLfTm5lAXEkBPpZJS6++MbWxcgB5KRJzLqk2sXICWSWSyx59pcJxBYS0 JI4emo2K8SkfUwS19tnMIPUswmYSMzqkACpERFQkri3ajLYAmaB+YwSTZN62UASwkAzz255ww piswioSqzZdoERxOYV8JF4tv0nE8QyOYmb5zqZQWxOoPiKHQvZIRZ7S+w6M5llAqPAAkaGVYw axalFZalFusYGeklFmekZJbmJmTm6hgamermpxcWJ6ak5iUnFesn5uZsYgeFVz8DAuINxwiq/ Q4ySHExKorz/87wjhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwKhcD5QSLUtNTK9Iyc4CBDpOW4 OBREuFtAWnlLS5IzC3OTIdInWK05LhyZd0XJo4Nq9cDySkHtn9hEmLJy89LlRLnFQWZJwDSkF GaBzcOFo2XGGWlhHkZGRgYhHgKUotyM0tQ5V8xinMwKgnz6hcBTeHJzCuB2/oK6CAmoINeHPE AOagkESEl1cC459ER0WVqQswBr3N//tq/bV6b48evs34zcIcmfPm+681ew0lHeDcc0PLUrtMN rJTat3vzy1uvWtgU7y6QYp287+y5upzK/q7Fr8XL2I696z2wpqn91E7mhrInSyyWBDBdtnU1W /j4j/7Xf2z2zp/NPN+nWjenRn/8cctyYVqqf3LyHe7Zh6zblViKMxINtZiLihMBmuWFa8ECAA A= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1498117171!89028782!1 X-Originating-IP: [209.85.192.181] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52045 invoked from network); 22 Jun 2017 07:39:32 -0000 Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:32 -0000 Received: by mail-pf0-f181.google.com with SMTP id e7so5153808pfk.0 for ; Thu, 22 Jun 2017 00:39: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=cNCILb7bVRIii38uyV44/OIVObTX3cweVyxlMkB+sHQ=; b=AmLNcOVVBjrq0u7AmNSfYDD1TgMG6UP0YdXCquR37ezwdcxYpMImFiXrEuszdwSBga r4hMNo0uhZA/hBZEyB8YY6x5KYR9ZxhKpmNN9JY7KIxodZ+RSws4E5J6FEwTnAJPwHqD 1DoWH9L9DfBcO0LLjyAgYfG1KlCLcf/3FqNFo= 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=cNCILb7bVRIii38uyV44/OIVObTX3cweVyxlMkB+sHQ=; b=laSgwR42ikqjdVzPR/NNapC2s31+ptJ7LFO98izEuORsnC9j3zN9bqSgbs3Hlr+1yo sRouUUm5ePAsA4Z9THslFF2pDs6ucjmfreFXRUmhXut6eE2ZOKZ63CQ4Lz905BKj0F4G 1Q9A5uLY4ZvzApolvWwvMdxqRpYQu0zTKHabcX1gtXL17fCYPZHL1y2f2wf6YMn2Pudp JQRSmqhAnrbh/rcUv2+eKc7znQp/PpBoPeconTnmFmTxwsXx0tzgLASzAmLdYxlZguoo NvrvmE16/OZhJhzc5lWUxk5Lcfb+2SKuAq1PyfnUmBLOWuvHnErLxwcfMk+zkxZ4TkJK Ylxg== X-Gm-Message-State: AKS2vOwzYLBxnr3IL5ZvJtwDHdC+ZTuJOvSppBViTX0NgxhaUxCGrF5J opyEExyJQd2bZLUElNhvUA== X-Received: by 10.101.70.70 with SMTP id k6mr1287209pgr.39.1498117171044; Thu, 22 Jun 2017 00:39:31 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:29 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:45 +0530 Message-Id: <1498117132-27139-11-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 10/17 v5] 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 Thu Jun 22 07:38:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106169 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327142qgd; Thu, 22 Jun 2017 00:41:22 -0700 (PDT) X-Received: by 10.107.167.199 with SMTP id q190mr1009363ioe.110.1498117281994; Thu, 22 Jun 2017 00:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117281; cv=none; d=google.com; s=arc-20160816; b=CCyglaJuQXK8GUenSt4SGQhkwV6zxWO2f9TjCQ8/Qj9QV4zesFngz210d9As8nf8xd m2xNSQW0IW58ZRO47zdduE3v/EOnvK3UhFyvDJG2p4MZJCWy/zS0AG+6Y8eH2FXkjyHd ZpkfdtsfBuT4GZR78oSjzaoQrcukjlTrpeYVoWXeMFBr0KaxGc2/1TlXkwryENAayfaB VpeyEu1LfyPp4KGjToGx/rXsu7WB8pqJSHXIAd6RL6+z3B7PVGPO1IHoTEqzCwVO5eNe ulcnFVRy6i0vMK2oYRgrLHGFgZ8gOZ0r80Gs33wTrzUsY+eujO7OCze8e0aAI1VrZ1A4 Q0YQ== 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=XrfDSSB1XjSuerrEg6bweFztwJhi2E5WcwBzcBPfhkY=; b=fNDYcGJzhlZ7vxeoFdaJWwVIf83sqTlB5sVfoLfGyq+Iqc44DdHG3sffOYN/3EJq+/ 51byYs66aQPlMJr+GARxeSDKkGddR/Tb0vJ53TFH3mLnBY+Lgrw6o0ULTvscqfmJ6lWF Z2qalaYk4FzQU5kh7WoSB77UvwTgwSLXFbMJHq3yO0tjHycXJ/rcvj7+V4XxPJfsuL3n 3hNKzLJcvQNiB/PHEbCjhmUNxFa8wS3kIjD3ZjJZXWOCpLGBpxoMJcXt45j7rSxercaE pHpLF4yyU6lOdE7LQAQJo7/q7RdRwCP6Md6hiBz9tUgNcQyvnNleSh6jw8JKrihvwoKn 386A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Vr8ePQh0; 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 b5si680230iog.279.2017.06.22.00.41.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:21 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Vr8ePQh0; 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 1dNwiI-0005jR-0W; Thu, 22 Jun 2017 07:39:38 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwiH-0005hq-4Y for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:37 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id A6/FD-01730-8347B495; Thu, 22 Jun 2017 07:39:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsVyMfTABl3zEu9 Ig+89ihbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b5y5vYC+ZIV5ze94m5gfGZWBcjF4eQwAxG iev7JjGDOCwC85glLmw/zAbiSAj0s0rseTmNvYuRE8hJk3h1s4cZwq6UWL7+GxuILSSgJXH01 GxWCHsfk8SVvzpdjBwcbAImErM6JEDCIgJKEvdWTWYCmcksMJ9RomlSL1ivsECCxMPFu5hAbB YBVYl9d/eDzeEV8JG4t6mNEWKXnMTNc51gezmB4it2LGSH2OUtsevMZJYJjAILGBlWMWoUpxa VpRbpGhrqJRVlpmeU5CZm5ugaGpjq5aYWFyemp+YkJhXrJefnbmIEhhYDEOxgXNnufIhRkoNJ SZT3f553pBBfUn5KZUZicUZ8UWlOavEhRhkODiUJXuVioJxgUWp6akVaZg4wyGHSEhw8SiK8L SCtvMUFibnFmekQqVOMxhxXrqz7wsQx5cD2L0xCLHn5ealS4ryiIJMEQEozSvPgBsGi7xKjrJ QwLyPQaUI8BalFuZklqPKvGMU5GJWEefWLgKbwZOaVwO17BXQKE9ApL454gJxSkoiQkmpgdCr VKl3bNT0karaZXt8s9uM3RF7uiuvilzaq61STNJNZbSGgaZz17LBe09Vpk6VN6qdvtfrw9/D0 T8errZTu/xNtObrn06zFTNe77YzWOun3GBiqvQzqlRbZfSL4rdU0w802/w/ryJlMzZp/T97rR e/0zWHO52+IFny4lr7ZhT3LpTAoQE1NiaU4I9FQi7moOBEA5s/scbkCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-206.messagelabs.com!1498117174!104400575!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21534 invoked from network); 22 Jun 2017 07:39:35 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-8.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:35 -0000 Received: by mail-pf0-f176.google.com with SMTP id s66so5120860pfs.1 for ; Thu, 22 Jun 2017 00:39: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=MpMFLIYj7J9yQ90VLo2ETIWIMt6mnltxIbQjgHJnEQg=; b=Vr8ePQh0gM3OI8yLNfv3o91br67GMNghkGpWMtkgVtzCsqpHDobNdNhUQ4DsLrQaB/ pOqGbZDvF25jgI+Uanz8d1qWFqXWLmG2EIH6amcSbkW5/15zo4w2OoE83g3IDIgBjSz/ DgIrChZsOO1pu3sWDfx+El9JhZ1RNMcAZsQJI= 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=MpMFLIYj7J9yQ90VLo2ETIWIMt6mnltxIbQjgHJnEQg=; b=iHTPQb7VQN2Cwzy1GbqZZHKRzSoU9GA4N/ottso3JxeYD9gEUEq6A+CoafrF0Vuxwe ligJcodPmVcI44aPzok968b82ZxBQg6YFhkm/UHlwb5KDVEXFlkMEU1djDSK14t58HJz 6gZdTTK8YRDRInbGHgAJwERp/aGWjJAWdDDUg7JYVhasAFLj+SxGX3/mPqO91I8W6nW8 Qd/D+Tp6KsfSOwpB/rVm18OUqltiYWLif0/vw127CA73D8xw7CiNdVmgmJYkb4w/upiN Opdu3g24RvyG1hHsWwsdV83kter9HdN49AvyZkKR+LQIVJAyu1neQb/m11Vton5HE2Ub krsw== X-Gm-Message-State: AKS2vOzTymnHW0yeCh7aNptuc99k2SfIUnvNWzCd8LLmO+1zdNBjtsK9 CKuPfTZidXt2F4L0nvEG+w== X-Received: by 10.84.231.135 with SMTP id g7mr1419735plk.110.1498117173864; Thu, 22 Jun 2017 00:39:33 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:33 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:46 +0530 Message-Id: <1498117132-27139-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/17 v5] 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 Thu Jun 22 07:38:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106174 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327265qgd; Thu, 22 Jun 2017 00:41:45 -0700 (PDT) X-Received: by 10.107.8.215 with SMTP id h84mr988212ioi.69.1498117305076; Thu, 22 Jun 2017 00:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117305; cv=none; d=google.com; s=arc-20160816; b=wC2EdT1cQMALPapXd62Y78mxj2w4k469F20pB7hDNjBpYLEnFXJLDnCuS5itJKk5o2 q/huCwJcOhQHYEYP+qtFvBcVtOv1NO1UxujzfTjUfjgqoZZLmS8Lj+vjaTEZdJ8G0LUv ZVJB60CGSnQpw27ONauZC8pm1st39+NiKpTGh8+g//ELBoVD+iFliCGqW6OWALqDO4zs x48Hyui04Q8Zv3Pnz/A5h85MTEJXVMH5zLovAt7Dv0kicDA7SxsvHbBq8gGmL1tPMzFk TWDpamAmLUFFUN//CyqO//LD5uBThCyDuRIcx9f0ij/OXPSHsBjHFBxXNUbMr1Fbl6IA UWRw== 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=XPBRwNP2z8fiCUYVdHnnpoVq0flE3dSiGZ+2xa4nf38=; b=eRQKZnHugUQmUUjD8IyJUykawLfcluayg1UVGDD3prStqjM7dAV+0/Gu7/2Py682hz 5+M9v7Z/PsThsB/tW2r5BH66Cf9l4I7r8BGpkG8x+7t/N8yfJ1R1w76rnXRah5/TmeM7 Pj+jh1mmtdjizv89YPDACx4yevit/LO3FOumoo2DwYRz8JyaY0dBfh6FACPJdQs/xj1a 7AFx5Bs1kEDRjH/9v6luuMLKlu79KHuvhta5/EEtnzn6yLj/ryUgIprZRp9MWA5alLw9 Q2NWIVAuoVUNcVDmh9/WXnroL+jW2ZHr9Fd1GgFZ1PRpAUeOyOoRSlQo/awNE0YYCWXT Wtew== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=jyELvP2v; 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 z199si375738itb.85.2017.06.22.00.41.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41: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=jyELvP2v; 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 1dNwiM-0005om-8L; Thu, 22 Jun 2017 07:39:42 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwiL-0005mv-49 for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:41 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 22/3E-01992-C347B495; Thu, 22 Jun 2017 07:39:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfTAFl3rEu9 Ig307xS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ow///+zFhz0rPg56yt7A+NVmy5GLg4hgRmM EguP/GbtYuTkYBGYxyzRfM8AJCEh0M8qcePfExaQhIRAmsTLJdOh7EqJizuuMILYQgJaEkdPz WaFmLSPSWLP8XtADgcHm4CJxKwOCZAaEQEliXurJjOB1DALzGeUaJrUywaSEBbIlDjz4yATSD 2LgKrE38MqIGFeAR+J89c72CB2yUncPNfJDGJzAsVX7FjIDrHXW2LXmcksExgFFjAyrGLUKE4 tKkst0jUy1ksqykzPKMlNzMzRNTQw1ctNLS5OTE/NSUwq1kvOz93ECAysegYGxh2MO9r9DjFK cjApifL+z/OOFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBq1wMlBMsSk1PrUjLzAGGOExagoNHS YS3BaSVt7ggMbc4Mx0idYrRmOPKlXVfmDimHNj+hUmIJS8/L1VKnHd2EVCpAEhpRmke3CBY7F 1ilJUS5mVkYGAQ4ilILcrNLEGVf8UozsGoJMyrDzKFJzOvBG7fK6BTmIBOeXHEA+SUkkSElFQ DY01g0sR7TQsOpi34zhybflF/Dd/MpW5WGxaUC1TK5iqWBgXypq+tz+vXauO2rQ0wLOqQ9Foy 9SSPQm1v6JKTvn5uewKTU30Tlx1g2FKfsG3xzfRvtvUPbjf9MNS+Fcjk2SVfaCczNfuuQuSi0 PIDdR6Hdxo+W3eiwFfTe0F19+cNPfFuC1WUWIozEg21mIuKEwEgLE5HuAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-206.messagelabs.com!1498117178!100948003!1 X-Originating-IP: [209.85.192.180] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27467 invoked from network); 22 Jun 2017 07:39:39 -0000 Received: from mail-pf0-f180.google.com (HELO mail-pf0-f180.google.com) (209.85.192.180) by server-3.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:39 -0000 Received: by mail-pf0-f180.google.com with SMTP id c73so5131531pfk.2 for ; Thu, 22 Jun 2017 00:39:38 -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=0VlPY7ezJVvMAptDe7WOlRVIfVn5WlbHc6weXyYkglA=; b=jyELvP2v55aamwz+0IKIg3BKy/irTsQLVQO/Nw3lwrt+TuMeWuFJFz8DUE8+U0Ckjj AjnMY2isPynkQHM156Q2dalUK1v1AjlcOgdZgCsYKnSQpKfPLAO0u4ZX0KVkcPKbxWZ5 5GqsCEEggshO3dFzmmG2B9MX87UTBdky32mOM= 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=0VlPY7ezJVvMAptDe7WOlRVIfVn5WlbHc6weXyYkglA=; b=X8qIdSqbRQdKLITMxUZA00FaUkWnw/vhdZjdNiUgWGaKyuM+BSx0Kc+dp9fhOMbCBB n9/PWbkR4hU8pdrIgUfrOuuosw2SSiunmTpctloa46oB3l1Mx90Fv0wqcf4dfz/e7uAN r/EldB/BUQ629y5g99sX0kbzjnySjfnt3d6e4MvneUNd7J6gTeWO1XkWzQ7h38nUGf84 DEEnDQ/u89jVYWWaWhkbnR3TJrybBxHeby63TMP9XMOZl97VEf/+/CFLZpgY7sJiYCIf GdxPCCoxOwvBNOwYX0biX43+pAnye0i27nBO68S4NvurcQmwGj43441uDpfn5X8bNWkM r1qA== X-Gm-Message-State: AKS2vOwuhT8Do8GAk3fgVBfnJIkXIV8/OxxnwTdWAddMqC8evkcEBla+ pqjqBPrb3HJZ+JRFC1R3vg== X-Received: by 10.84.232.197 with SMTP id x5mr1374039plm.159.1498117177375; Thu, 22 Jun 2017 00:39:37 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:36 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:47 +0530 Message-Id: <1498117132-27139-13-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 12/17 v5] xen/arm: vpl011: Modify xenconsole functions to take console structure as input X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Xenconsole functions take domain structure as input. These functions shall be modified to take console structure as input since these functions typically perform console specific operations. Also the console specific functions starting with prefix "domain_" shall be modified to "console_" to indicate that these are console specific functions. This patch is in preparation to support multiple consoles to support vuart console. Signed-off-by: Bhupinder Thakur Acked-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v3: - The changes in xenconsole have been split into four patches. This is the second patch. tools/console/daemon/io.c | 79 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 6f5c69c..a2a3496 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -163,10 +163,10 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } -static void buffer_append(struct domain *dom) +static void buffer_append(struct console *con) { - struct console *con = &dom->console; struct buffer *buffer = &con->buffer; + struct domain *dom = con->d; XENCONS_RING_IDX cons, prod, size; struct xencons_interface *intf = con->interface; @@ -296,12 +296,13 @@ static int create_hv_log(void) return fd; } -static int create_domain_log(struct domain *dom) +static int create_console_log(struct console *con) { char logfile[PATH_MAX]; char *namepath, *data, *s; int fd; unsigned int len; + struct domain *dom = con->d; namepath = xs_get_domain_path(xs, dom->domid); s = realloc(namepath, strlen(namepath) + 6); @@ -342,10 +343,8 @@ static int create_domain_log(struct domain *dom) return fd; } -static void domain_close_tty(struct domain *dom) +static void console_close_tty(struct console *con) { - struct console *con = &dom->console; - if (con->master_fd != -1) { close(con->master_fd); con->master_fd = -1; @@ -417,7 +416,7 @@ void cfmakeraw(struct termios *termios_p) } #endif /* __sun__ */ -static int domain_create_tty(struct domain *dom) +static int console_create_tty(struct console *con) { const char *slave; char *path; @@ -426,7 +425,7 @@ static int domain_create_tty(struct domain *dom) char *data; unsigned int len; struct termios term; - struct console *con = &dom->console; + struct domain *dom = con->d; assert(con->slave_fd == -1); assert(con->master_fd == -1); @@ -487,7 +486,7 @@ static int domain_create_tty(struct domain *dom) return 1; out: - domain_close_tty(dom); + console_close_tty(con); return 0; } @@ -526,10 +525,8 @@ static int xs_gather(struct xs_handle *xs, const char *dir, ...) return ret; } -static void domain_unmap_interface(struct domain *dom) +static void console_unmap_interface(struct console *con) { - struct console *con = &dom->console; - if (con->interface == NULL) return; if (xgt_handle && con->ring_ref == -1) @@ -540,11 +537,11 @@ static void domain_unmap_interface(struct domain *dom) con->ring_ref = -1; } -static int domain_create_ring(struct domain *dom) +static int console_create_ring(struct console *con) { int err, remote_port, ring_ref, rc; char *type, path[PATH_MAX]; - struct console *con = &dom->console; + struct domain *dom = con->d; err = xs_gather(xs, con->xspath, "ring-ref", "%u", &ring_ref, @@ -563,7 +560,7 @@ static int domain_create_ring(struct domain *dom) /* If using ring_ref and it has changed, remap */ if (ring_ref != con->ring_ref && con->ring_ref != -1) - domain_unmap_interface(dom); + console_unmap_interface(con); if (!con->interface && xgt_handle) { /* Prefer using grant table */ @@ -621,7 +618,7 @@ static int domain_create_ring(struct domain *dom) con->remote_port = remote_port; if (con->master_fd == -1) { - if (!domain_create_tty(dom)) { + if (!console_create_tty(con)) { err = errno; xenevtchn_close(con->xce_handle); con->xce_handle = NULL; @@ -632,7 +629,7 @@ static int domain_create_ring(struct domain *dom) } if (log_guest && (con->log_fd == -1)) - con->log_fd = create_domain_log(dom); + con->log_fd = create_console_log(con); out: return err; @@ -648,7 +645,7 @@ static bool watch_domain(struct domain *dom, bool watch) if (watch) { success = xs_watch(xs, con->xspath, domid_str); if (success) - domain_create_ring(dom); + console_create_ring(con); else xs_unwatch(xs, con->xspath, domid_str); } else { @@ -695,6 +692,7 @@ static struct domain *create_domain(int domid) con->slave_fd = -1; con->log_fd = -1; con->xce_pollfd_idx = -1; + con->d = dom; con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; @@ -746,7 +744,7 @@ static void cleanup_domain(struct domain *d) { struct console *con = &d->console; - domain_close_tty(d); + console_close_tty(con); if (con->log_fd != -1) { close(con->log_fd); @@ -768,7 +766,7 @@ static void shutdown_domain(struct domain *d) d->is_dead = true; watch_domain(d, false); - domain_unmap_interface(d); + console_unmap_interface(con); if (con->xce_handle != NULL) xenevtchn_close(con->xce_handle); con->xce_handle = NULL; @@ -799,9 +797,8 @@ static void enum_domains(void) } } -static int ring_free_bytes(struct domain *dom) +static int ring_free_bytes(struct console *con) { - struct console *con = &dom->console; struct xencons_interface *intf = con->interface; XENCONS_RING_IDX cons, prod, space; @@ -816,30 +813,30 @@ static int ring_free_bytes(struct domain *dom) return (sizeof(intf->in) - space); } -static void domain_handle_broken_tty(struct domain *dom, int recreate) +static void console_handle_broken_tty(struct console *con, int recreate) { - domain_close_tty(dom); + console_close_tty(con); if (recreate) { - domain_create_tty(dom); + console_create_tty(con); } else { - shutdown_domain(dom); + shutdown_domain(con->d); } } -static void handle_tty_read(struct domain *dom) +static void handle_tty_read(struct console *con) { ssize_t len = 0; char msg[80]; int i; - struct console *con = &dom->console; struct xencons_interface *intf = con->interface; + struct domain *dom = con->d; XENCONS_RING_IDX prod; if (dom->is_dead) return; - len = ring_free_bytes(dom); + len = ring_free_bytes(con); if (len == 0) return; @@ -853,7 +850,7 @@ static void handle_tty_read(struct domain *dom) * keep the slave open for the duration. */ if (len < 0) { - domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); + console_handle_broken_tty(con, domain_is_valid(dom->domid)); } else if (domain_is_valid(dom->domid)) { prod = intf->in_prod; for (i = 0; i < len; i++) { @@ -864,15 +861,15 @@ static void handle_tty_read(struct domain *dom) intf->in_prod = prod; xenevtchn_notify(con->xce_handle, con->local_port); } else { - domain_close_tty(dom); + console_close_tty(con); shutdown_domain(dom); } } -static void handle_tty_write(struct domain *dom) +static void handle_tty_write(struct console *con) { ssize_t len; - struct console *con = &dom->console; + struct domain *dom = con->d; if (dom->is_dead) return; @@ -882,7 +879,7 @@ static void handle_tty_write(struct domain *dom) if (len < 1) { dolog(LOG_DEBUG, "Write failed on domain %d: %zd, %d\n", dom->domid, len, errno); - domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); + console_handle_broken_tty(con, domain_is_valid(dom->domid)); } else { buffer_advance(&con->buffer, len); } @@ -901,7 +898,7 @@ static void handle_ring_read(struct domain *dom) con->event_count++; - buffer_append(dom); + buffer_append(con); if (con->event_count < RATE_LIMIT_ALLOWANCE) (void)xenevtchn_unmask(con->xce_handle, port); @@ -925,7 +922,7 @@ static void handle_xs(void) /* We may get watches firing for domains that have recently been removed, so dom may be NULL here. */ if (dom && dom->is_dead == false) - domain_create_ring(dom); + console_create_ring(&dom->console); } free(vec); @@ -975,7 +972,7 @@ static void handle_log_reload(void) if (con->log_fd != -1) close(con->log_fd); - con->log_fd = create_domain_log(d); + con->log_fd = create_console_log(con); } } @@ -1121,7 +1118,7 @@ void handle_io(void) if (con->master_fd != -1) { short events = 0; - if (!d->is_dead && ring_free_bytes(d)) + if (!d->is_dead && ring_free_bytes(con)) events |= POLLIN; if (!buffer_empty(&con->buffer)) @@ -1208,15 +1205,15 @@ void handle_io(void) if (con->master_fd != -1 && con->master_pollfd_idx != -1) { if (fds[con->master_pollfd_idx].revents & ~(POLLIN|POLLOUT|POLLPRI)) - domain_handle_broken_tty(d, + console_handle_broken_tty(con, domain_is_valid(d->domid)); else { if (fds[con->master_pollfd_idx].revents & POLLIN) - handle_tty_read(d); + handle_tty_read(con); if (fds[con->master_pollfd_idx].revents & POLLOUT) - handle_tty_write(d); + handle_tty_write(con); } } From patchwork Thu Jun 22 07:38:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106175 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327287qgd; Thu, 22 Jun 2017 00:41:48 -0700 (PDT) X-Received: by 10.36.73.131 with SMTP id e3mr730184itd.0.1498117308805; Thu, 22 Jun 2017 00:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117308; cv=none; d=google.com; s=arc-20160816; b=icphjOUCPI+VyxV/bWOV1dKtSjNePQh7gR5K7CAyllUt6Sh631sFXMAeEm7yVXq4HL CxeKQ3UYNx72M4FVxmBGiC6N58a9U0m5y0Xxb/XWw2OWwrJ5mebzGPV+NWQCBfw9sS1r +ayEqnjGsF8uzhV72aonOIq2CzvXbF7QyjjcYKc41b4ugpz9oj6caHhkZSo4SjbHALO6 fPqcLJSdJehB/1vfm+et8UmfAo+hl6r0+UPAw+kzdwjN/d2hnB89vXlb4JqA+bzUq1Sf RU1s19Y4UGh91RxLWZqkCO5KcHc+vxylnY2D8wc++ZU3ksucT43XKIUWUIZvYANsgHQm w5yw== 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=XYy9gAxkpqty8dNbUp8PpDWrKgPDy2bwqfb7n4zrdDE=; b=Aif+ftQuqARZxtEijZrusg8aKr48yhsa4vNRnFgyBRi5HqJiTH/PxB132BrznFTzRt gVccj7p22TPlPc+/oeKTd8n9UTk0d5KrpsIkKG1j+FHIa58aMNCKJp76CSXgGLgYpYBy z2PmJmLqIA+fZjgUMel5/Fp6JVqc6XjwOEmWijPtykYX2kkwcrG+G3quQZfck/YsiLwL d6CPOjUF9wHELo1f6Mpyw58KuCHFYELk3LWP5j35+XGjUCM6e63VT4vBqFXSPOkRtCtd jCUNRdC+rYsOkSpyxkDEgqbn1N4Aq9fSH+NnnMoD+VwcGHzniiZnj1dy3Iq/Dj4bgIPI Qd/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=c1vNS+84; 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 s125si371923ita.119.2017.06.22.00.41.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41: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=c1vNS+84; 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 1dNwiP-0005s5-H7; Thu, 22 Jun 2017 07:39: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 1dNwiN-0005qP-S7 for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:44 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 20/14-03613-F347B495; Thu, 22 Jun 2017 07:39:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRtsqmtX4h1 psPoGl8X3LZOZHBg9Dn+4whLAGMWamZeUX5HAmjFr/lHmgnUtjBWfetaxNDD+ze5i5OIQEpjO KNE45QsTiMMiMI9Z4vHllcwgjoRAP6vEvdMHGLsYOYCcNIknu9i7GDmBzCqJA/evgtlCAloSR 0/NZoWYtI9JomfKXVaQejYBE4lZHRIgNSICShL3Vk0GW8AsMJ9RomlSLxtIQlggUuLKieMsID aLgKpEQ+MzsKG8Aj4Sk2ZcYoJYJidx81wnM4jNCRRfsWMh1GJviV1nJrNMYBRYwMiwilGjOLW oLLVI19BML6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMLgYgGAH4/2NAYcYJTmY lER5/+d5RwrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4FUuBsoJFqWmp1akZeYAwxwmLcHBoyTC2 wLSyltckJhbnJkOkTrFaMyxYfX6L0wckw5s/8IkxJKXn5cqJc4rCjJJAKQ0ozQPbhAs/i4xyk oJ8zICnSbEU5BalJtZgir/ilGcg1FJmFe/CGgKT2ZeCdy+V0CnMAGd8uKIB8gpJYkIKakGRr+ N2t/EMucdsdO4ZS8bPXc756FPuZGTlnGujrz2929pckmb5ippi+/PtsXttjPp6AyNEV92wrb9 jEdY3ZmrexJn2PrdPf5GamNs4/kjbHqKAcEWIilK3RvP5dr+dVsqxBxwtGtuPL/3afWJNzS6j oZllOoVcYfeXdHa87XzZuLffRFciT99lViKMxINtZiLihMBNq4fyLoCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-16.tower-27.messagelabs.com!1498117181!108574953!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51774 invoked from network); 22 Jun 2017 07:39:41 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-16.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:41 -0000 Received: by mail-pg0-f53.google.com with SMTP id 132so4600063pgb.2 for ; Thu, 22 Jun 2017 00:39: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=xxwmGn5aet+IeQX2uXeayC9kd/Pq+fM/GcsQ8yi8eu4=; b=c1vNS+84A/LDT2NYfx7XI0ZUZi36ta7QosRzMeUbsnedsQ+hP24vy0Sfgzm3UlBH/g t/fsEfhRcEsFobS6R9IyZgIQfkXCscV+OZeOR7Bu6D0ECW6Wc1NvH5Ei6MMHYsewlcqR /Dm1eZBTNWbtPNbDHmLXjEQQN5y3vvZQZVRco= 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=xxwmGn5aet+IeQX2uXeayC9kd/Pq+fM/GcsQ8yi8eu4=; b=Bjd++Z8xcD/n9tgHFHCT8fPofM2lH7+3ZkmE+DgwsWUTl1vflBZWKEnxLGlnOjJLge UngQ7RxTfNoMq3HQ4Kf1ygFiM6DCvhgrTVsBaKmy4jk8AkhqMgp7JpqUROlr9oNT1mgi vAB2FYpCG64Xi8Ij89xaQA0FZwdzny4GhNAGtUszP4PHkhez5+ltG4IOma8wocNxrQc/ Y9caHkS79a2+WBFOBuahPE9JuZYoGOABwKnto/ISWKqiJxMW9NXzBWAAhWCZWoS+QLoa RijEeQeNaLD5f4wXlCs9ERwgQ5zBOrwH8hYS8uXPAWfv4x9ewWccsCkAIWuqasmBJV/g bmgA== X-Gm-Message-State: AKS2vOxTUdePlSa0aF21m/LbuGDG0K86VTUrarWKvUGM0X/OCEcaW5N8 v1o8q2MItnVnI6fampjwSA== X-Received: by 10.84.191.165 with SMTP id a34mr1414412pld.136.1498117180374; Thu, 22 Jun 2017 00:39:40 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:39 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:48 +0530 Message-Id: <1498117132-27139-14-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 13/17 v5] xen/arm: vpl011: Modify xenconsole to support multiple consoles 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 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 | 435 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 302 insertions(+), 133 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a2a3496..baf0e2e 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,16 +109,112 @@ 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) { @@ -163,12 +261,22 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } -static void buffer_append(struct console *con) +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, xenevtchn_port_or_error_t port) { struct buffer *buffer = &con->buffer; + struct xencons_interface *intf = con->interface; struct domain *dom = con->d; XENCONS_RING_IDX cons, prod, size; - struct xencons_interface *intf = con->interface; cons = intf->out_cons; prod = intf->out_prod; @@ -321,7 +429,7 @@ static int create_console_log(struct console *con) return -1; } - snprintf(logfile, PATH_MAX-1, "%s/guest-%s.log", log_dir, data); + snprintf(logfile, PATH_MAX-1, "%s/guest-%s%s.log", log_dir, data, con->log_suffix); free(data); logfile[PATH_MAX-1] = '\0'; @@ -473,7 +581,7 @@ static int console_create_tty(struct console *con) } free(path); - success = (asprintf(&path, "%s/tty", con->xspath) != -1); + success = (asprintf(&path, "%s/%s", con->xspath, con->ttyname) != -1); if (!success) goto out; success = xs_write(xs, XBT_NULL, path, slave, strlen(slave)); @@ -594,6 +702,7 @@ static int console_create_ring(struct console *con) con->local_port = -1; con->remote_port = -1; + if (con->xce_handle != NULL) xenevtchn_close(con->xce_handle); @@ -639,13 +748,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 { @@ -655,20 +764,59 @@ 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, void **data) { - struct domain *dom; char *s; + int err = -1; struct timespec ts; - struct console *con; + struct console_data **con_data = (struct console_data **)data; + char *xsname; 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->ttyname = (*con_data)->ttyname; + con->log_suffix = (*con_data)->log_suffix; + xsname = (*con_data)->xsname; + con->xspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->xspath, strlen(con->xspath) + + strlen(xsname) + 1); + if (s) + { + con->xspath = s; + strcat(con->xspath, xsname); + err = 0; } + (*con_data)++; + + 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_data *con_data = &console_data[0]; + dom = calloc(1, sizeof *dom); if (dom == NULL) { dolog(LOG_ERR, "Out of memory %s:%s():L%d", @@ -678,27 +826,8 @@ 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) + if (console_iter_int_arg3(dom, console_init, (void **)&con_data)) 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 (!watch_domain(dom, true)) goto out; @@ -710,7 +839,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->xspath); + console_iter_void_arg1(dom, console_free); free(dom); return NULL; } @@ -740,38 +869,51 @@ static void remove_domain(struct domain *dom) } } -static void cleanup_domain(struct domain *d) +static void console_cleanup(struct console *con) { - struct console *con = &d->console; - - console_close_tty(con); - if (con->log_fd != -1) { close(con->log_fd); con->log_fd = -1; } - free(con->buffer.data); - con->buffer.data = NULL; + if (con->buffer.data) + { + free(con->buffer.data); + con->buffer.data = NULL; + } + + if (con->xspath) + { + free(con->xspath); + con->xspath = NULL; + } +} + +static void cleanup_domain(struct domain *d) +{ + console_iter_void_arg1(d, console_close_tty); - free(con->xspath); - con->xspath = NULL; + console_iter_void_arg1(d, console_cleanup); remove_domain(d); } -static void shutdown_domain(struct domain *d) +static void console_close_evtchn(struct console *con) { - struct console *con = &d->console; - - 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; } +static void shutdown_domain(struct domain *d) +{ + d->is_dead = true; + watch_domain(d, false); + console_iter_void_arg1(d, console_unmap_interface); + console_iter_void_arg1(d, console_close_evtchn); +} + static unsigned enum_pass = 0; static void enum_domains(void) @@ -885,12 +1027,32 @@ static void handle_tty_write(struct console *con) } } -static void handle_ring_read(struct domain *dom) +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 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) @@ -898,10 +1060,23 @@ static void handle_ring_read(struct domain *dom) con->event_count++; - buffer_append(con); + buffer_append(con, port); if (con->event_count < RATE_LIMIT_ALLOWANCE) - (void)xenevtchn_unmask(con->xce_handle, port); + (void)xenevtchn_unmask(con->xce_handle, con->local_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); + } } static void handle_xs(void) @@ -922,7 +1097,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); @@ -963,16 +1138,22 @@ 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) { struct domain *d; 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_iter_void_arg1(d, console_open_log); } } @@ -1024,6 +1205,62 @@ static void reset_fds(void) memset(fds, 0, sizeof(struct pollfd) * current_array_size); } +static void add_console_evtchn_fd(struct console *con, void *data) +{ + long long next_timeout = *((long long *)data); + + if (con->event_count >= RATE_LIMIT_ALLOWANCE) { + /* Determine if we're going to be the next time slice to expire */ + if (!next_timeout || + con->next_period < next_timeout) + next_timeout = con->next_period; + } else if (con->xce_handle != NULL) { + if (buffer_available(con)) + { + int evtchn_fd = xenevtchn_fd(con->xce_handle); + con->xce_pollfd_idx = set_fds(evtchn_fd, + POLLIN|POLLPRI); + } + } + + *((long long *)data) = next_timeout; +} + +static void add_console_tty_fd(struct console *con) +{ + if (con->master_fd != -1) { + short events = 0; + if (!con->d->is_dead && ring_free_bytes(con)) + events |= POLLIN; + + if (!buffer_empty(&con->buffer)) + events |= POLLOUT; + + if (events) + con->master_pollfd_idx = + set_fds(con->master_fd, events|POLLPRI); + } +} + +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; + con->xce_pollfd_idx = -1; +} + void handle_io(void) { int ret; @@ -1081,55 +1318,11 @@ 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) > 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; - - 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 (discard_overflowed_data || - !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 (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); - } - } + console_iter_void_arg2(d, console_evtchn_unmask, (void *)now); + console_iter_void_arg2(d, add_console_evtchn_fd, (void *)&next_timeout); + console_iter_void_arg1(d, add_console_tty_fd); + } /* If any domain has been rate limited, we need to work out what timeout to supply to poll */ @@ -1189,35 +1382,11 @@ void handle_io(void) } for (d = dom_head; d; d = n) { - 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); - } - - 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->xce_pollfd_idx = con->master_pollfd_idx = -1; + console_iter_void_arg1(d, handle_console_ring); + console_iter_void_arg1(d, handle_console_tty); if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Thu Jun 22 07:38:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106173 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327234qgd; Thu, 22 Jun 2017 00:41:41 -0700 (PDT) X-Received: by 10.107.151.140 with SMTP id z134mr1089091iod.83.1498117301147; Thu, 22 Jun 2017 00:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117301; cv=none; d=google.com; s=arc-20160816; b=U7FnuLbmBIT9nkosOya2k3TxTowvvfYaIzC+MbvMOlSgH432iGrMcFqqWkOIMBYc6z EGwpD8xk/9iiq8Hd8JOYI1wmMZvfCghF231dhnEtyfn2zVD3MDozFmag7hSKYw37mmy0 5sZnAQIsV4mbdlM5KCWmcq/qqnnVqvLiSXKWKC3jylO2N88a8Cn4K9EIJ+czrJvdyNu7 W5VGKl5ixack6EqxsmSaieTIi551xsVFMMWIB8wHPBNMQp79wzW1O+R2sNnetHJ4GJDP XjjocogALVQTcXhnPFO7fM4Az//S6BrMJZfE0+kxhWH8m0FOX4+GGppcX7G7rZJATOC3 SWLQ== 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=DVpJwioHMZgAfvQLqR/TgpwCknd+DR4y/dTqDgE6YgM=; b=pDVX+O54xRDKOppCiNr5o8RPZ1yHMqtWPxLg4EkEPqc589Xzz4eMuXVsBD8h08xnxb z3J0WGd9fW5/6OH1m62pjvTgNi9JfijZJmlTPKhvZzNjbCnTdrqf6OabiRzdK6mllB99 SBpQyM2MNtylP2PRipq4m8r+DO7Q+fnRtDDAlkmwPHKou9Mg8HAW2uufll8yaJjE69En S0vh53b3eFpgQF+MM8yw1Ty6RBIyatSNpyS7zquHyJSBH6I0F4q72nQZUf2MGdpmNcCa lztx2tJ2FohbGqg+C4aO7iAkh38kLCU+BKBNWDqQt+hfVP/IEbLMEYtXIncR0RkReoQE /kqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=CtVZDdkW; 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 e9si710899ioe.292.2017.06.22.00.41.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:41 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=CtVZDdkW; 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 1dNwiQ-0005uW-TR; Thu, 22 Jun 2017 07:39:46 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwiQ-0005tQ-CM for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:46 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id AB/E9-03557-1447B495; Thu, 22 Jun 2017 07:39:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsVyMfTAWl3HEu9 IgwkT+S2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozLM0+wFFxQqNiw/xhTA+Nx6S5GLg4hgRmM Ei1rG1hAHBaBecwSl17cY+xi5OSQEOhnlbhzLAnCTpN4d2gGM4RdITFlwypWEFtIQEvi6KnZr BCT9jFJTJ54HqiZg4NNwERiVocESI2IgJLEvVWTmUBqmAXmM0o0TeplA0kIC4RJ3OhbCzaURU BVonPqRTCbV8BH4nVnB9QyOYmb5zrBbE6g+IodC9khFntL7DozmWUCo8ACRoZVjBrFqUVlqUW 6hqZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBocUABDsYvy0LOMQoycGkJMr7 P887UogvKT+lMiOxOCO+qDQntfgQowwHh5IEr3IxUE6wKDU9tSItMwcY5DBpCQ4eJRHeFpBW3 uKCxNzizHSI1ClGS44rV9Z9YeLYsHo9kJxyYPsXJiGWvPy8VClxXlGQeQIgDRmleXDjYJF4iV FWSpiXEehAIZ6C1KLczBJU+VeM4hyMSsK8+kVAU3gy80rgtr4COogJ6KAXRzxADipJREhJNTA a+89tSj90/RvjtmUZWyzTt0YxKm85MZMpbXp6Sqx3/7yLS0oE9yy9odqarvShKGpG/xyXVq+2 4vAEw036dy5oH39+Z/7MP01nfzpeZJO6v1DlhYvPrMaVF9aEzTx0oe7jAneegJ0qejdu5WTtP v1jssUy95o5FqLMvyUUOhSYf5v1hLcUXbJSYinOSDTUYi4qTgQATYdhDL8CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-27.messagelabs.com!1498117184!108618021!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 32168 invoked from network); 22 Jun 2017 07:39:45 -0000 Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:45 -0000 Received: by mail-pf0-f173.google.com with SMTP id s66so5122184pfs.1 for ; Thu, 22 Jun 2017 00:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y5KYWPT+rJa3lMHpqSzqcCfUuw5cKTxzwc4Sp+SyUC8=; b=CtVZDdkWFo33phk0rjZ6ZmJcBr0sKvXPqiOWbzDJECDAV0NTc+ShoyBfFjYA/KiiNP Ndl/7dY/myHFH7crv/bttBioGyxMpR47dL4lsItEUHQteTOiGqUoib4G526aypCvuyOd +RkLdzS68U+qNki7Z95XTuIF09bcESmkmPinI= 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=y5KYWPT+rJa3lMHpqSzqcCfUuw5cKTxzwc4Sp+SyUC8=; b=uUddjEyQ55WSWUbhUOlNoWw+V/CXTvlxsqdQ8ZA9tiuWUVhILhEgbOSEs2qb7uI/Df HXkEdzZ8GexSjITMbpf+h4YVE/a8g0cYl9qz0wgGP0nqE5g1qvdJwnZw2bujl7YnDzbT MWdT8HEy9RU8p8TcMV9Jkb8mBVWiWkebkc9JhvsNyhH0us/rrjqmzX3Rf6z5Zq5Q4+yG LoBS/VDSVm0ZeZZyugbRgePO6WJoH31K9m0nwMXuaH4YG7j9pSoHwWcYp98lLTfJZb1b eq1kMzmbZ63tSFUDowBFCi0pHbvlJ/GT1lXB/rPcpx600AsUXgyIKD/FBiAkfJJBryUw 114Q== X-Gm-Message-State: AKS2vOx3H8vBQd3wcuUc4fdbQ0yHmCDle1c/TMw6R95FnF5Z0Y0e6hqL ep01NnCVhMxLGOeSgfTjzw== X-Received: by 10.99.146.13 with SMTP id o13mr1288290pgd.54.1498117183516; Thu, 22 Jun 2017 00:39:43 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:43 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:49 +0530 Message-Id: <1498117132-27139-15-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 14/17 v5] 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. Signed-off-by: Bhupinder Thakur --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Renamed VUART_CFLAGS- to CFLAGS_vuart- in the Makefile as per the convention. config/arm32.mk | 1 + config/arm64.mk | 1 + tools/console/Makefile | 3 ++- tools/console/daemon/io.c | 31 ++++++++++++++++++++++++++++++- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/config/arm32.mk b/config/arm32.mk index f95228e..b9f23fe 100644 --- a/config/arm32.mk +++ b/config/arm32.mk @@ -1,5 +1,6 @@ CONFIG_ARM := y CONFIG_ARM_32 := y +CONFIG_VUART_CONSOLE := y CONFIG_ARM_$(XEN_OS) := y CONFIG_XEN_INSTALL_SUFFIX := diff --git a/config/arm64.mk b/config/arm64.mk index aa45772..861d0a4 100644 --- a/config/arm64.mk +++ b/config/arm64.mk @@ -1,5 +1,6 @@ CONFIG_ARM := y CONFIG_ARM_64 := y +CONFIG_VUART_CONSOLE := y CONFIG_ARM_$(XEN_OS) := y CONFIG_XEN_INSTALL_SUFFIX := diff --git a/tools/console/Makefile b/tools/console/Makefile index c8b0300..1cddb6e 100644 --- a/tools/console/Makefile +++ b/tools/console/Makefile @@ -11,6 +11,7 @@ LDLIBS += $(SOCKET_LIBS) LDLIBS_xenconsoled += $(UTIL_LIBS) LDLIBS_xenconsoled += -lrt +CFLAGS_vuart-$(CONFIG_VUART_CONSOLE) = -DCONFIG_VUART_CONSOLE BIN = xenconsoled xenconsole @@ -28,7 +29,7 @@ clean: distclean: clean daemon/main.o: daemon/_paths.h -daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) +daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) $(CFLAGS_vuart-y) xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c)) $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_xenconsoled) $(APPEND_LDFLAGS) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index baf0e2e..6b0114e 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -107,12 +107,16 @@ struct console { xenevtchn_port_or_error_t remote_port; struct xencons_interface *interface; struct domain *d; + bool optional; + bool prefer_gnttab; }; struct console_data { char *xsname; char *ttyname; char *log_suffix; + bool optional; + bool prefer_gnttab; }; static struct console_data console_data[] = { @@ -121,7 +125,18 @@ static struct console_data console_data[] = { .xsname = "/console", .ttyname = "tty", .log_suffix = "", + .optional = false, + .prefer_gnttab = true, }, +#if defined(CONFIG_VUART_CONSOLE) + { + .xsname = "/vuart/0", + .ttyname = "tty", + .log_suffix = "-vuart0", + .optional = true, + .prefer_gnttab = false, + }, +#endif }; #define MAX_CONSOLE (sizeof(console_data)/sizeof(struct console_data)) @@ -655,8 +670,18 @@ static int console_create_ring(struct console *con) "ring-ref", "%u", &ring_ref, "port", "%i", &remote_port, NULL); + if (err) + { + /* + * This is a normal condition for optional consoles: they might not be + * present on xenstore at all. In that case, just return without error. + */ + if (con->optional) + err = 0; + goto out; + } snprintf(path, sizeof(path), "%s/type", con->xspath); type = xs_read(xs, XBT_NULL, path, NULL); @@ -670,7 +695,9 @@ static int console_create_ring(struct console *con) if (ring_ref != con->ring_ref && con->ring_ref != -1) console_unmap_interface(con); - if (!con->interface && xgt_handle) { + if (!con->interface && + xgt_handle && + con->prefer_gnttab) { /* Prefer using grant table */ con->interface = xengnttab_map_grant_ref(xgt_handle, dom->domid, GNTTAB_RESERVED_CONSOLE, @@ -790,6 +817,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->prefer_gnttab = (*con_data)->prefer_gnttab; xsname = (*con_data)->xsname; con->xspath = xs_get_domain_path(xs, dom->domid); s = realloc(con->xspath, strlen(con->xspath) + From patchwork Thu Jun 22 07:38:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106158 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327057qgd; Thu, 22 Jun 2017 00:41:05 -0700 (PDT) X-Received: by 10.36.8.195 with SMTP id 186mr685668itc.76.1498117265480; Thu, 22 Jun 2017 00:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117265; cv=none; d=google.com; s=arc-20160816; b=VqNmygTGMVlZzEWM0ifZ9+Zngr51RrTEqlqfEKAxPz9TcEfCRM5EJDGRxKxljYt3wP Edkd9M3BqjqiZu0x4JHzjeS2oCR56iFkNSQeTSchcYswjA4j5fxalzDrPrUwUf4qPive UvNDgr/wuQdw29BJZRCc/zevI41TMrnVRhOZNYTOBBYO+i1B2Gf+bwwdTSQzooeHhG/A oEJHVQSQGmfbqsqJeUWJAT3q4i2zKY+asxEXUDUJgIdVIzjNxoDeNWyYl+lJZvz3ASgP g8odidlrsRq4/wYdY0DIZx4l7hCYOiiRGsuf+EeoTC7jhCQAVzxqehs0O24Is37pktIM EE+Q== 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=SXz199bqt3Za+NbIMM8ebZm8llkqGOhM78VglRWxa1k=; b=LVJvIKFPFatznRcs7sjgvnG9fL0jqTjI6nkl+2X+ALJX+nE5hAvzpmrvETUl+aHMAT EklMMU4fVtbKdPVDVZ8YhEFL7AS/VXyxEcEVyeROY2Ij9dd38tG0PzGJLBA6DTqdWEge TeYt7zagoPzT0fuiNgClgxkZiHw79m37qJbkY/inCYGBaVXRDK2lMyHQG64m4ZIGrsyG azLLmq6NtGyMnPkoVQUbYshnIOcTGsx8BPsQL9a72qmiv7f9gYyRnTRy+mmfMtsXWc1n DSi6OJ6GnMQqF/0xwl5V5R2ZPqBjZpHMZLrq7rkDDvaNSZCGtDqKMxsH5TeLs0vw8aus ehkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=O5ZOlkMt; 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 s103si708822ioi.238.2017.06.22.00.41.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41: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.b=O5ZOlkMt; 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 1dNwiU-0005yh-4x; Thu, 22 Jun 2017 07:39:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwiS-0005wd-QB for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:48 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 3E/FA-03696-4447B495; Thu, 22 Jun 2017 07:39:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsVyMfTABl3nEu9 Ig6XNuhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b5rb8YC56LVGz7t5u5gXGXQBcjF4eQwAxG ievPO1m7GDk5WATmMUs8nVINkpAQ6GeVaHxykA0kISGQJvG9cy4ThF0hcbl1MzOILSSgJXH01 GxWiEn7mCTa170Hcjg42ARMJGZ1SIDUiAgoSdxbNZkJpIZZYD6jRNOkXrChwgIxEnc+f2SD2K wqsfN5PyNIL6+Aj8SBW3EQu+Qkbp7rBNvFCRResWMhO8Reb4ldZyazTGAUWMDIsIpRvTi1qCy 1SNdUL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMKwYgGAH4/TL/ocYJTmYlER5 Nxd7RwrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4J1XBJQTLEpNT61Iy8wBBjhMWoKDR0mEtyUPK M1bXJCYW5yZDpE6xWjMceXKui9MHFMObP/CJMSSl5+XKiXOOxtkkgBIaUZpHtwgWORdYpSVEu ZlBDpNiKcgtSg3swRV/hWjOAejkjCvPsgUnsy8Erh9r4BOYQI65cURD5BTShIRUlINjPs+64V GTjLkCnJ5dk/mXQPfYS/dNSUv4kS9Vqy4cqLXbUMPp/CF7a6NThIShS9VjtRMm3qt9+f950/s YhviA0Tvz1XZ+4zpTzCT7PqZB4x+GGjY+1wwf21akRR8999qzqtCn0U31+kqZpl8s72gt4ZTS kaoo3+zd8aT2s3rbrBv+PTH0/3ILCWW4oxEQy3mouJEAL2qIK+3AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-27.messagelabs.com!1498117186!108618030!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 32599 invoked from network); 22 Jun 2017 07:39:47 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:47 -0000 Received: by mail-pf0-f176.google.com with SMTP id s66so5122518pfs.1 for ; Thu, 22 Jun 2017 00:39:47 -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=d1KBn+iFCfLFvWRPZsedtUmjRYNyzhLYEpMJ1vpscqw=; b=O5ZOlkMtafBo7Y3hqjdCYmTl4DqPB8K7mBtv0DFEucZYJRwaPl2eRRXJMYz3hsSMd0 PYa/sajU5v3pVqA5itmMAMmpywQc8xDBQVggxn2Ysw2Zj/vHxg+exTvJ9Q8VyADF9ayv ro1/M9INLtvryoOIlDQhwnNo/jMRz+DOo+VpI= 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=d1KBn+iFCfLFvWRPZsedtUmjRYNyzhLYEpMJ1vpscqw=; b=Y1IVapv+SmFhJjyi8xCCzHloXfU7PWXWD+ad0IEoXxJyRmIg0AwH7i7GJKkfLGStp6 Adjo43USPGJ2ilJ26qCt0Q0sEMRcwdcRxER8jB8w9vgE8K84HMbMqfFmNK1MuiXviGiW 1+A4dcN1JpJMcF5GB3EPTvc+lFbiI//TiabrMbwKnQdNkJ8Ihy3Fg7MQrf0x45dqPN6Z iT+lKTHZjLiHbBs0I65nSrEbvXVlDFulIrsy56V0SVGNCPsfeYG3rPIKTIxuYDFB3yhF CZB7XbWfANs8uUz4Xe8cL5d47V/M3BA5luMgn87M/4cBffOxm6qAzWp0TNgP4dWDl5IN ScJg== X-Gm-Message-State: AKS2vOzTwP5ZniMsfAo95WrEeGRF8r4rmAQHQo7UDXb3vn3oB+6txsgc +c3QnoNA5NujAV6VC+qGQw== X-Received: by 10.99.123.81 with SMTP id k17mr1267735pgn.71.1498117186016; Thu, 22 Jun 2017 00:39:46 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:45 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:50 +0530 Message-Id: <1498117132-27139-16-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 15/17 v5] xen/arm: vpl011: Add a new vuart console type to xenconsole client X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add a new console type VUART to connect to guest's emualated vuart console. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Removed the vuart compile time flag so that vuart code is compiled always. Changes since v3: - The vuart console support is under CONFIG_VUART_CONSOLE option. - Since there is a change from last review, I have not included reviewed-by tag from Stefano and acked-by tag from Wei. tools/console/client/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index 977779f..3dbb06f 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -76,7 +76,7 @@ static void usage(const char *program) { "\n" " -h, --help display this help and exit\n" " -n, --num N use console number N\n" - " --type TYPE console type. must be 'pv' or 'serial'\n" + " --type TYPE console type. must be 'pv', 'serial' or 'vuart'\n" " --start-notify-fd N file descriptor used to notify parent\n" , program); } @@ -264,6 +264,7 @@ typedef enum { CONSOLE_INVAL, CONSOLE_PV, CONSOLE_SERIAL, + CONSOLE_VUART, } console_type; static struct termios stdin_old_attr; @@ -343,6 +344,7 @@ int main(int argc, char **argv) char *end; console_type type = CONSOLE_INVAL; bool interactive = 0; + char *console_names = "serial, pv, vuart"; if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) interactive = 1; @@ -361,9 +363,12 @@ int main(int argc, char **argv) type = CONSOLE_SERIAL; else if (!strcmp(optarg, "pv")) type = CONSOLE_PV; + else if (!strcmp(optarg, "vuart")) + type = CONSOLE_VUART; else { fprintf(stderr, "Invalid type argument\n"); - fprintf(stderr, "Console types supported are: serial, pv\n"); + fprintf(stderr, "Console types supported are: %s\n", + console_names); exit(EINVAL); } break; @@ -436,6 +441,10 @@ int main(int argc, char **argv) else snprintf(path, strlen(dom_path) + strlen("/device/console/%d/tty") + 5, "%s/device/console/%d/tty", dom_path, num); } + if (type == CONSOLE_VUART) { + snprintf(path, strlen(dom_path) + strlen("/vuart/0/tty") + 1, + "%s/vuart/0/tty", dom_path); + } /* FIXME consoled currently does not assume domain-0 doesn't have a console which is good when we break domain-0 up. To keep us From patchwork Thu Jun 22 07:38:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106161 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327095qgd; Thu, 22 Jun 2017 00:41:12 -0700 (PDT) X-Received: by 10.36.194.71 with SMTP id i68mr728458itg.106.1498117272241; Thu, 22 Jun 2017 00:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117272; cv=none; d=google.com; s=arc-20160816; b=CUQNDcPXLgPC3Xl8j7BBkp6lD0D2n2Hp5a/aG7J0hrVwPt2b782rSqkdEdBeWLg6VT dvrr2+QlYP6Gb3sajmrRYNsCvf7uUae737c+Twt4uMEd0dXdSKovzuxH6pxvFVmk0620 aExLY16sk44Rb8s23KjApInfTbg2y6Ncu8/O6npwzmtJkB5jsBVixA9wshJuRq8m5JJq nRm4vkJxsUQNiu5Z2quABlEuKua9EX4iokvlsX7+/XI68al1YLorkYwGypkGcFzQBwix r4Otlb9bHUtmyWx6OlELjdw46gYj6RJLX1IBvOGlkqhzv80JZCn4xWNpD8dTsvLXjvUX ingg== 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=8xJVRoF3xNhgxAJVnLtI3xS6RpEjIuvw2QK3FQvK/qo=; b=VyadDEsos3LrKKnQIGcI1vTDlHz9KHzn2vqBzCaqUX6H264g4vnNPrDd1eZVpOyOwG e8bPEk0n3vkWSc2pfqdFdiKdny3S4HZywPwCOgWTEu9FeOYT3HAb5KxbsPSso2QBPDtx GzZ6lfWVR/ulkSjb0Wgv51ngTwZmLb1v8TLKSFwlFf74ZfR1qGAgZJpT5Yqr4ipJ2EP0 12n9pFhkNl+cQXcg71Ji3vsTARNH/KTN7bkqeYsCajMhQIo32MGx+Zow2oTMeHFKCeWK E0qAUq4C7OHqOaiVUXorV1hUjWyc+7fdPu61FAd3zoZw4OJ1qQ/T5jDTQCClaPUecDpk Ua9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=W+yPbE/H; 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 2si706629iob.205.2017.06.22.00.41.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41:12 -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=W+yPbE/H; 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 1dNwiX-00063S-DD; Thu, 22 Jun 2017 07:39:53 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNwiW-00061O-F1 for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:52 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id BD/A2-02183-7447B495; Thu, 22 Jun 2017 07:39:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsXiVRtspute4h1 p8CfH4vuWyUwOjB6HP1xhCWCMYs3MS8qvSGDNuH/wBHvBUoWKKfv72BsYv0l0MXJxCAnMYJR4 09XJCOKwCMxjlji1cBY7iCMh0M8q8bV/G1MXIyeQkybx+epEdgi7QmLTy06wuJCAlsTRU7NZI UbtY5JYfuEVUIKDg03ARGJWhwRIjYiAksS9VZOZQGqYBeYzSjRN6mUDSQgLxEhsm9rHCmKzCK hKPJj7lxnE5hXwkdgx7x8jxDI5iZvnOsHinEDxFTsWskMs9pbYdWYyywRGgQWMDKsYNYpTi8p Si3SNTPWSijLTM0pyEzNzdA0NTPVyU4uLE9NTcxKTivWS83M3MQJDq56BgXEH4652v0OMkhxM SqK8//O8I4X4kvJTKjMSizPii0pzUosPMcpwcChJ8CoXA+UEi1LTUyvSMnOAQQ6TluDgURLhb QFp5S0uSMwtzkyHSJ1i1OWYdGD7FyYhlrz8vFQpcV5RkBkCIEUZpXlwI2ARd4lRVkqYl5GBgU GIpyC1KDezBFX+FaM4B6OSMK9+EdAUnsy8ErhNr4COYAI64sURD5AjShIRUlINjBVyZQXnrn5 1brq0JGOrQPCyeneDR6VlDEcnxBzvUP5QK+eVPLFKovq3+t3JCRFvU/Yn3DfO7pBN5wjfu/rU 285Z/qEvc34fn9vHt9+B+9EfOdWp6d157EKbUs8FTb682FdNYHrTs1dKNoLOzEeOSsp8Kk7cV nue3WDSpPTHF8TPzBAqvde5XImlOCPRUIu5qDgRAABkYoazAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-206.messagelabs.com!1498117189!100099331!1 X-Originating-IP: [74.125.83.54] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55210 invoked from network); 22 Jun 2017 07:39:50 -0000 Received: from mail-pg0-f54.google.com (HELO mail-pg0-f54.google.com) (74.125.83.54) by server-5.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:50 -0000 Received: by mail-pg0-f54.google.com with SMTP id f127so4629460pgc.0 for ; Thu, 22 Jun 2017 00:39: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=DpDkfnSmAOPxKcNgj9ayeEYhq5xmRGTaV9bCbfvFz5o=; b=W+yPbE/HSl/NVP5x8HWWHMqwdAts2jimSfsMCsjMrQfVzdvWCOQ6FymlbG0Zf6L7mz 3UT0kV9N434su2uBKaCijVY2dqI4TYTlPDbOllnlnpNM3jSebKQ6z6KuiYD2UDPeefJe cMSpZjpK3boucyKPFwbyDX7xGIBkBBryJOzF4= 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=DpDkfnSmAOPxKcNgj9ayeEYhq5xmRGTaV9bCbfvFz5o=; b=mXOU4kTedWdkQRqqf3z6Jxd8JH4pJRLcSb3qaB9i0xRu5YXoo2IYbnzbJj/l/qtPt7 +LRNTKYkd19TPB2gzMQnhB9A574U15/BwJRUx1JXqQyTykGCOuvBj8TjvWQEsWwgtC6c AIJte9AApzX+UJ0KFpWYgxGMA4mGtjykBT6Wcm4jGOIrLe5+KTQTzf9mc23DtBOltvOf M5pctaEJYB/dI+TB6UbmB23o+tAJ2kRVMTRocrrfBTjkaX0WwYzwX1VrkD85tJwIXUIV 8IaKKDyC5SMuXjd5iR8LeI8/gfGToE2cu+xiwxb19CeL63prsyLahOCZ4802RtFqpj46 /3cA== X-Gm-Message-State: AKS2vOxrZiaO8Toxz/GpvmBwZ4LVqyKoI2Ri5aqJHVyk3OGWgi57xD2T DRb54qLpwvGdfe66qAJ3Og== X-Received: by 10.101.88.130 with SMTP id d2mr1293888pgu.58.1498117189026; Thu, 22 Jun 2017 00:39:49 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:48 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:51 +0530 Message-Id: <1498117132-27139-17-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 16/17 v5] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The SBSA UART node format is as specified in Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt and given below: ARM SBSA defined generic UART ------------------------------ This UART uses a subset of the PL011 registers and consequently lives in the PL011 driver. It's baudrate and other communication parameters cannot be adjusted at runtime, so it lacks a clock specifier here. Required properties: - compatible: must be "arm,sbsa-uart" - reg: exactly one register range - interrupts: exactly one interrupt specifier - current-speed: the (fixed) baud rate set by the firmware Currently the baud rate of 115200 has been selected as a default value, which is one of the valid baud rate setttings. Higher baud rate was selected since an emulated pl011 can support any valid baud rate without any limitation of the hardware. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall tools/libxl/libxl_arm.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 9d6448e..cf3de01 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -44,10 +44,22 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, uint32_t nr_spis = 0; unsigned int i; + /* + * If pl011 vuart is enabled then increment the nr_spis to allow allocation + * of SPI VIRQ for pl011. + */ + if (d_config->b_info.arch_arm.vuart) + nr_spis += (GUEST_VPL011_SPI - 32) + 1; + for (i = 0; i < d_config->b_info.num_irqs; i++) { uint32_t irq = d_config->b_info.irqs[i]; uint32_t spi; + if (d_config->b_info.arch_arm.vuart && (irq == GUEST_VPL011_SPI)) { + LOG(ERROR, "Physical IRQ %u conflicting with pl011 SPI\n", irq); + return ERROR_FAIL; + } + if (irq < 32) continue; @@ -130,9 +142,10 @@ static struct arch_info { const char *guest_type; const char *timer_compat; const char *cpu_compat; + const char *uart_compat; } arch_info[] = { - {"xen-3.0-armv7l", "arm,armv7-timer", "arm,cortex-a15" }, - {"xen-3.0-aarch64", "arm,armv8-timer", "arm,armv8" }, + {"xen-3.0-armv7l", "arm,armv7-timer", "arm,cortex-a15", "arm,sbsa-uart" }, + {"xen-3.0-aarch64", "arm,armv8-timer", "arm,armv8", "arm,sbsa-uart" }, }; /* @@ -590,6 +603,38 @@ static int make_hypervisor_node(libxl__gc *gc, void *fdt, return 0; } +static int make_vpl011_uart_node(libxl__gc *gc, void *fdt, + const struct arch_info *ainfo, + struct xc_dom_image *dom) +{ + int res; + gic_interrupt intr; + + res = fdt_begin_node(fdt, "sbsa-pl011"); + if (res) return res; + + res = fdt_property_compat(gc, fdt, 1, ainfo->uart_compat); + if (res) return res; + + res = fdt_property_regs(gc, fdt, ROOT_ADDRESS_CELLS, ROOT_SIZE_CELLS, + 1, + GUEST_PL011_BASE, GUEST_PL011_SIZE); + if (res) return res; + + set_interrupt(intr, GUEST_VPL011_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); + + res = fdt_property_interrupts(gc, fdt, &intr, 1); + if (res) return res; + + /* Use a default baud rate of 115200. */ + fdt_property_u32(fdt, "current-speed", 115200); + + res = fdt_end_node(fdt); + if (res) return res; + + return 0; +} + static const struct arch_info *get_arch_info(libxl__gc *gc, const struct xc_dom_image *dom) { @@ -889,6 +934,9 @@ next_resize: FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) ); FDT( make_hypervisor_node(gc, fdt, vers) ); + if (info->arch_arm.vuart) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) ); From patchwork Thu Jun 22 07:38:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 106160 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2327088qgd; Thu, 22 Jun 2017 00:41:11 -0700 (PDT) X-Received: by 10.36.91.129 with SMTP id g123mr723095itb.0.1498117270980; Thu, 22 Jun 2017 00:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498117270; cv=none; d=google.com; s=arc-20160816; b=Yv1URcPdw9jun7qNQAO1RlHxU9gEYWzVu0mulWBsEv08Pw5lMCnnu0hpTnVDl0nl3i fVguYhWCD3639bh96cze/Ja3yGYngIjNQRLIovmFsQvxK2rdxhqBzB0XNaasCosy51A5 V13WPJZ2j/Qo9TUDpG0xd4ZfVQwHcIvmFIn6xl+GdY28HkW1sB1don0YgEOUoRIjnUH0 DYlQ9WTJIe1Jf+IIPd1Zojmow8xxLHzqcyQ/+dnLFMu/DKu7qPr3REV1DumFlDhEhAi1 BF1BwG482TJhxz38A3/96c9tOTCDDVIZF6FKFZ6FiYJP6+vkL0+QLTKHGavxx3gYn5Lk Mz5Q== 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=tXrCe1Vtlrj79YcdlnPNq9cTsmIGCoXVeFsJz3DUNCg=; b=RxBpzXShwmrYZSThwDymLoF21yxZ4gueHjSI47DWIFS7lvsNy8PdXLUe5Nr+Je2f35 MhfSYIMGsBIwAd7dbDVjFdlqfIMGStGNvLM/caWVfcnO1Kp74mx4MBsZhjfl1C/jeFTn +cZz7Dbm8Cbud5s2qTuB6uh4QLD13OGulDzAZVwuBQQa7Mf1OVRTUqvMCIuuP0EeQ4BF oyh9y9cDc7IP/jzrGxMiIL3tgI1BNf9COeMtBRmHmXSvmfhN7WMdFt5rGV8tnPtHahXP Kp2UwAXW1+b0vV1u/kIiktdNZULhx3e8b7PzLG+lrpXofjFwMsORagZuWdRcm5PzMeQ1 QRUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=NCRGMVxD; 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 q66si343686itq.126.2017.06.22.00.41.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 00:41: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=NCRGMVxD; 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 1dNwia-0006Ag-Kz; Thu, 22 Jun 2017 07:39: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 1dNwiZ-00067S-3w for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 07:39:55 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 28/AE-01992-A447B495; Thu, 22 Jun 2017 07:39:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsVyMfTABl3PEu9 Ig1nHDSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxtr48zFZxTqTh3tZutgfGkXBcjF4eQwAxG ia3bv7B1MXJysAjMY5Y4/VcAxJYQ6GeVmP/eH8JOkzh2bT0bhF0lcfjwaWYQW0hAS+LoqdmsE IP2MUl8udUAlODgYBMwkZjVIQFSIyKgJHFv1WQmkBpmgfmMEk2TesEGCQtESsy6eIANpJ5FQF VizaUikDCvgI9E77TTjBC75CRunusE28UJFF+xYyE7xF5viV1nJrNMYBRYwMiwilGjOLWoLLV I18hYL6koMz2jJDcxM0fX0MBULze1uDgxPTUnMalYLzk/dxMjMKzqGRgYdzDuaPc7xCjJwaQk yvs/zztSiC8pP6UyI7E4I76oNCe1+BCjDAeHkgSvcjFQTrAoNT21Ii0zBxjgMGkJDh4lEd4Wk Fbe4oLE3OLMdIjUKUZjjitX1n1h4phyYPsXJiGWvPy8VClx3tlFQKUCIKUZpXlwg2CRd4lRVk qYl5GBgUGIpyC1KDezBFX+FaM4B6OSMK8+yBSezLwSuH2vgE5hAjrlxREPkFNKEhFSUg2MNY4 P28Of1C6Rl9lU0MR+TffPgdi+O82yO9S3uwSkM/tc9VavSRcrFA81TlCTOXBz8ccT33v1dbiN Mk3ya98k3V8XL7ysavat+9USP4JYFzF56V6I3si7Wub0mpQtVaGnZrXJzPlWY/e+bvcioeAvL VMd7Kc+0dxrvej4O5sUn4o/EjKrTPKUWIozEg21mIuKEwH2/fcTtwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-7.tower-206.messagelabs.com!1498117192!101651560!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30299 invoked from network); 22 Jun 2017 07:39:53 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-7.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jun 2017 07:39:53 -0000 Received: by mail-pf0-f176.google.com with SMTP id s66so5123390pfs.1 for ; Thu, 22 Jun 2017 00:39: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=g95H2qSI90FCwKNLDsVhfUA6l2A2qmzSq7WPYBbVr9g=; b=NCRGMVxDyPrNe8c4DUDY6wIbkmT7fNXlcNLueo23LZ0kqiQXew6/RM0GztItaq/vQY TCFLymbbk3LkWrbSfCpdCKGSMjlX8HTjCf2wtzKxHi+PJG3eRHjZUn0Ew7oupPETtHnx Smj3SHhROolAnMfu+2z8WvUJj8jePHHw/4I4s= 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=g95H2qSI90FCwKNLDsVhfUA6l2A2qmzSq7WPYBbVr9g=; b=qRbB2cb8vEJERoybojcJJf+2Vi0dm8pZ/4TmJAlBBkVF2DX9uMzrb+rzZ7cn8dzWrZ JobxKj0ORcwQ4IMy9S+ZVysSv2VqgrS0QWwkzx6h3RUBH7orgOMU0nne1ZkKFPL87gzQ unfUw4aNqjLIC9f61DlxVJeocsa6wwAfaT0ye2Jk3mo3A6pJ4eTtSjZ4f9LnLCOxAyG3 LdO0rjL48wATBwu+KAimVLw2CX9ApiyRb4twJNnko5PQiFt8Jbr6UTife3y+o+TdnplT QwQvM7LiOVStkwP6z3gjJ1y+ySPPMM0zAKOzz16XehQtL+fFLODN7ZMGnCKUe1a3xl4p OfRQ== X-Gm-Message-State: AKS2vOwTFUBdWqCRD8mFg+6JzK9O9vUzvB/vCHWjzJnynXAjIGUyyiff Nwt/26AXn1TStrvnsMlTDw== X-Received: by 10.101.83.138 with SMTP id x10mr1231122pgq.205.1498117191715; Thu, 22 Jun 2017 00:39:51 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id w69sm1883591pfk.107.2017.06.22.00.39.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jun 2017 00:39:51 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 13:08:52 +0530 Message-Id: <1498117132-27139-18-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> References: <1498117132-27139-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 17/17 v5] xen/arm: vpl011: Update documentation for vuart console support X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 1. Update documentation for a new vuart option added. 2. Update documentation about SPI irq reserved for vuart. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v4: - Minor change to rename "pl011" to "sbsa_uart". Since it is a minor change I have retained the reviewed-by and acked-by tags. docs/man/xl.cfg.pod.5.in | 9 +++++++++ docs/misc/console.txt | 44 +++++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in index 38084c7..0737ed1 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -1105,6 +1105,15 @@ Allow a guest to access specific physical IRQs. It is recommended to only use this option for trusted VMs under administrator's control. +If the virtual uart is enabled then irq 32 is reserved for it. By +default, it is disabled. If the user specifies the following option in +the VM config file then the vuart gets enabled. Today, only the +"sbsa_uart" model is supported. + +vuart = "sbsa_uart" + +Currently vuart console is available only for ARM64. + =item B Limit the guest to using at most N event channels (PV interrupts). diff --git a/docs/misc/console.txt b/docs/misc/console.txt index 16da805..d081acc 100644 --- a/docs/misc/console.txt +++ b/docs/misc/console.txt @@ -19,7 +19,20 @@ The first PV console path in xenstore remains: /local/domain/$DOMID/console -the other PV consoles follow the conventional xenstore device path and +The virtual UART console path in xenstore is defined as: + +/local/domain/$DOMID/vuart/0 + +The vuart console provides access to a virtual SBSA UART on ARM64 systems. +To enable vuart the following line has to be added to the guest configuration +file: + +vuart = "sbsa_uart" + +In Linux you can select the virtual SBSA UART by using the "ttyAMA0" +console instead of "hvc0". + +The other PV consoles follow the conventional xenstore device path and live in: /local/domain/$DOMID/device/console/$DEVID. @@ -61,6 +74,14 @@ output = pty The backend will write the pty device name to the "tty" node in the console frontend. +For the PV console the tty node is added at + +/local/domain/$DOMID/console/tty + +For the virtual UART console the tty node is added at + +/local/domain/$DOMID/vuart/0/tty + If the toolstack wants a listening Unix domain socket to be created at path , a connection accepted and data proxied to the console, it will write: @@ -79,8 +100,8 @@ For example: ioemu The supported values are only xenconsoled or ioemu; xenconsoled has -several limitations: it can only be used for the first PV console and it -can only connect to a pty. +several limitations: it can only be used for the first PV or virtual UART +console and it can only connect to a pty. Emulated serials are provided by qemu-dm only to hvm guests; the number of emulated serials depends on how many "-serial" command line options @@ -90,14 +111,15 @@ xenstore in the following path: /local/domain/$DOMID/serial/$SERIAL_NUM/tty -xenconsole is the tool to connect to a PV console or an emulated serial -that has a pty as output. Xenconsole takes a domid as parameter plus an -optional console type (pv for PV consoles or serial for emulated -serials) and console number. Depending on the type and console -number, xenconsole will look for the tty node in different xenstore -paths, as described above. If the user doesn't specify the console type -xenconsole will try to guess: if the guest is a pv guest it defaults to -PV console, if the guest is an hvm guest it defaults to emulated serial. +xenconsole is the tool to connect to a PV or virtual UART console or an +emulated serial that has a pty as output. Xenconsole takes a domid as +parameter plus an optional console type (pv for PV consoles, vuart for +virtual UART or serial for emulated serials) and console number. +Depending on the type and console number, xenconsole will look for the tty +node in different xenstore paths, as described above. If the user doesn't +specify the console type xenconsole will try to guess: if the guest is a pv +guest it defaults to PV console, if the guest is an hvm guest it defaults to +emulated serial. By default xl creates a pv console for hvm guests, plus an emulated serial if the user specified 'serial = "pty"' in the VM config file.