From patchwork Fri Apr 28 16:01:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 98372 Delivered-To: patch@linaro.org Received: by 10.182.236.104 with SMTP id ut8csp392066obc; Fri, 28 Apr 2017 09:03:47 -0700 (PDT) X-Received: by 10.36.73.207 with SMTP id e76mr10135437itd.55.1493395427164; Fri, 28 Apr 2017 09:03:47 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x62si14422ita.7.2017.04.28.09.03.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:03:47 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1d48L1-0008WD-Al; Fri, 28 Apr 2017 16:01:43 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48L0-0008Vn-5v for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:01:42 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 2B/7A-01730-56763095; Fri, 28 Apr 2017 16:01:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRuso5uUzhx pMPO0pMX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmrF31jS2ggdNjBWn751nbGDcmdrFyMUhJDCd UaJh82FWEIdFYB6zxMP7z5hAHAmBflaJlmMvWboYOYGcOImOluWsEHaFxLrp3WwgtpCAlsTRU 7NZIUY1M0ks7roA1M3BwSZgIjGrQwKkRkRASeLeqslgQ5kF3jJK9H88xQpSIyzgJbHwZCRIDY uAqsTEE8fA5vMKeEt0vdvLBrFLTuLmuU5mEJtTwEfiWv8ydoi93hLdDfNYJjAKLGBkWMWoUZx aVJZapGtoopdUlJmeUZKbmJmja2hgqpebWlycmJ6ak5hUrJecn7uJERhcDECwg/Hsac9DjJIc TEqivJXuzJFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHinpgHlBItS01Mr0jJzgGEOk5bg4FES4 ZUASfMWFyTmFmemQ6ROMRpzXGn9+J6J49HKH++ZhFjy8vNSpcR5D4CUCoCUZpTmwQ2Cxd8lRl kpYV5GoNOEeApSi3IzS1DlXzGKczAqCfM+SgWawpOZVwK37xXQKUxAp7C4MICcUpKIkJJqYGw 5sXzB1XDRb1dOqiveX2TDJ/P8fS/z8u+aYqtSvt2by/c7PuHEyZ1B8VrLF1xy0NJZYf59zaO1 X9yVz8bPm6ZlH7dnoQW30JNru2MUYzJPNlU0HT533XnS5LMvPvw04wtsSVISeb3Q/NSnwuadP JpK3uvy1ZfyR357zyAs+vYez6GvjcabgxYosRRnJBpqMRcVJwIA5Vy7fboCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-206.messagelabs.com!1493395297!81585294!1 X-Originating-IP: [74.125.83.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48516 invoked from network); 28 Apr 2017 16:01:38 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-15.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:01:38 -0000 Received: by mail-pg0-f44.google.com with SMTP id t7so16929528pgt.3 for ; Fri, 28 Apr 2017 09:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9E+5RpmIKu+z/Cx6tkdJMbYU4HirqNTMCLsT/mdTh1s=; b=iSDIyCGvzwWsuoy1CbDQ7hwAcoLbwylIQK4n983cx7qy5f0v1pG5SuuNd6tlOVUzm8 EGPvVt8Wn13tj7XkRw5v/I8rlzA1kw0g3eBgS8aExGtFbMJJYnNmeJ4SWDszWiJWOgOE X+nSedpsmfjx2A1MsUfEuF+LAdNKBLU4R4Ev8= 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=9E+5RpmIKu+z/Cx6tkdJMbYU4HirqNTMCLsT/mdTh1s=; b=I861yBrAvccV5Om5dkbnUJrWUfMY2kao96ahgmhvxJGEc1PFrrHLSOkOVGDPof6DAt cclAMHPZ4Wk41mrAkY+qLpAVqpcdCxlnMMHziSVkg6jNru6BlZoHUTXFhC6E0TKllelT mRlNJCJdZ508AozzBTLwvkf+L4HLHFif7X9x+l2rhG54roGQoJRw8Sgb7tgUcFf2uvuM DYj0onvt+Vs4FTjeglTHVKW5hpuLmoQSMCsx43JZ94Rpbb5VsA9vEH5xQ1X/G4Krx3kX H+kiIbN28/M4QVOE395K5D7ewq3rl/UxapAEMLXHf5BUXLMzJGe4QjOLsZE8Ypd/npU8 qmOA== X-Gm-Message-State: AN3rC/4oUp2cpkWREdnhHb6Gj9gtMMnP8GrWghHl7wcy36UmUJF5DdVW +dbk3wHGPS6iONVz X-Received: by 10.98.78.86 with SMTP id c83mr12853197pfb.85.1493395296247; Fri, 28 Apr 2017 09:01:36 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.01.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:01:35 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:15 +0530 Message-Id: <1493395284-18430-2-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 01/10 v2] 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 --- Changes since v1: - Removed the optimiztion related to sendiing events to xenconsole - Use local variables as ring buffer indices while using the ring buffer xen/arch/arm/Kconfig | 5 + xen/arch/arm/Makefile | 1 + xen/arch/arm/vpl011.c | 340 +++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/domain.h | 3 + xen/include/asm-arm/pl011-uart.h | 2 + xen/include/public/arch-arm.h | 8 + xen/include/xen/vpl011.h | 74 +++++++++ 7 files changed, 433 insertions(+) create mode 100644 xen/arch/arm/vpl011.c create mode 100644 xen/include/xen/vpl011.h 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..51abade --- /dev/null +++ b/xen/arch/arm/vpl011.c @@ -0,0 +1,340 @@ +/* + * 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 + +unsigned int vpl011_reg_mask[] = {0xff, 0xffff, 0xffffffff}; + +static void vgic_inject_vpl011_spi(struct domain *d) +{ + struct vpl011_s *vpl011 = &d->arch.vpl011; + + if ( (vpl011->uartris & vpl011->uartimsc) ) + vgic_vcpu_inject_spi(d, GUEST_VPL011_SPI); +} + +static void vpl011_read_data(struct domain *d, uint8_t *data) +{ + unsigned long flags; + struct vpl011_s *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + + /* + * Initialize the data so that even if there is no data in ring buffer + * 0 is returned. + */ + *data = 0; + + 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 ( !VPL011_IN_RING_EMPTY(intf) ) + { + uint32_t in_cons = intf->in_cons; + *data = intf->in[MASK_XENCONS_IDX(in_cons, intf->in)]; + smp_mb(); + intf->in_cons = in_cons + 1; + } + + if ( VPL011_IN_RING_EMPTY(intf) ) + { + vpl011->uartfr |= (RXFE); + vpl011->uartris &= ~(RXI); + } + vpl011->uartfr &= ~(RXFF); + VPL011_UNLOCK(d, flags); + + notify_via_xen_event_channel(d, vpl011->evtchn); +} + +static void vpl011_write_data(struct domain *d, uint8_t data) +{ + unsigned long flags; + struct vpl011_s *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + + 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 ( !VPL011_OUT_RING_FULL(intf) ) + { + uint32_t out_prod = intf->out_prod; + intf->out[MASK_XENCONS_IDX(out_prod, intf->out)] = data; + smp_wmb(); + intf->out_prod = out_prod + 1; + } + + if ( VPL011_OUT_RING_FULL(intf) ) + { + vpl011->uartfr |= (TXFF); + vpl011->uartris &= ~(TXI); + } + + vpl011->uartfr |= (BUSY); + + vpl011->uartfr &= ~(TXFE); + + VPL011_UNLOCK(d, flags); + + 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) +{ + uint8_t ch; + struct hsr_dabt dabt = info->dabt; + int vpl011_reg = (int)(info->gpa - GUEST_PL011_BASE); + struct vpl011_s *vpl011 = &v->domain->arch.vpl011; + + switch ( vpl011_reg ) + { + case DR: + if ( !VALID_W_SIZE(dabt.size) ) goto bad_width; + vpl011_read_data(v->domain, &ch); + *r = ch; + break; + + case RSR: + if ( !VALID_BW_SIZE(dabt.size) ) goto bad_width; + + /* It always returns 0 as there are no physical errors. */ + *r = 0; + break; + + case FR: + if ( !VALID_BW_SIZE(dabt.size) ) goto bad_width; + *r = (vpl011->uartfr & vpl011_reg_mask[dabt.size]); + break; + + case RIS: + if ( !VALID_W_SIZE(dabt.size) ) goto bad_width; + *r = (vpl011->uartris & vpl011_reg_mask[dabt.size]); + break; + + case MIS: + if ( !VALID_W_SIZE(dabt.size) ) goto bad_width; + *r = (vpl011->uartris & + vpl011->uartimsc & vpl011_reg_mask[dabt.size]); + break; + + case IMSC: + if ( !VALID_W_SIZE(dabt.size) ) goto bad_width; + *r = (vpl011->uartimsc & vpl011_reg_mask[dabt.size]); + break; + + case ICR: + if ( !VALID_W_SIZE(dabt.size) ) 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) +{ + uint8_t ch = ((struct uartdr_reg *)&r)->data; + struct hsr_dabt dabt = info->dabt; + int vpl011_reg = (int)(info->gpa - GUEST_PL011_BASE); + struct vpl011_s *vpl011 = &v->domain->arch.vpl011; + + switch ( vpl011_reg ) + { + case DR: + + if ( !VALID_BW_SIZE(dabt.size) ) goto bad_width; + vpl011_write_data(v->domain, ch); + break; + + case RSR: /* Nothing to clear. */ + if ( !VALID_BW_SIZE(dabt.size) ) goto bad_width; + break; + + case FR: + goto write_ignore; + case RIS: + case MIS: + goto word_write_ignore; + + case IMSC: + if ( !VALID_W_SIZE(dabt.size) ) goto bad_width; + vpl011->uartimsc = (r & vpl011_reg_mask[dabt.size]); + vgic_inject_vpl011_spi(v->domain); + break; + + case ICR: + if ( !VALID_W_SIZE(dabt.size) ) goto bad_width; + vpl011->uartris &= ~(r & vpl011_reg_mask[dabt.size]); + vgic_inject_vpl011_spi(v->domain); + break; + + default: + gprintk(XENLOG_ERR, "vpl011: unhandled write r%d offset %#08x\n", + dabt.reg, vpl011_reg); + return 0; + } + + return 1; + +write_ignore: + if ( !VALID_BW_SIZE(dabt.size) ) goto bad_width; + return 1; + +word_write_ignore: + if ( !VALID_W_SIZE(dabt.size) ) goto bad_width; + 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, +}; + +int vpl011_map_guest_page(struct domain *d, unsigned long pfn) +{ + struct vpl011_s *vpl011 = &d->arch.vpl011; + + /* Map the guest PFN to Xen address space. */ + return prepare_ring_for_helper(d, + pfn, + &vpl011->ring_page, + &vpl011->ring_buf); +} + +static void vpl011_data_avail(struct domain *d) +{ + unsigned long flags; + struct vpl011_s *vpl011 = &d->arch.vpl011; + struct xencons_interface *intf = vpl011->ring_buf; + uint32_t in_ring_depth, out_ring_depth; + + VPL011_LOCK(d, flags); + + in_ring_depth = intf->in_prod - intf->in_cons; + out_ring_depth = intf->out_prod - intf->out_cons; + + /* Update the uart rx state if the buffer is not empty. */ + if ( in_ring_depth != 0 ) + { + vpl011->uartfr &= ~(RXFE); + if ( in_ring_depth == VPL011_RING_MAX_DEPTH(intf, in) ) + vpl011->uartfr |= (RXFF); + vpl011->uartris |= (RXI); + } + + /* Update the uart tx state if the buffer is not full. */ + if ( out_ring_depth != VPL011_RING_MAX_DEPTH(intf, out) ) + { + vpl011->uartfr &= ~(TXFF); + vpl011->uartris |= (TXI); + if ( out_ring_depth == 0 ) + { + vpl011->uartfr &= ~(BUSY); + vpl011->uartfr |= (TXFE); + } + } + + VPL011_UNLOCK(d, flags); + + vgic_inject_vpl011_spi(d); +} + + +static void vpl011_notification(struct vcpu *v, unsigned int port) +{ + vpl011_data_avail(v->domain); +} + +int domain_vpl011_init(struct domain *d, struct xen_arch_domainconfig *config) +{ + int rc; + struct vpl011_s *vpl011 = &d->arch.vpl011; + + rc = alloc_unbound_xen_event_channel(d, 0, config->console_domid, + vpl011_notification); + if (rc < 0) + { + return rc; + } + + vpl011->evtchn = rc; + rc = vgic_reserve_virq(d, GUEST_VPL011_SPI); + if ( !rc ) + { + free_xen_event_channel(d, vpl011->evtchn); + vpl011->evtchn = -1; + return rc; + } + register_mmio_handler(d, &vpl011_mmio_handler, GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL); + spin_lock_init(&vpl011->lock); + + vpl011->initialized = true; + + return 0; +} + +void domain_vpl011_deinit(struct domain *d) +{ + struct vpl011_s *vpl011 = &d->arch.vpl011; + + if ( vpl011->initialized ) + { + free_xen_event_channel(d, vpl011->evtchn); + destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page); + } + vpl011->initialized = false; +} diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 6de8082..a0f8f89 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,8 @@ struct arch_domain struct { uint8_t privileged_call_enabled : 1; } monitor; + + struct vpl011_s vpl011; } __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/public/arch-arm.h b/xen/include/public/arch-arm.h index bd974fb..5f91207 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -322,6 +322,8 @@ struct xen_arch_domainconfig { * */ uint32_t clock_frequency; + + uint32_t console_domid; }; #endif /* __XEN__ || __XEN_TOOLS__ */ @@ -410,6 +412,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 +450,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/xen/vpl011.h b/xen/include/xen/vpl011.h new file mode 100644 index 0000000..57d61b4 --- /dev/null +++ b/xen/include/xen/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_ + +/* helper macros */ +#define VPL011_RING_DEPTH(intf,dir) (((intf)->dir ## _prod - (intf)->dir ## _cons)) + +#define VPL011_RING_MAX_DEPTH(intf,dir) (sizeof((intf)->dir)-1) + +#define VPL011_IN_RING_EMPTY(intf) (VPL011_RING_DEPTH(intf, in) == 0) + +#define VPL011_OUT_RING_EMPTY(intf) (VPL011_RING_DEPTH(intf, out) == 0) + +#define VPL011_IN_RING_FULL(intf) (VPL011_RING_DEPTH(intf, in) == VPL011_RING_MAX_DEPTH(intf, in)) + +#define VPL011_OUT_RING_FULL(intf) (VPL011_RING_DEPTH(intf, out) == VPL011_RING_MAX_DEPTH(intf,out)) + +#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) + +#define VALID_BW_SIZE(size) ( size == DABT_BYTE || size == DABT_HALF_WORD || size == DABT_WORD ) +#define VALID_W_SIZE(size) ( size == DABT_HALF_WORD || size == DABT_WORD ) + +struct uartdr_reg { + uint8_t data; + uint8_t error_status:4; + uint8_t reserved1:4; + uint16_t reserved2; + uint32_t reserved3; +}; + +struct vpl011_s { + 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; + bool initialized; /* Flag which tells whether vpl011 is initialized */ + uint32_t evtchn; +}; + +#ifdef CONFIG_VPL011_CONSOLE +int domain_vpl011_init(struct domain *d, struct xen_arch_domainconfig *config); +void domain_vpl011_deinit(struct domain *d); +int vpl011_map_guest_page(struct domain *d, unsigned long pfn); +#else +static inline int domain_vpl011_init(struct domain *d, struct xen_arch_domainconfig *config) { return -ENOSYS; } +static inline void domain_vpl011_deinit(struct domain *d) { } +static inline int vpl011_map_guest_page(struct domain *d, unsigned long pfn) { return -ENOSYS; } +#endif + +#endif From patchwork Fri Apr 28 16:01: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: 98366 Delivered-To: patch@linaro.org Received: by 10.182.236.104 with SMTP id ut8csp391960obc; Fri, 28 Apr 2017 09:03:36 -0700 (PDT) X-Received: by 10.36.135.66 with SMTP id f63mr8366389ite.54.1493395416669; Fri, 28 Apr 2017 09:03:36 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 76si327616iti.70.2017.04.28.09.03.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:03:36 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1d48L2-00005T-LY; Fri, 28 Apr 2017 16:01:44 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48L1-0008W5-3p for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:01:43 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 14/AB-03587-66763095; Fri, 28 Apr 2017 16:01:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsVyMfTAGt3UdOZ Ig+uX9Cy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxlP7rYCi4aV/zaJ9HAOEmti5GLQ0hgBqPE 0p7vTCAOi8A8Zokd3fPZuhg5OSQE+lklmlblQNhxEqf+bWOEsKslPr9ZAlYjJKAlcfTUbFaIS c1MEl9/rgdKcHCwCZhIzOqQAKkREVCSuLdqMtgCZoG3jBL9H0+xgiSEBRIlFm5azwJiswioSu x7vRhsAa+At8T/y3+YIJbJSdw818kMYnMK+Ehc61/GDrHYW6K7YR7LBEaBBYwMqxjVi1OLylK LdI31kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECw4oBCHYwdvxzOsQoycGkJMpb 6c4cKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCd2oaUE6wKDU9tSItMwcY4DBpCQ4eJRFeCZA0b 3FBYm5xZjpE6hSjMceLy+/fM3E8WfnjPZMQS15+XqqUOG8ESKkASGlGaR7cIFjkXWKUlRLmZQ Q6TYinILUoN7MEVf4VozgHo5Iwbw7IFJ7MvBK4fa+ATmECOoXFhQHklJJEhJRUA6OGp/vlV/L td5intdkITZfje/t/5oJps6UDdYOmSb5cxJSQ8Ogyj6BCVfTjzvocjm1ODu4JvokCc604BDg1 o1aWmrK4632tnH/uyGOffZUa6TdLzDc9yD2zkYX/+q3S/Tw7whrXCivsvMvf+TH84LknO7veW JmlbJO4eEg+MvPzxf0dM4qEdyuxFGckGmoxFxUnAgAHNqNetwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-27.messagelabs.com!1493395300!76313593!1 X-Originating-IP: [209.85.192.172] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50061 invoked from network); 28 Apr 2017 16:01:41 -0000 Received: from mail-pf0-f172.google.com (HELO mail-pf0-f172.google.com) (209.85.192.172) by server-10.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:01:41 -0000 Received: by mail-pf0-f172.google.com with SMTP id i4so13947186pfc.0 for ; Fri, 28 Apr 2017 09:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hdX+ngkWmG6KM/S14DnCDQSrXUxjir/JgEr69Bebol8=; b=RxFD7T/eo5dK4YypufWp7nRFesEnJbO5DoXJdvSDvGBBNTcMvfPq6R2k0bUPVAtbM5 b7/LoYdxk3bfrUbH25LO+QBkgVicwh73zkIQSMhgkTTNHgOVawyVtAvZvIFa4cnrVxQ3 L1xhwSRYi+sZHXPKk1psQN0fx2iJqxSdKBb34= 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=hdX+ngkWmG6KM/S14DnCDQSrXUxjir/JgEr69Bebol8=; b=JobZAhqwet9r4SORS8h4qFZf9K78PRhpjSLUBf2u+EJw5OBHwh85HsJW4Tn5rvpj0g KNnXrrMlvC+oni0Z02KDmSYVftEbks9gDw/czcTBcJDdNwnTFzCS8a4UuakSLblHayq8 AVTS9tdn6AQUqKEbyITJ56Na+6UEwZxNSgrjnpdOBevltqy8xdI2LEXh9uvT/phECFwm lGjlVSfLJ4q+mp7IN4OxL5BloMcrf+RPIvRWFwfbE4wzjHxbU853LHG8Rf8VNsJWMPdm okNpmUXfSxTzij1mNlVlStjE81dtAcILZt6x6PfH58jnl/vxAo7h6iR3nE46UCeQ4mLf i6Xw== X-Gm-Message-State: AN3rC/4+I56pUR/hxYLVTS7uFocGdwnd8XWe6NBNFUGXdu65a30gcCiC ZkLciZ7o2A7TkwwQ X-Received: by 10.84.160.226 with SMTP id v31mr16066256plg.122.1493395299836; Fri, 28 Apr 2017 09:01:39 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.01.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:01:39 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:16 +0530 Message-Id: <1493395284-18430-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 02/10 v2] xen/arm: vpl011: Add new vuart domctl interface to setup pfn and evtchn 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. Add two new domctl API to: - Allocate a new event channel for sending/receiving events to/from Xen. - Map the PFN allocted by the toolstack to be used as IN/OUT ring buffers. Xen will communicate with xenconsole over the ring buffer and the event channel to transmit and receive pl011 data on guest domain's behalf. Signed-off-by: Bhupinder Thakur --- Changes since v1: - Replaced the hvm interface with domctl interface tools/libxc/include/xenctrl.h | 26 ++++++++++++++++++++++++++ tools/libxc/xc_domain.c | 39 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/domctl.c | 20 ++++++++++++++++++++ xen/arch/x86/domctl.c | 4 ++++ xen/include/public/domctl.h | 11 +++++++++++ 5 files changed, 100 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 1629f41..bebfe7d 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -886,6 +886,32 @@ int xc_vcpu_getcontext(xc_interface *xch, vcpu_guest_context_any_t *ctxt); /** + * This function returns information about the pfn and the event channel + * to be used for setting up a virtual uart console. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the domain to get information from + * @parm vuart_pfn the pfn to be used for the ring buffer + * @return 0 on success, negative error on failure + */ +int xc_domain_vuart_set_pfn(xc_interface *xch, + uint32_t domid, + uint32_t vuart_pfn); + +/** + * This function returns information about the pfn and the event channel + * to be used for setting up a virtual console. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the domain to get information from + * @parm vuart_evtchn the event channel to be used for console events + * @return 0 on success, negative error on failure + */ +int xc_domain_vuart_get_evtchn(xc_interface *xch, + uint32_t domid, + uint32_t *vuart_evtchn); + +/** * This function returns information about the XSAVE state of a particular * vcpu of a domain. If extstate->size and extstate->xfeature_mask are 0, * the call is considered a query to retrieve them and the buffer is not diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 00909ad4..943f202 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -343,6 +343,45 @@ int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid, return 0; } +int xc_domain_vuart_set_pfn(xc_interface *xch, + uint32_t domid, + uint32_t vuart_pfn) +{ + 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_SET_PFN; + domctl.u.vuart_op.pfn = vuart_pfn; + + if ( (rc = do_domctl(xch, &domctl)) < 0 ) + return rc; + + return rc; +} + +int xc_domain_vuart_get_evtchn(xc_interface *xch, + uint32_t domid, + uint32_t *vuart_evtchn) +{ + DECLARE_DOMCTL; + int rc = 0; + + *vuart_evtchn = -1; + + domctl.cmd = XEN_DOMCTL_vuart_op; + domctl.domain = (domid_t)domid; + domctl.u.vuart_op.cmd = XEN_DOMCTL_VUART_OP_GET_EVTCHN; + + if ( (rc = do_domctl(xch, &domctl)) < 0 ) + return rc; + + *vuart_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/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index 971caec..e400f87 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -119,6 +120,25 @@ 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; + if ( d->arch.vpl011.initialized ) + { + if ( domctl->u.vuart_op.cmd == XEN_DOMCTL_VUART_OP_SET_PFN ) + { + rc = vpl011_map_guest_page(d, domctl->u.vuart_op.pfn); + } + else + { + domctl->u.vuart_op.evtchn = d->arch.vpl011.evtchn; + rc = __copy_to_guest(u_domctl, domctl, 1); + } + return rc; + } + else + return -EINVAL; + } default: { int rc; diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index e104be2..49e907d 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1465,6 +1465,10 @@ long arch_do_domctl( recalculate_cpuid_policy(d); break; + case XEN_DOMCTL_vuart_op: + ret = -EOPNOTSUPP; + break; + default: ret = iommu_do_domctl(domctl, d, u_domctl); break; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index e6cf211..8bee0c3 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1138,6 +1138,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_SET_PFN 0 +#define XEN_DOMCTL_VUART_OP_GET_EVTCHN 1 + uint32_t cmd; /* XEN_DOMCTL_VUART_OP_* */ + uint32_t pfn; /* IN */ + uint32_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 +1227,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 +1290,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 Fri Apr 28 16:01: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: 98367 Delivered-To: patch@linaro.org Received: by 10.182.236.104 with SMTP id ut8csp392026obc; Fri, 28 Apr 2017 09:03:42 -0700 (PDT) X-Received: by 10.36.2.205 with SMTP id 196mr10666299itu.63.1493395422673; Fri, 28 Apr 2017 09:03:42 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i193si39202itb.61.2017.04.28.09.03.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:03:42 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1d48L6-00007N-Sq; Fri, 28 Apr 2017 16:01:48 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48L6-00006x-0I for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:01:48 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 2A/0F-22906-B6763095; Fri, 28 Apr 2017 16:01:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfTANt2sdOZ Ig4mbtS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyph9cyFuyQrvi19D9rA+NP0S5GLg4hgZmM Ese6vrCBOCwC85glFr25yQTiSAj0s0r8+tfK3sXIAeTESWw+Gd7FyAlkVkkc7p7DCmILCWhJH D01mxViUjOTxIHjr5lA6tkETCRmdUiA1IgIKEncWzUZbCazwFtGif6Pp8CahQWiJSYdXMkOYr MIqEpsOTqZEcTmFfCWWLnuKAvEMjmJm+c6mUFsTgEfiWv9y9ghFntLdDfMY5nAKLCAkWEVo3p xalFZapGuhV5SUWZ6RkluYmaOrqGBqV5uanFxYnpqTmJSsV5yfu4mRmBgMQDBDsaDzc6HGCU5 mJREeSvdmSOF+JLyUyozEosz4otKc1KLDzHKcHAoSfAKpAHlBItS01Mr0jJzgCEOk5bg4FES4 ZUASfMWFyTmFmemQ6ROMRpzvLj8/j0Tx5OVP94zCbHk5eelSonzdqUClQqAlGaU5sENgsXeJU ZZKWFeRqDThHgKUotyM0tQ5V8xinMwKgnzKoEs5MnMK4Hb9wroFCagU1hcGEBOKUlESEk1MBa WbeRbsOXi1kORdxc8VfJsLti7LTZ/G9PnbXdEbmfUmnPu/8Er9Kmw2Lb3SGWEYeGHnW9jlyoE Wez4wvjvnY7CKZs1EvtXBS1dYygid7GPc6a9e9BF/VVZb44InYyYs+vI9gz3e6uvvGh9pK+zM id667OJWbcvKKmGnOt33lJ41MA86TJvzh8lluKMREMt5qLiRACvJWq3uAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-4.tower-206.messagelabs.com!1493395304!95568128!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.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20590 invoked from network); 28 Apr 2017 16:01:45 -0000 Received: from mail-pf0-f182.google.com (HELO mail-pf0-f182.google.com) (209.85.192.182) by server-4.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:01:45 -0000 Received: by mail-pf0-f182.google.com with SMTP id v14so50599049pfd.2 for ; Fri, 28 Apr 2017 09:01: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=J5Hxb4UQMt0y51QQuXFpitTz/GSUyQSdbI8PLgC5wPw=; b=d6WJ+7CICsry/SJJttXt0RtILNLTfckPx5KjB8jzHedLy1gGhC3AgdJUH4QHBo55jX nzZ2uz9oO69Xs1zoxWEF6hDm1c/IVojF7MQuyRnlAcbymJx5baBXmbX9UtaUyJ+yfAL4 vgvnOP4BaCmMa6GMM22rFJxOTrgqiLx918hYo= 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=J5Hxb4UQMt0y51QQuXFpitTz/GSUyQSdbI8PLgC5wPw=; b=VEHNBwvZ0IB907x+qKiimQ0ovdmY+vJylrHOleozmzWLIc/ld3TQtiKq/9AX3CSVQ5 xHswdpmxFrva8ibnsno/WR5sdXpa48N03LKF/6cbk48hkODjqsUZinWDIAwiYdKIzECb GG+Lg8IXiZuU+j6jM1zhD8SKQWgmulcW/8aNqU5LnkFZJZ/UuQFwti01sv9/aVndwD98 yN/o4jnJsEElhQbD4AMkCfv8/K83FlNK5ar2N4cwGeSiNY12U2C3L9q1qkUpgT4X20/3 bhZzzGxakykiWh4ZSbcU3ss9V01oTlKNE9wMt8JONQL10IYwei1I2+zo5p/KyqKoN84m Ju5Q== X-Gm-Message-State: AN3rC/6QI9YPHwMzNHaHwgKtO1f/YQp+L/UHsZ1sMbm/nJOGKH2hDoIP nkz8pRxyrxVfxNb2 X-Received: by 10.98.24.213 with SMTP id 204mr12358509pfy.237.1493395303835; Fri, 28 Apr 2017 09:01:43 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.01.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:01:43 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:17 +0530 Message-Id: <1493395284-18430-4-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 03/10 v2] xen/arm: vpl011: Enable pl011 emulation for a guest domain 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" Vpl011 emulation is enabled for a guest domain in Xen only when it is enabled through an option in libxl provided by the user through guest configuration. The pl011 enable/disable knob in libxl is introduced in the following patch: xen/arm: vpl011: Add support for vuart in libxl Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain.c | 6 ++++++ xen/common/domctl.c | 3 +++ xen/include/public/domctl.h | 2 ++ xen/include/xen/sched.h | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 76310ed..23baa81 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -36,6 +36,7 @@ #include #include "vtimer.h" #include "vuart.h" +#include DEFINE_PER_CPU(struct vcpu *, curr_vcpu); @@ -631,6 +632,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, if ( (rc = domain_vtimer_init(d, config)) != 0 ) goto fail; + if ( domcr_flags & DOMCRF_vuart ) + if ( (rc = domain_vpl011_init(d, config)) != 0 ) + goto fail; update_domain_wallclock_time(d); /* @@ -665,6 +669,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/common/domctl.c b/xen/common/domctl.c index 951a5dc..902dd71 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -501,6 +501,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) | XEN_DOMCTL_CDF_hap | XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off + | XEN_DOMCTL_VUART_enable | XEN_DOMCTL_CDF_xs_domain)) ) break; @@ -539,6 +540,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) domcr_flags |= DOMCRF_oos_off; if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_xs_domain ) domcr_flags |= DOMCRF_xs_domain; + if ( op->u.createdomain.flags & XEN_DOMCTL_VUART_enable ) + domcr_flags |= DOMCRF_vuart; d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref, &op->u.createdomain.config); diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 8bee0c3..c307013 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -63,6 +63,8 @@ struct xen_domctl_createdomain { /* Is this a xenstore domain? */ #define _XEN_DOMCTL_CDF_xs_domain 4 #define XEN_DOMCTL_CDF_xs_domain (1U<<_XEN_DOMCTL_CDF_xs_domain) +#define _XEN_DOMCTL_VUART_enable 6 +#define XEN_DOMCTL_VUART_enable (1U<<_XEN_DOMCTL_VUART_enable) uint32_t flags; struct xen_arch_domainconfig config; }; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 1127ca9..ee7dc7a 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -555,6 +555,10 @@ struct domain *domain_create(domid_t domid, unsigned int domcr_flags, #define _DOMCRF_xs_domain 5 #define DOMCRF_xs_domain (1U<<_DOMCRF_xs_domain) + /* DOMCRF_vuart: enable virtual uart emulation. Used for Aarch64. */ +#define _DOMCRF_vuart 7 +#define DOMCRF_vuart (1U<<_DOMCRF_vuart) + /* * rcu_lock_domain_by_id() is more efficient than get_domain_by_id(). * This is the preferred function if the returned domain reference From patchwork Fri Apr 28 16:01: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: 98370 Delivered-To: patch@linaro.org Received: by 10.182.236.104 with SMTP id ut8csp392054obc; Fri, 28 Apr 2017 09:03:46 -0700 (PDT) X-Received: by 10.36.26.87 with SMTP id 84mr15609iti.94.1493395426001; Fri, 28 Apr 2017 09:03:46 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id c65si504464itb.88.2017.04.28.09.03.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:03: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 1d48LA-00009C-3N; Fri, 28 Apr 2017 16:01:52 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48L8-00008R-SQ for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:01:50 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 4B/74-01870-E6763095; Fri, 28 Apr 2017 16:01:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRusr5ubzhx psGeqrMX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmrF550TGgqXqFf/unGJsYLwg38XIxSEkMJ1R 4nFLOxuIwyIwj1liyctZYI6EQD+rxMlD7YxdjJxATpzEvt0XmSDsSonFi2+CxYUEtCSOnprNC jGqmUni+6RLLF2MHBxsAiYSszokQGpEBJQk7q2azARSwyzwllGi/+MpVpCEsICnxNPWx+wgNo uAqsTK7l1gvbwC3hKP1hRD7JKTuHmukxnE5hTwkbjWv4wdYq+3RHfDPJYJjAILGBlWMWoUpxa VpRbpGhnqJRVlpmeU5CZm5ugaGhjr5aYWFyemp+YkJhXrJefnbmIEhlY9AwPjDsaevX6HGCU5 mJREeSvdmSOF+JLyUyozEosz4otKc1KLDzHKcHAoSfAKpAHlBItS01Mr0jJzgEEOk5bg4FES4 U1NBUrzFhck5hZnpkOkTjEac7xb+uE9E8ejlT/eMwmx5OXnpUqJ80aATBIAKc0ozYMbBIu+S4 yyUsK8jAwMDEI8BalFuZklqPKvGMU5GJWEeZVApvBk5pXA7XsFdAoT0CksLgwgp5QkIqSkGhg VvIS3HjteoZ6QsXq1c381b/Tsb5+mP5Pz0Hv9e6eGbWhJw3WmxRkSDPOmKK/4rWIx5d8uoeCP i7w/v5z1as+ZkkMSntaWd/PMed7Is2vbcZ3V/tn4+1vQgldWzXe7HnzPfXy/e77ThTUHfTb+r OlMDM7hZX+1TNBeZ+cjpZlXWyzL5YNN115VYinOSDTUYi4qTgQAo1+/TbkCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-12.tower-31.messagelabs.com!1493395308!81142128!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.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16829 invoked from network); 28 Apr 2017 16:01:49 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-12.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:01:49 -0000 Received: by mail-pg0-f47.google.com with SMTP id o3so11673294pgn.2 for ; Fri, 28 Apr 2017 09:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l+KGAUe62TLj7so7bVciyFWpDWa4oYTNJ/q6Tyo1TgQ=; b=e2VseITdAioshggD2YRGQBVlwB603Rqy+PGhxsQgwVeYVd+lTys33eGS16ZbXwNiwV ohhefwfbbWdHR9vBVGUyRCI6tefzfPgfSwaHoYzosYL+WVDYv7eI/dH0BTrFmaKtoezv iacXSm8snBkDiWRw0reAijeKRvMzmr8GWkccU= 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=l+KGAUe62TLj7so7bVciyFWpDWa4oYTNJ/q6Tyo1TgQ=; b=FZPJPSQzXEX7Y1/xLIP2Ud3N1gbEjSqW7FnGrEz1Qlftk505wvM2jdG3GXczMQHPXO gVYy0aTq9EWiiGZ4wsfc3P53OLJK1C/Fr6sduP85Aws0E+otnVPnxIYYe2LeiL2RLsyV lIKGMplexp99ssWAM+Te2Tat++WDskLyucD2X/uQuH7CYq4uY6Kzb/HbuBIjURNvoVRH P6B69Uo/4A1s4XBEhlhke0QYyByyJULGk7Y4JmQICDskJA6p2nph1Qw3BCSoCK5eam2Q yvi7Ku76dZpqZmdseOcjhBvaS5wYub8pbUo0xtzFsPkSKt34Blo221FEYbW5f3JkwpDB paGg== X-Gm-Message-State: AN3rC/6a+MIMqehdxSZaXorlTbPwHeIADytDfP7RngjHuOz/jg2YaTso CAUWdyDAhwAW+xiG X-Received: by 10.98.62.141 with SMTP id y13mr13007823pfj.93.1493395307545; Fri, 28 Apr 2017 09:01:47 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.01.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:01:46 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:18 +0530 Message-Id: <1493395284-18430-5-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 04/10 v2] 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 --- Changes since v1: - Modified the syntax for taking the pl011 as a console type in the configuration file. Now the syntax is vuart = "pl011". - Replaced the console type VCON with VUART, as it is more intuitive. tools/libxl/libxl.h | 6 ++++++ tools/libxl/libxl_create.c | 10 ++++++++++ tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_types.idl | 2 ++ tools/xl/xl_console.c | 4 +++- tools/xl/xl_parse.c | 3 +++ 6 files changed, 28 insertions(+), 1 deletion(-) 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_create.c b/tools/libxl/libxl_create.c index bffbc45..5d70bc2 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -536,6 +536,9 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, flags |= libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off; } + if (!strcmp(d_config->b_info.vuart, "pl011")) + flags |= XEN_DOMCTL_VUART_enable; + /* Ultimately, handle is an array of 16 uint8_t, same as uuid */ libxl_uuid_copy(ctx, (libxl_uuid *)handle, &info->uuid); @@ -900,6 +903,11 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } + if (!strcmp(d_config->b_info.vuart, "pl011")) + state->vuart_enabled = true; + else + state->vuart_enabled = false; + if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM && (libxl_defbool_val(d_config->b_info.u.hvm.nested_hvm) && (libxl_defbool_val(d_config->b_info.u.hvm.altp2m) || @@ -918,6 +926,8 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } + state->config.console_domid = state->console_domid; + ret = libxl__domain_make(gc, d_config, &domid, &state->config); if (ret) { LOGD(ERROR, domid, "cannot make domain: %d", ret); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 5d082c5..9dba8e7 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1135,6 +1135,10 @@ typedef struct { uint32_t num_vmemranges; xc_domain_configuration_t config; + + unsigned long vuart_mfn; + uint32_t vuart_port; + bool vuart_enabled; } 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..5d53f2c 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", [ @@ -470,6 +471,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("disable_migrate", libxl_defbool), ("cpuid", libxl_cpuid_policy_list), ("blkdev_start", string), + ("vuart", string), ("vnuma_nodes", Array(libxl_vnode_info, "num_vnuma_nodes")), diff --git a/tools/xl/xl_console.c b/tools/xl/xl_console.c index 0508dda..6f3cd7f 100644 --- a/tools/xl/xl_console.c +++ b/tools/xl/xl_console.c @@ -34,8 +34,10 @@ int main_console(int argc, char **argv) type = LIBXL_CONSOLE_TYPE_PV; else if (!strcmp(optarg, "serial")) type = LIBXL_CONSOLE_TYPE_SERIAL; + else if (!strcmp(optarg, "vuart")) + type = LIBXL_CONSOLE_TYPE_VUART; else { - fprintf(stderr, "console type supported are: pv, serial\n"); + fprintf(stderr, "console type supported are: pv, serial, vuart\n"); return EXIT_FAILURE; } break; diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 856a304..80fd184 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -916,6 +916,9 @@ 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_replace_string(config, "vuart", &b_info->vuart, 0)) + b_info->vuart = strdup("unknown"); + parse_vnuma_config(config, b_info); /* Set max_memkb to target_memkb and max_vcpus to avail_vcpus if From patchwork Fri Apr 28 16:01: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: 98369 Delivered-To: patch@linaro.org Received: by 10.182.236.104 with SMTP id ut8csp392043obc; Fri, 28 Apr 2017 09:03:44 -0700 (PDT) X-Received: by 10.107.15.146 with SMTP id 18mr10907914iop.128.1493395424492; Fri, 28 Apr 2017 09:03:44 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id h127si7353222ite.7.2017.04.28.09.03.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:03:44 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1d48LD-0000BC-AX; Fri, 28 Apr 2017 16:01:55 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48LC-0000AE-0g for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:01:54 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 5B/F8-03371-17763095; Fri, 28 Apr 2017 16:01:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfTAGt2CdOZ Ig79XtCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oz1lxtYC/6IVnxqfcrYwLhMqIuRi0NIYCaj xIv2CywgDovAPGaJhq/rmEAcCYF+VolzaxtZuxg5gZw4iZ9nn7N1MXIA2ZUSxyeVgISFBLQkj p6azQoxqZlJ4vGm40wgNWwCJhKzOiRAakQElCTurZoMNpNZ4C2jRP/HU2AzhQUiJE61X2IBsV kEVCUetPYwg9i8At4S065/ZIPYKydx81wnWJxTwEfiWv8ydojF3hLdDfNYJjAKLGBkWMWoXpx aVJZapGukl1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kRGFgMQLCDcdlfp0OMkhxM SqK8le7MkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeKemAeUEi1LTUyvSMnOAIQ6TluDgURLhl QBJ8xYXJOYWZ6ZDpE4xGnO8uPz+PRPHk5U/3jMJseTl56VKifMeACkVACnNKM2DGwSLvUuMsl LCvIxApwnxFKQW5WaWoMq/YhTnYFQS5p0GMoUnM68Ebt8roFOYgE5hcWEAOaUkESEl1cCo7CH /z7h7lt7z7rDZ1ierEu83JU8qjqrYVxN3z2wGR0ewwdP9qreuVhzQdr/oHM2g9inaND5+hikf x6foGXu+fXMNWR2Q2Gag2rZDV7DzU8iNqeHLF2+qkxb54ZZ8dKZV++zOJ47nTLaKna+vOv989 fuDZR1NntOLFq+IcOZ8teJPe9Q/ZgElluKMREMt5qLiRAAQY2R8uAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-27.messagelabs.com!1493395311!89252860!1 X-Originating-IP: [209.85.192.172] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63166 invoked from network); 28 Apr 2017 16:01:52 -0000 Received: from mail-pf0-f172.google.com (HELO mail-pf0-f172.google.com) (209.85.192.172) by server-8.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:01:52 -0000 Received: by mail-pf0-f172.google.com with SMTP id e64so13271140pfd.1 for ; Fri, 28 Apr 2017 09:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jXBisWG55AUiIV/FKhhGyK5ZsUDhrr6RA8bRgYsactI=; b=UQPypOdWX1UCq+y9qH1YO8NBkti5YJdOVgBIV/e3jBSsYUPvQUerWW1Bd+q5oQiq/O N6RgrZWviw8+oPjp06EXdNkXoMkPihOmT40YoflJSqTqnDSamtteBxjMORXFKr97Kew1 PckznYWijpkzeCnowdIlzewB+PSeF9FmoOpkE= 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=jXBisWG55AUiIV/FKhhGyK5ZsUDhrr6RA8bRgYsactI=; b=Rxn9M3suvIIbypYxKGyfcQx1nRndrLf83EOmyz91XN87RrTNHh5chcKSELmcQ0WnF1 d2vX1FM2wRYgnmI2h98kgqQ62OPvoIeBTiwbOVtW36tQWbklS4Wdb8BE9sgenyR8ZTK4 WUS+zaxHncSRXNiJ4YOR2OfRT/yMlMmbNAxSlHuPbV7GfMublzl0H3tfO2IB7dm2ue+H lcP70Xx8OnWU5evBST1t7J4L5s5YZNuTFRqgRAy8sjP/gFbeCuYKt+govAjjDqiwanYh Hm1JU+h2wpXUiw6g9C9EkVRdnkdJJr/aBXfw10w6NFYFF+EAwt0fLcqExi63u5SQ6Mb6 t0Ag== X-Gm-Message-State: AN3rC/7QIcAM9Vr8MBwUD9F8yIHZSoUmRZkykZGShlOrI95pn0nVdQe4 l9bwOxaGBGpdI++Q X-Received: by 10.84.224.136 with SMTP id s8mr16121233plj.93.1493395311147; Fri, 28 Apr 2017 09:01:51 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.01.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:01:50 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:19 +0530 Message-Id: <1493395284-18430-6-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 05/10 v2] xen/arm: vpl011: Allocate a new PFN 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 pfn and pass on to Xen using a domctl call. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini --- Changes since v1: - Replaced the hvm call with the domctl call to set the pfn. tools/libxc/include/xc_dom.h | 2 ++ tools/libxc/xc_dom_arm.c | 7 ++++++- tools/libxc/xc_dom_boot.c | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index ce47058..ca8bc23 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_pfn; }; /* --- pluggable kernel loader ------------------------------------- */ diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index e7d4bd0..ad805d1 100644 --- a/tools/libxc/xc_dom_arm.c +++ b/tools/libxc/xc_dom_arm.c @@ -26,10 +26,11 @@ #include "xg_private.h" #include "xc_dom.h" -#define NR_MAGIC_PAGES 3 +#define NR_MAGIC_PAGES 4 #define CONSOLE_PFN_OFFSET 0 #define XENSTORE_PFN_OFFSET 1 #define MEMACCESS_PFN_OFFSET 2 +#define VUART_PFN_OFFSET 3 #define LPAE_SHIFT 9 @@ -85,16 +86,20 @@ 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_pfn = 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, dom->xenstore_pfn); xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_MONITOR_RING_PFN, base + MEMACCESS_PFN_OFFSET); + xc_domain_vuart_set_pfn(dom->xch, dom->guest_domid, base + VUART_PFN_OFFSET); + /* allocated by toolstack */ xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CONSOLE_EVTCHN, dom->console_evtchn); diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c index c3b44dd..5e4b322 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_pfn)) != 0 ) + return rc; /* start info page */ if ( dom->arch_hooks->start_info ) From patchwork Fri Apr 28 16:01: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: 98368 Delivered-To: patch@linaro.org Received: by 10.182.236.104 with SMTP id ut8csp392040obc; Fri, 28 Apr 2017 09:03:44 -0700 (PDT) X-Received: by 10.107.15.146 with SMTP id 18mr10907893iop.128.1493395424313; Fri, 28 Apr 2017 09:03:44 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e99si330813itd.86.2017.04.28.09.03.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:03:44 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1d48LG-0000Dg-LJ; Fri, 28 Apr 2017 16:01:58 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48LF-0000Cz-Rz for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:01:57 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 39/08-01735-57763095; Fri, 28 Apr 2017 16:01:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIIsWRWlGSWpSXmKPExsXiVRtspFuSzhx p8H+zosX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvF+wgPmgltiFQcaJjA1MK4R6mLk4hASmM4o 0br9FxuIwyIwj1li34aVjCCOhEA/q0RD73OWLkZOICdNYs6NJ+wQdpXE7ZlzmEBsIQEtiaOnZ rNCjGpmklj0ZSbQKA4ONgETiVkdEiA1IgJKEvdWTWYCqWEWeMso0f/xFCtIQlggRKKvp48ZxG YRUJXY8vMXWJxXwFti4pomZohlchI3z3WC2ZwCPhLX+pexQyz2luhumMcygVFgASPDKkaN4tS istQiXSMLvaSizPSMktzEzBxdQwNTvdzU4uLE9NScxKRiveT83E2MwOCqZ2Bg3MHYt8rvEKMk B5OSKG+lO3OkEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQlegTSgnGBRanpqRVpmDjDMYdISHDxKI rwSIGne4oLE3OLMdIjUKUZdjkcrf7xnEmLJy89LlRLnjQApEgApyijNgxsBi7lLjLJSwryMDA wMQjwFqUW5mSWo8q8YxTkYlYR5c0Cm8GTmlcBtegV0BBPQESwuDCBHlCQipKQaGK3dLnqxTFh 9QNiaR9jkkH5fi96akuDHpS3ui/SbL7fPn/7x4Da5s7t3/V/m9FPIz7WvJH2Sdsa9X0tcOK71 yh1+2WLw7syyJY8yNlqmT7/xqfxm4JEvN1m7o6w311Yu2LrsSkfLjSWMf1r+/jwqGHec/WGAb RJPVo+PRzL3tpzOkFM+kluy3yqxFGckGmoxFxUnAgDD6XPJtAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-206.messagelabs.com!1493395315!56769883!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.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29313 invoked from network); 28 Apr 2017 16:01:56 -0000 Received: from mail-pg0-f50.google.com (HELO mail-pg0-f50.google.com) (74.125.83.50) by server-14.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:01:56 -0000 Received: by mail-pg0-f50.google.com with SMTP id y4so11663485pge.0 for ; Fri, 28 Apr 2017 09:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UeptOIno1pL+/p2UD3QbFyGbPoX+EgQCAdQRJvBJ7Yg=; b=jw2WV6yhtxk1mPz10JSSqeH9nc51s2g4irUrPejc3aeNDpUtj3eujJhLtToasY89ZS hm1wQF5+b4YSr6iXJ8GcYs8l6z5VysHKuIAi/S3lVyi3RlF+OV7+UwZt83jHNvu7W4pc znGxBlQ5n+2S3LfdKqZhFaRIb3+cTb6pbFQVs= 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=UeptOIno1pL+/p2UD3QbFyGbPoX+EgQCAdQRJvBJ7Yg=; b=h5RMfW3IW6iG4B4dmzux3HkK8CEV82OsKwrbU5QTZls5fHUT6PAs+eOp3UOaWB5dQL CUOVdsqF0arTAtH86yM+wBJh1v/tshrOKV9fS5rNHjsTCDLePDbVFy9ikzHOvW01yR/N YZk5dgBZ7J5ueODEqZIiaV885VHWcQzy5iA3Li+IfsFzz2I7ZiQne+84s/IN4s8sejMJ 3vl/J3T/UuNFzkjTU36kLTxRWV+R44IGfxna4/ZJdD5wVGHG9TJ20i5eFQbd8OMfwx2E I00B4Q2UloT9AIT/rkLQ2Iduo+dzlbVYxVoNb4MTquDCT600VEZl9hPo9YSxEgKiFRfz EWcA== X-Gm-Message-State: AN3rC/4ghBvcDN1mnsOmAvKLVyUYZ6uQdC5YXJrEcL+UADjuKivNOXcx vLoGJCgcPMnZ3lnvDRINZQ== X-Received: by 10.98.36.154 with SMTP id k26mr12757112pfk.174.1493395314822; Fri, 28 Apr 2017 09:01:54 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.01.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:01:54 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:20 +0530 Message-Id: <1493395284-18430-7-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 06/10 v2] xen/arm: vpl011: Add vuart ring-buf and evtchn to 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 two new parameters to the xen store to be used by xenconsoled: - newly allocated PFN to be used as IN/OUT ring buffer - get a new event channel allocated by Xen using a domctl call These paramters are added to xenstore only if vuart console is enabled by the user. Signed-off-by: Bhupinder Thakur --- Changes since v1: - Modified the xenstore key names to /vuart/0/ring-ref and /vuart/0/port. - Replaced the hvm call with domctl call to get the event channel. tools/libxl/libxl_console.c | 10 ++++++++++ tools/libxl/libxl_dom.c | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 446e766..ef3bd44 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; } @@ -326,6 +329,13 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t domid, flexarray_append(ro_front, GCSPRINTF("%"PRIu32, state->console_port)); flexarray_append(ro_front, "ring-ref"); flexarray_append(ro_front, GCSPRINTF("%lu", state->console_mfn)); + if (state->vuart_enabled) + { + flexarray_append(ro_front, "vuart/0/port"); + flexarray_append(ro_front, GCSPRINTF("%"PRIu32, state->vuart_port)); + flexarray_append(ro_front, "vuart/0/ring-ref"); + flexarray_append(ro_front, GCSPRINTF("%lu", state->vuart_mfn)); + } } else { flexarray_append(front, "state"); flexarray_append(front, GCSPRINTF("%d", XenbusStateInitialising)); diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 5d914a5..06ff3b7 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -434,6 +434,9 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->store_domid); state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->console_domid); + if (state->vuart_enabled) + xc_domain_vuart_get_evtchn(ctx->xch, domid, &state->vuart_port); + if (info->type == LIBXL_DOMAIN_TYPE_HVM) { hvm_set_conf_params(ctx->xch, domid, info); #if defined(__i386__) || defined(__x86_64__) @@ -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_mfn = dom->vuart_pfn; } else { state->console_mfn = xc_dom_p2m(dom, dom->console_pfn); state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); From patchwork Fri Apr 28 16:01: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: 98376 Delivered-To: patch@linaro.org Received: by 10.182.236.104 with SMTP id ut8csp392187obc; Fri, 28 Apr 2017 09:04:00 -0700 (PDT) X-Received: by 10.36.213.3 with SMTP id a3mr10545450itg.106.1493395440881; Fri, 28 Apr 2017 09:04:00 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id y189si6788024iod.0.2017.04.28.09.04.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:04:00 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1d48LK-0000GJ-TJ; Fri, 28 Apr 2017 16:02:02 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48LK-0000Fb-40 for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:02:02 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id F7/F3-03920-97763095; Fri, 28 Apr 2017 16:02:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRusr1uRzhx pMLNb2uL7lslMDowehz9cYQlgjGLNzEvKr0hgzWjes5Kt4NMexopdu5IaGHfMZOxi5OIQEpjO KLH27Ecwh0VgHrPExT+v2UEcCYF+VomLV6eydjFyAjlxEme2zmKCsCslbjSuZwaxhQS0JI6em s0KYTczSUze79DFyMHBJmAiMatDAiQsIqAkcW/VZCaQmcwCbxkl+j+eAqsXFvCT6Pl6nA3EZh FQlVj79iBYnFfAW2L69SNsELvkJG6e6wTbxSngI3Gtfxk7xC5vie6GeSwTGAUWMDKsYtQoTi0 qSy3SNbLQSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCrWS87P3cQIDC4GINjBeH5t4CFGSQ4m JVHeSnfmSCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvFPTgHKCRanpqRVpmTnAMIdJS3DwKInwS oCkeYsLEnOLM9MhUqcYjTneLf3wnonj0cof75mEWPLy81KlxHkjQEoFQEozSvPgBsHi7xKjrJ QwLyPQaUI8BalFuZklqPKvGMU5GJWEeaeBTOHJzCuB2/cK6BQmoFNYXBhATilJREhJNTAqfV0 t1fFq57W4yU33vF8eWtC2RsXEc7ph7ZTNQqcyRd++YLNgz3q350yJE3fb1C9TWWs519wNCrQN 7mh8ej6uK3e+isLvT1ZxZ4VEL+xmMmDds1JsyVRRQ4Orp58zxnPe7nGfdGHbOrO1PjfvTrFZm 2vS+NZl205uPtlv7Nee7znSmayqx2CuxFKckWioxVxUnAgAbHYWVboCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-27.messagelabs.com!1493395319!68974487!1 X-Originating-IP: [74.125.83.47] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19609 invoked from network); 28 Apr 2017 16:02:00 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-11.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:02:00 -0000 Received: by mail-pg0-f47.google.com with SMTP id o3so11675716pgn.2 for ; Fri, 28 Apr 2017 09:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T+QoVcpzs+DB91vJ3HJEcF2PySDtPlPR+bGeVWMLG0o=; b=hq0WrenmWcha5ggbwo3oa/K4J9KZq29O3ICPjEMzUjMqUPudSNA+fKuLfM4P5N2LOE OLERRkDiGKA066OC6cMuEyW4lYO8JV3iy2xA5EvxhRl2QdKef+WdAq2SAnK+HvlZv0b6 g1tBXqbuZZi1TBc/Kz6x1EPqKX53zGuzjtino= 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=T+QoVcpzs+DB91vJ3HJEcF2PySDtPlPR+bGeVWMLG0o=; b=lSJJNIGj2BrP5+5ICcCFbwvxuuJiH0c4P7xR5uHxeP+2Uao11QKFMbS0TNXstqdRXc xrdAK3ixOO0CGoVxJetkC73MrFIPVdvcW5MVmeS/xj7hvJbfv3CgkLd3GByuzraLIa7+ R3hUv7vPXm0S3bvBiIXVl396MPR2r82ygMkvJaDWPr9Ty6jjsIq+NIjvNQzN2qCa7V68 TnDiTZHqryxq9sJ5TeOArIJekWny9GQePAypCN5+A+rzHcZUN0ZEXlQa7aHFwl4Nhet9 UoOpvLhR2mgZNx5IaYJDEetKzle6rCf731qr1i/vquyI0CDkyqQdDrPlhIH7rtZoyZG0 El+Q== X-Gm-Message-State: AN3rC/78nkwLaTwHHtzJ3LJ7lIR6a0Oy3mO/ZGmE+iQbU6cumj/FDlzr vCCZA5vAguS+1VV7 X-Received: by 10.99.144.65 with SMTP id a62mr12898831pge.12.1493395318346; Fri, 28 Apr 2017 09:01:58 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.01.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:01:57 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:21 +0530 Message-Id: <1493395284-18430-8-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 07/10 v2] xen/arm: vpl011: Add support for vuart 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" Xenconsole supports only PV console currently. This patch adds support for vuart, which allows emulated pl011 uart to be accessed as a console. This patch modifies different data structures and APIs used in xenconsole to support two console types: PV and VUART. Change summary: 1. Split the domain structure into a console structure and the domain structure. Each PV and VUART will have seprate console structures. 2. Modify different APIs such as buffer_append() etc. to take console structure as input and perform per console specific operations. 3. Modfications in domain_create_ring(): - Bind to the vpl011 event channel obtained from the xen store as a new parameter. - Map the PFN to its address space to be used as IN/OUT ring buffers. It obtains the PFN from the xen store as a new parameter 4. Modifications in handle_ring_read() to handle both PV and VUART events. 5. Add a new log_file for VUART console logs. Signed-off-by: Bhupinder Thakur --- 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 | 514 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 365 insertions(+), 149 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 7e6a886..55fda37 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -61,6 +61,10 @@ /* Duration of each time period in ms */ #define RATE_LIMIT_PERIOD 200 +#define MAX_CONSOLE 2 +#define CONSOLE_TYPE_PV 0 +#define CONSOLE_TYPE_VUART 1 + extern int log_reload; extern int log_guest; extern int log_hv; @@ -89,29 +93,75 @@ struct buffer { size_t max_capacity; }; -struct domain { - int domid; +struct console { + char *name; + char *ttyname; 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; /* Reference to the domain it is contained in. */ +}; + +struct domain { + int domid; + bool is_dead; + unsigned last_seen; + struct domain *next; + char *conspath; xenevtchn_handle *xce_handle; int xce_pollfd_idx; - struct xencons_interface *interface; int event_count; long long next_period; + struct console console[MAX_CONSOLE]; }; static struct domain *dom_head; +static inline bool console_enabled(struct console *con) { return con->local_port != -1; } + +static inline void console_iter_no_check(struct domain *d, void (* iter_func)(struct console *)) +{ + int i = 0; + struct console *con = &(d->console[0]); + + for (i=0; i < MAX_CONSOLE; i++, con++) + { + iter_func(con); + } +} + +static inline bool console_iter_bool_check(struct domain *d, bool (* iter_func)(struct console *)) +{ + 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_err_check(struct domain *d, int (* iter_func)(struct console *)) +{ + int i = 0; + struct console *con = &(d->console[0]); + + for (i=0; i < MAX_CONSOLE; i++, con++) + { + if (!iter_func(con)) + return 0; + } + return 1; +} + static int write_all(int fd, const char* buf, size_t len) { while (len) { @@ -158,11 +208,24 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } -static void buffer_append(struct domain *dom) +static inline bool buffer_available(struct console *con) +{ + if (discard_overflowed_data || + !con->buffer.max_capacity || + con->buffer.size < con->buffer.max_capacity) + return true; + else + return false; +} + +static void buffer_append(struct console *con) { - struct buffer *buffer = &dom->buffer; + struct buffer *buffer = &con->buffer; + struct xencons_interface *intf = con->interface; + xenevtchn_port_or_error_t port = con->local_port; + struct domain *dom = con->d; + XENCONS_RING_IDX cons, prod, size; - struct xencons_interface *intf = dom->interface; cons = intf->out_cons; prod = intf->out_prod; @@ -187,22 +250,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, 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); } @@ -290,12 +353,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); @@ -314,7 +378,8 @@ static int create_domain_log(struct domain *dom) 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, con->name, data); free(data); logfile[PATH_MAX-1] = '\0'; @@ -336,19 +401,24 @@ 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) { - if (dom->master_fd != -1) { - close(dom->master_fd); - dom->master_fd = -1; + 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; } } +static void domain_close_tty(struct domain *dom) +{ + console_iter_no_check(dom, console_close_tty); +} + #ifdef __sun__ static int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp) @@ -409,7 +479,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; @@ -418,19 +488,23 @@ static int domain_create_tty(struct domain *dom) char *data; unsigned int len; struct termios term; + struct domain *dom = con->d; + + if (!console_enabled(con)) + return 1; - assert(dom->slave_fd == -1); - assert(dom->master_fd == -1); + assert(con->master_fd == -1); + assert(con->slave_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)", - dom->domid, err, strerror(err)); - return 0; + "(errno = %i, %s)", + dom->domid, err, strerror(err)); + goto out; } - 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 +512,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,11 +520,11 @@ 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)", - dom->domid, err, strerror(err)); + "(errno = %i, %s)", + dom->domid, err, strerror(err)); goto out; } @@ -460,27 +534,41 @@ static int domain_create_tty(struct domain *dom) 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/%s", dom->conspath, con->ttyname) != -1); + if (!success) goto out; success = xs_write(xs, XBT_NULL, path, slave, strlen(slave)); free(path); - if (!success) + + if (fcntl(con->master_fd, F_SETFL, O_NONBLOCK) == -1) goto out; - if (fcntl(dom->master_fd, F_SETFL, O_NONBLOCK) == -1) + if (!success) goto out; return 1; + out: - domain_close_tty(dom); return 0; } + +static int domain_create_tty(struct domain *dom) +{ + int ret; + + ret = console_iter_err_check(dom, console_create_tty); + + if (!ret) + domain_close_tty(dom); + + return ret; +} /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */ static int xs_gather(struct xs_handle *xs, const char *dir, ...) @@ -517,22 +605,64 @@ 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) { - if (dom->interface == NULL) + 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 void domain_unmap_interface(struct domain *dom) +{ + console_iter_no_check(dom, console_unmap_interface); +} + +static int bind_event_channel(struct domain *dom, + int new_rport, + int *lport, + int *rport) +{ + int err = 0, rc; + + /* Go no further if port has not changed and we are still bound. */ + if (new_rport == *rport) { + xc_evtchn_status_t status = { + .dom = DOMID_SELF, + .port = *lport }; + if ((xc_evtchn_status(xc, &status) == 0) && + (status.status == EVTCHNSTAT_interdomain)) + goto out; + } + + *lport = -1; + *rport = -1; + rc = xenevtchn_bind_interdomain(dom->xce_handle, + dom->domid, new_rport); + + if (rc == -1) { + err = errno; + xenevtchn_close(dom->xce_handle); + dom->xce_handle = NULL; + goto out; + } + + *lport = rc; + *rport = new_rport; +out: + return err; } static int domain_create_ring(struct domain *dom) { - int err, remote_port, ring_ref, rc; + int err, remote_port, ring_ref, vuart_remote_port, vuart_ring_ref; char *type, path[PATH_MAX]; + struct console *pv_con = &dom->console[CONSOLE_TYPE_PV]; + struct console *vuart_con = &dom->console[CONSOLE_TYPE_VUART]; err = xs_gather(xs, dom->conspath, "ring-ref", "%u", &ring_ref, @@ -541,6 +671,17 @@ static int domain_create_ring(struct domain *dom) if (err) goto out; + /* vuart is optional. */ + err = xs_gather(xs, dom->conspath, + "vuart/0/ring-ref", "%u", &vuart_ring_ref, + "vuart/0/port", "%i", &vuart_remote_port, + NULL); + if (err) + { + vuart_remote_port = -1; + vuart_ring_ref = -1; + } + snprintf(path, sizeof(path), "%s/type", dom->conspath); type = xs_read(xs, XBT_NULL, path, NULL); if (type && strcmp(type, "xenconsoled") != 0) { @@ -550,41 +691,50 @@ 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) - domain_unmap_interface(dom); + if (ring_ref != pv_con->ring_ref && pv_con->ring_ref != -1) + console_unmap_interface(pv_con); - if (!dom->interface && xgt_handle) { + /* If using vuart ring_ref and it has changed, remap */ + if (vuart_ring_ref != vuart_con->ring_ref && + vuart_con->ring_ref != -1 ) + console_unmap_interface(vuart_con); + + if (!pv_con->interface && xgt_handle) { /* Prefer using grant table */ - dom->interface = xengnttab_map_grant_ref(xgt_handle, - dom->domid, GNTTAB_RESERVED_CONSOLE, - PROT_READ|PROT_WRITE); - dom->ring_ref = -1; + pv_con->interface = xengnttab_map_grant_ref(xgt_handle, + dom->domid, GNTTAB_RESERVED_CONSOLE, + PROT_READ|PROT_WRITE); + pv_con->ring_ref = -1; } - if (!dom->interface) { + if (!pv_con->interface) { /* Fall back to xc_map_foreign_range */ - dom->interface = xc_map_foreign_range( + pv_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 (pv_con->interface == NULL) { err = EINVAL; goto out; } - dom->ring_ref = ring_ref; + pv_con->ring_ref = ring_ref; } - /* Go no further if port has not changed and we are still bound. */ - if (remote_port == dom->remote_port) { - xc_evtchn_status_t status = { - .dom = DOMID_SELF, - .port = dom->local_port }; - if ((xc_evtchn_status(xc, &status) == 0) && - (status.status == EVTCHNSTAT_interdomain)) - goto out; + /* Map vuart console ring buffer. */ + if ((vuart_remote_port != -1) && !vuart_con->interface) { + + vuart_con->interface = xc_map_foreign_range(xc, + dom->domid, + XC_PAGE_SIZE, + PROT_READ|PROT_WRITE, + (unsigned long)vuart_ring_ref); + + if (vuart_con->interface == NULL) { + err = EINVAL; + goto out1; + } + vuart_con->ring_ref = vuart_ring_ref; } - dom->local_port = -1; - dom->remote_port = -1; if (dom->xce_handle != NULL) xenevtchn_close(dom->xce_handle); @@ -593,35 +743,55 @@ static int domain_create_ring(struct domain *dom) dom->xce_handle = xenevtchn_open(NULL, 0); if (dom->xce_handle == NULL) { err = errno; - goto out; + goto out2; } - rc = xenevtchn_bind_interdomain(dom->xce_handle, - dom->domid, remote_port); - - if (rc == -1) { - err = errno; + err = bind_event_channel(dom, remote_port, + &pv_con->local_port, + &pv_con->remote_port); + if (err) + { xenevtchn_close(dom->xce_handle); - dom->xce_handle = NULL; - goto out; + goto out2; + } + + if (vuart_remote_port != -1) + { + err = bind_event_channel(dom, vuart_remote_port, + &vuart_con->local_port, + &vuart_con->remote_port); + if (err) + { + xenevtchn_close(dom->xce_handle); + goto out2; + } } - dom->local_port = rc; - dom->remote_port = remote_port; - if (dom->master_fd == -1) { + if (pv_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; - goto out; + pv_con->local_port = -1; + pv_con->remote_port = -1; + vuart_con->local_port = -1; + vuart_con->remote_port = -1; + goto out2; } } - if (log_guest && (dom->log_fd == -1)) - dom->log_fd = create_domain_log(dom); + if (log_guest && (pv_con->log_fd == -1)) + pv_con->log_fd = create_console_log(pv_con); + + if (log_guest && (vuart_remote_port != -1) && (vuart_con->log_fd == -1)) + vuart_con->log_fd = create_console_log(vuart_con); + return err; + + out2: + console_unmap_interface(vuart_con); + out1: + console_unmap_interface(pv_con); out: return err; } @@ -645,6 +815,19 @@ static bool watch_domain(struct domain *dom, bool watch) return success; } +static void console_init(struct domain *d, struct console *con, char *name, char *ttyname) +{ + 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->name = name; + con->ttyname = ttyname; + con->d = d; +} static struct domain *create_domain(int domid) { @@ -675,18 +858,13 @@ static struct domain *create_domain(int domid) dom->conspath = s; strcat(dom->conspath, "/console"); - dom->master_fd = -1; - dom->master_pollfd_idx = -1; - dom->slave_fd = -1; - dom->log_fd = -1; + console_init(dom, &dom->console[CONSOLE_TYPE_PV], "pv", "tty"); + console_init(dom, &dom->console[CONSOLE_TYPE_VUART], "vuart", "vtty"); + 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; - if (!watch_domain(dom, true)) goto out; @@ -727,17 +905,22 @@ static void remove_domain(struct domain *dom) } } + +static void console_cleanup(struct console *con) +{ + if (con->log_fd != -1) { + close(con->log_fd); + con->log_fd = -1; + } + free(con->buffer.data); + con->buffer.data = NULL; +} + static void cleanup_domain(struct domain *d) { domain_close_tty(d); - if (d->log_fd != -1) { - close(d->log_fd); - d->log_fd = -1; - } - - free(d->buffer.data); - d->buffer.data = NULL; + console_iter_no_check(d, console_cleanup); free(d->conspath); d->conspath = NULL; @@ -749,7 +932,9 @@ static void shutdown_domain(struct domain *d) { d->is_dead = true; watch_domain(d, false); + domain_unmap_interface(d); + if (d->xce_handle != NULL) xenevtchn_close(d->xce_handle); d->xce_handle = NULL; @@ -780,9 +965,9 @@ static void enum_domains(void) } } -static int ring_free_bytes(struct domain *dom) +static int ring_free_bytes(struct console *con) { - struct xencons_interface *intf = dom->interface; + struct xencons_interface *intf = con->interface; XENCONS_RING_IDX cons, prod, space; cons = intf->in_cons; @@ -807,25 +992,27 @@ static void domain_handle_broken_tty(struct domain *dom, int recreate) } } -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 xencons_interface *intf = dom->interface; XENCONS_RING_IDX prod; + struct xencons_interface *intf = con->interface; + xenevtchn_port_or_error_t port = con->local_port; + struct domain *dom = con->d; if (dom->is_dead) return; - len = ring_free_bytes(dom); + len = ring_free_bytes(con); if (len == 0) return; 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,34 +1028,44 @@ 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, port); } else { domain_close_tty(dom); shutdown_domain(dom); } } -static void handle_tty_write(struct domain *dom) +static void handle_tty_write(struct console *con) { ssize_t len; + struct domain *dom = con->d; if (dom->is_dead) return; - len = write(dom->master_fd, dom->buffer.data + dom->buffer.consumed, - dom->buffer.size - dom->buffer.consumed); + len = write(con->master_fd, + con->buffer.data + con->buffer.consumed, + con->buffer.size - con->buffer.consumed); if (len < 1) { dolog(LOG_DEBUG, "Write failed on domain %d: %zd, %d\n", dom->domid, len, errno); domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); } else { - buffer_advance(&dom->buffer, len); + buffer_advance(&con->buffer, len); } } +static void 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 *pv_con = &dom->console[CONSOLE_TYPE_PV]; + struct console *vuart_con = &dom->console[CONSOLE_TYPE_VUART]; if (dom->is_dead) return; @@ -878,10 +1075,13 @@ static void handle_ring_read(struct domain *dom) dom->event_count++; - buffer_append(dom); + if (port == vuart_con->local_port) + buffer_append(vuart_con); + else + buffer_append(pv_con); if (dom->event_count < RATE_LIMIT_ALLOWANCE) - (void)xenevtchn_unmask(dom->xce_handle, port); + console_iter_no_check(dom, console_event_unmask); } static void handle_xs(void) @@ -943,14 +1143,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) { - if (d->log_fd != -1) - close(d->log_fd); - d->log_fd = create_domain_log(d); + console_iter_no_check(d, console_open_log); } } @@ -1002,6 +1210,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)) + domain_handle_broken_tty(con->d, 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; @@ -1068,7 +1310,7 @@ 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); + console_iter_no_check(d, console_event_unmask); } d->event_count = 0; } @@ -1081,28 +1323,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 || - !d->buffer.max_capacity || - d->buffer.size < d->buffer.max_capacity) { + if (console_iter_bool_check(d, buffer_available)) + { int evtchn_fd = xenevtchn_fd(d->xce_handle); d->xce_pollfd_idx = set_fds(evtchn_fd, - POLLIN|POLLPRI); + POLLIN|POLLPRI); } } - if (d->master_fd != -1) { - short events = 0; - if (!d->is_dead && ring_free_bytes(d)) - events |= POLLIN; - - if (!buffer_empty(&d->buffer)) - events |= POLLOUT; - - if (events) - d->master_pollfd_idx = - set_fds(d->master_fd, - events|POLLPRI); - } + console_iter_no_check(d, add_console_fd); } /* If any domain has been rate limited, we need to work @@ -1170,22 +1399,9 @@ 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 & - ~(POLLIN|POLLOUT|POLLPRI)) - domain_handle_broken_tty(d, - domain_is_valid(d->domid)); - else { - if (fds[d->master_pollfd_idx].revents & - POLLIN) - handle_tty_read(d); - if (fds[d->master_pollfd_idx].revents & - POLLOUT) - handle_tty_write(d); - } - } + console_iter_no_check(d, process_console); - d->xce_pollfd_idx = d->master_pollfd_idx = -1; + d->xce_pollfd_idx = -1; if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Fri Apr 28 16:01: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: 98374 Delivered-To: patch@linaro.org Received: by 10.182.236.104 with SMTP id ut8csp392173obc; Fri, 28 Apr 2017 09:03:59 -0700 (PDT) X-Received: by 10.107.162.4 with SMTP id l4mr10490600ioe.169.1493395439103; Fri, 28 Apr 2017 09:03:59 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id p140si6473978iod.111.2017.04.28.09.03.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:03:59 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1d48LP-0000Kg-8n; Fri, 28 Apr 2017 16:02:07 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48LN-0000IF-Cf for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:02:05 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id 20/FF-02181-C7763095; Fri, 28 Apr 2017 16:02:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsVyMfTAVt2adOZ Ig0tPGS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy1ex+xFrTwVXRsncvcwPiFq4uRi0NIYCaj xMYrm1lBHBaBecwSO48eZwNxJAT6WSXWrrvP3sXIAeSkSfSuiO9i5AQyyyXWNMxnBbGFBLQkj p6azQoxqZlJ4tPB3Ywg9WwCJhKzOiRAakQElCTurZrMBFLDLPCWUaL/4ymwZmGBGIkpBzcxg9 gsAqoSm9d0sIHYvALeElOPfGSCWCYncfNcJ1gNp4CPxLX+ZewQi70luhvmsUxgFFjAyLCKUaM 4tagstUjXyEQvqSgzPaMkNzEzR9fQwFQvN7W4ODE9NScxqVgvOT93EyMwtOoZGBh3MN6c7HeI UZKDSUmUt9KdOVKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBK9AGlBOsCg1PbUiLTMHGOQwaQkOH iURXgmQNG9xQWJucWY6ROoUozHHi8vv3zNxPFn54z2TEEtefl6qlDhvVypQqQBIaUZpHtwgWP RdYpSVEuZlZGBgEOIpSC3KzSxBlX/FKM7BqCTMmwOykCczrwRu3yugU5iATmFxYQA5pSQRISX VwCgUsnbPlbk+c9W9zA7Z8PzQ9dDjK6iW22FZuHIPE1tqx8mC7kpnNhkZ5fUKdVOSWjXf3koW XrTrUWGo0IG722JPyNj8PNlbwiHePjc5r/SJqb9J3a2EBuedzy6fZpvgyR+w5Ooel577Ub8rq raYTjzScFL6drFLIoPEzT8zHnS6nRcq6Z/FqMRSnJFoqMVcVJwIAMuaNnC5AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-206.messagelabs.com!1493395322!91997165!1 X-Originating-IP: [209.85.192.181] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1985 invoked from network); 28 Apr 2017 16:02:03 -0000 Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by server-3.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:02:03 -0000 Received: by mail-pf0-f181.google.com with SMTP id v14so50602907pfd.2 for ; Fri, 28 Apr 2017 09:02: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=6fMh5lhHWEE+Qerk0XI0VNtvzfxHZcId/pqsfB06kZg=; b=EgnX2JBsQEHpvrcAVh80ixxjIgIhGtpWSji4Q9YWkZgzNZAPUlWmmbzk0dhPr5gh+v MZMorn3AtyFQPiwBWhrd7ADaWyn5M/k2yZytrwbYKsDTNigF6tCO4fZ9zlGIh7BpKaI/ 5jrvAw9mioSCgaXGsbTAq1e8EdHuMbOlcsFz4= 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=6fMh5lhHWEE+Qerk0XI0VNtvzfxHZcId/pqsfB06kZg=; b=O3CxEydAcEfuebh+rcR4/DVthHT3oDEprwq70KB/16QIDeAgZkB0Nx8AhnANaBuW+f qRKB6cgcULBmYRZQXtkgUqw7AEqnRbV+g3gIrdNIYSdxL/TY8RBQDnI4b1arON+69lNo K4habTypWia5Prl+qF1puO9bHX9BSzbyEGy+dBZJtQ7qOMWOO32VeB9F9lU0UbwnUOhS gQGCBYtYr0xRgcgJDLGvsGDW7HuiBCmp8bYkkO3cS0Ik0mEQBo8kTcAl223oJh6/doUe JpwXmIBLuhArtlJnA5uLc6zJjL6sEQr3xWnmBUrDjZAdokKw4/6DgMHaB0y7Kk1M9eBP 9FjQ== X-Gm-Message-State: AN3rC/7sQckL3IUUCioGyep97+qnYGCwdbD+rO67shmfMl4aO8J8l2wR Of/2fsoiZVXBrHDtW0+0BA== X-Received: by 10.99.3.212 with SMTP id 203mr12964155pgd.0.1493395321989; Fri, 28 Apr 2017 09:02:01 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.01.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:02:01 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:22 +0530 Message-Id: <1493395284-18430-9-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 08/10 v2] 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 vuart. Signed-off-by: Bhupinder Thakur --- tools/console/client/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index 977779f..ec5c6e1 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -76,7 +76,7 @@ static void usage(const char *program) { "\n" " -h, --help display this help and exit\n" " -n, --num N use console number N\n" - " --type TYPE console type. must be 'pv' or 'serial'\n" + " --type TYPE console type. must be 'pv', 'serial' or 'vuart'\n" " --start-notify-fd N file descriptor used to notify parent\n" , program); } @@ -264,6 +264,7 @@ typedef enum { CONSOLE_INVAL, CONSOLE_PV, CONSOLE_SERIAL, + CONSOLE_VUART, } console_type; static struct termios stdin_old_attr; @@ -361,6 +362,8 @@ int main(int argc, char **argv) type = CONSOLE_SERIAL; else if (!strcmp(optarg, "pv")) type = CONSOLE_PV; + else if (!strcmp(optarg, "vuart")) + type = CONSOLE_VUART; else { fprintf(stderr, "Invalid type argument\n"); fprintf(stderr, "Console types supported are: serial, pv\n"); @@ -436,6 +439,9 @@ int main(int argc, char **argv) else snprintf(path, strlen(dom_path) + strlen("/device/console/%d/tty") + 5, "%s/device/console/%d/tty", dom_path, num); } + if (type == CONSOLE_VUART) { + snprintf(path, strlen(dom_path) + strlen("/console/vtty") + 1, "%s/console/vtty", dom_path); + } /* FIXME consoled currently does not assume domain-0 doesn't have a console which is good when we break domain-0 up. To keep us From patchwork Fri Apr 28 16:01: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: 98373 Delivered-To: patch@linaro.org Received: by 10.182.236.104 with SMTP id ut8csp392160obc; Fri, 28 Apr 2017 09:03:58 -0700 (PDT) X-Received: by 10.36.207.138 with SMTP id y132mr29028itf.82.1493395438070; Fri, 28 Apr 2017 09:03:58 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id r192si7802225ita.50.2017.04.28.09.03.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:03: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 1d48LT-0000Nr-Fj; Fri, 28 Apr 2017 16:02:11 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48LR-0000M3-Bd for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:02:09 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 84/E1-01999-08763095; Fri, 28 Apr 2017 16:02:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRuspduQzhx p8K6X2+L7lslMDowehz9cYQlgjGLNzEvKr0hgzXi5qou9YKl8xf6nl1kbGL+IdzFycQgJTGeU 2HFuPjuIwyIwj1mi5/R+NhBHQqCfVeLC812sXYwcQE6cxM4b9V2MnEBmlcSjIyfYQWwhAS2Jo 6dms0JMamaSmNJ5gwmknk3ARGJWhwRIjYiAksS9VZOZQGqYBd4ySvR/PMUKkhAWiJGY1vCAEc RmEVCVmDwdZDEnB6+Aj8TiDXvZIJbJSdw818kMYnMCxa/1L4Na7C3R3TCPZQKjwAJGhlWM6sW pRWWpRbpmeklFmekZJbmJmTm6hgamermpxcWJ6ak5iUnFesn5uZsYgYHFAAQ7GKc2OB9ilORg UhLlrXRnjhTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwSuQBpQTLEpNT61Iy8wBhjhMWoKDR0mEV wIkzVtckJhbnJkOkTrFqMvxaOWP90xCLHn5ealS4rwRIEUCIEUZpXlwI2DxdolRVkqYlxHoKC GegtSi3MwSVPlXjOIcjErCvNNApvBk5pXAbXoFdAQT0BEsLgwgR5QkIqSkGhjXJ5prZzyOP94 wQ/x31rP5k3ctPxwt0FYgq9w8N/bID6NW3kfpDx7MFsjdtOV66caVDpfzRS1bBW3FNt3P5/n/ +nXFy4Jln1ryj/Cvamyv3rJ99bzSpQWxzPz1e/5+r5pasz5io2arSza74eNqedd3M5IWpG1Iu nZNecorPvmDazLO2aVxx4srsRRnJBpqMRcVJwIADWXXQbICAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-206.messagelabs.com!1493395325!95461757!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.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36478 invoked from network); 28 Apr 2017 16:02:08 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-8.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:02:08 -0000 Received: by mail-pg0-f42.google.com with SMTP id t7so16935849pgt.3 for ; Fri, 28 Apr 2017 09:02: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=PdIMbGJp48Y/2+8oZHjr/KQ/2T50XNCZzlwg16F3AGs=; b=eWl681pYAW8FH2tHHLeXnIP0c3Wtg976uwXloakCYCuvMGtcIMJkYKr/HyC1BWEu1M SL8o3hExmszaoOoSjY2ABn93KJSbDMQKrt+Uah2MXrZhNFoYelQUlOijOCK/Em83nD8z uDTWfGlYgr8g9qp/8ERQa9Tw2OoVsjTgOuRq4= 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=PdIMbGJp48Y/2+8oZHjr/KQ/2T50XNCZzlwg16F3AGs=; b=VGo+ZpAtZcgk6+gNSh1hLOmQZA6eVyyWkA2vYK5CwJTQpwu3DaJ8Ds2Oje8XVMXwIi ASLxx7hSvDHFCIJGTNOh/mXoCyD9AB9S7ubQ1Qgx8xU18DBOF8pdgE4B6KOvCjdoPOTj Dbyl8FjUwqDhkpO0LCL4CoBPzGhd5e/x95sm7PO6T2rc/kNcUghab94WISTQXhbSwiRS m7tNKwIh3DaRvsJr0Furirt5g4tdfcOaEha8ZHQPk4C/vT6dJzofrTpiBfZd8s5Rto8V 1Wb0+iIidfjW6SUnfhDGt+SWf+QhSkfMpGuhfQt1bVWFEpHuVRM2+1yt6X5R3GVZH/hI 6LLg== X-Gm-Message-State: AN3rC/7LQTxgPT7eQgTuCMacyX0sJFDVWPoI142u1gQPK1BcwIZ3rWSu aejUno38RCfYcnra X-Received: by 10.99.122.81 with SMTP id j17mr12968983pgn.111.1493395325495; Fri, 28 Apr 2017 09:02:05 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.02.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:02:05 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:23 +0530 Message-Id: <1493395284-18430-10-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 09/10 v2] 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 Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini --- Changes since v1: - Modified the code to increment nr_spis based on the SPI value reserved for vpl011. - Added a check to verify that physical irq assigment is not conflicting with vpl011 SPI. - Fixed minor indentation issues. tools/libxl/libxl_arm.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..45a56a8 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -43,11 +43,25 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, { uint32_t nr_spis = 0; unsigned int i; + bool vpl011_enabled = !strcmp(d_config->b_info.vuart, "pl011"); + + /* + * If pl011 vuart is enabled then increment the nr_spis to allow allocation + * of SPI VIRQ for pl011. + */ + if (vpl011_enabled) + 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 (vpl011_enabled && irq == GUEST_VPL011_SPI) + { + LOG(ERROR, "Physical IRQ %d conflicting with pl011 SPI\n", irq); + return ERROR_FAIL; + } + if (irq < 32) continue; @@ -130,9 +144,10 @@ static struct arch_info { const char *guest_type; const char *timer_compat; const char *cpu_compat; + const char *uart_compat; } arch_info[] = { - {"xen-3.0-armv7l", "arm,armv7-timer", "arm,cortex-a15" }, - {"xen-3.0-aarch64", "arm,armv8-timer", "arm,armv8" }, + {"xen-3.0-armv7l", "arm,armv7-timer", "arm,cortex-a15", "arm,sbsa-uart" }, + {"xen-3.0-aarch64", "arm,armv8-timer", "arm,armv8", "arm,sbsa-uart" }, }; /* @@ -590,6 +605,38 @@ static int make_hypervisor_node(libxl__gc *gc, void *fdt, return 0; } +static int make_vpl011_uart_node(libxl__gc *gc, void *fdt, + const struct arch_info *ainfo, + struct xc_dom_image *dom) +{ + int res; + gic_interrupt intr; + + res = fdt_begin_node(fdt, "sbsa-pl011"); + if (res) return res; + + res = fdt_property_compat(gc, fdt, 1, ainfo->uart_compat); + if (res) return res; + + res = fdt_property_regs(gc, fdt, ROOT_ADDRESS_CELLS, ROOT_SIZE_CELLS, + 1, + GUEST_PL011_BASE, GUEST_PL011_SIZE); + if (res) return res; + + set_interrupt(intr, GUEST_VPL011_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); + + res = fdt_property_interrupts(gc, fdt, &intr, 1); + if (res) return res; + + /* Use a default baud rate of 115200. */ + fdt_property_u32(fdt, "current-speed", 115200); + + res = fdt_end_node(fdt); + if (res) return res; + + return 0; +} + static const struct arch_info *get_arch_info(libxl__gc *gc, const struct xc_dom_image *dom) { @@ -889,6 +936,9 @@ next_resize: FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) ); FDT( make_hypervisor_node(gc, fdt, vers) ); + if (!strcmp(info->vuart, "pl011")) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) ); From patchwork Fri Apr 28 16:01: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: 98375 Delivered-To: patch@linaro.org Received: by 10.182.236.104 with SMTP id ut8csp392186obc; Fri, 28 Apr 2017 09:04:00 -0700 (PDT) X-Received: by 10.107.203.1 with SMTP id b1mr13036799iog.29.1493395440869; Fri, 28 Apr 2017 09:04:00 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id c2si7374511iof.168.2017.04.28.09.04.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:04:00 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1d48LU-0000P3-N5; Fri, 28 Apr 2017 16:02:12 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d48LT-0000Nl-Rg for xen-devel@lists.xenproject.org; Fri, 28 Apr 2017 16:02:11 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 04/53-02006-38763095; Fri, 28 Apr 2017 16:02:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIIsWRWlGSWpSXmKPExsXiVRusq9uUzhx pcH+xgsX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmrFz0zbmgi6+is/vf7E2MP7h7mLk4hASmM4o sXf5BWYQh0VgHrPEnxn7WEAcCYF+VonuK4eBMpxATpxE45+LjBB2lcTqk5PB4kICWhJHT81mh RjVzCTxtuERkMPBwSZgIjGrQwKkRkRASeLeqslMIDXMAm8ZJfo/nmIFSQgLRErsvXSeBcRmEV CV2DCrhx3E5hXwkVh8+gw7xDI5iZvnOsGWcQLFr/UvY4dY7C3R3TCPZQKjwAJGhlWMGsWpRWW pRbqG5npJRZnpGSW5iZk5uoYGpnq5qcXFiempOYlJxXrJ+bmbGIHBxQAEOxgvnvY8xCjJwaQk ylvpzhwpxJeUn1KZkVicEV9UmpNafIhRhoNDSYJ3ahpQTrAoNT21Ii0zBxjmMGkJDh4lEV4Jk DRvcUFibnFmOkTqFKMux6OVP94zCbHk5eelSonzRoAUCYAUZZTmwY2AxdwlRlkpYV5GoKOEeA pSi3IzS1DlXzGKczAqCfMqgUzhycwrgdv0CugIJqAjWFwYQI4oSURISTUwvr4ezLJmW+93s9M f7fSM37xr8zUMdlvzzO+j3fXo/0WOZ/u4n3RdZrrj7Vlp7WG5cnJHfC5/6ZvXiwuvykY7bbHg D1wX0qx47lKu/cxLDvvO5aoJ5Ru8CLfLVHdXfCYwTeFJQWBc9V+Fgm23zB8cmJkU6sIa9Xb9a av88JSsjlOJV5w2z5ioxFKckWioxVxUnAgAEJNgGrQCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-7.tower-206.messagelabs.com!1493395329!92736874!1 X-Originating-IP: [74.125.83.45] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23305 invoked from network); 28 Apr 2017 16:02:10 -0000 Received: from mail-pg0-f45.google.com (HELO mail-pg0-f45.google.com) (74.125.83.45) by server-7.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Apr 2017 16:02:10 -0000 Received: by mail-pg0-f45.google.com with SMTP id t7so16936575pgt.3 for ; Fri, 28 Apr 2017 09:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J8kraTfJtG96igPrU8pS6Z5yko0GHkWNAtxw1WmFUPM=; b=b6S5CYhl/8aVDiLG4rK4v8xiyLiqt6nXe3OyTeWg0IbTKuiJSgP2ofiT5+kVObIAqv Sib26BvEth8+e30AH6XItgx21gTf92RJGGs/zfcs2yg8OOz5Kfmb/sTeYHBc54q/5g2r j0ggTiUyURhK0g5aY3LY2lncStC/hXqOSf+QQ= 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=J8kraTfJtG96igPrU8pS6Z5yko0GHkWNAtxw1WmFUPM=; b=ZB/+Menus8a1/k7Pivvu9vSV3G2XARwiyiJ2P04WapX8QEAegQkAHwlvyYDbnaIiXD Ra20iGU3XkiRCaj9vuvQhAvas+tmKbqIHufcwjwd0orZxNHYB7mXX/XJWR2E2AClOYU/ K4vy0m9OcsKY/DHKdF7PmtHp7PdfsOdhC+OwLUBF/xXyuFA4X+mEonLCd7tgmSuQ2omI sagTza0WEsgYX33j3PJfA1NBQjGRiG+Bzh6dCOvnVpsgTQZHWCasafjmeoHwRbbIwSj3 AKGmwActRJBacu3GuvzzBPxz9VRCg78Kw/xWGFyuiKxSHBQ34y7w6sVw/vBrP8tXaLFS yd/Q== X-Gm-Message-State: AN3rC/6iUmgSFS0IERvz8fGhwB2nGeSTArmWZo3x6BuDcb18xTvd2+n3 CAKhb9vQsfCBOMDK X-Received: by 10.98.80.156 with SMTP id g28mr12592697pfj.163.1493395329016; Fri, 28 Apr 2017 09:02:09 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id n65sm9870239pga.8.2017.04.28.09.02.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 09:02:08 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 28 Apr 2017 21:31:24 +0530 Message-Id: <1493395284-18430-11-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> References: <1493395284-18430-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 10/10 v2] 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 vuart = "pl011" option added. 2. Update documentation about SPI irq reserved for vpl011. Signed-off-by: Bhupinder Thakur --- docs/man/xl.cfg.pod.5.in | 8 ++++++++ docs/misc/console.txt | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in index 13167ff..44118a8 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -1085,6 +1085,14 @@ Allow a guest to access specific physical IRQs. It is recommended to use this option only for trusted VMs under administrator control. +If vuart console is enabled then irq 32 is reserved for vuart. By default +vuart console is disabled. If user specifies the following option in +the guest config file then vuart console is enabled. + +vuart = "pl011" + +vuart console is currently enabled 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..2455fc7 100644 --- a/docs/misc/console.txt +++ b/docs/misc/console.txt @@ -19,7 +19,19 @@ The first PV console path in xenstore remains: /local/domain/$DOMID/console -the other PV consoles follow the conventional xenstore device path and +The vuart console path in xenstore is defined as: + +/local/domain/$DOMID/console/vuart/0 + +The vuart console provides access to pl011 UART on ARM64 systems. To +enable vuart the following line has to be added the guest configuration +file: + +vuart = "pl011" + +Also the console should be set to "ttyAMA0" instead of "hvc0". + +The other PV consoles follow the conventional xenstore device path and live in: /local/domain/$DOMID/device/console/$DEVID.