From patchwork Mon Apr 3 09:44: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: 96603 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp18541qgd; Mon, 3 Apr 2017 02:47:09 -0700 (PDT) X-Received: by 10.107.59.146 with SMTP id i140mr14915704ioa.100.1491212829812; Mon, 03 Apr 2017 02:47:09 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n192si14258563iod.213.2017.04.03.02.47.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 02:47:09 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1cuyXa-0001MN-QR; Mon, 03 Apr 2017 09:44:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyXZ-0001MH-Qi for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 09:44:49 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id E0/86-04817-19912E85; Mon, 03 Apr 2017 09:44:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXiVRtsoDtB8lG EwZMVnBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aXuYuYClrqK64+3c7WwPg+qYuRi0NIYBaj xOeeBUwgDovAPGaJcytusIM4EgL9rBLtZ+4DOZxATozE/G3rmCDsKomv3y6A2UICWhJHT81mh RjVyiQxZfNaoAYODjYBE4lZHRIgNSICShL3Vk0G28AsMJ9RYm/PWVaQhLCAu8SM5RcZQepZBF Qlrs6LBAnzCnhL3Px3lBFil5zEzXOdzCAlnAI+ErdeJUCs9ZZ4dX8a2wRGgQWMDKsY1YtTi8p Si3QN9ZKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpOK9ZLzczcxAsOKAQh2MO587nSIUZKDSUmU 982dhxFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHhzJR5FCAkWpaanVqRl5gADHCYtwcGjJMI7C STNW1yQmFucmQ6ROsVozLHo3+43TBwf+g+/YRJiycvPS5US590PUioAUppRmgc3CBZ5lxhlpY R5GYFOE+IpSC3KzSxBlX/FKM7BqCTMOw9kCk9mXgncvldApzABnfIE5Ave4pJEhJRUA6OG7j+ vvE8P+s057bz+3vDJkDt0I5ir6oO/yjQdow9HBb/sSrhTXtSmH5K/00Pl/HJrnpUTyqpb3p/w yuqY9+BQzOXKypsMBmGXF1WzXk0Iipoh1LnQUuvKk+Ib5qLRn6OKZJ8wf7y8vPlc2bL3Ocv6n +3u9V7Hn3XeeUJ4F0fXC9O3346Kn1NiKc5INNRiLipOBAC0knaDtwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-12.tower-27.messagelabs.com!1491212686!93728541!1 X-Originating-IP: [74.125.83.48] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35557 invoked from network); 3 Apr 2017 09:44:47 -0000 Received: from mail-pg0-f48.google.com (HELO mail-pg0-f48.google.com) (74.125.83.48) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Apr 2017 09:44:47 -0000 Received: by mail-pg0-f48.google.com with SMTP id x125so115247007pgb.0 for ; Mon, 03 Apr 2017 02:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YloYqwUTUfSBvRRnsFmFA82AONP5vNg7MT4xlFbB4LE=; b=BsjC70NtKu0bytIb/9WGs1y1e/oS2WzFX+NG6S+Z0GKguPPkB27MxD5U0xUVsopaHj oscAwO38BXZjfKE0CLCT5OgFhNmRyKKsC0QVkPHCSIQQr5vdlPTyRrSpbhFmJkdxLL6D t2I5zTijqI385JWDz06MUh3AdhzYf5P1lXQoI= 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=YloYqwUTUfSBvRRnsFmFA82AONP5vNg7MT4xlFbB4LE=; b=KQwu9q7qe1AeEIXx/iHIdISmTin+jNuuQd+iMNZRQdN/bjZC52AoDx9EXhaLGORboW f3LH0do7Dcz3rGKzle1NNY3NiMTxu+KPl8ZrVJ08l+r3CiJYlH/Qjb7oCWbfr4zx8HXQ Rnfd82bEU7lpHdEFgfOY/izxybp+we+W7xEMQukMwx8tPV/SRWPXD+yidXMgTBCX6WF9 gp3rE02Boc+GMMkIvTcntwL9Rb8qoJt1v6cIvUEgjaYJg0+ufbleo2dSwu2OrlMTIz6b vhakDb46pBB3IipNL62EgYvFWZKcTV8jAXP3t/z3LRtCKuZxRf5dz+nic8exrNA4Y1tu u/rg== X-Gm-Message-State: AFeK/H37xkX6I1eNmTLNPgLSKPP2HvURlTex7yO0TEPYwzQYxo3A8lXvORSkxY7e8eMy2FPc X-Received: by 10.84.232.131 with SMTP id i3mr20560846plk.172.1491212686280; Mon, 03 Apr 2017 02:44:46 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([202.46.23.54]) by smtp.gmail.com with ESMTPSA id y7sm24751844pfk.93.2017.04.03.02.44.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:44:45 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 3 Apr 2017 15:14:24 +0530 Message-Id: <1491212673-13476-2-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> References: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 01/10] 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 --- xen/arch/arm/Kconfig | 5 + xen/arch/arm/Makefile | 1 + xen/arch/arm/vpl011.c | 339 +++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/domain.h | 5 + xen/include/asm-arm/pl011-uart.h | 2 + xen/include/public/arch-arm.h | 8 + xen/include/xen/vpl011.h | 67 ++++++++ 7 files changed, 427 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 2e023d1..bfa86c7 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -45,6 +45,11 @@ config ACPI config HAS_GICV3 bool +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 7afb8a3..a94bdab 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -49,6 +49,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..eeb1cbf --- /dev/null +++ b/xen/arch/arm/vpl011.c @@ -0,0 +1,339 @@ +/* + * 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=(struct xencons_interface *)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 event when TXFE bit is set then 0 will + * be returned. + */ + if ( !VPL011_IN_RING_EMPTY(intf) ) + { + *data = intf->in[MASK_XENCONS_IDX(intf->in_cons++, intf->in)]; + } + + if ( VPL011_IN_RING_EMPTY(intf) ) + { + vpl011->uartfr |= (RXFE); + vpl011->uartris &= ~(RXI); + } + + vpl011->uartfr &= ~(RXFF); + + VPL011_UNLOCK(d, flags); +} + +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=(struct xencons_interface *)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) ) + { + intf->out[MASK_XENCONS_IDX(intf->out_prod++, intf->out)] = data; + smp_wmb(); + } + + if ( VPL011_OUT_RING_FULL(intf) ) + { + vpl011->uartfr |= (TXFF); + vpl011->uartris &= ~(TXI); + } + + vpl011->uartfr |= (BUSY); + + vpl011->uartfr &= ~(TXFE); + + VPL011_UNLOCK(d, flags); + + /* raise an event to xenconsoled only if it is the first character in the buffer */ + if ( VPL011_RING_DEPTH(intf, out) == 1 ) + { + notify_via_xen_event_channel(d, d->arch.hvm_domain.params[HVM_PARAM_VCONSOLE_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) +{ + struct vpl011_s *vpl011 = &d->arch.vpl011; + + /* Map the guest PFN to Xen address space. */ + return prepare_ring_for_helper(d, + d->arch.hvm_domain.params[HVM_PARAM_VCONSOLE_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=(struct xencons_interface *)vpl011->ring_buf; + + VPL011_LOCK(d, flags); + + /* Update the uart rx state if the buffer is not empty. */ + if ( !VPL011_IN_RING_EMPTY(intf) ) + { + vpl011->uartfr &= ~(RXFE); + if ( VPL011_IN_RING_FULL(intf) ) + vpl011->uartfr |= (RXFF); + vpl011->uartris |= (RXI); + } + + /* Update the uart tx state if the buffer is not full. */ + if ( !VPL011_OUT_RING_FULL(intf) ) + { + vpl011->uartfr &= ~(TXFF); + vpl011->uartris |= (TXI); + if ( VPL011_OUT_RING_EMPTY(intf) ) + { + vpl011->uartfr &= ~(BUSY); + vpl011->uartfr |= (TXFE); + } + } + + VPL011_UNLOCK(d, flags); + + vgic_inject_vpl011_spi(d); + + if ( !VPL011_OUT_RING_EMPTY(intf) ) + { + ASSERT( d->arch.hvm_domain.params[HVM_PARAM_VCONSOLE_EVTCHN] != 0 ); + notify_via_xen_event_channel(d, d->arch.hvm_domain.params[HVM_PARAM_VCONSOLE_EVTCHN]); + } +} + + +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; + } + d->arch.hvm_domain.params[HVM_PARAM_VCONSOLE_EVTCHN] = rc; + rc = vgic_reserve_virq(d, GUEST_VPL011_SPI); + if ( !rc ) + return rc; + register_mmio_handler(d, &vpl011_mmio_handler, GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL); + spin_lock_init(&vpl011->lock); + + vpl011->intialized = true; + + return 0; +} + +int domain_vpl011_deinit(struct domain *d) +{ + struct vpl011_s *vpl011 = &d->arch.vpl011; + + if ( vpl011->intialized ) + { + free_xen_event_channel(d, d->arch.hvm_domain.params[HVM_PARAM_VCONSOLE_EVTCHN]); + destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page); + } + + return 0; +} + diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 2d6fbb1..a122504 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 { @@ -131,6 +132,10 @@ struct arch_domain struct { uint8_t privileged_call_enabled : 1; } monitor; + +#ifdef CONFIG_VPL011_CONSOLE + struct vpl011_s vpl011; +#endif } __cacheline_aligned; struct arch_vcpu diff --git a/xen/include/asm-arm/pl011-uart.h b/xen/include/asm-arm/pl011-uart.h index 123f477..57e9ec7 100644 --- a/xen/include/asm-arm/pl011-uart.h +++ b/xen/include/asm-arm/pl011-uart.h @@ -49,6 +49,8 @@ /* FR bits */ #define TXFE (1<<7) /* TX FIFO empty */ #define RXFE (1<<4) /* RX FIFO empty */ +#define TXFF (1<<5) /* TX FIFO full */ +#define RXFF (1<<6) /* RX FIFO full */ #define BUSY (1<<3) /* Transmit is not complete */ /* LCR_H bits */ diff --git a/xen/include/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..f9f2aba --- /dev/null +++ b/xen/include/xen/vpl011.h @@ -0,0 +1,67 @@ +/* + * 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 intialized; /* flag which tells whether vpl011 is initialized */ +}; + +int domain_vpl011_init(struct domain *d, struct xen_arch_domainconfig *config); +int domain_vpl011_deinit(struct domain *d); +int vpl011_map_guest_page(struct domain *d); + +#endif From patchwork Mon Apr 3 09:44:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 96601 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp18530qgd; Mon, 3 Apr 2017 02:47:08 -0700 (PDT) X-Received: by 10.36.67.135 with SMTP id s129mr8573378itb.36.1491212828746; Mon, 03 Apr 2017 02:47:08 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id h9si14305381ioa.170.2017.04.03.02.47.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 02:47:08 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1cuyXt-0001UQ-SG; Mon, 03 Apr 2017 09:45:09 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyXs-0001Td-Ju for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 09:45:08 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 15/9A-19731-3A912E85; Mon, 03 Apr 2017 09:45:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDIsWRWlGSWpSXmKPExsXiVRtsqLtY8lG Ewdl+IYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPPpRb2gj8qFbN2tLM3MB6Q6mLk4hASmMEo 8ezkfKYuRk4OFoF5zBLrH0uC2BIC/awS++ZnQNgxEg1r3rJB2BUSd443MILYQgJaEkdPzWaFG NTKJLHjwBMgh4ODTcBEYlaHBEiNiICSxL1Vk5lAapgF5jNK7O05C1YjLBAosfhIOIjJIqAq8W uhOEg5r4C3xPnfN1ggVslJ3DzXyQxSwingI3HrVQLEVm+JV/ensU1gFFjAyLCKUaM4tagstUj X0EwvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMwpBiAYAfj/Y0BhxglOZiURHnf 3HkYIcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mC97n4owghwaLU9NSKtMwcYHDDpCU4eJREeB+Cp HmLCxJzizPTIVKnGHU5PvQffsMkxJKXn5cqJc4bKQFUJABSlFGaBzcCFmmXGGWlhHkZgY4S4i lILcrNLEGVf8UozsGoJMz7EmQVT2ZeCdymV0BHMAEd8QTkft7ikkSElFQDI4NxY0ly7Dd7Pfa tqgtSjedcuxZjNMGrPWBzRqjZjmDjZ30Z7Xr1LdGaTx8qrxJwOPFocqPIn1MxrhNVOdQ+xjPr FPlfeirM/yHhG3vij/6V1tUlMX9Xy19zrJ3zUWAHX7TaUZ8dHeZi8YGcvlrs7K9+eAtwPtiXs funlkps0umTapNUFxorsRRnJBpqMRcVJwIAOhSRR68CAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-2.tower-21.messagelabs.com!1491212706!47821646!1 X-Originating-IP: [74.125.83.49] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31793 invoked from network); 3 Apr 2017 09:45:07 -0000 Received: from mail-pg0-f49.google.com (HELO mail-pg0-f49.google.com) (74.125.83.49) by server-2.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Apr 2017 09:45:07 -0000 Received: by mail-pg0-f49.google.com with SMTP id 21so115428117pgg.1 for ; Mon, 03 Apr 2017 02:45: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=E9PvMy+Ii+Irs6yieWYOybtvMHOHqK0uBIdU4BXqEUg=; b=R91TvyBIIvWkZaSDkpvP1a1v9Q4y8JGUPw9vmMYOsBKcOtvCrlCaGQazdxhRK4lShE 9FHOUfTw2owf+uxjMGfc64SihXFQWJy5quFprhjniEByI39e6qj99VvG/MVhwiV0SqSa CSREDwU/JwkVg4UGRVrPhwkdxji4pq5o5sazY= 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=E9PvMy+Ii+Irs6yieWYOybtvMHOHqK0uBIdU4BXqEUg=; b=a3WWtRWXSJ/IBj3bSlzHonjz0EuThwhCoxvBH4QUojc/H5XLINHIIha6rgUZNpVxeN dJCTTvIpn9Eu4DwVWPmwtOEe5Gl+xnvkRmoRY0Dz7zClX+EjaMUR2gtPdregKTg51xri I/c3PBuwZMEzIaPbkwvB+m3FJfS6gCij5+xbVTIjbJ50651POovlbAloSg8AugN5Smzq 8+13u04HJGChMsX9X0PMhqoMML5XYQmN6gS3ICn4ycFmAR/YHuBCvjwNKaaP30K5/++G jgmDNHfkx+9+3URI5vPvBLtMjCSwemF26w9zRWSTDG0R/TOpLbDRm54grdonJzU6DS56 FRkA== X-Gm-Message-State: AFeK/H14quQjCbz9OxEmcLba0zuchPeHimnLDPXxjlLO0LByzF8yC55uzq12zYz1FRLT0+Fm X-Received: by 10.99.247.69 with SMTP id f5mr17295464pgk.63.1491212690629; Mon, 03 Apr 2017 02:44:50 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([202.46.23.54]) by smtp.gmail.com with ESMTPSA id y7sm24751844pfk.93.2017.04.03.02.44.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:44:50 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 3 Apr 2017 15:14:25 +0530 Message-Id: <1491212673-13476-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> References: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 02/10] xen/arm: vpl011: Add new virtual console hvm params 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" 1. Add two new HVM param handlers for: - 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. 2. Add validation to disallow get/set of these HVM params from guest domain. 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 --- xen/arch/arm/hvm.c | 112 ++++++++++++++++++++++++++++++++++++++++ xen/include/public/hvm/params.h | 10 ++++ 2 files changed, 122 insertions(+) diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c index d999bde..c1fed45 100644 --- a/xen/arch/arm/hvm.c +++ b/xen/arch/arm/hvm.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include @@ -31,6 +33,80 @@ #include #include +#include + +static bool vpl011_built(void) +{ +#ifdef CONFIG_VPL011_CONSOLE + return true; +#else + return false; +#endif +} + +static int hvm_allow_set_param(struct domain *d, + const struct xen_hvm_param *a) +{ + uint64_t value = d->arch.hvm_domain.params[a->index]; + int rc; + + rc = xsm_hvm_param(XSM_TARGET, d, HVMOP_set_param); + if ( rc ) + return rc; + + switch ( a->index ) + { + /* The following parameters should not be set by the guest. */ + case HVM_PARAM_VCONSOLE_PFN: + case HVM_PARAM_VCONSOLE_EVTCHN: + if ( d == current->domain ) + rc = -EPERM; + break; + default: + break; + } + + if ( rc ) + return rc; + + switch ( a->index ) + { + /* The following parameters should only be changed once. */ + case HVM_PARAM_VCONSOLE_PFN: + case HVM_PARAM_VCONSOLE_EVTCHN: + if ( value != 0 && a->value != value ) + rc = -EEXIST; + break; + default: + break; + } + + return rc; +} + +static int hvm_allow_get_param(struct domain *d, + const struct xen_hvm_param *a) +{ + int rc; + + rc = xsm_hvm_param(XSM_TARGET, d, HVMOP_get_param); + if ( rc ) + return rc; + + switch ( a->index ) + { + /* The remaining parameters should not be read by the guest. */ + case HVM_PARAM_VCONSOLE_PFN: + case HVM_PARAM_VCONSOLE_EVTCHN: + if ( d == current->domain ) + rc = -EPERM; + break; + default: + break; + } + + return rc; +} long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) { @@ -61,9 +137,45 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) if ( op == HVMOP_set_param ) { d->arch.hvm_domain.params[a.index] = a.value; + + if ( a.index == HVM_PARAM_VCONSOLE_PFN || + a.index == HVM_PARAM_VCONSOLE_EVTCHN ) + { + if ( vpl011_built() ) + { + rc = hvm_allow_set_param(d, &a); + if ( rc ) + goto param_fail; + + if ( a.index == HVM_PARAM_VCONSOLE_PFN ) + { + rc = vpl011_map_guest_page(d); + if ( rc ) + goto param_fail; + } + } + else + { + rc = -1; + goto param_fail; + } + } } else { + if ( a.index == HVM_PARAM_VCONSOLE_PFN || + a.index == HVM_PARAM_VCONSOLE_EVTCHN ) + { + if ( !vpl011_built() ) + { + rc = -1; + goto param_fail; + } + } + rc = hvm_allow_get_param(d, &a); + if ( rc ) + goto param_fail; + a.value = d->arch.hvm_domain.params[a.index]; rc = copy_to_guest(arg, &a, 1) ? -EFAULT : 0; } diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h index 3f54a49..15d37e5 100644 --- a/xen/include/public/hvm/params.h +++ b/xen/include/public/hvm/params.h @@ -203,10 +203,20 @@ */ #define HVM_PARAM_ACPI_IOPORTS_LOCATION 19 +#if defined(__arm__) || defined(__aarch64__) +/* Virtual console (VC) shared memory ring and event channel. */ +#define HVM_PARAM_VCONSOLE_PFN 20 +#define HVM_PARAM_VCONSOLE_EVTCHN 21 +#else /* Deprecated */ #define HVM_PARAM_MEMORY_EVENT_CR0 20 #define HVM_PARAM_MEMORY_EVENT_CR3 21 +#endif + +/* Deprecated */ #define HVM_PARAM_MEMORY_EVENT_CR4 22 + +/* Deprecated */ #define HVM_PARAM_MEMORY_EVENT_INT3 23 #define HVM_PARAM_MEMORY_EVENT_SINGLE_STEP 25 #define HVM_PARAM_MEMORY_EVENT_MSR 30 From patchwork Mon Apr 3 09:44:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 96595 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp18466qgd; Mon, 3 Apr 2017 02:46:59 -0700 (PDT) X-Received: by 10.36.112.149 with SMTP id f143mr8936217itc.50.1491212819356; Mon, 03 Apr 2017 02:46:59 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i125si10580855ith.101.2017.04.03.02.46.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 02:46: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 1cuyXj-0001OS-5K; Mon, 03 Apr 2017 09:44:59 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyXh-0001Nc-MU for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 09:44:57 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 89/29-12861-89912E85; Mon, 03 Apr 2017 09:44:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRusqTtD8lG EQWeLtMX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvFxZz97wUeZiqNX/zI2MC4V72Lk4hASmMEo sfDFAsYuRk4OFoF5zBIPeypAEhIC/awSF1tvsoIkJARiJCaf3sbcxcgBZFdKbGlwAQkLCWhJH D01mxViUCuTxNwLixhBatgETCRmdUiA1IgIKEncWzWZCaSGWWA+o8TenrNgM4UFIiRO3zvCCr FYVeJD5092EJtXwFvi18lWRoi9chI3z3WC7eUU8JG49SoBYq+3xKv709gmMAosYGRYxahRnFp Ullqka2Sil1SUmZ5RkpuYmaNraGCsl5taXJyYnpqTmFSsl5yfu4kRGFb1DAyMOxhfHfc7xCjJ waQkyvvmzsMIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8uRKPIoQEi1LTUyvSMnOAAQ6TluDgU RLhnQSS5i0uSMwtzkyHSJ1i1OX40H/4DZMQS15+XqqUOO9+kCIBkKKM0jy4EbBou8QoKyXMy8 jAwCDEU5BalJtZgir/ilGcg1FJmHceyBSezLwSuE2vgI5gAjriCcj9vMUliQgpqQZG7cyZQZv iE9sXaO4z3PRFsLxWRa3kkBTb7BiWdM33Pw/nsNaEXdvaLChzgWWph4rvLIfpa0KO7LjP1xKT aH/L6Ksi56L3NydIFn9S6Qmb7sW5aYnnes3XihXChvpzP302DF1Q15qR9qlMQCnJeyHbj5ddd /9oumXsmzuj49vtmj8RfWsYcyYqsRRnJBpqMRcVJwIA2YwuB7ECAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-31.messagelabs.com!1491212695!90504530!1 X-Originating-IP: [74.125.83.41] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27307 invoked from network); 3 Apr 2017 09:44:56 -0000 Received: from mail-pg0-f41.google.com (HELO mail-pg0-f41.google.com) (74.125.83.41) by server-5.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Apr 2017 09:44:56 -0000 Received: by mail-pg0-f41.google.com with SMTP id 81so115399155pgh.2 for ; Mon, 03 Apr 2017 02:44: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=Ieow7BdBSn5/m29jMs2mlkpcT6Qq1Ovxh95DaCJaa00=; b=H+MAriWuFMXM3HC4P6sDOk4lEEdNf1caXAFnXNBM6dzMhQqyUHYJDrAt9RKd+O5ExY 0q3fNUlShN4GhGkaI86kyboxb33+fSQhxQe7YvkZ8ZNdPT+NDtWA5Mfxhy5BUkrJF578 wStTCyUXb3bSeyjhMjWmJRf1fzVuCn1ATCOvo= 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=Ieow7BdBSn5/m29jMs2mlkpcT6Qq1Ovxh95DaCJaa00=; b=UQFl2fIkGc0GQdlqDExuUy6mO2l3Hfx3/yCzMjKQRFzIE9+/JG79mMNx0oXqFXAKTK LrNp0ZWWHK9CSRtrmC85XO3JKtob8abumjeX2o6IqcUh2YyAHaXwphFQ+R73nsjiLbR9 UO813H/W4X2yjM9N2SmlMMuv3t8r7wfko+iKtVuDGLbjhUspEq4vUUJYi0pf9fgqsx7u jkYn+2a1iJhmrjAJGCj1ecrSCLQ0cc8vsspiXPg0yp0L7+0pIV3wGU7WSNMJY7JwMtyc gUCY0YVa/sdBfZm0MQczEcOgq7oI7WZ8ghswcNg6CapKCp+JcD/ONQMJtf68c3L1sggI VMag== X-Gm-Message-State: AFeK/H1yM/E1ox9bs4pLafbBbeue835mojXLTsOp/lFsFkldJgrEM+hTQ03T9p/pLgYCnLvR X-Received: by 10.99.96.68 with SMTP id u65mr17255260pgb.159.1491212694661; Mon, 03 Apr 2017 02:44:54 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([202.46.23.54]) by smtp.gmail.com with ESMTPSA id y7sm24751844pfk.93.2017.04.03.02.44.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:44:54 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 3 Apr 2017 15:14:26 +0530 Message-Id: <1491212673-13476-4-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> References: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 03/10] 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: Provide a knob in libxl to enable/disable pl011 emulation Signed-off-by: Bhupinder Thakur --- xen/arch/arm/domain.c | 11 +++++++++++ xen/common/domctl.c | 3 +++ xen/include/public/domctl.h | 2 ++ xen/include/xen/sched.h | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 7e43691..8e383d0 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -36,6 +36,9 @@ #include #include "vtimer.h" #include "vuart.h" +#ifdef CONFIG_VPL011_CONSOLE +#include +#endif DEFINE_PER_CPU(struct vcpu *, curr_vcpu); @@ -626,6 +629,11 @@ 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_vconsole ) +#ifdef CONFIG_VPL011_CONSOLE + if ( (rc = domain_vpl011_init(d, config)) != 0 ) +#endif + goto fail; update_domain_wallclock_time(d); /* @@ -660,6 +668,9 @@ fail: void arch_domain_destroy(struct domain *d) { +#ifdef CONFIG_VPL011_CONSOLE + domain_vpl011_deinit(d); +#endif /* 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 12cf4a9..3385479 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -506,6 +506,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_VCONSOLE_enable | XEN_DOMCTL_CDF_xs_domain)) ) break; @@ -550,6 +551,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_VCONSOLE_enable ) + domcr_flags |= DOMCRF_vconsole; 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 85cbb7c..1fca180 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -66,6 +66,8 @@ struct xen_domctl_createdomain { /* Is this a xenstore domain? */ #define _XEN_DOMCTL_CDF_xs_domain 5 #define XEN_DOMCTL_CDF_xs_domain (1U<<_XEN_DOMCTL_CDF_xs_domain) +#define _XEN_DOMCTL_VCONSOLE_enable 6 +#define XEN_DOMCTL_VCONSOLE_enable (1U<<_XEN_DOMCTL_VCONSOLE_enable) uint32_t flags; struct xen_arch_domainconfig config; }; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 063efe6..4efdc48 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 6 #define DOMCRF_xs_domain (1U<<_DOMCRF_xs_domain) + /* DOMCRF_vconsole: enable virtual console emulation. Used for aarach64. */ +#define _DOMCRF_vconsole 7 +#define DOMCRF_vconsole (1U<<_DOMCRF_vconsole) + /* * 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 Mon Apr 3 09:44:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 96599 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp18519qgd; Mon, 3 Apr 2017 02:47:07 -0700 (PDT) X-Received: by 10.107.140.211 with SMTP id o202mr17042352iod.180.1491212827538; Mon, 03 Apr 2017 02:47:07 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id a189si14319632ioa.51.2017.04.03.02.47.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 02:47:07 -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 1cuyXn-0001RB-Cl; Mon, 03 Apr 2017 09:45:03 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyXl-0001Po-SO for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 09:45:01 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 8B/D4-23940-D9912E85; Mon, 03 Apr 2017 09:45:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRWlGSWpSXmKPExsXiVRtspDtH8lG EQc8vcYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPb3u8sBRcUKlY1/mBtYNwk1cXIxSEkMINR 4sfD2ywgDovAPGaJzobprF2MnBwSAv2sEofb6yHsGIkZV88xQ9iVEkduHAazhQS0JI6ems0KM amVSWLG0S6gBAcHm4CJxKwOCZAaEQEliXurJjOB1DALzGeU2NtzFmyBsECixI7Ls8BsFgFViW t3NzCC9PIKeEs8meYLsUtO4ua5TrCRnAI+ErdeJUCs9ZZ4dX8a2wRGgQWMDKsY1YtTi8pSi3T N9ZKKMtMzSnITM3N0DQ2M9XJTi4sT01NzEpOK9ZLzczcxAoOKAQh2MDZ+dzrEKMnBpCTK++bO wwghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKEry5Eo8ihASLUtNTK9Iyc4DhDZOW4OBREuG9CJLmL S5IzC3OTIdInWLU5fjQf/gNkxBLXn5eqpQ4736QIgGQoozSPLgRsFi7xCgrJczLCHSUEE9Bal FuZgmq/CtGcQ5GJWHeeSBTeDLzSuA2vQI6ggnoiCcg9/MWlyQipKQaGBu2n5nDwqs07U1L3Za 0JbNcb89pP2DwlkV+cp1tRJpMrLzIlClXH+sdeW/U+Pz3jc6QzV4uTj4rtBvLyp5oLWWRmyEQ sequiWGub/ealK/Nhlt3Hby7r/b5xYcLQ7fU/upk3qmUc7mp/5VUk+39qC2RrJqq0zeu4BP/H xznyPDFoEHH7cU/BiWW4oxEQy3mouJEAOH20M2wAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-31.messagelabs.com!1491212699!62854839!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.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40773 invoked from network); 3 Apr 2017 09:45:00 -0000 Received: from mail-pg0-f50.google.com (HELO mail-pg0-f50.google.com) (74.125.83.50) by server-11.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Apr 2017 09:45:00 -0000 Received: by mail-pg0-f50.google.com with SMTP id 81so115400685pgh.2 for ; Mon, 03 Apr 2017 02:45:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6jM/ZYj32/DjzwfMoym7PyIVY+zOI+agnapr1N/Aj2s=; b=LK49ZGQAioK1P+xh7TKsj0d45ulsmVniBhJSFVKQtO0ADOad8lVowZ0B9UqWxKC0Oz KmH3ZGYkftJ1ljigM6ADVnPhJrCzqVbRH26PQy0rOAnMTsjm0JNbSYkijCKZm3AkyIyD T1tFfMyD/Ti3YKl8S91w6spwBOGXvCB1tgvbc= 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=6jM/ZYj32/DjzwfMoym7PyIVY+zOI+agnapr1N/Aj2s=; b=V8xZPdIi/MHgjz+SwqYGsgX2PjnXfkn/6BEBYL15sHU4aJNQsWY+SywC0tNRdCs+WC 4ViyXWU2s3roNy8zEGRJadgIVDMSC0EdKAVuAiQhPKXHuWhixEAW7AqtVTRWx38xpCAs lOiDEefiM6+9RJyZtd7iZx6Alylv/gu6XEbby+O30czB1nnIgQIKBAu4IdGvM6G7ANtS B5azdVcVEfWxOeaEHf4lyKPzGN+093+0I+kh9aL7CcICIpJdC1CYsevqC20rJh/Qw0gT hznwfqXbTo8f6JviO9yIU0t3S1rBRWwBMAkHVRfXF9EKmzwckn/5173OWaP4uNwqX66U Op3Q== X-Gm-Message-State: AFeK/H2NjDUFYkQAAru0CkYM6kpTnhhuosWZa2IawjnOFJC3yKaBpfha+tPAAtIeXPnpQspD X-Received: by 10.98.102.88 with SMTP id a85mr16842229pfc.33.1491212698663; Mon, 03 Apr 2017 02:44:58 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([202.46.23.54]) by smtp.gmail.com with ESMTPSA id y7sm24751844pfk.93.2017.04.03.02.44.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:44:58 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 3 Apr 2017 15:14:27 +0530 Message-Id: <1491212673-13476-5-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> References: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 04/10] xen/arm: vpl011: Provide a knob in libxl to enable/disable pl011 emulation 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 emulation while creating a guest domain. Signed-off-by: Bhupinder Thakur --- tools/libxl/libxl_create.c | 12 ++++++++++++ tools/libxl/libxl_internal.h | 5 +++++ tools/libxl/libxl_types.idl | 2 ++ tools/libxl/xl_cmdimpl.c | 4 ++++ 4 files changed, 23 insertions(+) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index e3bc257..9a59354 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -208,6 +208,8 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_defbool_setdefault(&b_info->disable_migrate, false); + libxl_defbool_setdefault(&b_info->enable_pl011, false); + for (i = 0 ; i < b_info->num_iomem; i++) if (b_info->iomem[i].gfn == LIBXL_INVALID_GFN) b_info->iomem[i].gfn = b_info->iomem[i].start; @@ -546,6 +548,9 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, flags |= XEN_DOMCTL_CDF_hap; } + if (libxl_defbool_val(d_config->b_info.enable_pl011)) + flags |= XEN_DOMCTL_VCONSOLE_enable; + /* Ultimately, handle is an array of 16 uint8_t, same as uuid */ libxl_uuid_copy(ctx, (libxl_uuid *)handle, &info->uuid); @@ -910,6 +915,11 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } + if (libxl_defbool_val(d_config->b_info.enable_pl011)) + state->vconsole_enabled = true; + else + state->vconsole_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))) { @@ -926,6 +936,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 5f46578..2406eaa 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1128,6 +1128,11 @@ typedef struct { uint32_t num_vmemranges; xc_domain_configuration_t config; + + /* Virtual console mfn and port. */ + unsigned long vconsole_mfn; + uint32_t vconsole_port; + bool vconsole_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 a612d1f..fe7f795 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, "VCON"), ]) libxl_disk_format = Enumeration("disk_format", [ @@ -460,6 +461,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("disable_migrate", libxl_defbool), ("cpuid", libxl_cpuid_policy_list), ("blkdev_start", string), + ("enable_pl011", libxl_defbool), ("vnuma_nodes", Array(libxl_vnode_info, "num_vnuma_nodes")), diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 358757f..4f4d4e6 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1433,6 +1433,8 @@ static void parse_config_data(const char *config_source, if (!xlu_cfg_get_long (config, "maxvcpus", &l, 0)) b_info->max_vcpus = l; + xlu_cfg_get_defbool(config, "pl011", &b_info->enable_pl011, 0); + parse_vnuma_config(config, b_info); /* Set max_memkb to target_memkb and max_vcpus to avail_vcpus if @@ -3788,6 +3790,8 @@ 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, "vcon")) + type = LIBXL_CONSOLE_TYPE_VCON; else { fprintf(stderr, "console type supported are: pv, serial\n"); return EXIT_FAILURE; From patchwork Mon Apr 3 09:44:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 96596 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp18467qgd; Mon, 3 Apr 2017 02:46:59 -0700 (PDT) X-Received: by 10.107.3.14 with SMTP id 14mr14455162iod.231.1491212819609; Mon, 03 Apr 2017 02:46:59 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 17si9231948iob.248.2017.04.03.02.46.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 02:46: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 1cuyXr-0001T2-KF; Mon, 03 Apr 2017 09:45:07 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyXq-0001SV-Hd for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 09:45:06 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id 63/72-03642-1A912E85; Mon, 03 Apr 2017 09:45:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsXiVRtsqLtQ8lG EwfrZPBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a3hh2sBWukKxqnHGVsYFwn1sXIxSEkMItR ovvKa0YQh0VgHrPEjQ/vwRwJgX5WiV2LFrF0MXICOTESj3+cYIawKyXerPsHZgsJaEkcPTWbF WJUK5PE56VNQA0cHGwCJhKzOiRAakQElCTurZrMBFLDLDCfUWJvz1lWkISwQLJE69k5jCA2i4 CqxMrfr5hAbF4Bb4ktc1ezQyyTk7h5rpMZZCangI/ErVcJEHu9JV7dn8Y2gVFgASPDKkaN4tS istQiXUNTvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MwNBiAIIdjN+WBRxilORg UhLlfXPnYYQQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd5ciUcRQoJFqempFWmZOcAgh0lLcPAoi fBOAknzFhck5hZnpkOkTjHqcnzoP/yGSYglLz8vVUqcdz9IkQBIUUZpHtwIWMRdYpSVEuZlBD pKiKcgtSg3swRV/hWjOAejkjBvPMgUnsy8ErhNr4COYAI64gnI/bzFJYkIKakGRtfvK1aHzMz fW9fdvD/Y8gtX8CP36PnWRpcf5+/cMyPg65xvxyU8av/7LWWOrdw+d2WUBcNpoXUzlG5fWsml mbr2QV/Z4u2++5Jm+4meXiz56ukUraVCfgsuqCap6Qm1i+ZrJ+1YkcHz5oC2cs6rxnyrUO6tb cbic5e9lpX99ep0+9TIH40PpZVYijMSDbWYi4oTAQekY3uzAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-21.messagelabs.com!1491212704!55111662!1 X-Originating-IP: [74.125.83.49] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23599 invoked from network); 3 Apr 2017 09:45:05 -0000 Received: from mail-pg0-f49.google.com (HELO mail-pg0-f49.google.com) (74.125.83.49) by server-10.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Apr 2017 09:45:05 -0000 Received: by mail-pg0-f49.google.com with SMTP id x125so115253461pgb.0 for ; Mon, 03 Apr 2017 02:45:04 -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=SzRnVnaIjcbhVkeY5DIrcjdp1N9a40mqnv50ikNMOBc=; b=YdJ8KBnlMGJwHJvbfx5D4EC+LtwU2ZoTVuzNzaCNpWjP4uNOHsjJmGY6r+WQC+VAkG 7n/f0DDKv86CEnH8/Ozoz91M8BYmJtM+p3ePjRDRVsxc2VQTiSNDZdhHCEuNNmeAHmZB xFcuvCRyXcKMzwd11Veae4Y337DOnDZxmhC4o= 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=SzRnVnaIjcbhVkeY5DIrcjdp1N9a40mqnv50ikNMOBc=; b=D08D1Jdj9jZ4lpF0JHHc/smcVePY5KGEsHF3sa3LRFgZC4d8jUP+BViSte10dyzZeq mMObXP6cMHYEccr1VC/dkCHw+ca7whThurmZDdgdyg8Z7+4WQSPR4wwj3hYPnSv8UVoo hFA5oc2j6wmRlVkIa9v3Sr0UZs43s6vahrjeQRGe8ZZdjUZMkIkMzG907BWPBKyOYZYq PoxWWHPITYQ0ZmDzVl/hVnh4pgjoGFw9qgyN4+hKmVywbo8VZWBRaE8ynx1Y8b6eTbQr ksDIFi88WX9cbeZcBVUXG18yGglX0uAsMXQEElYUtrBuJiZ9nu4Qgr+zg0WPzm3oK2b3 CsCA== X-Gm-Message-State: AFeK/H2e1jk1207vgDjuBKf0TKgxldvhquDJZPDRcHpwf+cq55Y/AVzceH2tmBKv5ow0MNco X-Received: by 10.99.240.83 with SMTP id s19mr16995975pgj.45.1491212702743; Mon, 03 Apr 2017 02:45:02 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([202.46.23.54]) by smtp.gmail.com with ESMTPSA id y7sm24751844pfk.93.2017.04.03.02.44.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:45:02 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 3 Apr 2017 15:14:28 +0530 Message-Id: <1491212673-13476-6-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> References: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 05/10] xen/arm: vpl011: Allocate a new PFN in the toolstack for the virtual console 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. Allocate a new pfn and pass on to Xen using a hvm call. 2. Change in xc_hvm_param_deprecated_check () to allow new vpl011 HVM params, which are reusing some deprecated x86 HVM params. Signed-off-by: Bhupinder Thakur --- tools/libxc/include/xc_dom.h | 3 +++ tools/libxc/xc_dom_arm.c | 7 ++++++- tools/libxc/xc_dom_boot.c | 3 +++ tools/libxc/xc_domain.c | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index 608cbc2..c93d98c 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -218,6 +218,9 @@ struct xc_dom_image { /* Extra SMBIOS structures passed to HVMLOADER */ struct xc_hvm_firmware_module smbios_module; + + /* Virtual console pfn. */ + xen_pfn_t vconsole_pfn; }; /* --- pluggable kernel loader ------------------------------------- */ diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index a7e839e..157381e 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 VCONSOLE_PFN_OFFSET 3 #define LPAE_SHIFT 9 @@ -85,6 +86,7 @@ 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->vconsole_pfn = base + VCONSOLE_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); @@ -95,6 +97,9 @@ static int alloc_magic_pages(struct xc_dom_image *dom) dom->xenstore_pfn); xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_MONITOR_RING_PFN, base + MEMACCESS_PFN_OFFSET); + xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_VCONSOLE_PFN, + base + VCONSOLE_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 791041b..ec91b15 100644 --- a/tools/libxc/xc_dom_boot.c +++ b/tools/libxc/xc_dom_boot.c @@ -227,6 +227,9 @@ int xc_dom_boot_image(struct xc_dom_image *dom) if ( (rc = clear_page(dom, dom->xenstore_pfn)) != 0 ) return rc; + if ( (rc = clear_page(dom, dom->vconsole_pfn)) != 0 ) + return rc; + /* start info page */ if ( dom->arch_hooks->start_info ) dom->arch_hooks->start_info(dom); diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index fa1daeb..8ac7d4f 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -1337,9 +1337,16 @@ static inline int xc_hvm_param_deprecated_check(uint32_t param) { switch ( param ) { + /* + * For Aarch64 the following three parameters are reused and hence this + * empty check to avoid returning an error. + */ +#if defined (__arm__) || defined(__aarch64__) +#else case HVM_PARAM_MEMORY_EVENT_CR0: case HVM_PARAM_MEMORY_EVENT_CR3: case HVM_PARAM_MEMORY_EVENT_CR4: +#endif case HVM_PARAM_MEMORY_EVENT_INT3: case HVM_PARAM_MEMORY_EVENT_SINGLE_STEP: case HVM_PARAM_MEMORY_EVENT_MSR: From patchwork Mon Apr 3 09:44:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 96597 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp18480qgd; Mon, 3 Apr 2017 02:47:01 -0700 (PDT) X-Received: by 10.107.179.136 with SMTP id c130mr14742531iof.157.1491212821552; Mon, 03 Apr 2017 02:47:01 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v192si10612902ith.92.2017.04.03.02.47.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 02:47:01 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyXw-0001Wi-7I; Mon, 03 Apr 2017 09:45:12 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyXu-0001V9-Nv for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 09:45:10 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 0A/B6-23854-5A912E85; Mon, 03 Apr 2017 09:45:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDIsWRWlGSWpSXmKPExsXiVRtsoLtE8lG EQd83I4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNePjnKvsBeckKo7t+M7WwLhFuIuRk0NIYAaj xP6PSV2MXBwsAvOYJb5f+MkEkpAQ6GcFchQh7BiJ/c+mQsWrJabtX88O0awlcfTUbFYIu5VJY k6jYRcjBwebgInErA4JkLCIgJLEvVWTmUDmMwvMZ5TY23MWrF5YIE5ix4XrYHNYBFQlvs/6Az afV8BboqlrIjvELjmJm+c6mUFmcgr4SNx6lQCxylvi1f1pbBMYBRYwMqxiVC9OLSpLLdI100s qykzPKMlNzMzRNTQw1stNLS5OTE/NSUwq1kvOz93ECAypegYGxh2MV9qcDzFKcjApifK+ufMw QogvKT+lMiOxOCO+qDQntfgQowwHh5IEb67EowghwaLU9NSKtMwcYHDDpCU4eJREeCeBpHmLC xJzizPTIVKnGHU5PvQffsMkxJKXn5cqJc4bCVIkAFKUUZoHNwIWaZcYZaWEeRkZGBiEeApSi3 IzS1DlXzGKczAqCfPGg0zhycwrgdv0CugIJqAjnoDcz1tckoiQkmpgnKNXuvORecCMY50HJz7 RD57W+jL0yKW13zYL3Nk3NfL2U0vuz5Nv1Gx4YvfsiMU9+S3Pje4lZfyWDPhVKqhkyvD63WPO X4bqc99yi7s++6Xbl691Za2AR+zFVVrTDc0vHFv+U/zjT49bbx+1vHW7mLNi+VGx7Isi/05tM qucaZl1JfX35sz/jwSUWIozEg21mIuKEwHeyNhHrwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-13.tower-31.messagelabs.com!1491212707!93096544!1 X-Originating-IP: [74.125.83.48] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 65471 invoked from network); 3 Apr 2017 09:45:08 -0000 Received: from mail-pg0-f48.google.com (HELO mail-pg0-f48.google.com) (74.125.83.48) by server-13.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Apr 2017 09:45:08 -0000 Received: by mail-pg0-f48.google.com with SMTP id 81so115404056pgh.2 for ; Mon, 03 Apr 2017 02:45:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hKqzCRoq5ZyD1sggAMACL2Z1OX45c34HDvJRWEfIJeE=; b=gq4dKy6Wb0e2Vih/tQn7vSmnGmfBwVP+JRIONP+6dCVE66+G4rJ27JgsqIOCHH3ody 5dRV+SXB1mRX9y2Txuv+5Y8ZqeL4a3G8sOUEpFjn5ySRxN/4YFQzjpREgi2LUtn+1lUq fh7NbU9d1T6gYKUYX8dtxJQZoHMLQyzMdkBrI= 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=hKqzCRoq5ZyD1sggAMACL2Z1OX45c34HDvJRWEfIJeE=; b=mm2XBglyPn7fvLZMwalDlxsQgr8aY5DYNgpmD19o/SqInY8Onq2bDrGwlpnNdt9PH6 AJx5voDAI0cP6F3acbbB074lftmK/dHZEWq7EfyLQFEbD/Nld/B3Umu6tQsKsJkd/AuI 3i4WjGKlv7HE6sDszWXH08W/d8Ho9CIT2rKBCur+7AxeGMcrJJC94twUAUISb5HTiPSR lHhuh3NUfTgTsXexdRqNWQjcmKYAKEQMLiSMBXwSIAJV1dohQqQ/cMc4HMcImBQM4HMu cXiedOtTIvv9AJ6G1DJew2q9xLCnDqA7AUaF0MpJtwB4pqnwNSYF8+VAIwYIgLoncLD+ OjGg== X-Gm-Message-State: AFeK/H0DSgeah4evNV82uDM7c1uPPLsdML07x/iguTLqEjwiR98qi0HPP95e7aBPA5wyaw5V X-Received: by 10.99.131.195 with SMTP id h186mr16722641pge.57.1491212706916; Mon, 03 Apr 2017 02:45:06 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([202.46.23.54]) by smtp.gmail.com with ESMTPSA id y7sm24751844pfk.93.2017.04.03.02.45.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:45:06 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 3 Apr 2017 15:14:29 +0530 Message-Id: <1491212673-13476-7-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> References: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 06/10] xen/arm: vpl011: Add new parameters to xenstore for the virtual console 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: - newly allocated PFN to be used as IN/OUT ring buffer by xenconsoled - a new event channel read from Xen using a hvm call to be used by xenconsoled Signed-off-by: Bhupinder Thakur --- tools/libxl/libxl.c | 10 ++++++++++ tools/libxl/libxl_dom.c | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index d400fa2..5fa1e41 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1791,6 +1791,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_VCON: + cons_type_s = "vcon"; + break; default: goto out; } @@ -3159,6 +3162,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->vconsole_enabled) + { + flexarray_append(ro_front, "vcon-port"); + flexarray_append(ro_front, GCSPRINTF("%"PRIu32, state->vconsole_port)); + flexarray_append(ro_front, "vcon-ring-ref"); + flexarray_append(ro_front, GCSPRINTF("%lu", state->vconsole_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 d519c8d..8df1e10 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -302,7 +302,7 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, libxl_ctx *ctx = libxl__gc_owner(gc); char *xs_domid, *con_domid; int rc; - uint64_t size; + uint64_t size, val; if (xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus) != 0) { LOG(ERROR, "Couldn't set max vcpu count"); @@ -432,6 +432,16 @@ 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); + state->vconsole_port = -1; + + if (state->vconsole_enabled) + { + rc = xc_hvm_param_get(ctx->xch, domid, HVM_PARAM_VCONSOLE_EVTCHN, + &val); + if ( !rc ) + state->vconsole_port = val; + } + if (info->type == LIBXL_DOMAIN_TYPE_HVM) { hvm_set_conf_params(ctx->xch, domid, info); #if defined(__i386__) || defined(__x86_64__) @@ -771,6 +781,7 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid, if (xc_dom_feature_translated(dom)) { state->console_mfn = dom->console_pfn; state->store_mfn = dom->xenstore_pfn; + state->vconsole_mfn = dom->vconsole_pfn; } else { state->console_mfn = xc_dom_p2m(dom, dom->console_pfn); state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); From patchwork Mon Apr 3 09:44:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 96602 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp18536qgd; Mon, 3 Apr 2017 02:47:09 -0700 (PDT) X-Received: by 10.36.60.82 with SMTP id m79mr9101834ita.107.1491212829337; Mon, 03 Apr 2017 02:47:09 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f77si14293083iof.203.2017.04.03.02.47.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 02:47:09 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1cuyXz-0001ZT-FN; Mon, 03 Apr 2017 09:45:15 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyXy-0001YL-4M for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 09:45:14 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id E2/18-04817-9A912E85; Mon, 03 Apr 2017 09:45:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRtsrLtC8lG Eway1/Bbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b6VYfYCr7wVGybs5y1gXECdxcjF4eQwAxG iT3zdzKBOCwC85glJk+eygbiSAj0s0r8/9IO5HACOTESLy6/Y4GwqyUuzvnDBGILCWhJHD01m xViVCuTxMa57xi7GDk42ARMJGZ1SIDUiAgoSdxbNRlsA7PAfEaJvT1nWUESwgIJEtvfPQcbxC KgKjFj82cWkF5eAW+JRRNcIHbJSdw818kMEuYU8JG49SoBYq23xKv709gmMAosYGRYxahRnFp Ullqka2isl1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kRGFgMQLCD8cuygEOMkhxM SqK8b+48jBDiS8pPqcxILM6ILyrNSS0+xCjDwaEkwZsr8ShCSLAoNT21Ii0zBxjiMGkJDh4lE d5JIGne4oLE3OLMdIjUKUZdjg/9h98wCbHk5eelSonz7gcpEgApyijNgxsBi7dLjLJSwryMQE cJ8RSkFuVmlqDKv2IU52BUEuadBzKFJzOvBG7TK6AjmICOeAJyP29xSSJCSqqB8cCaCS94bzq djQveGalsw6upISrkPP+XfWf8Be9VUgLxkzKPsN76/VPQo/Zh0P/GEvPZdjdl5JJ4NBuvKC6/ IXqDY+bC5baz3nuxFd4/tS5Tc6Hdt8/BJxdyZy5kuaeb92n19YNcKqs2vj6y7ExM05uy7rj12 uc1PjD8D3hwm8VeR9aOSU9rpRJLcUaioRZzUXEiAHBsZ02yAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1491212711!85735454!1 X-Originating-IP: [74.125.83.51] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34772 invoked from network); 3 Apr 2017 09:45:12 -0000 Received: from mail-pg0-f51.google.com (HELO mail-pg0-f51.google.com) (74.125.83.51) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Apr 2017 09:45:12 -0000 Received: by mail-pg0-f51.google.com with SMTP id 81so115405717pgh.2 for ; Mon, 03 Apr 2017 02:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u/hDLidcS2Dwx5ykcCUoL+F/0YkmMCPtg1iR9D9ErlY=; b=BrGoNPbtcwnljIrreBIvDnJwxy/OgXBqymq+YPSQV9Cua/Vdx5ansBfyPunyqkzmib 74FPv37BIdSpPtaBOP0LPKeJbSMDNRkiu43Wg0m1cXmGf7GwSDilYcyFyrFdtVAkoFYN NTff/etCEhmurMR08LAddYETpuk7IT0nM/2oM= 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=u/hDLidcS2Dwx5ykcCUoL+F/0YkmMCPtg1iR9D9ErlY=; b=UFo9j9zQ+7rl6QIglwC+yltL6ppMLUccwTiLWd/Ct+5qOpVm63ZgFUSD3enTgBUDfH FYUikmOJDS5/5DB++k78QUY7EA9iPpWWZ4xHhAyRQznhZFKkXK+Bl213sRGvqFuTaTHO j38uV6xW09qoXpsROt5V0HeD3NK0QEJSEPV9pvnpi5CULmtxQYjeyAsMAP1IIm+gAbJI 9TtdFAY2sL/EGx1NSbi5RwRviYgVdMr7iWpx7WrDL2nSh46tnyUQ/52AQuZF7NjOSkWu drz0VA/3WjlaQYfC5umrYF083/OuyzLpi6epxEEDMSOyGx/hIVpuRwWaViMPp305kYCw PNog== X-Gm-Message-State: AFeK/H0oMPK0lpY4mREv00EDlB/HbHOPbvf3QsWXf58gWHQbMCI0IJWC/ioBjCiS0hi9Kuoa X-Received: by 10.84.176.100 with SMTP id u91mr21087227plb.112.1491212710820; Mon, 03 Apr 2017 02:45:10 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([202.46.23.54]) by smtp.gmail.com with ESMTPSA id y7sm24751844pfk.93.2017.04.03.02.45.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:45:10 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 3 Apr 2017 15:14:30 +0530 Message-Id: <1491212673-13476-8-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> References: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 07/10] xen/arm: vpl011: Add a new console type to domain structure 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" Modify the domain structure to to make console specific fields as an array indexed by the console type. Two console types are defined - PV and VCON. Signed-off-by: Bhupinder Thakur --- tools/console/daemon/io.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 7e6a886..0cd1fee 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_VCON 1 + extern int log_reload; extern int log_guest; extern int log_hv; @@ -91,23 +95,25 @@ struct buffer { struct domain { int domid; - int master_fd; - int master_pollfd_idx; - int slave_fd; - int log_fd; + int master_fd[MAX_CONSOLE]; + int master_pollfd_idx[MAX_CONSOLE]; + int slave_fd[MAX_CONSOLE]; + int log_fd[MAX_CONSOLE]; bool is_dead; unsigned last_seen; - struct buffer buffer; + struct buffer buffer[MAX_CONSOLE]; struct domain *next; char *conspath; - int ring_ref; - xenevtchn_port_or_error_t local_port; - xenevtchn_port_or_error_t remote_port; + int ring_ref[MAX_CONSOLE]; + xenevtchn_port_or_error_t local_port[MAX_CONSOLE]; + xenevtchn_port_or_error_t remote_port[MAX_CONSOLE]; xenevtchn_handle *xce_handle; int xce_pollfd_idx; - struct xencons_interface *interface; + struct xencons_interface *interface[MAX_CONSOLE]; int event_count; long long next_period; + int console_data_pending; + bool vcon_enabled; }; static struct domain *dom_head; From patchwork Mon Apr 3 09:44:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 96605 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp18637qgd; Mon, 3 Apr 2017 02:47:25 -0700 (PDT) X-Received: by 10.36.208.210 with SMTP id m201mr8837638itg.98.1491212845749; Mon, 03 Apr 2017 02:47:25 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 63si14311425iot.17.2017.04.03.02.47.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 02:47:25 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (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 1cuyYJ-0001oP-7A; Mon, 03 Apr 2017 09:45:35 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyYI-0001nV-Fh for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 09:45:34 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 9D/3C-19731-DB912E85; Mon, 03 Apr 2017 09:45:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRWlGSWpSXmKPExsXiVRusqbtH8lG EwYcpJhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b1KzdYC+4dYKx4cHAySwNj2zzGLkYuDiGB GYwSy7e9ZQJxWATmMUv8XX6QDcSREOhnlTjxpJu5i5ETyImR2PrrKzuEXSWx6/UTMFtIQEvi6 KnZrBCjWpkkuuc9Yuli5OBgEzCRmNUhAVIjIqAkcW/VZLANzALzGSX29pxlBUkIC2RI/No6kR HEZhFQlXi+vIUJxOYV8JZ48mszE8QyOYmb5zqZQWZyCvhI3HqVALHXW+LV/WlsExgFFjAyrGL UKE4tKkst0jU01UsqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECAwvBiDYwfhtWcAh RkkOJiVR3jd3HkYI8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuDNlXgUISRYlJqeWpGWmQMMdJi0B AePkgjvJJA0b3FBYm5xZjpE6hSjMcec2bvfMHF86D/8hkmIJS8/L1VKnHc/SKkASGlGaR7cIF gEXmKUlRLmZQQ6TYinILUoN7MEVf4VozgHo5IwbzzIFJ7MvBK4fa+ATmECOuUJyBe8xSWJCCm pBsZFj2qlF8nGrg7r+TrX1fZfs9KWlQ3r4xuUD4Q9W5njdsj815+CVe1Gy7OT924rcmd7MOeI xspfj+erLvnEdZc/1SpX9/LrxHnbzN9NEkl9psCooV4o+MMnxpbHZl6/xpsc49uuS64YTex+u 7PtV8PTdUe+mgtK/9nO96z06aGtyvEn9jx2W3ddiaU4I9FQi7moOBEAYOJCZbsCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-21.messagelabs.com!1491212731!61619033!1 X-Originating-IP: [74.125.83.41] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26898 invoked from network); 3 Apr 2017 09:45:32 -0000 Received: from mail-pg0-f41.google.com (HELO mail-pg0-f41.google.com) (74.125.83.41) by server-15.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Apr 2017 09:45:32 -0000 Received: by mail-pg0-f41.google.com with SMTP id g2so113988235pge.3 for ; Mon, 03 Apr 2017 02:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nz6v32sWani9tFbYVPcrXl0FzvG9Pcdn7E2camivVI8=; b=jPKN9ffUzuwdvqyk/Th9dmCa7v2hNK6jzN5C4TLY21yCAq1GAQiZLMS3ulhrlEE80e +MLgAupqFeLbR4Pa9651rsJg4wy6w4m2eAIqb53LQ9K88ZnlJFg/3d+tpSiXf7Y9WWsf Kv8gdfspJpIPneNWx+Y/MRBvEhs8hoDHn0JUk= 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=nz6v32sWani9tFbYVPcrXl0FzvG9Pcdn7E2camivVI8=; b=fDctTKsQHaCmnmXmVfbCJvYDEGolKCYOn6bUk6hy46CA4Y08zOjqGMlbN98ir3dKuM YyBLDzikQtJ/tSxpznFVq00TZtiCCk5RKLmV4bJcHg/cIehQd0YM/PgDPocdtoCefjuS kLRvmXQFczGndZbcLHm9Ijp35QgTa1cjtrYKT7UbyMb3p1KkxSSwIPe61CZgJkVgaA4y FohK6w8DXLsieMDRE+Q1SuUjCi2wECBCWZO7X5AB5Am6lB1seRjfTXhhZwEL24+Q3ArM W3GHJxNpcmLUoLLaIy9DLyBqB8U3TEuiaqfRxgY9JnJnxkbrtxX0Uq+3vNOOMWEnjZ5/ jodA== X-Gm-Message-State: AFeK/H22OWtqSoh5oEq88I/CHZcpTQn7TwKOACf/rzPSUAlvrBQbJEkU6mC3hb+KjXC2O+fe X-Received: by 10.98.25.202 with SMTP id 193mr16841568pfz.134.1491212715779; Mon, 03 Apr 2017 02:45:15 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([202.46.23.54]) by smtp.gmail.com with ESMTPSA id y7sm24751844pfk.93.2017.04.03.02.45.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:45:15 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 3 Apr 2017 15:14:31 +0530 Message-Id: <1491212673-13476-9-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> References: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 08/10] xen/arm: vpl011: Modify the APIs in xenconsole to acces both PV and VCON consoles X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Xenconsole supports only PV console currently. To get access to emulated pl011 uart another backend console is required. This patch modifies different data structures and APIs used in xenconsole to support two console types: PV and VCON (virtual console). Change summary: 1. Modify the domain structure to support two console types: PV and a virtual console (VCON). 2. Modify different APIs such as buffer_append() to take a new parameter console_type as input and operate on the data structures indexed by the console_type. 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 VCON events. 5. Add a new log_file for VCON console logs. Signed-off-by: Bhupinder Thakur --- tools/console/daemon/io.c | 508 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 356 insertions(+), 152 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 0cd1fee..b9be5a5 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -164,11 +164,39 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } -static void buffer_append(struct domain *dom) +/* + * This function checks if the data is allowed to be buffered for that console. + * If not then it marks it pending for later receiving. + */ +static bool buffer_available(struct domain *dom, int console_type) +{ + if (discard_overflowed_data || + !dom->buffer[console_type].max_capacity || + dom->buffer[console_type].size < dom->buffer[console_type].max_capacity) + { + dom->console_data_pending &= ~(1<console_data_pending |= (1<buffer; + struct buffer *buffer = &dom->buffer[console_type]; + struct xencons_interface *intf=dom->interface[console_type]; + xenevtchn_port_or_error_t port=dom->local_port[console_type]; + XENCONS_RING_IDX cons, prod, size; - struct xencons_interface *intf = dom->interface; + + /* + * check if more data is allowed to be buffered + */ + if (!buffer_available(dom, console_type)) + return; cons = intf->out_cons; prod = intf->out_prod; @@ -193,22 +221,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 (dom->log_fd[console_type] != -1) { int logret; if (log_time_guest) { logret = write_with_timestamp( - dom->log_fd, + dom->log_fd[console_type], buffer->data + buffer->size - size, size, &log_time_guest_needts); } else { logret = write_all( - dom->log_fd, + dom->log_fd[console_type], buffer->data + buffer->size - size, size); } @@ -296,12 +324,13 @@ static int create_hv_log(void) return fd; } -static int create_domain_log(struct domain *dom) +static int create_domain_log(struct domain *dom, int console_type) { char logfile[PATH_MAX]; char *namepath, *data, *s; int fd; unsigned int len; + char *console_name[]={"pv", "vcon"}; namepath = xs_get_domain_path(xs, dom->domid); s = realloc(namepath, strlen(namepath) + 6); @@ -320,7 +349,7 @@ 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, console_name[console_type], data); free(data); logfile[PATH_MAX-1] = '\0'; @@ -344,14 +373,24 @@ static int create_domain_log(struct domain *dom) static void domain_close_tty(struct domain *dom) { - if (dom->master_fd != -1) { - close(dom->master_fd); - dom->master_fd = -1; + if (dom->master_fd[CONSOLE_TYPE_PV] != -1) { + close(dom->master_fd[CONSOLE_TYPE_PV]); + dom->master_fd[CONSOLE_TYPE_PV] = -1; + } + + if (dom->slave_fd[CONSOLE_TYPE_PV] != -1) { + close(dom->slave_fd[CONSOLE_TYPE_PV]); + dom->slave_fd[CONSOLE_TYPE_PV] = -1; + } + + if (dom->master_fd[CONSOLE_TYPE_VCON] != -1) { + close(dom->master_fd[CONSOLE_TYPE_VCON]); + dom->master_fd[CONSOLE_TYPE_VCON] = -1; } - if (dom->slave_fd != -1) { - close(dom->slave_fd); - dom->slave_fd = -1; + if (dom->slave_fd[CONSOLE_TYPE_VCON] != -1) { + close(dom->slave_fd[CONSOLE_TYPE_VCON]); + dom->slave_fd[CONSOLE_TYPE_VCON] = -1; } } @@ -424,63 +463,86 @@ static int domain_create_tty(struct domain *dom) char *data; unsigned int len; struct termios term; + int console_type=0; - assert(dom->slave_fd == -1); - assert(dom->master_fd == -1); + assert(dom->master_fd[CONSOLE_TYPE_PV] == -1); + assert(dom->slave_fd[CONSOLE_TYPE_PV] == -1); + assert(dom->master_fd[CONSOLE_TYPE_VCON] == -1); + assert(dom->slave_fd[CONSOLE_TYPE_VCON] == -1); - if (openpty(&dom->master_fd, &dom->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; - } + /* + * Open pty for both PV and vcon consoles. + */ + for (console_type=0; console_typemaster_fd[console_type], &dom->slave_fd[console_type], 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; + } - if (tcgetattr(dom->slave_fd, &term) < 0) { - err = errno; - dolog(LOG_ERR, "Failed to get tty attributes for domain-%d " - "(errno = %i, %s)", - dom->domid, err, strerror(err)); - goto out; - } - cfmakeraw(&term); - if (tcsetattr(dom->slave_fd, TCSANOW, &term) < 0) { - err = errno; - dolog(LOG_ERR, "Failed to set tty attributes for domain-%d " - "(errno = %i, %s)", - dom->domid, err, strerror(err)); - goto out; - } + if (tcgetattr(dom->slave_fd[console_type], &term) < 0) { + err = errno; + dolog(LOG_ERR, "Failed to get tty attributes for domain-%d " + "(errno = %i, %s)", + dom->domid, err, strerror(err)); + goto out; + } + cfmakeraw(&term); + if (tcsetattr(dom->slave_fd[console_type], TCSANOW, &term) < 0) { + err = errno; + dolog(LOG_ERR, "Failed to set tty attributes for domain-%d " + "(errno = %i, %s)", + dom->domid, err, strerror(err)); + goto out; + } - if ((slave = ptsname(dom->master_fd)) == NULL) { - err = errno; - dolog(LOG_ERR, "Failed to get slave name for domain-%d " - "(errno = %i, %s)", - dom->domid, err, strerror(err)); - goto out; - } + if ((slave = ptsname(dom->master_fd[console_type])) == NULL) { + err = errno; + dolog(LOG_ERR, "Failed to get slave name for domain-%d " + "(errno = %i, %s)", + dom->domid, err, strerror(err)); + goto out; + } - success = asprintf(&path, "%s/limit", dom->conspath) != - -1; - if (!success) - goto out; - data = xs_read(xs, XBT_NULL, path, &len); - if (data) { - dom->buffer.max_capacity = strtoul(data, 0, 0); - free(data); + /* + * Initialize the console buffer capacity. + */ + success = asprintf(&path, "%s/limit", dom->conspath) != + -1; + if (!success) + goto out; + data = xs_read(xs, XBT_NULL, path, &len); + if (data) { + dom->buffer[console_type].max_capacity = strtoul(data, 0, 0); + free(data); + } + free(path); + + /* + * Write console slave name to xen store. + */ + if (console_type == CONSOLE_TYPE_VCON) + success = (asprintf(&path, "%s/vtty", dom->conspath) != -1); + else + success = (asprintf(&path, "%s/tty", dom->conspath) != -1); + + if (!success) + goto out; + success = xs_write(xs, XBT_NULL, path, slave, strlen(slave)); + free(path); + + if (fcntl(dom->master_fd[console_type], F_SETFL, O_NONBLOCK) == -1) + goto out; + + if (!dom->vcon_enabled) + break; } - free(path); - success = (asprintf(&path, "%s/tty", dom->conspath) != -1); if (!success) goto out; - success = xs_write(xs, XBT_NULL, path, slave, strlen(slave)); - free(path); - if (!success) - goto out; - - if (fcntl(dom->master_fd, F_SETFL, O_NONBLOCK) == -1) - goto out; return 1; out: @@ -523,21 +585,53 @@ static int xs_gather(struct xs_handle *xs, const char *dir, ...) return ret; } -static void domain_unmap_interface(struct domain *dom) +static void domain_unmap_interface(struct domain *dom, int console_type) { - if (dom->interface == NULL) + if (dom->interface[console_type] == NULL) return; - if (xgt_handle && dom->ring_ref == -1) - xengnttab_unmap(xgt_handle, dom->interface, 1); + if (xgt_handle && dom->ring_ref[console_type] == -1) + xengnttab_unmap(xgt_handle, dom->interface[console_type], 1); else - munmap(dom->interface, XC_PAGE_SIZE); - dom->interface = NULL; - dom->ring_ref = -1; + munmap(dom->interface[console_type], XC_PAGE_SIZE); + dom->interface[console_type] = NULL; + dom->ring_ref[console_type] = -1; +} + +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, vcon_remote_port, vcon_ring_ref; char *type, path[PATH_MAX]; err = xs_gather(xs, dom->conspath, @@ -547,6 +641,17 @@ static int domain_create_ring(struct domain *dom) if (err) goto out; + /* vcon console is optional. */ + err = xs_gather(xs, dom->conspath, + "vcon-ring-ref", "%u", &vcon_ring_ref, + "vcon-port", "%i", &vcon_remote_port, + NULL); + + if (err || vcon_ring_ref == -1) + dom->vcon_enabled = false; + else + dom->vcon_enabled = true; + snprintf(path, sizeof(path), "%s/type", dom->conspath); type = xs_read(xs, XBT_NULL, path, NULL); if (type && strcmp(type, "xenconsoled") != 0) { @@ -556,41 +661,51 @@ 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 != dom->ring_ref[CONSOLE_TYPE_PV] && dom->ring_ref[CONSOLE_TYPE_PV] != -1) + domain_unmap_interface(dom, CONSOLE_TYPE_PV); + + /* If using vcon ring_ref and it has changed, remap */ + if (dom->vcon_enabled && + vcon_ring_ref != dom->ring_ref[CONSOLE_TYPE_VCON] && + dom->ring_ref[CONSOLE_TYPE_VCON] != -1 ) + domain_unmap_interface(dom, CONSOLE_TYPE_VCON); - if (!dom->interface && xgt_handle) { + if (!dom->interface[CONSOLE_TYPE_PV] && 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; + dom->interface[CONSOLE_TYPE_PV] = xengnttab_map_grant_ref(xgt_handle, + dom->domid, GNTTAB_RESERVED_CONSOLE, + PROT_READ|PROT_WRITE); + dom->ring_ref[CONSOLE_TYPE_PV] = -1; } - if (!dom->interface) { + + if (!dom->interface[CONSOLE_TYPE_PV]) { /* Fall back to xc_map_foreign_range */ - dom->interface = xc_map_foreign_range( + dom->interface[CONSOLE_TYPE_PV] = xc_map_foreign_range( xc, dom->domid, XC_PAGE_SIZE, PROT_READ|PROT_WRITE, (unsigned long)ring_ref); - if (dom->interface == NULL) { + if (dom->interface[CONSOLE_TYPE_PV] == NULL) { err = EINVAL; goto out; } - dom->ring_ref = ring_ref; + dom->ring_ref[CONSOLE_TYPE_PV] = 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)) + /* Map vcon console ring buffer. */ + if (dom->vcon_enabled && !dom->interface[CONSOLE_TYPE_VCON]) { + + /* Fall back to xc_map_foreign_range */ + dom->interface[CONSOLE_TYPE_VCON] = xc_map_foreign_range( + xc, dom->domid, XC_PAGE_SIZE, + PROT_READ|PROT_WRITE, + (unsigned long)vcon_ring_ref); + if ( dom->interface[CONSOLE_TYPE_VCON] == NULL ) { + err = EINVAL; goto out; + } + dom->ring_ref[CONSOLE_TYPE_VCON] = vcon_ring_ref; } - dom->local_port = -1; - dom->remote_port = -1; if (dom->xce_handle != NULL) xenevtchn_close(dom->xce_handle); @@ -602,31 +717,46 @@ static int domain_create_ring(struct domain *dom) goto out; } - rc = xenevtchn_bind_interdomain(dom->xce_handle, - dom->domid, remote_port); - - if (rc == -1) { - err = errno; + err = bind_event_channel(dom, remote_port, + &dom->local_port[CONSOLE_TYPE_PV], + &dom->remote_port[CONSOLE_TYPE_PV]); + if (err) + { xenevtchn_close(dom->xce_handle); - dom->xce_handle = NULL; goto out; } - dom->local_port = rc; - dom->remote_port = remote_port; - if (dom->master_fd == -1) { + if (dom->vcon_enabled) + { + err = bind_event_channel(dom, vcon_remote_port, + &dom->local_port[CONSOLE_TYPE_VCON], + &dom->remote_port[CONSOLE_TYPE_VCON]); + if (err) + { + xenevtchn_close(dom->xce_handle); + goto out; + } + } + + if (dom->master_fd[CONSOLE_TYPE_PV] == -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; + dom->local_port[CONSOLE_TYPE_PV] = -1; + dom->remote_port[CONSOLE_TYPE_PV] = -1; + dom->local_port[CONSOLE_TYPE_VCON] = -1; + dom->remote_port[CONSOLE_TYPE_VCON] = -1; + dom->vcon_enabled = false; goto out; } } - if (log_guest && (dom->log_fd == -1)) - dom->log_fd = create_domain_log(dom); + if (log_guest && (dom->log_fd[CONSOLE_TYPE_PV] == -1)) + dom->log_fd[CONSOLE_TYPE_PV] = create_domain_log(dom, CONSOLE_TYPE_PV); + + if (log_guest && dom->vcon_enabled && (dom->log_fd[CONSOLE_TYPE_VCON] == -1)) + dom->log_fd[CONSOLE_TYPE_VCON] = create_domain_log(dom, CONSOLE_TYPE_VCON); out: return err; @@ -681,17 +811,24 @@ 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; + dom->master_fd[CONSOLE_TYPE_PV] = -1; + dom->master_pollfd_idx[CONSOLE_TYPE_PV] = -1; + dom->slave_fd[CONSOLE_TYPE_PV] = -1; + dom->master_fd[CONSOLE_TYPE_VCON] = -1; + dom->master_pollfd_idx[CONSOLE_TYPE_VCON] = -1; + dom->slave_fd[CONSOLE_TYPE_VCON] = -1; + dom->log_fd[CONSOLE_TYPE_PV] = -1; + dom->log_fd[CONSOLE_TYPE_VCON] = -1; dom->xce_pollfd_idx = -1; dom->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; - dom->ring_ref = -1; - dom->local_port = -1; - dom->remote_port = -1; + dom->ring_ref[CONSOLE_TYPE_PV] = -1; + dom->ring_ref[CONSOLE_TYPE_VCON] = -1; + dom->local_port[CONSOLE_TYPE_PV] = -1; + dom->remote_port[CONSOLE_TYPE_PV] = -1; + dom->local_port[CONSOLE_TYPE_VCON] = -1; + dom->remote_port[CONSOLE_TYPE_VCON] = -1; if (!watch_domain(dom, true)) goto out; @@ -737,13 +874,21 @@ static void cleanup_domain(struct domain *d) { domain_close_tty(d); - if (d->log_fd != -1) { - close(d->log_fd); - d->log_fd = -1; + if (d->log_fd[CONSOLE_TYPE_PV] != -1) { + close(d->log_fd[CONSOLE_TYPE_PV]); + d->log_fd[CONSOLE_TYPE_PV] = -1; + } + + if (d->log_fd[CONSOLE_TYPE_VCON] != -1) { + close(d->log_fd[CONSOLE_TYPE_VCON]); + d->log_fd[CONSOLE_TYPE_VCON] = -1; } - free(d->buffer.data); - d->buffer.data = NULL; + free(d->buffer[CONSOLE_TYPE_PV].data); + free(d->buffer[CONSOLE_TYPE_VCON].data); + + d->buffer[CONSOLE_TYPE_PV].data = NULL; + d->buffer[CONSOLE_TYPE_VCON].data = NULL; free(d->conspath); d->conspath = NULL; @@ -755,7 +900,8 @@ static void shutdown_domain(struct domain *d) { d->is_dead = true; watch_domain(d, false); - domain_unmap_interface(d); + domain_unmap_interface(d, CONSOLE_TYPE_PV); + domain_unmap_interface(d, CONSOLE_TYPE_VCON); if (d->xce_handle != NULL) xenevtchn_close(d->xce_handle); d->xce_handle = NULL; @@ -786,9 +932,9 @@ static void enum_domains(void) } } -static int ring_free_bytes(struct domain *dom) +static int ring_free_bytes(struct domain *dom, int console_type) { - struct xencons_interface *intf = dom->interface; + struct xencons_interface *intf = dom->interface[console_type]; XENCONS_RING_IDX cons, prod, space; cons = intf->in_cons; @@ -813,25 +959,26 @@ 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 domain *dom, int console_type) { ssize_t len = 0; char msg[80]; int i; - struct xencons_interface *intf = dom->interface; XENCONS_RING_IDX prod; + struct xencons_interface *intf=dom->interface[console_type]; + xenevtchn_port_or_error_t port=dom->local_port[console_type]; if (dom->is_dead) return; - len = ring_free_bytes(dom); + len = ring_free_bytes(dom, console_type); if (len == 0) return; if (len > sizeof(msg)) len = sizeof(msg); - len = read(dom->master_fd, msg, len); + len = read(dom->master_fd[console_type], 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 @@ -847,28 +994,29 @@ 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 domain *dom, int console_type) { ssize_t len; if (dom->is_dead) return; - len = write(dom->master_fd, dom->buffer.data + dom->buffer.consumed, - dom->buffer.size - dom->buffer.consumed); + len = write(dom->master_fd[console_type], + dom->buffer[console_type].data + dom->buffer[console_type].consumed, + dom->buffer[console_type].size - dom->buffer[console_type].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(&dom->buffer[console_type], len); } } @@ -884,7 +1032,10 @@ static void handle_ring_read(struct domain *dom) dom->event_count++; - buffer_append(dom); + if (port == dom->local_port[CONSOLE_TYPE_VCON]) + buffer_append(dom, CONSOLE_TYPE_VCON); + else + buffer_append(dom, CONSOLE_TYPE_PV); if (dom->event_count < RATE_LIMIT_ALLOWANCE) (void)xenevtchn_unmask(dom->xce_handle, port); @@ -954,9 +1105,16 @@ 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); + if (d->log_fd[CONSOLE_TYPE_PV] != -1) + close(d->log_fd[CONSOLE_TYPE_PV]); + d->log_fd[CONSOLE_TYPE_PV] = create_domain_log(d, CONSOLE_TYPE_PV); + + if (d->vcon_enabled) + { + if (d->log_fd[CONSOLE_TYPE_VCON] != -1) + close(d->log_fd[CONSOLE_TYPE_VCON]); + d->log_fd[CONSOLE_TYPE_PV] = create_domain_log(d, CONSOLE_TYPE_VCON); + } } } @@ -1074,7 +1232,9 @@ void handle_io(void) if ((now+5) > d->next_period) { d->next_period = now + RATE_LIMIT_PERIOD; if (d->event_count >= RATE_LIMIT_ALLOWANCE) { - (void)xenevtchn_unmask(d->xce_handle, d->local_port); + (void)xenevtchn_unmask(d->xce_handle, d->local_port[CONSOLE_TYPE_PV]); + if (d->vcon_enabled) + (void)xenevtchn_unmask(d->xce_handle, d->local_port[CONSOLE_TYPE_VCON]); } d->event_count = 0; } @@ -1087,27 +1247,47 @@ 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 (buffer_available(d, CONSOLE_TYPE_PV)) { + int evtchn_fd = xenevtchn_fd(d->xce_handle); + d->xce_pollfd_idx = set_fds(evtchn_fd, + POLLIN|POLLPRI); + } + + if (buffer_available(d, CONSOLE_TYPE_VCON ) ) + { 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) { + if (d->master_fd[CONSOLE_TYPE_PV] != -1) { short events = 0; - if (!d->is_dead && ring_free_bytes(d)) + if (!d->is_dead && ring_free_bytes(d, CONSOLE_TYPE_PV)) events |= POLLIN; - if (!buffer_empty(&d->buffer)) + if (!buffer_empty(&d->buffer[CONSOLE_TYPE_PV])) events |= POLLOUT; if (events) - d->master_pollfd_idx = - set_fds(d->master_fd, - events|POLLPRI); + d->master_pollfd_idx[CONSOLE_TYPE_PV] = + set_fds(d->master_fd[CONSOLE_TYPE_PV], + events|POLLPRI); + } + + if (d->vcon_enabled && d->master_fd[CONSOLE_TYPE_VCON] != -1) { + short events = 0; + if (!d->is_dead && ring_free_bytes(d, CONSOLE_TYPE_VCON)) + events |= POLLIN; + + if (!buffer_empty(&d->buffer[CONSOLE_TYPE_VCON])) + events |= POLLOUT; + + if (events) + d->master_pollfd_idx[CONSOLE_TYPE_VCON] = + set_fds(d->master_fd[CONSOLE_TYPE_VCON], + events|POLLPRI); } } @@ -1166,6 +1346,16 @@ void handle_io(void) for (d = dom_head; d; d = n) { n = d->next; + + /* + * Check if the data pending flag is set for any of the consoles. + * If yes then service those first. + */ + if ( d->console_data_pending & (1<console_data_pending & (1<event_count < RATE_LIMIT_ALLOWANCE) { if (d->xce_handle != NULL && d->xce_pollfd_idx != -1 && @@ -1176,22 +1366,36 @@ void handle_io(void) handle_ring_read(d); } - if (d->master_fd != -1 && d->master_pollfd_idx != -1) { - if (fds[d->master_pollfd_idx].revents & + if (d->master_fd[CONSOLE_TYPE_PV] != -1 && d->master_pollfd_idx[CONSOLE_TYPE_PV] != -1) { + if (fds[d->master_pollfd_idx[CONSOLE_TYPE_PV]].revents & + ~(POLLIN|POLLOUT|POLLPRI)) + domain_handle_broken_tty(d, domain_is_valid(d->domid)); + else { + if (fds[d->master_pollfd_idx[CONSOLE_TYPE_PV]].revents & + POLLIN) + handle_tty_read(d, CONSOLE_TYPE_PV); + if (fds[d->master_pollfd_idx[CONSOLE_TYPE_PV]].revents & + POLLOUT) + handle_tty_write(d, CONSOLE_TYPE_PV); + } + } + + if (d->master_fd[CONSOLE_TYPE_VCON] != -1 && d->master_pollfd_idx[CONSOLE_TYPE_VCON] != -1) { + if (fds[d->master_pollfd_idx[CONSOLE_TYPE_VCON]].revents & ~(POLLIN|POLLOUT|POLLPRI)) - domain_handle_broken_tty(d, - domain_is_valid(d->domid)); + domain_handle_broken_tty(d, domain_is_valid(d->domid)); else { - if (fds[d->master_pollfd_idx].revents & + if (fds[d->master_pollfd_idx[CONSOLE_TYPE_VCON]].revents & POLLIN) - handle_tty_read(d); - if (fds[d->master_pollfd_idx].revents & + handle_tty_read(d, CONSOLE_TYPE_VCON); + if (fds[d->master_pollfd_idx[CONSOLE_TYPE_VCON]].revents & POLLOUT) - handle_tty_write(d); + handle_tty_write(d, CONSOLE_TYPE_VCON); } } - d->xce_pollfd_idx = d->master_pollfd_idx = -1; + d->xce_pollfd_idx = d->master_pollfd_idx[CONSOLE_TYPE_PV] = + d->master_pollfd_idx[CONSOLE_TYPE_VCON] = -1; if (d->last_seen != enum_pass) shutdown_domain(d); From patchwork Mon Apr 3 09:44:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 96598 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp18516qgd; Mon, 3 Apr 2017 02:47:06 -0700 (PDT) X-Received: by 10.107.144.197 with SMTP id s188mr14664225iod.146.1491212826032; Mon, 03 Apr 2017 02:47:06 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id b41si14294218ioj.178.2017.04.03.02.47.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 02:47:06 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyY7-0001fR-NP; Mon, 03 Apr 2017 09:45:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyY6-0001eL-JZ for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 09:45:22 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id AC/7B-19731-2B912E85; Mon, 03 Apr 2017 09:45:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRusr7tR8lG Ewc8Fchbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8ajvduZCo5yVcyb+5exgfEURxcjJ4eQwAxG ia378roYuThYBOYxS/zeeYQJxJEQ6GeVuDT/CSNIlYRAjMSlGadZIewyiUl/HjNBdGtJHD01m xWkQUiglUmic9Fi5i5GDg42AROJWR0SIDUiAkoS91ZNBhvKLDCfUWJvz1mwQcICIRJX7z5jBa lnEVCVOPm8FiTMK+AjcfvZHzaIXXISN891go3kBIrfepUAsdZb4tX9aWwTGAUWMDKsYtQoTi0 qSy3SNTbWSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCrWS87P3cQIDCsGINjBuHN94CFGSQ4m JVHeN3ceRgjxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4M2VeBQhJFiUmp5akZaZAwxwmLQEB4+SC O8kkDRvcUFibnFmOkTqFKMux4f+w2+YhFjy8vNSpcR5I0GKBECKMkrz4EbAou0So6yUMC8j0F FCPAWpRbmZJajyrxjFORiVhHnngUzhycwrgdv0CugIJqAjnoDcz1tckoiQkmpgrM4UuHBkchN P+h3hPV83yenqsLZZNnwJUqkUnXjDTFbjhrdyuOxUPvvpOz7WGzJuf1oiJ8R9dYlIc61K0Xqd Tt1nXUsK97bNmnLlRXJFZtD/60F3Fuxd+/xkYN2KV2/b7rBOe6vquOo3993KCX8dttzLf61eZ agnX8fzekXl8e7C9sIvzW/PK7EUZyQaajEXFScCAOdA0h6xAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1491212720!95292087!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.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37290 invoked from network); 3 Apr 2017 09:45:21 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Apr 2017 09:45:21 -0000 Received: by mail-pg0-f47.google.com with SMTP id 81so115409615pgh.2 for ; Mon, 03 Apr 2017 02:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VhCtF7tcYUwxN/VzC9NCk7l2Euvb2P0oZ5/1sZpOEYU=; b=G/SSc9tIo/LCWZFYwlYp2z9K24Lul3OoOWjBB4/3si9dGLKwYsAuuav0KiS1my1mXt FgJ3qa6/yhkbpoDgXjriwWcS9S4s+HQWD/ry7n2pxXLGlVPIPJftMyh+rKcWyzSlmQBV G3PiMD/3TIV8YBOr2SOiBO9cAdi/u4uJ/K0pw= 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=VhCtF7tcYUwxN/VzC9NCk7l2Euvb2P0oZ5/1sZpOEYU=; b=hnisoJaGJB+Mhu4H9kSFMNsTxnVgDRTJ15o9B+btOwrjI2gb/3HmOUe6dkm/yAo9Cx Ew698s6nfHF+eNE2pb22LnGX8MuTkVV1msq9OKQFThWx2hLnY4F2NzjbXufTO6v96Lh2 sM1XHuPJ3ng1D/qPqSwEtyLsTfCaA/MTA7IrPUNBi8PVGHvGa/IENubN+3EAwyfKoh3R B0M1lqXU0qZkEfqbaL0Dz82lt1iXt8W8iEJUTOYcE5xQOPx0ODV08IkDeL9V+sFHtd6D FzKeJKyQaXFnLescbMunAO5UhDC8MdZLCaCVEAhnKPn4Ml6mSpnSr8KjQv/dToEXqD3E MDdg== X-Gm-Message-State: AFeK/H3wawt9fs0O4Z0qpgg6Xue1U1cW2xzXpORRiBrbiwtFUXz1QPgW2SJEjGBpps+o+BNm X-Received: by 10.84.236.5 with SMTP id q5mr20706184plk.2.1491212719893; Mon, 03 Apr 2017 02:45:19 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([202.46.23.54]) by smtp.gmail.com with ESMTPSA id y7sm24751844pfk.93.2017.04.03.02.45.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:45:19 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 3 Apr 2017 15:14:32 +0530 Message-Id: <1491212673-13476-10-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> References: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 09/10] xen/arm: vpl011: Add new virtual console 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 VCON to connect to the virtual console. Signed-off-by: Bhupinder Thakur --- tools/console/client/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index 977779f..03b6fb1 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -264,6 +264,7 @@ typedef enum { CONSOLE_INVAL, CONSOLE_PV, CONSOLE_SERIAL, + CONSOLE_VCON, } 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, "vcon")) + type = CONSOLE_VCON; 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_VCON) { + 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 Mon Apr 3 09:44:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 96604 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp18554qgd; Mon, 3 Apr 2017 02:47:11 -0700 (PDT) X-Received: by 10.36.220.6 with SMTP id q6mr8729278itg.77.1491212831655; Mon, 03 Apr 2017 02:47:11 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v16si10567532itb.66.2017.04.03.02.47.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 02:47:11 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyYC-0001iv-Vd; Mon, 03 Apr 2017 09:45:28 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuyYB-0001hc-24 for xen-devel@lists.xenproject.org; Mon, 03 Apr 2017 09:45:27 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id DF/EF-13192-6B912E85; Mon, 03 Apr 2017 09:45:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRWlGSWpSXmKPExsXiVRusr7tV8lG EweLj2hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aEWa3MBaulKt61vGdsYJwl0sXIwSEkMINR Yj5TFyMXB4vAPGaJ1/+nsoI4EgL9rBIL2tcDZTiBnBiJa0cPMYM0SAhUSXw96g4SFhLQkjh6a jZYvZBAK5PEjvY1rCA1bAImErM6JEBqRASUJO6tmgy2gFlgPqPE3p6zrCAJYYFIiY1nD4HNZx FQlZjffpMFxOYV8JE49OQCM8ReOYmb5zrB9nICxW+9SoDY6y3x6v40tgmMAgsYGVYxahSnFpW lFukaG+klFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgQGFQMQ7GA8vS7wEKMkB5OS KO+bOw8jhPiS8lMqMxKLM+KLSnNSiw8xynBwKEnw3pN4FCEkWJSanlqRlpkDDG+YtAQHj5II7 0WQNG9xQWJucWY6ROoUoy7Hh/7Db5iEWPLy81KlxHn3gxQJgBRllObBjYDF2iVGWSlhXkago4 R4ClKLcjNLUOVfMYpzMCoJ874UB5rCk5lXArfpFdARTEBHPAG5n7e4JBEhJdXA2P7gm1VEUb3 +kkDlmdoaplN+qrZ+XPgy2PLMcqt5jsZXpmzIeFS3a5dT6fkywf8My34f3KIjHLknqOfCJ5FH obtqpVnu98T81Q8/WzX37CktoZWCXd4T9SYeC8hMlf2uHzo/7PXFs3pRpVEvmLbdXjQtZ0Niw 1bh+g33Dar9fsndLcrcP3N3oxJLcUaioRZzUXEiAOjviZewAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-4.tower-21.messagelabs.com!1491212724!55577322!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.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1764 invoked from network); 3 Apr 2017 09:45:25 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-4.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Apr 2017 09:45:25 -0000 Received: by mail-pg0-f47.google.com with SMTP id g2so113991328pge.3 for ; Mon, 03 Apr 2017 02:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=At7GjhRsIhKcaRlGxMmcNdZMKlE/tGNO1ZVQg+7A7w0=; b=QdreyF8e36ELYaTKjAUn6Qc7FBeElHrmhX7e2L8EotbMblonNNMqAeKPP+D/LX1IW4 VOtpYGs5DU0UjbzduN+phIYk2q6UGfN97NpKaYAU1+ANGhuUG/sZP3cCd4FxH+pnOC6R DBaTHnZiSW56UTN2Ws1yhEkk33UNx0uZHlHbA= 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=At7GjhRsIhKcaRlGxMmcNdZMKlE/tGNO1ZVQg+7A7w0=; b=Zldrlf+PLTT+HiZvmnO/6H/k4XabCk0QjvXsVzwbqyzS5s0EeRUkmmoaswpILxkTC9 UPVf+2rcPSjaaayhFQeds8n86D9479s0+BQLaDEGuK+6Os3L1dksq4oYwXuAizJZJYB/ a2eIL38WcWjX1L/nCpzajuUyTpaS16pZpJB1mxN98r2MMN0vYR2ZSPIuS2SVegdxOfru fOPghUoLCZJhNwe7C5JGVW2tkvf0E8mMl7wd5M9XhkR1FaxpbFlqD5zyoWTsf6e21RqC n1hdNg/3CcUeunU7EBkEXzwi1mUi6REo/yWkOdI7fXNh3QsjKRUvlfAQS+bcBnv4xDTE lNGw== X-Gm-Message-State: AFeK/H3mDzIBqnhCutdTWaUNDwSMxBk3gi8RfjyP51/mnyWKsGqpKzP3Un7TRDSf6MsX3vsZ X-Received: by 10.99.114.89 with SMTP id c25mr17095749pgn.163.1491212724228; Mon, 03 Apr 2017 02:45:24 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([202.46.23.54]) by smtp.gmail.com with ESMTPSA id y7sm24751844pfk.93.2017.04.03.02.45.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:45:23 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 3 Apr 2017 15:14:33 +0530 Message-Id: <1491212673-13476-11-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> References: <1491212673-13476-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 10/10] 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 --- tools/libxl/libxl_arm.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..b25fff6 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -57,6 +57,13 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, nr_spis = spi + 1; } + /* + * If pl011 is enabled then increment the nr_spis to allow allocation + * of a SPI VIRQ for pl011. + */ + if (libxl_defbool_val(d_config->b_info.enable_pl011)) + nr_spis += 1; + LOG(DEBUG, "Configure the domain"); xc_config->nr_spis = nr_spis; @@ -130,9 +137,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 +598,39 @@ 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 +930,9 @@ next_resize: FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) ); FDT( make_hypervisor_node(gc, fdt, vers) ); + if ( libxl_defbool_val(info->enable_pl011) ) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) );