From patchwork Tue Jun 6 17:25:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103171 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536646qgd; Tue, 6 Jun 2017 10:27:45 -0700 (PDT) X-Received: by 10.107.139.214 with SMTP id n205mr16656622iod.178.1496770065621; Tue, 06 Jun 2017 10:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770065; cv=none; d=google.com; s=arc-20160816; b=yiBn/L27jQIgNrkRK4ccICLRbgs8aurig30OonoY92jn6f48IhTAFULcu9utNzuq3x pBjcOCGhKhOhehPn7/3pNB1s/Trw6k4OXNfqe8yNPJfQXu0qWgSf+spWplfmez3Bwqcj E8Q/LG5ePUU3QTL8H8yt1t10/tASISIe8wRlZIOVzp8VEhhX9e4UQHlbzsrxO8z6JzcQ TmQnKDcdBlOrCn9mrqo+MYtJf000QistkKhATX3SPv7dDD08v6qTFgJt5PbLKaMZG4aP o6WoLqqsDy84XiX8ODXJ+hDKI3jBWVapnWDRfgdDq6Eopu6mZN+IjBSm5yBYKmuQl8Jd 3pig== 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=yU61mAy/rfPJFSv77P2QI8AOgL1JuT62MC2c+q0J2sc=; b=q45+datdq0pEgXPnIzUJ30JK2zuKZRJod/MqJ6qMOK8RSuiTq3njh7EpLXMERFxdab TRRZYNKPtFetc61koLLDoKpCuuR5aRuQ96j7fW19WmBv/bBsS0ZJ+oaj4UPwdffGxn1V ZTv3nkh+nA3IqhZCCi6Fd+qqLVbLeKPKlc/QOBOiBlqLKvnZKmaVJH7nRxIOtnjd3Lax naGdnVzpGN/uTEWzf58whoDGw2G203K+LievtRPBAEraHrHS7a0bq+89dUAIql4wfG/3 rmhJUpX73I3LAStPB6R67SLss0UZb/J0EpFBZSvN6te+16TURKK3IveOfZ928OJLoQ7G lkPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 m36si15053380iti.31.2017.06.06.10.27.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:27: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; spf=neutral (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 1dIIEh-0001UA-92; Tue, 06 Jun 2017 17:25:43 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIEf-0001Tf-PD for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:25:41 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id BE/A6-02199-495E6395; Tue, 06 Jun 2017 17:25:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfTASt0pT80 iDQ7sYLP4vmUykwOjx+EPV1gCGKNYM/OS8isSWDOu3XjCVPAuumL+tZlsDYzTdLoYuTiEBGYw SixYsIwJxGERmMcssebjETBHQqCfVeLG1IksXYycQE6axPl7+9kg7CqJRd8b2UFsIQEtiaOnZ rNCjGpmkjh6/TZQAwcHm4CJxKwOCZAaEQEliXurJjOB2MwCoRJT/z4AmyksECHx/9hssJksAq oSr37uYQWxeQW8Jd5vfMcIsUtO4ua5TmYQm1PAR2Lm+SWMEHu9JfY0tDFOYBRYwMiwilG9OLW oLLVI11gvqSgzPaMkNzEzR9fQwFgvN7W4ODE9NScxqVgvOT93EyMwsBiAYAdj8xenQ4ySHExK oryRl8wihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwfnkMlBMsSk1PrUjLzAGGOExagoNHSYR38 gOgNG9xQWJucWY6ROoUozHHlSvrvjBxTDmw/QuTEEtefl6qlDivwhOgUgGQ0ozSPLhBsNi7xC grJczLCHSaEE9BalFuZgmq/CtGcQ5GJWHeFJApPJl5JXD7XgGdwgR0Ct8lE5BTShIRUlINjFW Lb+1k39N3yGWTVXRZVrC9f5Bhl9SaUpO8oGKlTyfVd/i3t0ayqyV5X9v9hWtTdfIsO+5pTUJ+ 5tetn6fNcXqwbfamiz8P/Ik65Lkpwr36p/ueo3L154MuJh3QUF0dsN1g/rZDrJ5L1aYlav3cl y1bXLI5ue1b7DOzLLac5iaxpqL1q+0TlFiKMxINtZiLihMBNksuvbgCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-31.messagelabs.com!1496769938!48878377!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 56909 invoked from network); 6 Jun 2017 17:25:39 -0000 Received: from mail-pf0-f169.google.com (HELO mail-pf0-f169.google.com) (209.85.192.169) by server-9.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:25:39 -0000 Received: by mail-pf0-f169.google.com with SMTP id 83so42505002pfr.0 for ; Tue, 06 Jun 2017 10:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mKQyHCr4fhk7FRvcwewPz3anN3P4JyxOPFBfdU5g9mw=; b=eLbgtt0Uj6fqjEQa+vU2g1DmcehjqeqWsr+x2iIXOJY9atm48B8/BR8L8bYfsSqcEw fA3hyvwQuQXiRYEzIHY1F7wqOOl1XQ/0H/V7KXvUVIOfzS3GBLo0NgF95Epy+n4QfzR2 5M8PgdZ3EexZl450vU3Abb66qlOm6LHdKtsmA= 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=mKQyHCr4fhk7FRvcwewPz3anN3P4JyxOPFBfdU5g9mw=; b=ndCKXGmSOA/npAjcRQOwP2ZHJTNzvoApXMfef2yL/x0N7/uTWFE/ToPGP4SYE1/AFG 2Idkmgn2X8HBOodpiUuofYC22lArKJJQFj0Vz8rytoyZ0rlyJtKJ3j5V4Itdrp+lZLLf iOD78LHNKmFtfaQw7iwwN9CKxjmGjJJnz6vN51lPT7vwRGyoLyyE9F8t3K+mnAvt549U syAw4u+VFQscEnlPDfRtmD8tSZkB09cPhQOqKfVQumPfG0jDfH270vgmnhrDROA4AI2O FsAaOXEX+pDzwiGeXBNo2NaAt60hxmJpfNeIkSgwxdAMMBJH0gV1SVubTcz9HoXNleTM qKBw== X-Gm-Message-State: AODbwcB+P5anqGNUFqy3tyDTdFO6atdhu2v+/NaC5zhOD3wIYxUIaW6c N0+uwUnG697+ulS+hOtD3A== X-Received: by 10.99.175.76 with SMTP id s12mr27907651pgo.152.1496769937918; Tue, 06 Jun 2017 10:25:37 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.25.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:25:37 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:16 +0530 Message-Id: <1496769929-23355-2-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 01/14 v4] 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. One recent example is pl011 emulation, which needs similar functions to read/write the 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: ss CC: jg 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 544867a..75c716e 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 { @@ -171,116 +172,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 Tue Jun 6 17:25:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103173 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536661qgd; Tue, 6 Jun 2017 10:27:46 -0700 (PDT) X-Received: by 10.36.9.144 with SMTP id 138mr16926304itm.98.1496770066809; Tue, 06 Jun 2017 10:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770066; cv=none; d=google.com; s=arc-20160816; b=Ks5P/UhLQwU4SQuVJVrNU3RMoj1AiNBdp+6h8PD6IeOjtG+jvgH7iS6FCC0TSa/G+H FtWgm/AECv0yGWarmRQNHaPkJyKWTp/YN1aFkOSuyp/jAGbrZo5c9zPfxWlWnOwUB17g O3/qVItqAjrODu8giODqTrqqVg1iq++SQvnX6w/GDvTP8A0+H3DT8413G/pQ/CpwZIXx HTugzOEqlvvxuR7yZZ4PG0fgK62yuNYiWny4wDR1/NoxaohVHP21iv6xOXg/zp93IJ2N yUFg5BozhoFmc3pxxfyrIumo5ndKHFItnIfDLdkSOjdKScz6L6HFT1MrbEoxaMHc3KL/ 0Hhw== 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=BWFmwuS9DhyTrCl1zkRAP9qiJkP17D6zImVn5/wlP8Y=; b=rzUH8TxdjFoBRnLlNPjyZ79Pz53ej59iUrLagRV26dt1sQJOyyHa9iqOyuSYlDjDER IkCGqIOTEuWMN1R9IHyPNedpWJLP18386wnzvbPEgOFBEjARoIv6daYTgw2/3HtJTLDb S5tyxcOc+kI96fcXzxC5r6bbf0LPB1wbvPwUtSQbF+h7K84PfY/PqjCd4YkwSBqeA8G5 8368bhtuR9apAs5Nm7P+qGeaneOWXKyAKi/jWIlZYToJMqe1Jjpe1ClEgAH1PEu6EAGm BXA1u5KFmvsWgtZgzXo0tGhIHLLIg28H9HEGdMl5NimGH9F1xOxyw7vzYIjZBbaVHPes WmcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 y30si5599337ioe.56.2017.06.06.10.27.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:27:46 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIEj-0001Ux-H1; Tue, 06 Jun 2017 17:25: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 1dIIEh-0001UT-V1 for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:25:44 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 9B/CC-03613-795E6395; Tue, 06 Jun 2017 17:25:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRtspDvtqVm kwZU2JYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNaP/yX6WguN7GCu2r1nI3MB4sLCLkYtDSGAG o8TaS4eYuhg5OVgE5jFL3O+WAklICPSzSmy4cIIRJCEhkCYx49ce5i5GDiC7UuLGt0CQsJCAl sTRU7NZIQY1M0nc73vCAlLDJmAiMatDAqRGREBJ4t6qyWDzmQVCJab+fcACYgsLxEmsbFrNDr FXVaL9xUKwVbwC3hI/9m2FWisncfNcJzOIzSngIzHz/BJGiL3eEnsa2hgnMAosYGRYxahenFp Ullqka6qXVJSZnlGSm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iREYVgxAsINx+mX/Q4ySHExK oryRl8wihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwRj4BygkWpaanVqRl5gADHCYtwcGjJMI7+ QFQmre4IDG3ODMdInWKUZdj0oHtX5iEWPLy81KlxHkVQGYIgBRllObBjYBF2yVGWSlhXkago4 R4ClKLcjNLUOVfMYpzMCoJ86aATOHJzCuB2/QK6AgmoCP4LpmAHFGSiJCSamDkaLm+9MDSJwz tTfvnfv014czkE3Erpn++JZguMrGq49yvJfELn3co3u+dyfNnufmNdZaJx/LdPRUtXuSf2rLo 6M5apfsqzfv28NX9yNzY/NX2ovtyNf2lu/wnqDZo/7LgrbecmKi7dce750cfOkmfULe+clvtd 8oFVYctC4P+xK43Y5toUvP3thJLcUaioRZzUXEiAMXVQSSxAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-27.messagelabs.com!1496769941!106074625!1 X-Originating-IP: [74.125.83.50] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61701 invoked from network); 6 Jun 2017 17:25:42 -0000 Received: from mail-pg0-f50.google.com (HELO mail-pg0-f50.google.com) (74.125.83.50) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:25:42 -0000 Received: by mail-pg0-f50.google.com with SMTP id v18so27200250pgb.1 for ; Tue, 06 Jun 2017 10:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=74FBspI/Y17t4J1kWlFa7B2MWBkGi7flO/LyjuVEWVs=; b=KcXHXRfHSAbcT2w4RAGCd3Eyrtwpm0s7giZJT0eCBdiO5bshPWNN3u2rEFiinESWLj fTZVYfbV2HVZcX7t3ZGtB+m5uKPBrMYONqxU9clvNLcsYoSaOkS/N5t2v5s+nCBw9Mxf IneF7yTDu1SFvqxt2mgHpqLBo5Z9uBoagVi1Q= 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=74FBspI/Y17t4J1kWlFa7B2MWBkGi7flO/LyjuVEWVs=; b=f4488XIFm2Qnu8s6xVWpamXwp1fTkN/a1WxPDkHWzPDdZW9DI8BCYBRylNm/bwVUuj OWZsshcgJfl7XUsfAfRbHgBPmWRqDNtdcIl0gQZNDF5myv9fHXkMjP2sRfLI3AjFoSUp lDjF3N58djO9Uuk0vNGDyQ1bNB7rzF41c5vnt8jdUKYdTE9s7AN0csH/GOr/aIbsKkih KyK9EL0bjp+8F9+svfrBsk2WYAUYFSLj7RarUdELo27jVnmQVlzAsquIwRRlbB9PUJHt 7WmXlb4rpCcU5bgY7XpXABjOqk5iEFVAjI8vMeO2lOS1D6AoX0nYyZH70hqA+Q9nfOXo OR8g== X-Gm-Message-State: AODbwcCrFUI9ysriUBp16QmzcRGs6bH1mZ65fQQHgkVVV9Mqae2/Dwix Qx0ukvblUCn8kN8EKW2bYw== X-Received: by 10.84.232.76 with SMTP id f12mr22345743pln.87.1496769940420; Tue, 06 Jun 2017 10:25:40 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.25.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:25:39 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:17 +0530 Message-Id: <1496769929-23355-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 02/14 v4] xen/arm: vpl011: Define generic vreg_reg* access functions in 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" This patch redefines the vgic_reg* access functions to vreg_reg* functions. These are generic functions, which will be used by the vgic emulation code to access the vgic registers. PL011 emulation code will also use vreg_reg* access functions. Signed-off-by: Bhupinder Thakur --- CC: ss CC: jg Changes since v3: - Renamed DEFINE_VREG_REG_HELPERS to VREG_REG_HELPERS. xen/arch/arm/vgic-v2.c | 28 +++++------ xen/arch/arm/vgic-v3.c | 40 ++++++++-------- xen/include/asm-arm/vreg.h | 115 ++++++++++++++++++++++----------------------- 3 files changed, 91 insertions(+), 92 deletions(-) diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index dc9f95b..3e35a90 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, gicd_reg - GICD_IPRIORITYR, DABT_WORD)]; 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; @@ -508,7 +508,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info, ipriorityr = &rank->ipriorityr[REG_RANK_INDEX(8, gicd_reg - GICD_IPRIORITYR, DABT_WORD)]; - vgic_reg32_update(ipriorityr, r, info); + vreg_reg32_update(ipriorityr, r, info); vgic_unlock_rank(v, rank, flags); return 1; } @@ -529,7 +529,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); @@ -551,7 +551,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.c b/xen/arch/arm/vgic-v3.c index d10757a..e1213d9 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -181,7 +181,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): @@ -199,7 +199,7 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info, if ( v->arch.vgic.flags & VGIC_V3_RDIST_LAST ) typer |= GICR_TYPER_LAST; - *r = vgic_reg64_extract(typer, info); + *r = vreg_reg64_extract(typer, info); return 1; } @@ -257,7 +257,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: @@ -284,7 +284,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: @@ -328,7 +328,7 @@ read_reserved: return 1; read_unknown: - *r = vgic_reg64_extract(0xdeadbeafdeadbeaf, info); + *r = vreg_reg64_extract(0xdeadbeafdeadbeaf, info); return 1; } @@ -489,7 +489,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; @@ -498,7 +498,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; @@ -525,7 +525,7 @@ static int __vgic_v3_distr_common_mmio_read(const char *name, struct vcpu *v, DABT_WORD)]; vgic_unlock_rank(v, rank, flags); - *r = vgic_reg32_extract(ipriorityr, info); + *r = vreg_reg32_extract(ipriorityr, info); return 1; } @@ -541,7 +541,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; } @@ -585,7 +585,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; @@ -596,7 +596,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; @@ -638,7 +638,7 @@ static int __vgic_v3_distr_common_mmio_write(const char *name, struct vcpu *v, vgic_lock_rank(v, rank, flags); ipriorityr = &rank->ipriorityr[REG_RANK_INDEX(8, reg - GICD_IPRIORITYR, DABT_WORD)]; - vgic_reg32_update(ipriorityr, r, info); + vreg_reg32_update(ipriorityr, r, info); vgic_unlock_rank(v, rank, flags); return 1; } @@ -653,7 +653,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); @@ -901,7 +901,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; @@ -926,14 +926,14 @@ static int vgic_v3_distr_mmio_read(struct vcpu *v, mmio_info_t *info, typer |= (irq_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): @@ -1026,7 +1026,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; } @@ -1044,7 +1044,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): @@ -1107,7 +1107,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 ) @@ -1213,7 +1213,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..16207ce 100644 --- a/xen/include/asm-arm/vreg.h +++ b/xen/include/asm-arm/vreg.h @@ -107,102 +107,102 @@ 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, \ - 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; \ +#define VREG_REG_HELPERS(sz, offmask) \ +/* N-bit register helpers */ \ +static inline register_t vreg_reg##sz##_extract(uint##sz##_t reg, \ + const mmio_info_t *info) \ +{ \ + return vreg_reg_extract(reg, info->gpa & offmask, \ + info->dabt.size); \ +} \ + \ +static inline void vreg_reg##sz##_update(uint##sz##_t *reg, \ + register_t val, \ + const mmio_info_t *info) \ +{ \ + unsigned long tmp = *reg; \ + \ + vreg_reg_update(&tmp, val, info->gpa & offmask, \ + info->dabt.size); \ + \ + *reg = tmp; \ +} \ + \ +static inline void vreg_reg##sz##_setbits(uint##sz##_t *reg, \ + register_t bits, \ + const mmio_info_t *info) \ +{ \ + unsigned long tmp = *reg; \ + \ + vreg_reg_setbits(&tmp, bits, info->gpa & offmask, \ + info->dabt.size); \ + \ + *reg = tmp; \ +} \ + \ +static inline void vreg_reg##sz##_clearbits(uint##sz##_t *reg, \ + register_t bits, \ + const mmio_info_t *info) \ +{ \ + unsigned long tmp = *reg; \ + \ + vreg_reg_clearbits(&tmp, bits, info->gpa & offmask, \ + info->dabt.size); \ + \ + *reg = tmp; \ } /* @@ -211,10 +211,9 @@ 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); - -#undef VGIC_REG_HELPERS +VREG_REG_HELPERS(32, 0x3); +#undef VREG_REG_HELPERS #endif /* __ASM_ARM_VREG__ */ From patchwork Tue Jun 6 17:25:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103178 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536721qgd; Tue, 6 Jun 2017 10:27:56 -0700 (PDT) X-Received: by 10.36.40.17 with SMTP id h17mr20138935ith.39.1496770076272; Tue, 06 Jun 2017 10:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770076; cv=none; d=google.com; s=arc-20160816; b=bMJd1MLjOuVZf5thpZyHdlvopPXQ/DGtrlpo+FZOQMkpHb2SqYnwNBwj6ClY1VVq+H 3Kkeb8MGgNIjKarB8E/F23234337r2hQADmUa1yehy2FgAFmUynM25oKHoVK48jW5XHx qk4rQBqsxTMK3myrN8rohv8UmtvHgsb5S5GPAZYYvWe86VtNTGGmq7ohFBFavzv2is9n beF4u6wfDns3mMAtWM02ctU4t1sjYAnFbReGJNR34Rkt4U0IkQJVlt2wr4RuKcBhRvHG e6Cqdf/l4F1lMAGBwkba76hpx9cabEUZPSOKjxM58xfuBl1MQ7HfrZ1pC8aZpKm4V2hv b9hw== 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=+nmy7rtpWICwxLk53Wv+qD1utVoN/6jPLbKfUDOTqv8=; b=TftuEFTzY85M7ZzF/zvQMsXB4hiWtWL0L1o6p3DtrAJurfaFubJNoP46qGOkOpk4iU mHNUtiFJtcfZWfdr9HfCglBJzCIywY7qLdnsza9YB+PlOGn29d1Rd1hWpPmFpM1DkDw8 cNGWKsyVx7XV0hN+Y9IKwjtxMlcp8VbFO2aAHW5v4a7uFOgIAGtD0Mde8jvg+PwdyKOb S/pe3xEayfiXSUsgNtzp6677NDvT0JfqbhynOwwlBin1r/qvmNhZu2vGpspJR+++r/au R5rn7zedYVkLyKfzWm5RGwskUjPOU6WdA8uBcx/c8B61g+rfGYhzm+kN9eh4gt2q9ZnX 8FiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 6si16265165itn.5.2017.06.06.10.27.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:27:56 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIEm-0001XG-UM; Tue, 06 Jun 2017 17:25:48 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIEl-0001WS-Mf for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:25:47 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id 24/DE-03920-B95E6395; Tue, 06 Jun 2017 17:25:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRusrzvrqVm kwYYbzBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b7MxsZCxbNZ6x4N2MSewPj68ouRi4OIYHp jBLP+++xgTgsAvOYJT5tmMkM4kgI9LNKNG1axd7FyAnkpElMuvkLyi6XmPC8kQ3EFhLQkjh6a jYrxKhmJontDz8AJTg42ARMJGZ1SIDUiAgoSdxbNZkJpIZZ4AKjxI/zz8GahQW8JObdOgdWzy KgKtFxwgEkzCvgLbG5cw0rxC45iZvnOplBbE4BH4mZ55cwQuz1ltjT0MY4gVFgASPDKkb14tS istQiXSO9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYzA0GIAgh2My/46HWKU5GBS EuWNvGQWKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCN/IJUE6wKDU9tSItMwcY5DBpCQ4eJRHey Q+A0rzFBYm5xZnpEKlTjMYcC3o2fGHimHRg+xcmIZa8/LxUKXFeBZBJAiClGaV5cINg0XeJUV ZKmJcR6DQhnoLUotzMElT5V4ziHIxKwrwpIFN4MvNK4Pa9AjqFCegUvksmIKeUJCKkpBoYBXj 4TB9nfV6WzvHt/Uy3t39/MD2pPXBLRnd5tVzOsez3EjlTmorbMoRaHx9+vXONr4k504V3K5Nn 7Kr2/JJsbHa3sm//JdODHVv3GD+U+jf/4tn0i4zpS+Q7MrLl7xxNusOxsr7peeCW1WEbNUtL7 09c/Tt0S2ZF7f0vXhnmjPWmj4/K9uWmK7EUZyQaajEXFScCAMzV0aO5AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-4.tower-27.messagelabs.com!1496769944!105565001!1 X-Originating-IP: [74.125.83.47] 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 42488 invoked from network); 6 Jun 2017 17:25:45 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-4.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:25:45 -0000 Received: by mail-pg0-f47.google.com with SMTP id k71so4103164pgd.2 for ; Tue, 06 Jun 2017 10:25: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=YtFPP34Ox9mtW12x0jD/z/QOpMH1T338dVu4Dm6GVbU=; b=f6jdZdaHCXBKckkUT8KDCRHCzooH1nVM86QFSIygjckQJ2NEMalqLi+o9kLIVFKzS4 8fDMDqpKsF53nCow9NO/hgtXX5Q96+1mpmkfp3qfO/XknVVm04ohpqTOsB7B1STw3RPl LVD8LAw7Vgi7BS4t6bn+YTGgiZqbcvkiqeaK0= 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=YtFPP34Ox9mtW12x0jD/z/QOpMH1T338dVu4Dm6GVbU=; b=rBU5Ro5oTPEgW/kDhlxncxxI4mUyd53GMg00yhhV3xbC4TcdZ6q8FYsKhBSXXKGL8j Su8xi1F7Wv5QjlCu5OVpXqWTlwLF72NB/zNJ/oan6BpMlRCB2uZuduclarduE3zKXw6X qbzz0RaEsD7n5sQj+UBMTtOxmV2VHE8Nv4sWtWnQFBZRYNVBRn3ZFImlXxAWBddx+xbN yTepBNAlVrHvINXUj7dsk+TSmoczqwJm9nO5w/eFNLKjG1rLv3IuiwnAGG3U0S1Jd0o0 1xrjFr5/DW1V25XlrACD+L+FWfCScQ0UGVsucb58L215bav97plGuFpiAmiiC+XVwGBl wAfw== X-Gm-Message-State: AODbwcAoLRlSV8yfJYX+Kf8jshtx0usXGvWWBKKh6aote+jie4vEgk83 kVA9+v147O8xJ2eJu1QAzg== X-Received: by 10.99.1.88 with SMTP id 85mr28247283pgb.110.1496769943709; Tue, 06 Jun 2017 10:25:43 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.25.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:25:43 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:18 +0530 Message-Id: <1496769929-23355-4-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 03/14 v4] xen/arm: vpl011: Add pl011 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 The SBSA compliant pl011 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: ij CC: wl CC: ss CC: jg CC: kw 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 tools/console/daemon/io.c | 2 +- xen/arch/arm/Kconfig | 5 + xen/arch/arm/Makefile | 1 + xen/arch/arm/vpl011.c | 418 +++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/domain.h | 6 + xen/include/asm-arm/pl011-uart.h | 2 + xen/include/asm-arm/vpl011.h | 74 +++++++ xen/include/public/arch-arm.h | 6 + xen/include/public/io/console.h | 4 + 9 files changed, 517 insertions(+), 1 deletion(-) create mode 100644 xen/arch/arm/vpl011.c create mode 100644 xen/include/asm-arm/vpl011.h diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 7e6a886..947f13a 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/arch/arm/Kconfig b/xen/arch/arm/Kconfig index d46b98c..c1a0e7f 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -50,6 +50,11 @@ config HAS_ITS prompt "GICv3 ITS MSI controller support" if EXPERT = "y" depends on HAS_GICV3 +config VPL011_CONSOLE + bool "Emulated pl011 console support" + default y + ---help--- + Allows a guest to use pl011 UART as a console endmenu menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 49e1fb2..15efc13 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -52,6 +52,7 @@ obj-y += vm_event.o obj-y += vtimer.o obj-y += vpsci.o obj-y += vuart.o +obj-$(CONFIG_VPL011_CONSOLE) += vpl011.o #obj-bin-y += ....o diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c new file mode 100644 index 0000000..9b1f27e --- /dev/null +++ b/xen/arch/arm/vpl011.c @@ -0,0 +1,418 @@ +/* + * 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 + +static bool vpl011_reg32_check_access(struct hsr_dabt dabt) +{ + return (dabt.size != DABT_DOUBLE_WORD); +} + +static void vpl011_update(struct domain *d) +{ + struct vpl011 *vpl011 = &d->arch.vpl011; + + /* + * 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. + */ + if ( vpl011->uartris & vpl011->uartimsc ) + vgic_vcpu_inject_spi(d, GUEST_VPL011_SPI); +} + +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 = intf->in_cons; + XENCONS_RING_IDX in_prod = intf->in_prod; + + VPL011_LOCK(d, flags); + + /* + * 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; + intf->in_cons = in_cons; + smp_mb(); + } + 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_UNLOCK(d, flags); + + 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 = intf->out_cons; + XENCONS_RING_IDX out_prod = intf->out_prod; + + VPL011_LOCK(d, flags); + + /* + * 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; + smp_wmb(); + out_prod += 1; + 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_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; + + switch ( vpl011_reg ) + { + case DR: + /* + * Since pl011 registers are 32-bit registers, all registers + * are handled similarly allowing 8-bit, 16-bit and 32-bit + * accesses. + */ + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + *r = vreg_reg32_extract(vpl011_read_data(v->domain), 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; + + *r = vreg_reg32_extract(vpl011->uartfr, info); + return 1; + + case RIS: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + *r = vreg_reg32_extract(vpl011->uartris, info); + return 1; + + case MIS: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + *r = vreg_reg32_extract(vpl011->uartris & + vpl011->uartimsc, info); + return 1; + + case IMSC: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + *r = vreg_reg32_extract(vpl011->uartimsc, info); + 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; + + /* + * Since pl011 registers are 32-bit registers, all registers + * are handled similarly allowing 8-bit, 16-bit and 32-bit + * accesses. + */ + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + vreg_reg32_update(&data, r, info); + data &= 0xFF; + vpl011_write_data(v->domain, data); + return 1; + } + case RSR: /* Nothing to clear. */ + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + return 1; + + case FR: + case RIS: + case MIS: + goto write_ignore; + + case IMSC: + if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; + + VPL011_LOCK(d, flags); + vreg_reg32_update(&vpl011->uartimsc, r, info); + VPL011_UNLOCK(d, flags); + vpl011_update(v->domain); + 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_UNLOCK(d, flags); + vpl011_update(d); + 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 = intf->in_cons; + XENCONS_RING_IDX in_prod = intf->in_prod; + XENCONS_RING_IDX out_cons = intf->out_cons; + XENCONS_RING_IDX out_prod = intf->out_prod; + XENCONS_RING_IDX in_ring_qsize, out_ring_qsize; + + VPL011_LOCK(d, flags); + + 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_UNLOCK(d, flags); + + vpl011_update(d); +} + + +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 0; + + /* 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; + } + + register_mmio_handler(d, &vpl011_mmio_handler, + GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL); + + spin_lock_init(&vpl011->lock); + + rc = alloc_unbound_xen_event_channel(d, 0, info->console_domid, + vpl011_notification); + if ( rc < 0 ) + goto out2; + + vpl011->evtchn = info->evtchn = rc; + + return 0; + +out2: + xfree(d->arch.vmmio.handlers); + 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 6de8082..91d1061 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 { @@ -133,6 +134,11 @@ struct arch_domain struct { uint8_t privileged_call_enabled : 1; } monitor; + +#ifdef CONFIG_VPL011_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..b3e332d --- /dev/null +++ b/xen/include/asm-arm/vpl011.h @@ -0,0 +1,74 @@ +/* + * 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 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_VPL011_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 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 Tue Jun 6 17:25:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103170 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536639qgd; Tue, 6 Jun 2017 10:27:44 -0700 (PDT) X-Received: by 10.36.95.197 with SMTP id r188mr20346059itb.38.1496770063946; Tue, 06 Jun 2017 10:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770063; cv=none; d=google.com; s=arc-20160816; b=j/5oSdn9qzFhbgp+g6zaYTIGanB1caCb3e6ws/pF+D+P5i3AFwU13LLJIVlvGWIEy6 ljgBtYM8xASl3cqldLteCHVitL3kfm5H4z/Vpr/lf2t5X9b691FPp4aT1GAoTR6Rx30R OHgKWV0GiSgHmj1FRHqbmMqWV2DlAWZUDtqRIRxXTBXFRx/iSAIAHetWzfanmRDvfcxw HAyBVgI5IX0wjec6L3Lx9EmsxHImjeKnC+hmhc5yfL/qha+efOqBXMCmFZpfhmAwLLiZ KIcdmt364Sc07f8x5BA3XvNIlBH5SN0LBkOTkrpdou1gcnbSLraMmrKHo6g7vBD7y0wP jX7A== 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=w90pSoebXgBVu3eu/THaQ9ShGDN6H8j7YBss6OCILbg=; b=bfVVFHx7H2kZUlpNUHu8qwj5Q695BpGR32JSI0rTEWugCwl7k+LQ/TsekAyTUvdhtu uCn8PK/cCfC7yfcR8aWdhXxOlva/iTULgCmHaz3kVP32uIHn91XHNjfSk2ewY2fO70mK 81bR+7X9Rz3RK6uf1jf9u0e2W7gggXyyw2Zp5S//kzsNGwxM1DkISEf3cAptub3LM8/6 y8Tg2FUW9ypOKsTgICMOkI7YTwYg4IpRCqp9FZat1wznIwPNtVnrpOGRLSD74MXWPExd gZeFOUqLMMweWA6TdB6xyBpQgOGhTCF5Nri/QdgGQ1m34PKI4dK/4WkDAamhcWUI+5QG e85g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 y99si9399040ioe.224.2017.06.06.10.27.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:27:43 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIEp-0001Ys-5a; Tue, 06 Jun 2017 17:25:51 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIEn-0001Xd-Q4 for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:25:49 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 42/D3-03058-D95E6395; Tue, 06 Jun 2017 17:25:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsVyMfTAZt05T80 iDc7clrH4vmUykwOjx+EPV1gCGKNYM/OS8isSWDP2/7vEVPDdrGLd1iaWBsbH2l2MnBxCAjMY JbYvLOpi5OJgEZjHLLH++z4WkISEQD+rxNzj3hB2mkTPvR52CLtK4uHHWWwQzVoSR0/NZgVpF hJoZpKYtuELkMPBwSZgIjGrQwKkRkRASeLeqslMIDXMAvMZJZom9YI1Cwt4SqxsfcsKYrMIqE pcOH+TGcTmFfCWeND+gRFimZzEzXOdYHFOAR+JmeeXMEIs9pbY09DGOIFRYAEjwypGjeLUorL UIl0jI72kosz0jJLcxMwcXUMDM73c1OLixPTUnMSkYr3k/NxNjMDAYgCCHYxr5gceYpTkYFIS 5Y28ZBYpxJeUn1KZkVicEV9UmpNafIhRhoNDSYI38glQTrAoNT21Ii0zBxjiMGkJDh4lEd7JD 4DSvMUFibnFmekQqVOMlhxXrqz7wsSxYfV6IDnlwPYvTEIsefl5qVLivAog8wRAGjJK8+DGwe LwEqOslDAvI9CBQjwFqUW5mSWo8q8YxTkYlYR574Gs5cnMK4Hb+groICagg/gumYAcVJKIkJJ qYJReI5As/C7rzpsd6QX7N7npXuxfMS1KtfmES/j/rdnMN84Z1Z99vezuoqzIOP6ZUV9CVBnq PzLW/Et55uWqlhNW4sH2sd7w/bb9T6xubuRYt+JEziw3ga+7Zh8pWXxp9d4n69YLM9mUmFiyS SwVsn7gFx+Z3WIUn721P+Ewy/nnSvnXvuxdwqLEUpyRaKjFXFScCAAdeehEvgIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-21.messagelabs.com!1496769947!72472212!1 X-Originating-IP: [209.85.192.179] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58456 invoked from network); 6 Jun 2017 17:25:48 -0000 Received: from mail-pf0-f179.google.com (HELO mail-pf0-f179.google.com) (209.85.192.179) by server-11.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:25:48 -0000 Received: by mail-pf0-f179.google.com with SMTP id x63so2102495pff.3 for ; Tue, 06 Jun 2017 10:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7GlVSQFidO4VN3kkYpQ+75PBMnIiFHskT94zljnu7ZY=; b=A3N22az71yEi90OghoOcRVGvOmT6xemhWEt6oh4jeYkAidsbSo6Rlqdb5U0cEdTEED DaM5UxgoJ9YPppY51UsZrxksTcipVVS0WUsassKaosp02W3oDEVZH617fwfzErQKNmzY 7m31chk6eM4JPBoxFbZNIeCUbP+61XXndfnVw= 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=7GlVSQFidO4VN3kkYpQ+75PBMnIiFHskT94zljnu7ZY=; b=SAuiJ0/xEzOSl8aHjEqlYi7jjBqg6Hp8Ikhm9lIPlLCASXcm3pdeSMNdozjmno/nfG KLNAmFoKSYHRoZPu8vCHLBdbm5GPsrheOUAu4LjrkYN+o9Qujnbzq9d9R/xBWIBGXwdF 4S/q4PjZ9boZUTRHWn+he0+d/Vrd6UsSU0r3hh1fBCWppyh0hMJsygZcYKbiGkgRgedT +Mb1GfOoMsgrP7o8RS3ef9t/h6qILoHEIZWaW2vQwEZcQGqDEslGBQnzMwqSZgJRDf3y /oz67NIkZJ4ih51RqtVB40aSt3HFTJTq0JWNjcIJcHab7/JzRZfTD9gYNQO62VOAxU07 pT2w== X-Gm-Message-State: AODbwcCdO6eP/IDedb8FTFV6fFOJx61bh2hOA1hj8NLyiMwvb9bQ9iGv zrz6rRaGjwIpz9sFObpiag== X-Received: by 10.98.131.134 with SMTP id h128mr26958450pfe.0.1496769946579; Tue, 06 Jun 2017 10:25:46 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.25.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:25:46 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:19 +0530 Message-Id: <1496769929-23355-5-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 04/14 v4] 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 pl011 vuart while creating a guest domain. Libxl now suppots a generic vuart console and pl011 is a specific type. In future support can be added for multiple vuart of different types. User can enable pl011 vuart by adding the following line in the guest configuration file: vuart = "pl011" Signed-off-by: Bhupinder Thakur --- CC: ij CC: wl CC: ss CC: jg 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. config/arm32.mk | 1 + config/arm64.mk | 1 + tools/libxl/libxl.h | 6 ++++++ tools/libxl/libxl_console.c | 3 +++ tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_types.idl | 7 +++++++ tools/xl/Makefile | 4 ++++ tools/xl/xl_cmdtable.c | 4 ++++ tools/xl/xl_console.c | 11 ++++++++++- tools/xl/xl_parse.c | 8 ++++++++ 10 files changed, 47 insertions(+), 1 deletion(-) 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/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_internal.h b/tools/libxl/libxl_internal.h index 5d082c5..4e2c247 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1135,6 +1135,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..066aace 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, "pl011"), + ]) + # # 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/Makefile b/tools/xl/Makefile index e16f877..d7c4927 100644 --- a/tools/xl/Makefile +++ b/tools/xl/Makefile @@ -15,6 +15,10 @@ LDFLAGS += $(PTHREAD_LDFLAGS) CFLAGS_XL += $(CFLAGS_libxenlight) CFLAGS_XL += -Wshadow +ifeq ($(CONFIG_VUART_CONSOLE),y) +CFLAGS_XL += -DCONFIG_VUART_CONSOLE +endif + XL_OBJS = xl.o xl_cmdtable.o xl_sxp.o xl_utils.o XL_OBJS += xl_tmem.o xl_parse.o xl_cpupool.o xl_flask.o XL_OBJS += xl_vtpm.o xl_block.o xl_nic.o xl_usb.o diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 30eb93c..14f7a50 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -133,7 +133,11 @@ struct cmd_spec cmd_table[] = { &main_console, 0, 0, "Attach to domain's console", "[options] \n" +#ifdef CONFIG_VUART_CONSOLE + "-t console type, pv , serial or vuart\n" +#else "-t console type, pv or serial\n" +#endif "-n console number" }, { "vncviewer", diff --git a/tools/xl/xl_console.c b/tools/xl/xl_console.c index 0508dda..d6ca93f 100644 --- a/tools/xl/xl_console.c +++ b/tools/xl/xl_console.c @@ -27,6 +27,11 @@ int main_console(int argc, char **argv) uint32_t domid; int opt = 0, num = 0; libxl_console_type type = 0; +#ifdef CONFIG_VUART_CONSOLE + char *console_names = "pv, serial, vuart"; +#else + char *console_names = "pv, serial"; +#endif SWITCH_FOREACH_OPT(opt, "n:t:", NULL, "console", 1) { case 't': @@ -34,8 +39,12 @@ int main_console(int argc, char **argv) type = LIBXL_CONSOLE_TYPE_PV; else if (!strcmp(optarg, "serial")) type = LIBXL_CONSOLE_TYPE_SERIAL; +#ifdef CONFIG_VUART_CONSOLE + else if (!strcmp(optarg, "vuart")) + type = LIBXL_CONSOLE_TYPE_VUART; +#endif 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 Tue Jun 6 17:25:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103169 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536596qgd; Tue, 6 Jun 2017 10:27:39 -0700 (PDT) X-Received: by 10.107.20.145 with SMTP id 139mr26985095iou.11.1496770059304; Tue, 06 Jun 2017 10:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770059; cv=none; d=google.com; s=arc-20160816; b=lBkkMWuOTCZeIZa+VeWfriTPtThlvK2DMH0uak+jYxxBlxjflUG9e2ZJi1w7X+BR+w XjifUvtXV/uOSXeq7huiO1950YzwmHAFKyHsyebp4QelpYXw4nTeBUr4uXWGh/WqUwof SeCHKGUuNxL2AF/bePGIbYYgo4UhSpNFPvFw9HCpEfaYwucjj2modZXI3LVRgdgraI3/ 05n7vpj6q1yY0068ogpzxYCq4VWzNXSGT3VYXmZHrZ+BszdRwkaGG009nQmdOt/Pf/Dp gBvyS1dXKO7LTyNHk7zTLIM6Kerj6y3RzpXCt0Z2RyKY79sQBRp+0J31eTjPna02XMkG RDzw== 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=bftm4WadwKfLG/hdPStLCu9Z4GlXQnB8jG6KxBrAROg=; b=J12VtKfYYWSiRH2BotpbPtlgANHeQgmn1tlkdpkRxNKNR+MF+dsUpdE17tuI5/Ffab b1jv0Bi3dK0Q39C9jcksJ4uyM2z4DnDK/1QIBdwa7CNVT/w4PyG2e2tiNj1HiVnGuDHu nGJBwbgsHgk7H/30oYObDai5HK5luVJSNZPtz63tnUbGxA9B5yzND72evRJqHpdkySdM 2jq8WR6vJd7VSrVlmMvZ40f3fIaQlYjKZzHCQISE5W64PwnzpwHVmf6s5ASdYkpAQEYc 5UR/Uio9CtRTbFk5V9g8L9gQKQxyY8ainMk2WPQKmkClLkBJZGg333J0AJsNWNNjhBgc dEgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 t26si34727589ioi.151.2017.06.06.10.27.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:27:39 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIEs-0001bp-Hl; Tue, 06 Jun 2017 17:25:54 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIEr-0001ar-Om for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:25:53 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 70/46-02006-0A5E6395; Tue, 06 Jun 2017 17:25:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsVyMfTANt0FT80 iDb5c4bP4vmUykwOjx+EPV1gCGKNYM/OS8isSWDM2fL3AWnBRuuLj31bWBsafYl2MXBxCAjMY JVa82swO4rAIzGOW2Dx3MjOIIyHQzyrRcaubpYuRE8hJk2jZvo8Nwq6S2Hy3hRXEFhLQkjh6a jYrxKhmJonV3VOAujk42ARMJGZ1SIDUiAgoSdxbNZkJpIZZYD6jRNOkXrBBwgIREpP/7WACqW cRUJWYNMMPJMwr4C2x92A3I8QuOYmb5zqZQWxOAR+JmeeXMELs9ZbY09DGOIFRYAEjwypGjeL UorLUIl0jM72kosz0jJLcxMwcXUMDU73c1OLixPTUnMSkYr3k/NxNjMDQqmdgYNzBeHuy3yFG SQ4mJVHeyEtmkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeCOfAOUEi1LTUyvSMnOAQQ6TluDgU RLhnfwAKM1bXJCYW5yZDpE6xWjMceXKui9MHFMObP/CJMSSl5+XKiXOuwJkkgBIaUZpHtwgWP RdYpSVEuZlZGBgEOIpSC3KzSxBlX/FKM7BqCTMmwIyhSczrwRu3yugU5iATuG7ZAJySkkiQkq qgdHrySYJj6enJ0utStrsvNvhvvEkEQbNQ8lXVT08VcW6b/3e889D1Nf5cVfKBalF//r3FizZ 2Nly7r3iU2uuk/veGtpx1om/j5nBX+zY8OrvWdPu2xr7LfwCz/YfandX/DbjeKD1tc/1n80tt IsN+iK3r+zfZfDA7xT/vgfM0h+6Q288OrBGyFeJpTgj0VCLuag4EQDgKzfguQIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-206.messagelabs.com!1496769950!63306918!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 44283 invoked from network); 6 Jun 2017 17:25:51 -0000 Received: from mail-pf0-f182.google.com (HELO mail-pf0-f182.google.com) (209.85.192.182) by server-14.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:25:51 -0000 Received: by mail-pf0-f182.google.com with SMTP id x63so2102984pff.3 for ; Tue, 06 Jun 2017 10:25: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=7Y8k5BD7EVf7eZ+CjzIjc9lGlzP8uFPbGxSAN8US9UY=; b=QvTDGzE0d+CiNbToXICC8t/AZXP913VJZRAyQhLM8Jtrp6IEwascvXNt2UA/PJFeWy DJoUGFlD3RzvfoKckUY/bPGMqQ1hA/eQ5/S/vZ4uaieqNekdHT5ucxfg16MGPzZVtwVG RlFf2D4YidL7Fv3XWdrczdoS29dhW/ZY+AriQ= 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=7Y8k5BD7EVf7eZ+CjzIjc9lGlzP8uFPbGxSAN8US9UY=; b=B0Dx8b/SRDEwL+SoG53N4smSX/NmFkP0rn5ZCngEMTSF5ukYr98MdVh/J591gXXUKt DNXsKLRUizUIDEvbkl8WWJKgjIqPWwQVWJjT8VXt3wRct2Bx6kaEzcd3JM3xxl0PlL5+ Ifb3jzREymQGz01rmnVijM9fgQh2lfrS5+IgL2Sz8sFyVyg7d2eCMUnB3c2yRSZp74gB fKeZF8igRLX8m783V8aTOReMzW5W8ISKXqrl9ieSSwAK+S0GfpXSEd8ckhJTkuOQ3yUp xTY0zgqkcUs3Bki1uJa1OWuWp9H/oHEJl2T6RQlFekV+w82tl5IksmAb3+VdmHkv+wmT YCzQ== X-Gm-Message-State: AODbwcCkqDPR93cvjUtfBcTnWFDv35rZm1TBR3TuBWoe/mjAVB+9mg31 D5Twj56W9Zf37Wgt3C3xWQ== X-Received: by 10.98.99.193 with SMTP id x184mr1296226pfb.101.1496769949430; Tue, 06 Jun 2017 10:25:49 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.25.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:25:49 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:20 +0530 Message-Id: <1496769929-23355-6-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 05/14 v4] 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: ij CC: wl CC: ss CC: jg 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 | 3 +++ tools/libxc/xc_dom_arm.c | 12 +++++++++++- tools/libxc/xc_dom_boot.c | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index ce47058..1cde2b7 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 ------------------------------------- */ @@ -334,6 +336,7 @@ int xc_dom_gnttab_seed(xc_interface *xch, domid_t domid, domid_t console_domid, domid_t xenstore_domid); bool xc_dom_translated(const struct xc_dom_image *dom); +xen_pfn_t xc_get_vuart_gfn(void); /* --- debugging bits ---------------------------------------------- */ diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index e7d4bd0..89d0d37 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 @@ -64,6 +65,13 @@ static int setup_pgtables_arm(struct xc_dom_image *dom) /* ------------------------------------------------------------------------ */ +xen_pfn_t xc_get_vuart_gfn() +{ + const xen_pfn_t base = GUEST_MAGIC_BASE >> XC_PAGE_SHIFT; + + return base + VUART_PFN_OFFSET; +} + static int alloc_magic_pages(struct xc_dom_image *dom) { int rc, i; @@ -85,10 +93,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 Tue Jun 6 17:25:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103172 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536655qgd; Tue, 6 Jun 2017 10:27:46 -0700 (PDT) X-Received: by 10.36.29.150 with SMTP id 144mr17613737itj.71.1496770066179; Tue, 06 Jun 2017 10:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770066; cv=none; d=google.com; s=arc-20160816; b=GeFv/3LEHgzVLqbAoh/xTTIj1Ai/Bo8Lep9gNZDkJYtcncFRGXc1P66T/gopLTQvd0 48otzKMy0w87ToSxvswTLCzUnpGAFP4OkKsUxwgFRMSk2rJvqoQEnM8t+whxHTrqfD56 TE+jlj02p9J6oUprqFuWK2LD8ciyhlY576PPQncRrWOBDn+xT5fkA1JtjUP54rxbOfkG gJdpc9izeX+VVU8oFywVXiUO2w/tMinAI6gfe2o5m2H1zIISTX83S/FtJH859F6twZFh A5QklUYvbV1M1j/XZ69m2LM/YS11A2KIz2kS0wuXgTSrxHd742spP/2IXjAzww4nh625 wCrg== 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=7TIcO2o0NiLMdhRqY2J0lA0ZZitdcMt8Um6Wj+oP6Ww=; b=eCINzYkql0DVGme2x7kYjhL7rA19ysvewtAh9D6gQrMNW/iIyETUWGviGd1nF/Qmze vz4P4Rbyxf12wx8lkOSO6jlUg1PqgrlhVvJdXABgw/5p/2KbZ+RhPFtgeAD4kUZWP8GW KQl186E5rJapAlZHgC3iMPdIBFNRBJY2EBQv4rqqF9iiH7DwH9Dm04zFfLg4mXA29GYA R42M1FADYhfqFmMF/Vpu7UK1P/lTvB2y99pYmrgtOHiEU/J4tGZxSEDk7ZHynWXRmo7L EHpzckoLmjUoe6AtQ2uDdor7I78KZcrJUy1AAppXOFPtp2TnLgCEd6eItil1nNesE8JW 63pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 88si12351846iol.215.2017.06.06.10.27.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:27:46 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIEv-0001eD-PQ; Tue, 06 Jun 2017 17:25:57 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIEt-0001cu-W3 for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:25:56 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 30/46-02196-3A5E6395; Tue, 06 Jun 2017 17:25:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsVyMfTAat1FT80 iDQ52yFp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmfXyxjLpgYWnFsVTNjA+Mb2y5GLg4hgRmM Eme//WQEcVgE5jFLPDvfwgriSAj0s0r83nuIpYuRA8hJk/j7xLeLkRPIrJR40rCRHcQWEtCSO HpqNivEpGYmicvdV8Dq2QRMJGZ1SIDUiAgoSdxbNZkJpIZZYD6jRNOkXjaQhLBAiMTqBe2MID aLgKrE2nmzwGxeAW+JxYv+sUIsk5O4ea6TGcTmFPCRmHl+CSPEYm+JPQ1tjBMYBRYwMqxi1Ch OLSpLLdI1MtVLKspMzyjJTczM0TU0MNbLTS0uTkxPzUlMKtZLzs/dxAgMrXoGBsYdjK0n/A4x SnIwKYnyRl4yixTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwXv/CVBOsCg1PbUiLTMHGOQwaQkOH iUR3skPgNK8xQWJucWZ6RCpU4zGHFeurPvCxDHlwPYvTEIsefl5qVLivCtAJgmAlGaU5sENgk XfJUZZKWFeRgYGBiGegtSi3MwSVPlXjOIcjErCvCkgU3gy80rg9r0COoUJ6BS+SyYgp5QkIqS kGhh7LNImndq0Zv2nA3M3vak/sMzko/GHV6+rBPP5V294dubfzysLujWP12zNCCiXdTXfaGi4 bmpsUbaDat2lLQfjGpMPfUv4pW7KMcNi74FYAcVLMX9O/1qjF2pQdOTgdF+Og+mHT8ZWTLt5v SVmQ4hT1g6GsBOPm8K7n7BHxTTp7S+Z2xjUJ3VSiaU4I9FQi7moOBEAd/Ue47kCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-2.tower-31.messagelabs.com!1496769953!92673486!1 X-Originating-IP: [209.85.192.171] 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 24600 invoked from network); 6 Jun 2017 17:25:54 -0000 Received: from mail-pf0-f171.google.com (HELO mail-pf0-f171.google.com) (209.85.192.171) by server-2.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:25:54 -0000 Received: by mail-pf0-f171.google.com with SMTP id 9so100034631pfj.1 for ; Tue, 06 Jun 2017 10:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7Jt2e94WLGukUYgBe9hFM67FAHDdWS9/aM+xrVXX5CI=; b=fGYQbob4z15YWCo2LrwCIcmcx0ElCjarWjkBvZxegv11GkWgZp1CCHveQLijFwQiuj uYtSTwoa+rz6RbPBWJgGA8xV76BhMKaq9Waw11YmejAmWRUSCUlYJrHOXN6BuwgWa/DB I3HECcqDbpQZbP8Ebn3VEqXVcPJiC8ca9KO1E= 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=7Jt2e94WLGukUYgBe9hFM67FAHDdWS9/aM+xrVXX5CI=; b=OpOyaijbTJ8cLV88wEhP24b1v1lRadUauPuTU9lK77KdwbDkxNfH2qohKqbQeo4yR/ o6aM6Sblzo1awa0s6r6dUWgcTMoH/AOTmJglF+90ZPdCd+YEuoNBFSxtj43sULyBfiVW tGouIxrVV1n+GFOThtunGeFCHueMebjjUEDkG8MUOKU1pjrqom1t3Y8w+GHvJFyVrYyz WHZxyPD9tfkaGWf1wXGJt7WYd+jGwyQHLnLGo1FqyilQPjSdKDwZIm57ng+Hjj6JbQuR 8iqT6SMZ42FjAhNwfo1vg0U+2aS/nsX14LoUWHSR4xuNX9Kvq7qTGrOcqtiGlVY2gCL1 a0QQ== X-Gm-Message-State: AODbwcAD3A67tfMtu/4FTmjZgAZjZoLDrbNeZ7PbHG+X/XjdxmySwrdc kIMLT76+y8tL8cvN+eR3mQ== X-Received: by 10.98.200.66 with SMTP id z63mr15072469pff.18.1496769952461; Tue, 06 Jun 2017 10:25:52 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.25.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:25:52 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:21 +0530 Message-Id: <1496769929-23355-7-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 06/14 v4] 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: ij CC: wl CC: ss CC: jg 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 | 17 +++++++++++++++++ tools/libxc/xc_domain.c | 23 ++++++++++++++++++++++ tools/libxl/libxl_arch.h | 7 +++++++ tools/libxl/libxl_arm.c | 19 +++++++++++++++++++ tools/libxl/libxl_dom.c | 6 +++++- tools/libxl/libxl_x86.c | 8 ++++++++ xen/arch/arm/domain.c | 2 ++ xen/arch/arm/domctl.c | 44 ++++++++++++++++++++++++++++++++++++++++--- xen/include/public/domctl.h | 12 ++++++++++++ 9 files changed, 134 insertions(+), 4 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 1629f41..77425dd 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -884,6 +884,23 @@ int xc_vcpu_getcontext(xc_interface *xch, uint32_t domid, uint32_t vcpu, vcpu_guest_context_any_t *ctxt); +/** + * This function initializes the vpl011 emulation and returns + * the event to be used by the backend for communicating with + * the emulation code. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the domain to get information from + * @parm console_domid the domid of the backend console + * @parm gfn the guest pfn to be used as the ring buffer + * @parm evtchn the event channel to be used for events + * @return 0 on success, negative error on failure + */ +int xc_dom_vpl011_init(xc_interface *xch, + uint32_t domid, + uint32_t console_domid, + xen_pfn_t gfn, + evtchn_port_t *evtchn); /** * This function returns information about the XSAVE state of a particular diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 00909ad4..a8efd5e 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -343,6 +343,29 @@ int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid, return 0; } +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; +} + 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..d1ca9c6 100644 --- a/tools/libxl/libxl_arch.h +++ b/tools/libxl/libxl_arch.h @@ -32,6 +32,13 @@ _hidden int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid); +/* arch specific internal domain creation finish function */ +_hidden +int libxl__arch_domain_create_finish(libxl__gc *gc, + libxl_domain_build_info *info, + uint32_t domid, + libxl__domain_build_state *state); + /* setup arch specific hardware description, i.e. DTB on ARM */ _hidden int libxl__arch_domain_init_hw_description(libxl__gc *gc, diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..b60dfa9 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -106,6 +106,25 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config, return 0; } +int libxl__arch_domain_create_finish(libxl__gc *gc, + libxl_domain_build_info *info, + uint32_t domid, + libxl__domain_build_state *state) +{ + int ret = 0; + + if ( info->arch_arm.vuart && + (ret = xc_dom_vpl011_init(CTX->xch, + domid, + state->console_domid, + xc_get_vuart_gfn(), + &state->vuart_port)) != 0 ) { + LOG(ERROR, "xc_dom_vpl011_init failed\n"); + } + + return ret; +} + int libxl__arch_extra_memory(libxl__gc *gc, const libxl_domain_build_info *info, uint64_t *out) diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 5d914a5..187c5bd 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -587,7 +587,10 @@ retry_transaction: goto retry_transaction; xs_introduce_domain(ctx->xsh, domid, state->store_mfn, state->store_port); free(vm_path); - return 0; + + rc = libxl__arch_domain_create_finish(gc, info, domid, state); + + return rc; } static int set_vnuma_info(libxl__gc *gc, uint32_t domid, @@ -788,6 +791,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_x86.c b/tools/libxl/libxl_x86.c index 455f6f0..3544028 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -358,6 +358,14 @@ out: return ret; } +int libxl__arch_domain_create_finish(libxl__gc *gc, + libxl_domain_build_info *info, + uint32_t domid, + libxl__domain_build_state *state) +{ + return 0; +} + int libxl__arch_extra_memory(libxl__gc *gc, const libxl_domain_build_info *info, uint64_t *out) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 76310ed..9e150ba 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -665,6 +665,8 @@ fail: void arch_domain_destroy(struct domain *d) { + 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 971caec..741679b 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -5,13 +5,15 @@ */ #include -#include +#include #include -#include +#include #include #include +#include +#include +#include #include -#include void arch_get_domain_info(const struct domain *d, struct xen_domctl_getdomaininfo *info) @@ -119,6 +121,42 @@ 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 e6cf211..c6ff458 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 0x0000000d @@ -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 Tue Jun 6 17:25:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103176 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536707qgd; Tue, 6 Jun 2017 10:27:53 -0700 (PDT) X-Received: by 10.36.58.196 with SMTP id m187mr18094879itm.89.1496770073297; Tue, 06 Jun 2017 10:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770073; cv=none; d=google.com; s=arc-20160816; b=SxWmuqbn27QOpNDs7btXBKhrp5PBpHSF45ecGIHWEt90Rl1gka2+RRwukoM2MMq0Cs M5d0gFQ8dB/hQpdybMQMNCs5KA8QgVDNyfm3yaJ+1JS8/3mYeLuD4tj/W/+NUlBL20Qi +zNZJmkk9nqDXzEcfw/Kbg6QnV6tPVlVrC9MOkMpVdn8e9oJs6Yd58OjQFMkNS3VUIeD fqJ4XPUhzI40Z3bnSh6Dy1/p3xIHTp0j3mLf3JP5jVQ1OdFUE/lFySVF1Ut0V6WYurbR RH0dYQJfhDfXXpeyEAwPYq9AHTg9DfNuohK9L50J6MnNkAjhrz3OQA5I0Nd7GyCXsiM6 oPyg== 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=0MZnY3or4jlSUGrHPDVyGoYKIQBH33b5DclwUNy4BKo=; b=Oy//wCRqJ8ZRsUJo4hB63KYHjsQFeij5Vm7A7dDQxnEu/M7ef3ekpdHVhFfbUDA5Ql IEDvllugHkGWzDzRljTkGUNqZ/DpSya2f9Ao/co1Flh7aJYWlfl6dGMo+kD5K5E7mn6d N/VWgI8eMqxgOkqUrzSOYutc/lsfx/kA/VErjpvgk6MDFNpIp6AlBwGNGy3Pj1y3Cn6/ dk/T3BZ/X7YITG1ddBWoEs37/B6s0H1monCKV0nwswmn2PE1Ov9Nw0LhEBVztYybv8XA lmaG6yjJQRFpHu8aZRA057bY6S+iKia4jRM7MIg64XqWHDXD+6Hdh7esezTsX7yf3RmN dFIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 m95si34862946ioi.35.2017.06.06.10.27.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:27:53 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIEy-0001h5-13; Tue, 06 Jun 2017 17:26:00 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIEw-0001ey-LO for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:25:58 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id 78/12-03557-6A5E6395; Tue, 06 Jun 2017 17:25:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsXiVRuspbv0qVm kwcXPEhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a1H92MBUstK+Y/OcnSwDhZu4uRi0NIYDqj xL81t9hBHBaBecwS82Z8YQJxJAT6WSXuTJ7I2MXICeSkSXS2PmWBsCslnnR+ZwKxhQS0JI6em s0KYTczSbzep9DFyMHBJmAiMatDAiQsIqAkcW/VZLCZzALzGSWaJvWygSSEBfwlus78ZQaxWQ RUJd7e/gBm8wp4S/yd2s0KsUtO4ua5TrA4p4CPxMzzSxghdnlL7GloY5zAKLCAkWEVo0ZxalF ZapGuoZleUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZgaDEAwQ7G+xsDDjFKcjAp ifJGXjKLFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBG/kEKCdYlJqeWpGWmQMMcpi0BAePkgjv5 AdAad7igsTc4sx0iNQpRl2OSQe2f2ESYsnLz0uVEudVAJkhAFKUUZoHNwIWcZcYZaWEeRmBjh LiKUgtys0sQZV/xSjOwagkzJsCMoUnM68EbtMroCOYgI7gu2QCckRJIkJKqoGxbIpIqOu1lEO 68vw1+b0CEfpXv/lp2HKbif9YyfdznUDzyY0Lap66v0raLKPT/+G04f0KgRRnMwatpKN73q1m epbxkollq8DjSdd2bDTSKz2ueEjsbGdguPbae67/8oyverwVXZqb7sRV2TP5z9fq5Q+X9h2Ir zZ4Z3k0fVXrla0/TVdcrhBXYinOSDTUYi4qTgQA7UKIkbMCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-12.tower-21.messagelabs.com!1496769955!72556474!1 X-Originating-IP: [74.125.83.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39872 invoked from network); 6 Jun 2017 17:25:57 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-12.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:25:57 -0000 Received: by mail-pg0-f42.google.com with SMTP id k71so4104598pgd.2 for ; Tue, 06 Jun 2017 10:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ypHL0H/QqjMzUVwPRiybi9ujUkTggl200zOr23Q8Rk8=; b=D3ER/tdoVsRGFokrTe+FZZcEGlxE22avaFZtRGeIGEzkeYRCvGkFmuxcnKiG5qg+Gh RVsl4LTbb3T2paE9qk7OBlYjtM3wVmiHthaX0shbMKdeRGPeNgvT9G2UuClFia/HQEZQ YmeaSFvz3DAEmyGkw3s7oLAv9+knFU6oh5x/I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ypHL0H/QqjMzUVwPRiybi9ujUkTggl200zOr23Q8Rk8=; b=h6P5veqNc4ixCikfRH52lgmVaP5bT4//RvvVoCq+e8p5z8t8KLwKu97iuLGOasPFEv 2bSBkIbzmopqVn9nlfPBceUjR09ZYi8xUcEe5pOzzUZv/mIb0cfNLZPrgQnOXf9NF1ss lcIc51faTZGxlLV9kytnvzkk6sTnnDKp4J4ikHxm/OdkoJAESWxi5C/4QL/mntGdS+uQ n0m3ul9dFUF4xocKDviiHKI57SVjRxiZdXjLF4tRMYAwDVllmAOVU5CQwL9as/xN8Akl 7mlXVlqQn9KCYgGcbz8nuYldeBcuuSJOAuAysu3Sr3SU+Uz9w7EoLRm9vW04rihE4WXV l79w== X-Gm-Message-State: AODbwcBBdNskz2x36ABzgLaVW64pxcZKUMs+UblR3djMaR/lrZ7nms23 SoZOclMMCNNjw5s+a29lEw== X-Received: by 10.84.140.133 with SMTP id 5mr23148056plt.224.1496769955403; Tue, 06 Jun 2017 10:25:55 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.25.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:25:54 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:22 +0530 Message-Id: <1496769929-23355-8-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 07/14 v4] 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 --- CC: ij CC: wl CC: ss CC: jg 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 | 12 ++++++++-- tools/libxl/libxl_device.c | 9 ++++++-- tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_types_internal.idl | 1 + 5 files changed, 66 insertions(+), 4 deletions(-) diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 853be15..259f865 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..091a661 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1367,14 +1367,22 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, } case LIBXL_DOMAIN_TYPE_PV: { - libxl__device_console console; - libxl__device device; + libxl__device_console console, vuart; + libxl__device device, vuart_device; for (i = 0; i < d_config->num_vfbs; i++) { libxl__device_vfb_add(gc, domid, &d_config->vfbs[i]); 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, &vuart_device); + 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 5e96676..b110041 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 4e2c247..7a22db0 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1202,6 +1202,10 @@ _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, + libxl__device *device); /* 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 Tue Jun 6 17:25:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103179 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536732qgd; Tue, 6 Jun 2017 10:27:58 -0700 (PDT) X-Received: by 10.107.173.18 with SMTP id w18mr3966756ioe.80.1496770078277; Tue, 06 Jun 2017 10:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770078; cv=none; d=google.com; s=arc-20160816; b=ZjYYrlwWAIPjJEQYrewZ5pbakZQ5Ejfr2y53ZNjnZDHLae00tFrqfU00MiyPZK/ZxF hvqfYouQqSgjIxcC95epCplQIV7EM5/XT05MFyuvluekMXsfKCD5IXQm3mBW/kcNRn04 EBB/aoB/DMSt9Nw+cu387xsRpjSZ66DNZ2zkmptIG74hZJmOinL8K5/0KZUvJUKFFKgU lqjiCL16I4+hX5FVEwD+RNz3ooq2ow9z6tqR3r6ZboBZ+cO+eNAspmKODOSj+2DigS5q 8O8ev2EtAc7ZMmDI5jWoCT/eGPklIrGs8EoFPgQyS7F1F0ozN1yQx8lzZpzVUK5QSay6 g3JA== 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=XCe8kKVIXS7TrFHWPjcGy+f9FuJw4T/YjIRmdrDG7XA=; b=upQUz3LLnK/crFwtxLI0/vyTOnjiBoaFYLauos2/T3B+T7ptfk1kAT/EA4TDYc8zgW yGCUkrt3MGVJGC2seXPPdUkgSWVBr7wETamra+WbAqxrQwC3BwQ2H2XazwwjSFhMQUan r6yWebV22pO9hHN+X4cIB/EjkKfzeB70eFtzIXlWacggjr/51vfoFWVKWoyTVK1eUStx Yr5bzQ00goZnY/PA+/lpOdpEUoP6o9dbkw8ImKMJKVXZaA7b2jPrVFxEgGm5PYeJM08i +jJMKPdCZVsv56grJJFfeEwdUyxzzjCsqGwoAT/gUJYmbzIEz+ScqcjHExfD7hbiXJNr ew6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 c15si15301846ioe.252.2017.06.06.10.27.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:27:58 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIF2-0001lF-Dy; Tue, 06 Jun 2017 17:26:04 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIF0-0001jH-7U for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:26:02 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 33/34-03058-9A5E6395; Tue, 06 Jun 2017 17:26:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRusp7viqVm kwYWZWhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aiuw8ZCx50MVYsmXmUqYGxoaCLkYtDSGA6 o8TRuU9ZQBwWgXnMEu8/XWIDcSQE+lklGhatZe9i5ARy0iSOtMxkgbDLJG5+uc0GYgsJaEkcP TWbFWJUM5PE9fU7gYo4ONgETCRmdUiA1IgIKEncWzWZCaSGWWA+o0TTpF6wZmGgoQsX7gOzWQ RUJZY8/MkE0ssr4C3x+LUGxC45iZvnOplBbE4BH4mZ55cwQuz1ltjT0MY4gVFgASPDKkb14tS istQiXUO9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYzA0GIAgh2MO587HWKU5GBS EuWNvGQWKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCN/IJUE6wKDU9tSItMwcY5DBpCQ4eJRHey Q+A0rzFBYm5xZnpEKlTjMYcG1av/8LEMenA9i9MQix5+XmpUuK8K0AmCYCUZpTmwQ2CRd8lRl kpYV5GoNOEeApSi3IzS1DlXzGKczAqCfOmgEzhycwrgdv3CugUJqBT+C6ZgJxSkoiQkmpgtGd 2nfqviz/5uHzQ1Lk3hcxcPrwNsOtIPensadTC5H7iosqTcsZi9kf/rj180iF7LOB9fdPTL7z1 8Qoik+bHiDCeStijepzZe8eK/Z9v8J1WX5o8UTnZXZL/J1/OV2epdl8N9l85OrIXroeanV/14 7/Rx1lLNq8M1ej8t16s2PfCPQF2bX8xJZbijERDLeai4kQAv9inbbkCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1496769959!106473661!1 X-Originating-IP: [74.125.83.46] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22706 invoked from network); 6 Jun 2017 17:26:00 -0000 Received: from mail-pg0-f46.google.com (HELO mail-pg0-f46.google.com) (74.125.83.46) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:26:00 -0000 Received: by mail-pg0-f46.google.com with SMTP id k71so4105015pgd.2 for ; Tue, 06 Jun 2017 10:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=R8yByu0ehlSAn3njcBu3jcyqGWLQk9BxErUGT3OmO/A=; b=iRW/YLTy4oujrv/3i7yRXDU21xmx7aKjabDRfAWl33lcrHg9NYKLDQ5W2T4aHCVyef 0MO87A8LpxUGYHwYZmZqUUb/NLqE6ZKM4pdbC3P5K1vOnyegY8xBY8aRbuZjnHZZq0/Y aGyclNd3aWbgyRP9POI/OB7DEF+miVwAYkBSA= 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=R8yByu0ehlSAn3njcBu3jcyqGWLQk9BxErUGT3OmO/A=; b=OE4NXdu+hqmlOlQIZlKe18dx6eeNfUxcyh3fjmsqaexI0Up1lQAFdDkFlxB5lxy88b TGdrqbRdaQbGh9kyEsYYdi8sgcRyE8wg6ljtk03E2dUAXlIzRetfNIbvdGRNCZuP85Lk Ewg26aGkCbMQDHhMh0tYNo83tUojWU+sWK5mntvxtjN+ABxMLZr2lvtXtina7rxnxWq/ cO9YvrwLqq33cz6S9Vz26OjT2tAXGE93uo8Gde1QcwbgO9Jz9XCmgoGzp2UfnrIfkowA LrM6R2/jPwUL/yxBa3/A0DG4wf6tf4+OBxL/j5QmEuXa2yQpVrud6d3+JypHSwn8bnE0 e7pw== X-Gm-Message-State: AODbwcD+lhUsJWEq23vrXD+SvugkB7Xml54AJSlJe2A25kVidgix5Dcq kH+RYtJDg9FlDEVdNUy6LA== X-Received: by 10.98.52.66 with SMTP id b63mr1108839pfa.7.1496769958540; Tue, 06 Jun 2017 10:25:58 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.25.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:25:58 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:23 +0530 Message-Id: <1496769929-23355-9-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 08/14 v4] 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 --- CC: ij CC: wl CC: ss CC: jg 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 | 226 ++++++++++++++++++++++++++-------------------- 1 file changed, 127 insertions(+), 99 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 947f13a..0402ddf 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; + struct xencons_interface *interface; + struct domain *d; +}; + +struct domain { + int domid; + bool is_dead; + unsigned last_seen; + struct domain *next; xenevtchn_handle *xce_handle; int xce_pollfd_idx; - struct xencons_interface *interface; int event_count; long long next_period; + 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(dom->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,41 +562,41 @@ 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; + con->local_port = -1; + con->remote_port = -1; if (dom->xce_handle != NULL) xenevtchn_close(dom->xce_handle); @@ -605,22 +617,22 @@ static int domain_create_ring(struct domain *dom) dom->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; + 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; + con->master_fd = -1; + con->master_pollfd_idx = -1; + con->slave_fd = -1; + con->log_fd = -1; dom->xce_pollfd_idx = -1; dom->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,18 +744,20 @@ 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); } @@ -782,7 +799,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 +830,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 +844,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 +860,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(dom->xce_handle, con->local_port); } else { domain_close_tty(dom); shutdown_domain(dom); @@ -851,18 +870,19 @@ 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); } } @@ -948,9 +968,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,6 +1081,8 @@ 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 @@ -1068,13 +1092,15 @@ void handle_io(void) 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); + (void)xenevtchn_unmask(d->xce_handle, con->local_port); } d->event_count = 0; } } for (d = dom_head; d; d = d->next) { + struct console *con = &d->console; + if (d->event_count >= RATE_LIMIT_ALLOWANCE) { /* Determine if we're going to be the next time slice to expire */ if (!next_timeout || @@ -1082,25 +1108,25 @@ void handle_io(void) next_timeout = d->next_period; } else if (d->xce_handle != NULL) { if (discard_overflowed_data || - !d->buffer.max_capacity || - d->buffer.size < d->buffer.max_capacity) { + !con->buffer.max_capacity || + con->buffer.size < con->buffer.max_capacity) { int evtchn_fd = xenevtchn_fd(d->xce_handle); d->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); } } @@ -1159,6 +1185,8 @@ 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 && @@ -1170,22 +1198,22 @@ void handle_io(void) 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; + d->xce_pollfd_idx = con->master_pollfd_idx = -1; if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Tue Jun 6 17:25:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103177 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536718qgd; Tue, 6 Jun 2017 10:27:55 -0700 (PDT) X-Received: by 10.107.128.228 with SMTP id k97mr11001726ioi.115.1496770075476; Tue, 06 Jun 2017 10:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770075; cv=none; d=google.com; s=arc-20160816; b=WS9bk5d906TVSw43TCNn6Fay3n2kU5QlOA5hfcEUfx8qeAw4Nk1Mb6bSStMINDvZqK q62hPNdJR+pjDrY6Xf+ha11OGLXG0021e/JZSlFqxcRpBO7bDZncNkzMTt0vZd2zo5fG 65WG+AG2Ky6xx2oiriF8gmKTz3M3bi9TNLXOIY8cus3L/+2Ig/huRQq7zILBXVc4CaeC 1BCOiv6/zyxSCxTvByn4ZilAcRAkiwV2AgDugeHQwlGw38ykeejsif1O0a2ocGwzB3OY 9bBXiWgcF8TwYnD51m+PIBTx28ch9CrPddk/NUwXa4j7gaQ6yBpwOyfI4CPgRuAAQc8k e5Sw== 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=ReLeOFPRHqMMg9vmCiuAc/V2E23YM6NAovKxki/xzJ4=; b=qxBd7eWBV3oONLKIVnKqlY/APgXdSe5F4neigSSXtSnqOp0REiHZjjMGUHTI7bhlsu mHxmiCT1mVLCnu2LInq+tkoUWD0g6Ee440Z5vqmqewokhTEL5TBmOy7koj6Mg/Dcf1jQ kVcHAg+otCNZdcuOo486WFO3f2dZmeh0OLRUsU/zsb2wRJBHZYDN1e+MvOtFfg/y3bA8 OWqUKlGO8eerJXbGDc933sEPUmTQuNUuhkiVB8UvSiVpBBGa6shq7nEO4aQYiPuE3nKF D+xqy79QlQrNI8Xb/btJr4TUtIqq4b1m+MVgfebzLeZ3oJaFx8GZsxtTvwFz9JLnRNAx YvUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 x41si672694ioi.247.2017.06.06.10.27.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:27:55 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIF3-0001ms-M7; Tue, 06 Jun 2017 17:26:05 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIF3-0001lZ-1i for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:26:05 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id F8/76-23755-CA5E6395; Tue, 06 Jun 2017 17:26:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIIsWRWlGSWpSXmKPExsXiVRusr7v6qVm kwYwZShbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bFV6+ZC257VXTs+cnSwHjEtouRi0NIYAaj RN+0R8wgDovAPGaJ6WeWsoE4EgL9rBK9zdeBMpxATprEgq/nWSHsSolT//4wgdhCAloSR0/NZ oUY1cwksWzZZvYuRg4ONgETiVkdEiA1IgJKEvdWTWYCqWEWmM8o0TSplw0kISyQKXHt0UIwm0 VAVeJ/yztGEJtXwEdi++8/UIvlJG6e6wSzOYHiM88vYYRY7C2xp6GNcQKjwAJGhlWMGsWpRWW pRbpGBnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIHBVc/AwLiDsfmE3yFGSQ4m JVHeyEtmkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeCOfAOUEi1LTUyvSMnOAYQ6TluDgURLhn fwAKM1bXJCYW5yZDpE6xajLMenA9i9MQix5+XmpUuK8K0BmCIAUZZTmwY2AxdwlRlkpYV5GBg YGIZ6C1KLczBJU+VeM4hyMSsK8KSBTeDLzSuA2vQI6ggnoCL5LJiBHlCQipKQaGNf1MudF+5u cq3O7wOD/zll351+tVL9NsWHX8xpkOLf4+pX4/y9643isOfrNgVnBBRzGNxMeXu93bqnrbn1l lL33+6zG4peLa+aGObN3vfHjYwjT4Fmz7Pt5tUDz8+eC/T18NAtfhr2a2Ld13+nJj3dff9Zv0 /H5oe8cnX7eZt4OCea3+1yYlViKMxINtZiLihMB2BmJqrQCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-2.tower-31.messagelabs.com!1496769962!92673493!1 X-Originating-IP: [74.125.83.47] 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 25716 invoked from network); 6 Jun 2017 17:26:03 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-2.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:26:03 -0000 Received: by mail-pg0-f47.google.com with SMTP id a70so29742029pge.3 for ; Tue, 06 Jun 2017 10:26: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=TYKtNjajYn6etUxLGRWztiZjDrswF0Yqivu0xmEmEHo=; b=hxAw1/04wwoKfUFv8go2vk2DggUtOf9wlPmq7uSwAark1jQ00Y87RaMqcIt9eypo9r hrOle4k3uLJMAsmsLIcaKz1V1aqa8XEfJgpBc0/HYeuD57lL8AI1nacFwrkxgAAZAE5A EjCK8qpmtcSZACJNt8GBoG9dvyM7rHS7nj7vM= 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=TYKtNjajYn6etUxLGRWztiZjDrswF0Yqivu0xmEmEHo=; b=ir1zIL5o+gUw1Jn+6mhm+G5GC6SmittDQ3eYkJSsfHx3iQIFnDFIsNU3Hw4cVlkPNg et786ZLnQGZLm4pX0vVyNRwmhG1WBVcmjMwRfWooz2rOHCVn2iM9b1vFUGv+RIFWTcAt 3a5U4iAHyAmBze/Fmzx2KlXL+QL7uRDEXoUBrD3ubnWirbWz4w/NE0ON6Y3gMUJYNnpT DOPuQ3muakyRL2BjaWrV4C2hJghp0ftVcpnhKx7D4HSVoIM0gR89gpZA1b6Xw+Ts7p/X dHy0eyV1jH/sxgIRTo4OJozC3PhNyQQOxKrFGJJ+ONwCE71e9JFzzs981U53JMB6pOu5 bJIA== X-Gm-Message-State: AODbwcCMYqgn1lbYH6ZAdN78+dQT0mI/HIN0l/jjTrMiTFOiWcqNfoVE bSwGm8VghYq7WxPGgLATbA== X-Received: by 10.84.131.163 with SMTP id d32mr2193435pld.16.1496769961583; Tue, 06 Jun 2017 10:26:01 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.25.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:26:01 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:24 +0530 Message-Id: <1496769929-23355-10-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 09/14 v4] 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 --- CC: ij CC: wl CC: ss CC: jg Changes since v3: - The changes in xenconsole have been split into four patches. This is the second patch. tools/console/daemon/io.c | 82 +++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 0402ddf..c5dd08d 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->conspath, "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(dom->xce_handle); dom->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->conspath, domid_str); if (success) - domain_create_ring(dom); + console_create_ring(con); else xs_unwatch(xs, con->conspath, domid_str); } else { @@ -694,6 +691,7 @@ static struct domain *create_domain(int domid) con->master_pollfd_idx = -1; con->slave_fd = -1; con->log_fd = -1; + con->d = dom; dom->xce_pollfd_idx = -1; dom->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); @@ -764,9 +762,11 @@ static void cleanup_domain(struct 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); + console_unmap_interface(con); if (d->xce_handle != NULL) xenevtchn_close(d->xce_handle); d->xce_handle = NULL; @@ -797,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; @@ -814,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; @@ -851,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++) { @@ -862,15 +861,15 @@ static void handle_tty_read(struct domain *dom) intf->in_prod = prod; xenevtchn_notify(dom->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; @@ -880,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); } @@ -889,6 +888,7 @@ static void handle_tty_write(struct domain *dom) static void handle_ring_read(struct domain *dom) { xenevtchn_port_or_error_t port; + struct console *con = &dom->console; if (dom->is_dead) return; @@ -898,7 +898,7 @@ static void handle_ring_read(struct domain *dom) dom->event_count++; - buffer_append(dom); + buffer_append(con); if (dom->event_count < RATE_LIMIT_ALLOWANCE) (void)xenevtchn_unmask(dom->xce_handle, port); @@ -922,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); @@ -972,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); } } @@ -1118,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)) @@ -1201,15 +1201,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 Tue Jun 6 17:25:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103180 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536752qgd; Tue, 6 Jun 2017 10:28:01 -0700 (PDT) X-Received: by 10.36.110.209 with SMTP id w200mr19996214itc.37.1496770081338; Tue, 06 Jun 2017 10:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770081; cv=none; d=google.com; s=arc-20160816; b=XNgwVlClzudQoFRjw4sFRnDN/Lazr3YcXLKjO9lFFMotofAHl4ZhmW9632q+YOJ+KG 5e7wcSnI8fp2ptuI4H48GckF02jQppVLm1H1VoUo6FIPexeV6Z48U917VCrsMPdusgWv VspZ9YUHtBJvv8/ceq8+db90qS/KpDz3wthfLjh4GI4OQtVKFHub6fPSvvpLKNLxaFuq 00DrYcyU1viIcePnTCl+skD0/FuZCfhnKZDW0B1NU4xDCOXUuJCwR2DUw5K8aVDbRULk FJGf2rQxCuTrpubmJgkJo7huoPKR9eivNPP2yi9sIkoheOA32n9vvsplAS35HokDY16r JGPg== 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=zy6FEiLCoyvOeGohz3J4hSm7r2jRDkqJo3JFGYxw0Ks=; b=POOQT+jo1y1BKbxsTlJ9p6Y7+1359ElLhvMWbFQ8GxiET8RkZi2zeupCRq6ZV/V3Ac S4yvXkyFBru2iRCfGKjInMQL8Oj/Bg2jgkO54+muyD4cLgyfBMkpSN1sj8QJ9q0Qs6S5 E2kqBQ3fYxTcGFK5RJDHNS/D39EqClRI4cPtRdu1207BE0hboWpydFe/ly8U6+NHA+a9 X1yLKNS3uGDCheROidAAlgOk1EuHasldZNqczKXoYX9ynbecnb/horMFeBbMaTrGCuQN drJJE7b+/cIaGkN34MeB8rK3/f4nAe1EMiabaRUyqtOqRJqqyQObswbE+UJrc7ANxc/J dtyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 k34si13961945ioo.139.2017.06.06.10.28.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:28:01 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIF8-0001s6-2v; Tue, 06 Jun 2017 17:26:10 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIF6-0001pz-Do for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:26:08 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id E7/4C-11537-FA5E6395; Tue, 06 Jun 2017 17:26:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsVyMfTARt11T80 iDU7f0LH4vmUykwOjx+EPV1gCGKNYM/OS8isSWDPW/zvIXrCnruLY7pIGxob0LkYuDiGBmYwS n9ouMoI4LALzmCWerp3F1MXIySEh0M8qcfJdMYSdJvFuwjeoeJXEme/PWEFsIQEtiaOnZrNCT Gpmkvh49D9LFyMHB5uAicSsDgmQGhEBJYl7qyYzgdQwC8xnlGia1MsGkhAWiJTYfWoNI4jNIq AqsefgYhYQm1fAR2LlkQ+MEMvkJG6e62QGsTmB4jPPL2GEWOwtsaehjXECo8ACRoZVjBrFqUV lqUW6RkZ6SUWZ6RkluYmZObqGBsZ6uanFxYnpqTmJScV6yfm5mxiBgVXPwMC4g3HqCb9DjJIc TEqivJGXzCKF+JLyUyozEosz4otKc1KLDzHKcHAoSfBGPgHKCRalpqdWpGXmAEMcJi3BwaMkw jv5AVCat7ggMbc4Mx0idYrRkuPKlXVfmDg2rF4PJKcc2P6FSYglLz8vVUqcdwXIPAGQhozSPL hxsDi8xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDUUmYNwVkCk9mXgnc1ldABzEBHcR3yQTkoJJ EhJRUA2OyysfwGH/5Qy/O/pdfOvGgsWRTZ4tH2RXxgIYLB2fwZDEzyF3+vOlFkCJzwJdfO3dG r73lzm/1cpGEVqRpqc5zlqfavzW+8FZobPBt7XqwplHz7e5Gu4WWP3jmbbv5Mj9rddZ1x/a1z aFHS5pvFs1S6XS84iiyWfzEl5RlfPZ1t2MOcSxfcFOJpTgj0VCLuag4EQCzp41hvgIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-31.messagelabs.com!1496769965!48878423!1 X-Originating-IP: [209.85.192.177] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58901 invoked from network); 6 Jun 2017 17:26:06 -0000 Received: from mail-pf0-f177.google.com (HELO mail-pf0-f177.google.com) (209.85.192.177) by server-9.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:26:06 -0000 Received: by mail-pf0-f177.google.com with SMTP id l89so25888741pfi.2 for ; Tue, 06 Jun 2017 10:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1Clq+nfBW9vGoCTF5/uqMzPVQNvD51giXJ+nmutteg4=; b=PIMZocGMb7ky5a4gqpxk5jPEdUWx0Oa3+prDbOsHCdANEQQCBXpUPL9Ge6QCyMx8ZA ugPRzN8y7JSSXPeDwB4OM9896zKhd3FcjeIOmj69dGE89BZHbaWPzQPpH9RSKH1VT/Kn 9sahxQPX62BIydaZEEzg6TkNLsLSKskXM4dl4= 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=1Clq+nfBW9vGoCTF5/uqMzPVQNvD51giXJ+nmutteg4=; b=a2fheKbpgx6HyHwE7uc8NQaNCsN4Lvxbt5ZvAA3tbEGeaPm3zM50i/e6wXI9Qh/F3F NRklauj+bB5GGuZzjSWUqBXBc/WMWl8GYjeNT28YuimaHCq1pC2hrkhhrubZdsXWMtCf exwrmg4zyTDLxE7ZeJDPkR3RKwYLTwX2dkCF++YSMkUjdChHglq5gmYc9MYqZC1I1Mh5 khDjiP9aVNVxFkUlt61AAdGVflyH3qK7WjhjadJU/09J/YW/x3/VDiAXjWtsUOlwzZwo 17GEXsT7SJNJR4eZalxrHOaqQpoOcNtmvelV9Os9n5IyUKwhVExRAIFz5oEZS90MbvT4 oGHQ== X-Gm-Message-State: AODbwcANq3IqCjj8bT5O8G7UskLJ0ETlqnJ93BjGmYk5LGZKcUSo+39T Zl+wB1t+QczLZkgSkUDxKQ== X-Received: by 10.98.202.206 with SMTP id y75mr27157184pfk.34.1496769964626; Tue, 06 Jun 2017 10:26:04 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.26.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:26:04 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:25 +0530 Message-Id: <1496769929-23355-11-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 10/14 v4] 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: ij CC: wl CC: ss CC: jg Changes since v3: - The changes in xenconsole have been split into four patches. This is the third patch. tools/console/daemon/io.c | 364 +++++++++++++++++++++++++++++++++------------- 1 file changed, 263 insertions(+), 101 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index c5dd08d..db73e10 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -90,12 +90,15 @@ struct buffer { }; struct console { + char *xsname; + char *ttyname; int master_fd; int master_pollfd_idx; int slave_fd; int log_fd; struct buffer buffer; - char *conspath; + char *xspath; + char *log_suffix; int ring_ref; xenevtchn_port_or_error_t local_port; xenevtchn_port_or_error_t remote_port; @@ -103,6 +106,23 @@ 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; @@ -112,11 +132,90 @@ struct domain { int xce_pollfd_idx; int event_count; long long next_period; - 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 *, unsigned int); +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, + unsigned int 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 +262,27 @@ 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, unsigned int data) { struct buffer *buffer = &con->buffer; + struct xencons_interface *intf = con->interface; + xenevtchn_port_or_error_t rxport = (xenevtchn_port_or_error_t)data; struct domain *dom = con->d; XENCONS_RING_IDX cons, prod, size; - struct xencons_interface *intf = con->interface; + + /* If incoming data is not for the current console then ignore. */ + if (con->local_port != rxport) + return; cons = intf->out_cons; prod = intf->out_prod; @@ -321,7 +435,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'; @@ -427,6 +541,9 @@ static int console_create_tty(struct console *con) struct termios term; struct domain *dom = con->d; + if (!console_enabled(con)) + return 1; + assert(con->slave_fd == -1); assert(con->master_fd == -1); @@ -462,7 +579,7 @@ static int console_create_tty(struct console *con) goto out; } - success = asprintf(&path, "%s/limit", con->conspath) != + success = asprintf(&path, "%s/limit", con->xspath) != -1; if (!success) goto out; @@ -473,7 +590,7 @@ static int console_create_tty(struct console *con) } free(path); - success = (asprintf(&path, "%s/tty", con->conspath) != -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)); @@ -543,14 +660,14 @@ static int console_create_ring(struct console *con) char *type, path[PATH_MAX]; struct domain *dom = con->d; - 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); @@ -594,15 +711,16 @@ static int console_create_ring(struct console *con) con->local_port = -1; con->remote_port = -1; - if (dom->xce_handle != NULL) - xenevtchn_close(dom->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) { - err = errno; - goto out; + if (dom->xce_handle == NULL) + { + /* 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) { + err = errno; + goto out; + } } rc = xenevtchn_bind_interdomain(dom->xce_handle, @@ -639,29 +757,65 @@ 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->conspath, domid_str); + 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->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; } +static int console_init(struct console *con, struct domain *dom, void **data) +{ + char *s; + int err = -1; + struct console_data **con_data = (struct console_data **)data; + + 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->d = dom; + con->ttyname = (*con_data)->ttyname; + con->log_suffix = (*con_data)->log_suffix; + con->xsname = (*con_data)->xsname; + con->xspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->xspath, strlen(con->xspath) + + strlen(con->xsname) + 1); + if (s) + { + con->xspath = s; + strcat(con->xspath, con->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; - char *s; struct timespec ts; - struct console *con; + struct console_data *con_data = &console_data[0]; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d", @@ -678,28 +832,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) + - strlen("/console") + 1); - if (s == NULL) + if (console_iter_int_arg3(dom, console_init, (void **)&con_data)) goto out; - con->conspath = s; - strcat(con->conspath, "/console"); - con->master_fd = -1; - con->master_pollfd_idx = -1; - con->slave_fd = -1; - con->log_fd = -1; - con->d = dom; dom->xce_pollfd_idx = -1; dom->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 +849,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->conspath); + console_iter_void_arg1(dom, console_free); free(dom); return NULL; } @@ -740,33 +879,40 @@ 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; + } - free(con->conspath); - con->conspath = 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); + + console_iter_void_arg1(d, console_cleanup); remove_domain(d); } static void shutdown_domain(struct domain *d) { - struct console *con = &d->console; - d->is_dead = true; watch_domain(d, false); - console_unmap_interface(con); + console_iter_void_arg1(d, console_unmap_interface); if (d->xce_handle != NULL) xenevtchn_close(d->xce_handle); d->xce_handle = NULL; @@ -885,10 +1031,15 @@ static void handle_tty_write(struct console *con) } } +static void console_event_unmask(struct console *con) +{ + if (con->local_port != -1) + (void)xenevtchn_unmask(con->d->xce_handle, con->local_port); +} + static void handle_ring_read(struct domain *dom) { xenevtchn_port_or_error_t port; - struct console *con = &dom->console; if (dom->is_dead) return; @@ -898,10 +1049,10 @@ static void handle_ring_read(struct domain *dom) dom->event_count++; - buffer_append(con); + console_iter_void_arg2(dom, buffer_append, port); if (dom->event_count < RATE_LIMIT_ALLOWANCE) - (void)xenevtchn_unmask(dom->xce_handle, port); + console_iter_void_arg1(dom, console_event_unmask); } static void handle_xs(void) @@ -922,7 +1073,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 +1114,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 +1181,40 @@ static void reset_fds(void) memset(fds, 0, sizeof(struct pollfd) * current_array_size); } +static void add_console_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 process_console(struct console *con) +{ + if (con->master_fd != -1 && con->master_pollfd_idx != -1) { + if (fds[con->master_pollfd_idx].revents & + ~(POLLIN|POLLOUT|POLLPRI)) + console_handle_broken_tty(con, domain_is_valid(con->d->domid)); + else { + if (fds[con->master_pollfd_idx].revents & + POLLIN) + handle_tty_read(con); + if (fds[con->master_pollfd_idx].revents & + POLLOUT) + handle_tty_write(con); + } + } + con->master_pollfd_idx = -1; +} + void handle_io(void) { int ret; @@ -1081,7 +1272,6 @@ 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 @@ -1092,14 +1282,13 @@ void handle_io(void) 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, con->local_port); + console_iter_void_arg1(d, console_event_unmask); } d->event_count = 0; } } for (d = dom_head; d; d = d->next) { - struct console *con = &d->console; if (d->event_count >= RATE_LIMIT_ALLOWANCE) { /* Determine if we're going to be the next time slice to expire */ @@ -1107,28 +1296,15 @@ void handle_io(void) d->next_period < next_timeout) next_timeout = d->next_period; } else if (d->xce_handle != NULL) { - if (discard_overflowed_data || - !con->buffer.max_capacity || - con->buffer.size < con->buffer.max_capacity) { - int evtchn_fd = xenevtchn_fd(d->xce_handle); - d->xce_pollfd_idx = set_fds(evtchn_fd, - POLLIN|POLLPRI); + if (console_iter_bool_arg1(d, buffer_available)) + { + int evtchn_fd = xenevtchn_fd(d->xce_handle); + d->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_arg1(d, add_console_fd); } /* If any domain has been rate limited, we need to work @@ -1185,7 +1361,6 @@ 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) { @@ -1198,22 +1373,9 @@ void handle_io(void) 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); - } - } + console_iter_void_arg1(d, process_console); - d->xce_pollfd_idx = con->master_pollfd_idx = -1; + d->xce_pollfd_idx = -1; if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Tue Jun 6 17:25:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103175 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536708qgd; Tue, 6 Jun 2017 10:27:53 -0700 (PDT) X-Received: by 10.36.121.141 with SMTP id z135mr18380461itc.36.1496770073274; Tue, 06 Jun 2017 10:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770073; cv=none; d=google.com; s=arc-20160816; b=r8Dma62RJF62LxbODBRyXQNvD5HG5z3dUhcFO6pY0VoNwsjtsKlh8nzIqVvnnRWk1a fzMtrH1hJs6+5/9Lgrkf52JNSVdEkt7Y7nhnjztIogO10D+n1MUfGsSf+XQ/8uFjbcDH WeO7m73oFpFHkl+oQNSfY5EGi+5rMw3xqIsIEPguD8WCcfYThCxuBKX17qiGpR265/pQ mRtYkJFUxYpDoknP+iu+hHL7K53/W+wx+hQWfpuSRCLEp9xlPL8zyGqn0kUdTMlgww+Y i9VkIERiuVeVrzJdcZ+rCYMtZhdtfRqmIhFZaM8eFgu++ABBCO31ZswjLXkVSb2IdUet F8jw== 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=YmPBa2ZcUJ4rFPGzU4aqcsOjFSZ5whzN5XTHWRv4uIw=; b=YpQDAFVB+W2uo73yv4k0BPpIInmdM7fxHOnQrJthbabaqrwoJCuqZ5ocOaCI+bo5Wy iN78m9ewaj6c3fCULYxpCrh/8B3g4Mkw+mckcPfQqaoLB+x1rerTV+20YXAq+QAiOYmk e5vx0bNlzyCH/cqM/qdXfCK6O7IaBKMq72rK6GAud0YlaUBE47be1BW3LiBHDAdZhRc/ Kd6nBj+mdCwWnE7oS8lv9WXI2aGeT1lFvKvQ3WuC1STPquZtR08o259TSciT1YtPLYKi au39Q9/Ar4116FqoklM+bu7/Rm3QC2+Q7NyCdD5aPBEDeEmrPDIEI9Qa35nT3aLizp9k X7YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 e195si3762106itb.90.2017.06.06.10.27.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:27:53 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIFA-0001uX-AI; Tue, 06 Jun 2017 17:26:12 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIF8-0001sb-Mn for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:26:10 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id 9F/D8-03587-2B5E6395; Tue, 06 Jun 2017 17:26:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEIsWRWlGSWpSXmKPExsXiVRtsqrvxqVm kwZZdchbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b0ExOZCo5JVSxfyd/AuFesi5GLQ0hgOqPE 2QldjCAOi8A8ZonTfx6wgzgSAv2sEsfWvmXpYuQEctIkHh6fygZhV0h8PXGREcQWEtCSOHpqN iuE3cwk8fypaxcjBwebgInErA4JkLCIgJLEvVWTmUBmMgvMZ5RomtTLBlIjLBAm8a0vHsRkEV CV2LncGcTkFfCRmHs7DGKRnMTNc53MIDYnUHjm+SVQS70l9jS0MU5gFFjAyLCKUaM4tagstUj XyFAvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMwpBiAYAfjn2UBhxglOZiURHkj L5lFCvEl5adUZiQWZ8QXleakFh9ilOHgUJLgvf8EKCdYlJqeWpGWmQMMbpi0BAePkgjv5AdAa d7igsTc4sx0iNQpRmOODavXf2HimHRg+xcmIZa8/LxUKXHeFSCTBEBKM0rz4AbBou4So6yUMC 8j0GlCPAWpRbmZJajyrxjFORiVhHlTQKbwZOaVwO17BXQKE9ApfJdMQE4pSURISTUwbpS3fDF 38nXLnDN7aqo2vH8twRNtxVu3v1XBaEFF6+eFCbs/rz+Qa/Tt3faSk4WVR/7+5J387NP960dn +8xtZJgq//zJ1IMvnPnajBP+5vmwKKoYXTWr0N80a96GJ8FiLtOm9Nm+5s28bOQguPHqUy752 gtLS7/fszmtPlnE5PmnFRwJxS0aMkosxRmJhlrMRcWJAI+Xibm1AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-21.messagelabs.com!1496769968!72445596!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 47249 invoked from network); 6 Jun 2017 17:26:09 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-9.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:26:09 -0000 Received: by mail-pg0-f53.google.com with SMTP id k71so4106145pgd.2 for ; Tue, 06 Jun 2017 10:26: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=PeGx06wWbJVg+qDsrvMGeGctPINrr8ZqmEIOjVyUamo=; b=Cwh78oM74SzmX4ulNN8RcGJuyA46Grx3TihyWd/LLbAfhIYGEX2C805Whi8V8RZLs7 0ZhLQ/BbEO4FneWM1PN3S046FrRttaDbfBDPCZw7QnxEjc94qLuz6yhBlLlBeUnSfHHh 2AxwHC6GvyqnENSwopLkgO654V/rbjZw6Qt+U= 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=PeGx06wWbJVg+qDsrvMGeGctPINrr8ZqmEIOjVyUamo=; b=esBbr42INt7pnJL1X3qFjva3exkhQcdQ2oCgisD8aWjm66svQWlLiFhTmx4grfoGL2 L9PVcycuZ7x2WPKiSoYmcsrnhsR+VuO+3tH5dN1Ykwk+4izeIo68U6hrmR/GZ8HexnVz UTu8wMTXy2r7B+s9mQdC3/f6vvmJdaWvvyW/Xj0jRjxyjgQ6cbobGqTr8L7nytJh5CtQ 06CL3vA6CO2NHiScBFgzVnmoOFk0poxT9WZzHHdWU0C6OA97cDgTgX8M3JWwFKHjYmt9 Y2muXOMxG6VUc7QSRD1AKzVNlqipjPm0iWmM1L3WytpRp0DnY0hghPlG+L2pquMbHR1z 2PZw== X-Gm-Message-State: AODbwcDpTM9YivhrUppkJBLoKBWaEDTAEx0RiUzNXnVb365y8iFd80ez XCPMgC6gK+4aZK5j5KqW2Q== X-Received: by 10.84.151.99 with SMTP id i90mr3402618pli.81.1496769967759; Tue, 06 Jun 2017 10:26:07 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.26.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:26:07 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:26 +0530 Message-Id: <1496769929-23355-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/14 v4] 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: ij CC: wl CC: ss CC: jg Changes since v3: - The changes in xenconsole have been split into four patches. This is the fourth patch. - The vuart console support is added under CONFIG_VUART_CONSOLE option. tools/console/Makefile | 3 ++- tools/console/daemon/io.c | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tools/console/Makefile b/tools/console/Makefile index c8b0300..fcee313 100644 --- a/tools/console/Makefile +++ b/tools/console/Makefile @@ -11,6 +11,7 @@ LDLIBS += $(SOCKET_LIBS) LDLIBS_xenconsoled += $(UTIL_LIBS) LDLIBS_xenconsoled += -lrt +VUART_CFLAGS-$(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) $(VUART_CFLAGS-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 db73e10..cae2efe 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -104,12 +104,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[] = { @@ -118,7 +122,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)) @@ -665,7 +680,12 @@ static int console_create_ring(struct console *con) "port", "%i", &remote_port, NULL); if (err) + { + /* If the console is optional then do not return an error. */ + if (con->optional) + err = 0; goto out; + } snprintf(path, sizeof(path), "%s/type", con->xspath); type = xs_read(xs, XBT_NULL, path, NULL); @@ -679,7 +699,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, @@ -789,6 +811,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; con->xsname = (*con_data)->xsname; con->xspath = xs_get_domain_path(xs, dom->domid); s = realloc(con->xspath, strlen(con->xspath) + From patchwork Tue Jun 6 17:25:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103182 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536791qgd; Tue, 6 Jun 2017 10:28:06 -0700 (PDT) X-Received: by 10.36.209.70 with SMTP id w67mr19149013itg.68.1496770086359; Tue, 06 Jun 2017 10:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770086; cv=none; d=google.com; s=arc-20160816; b=MUAYe5AIIP0mCY7SFzKX6qR4dtiFbdqE7gaz9sfWhVFVjvyfRMbTiaxReg//IrSzj/ SKrekLWoB+yW74umQT1kMa8eHzVE91wc5/jWz2vs14rkXTTmOjyvKvfLoMbzOzFrSWTo 1+0+Rf5/2noI9lgIX9JS9RFBtGp32paPZTQOPjr5jzPayj4GeHRtW4casY9M5vCudMEP eSDnFqgpo2aFXvuxkDzEIZPzWUfnIWztj3iekwId7XPYPJZN3Xum6cqaaU3w5MBPxcDT ABo4X3V0ULvSGr5c/SSt5p3uwle+T1N00g+vu4hhapJRER4xdTcYGLbeDavzS+gl6XBZ PpdA== 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=BIYtki685oTQ9nXom6sG6cmGfk4bgna+9r6Cqq6MnSE=; b=zm14fZziMoF1BK1cbwoP4ysKTortuyQSYq9c4mGUPi/2EovH3aUGL6ZUCi5Aqp68IO 9leib+9nT2Ue92OijGQ8MofmLrPmtzfuRJdNEAJ054GZltyphySO5Id2OUsL2rDGUrJ4 XJCuz3rDMdmmSy4fyXmuePi60jtnrrgYSZXxlzuYMUYdOjHRWDhpbC3nEVU4ezb7PSoW j5lmUKxCg3uGjYXWsFRCvRJ2fjKTFsZkd75bIki9K+oERQVNE7ZGnLYXTOPqF8nPuvMz D9tESrWK0kKiISSf2fyHc5qohOnIZr4qVI+LTGiMLJzltRjwD8E4aw8ZHsbP3gUNu5sU xYdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 g16si4555902iod.30.2017.06.06.10.28.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:28:06 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIFD-0001yB-HJ; Tue, 06 Jun 2017 17:26:15 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIFB-0001wE-RX for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:26:13 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 2F/84-03058-5B5E6395; Tue, 06 Jun 2017 17:26:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRusqbvlqVm kwd85Khbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bWhoXsBfckKyb8OM3WwHhXpIuRi0NIYDqj xKwVi9lAHBaBecwS90+8ZQVxJAT6WSV+Hexm6mLkBHLSJL40vGaGsCslJm48wAZiCwloSRw9N ZsVYlQzk8TGz/1ADgcHm4CJxKwOCZAaEQEliXurJjOB1DALzGeUaJrUC9YsLBAj0di7E2wBi4 CqxLrfz1lAenkFfCQuv9eH2CUncfNcJ9heTqDwzPNLGCH2ekvsaWhjnMAosICRYRWjRnFqUVl qka6hsV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmBoMQDBDsYvywIOMUpyMCmJ 8kZeMosU4kvKT6nMSCzOiC8qzUktPsQow8GhJMEb+QQoJ1iUmp5akZaZAwxymLQEB4+SCO/kB 0Bp3uKCxNzizHSI1ClGY44Nq9d/YeKYdGD7FyYhlrz8vFQpcd4VIJMEQEozSvPgBsGi7xKjrJ QwLyPQaUI8BalFuZklqPKvGMU5GJWEeVNApvBk5pXA7XsFdAoT0Cl8l0xATilJREhJNTCyaYe vSbh451xu8vEZG6S38iWLOB0338o14eu1fRxaxzYJaqubxr/YGdh04izXOofjfafnF5gLnZne NOXYoc2m1WqeoVrG67Pkdj7zjHTzmVL1wEhRrfDQNvbXy7aLsTP4VdZf3/reLuR0necF229/u pjqljt+Zr0UYWBQNrdIr/5v5degK4JKLMUZiYZazEXFiQDN/7RzuQIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-4.tower-27.messagelabs.com!1496769971!105565060!1 X-Originating-IP: [74.125.83.41] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45694 invoked from network); 6 Jun 2017 17:26:12 -0000 Received: from mail-pg0-f41.google.com (HELO mail-pg0-f41.google.com) (74.125.83.41) by server-4.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:26:12 -0000 Received: by mail-pg0-f41.google.com with SMTP id k71so4106554pgd.2 for ; Tue, 06 Jun 2017 10:26: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=B/JKyaOTk1zL9Z1BOSMDLeQPFHejwUPS/Kszi0QR7RA=; b=ICwk9O9l6k+ePJQI21Xz5RM/2yWEXEjmrpfq3jZsEN1MxV+VjdLjXDDM5KxvAmxVdO sNci5E7jze76uu6CICtra0RhxkQxzxR7ZGVS6xmRp1Uk2javhg5WNVFfEZAO0k93gcZf 31C3RcirZdEXW7J6UlhB87gx86meFGtGCjixY= 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=B/JKyaOTk1zL9Z1BOSMDLeQPFHejwUPS/Kszi0QR7RA=; b=f1bv0Y3RlD/mVBdEQoLkh6NkZJ0Xz3O2kXWAYqj7tURIVRs0FIT3vNBrYbY90peSrX 8i+9MUuHz8zeMmzaOSCFgqfMCfDi2LKJl1XliYzdL768Wt3MdqLFRqRVfH3l1ZyfABZg G/ZyvnJcIESsO4+fU5EOjGbOcNK8tyWDa/hVkLmU9h8drqDoNpE3Fkv4U2Za4jnwVvJE /db90QYfKqDeFLjBwG9WAJ7zXRWWxatud72fkt2KBom/gDUyWrsdrRxN12oo/ou99Wfy M3I1gKmZKZqr/q5DZsSk5D5g+Holb4V/44f5lc6EarOfk1tVg5EVcNUHkDT55+tbAR7b eYgA== X-Gm-Message-State: AODbwcAPBsASCQa2ikSSTPf5Dfualq+AsuHZJPIqpdPZmVmrc8j6LMrU oVilHN7rzEdHXpMu0zggmQ== X-Received: by 10.84.130.67 with SMTP id 61mr22595103plc.150.1496769970860; Tue, 06 Jun 2017 10:26:10 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.26.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:26:10 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:27 +0530 Message-Id: <1496769929-23355-13-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 12/14 v4] 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 --- CC: ij CC: wl CC: ss CC: jg 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/Makefile | 1 + tools/console/client/main.c | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tools/console/Makefile b/tools/console/Makefile index fcee313..49c02d4 100644 --- a/tools/console/Makefile +++ b/tools/console/Makefile @@ -34,6 +34,7 @@ xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c)) $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_xenconsoled) $(APPEND_LDFLAGS) client/main.o: client/_paths.h +client/main.o: CFLAGS += $(VUART_CFLAGS-y) xenconsole: $(patsubst %.c,%.o,$(wildcard client/*.c)) $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_xenconsole) $(APPEND_LDFLAGS) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index 977779f..8d31fe9 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -76,7 +76,11 @@ static void usage(const char *program) { "\n" " -h, --help display this help and exit\n" " -n, --num N use console number N\n" +#ifdef CONFIG_VUART_CONSOLE + " --type TYPE console type. must be 'pv', 'serial' or 'vuart'\n" +#else " --type TYPE console type. must be 'pv' or 'serial'\n" +#endif " --start-notify-fd N file descriptor used to notify parent\n" , program); } @@ -264,6 +268,9 @@ typedef enum { CONSOLE_INVAL, CONSOLE_PV, CONSOLE_SERIAL, +#ifdef CONFIG_VUART_CONSOLE + CONSOLE_VUART, +#endif } console_type; static struct termios stdin_old_attr; @@ -343,6 +350,11 @@ int main(int argc, char **argv) char *end; console_type type = CONSOLE_INVAL; bool interactive = 0; +#ifdef CONFIG_VUART_CONSOLE + char *console_names = "serial, pv, vuart"; +#else + char *console_names = "serial, pv"; +#endif if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) interactive = 1; @@ -361,9 +373,14 @@ int main(int argc, char **argv) type = CONSOLE_SERIAL; else if (!strcmp(optarg, "pv")) type = CONSOLE_PV; +#ifdef CONFIG_VUART_CONSOLE + else if (!strcmp(optarg, "vuart")) + type = CONSOLE_VUART; +#endif 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 +453,12 @@ 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); } +#ifdef CONFIG_VUART_CONSOLE + if (type == CONSOLE_VUART) { + snprintf(path, strlen(dom_path) + strlen("/vuart/0/tty") + 1, + "%s/vuart/0/tty", dom_path); + } +#endif /* 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 Tue Jun 6 17:25:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103181 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536778qgd; Tue, 6 Jun 2017 10:28:05 -0700 (PDT) X-Received: by 10.36.13.20 with SMTP id 20mr19627588itx.37.1496770084967; Tue, 06 Jun 2017 10:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770084; cv=none; d=google.com; s=arc-20160816; b=xGXPLm3EFcSbXkHjUkAchY6/GZfxskzhM9Y3O7vcIYYN2NR6E4ta/kgvtOsJh0bg3l jmqLxMQOcvlo3KUGW9B2Ot7f9cEEEhSoQzfpdSjuZIt8s8ktQfGRkzu3NlMyzHCtMocs BNXcnPuMXuO0FRGIiWWNPBX63gnZkgyhgpJDVAvBayYjtfiA2R0cdUzbRDM2XIHDVq8E upleEcytchxzjmFIpzxJ0mNY7mexdHA81UPkBHHXmtfiY1cAdhobvg9LyGovh1ChLGgZ k/9LQ6FrMqE3TMOo4j6y9wpuZ12nrSfwSAMdxTQVFaURO3hRQ+CSfdBZQ+Ghv2/TpiYx mdwA== 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=T1QWsLpB8+EjMfe3lPzzUj64MJ/y9YHIfo7xkP0wQp4=; b=mxZGc0mNt1qmMyiD0RwJ1cvgYbUoY/DcIUyIkCSozKenYu+b7m82+AwCFoajnuCYUa 7z1vY8nUfmUTe02XwDwY1shIKdAqKJr1QkGFJg2mmI46hfX6qfJNzkQ9D9hUX3u8YfmJ mwC2XL5cDiPnXq/hEF4xCjHlwlwv2v9iIUoutEpIQpUz0bzzmRL1qBEXNmLyQk6Ft2sP rpySx0VBPNGxOGzX5nf15FVUduZwv1Ex+JgSuPrRzZVqIl8y7oNlFoBjN37jwnbfD25Q ILzN6xk6ITarqUXFfHVzMjC/mRuwPMd4pEjMZsrD9+xrUsgpUwyvqT5+RfPV9uYYnrvj I1AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 l186si38043839iof.223.2017.06.06.10.28.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:28:04 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1dIIFF-00021b-Sh; Tue, 06 Jun 2017 17:26:17 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIFE-0001zl-Oo for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:26:16 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id E1/41-29088-8B5E6395; Tue, 06 Jun 2017 17:26:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfTARt3tT80 iDY5fl7P4vmUykwOjx+EPV1gCGKNYM/OS8isSWDPud31jLJgtX/FixUqmBsYv4l2MnBxCAjMY Jeavteti5OJgEZjHLPH/7mdmEEdCoJ9V4tLyT6wgVRICaRJdk5YyQtjVEo2T17JBdGtJHD01m xWkQUigmUnizoIGoAQHB5uAicSsDgmQGhEBJYl7qyYzgdQwC8xnlGia1AtWIywQIzFtjRpIDY uAqsTGN/uYQGxeAR+JGccnsUDskpO4ea6TGcTmBIrPPL+EEWKvt8SehjbGCYwCCxgZVjFqFKc WlaUW6RoZ6SUVZaZnlOQmZuboGhoY6+WmFhcnpqfmJCYV6yXn525iBAZWPQMD4w7GqSf8DjFK cjApifJGXjKLFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBG/kEKCdYlJqeWpGWmQMMcZi0BAePk gjv5AdAad7igsTc4sx0iNQpRmOOK1fWfWHimHJg+xcmIZa8/LxUKXHeFSCTBEBKM0rz4AbBYu 8So6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWHeFJApPJl5JXD7XgGdwgR0Ct8lE5BTShIRUlI NjPMtry1etbxnUeD7Lan/dsuzrm5eHNDktzWQ+cSuhqvumR95N58//1WPN/zJjND7H53fv9I4 zHmklm/Bp+cfH227kD3rocz767JFsaUCLR835+/T9goPLd2ndSh7Y5SY7gGnt/v7u9N/XHy34 p7+hhU+G/ZozjmVpDRtCt//JS/SCthEP/kVcZgrsRRnJBpqMRcVJwIA09GFXrgCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-31.messagelabs.com!1496769974!104434355!1 X-Originating-IP: [209.85.192.177] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8248 invoked from network); 6 Jun 2017 17:26:15 -0000 Received: from mail-pf0-f177.google.com (HELO mail-pf0-f177.google.com) (209.85.192.177) by server-8.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:26:15 -0000 Received: by mail-pf0-f177.google.com with SMTP id x63so2106606pff.3 for ; Tue, 06 Jun 2017 10:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VZJUuuIprOQStGxdyVOS4eGm62UShMry/rjYX8AeUVs=; b=EhzxyYu+/dS14vcvpqWKlvkmavwKrBKKtKftGdwsyMLae2IamgGULXAQ1+UJ3sRmY6 3MnTTurUwnegTPEZx4eRi3NQcUHyqzHrSTd8YDiYOuw3GSbpvDebBA44901QzTazY2oA xXAADDlkxnk3ZHZKObzT87g0AhRflEp5WxCL4= 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=VZJUuuIprOQStGxdyVOS4eGm62UShMry/rjYX8AeUVs=; b=VA2dRma3X6/WFvj+kS4hg9yBaKLKSLWufWUDakq/hT26kgE1LGP8giqaNLtRwBvaHE m0AbZj1nSR0tO3wdwI61Jg407WCjQcmLd/6iLRG/zPSwUgjhW3nK7c/b9BAa+lVYOYWg 1p1+CpKQNFzTy3MWta0g9wNWDPzBz5pU/dpcEMyQzoxi6+xIUcKt8Ein3N9V2sH72ej3 NY/1Ep0TU8yRMI9MGwtDDp0N3tu1LScrlF9SuupXEMx5lM8SjWJYB8M48nI1XLNIap6j gLB83NTii72gV1WStuI8O+6MILEta7f41COxIh9OTHksOhh9KAjgqEjVOuqJpYmYVgbI bL1g== X-Gm-Message-State: AODbwcCIGJfG6Vneqcg8UrLfTrjsWD6Hak7+ppuLqljLOP1KxWIhQZU9 U7hRxfN0samftU9UBUz0OQ== X-Received: by 10.84.217.216 with SMTP id d24mr10364666plj.148.1496769973824; Tue, 06 Jun 2017 10:26:13 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.26.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:26:13 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:28 +0530 Message-Id: <1496769929-23355-14-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 13/14 v4] 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 --- CC: ij CC: wl CC: ss CC: jg 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 b60dfa9..b59fd9f 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; @@ -149,9 +161,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" }, }; /* @@ -609,6 +622,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) { @@ -908,6 +953,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 Tue Jun 6 17:25:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 103183 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1536820qgd; Tue, 6 Jun 2017 10:28:11 -0700 (PDT) X-Received: by 10.107.35.13 with SMTP id j13mr26037555ioj.75.1496770091741; Tue, 06 Jun 2017 10:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496770091; cv=none; d=google.com; s=arc-20160816; b=GBUdstUjwXBYUViH+Yxv0NgdinJKzkRrM47uN8ci4tuq57HJ5lnoJvPBM9sRCJj4vG 1BFETvd5JDZOge1L5/8qC1heQ7ptw8wMpYLc/PjWevp2iNDKFOXurdPPRVIxoCuubmJY D1asX/5eFJgP/xfu4GPtLvi1KusiOT4vTvnrEV8njD9NJr3Kv7156iMevEq9y87VtLnQ FcfyGj/Zp281CYQ3PNiLccCln7D4Sk0c9YNHEpRG5Q3+nOWrTJXn2g/qDP2JXMndld6i cevLDxsapwNCCuOE53D1rEXM6TlTSPLZ2QGteZkAG4LOTLx2H7cxFnsUSTVSXs+FJpwN oiMA== 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=+cayodNjneJlZ9gZjChGDhnsh/nulYVJSWC4GGhIJ3s=; b=p5FcxDVgtXOC9/pY4dZMd61uj2Bg9Q8z5iKQ6Ct93Vbp733Qts3PVv5jgGJW/1O+S2 K+s1eHbxHDsvGlRLlvDS3ALukWYiN9jIdXRaZROtvn/Yd6VWblkS5QIxjFI6yTfUVAW/ gmL5DPHOzlojOWarArUk6M3SKhIu7JVj1xvH/By25AdUx+I1PXAemUVqyf2SvDaKxOHB VKkbb1M5HTQDV2YIePScYj/xWpdrjaDN2p78oQgiSKK4s7y5weLKafNMzU1DtAHSvpyO Zb5Bil3scbPB5fRgLvUWmklKyJjLXVOINq+if6yNAxMPsANF8jWoInkwfKTEKi9DVVry Xecg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 k78si15785336ita.112.2017.06.06.10.28.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 10:28:11 -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; spf=neutral (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 1dIIFJ-000269-46; Tue, 06 Jun 2017 17:26:21 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIIFI-000248-4F for xen-devel@lists.xenproject.org; Tue, 06 Jun 2017 17:26:20 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id F0/A6-17076-BB5E6395; Tue, 06 Jun 2017 17:26:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRuspbvrqVm kwYL5uhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a767fYC1YrVTSvN2tgPCLTxcjFISQwg1Fi 45S9zCAOi8A8Zomvb/rZQBwJgX5WiQkXF7N2MXICOWkSX+dfY4KwqyXadr9iA7GFBLQkjp6az QoxqplJYvX204xdjBwcbAImErM6JEBqRASUJO6tmswEUsMsMJ9RomlSLxtIjbBApMTJ/cUgNS wCqhJflv8G28Ur4COx++tZRohdchI3z3Uyg9icQPGZ55cwQuz1ltjT0MY4gVFgASPDKkb14tS istQiXXO9pKLM9IyS3MTMHF1DA2O93NTi4sT01JzEpGK95PzcTYzAsGIAgh2Mjd+dDjFKcjAp ifJGXjKLFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBG/kEKCdYlJqeWpGWmQMMcJi0BAePkgjv5 AdAad7igsTc4sx0iNQpRl2OSQe2f2ESYsnLz0uVEuddATJDAKQoozQPbgQs2i4xykoJ8zICHS XEU5BalJtZgir/ilGcg1FJmDcFZApPZl4J3KZXQEcwAR3Bd8kE5IiSRISUVAOjnPGsuI8y95i iDrRYT15cIGbibRgocW+Nxa78Va1TNSIOl//beuKscvb0c2s+NLkdEDm8c6fPs3RR4YYfshmq fAsWqC+PUZ0W8UFvKtfZmUnhgeqrWW2+zC8wbbXJyhFfNKlr34Zp23q5b/hOKzDJ1Pu99oD71 NN6kw+U15x8JO01cW9A7N4+JZbijERDLeai4kQAbuRXkbECAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-31.messagelabs.com!1496769977!103666288!1 X-Originating-IP: [74.125.83.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48417 invoked from network); 6 Jun 2017 17:26:18 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-10.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Jun 2017 17:26:18 -0000 Received: by mail-pg0-f42.google.com with SMTP id v18so27204811pgb.1 for ; Tue, 06 Jun 2017 10:26: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=f/pb3ed979C9eGW8CQnYS1QomAP0Wt6Osf29heVhA7o=; b=VocRiUz1y+DHZ5PxjFTXLGHTbO3a7abU/MP3zqZqzaumzT9cbphpfWixplOaBYxyWt vDyni1BjLNhuvqF9+wTUz8xuL69hTVozHMVRTQUmTZQJBdP8F5e2Cxxl9khH6lC2rtcM MLnztFJOgEn/DmaDq9qz2rxZMZMteN9lJPwA4= 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=f/pb3ed979C9eGW8CQnYS1QomAP0Wt6Osf29heVhA7o=; b=mPQyqvDyUqbfImBzefNJg+vB2MToaEOHiKoV5bsT+SS02SHT2ViWjyyGNxmRvcCWnO 9K49P5oKbarok30qTlCgTQIO7kfiZ6QAyrEvPTeeOus0pUvwf344TTCKOjtgubZShtTW q94gmiL1/TsjFNFXWiPhpZT49dOnVVLBtL4YHBzENMTkvTjHqePB7iba/HCrOd86hGas MF0vxTUx98MHx++jIR9FNly7R4YUjNeehLs3AaH4rUxbIGsZOD8WD1mkFjiYzf4UJm/n tSurIEjpdEhu19oVPhEOGYUwZ/B2zq/g6YWFIhOE3zyAO++cP0NJsyHxZsdOkbPqkWDt 3KUw== X-Gm-Message-State: AODbwcDo3Xi2dODbfbo7Y2iE7berqboU9P30JMVZz9qEhaVn7A/CqBbQ iWLxRHPXsGOYGBY4VpjVuA== X-Received: by 10.98.105.137 with SMTP id e131mr13834819pfc.56.1496769976751; Tue, 06 Jun 2017 10:26:16 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id 62sm6031632pfr.90.2017.06.06.10.26.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 10:26:16 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 6 Jun 2017 22:55:29 +0530 Message-Id: <1496769929-23355-15-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> References: <1496769929-23355-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 14/14 v4] 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 vpl011. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: ij CC: wl CC: ss CC: jg 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 13167ff..3397cda 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -1085,6 +1085,15 @@ Allow a guest to access specific physical IRQs. It is recommended to use this option only for trusted VMs under administrator 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 +"pl011" model is supported. + +vuart = "pl011" + +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..48fe914 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 pl011 UART on ARM64 systems. +To enable vuart the following line has to be added to the guest configuration +file: + +vuart = "pl011" + +In Linux you can select the virtual pl011 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.