From patchwork Tue Feb 21 11:25:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94258 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396471qgi; Tue, 21 Feb 2017 03:28:17 -0800 (PST) X-Received: by 10.36.36.142 with SMTP id f136mr28396175ita.0.1487676496944; Tue, 21 Feb 2017 03:28:16 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 130si11288558iou.121.2017.02.21.03.28.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:16 -0800 (PST) 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 1cg8aN-0002gx-ML; Tue, 21 Feb 2017 11:26: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 1cg8aM-0002gQ-EZ for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:22 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 98/5C-27165-DD32CA85; Tue, 21 Feb 2017 11:26:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRWlGSWpSXmKPExsXiVRtsontHeU2 EwcebVhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bGJ81sBdu3MFYsf3CHpYGxpZexi5GLQ0hg GqPEna63rCAOi8A8ZokXv7vAHAmBflaJafcnsXcxcgI5MRILO+eyQtgVEieOdrKB2EICWhJHT 81mhbBbmSSOTw/uYuTgYBMwkZjVIQESFhFQkri3ajITiM0sECrx71kb2EhhAXeJqZfuMoLYLA KqEvunPGEGaeUV8JY40+sEsUlO4ua5TmYQm1PAR+LvvpfsEJu8JabdWcE2gVFgASPDKkaN4tS istQiXUNDvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MwNBiAIIdjJ+WBRxilORg UhLlzZZaEyHEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgneOElBOsCg1PbUiLTMHGOQwaQkOHiUR3 iOKQGne4oLE3OLMdIjUKUZ7jlu/Tr1k4ti3/QyQ/LITRO7adfklkxBLXn5eqpQ4bxnIVAGQto zSPLihsKi8xCgrJczLCHSmEE9BalFuZgmq/CtGcQ5GJWHe/SBTeDLzSuB2vwI6iwnorJseK0H OKklESEk1MMrVOn68k/jU4u6v418sChhmiU37bHFCbMKEU0usZwVs88nJ1dFiMUl59n7b0Z4Z /P+W+1nkvPr0curGYxv3V+5uKuH/8qzVqNf0kNmN1j2/HWwD4+wycpYIhHrPfXaWkXHp2fX+W UUR1neuiBbeYSy33/jw8IKz5zLmqz9NrHLODVlzcem7I0JKLMUZiYZazEXFiQBEX94SxQIAAA == X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-27.messagelabs.com!1487676379!64852943!1 X-Originating-IP: [74.125.83.52] X-SpamReason: No, hits=0.0 required=7.0 tests=UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51685 invoked from network); 21 Feb 2017 11:26:20 -0000 Received: from mail-pg0-f52.google.com (HELO mail-pg0-f52.google.com) (74.125.83.52) by server-10.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:20 -0000 Received: by mail-pg0-f52.google.com with SMTP id 1so16553564pgi.1 for ; Tue, 21 Feb 2017 03:26:20 -0800 (PST) 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=DlVmuYIXs5ywJmDBShT78+jnheTZTsjwqJeRy+GlkoA=; b=jG+9TMTAs//LIMcNgyjznHigZ/BbhfqHlhNu2hQHALZnhpZUo2GjXwoJRbmsgwIpkX B9TH6N1RVIOe/kLlM/Q9zkgOqMTRkl9D2TDmGU/20mIcqXo4ya11/cJpLh80PSQbvNra GwmZO4cHj/bCvuh58/cdXvGhJ6FYQ7RQZVMng= 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=DlVmuYIXs5ywJmDBShT78+jnheTZTsjwqJeRy+GlkoA=; b=ZHoIwSCpWFsS+UeSL1EmiuieSMfPwfH5do8xuiraLflUamCbDqJWNh41jp60/Hqyee 790w77Py+yfXqY4jJmg8d++VLNvP5sNvJYmkq+v5q0fEwtfUSP59X8g7Elcl6wyP2BR8 /QtQtBccEExlcYMR02Lqb7DArf21rGeWpb8jjJzZ11xKmIvlgv7deD/1AnYSj9qkKxwI Uap+SpYmVVch9tB5eki6VOQ9P/VyYvN0rLWce0fPcnjqYZlj6/A0oMLDiJaXLAfMGHRK E2WtAECEAv2YWE8vRk6+6soTb7osrEJHs/JbyvBiw5Lf51JLpYzot9yGOIq7FIpqTDWn FE5g== X-Gm-Message-State: AMke39kxJDXN33xTm010p0Jkj2AcfmpwQ+hXICnEpkOd1BIzU389KkEzR+0RZVmK8YRCnZf8 X-Received: by 10.99.112.75 with SMTP id a11mr33965286pgn.7.1487676378729; Tue, 21 Feb 2017 03:26:18 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:18 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:55:58 +0530 Message-Id: <1487676368-22356-2-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 01/11] 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: - It emulates DR read/write by reading and writing from/to the IN and OUT ring buffers and raising an event to dom0 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 Signed-off-by: Bhupinder Thakur --- xen/arch/arm/Makefile | 1 + xen/arch/arm/vpl011.c | 366 ++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vpl011.h | 208 ++++++++++++++++++++++++ xen/common/Kconfig | 6 + xen/include/asm-arm/domain.h | 15 ++ xen/include/public/arch-arm.h | 5 + 6 files changed, 601 insertions(+) create mode 100644 xen/arch/arm/vpl011.c create mode 100644 xen/arch/arm/vpl011.h 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..88ba968 --- /dev/null +++ b/xen/arch/arm/vpl011.c @@ -0,0 +1,366 @@ +/* + * arch/arm/vpl011.c + * + * Virtual PL011 UART + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include "vpl011.h" + +static int vpl011_mmio_read(struct vcpu *v, mmio_info_t *info, register_t *r, void *priv) +{ + unsigned char ch; + + switch (info->gpa - GUEST_PL011_BASE) + { + case VPL011_UARTCR_OFFSET: + *r = v->domain->arch.vpl011.control; + break; + case VPL011_UARTDR_OFFSET: + vpl011_read_data(v->domain, &ch); + *r = ch; + break; + case VPL011_UARTFR_OFFSET: + *r = v->domain->arch.vpl011.flag; + break; + case VPL011_UARTIMSC_OFFSET: + *r = v->domain->arch.vpl011.intr_mask; + break; + case VPL011_UARTICR_OFFSET: + *r = 0; + break; + case VPL011_UARTRIS_OFFSET: + *r = v->domain->arch.vpl011.raw_intr_status; + break; + case VPL011_UARTMIS_OFFSET: + *r = v->domain->arch.vpl011.raw_intr_status & + v->domain->arch.vpl011.intr_mask; + break; + case VPL011_UARTDMACR_OFFSET: + *r = 0; /* uart DMA is not supported. Here it always returns 0 */ + break; + case VPL011_UARTRSR_OFFSET: + *r = 0; /* it always returns 0 as there are no physical errors */ + break; + default: + printk ("vpl011_mmio_read: invalid switch case %d\n", (int)(info->gpa - GUEST_PL011_BASE)); + break; + } + + return VPL011_EMUL_OK; +} + +static int vpl011_mmio_write(struct vcpu *v, mmio_info_t *info, register_t r, void *priv) +{ + unsigned char ch = r; + + switch (info->gpa - GUEST_PL011_BASE) + { + case VPL011_UARTCR_OFFSET: + v->domain->arch.vpl011.control = r; + break; + case VPL011_UARTDR_OFFSET: + vpl011_write_data(v->domain, ch); + break; + case VPL011_UARTIMSC_OFFSET: + v->domain->arch.vpl011.intr_mask = r; + if ( (v->domain->arch.vpl011.raw_intr_status & v->domain->arch.vpl011.intr_mask) ) + vgic_vcpu_inject_spi(v->domain, (int)v->domain->arch.hvm_domain.params[HVM_PARAM_VPL011_VIRQ]); + break; + case VPL011_UARTICR_OFFSET: + /* + * clear all bits which are set in the input + */ + v->domain->arch.vpl011.raw_intr_status &= ~r; + if ( (v->domain->arch.vpl011.raw_intr_status & v->domain->arch.vpl011.intr_mask) ) + { + vgic_vcpu_inject_spi(v->domain, (int)v->domain->arch.hvm_domain.params[HVM_PARAM_VPL011_VIRQ]); + } + break; + case VPL011_UARTRSR_OFFSET: // nothing to clear + break; + case VPL011_UARTFR_OFFSET: // these are all RO registers + case VPL011_UARTRIS_OFFSET: + case VPL011_UARTMIS_OFFSET: + case VPL011_UARTDMACR_OFFSET: + break; + default: + printk ("vpl011_mmio_write: switch case not handled %d\n", (int)(info->gpa - GUEST_PL011_BASE)); + break; + } + + return VPL011_EMUL_OK; +} + +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) +{ + int rc=0; + + /* + * map the guest PFN to Xen address space + */ + rc = prepare_ring_for_helper(d, + d->arch.hvm_domain.params[HVM_PARAM_VPL011_CONSOLE_PFN], + &d->arch.vpl011.ring_page, + (void **)&d->arch.vpl011.ring_buf); + if ( rc < 0 ) + { + printk("Failed to map vpl011 guest PFN\n"); + } + + return rc; +} + +static int vpl011_data_avail(struct domain *d) +{ + int rc=0; + unsigned long flags; + + struct console_interface *intf=(struct console_interface *)d->arch.vpl011.ring_buf; + + VPL011_LOCK(d, flags); + + /*` + * check IN ring buffer + */ + if ( !VPL011_IN_RING_EMPTY(intf) ) + { + /* + * clear the RX FIFO empty flag as the ring is not empty + */ + d->arch.vpl011.flag &= ~(VPL011_UARTFR_RXFE); + + /* + * if the buffer is full then set the RX FIFO FULL flag + */ + if ( VPL011_IN_RING_FULL(intf) ) + d->arch.vpl011.flag |= (VPL011_UARTFR_RXFF); + + /* + * set the RX interrupt status + */ + d->arch.vpl011.raw_intr_status |= (VPL011_UARTRIS_RXRIS); + } + + /* + * check OUT ring buffer + */ + if ( !VPL011_OUT_RING_FULL(intf) ) + { + /* + * if the buffer is not full then clear the TX FIFO full flag + */ + d->arch.vpl011.flag &= ~(VPL011_UARTFR_TXFF); + + /* + * set the TX interrupt status + */ + d->arch.vpl011.raw_intr_status |= (VPL011_UARTRIS_TXRIS); + + if ( VPL011_OUT_RING_EMPTY(intf) ) + { + /* + * clear the uart busy flag and set the TX FIFO empty flag + */ + d->arch.vpl011.flag &= ~(VPL011_UARTFR_BUSY); + d->arch.vpl011.flag |= (VPL011_UARTFR_TXFE); + } + } + + VPL011_UNLOCK(d, flags); + + /* + * send an interrupt if it is not masked + */ + if ( (d->arch.vpl011.raw_intr_status & d->arch.vpl011.intr_mask) ) + vgic_vcpu_inject_spi(d, (int)d->arch.hvm_domain.params[HVM_PARAM_VPL011_VIRQ]); + + if ( !VPL011_OUT_RING_EMPTY(intf) ) + { + /* + * raise an interrupt to dom0 + */ + rc = raw_evtchn_send(d, + d->arch.hvm_domain.params[HVM_PARAM_VPL011_CONSOLE_EVTCHN], NULL); + + if ( rc < 0 ) + printk("Failed to send vpl011 interrupt to dom0\n"); + } + + return rc; +} + +int vpl011_read_data(struct domain *d, unsigned char *data) +{ + int rc=0; + unsigned long flags; + struct console_interface *intf=(struct console_interface *)d->arch.vpl011.ring_buf; + + *data = 0; + + VPL011_LOCK(d, flags); + + /* + * if there is data in the ring buffer then copy it to the output buffer + */ + if ( !VPL011_IN_RING_EMPTY(intf) ) + { + *data = intf->in[MASK_VPL011CONS_IDX(intf->in_cons++, intf->in)]; + } + + /* + * if the ring buffer is empty then set the RX FIFO empty flag + */ + if ( VPL011_IN_RING_EMPTY(intf) ) + { + d->arch.vpl011.flag |= (VPL011_UARTFR_RXFE); + d->arch.vpl011.raw_intr_status &= ~(VPL011_UARTRIS_RXRIS); + } + + /* + * clear the RX FIFO full flag + */ + d->arch.vpl011.flag &= ~(VPL011_UARTFR_RXFF); + + VPL011_UNLOCK(d, flags); + + return rc; +} + +int vpl011_write_data(struct domain *d, unsigned char data) +{ + int rc=0; + unsigned long flags; + struct console_interface *intf=(struct console_interface *)d->arch.vpl011.ring_buf; + + VPL011_LOCK(d, flags); + + /* + * if there is space in the ring buffer then write the data + */ + if ( !VPL011_OUT_RING_FULL(intf) ) + { + intf->out[MASK_VPL011CONS_IDX(intf->out_prod++, intf->out)] = data; + smp_wmb(); + } + + /* + * if there is no space in the ring buffer then set the + * TX FIFO FULL flag + */ + if ( VPL011_OUT_RING_FULL(intf) ) + { + d->arch.vpl011.flag |= (VPL011_UARTFR_TXFF); + d->arch.vpl011.raw_intr_status &= ~(VPL011_UARTRIS_TXRIS); + } + + /* + * set the uart busy status + */ + d->arch.vpl011.flag |= (VPL011_UARTFR_BUSY); + + /* + * clear the TX FIFO empty flag + */ + d->arch.vpl011.flag &= ~(VPL011_UARTFR_TXFE); + + VPL011_UNLOCK(d, flags); + + /* + * raise an event to dom0 only if it is the first character in the buffer + */ + if ( VPL011_RING_DEPTH(intf, out) == 1 ) + { + rc = raw_evtchn_send(d, + d->arch.hvm_domain.params[HVM_PARAM_VPL011_CONSOLE_EVTCHN], NULL); + + if ( rc < 0 ) + printk("Failed to send vpl011 interrupt to dom0\n"); + } + + return rc; +} + +static void vpl011_notification(struct vcpu *v, unsigned int port) +{ + vpl011_data_avail(v->domain); +} + +int domain_vpl011_init(struct domain *d) +{ + int rc=0; + + /* + * register xen event channel + */ + rc = alloc_unbound_xen_event_channel(d, 0, current->domain->domain_id, + vpl011_notification); + if (rc < 0) + { + printk ("Failed to allocate vpl011 event channel\n"); + return rc; + } + d->arch.hvm_domain.params[HVM_PARAM_VPL011_CONSOLE_EVTCHN] = rc; + + /* + * allocate an SPI VIRQ for the guest + */ + d->arch.hvm_domain.params[HVM_PARAM_VPL011_VIRQ] = vgic_allocate_spi(d); + + /* + * register mmio handler + */ + register_mmio_handler (d, &vpl011_mmio_handler, GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL); + + /* + * initialize the lock + */ + spin_lock_init(&d->arch.vpl011.lock); + + /* + * clear the flag, control and interrupt status registers + */ + d->arch.vpl011.control = 0; + d->arch.vpl011.flag = 0; + d->arch.vpl011.intr_mask = 0; + d->arch.vpl011.intr_clear = 0; + d->arch.vpl011.raw_intr_status = 0; + d->arch.vpl011.masked_intr_status = 0; + + return 0; +} diff --git a/xen/arch/arm/vpl011.h b/xen/arch/arm/vpl011.h new file mode 100644 index 0000000..f2c577f --- /dev/null +++ b/xen/arch/arm/vpl011.h @@ -0,0 +1,208 @@ +/* + * 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_ + +/* + * register offsets + */ +#define VPL011_UARTDR_OFFSET 0x0 // data register (RW) +#define VPL011_UARTRSR_OFFSET 0x4 // receive status and error clear register (RW) +#define VPL011_UARTFR_OFFSET 0x18 // flag register (RO) +#define VPL011_UARTRIS_OFFSET 0x3c // raw interrupt status register (RO) +#define VPL011_UARTMIS_OFFSET 0x40 // masked interrupt status register (RO) +#define VPL011_UARTIMSC_OFFSET 0x38 // interrupt mask set/clear register (RW) +#define VPL011_UARTICR_OFFSET 0x44 // interrupt clear register (WO) +#define VPL011_UARTCR_OFFSET 0x30 // uart control register +#define VPL011_UARTDMACR_OFFSET 0x48 // uart dma control register + +/* + * control register bits - RW + */ +#define VPL011_UARTCR_UARTEN_BIT 0 +#define VPL011_UARTCR_UARTEN (1<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) + +/* + * MMIO return values + */ +#define VPL011_EMUL_OK 1 +#define VPL011_EMUL_FAIL 0 + +int domain_vpl011_init(struct domain *d); +int vpl011_map_guest_page(struct domain *d); +int vpl011_read_data(struct domain *d, unsigned char *data); +int vpl011_write_data(struct domain *d, unsigned char data); + +#define MASK_VPL011CONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1)) +struct console_interface { + char in[1024]; + char out[2048]; + uint32_t in_cons, in_prod; + uint32_t out_cons, out_prod; +}; +#endif diff --git a/xen/common/Kconfig b/xen/common/Kconfig index f2ecbc4..7e2feac 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -237,4 +237,10 @@ config FAST_SYMBOL_LOOKUP The only user of this is Live patching. If unsure, say Y. + +config VPL011_CONSOLE + bool "Emulated pl011 console support" + default y + ---help--- + Allows a guest to use pl011 UART as a console endmenu diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 2d6fbb1..ff2403a 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -40,6 +40,7 @@ struct vtimer { uint64_t cval; }; + struct arch_domain { #ifdef CONFIG_ARM_64 @@ -131,6 +132,20 @@ struct arch_domain struct { uint8_t privileged_call_enabled : 1; } monitor; + +#ifdef CONFIG_VPL011_CONSOLE + struct vpl011 { + void *ring_buf; + struct page_info *ring_page; + uint32_t flag; /* flag register */ + uint32_t control; /* control register */ + uint32_t intr_mask; /* interrupt mask register*/ + uint32_t intr_clear; /* interrupt clear register */ + uint32_t raw_intr_status; /* raw interrupt status register */ + uint32_t masked_intr_status; /* masked interrupt register */ + spinlock_t lock; + } vpl011; +#endif } __cacheline_aligned; struct arch_vcpu diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index bd974fb..1d4548f 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -410,6 +410,10 @@ typedef uint64_t xen_callback_t; #define GUEST_ACPI_BASE 0x20000000ULL #define GUEST_ACPI_SIZE 0x02000000ULL +/* PL011 mappings */ +#define GUEST_PL011_BASE 0x22000000ULL +#define GUEST_PL011_SIZE 0x00001000ULL + /* * 16MB == 4096 pages reserved for guest to use as a region to map its * grant table in. @@ -420,6 +424,7 @@ typedef uint64_t xen_callback_t; #define GUEST_MAGIC_BASE xen_mk_ullong(0x39000000) #define GUEST_MAGIC_SIZE xen_mk_ullong(0x01000000) + #define GUEST_RAM_BANKS 2 #define GUEST_RAM0_BASE xen_mk_ullong(0x40000000) /* 3GB of low RAM @ 1GB */ From patchwork Tue Feb 21 11:25:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94253 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396412qgi; Tue, 21 Feb 2017 03:28:07 -0800 (PST) X-Received: by 10.36.216.213 with SMTP id b204mr7463701itg.66.1487676487666; Tue, 21 Feb 2017 03:28:07 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id b20si20007380ioe.107.2017.02.21.03.28.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:07 -0800 (PST) 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 1cg8aQ-0002if-1a; Tue, 21 Feb 2017 11:26:26 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8aO-0002hu-KJ for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:24 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id D2/C9-31146-FD32CA85; Tue, 21 Feb 2017 11:26:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRWlGSWpSXmKPExsXiVRusq3tfeU2 EwcGP4hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8astsuMBT3SFT0v3jE1MO4W7mLk4hASmMko 0b2xmQ3EYRGYxyzx9OgH9i5GTg4JgX5Wie5PvBB2jMT8WT9ZIexKiQdL9jKB2EICWhJHT81mh ZjUyiTx5egXoGYODjYBE4lZHRIgNSICShL3Vk0Gq2cWCJX496wNrERYIFbi9vo6kDCLgKpEx9 3NYCW8At4Sn7p2MkGskpO4ea6TGcTmFPCR+LvvJTvEWm+JaXdWsE1gFFjAyLCKUb04tagstUj XUC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzCoGIBgB+PO506HGCU5mJREebOl 1kQI8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuCdowSUEyxKTU+tSMvMAYY3TFqCg0dJhPeIIlCat 7ggMbc4Mx0idYpRl2PXrssvmYRY8vLzUqXEectAZgiAFGWU5sGNgMXaJUZZKWFeRqCjhHgKUo tyM0tQ5V8xinMwKgnzdoJM4cnMK4Hb9AroCCagI256rAQ5oiQRISXVwDijPWf79n8L3s+p9sn p2nZAYMmD3z2bVD92RC5SFG978k3WfwZj6ckb0k/FjSs8KhbUvzzceynsECO7Tv6vG78FL15v vTRFyt/XVE44bbVwwf8lB4w9UkP2fjM+/OW0o4Z93rTjWWdX6U5LKU9Js3hf8WnRkTlVinvcU oo26Rv3lq9/duS8xSolluKMREMt5qLiRAARvmJ+sAIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1487676382!78611974!1 X-Originating-IP: [74.125.83.45] X-SpamReason: No, hits=0.0 required=7.0 tests=UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25797 invoked from network); 21 Feb 2017 11:26:23 -0000 Received: from mail-pg0-f45.google.com (HELO mail-pg0-f45.google.com) (74.125.83.45) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:23 -0000 Received: by mail-pg0-f45.google.com with SMTP id b129so34936775pgc.2 for ; Tue, 21 Feb 2017 03:26:23 -0800 (PST) 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=dVUyLnPmFnonoRCkCBBUBs+RnEM6ldsiNXVN8oZne5I=; b=ZhzBjK+/vvAxXicAh0wCNPfc3WUzRVJ5Cg01DGmZ1LwbW2UhQH+KPVpT7WQvuzK8jw o8ZLzt9699/3MiAWV1ao+LDm932HWyxI5CnX3kocDv4f7ifs7QZIxqu17nxnzFAvzk3K YYzYN1UYaJDhfK8vVZXlPSpFqtzfDqkmoejmc= 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=dVUyLnPmFnonoRCkCBBUBs+RnEM6ldsiNXVN8oZne5I=; b=j/MbsvyTVeRp4IecvO12IDRpyBBr/11uRpHlIoWTPqx06ykUk9Ua3y31i9hkuTNYEY UZdkk/1fB+oCXRfeCku8Cgam8yDmRFmE8ed069xQECQyrFTpeO4CppsMiqQCJkNk+dMH uczqF5Ul+iU6Kib2uAXoSyo5SzSjIIc6Kx6/JOJFcAE37TSFQY2bnV5KMYkXXgxzSjzz ZWLNZ5nqRPHIUDIm3bphragDQXST0oAnvY9T+jbVweC+j2eKsdmwSd/J87FQ05ND7thp NFR5m+Juao/Q6IyhumBWmidUx5gAD+61JxJ0X84w7CTbN3s/aGAC+LVSte2+dSkPd4XL sBaQ== X-Gm-Message-State: AMke39klsXaPYv1yH0KakAC5LL7EFYpPRAVdLHw+CZoh+NZY6dYs14cZ6u2J9iLfq25MNazE X-Received: by 10.99.175.67 with SMTP id s3mr12651064pgo.185.1487676381704; Tue, 21 Feb 2017 03:26:21 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:21 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:55:59 +0530 Message-Id: <1487676368-22356-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 02/11] xen/arm: vpl011: Add new hvm params in Xen for ring buffer/event setup 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" Three new HVM param handlers added for: - allocating a new VIRQ and return to the toolstack - allocating a new event channel for sending/receiving events from Xen and return to the toolstack - mapping the PFN allocted by the toolstack to be used as IN/OUT ring buffers Signed-off-by: Bhupinder Thakur --- xen/arch/arm/hvm.c | 39 +++++++++++++++++++++++++++++++++++++++ xen/include/public/hvm/params.h | 10 +++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c index d999bde..f3b9eb1 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,7 @@ #include #include +#include "vpl011.h" long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) { @@ -61,9 +64,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; + +#ifdef CONFIG_VPL011_CONSOLE + /* + * if it is a vpl011 console pfn then map it to its + * own address space + */ + if ( a.index == HVM_PARAM_VPL011_CONSOLE_PFN ) + { + vpl011_map_guest_page(d); + } +#else + /* + * if VPL011 is not compiled in then disallow setting of any + * related HVM params + */ + if ( a.index == HVM_PARAM_VPL011_CONSOLE_PFN || + a.index == HVM_PARAM_VPL011_CONSOLE_EVTCHN || + a.index == HVM_PARAM_VPL011_VIRQ ) + { + rc = -1; + goto param_fail; + } +#endif } else { +#ifndef CONFIG_VPL011_CONSOLE + /* + * if VPL011 is not compiled in then disallow setting of any + * related HVM params + */ + if ( a.index == HVM_PARAM_VPL011_CONSOLE_PFN || + a.index == HVM_PARAM_VPL011_CONSOLE_EVTCHN || + a.index == HVM_PARAM_VPL011_VIRQ ) + { + rc = -1; + goto param_fail; + } +#endif 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..13bf719 100644 --- a/xen/include/public/hvm/params.h +++ b/xen/include/public/hvm/params.h @@ -203,10 +203,17 @@ */ #define HVM_PARAM_ACPI_IOPORTS_LOCATION 19 -/* Deprecated */ +#if defined(__arm__) || defined(__aarch64__) +#define HVM_PARAM_VPL011_CONSOLE_PFN 20 +#define HVM_PARAM_VPL011_CONSOLE_EVTCHN 21 +#define HVM_PARAM_VPL011_VIRQ 22 +#else #define HVM_PARAM_MEMORY_EVENT_CR0 20 #define HVM_PARAM_MEMORY_EVENT_CR3 21 #define HVM_PARAM_MEMORY_EVENT_CR4 22 +#endif + +/* Deprecated */ #define HVM_PARAM_MEMORY_EVENT_INT3 23 #define HVM_PARAM_MEMORY_EVENT_SINGLE_STEP 25 #define HVM_PARAM_MEMORY_EVENT_MSR 30 @@ -253,6 +260,7 @@ */ #define HVM_PARAM_X87_FIP_WIDTH 36 + #define HVM_NR_PARAMS 37 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */ From patchwork Tue Feb 21 11:26:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94254 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396443qgi; Tue, 21 Feb 2017 03:28:12 -0800 (PST) X-Received: by 10.36.8.70 with SMTP id 67mr10613938itc.20.1487676492399; Tue, 21 Feb 2017 03:28:12 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n5si19968178iof.45.2017.02.21.03.28.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:12 -0800 (PST) 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 1cg8aT-0002kW-95; Tue, 21 Feb 2017 11:26:29 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8aS-0002jm-Ci for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:28 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 77/21-13524-3E32CA85; Tue, 21 Feb 2017 11:26:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRtsrPtQeU2 Ewdd7Jhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a1h3uYC7bLVDQf3cjcwHhRrIuRi0NIYCaj xPnW/4wgDovAPGaJs9fWsIA4EgL9rBJ3W/vZuxg5gZwYiX+/PzFC2BUSbTtuMoHYQgJaEkdPz WaFGNXKJHFm4QegBAcHm4CJxKwOCZAaEQEliXurJoPVMwuESvx71gY2U1igROL1qQdgcRYBVY kDF0+DxXkFvCVe/v3HCrFLTuLmuU5mEJtTwEfi776X7BB7vSWm3VnBNoFRYAEjwypGjeLUorL UIl0jC72kosz0jJLcxMwcXUMDM73c1OLixPTUnMSkYr3k/NxNjMDQYgCCHYzn1wYeYpTkYFIS 5c2WWhMhxJeUn1KZkVicEV9UmpNafIhRhoNDSYJ3jhJQTrAoNT21Ii0zBxjkMGkJDh4lEd4ji kBp3uKCxNzizHSI1ClGY45TN06/ZOLYtevySyYhlrz8vFQpcd4ykEkCIKUZpXlwg2DRd4lRVk qYlxHoNCGegtSi3MwSVPlXjOIcjErCvBzAWBbiycwrgdv3CugUJqBTbnqsBDmlJBEhJdXA6KA /M39vHONExvN/FJpDtfN+l/x7Pi9iWsqbgmXrUzu7ebZy9/75WSDAweXF4ddc+O7SirbfX9yz ls5ZZ73UoLF47uGaX8rbY36+OvHDt3Vr/wPmBW7Pvm25H3bButT45eqT/1bfDrLYUpEp2Njd+ U2QmWd290O/tRdnlvBoR9/ZfvfU2Yf/jymxFGckGmoxFxUnAgDntz4quQIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-21.messagelabs.com!1487676384!52965562!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 57669 invoked from network); 21 Feb 2017 11:26:25 -0000 Received: from mail-pg0-f51.google.com (HELO mail-pg0-f51.google.com) (74.125.83.51) by server-14.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:25 -0000 Received: by mail-pg0-f51.google.com with SMTP id a123so33306486pgc.0 for ; Tue, 21 Feb 2017 03:26:25 -0800 (PST) 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=YbDdgvYJAB5qY+CEQBs44Dp+uG0b76kajL+9CESUG0w=; b=UpLP7VAGjx53oo9QICyv91PgMk9ZOkucEbLbVysvJ6dfy5xkDLJGJig4WTAZa0Ys+f ySsqRfkV/bJsoMbvQ9oZy69pep+jag0WMgJhhbbbtCwhzsCAPgxmyqSmTDbMGAaFB3+N Ud5HIGtj2rQyWsdOhV6h7ebGvKM1tllYvyUVs= 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=YbDdgvYJAB5qY+CEQBs44Dp+uG0b76kajL+9CESUG0w=; b=L702/vk6OcqRPt6wbof8JaRSzKvRVc/K77ChIDIOg0Kog3SukUkrQZ3hwK0MQaG6ZQ OY9VXbmrFgxIs9HVeXuWi8OKEB19kFPAi77hVlNc8Jf6WUBEUZEEtfrqMdg9SahqE5pm +4+j9WTZR7KVaBVyHvcFXehDciuhAlIRms2Czvp1PFjatG1SrDxoLrcAkSoQEM08uVtt cmQxZFMSjq2IewnN3ACWjrRWubxUTIMhY3Isk0icZ/zpj4+NEdPsm3R5GPAj40204S4O zYb3BTuSVzIHmxgXtHd1cO42g/sapgB68UpI7KYUVlJf3n7RV+FUOCmBnk7J+CTDH2S5 J0Qg== X-Gm-Message-State: AMke39nuqZHQxuAKyTVuTgeCKq/QYVgtz3ijmYw3I0ezc9jTy5qVXp1srMvVo8A5SChYn2fA X-Received: by 10.84.217.65 with SMTP id e1mr39260441plj.40.1487676384397; Tue, 21 Feb 2017 03:26:24 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:23 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:00 +0530 Message-Id: <1487676368-22356-4-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 03/11] xen/arm: vpl011: Refactor evtchn_send in Xen to allow sending events from a xen bound channel 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" Breakup evtchn_send() to allow sending events for a Xen bound channel. Currently, there is a check in evtchn_send() i.e. is_consumer_xen() that if the event channel is bound to a xen consumer then event generation is not allowed for that channel. This check is to disallow a guest from raising an event via this channel. However, it should allow Xen to send a event via this channel as it is required for sending vpl011 event to the dom0. This change introduces a new function raw_evtchn_send() which sends the event without this check. The current evtchn_send() calls this function after doing the xen consumer check. Xen uses the raw_evtchm_send() version to send the event thus bypassing the check. Signed-off-by: Bhupinder Thakur --- xen/common/event_channel.c | 49 ++++++++++++++++++++++++++++++++++------------ xen/include/xen/event.h | 6 ++++++ 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 638dc5e..4b039f3 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -650,25 +651,21 @@ static long evtchn_close(struct domain *d1, int port1, bool_t guest) return rc; } -int evtchn_send(struct domain *ld, unsigned int lport) +int raw_evtchn_send(struct domain *ld, unsigned int lport, void *data) { struct evtchn *lchn, *rchn; struct domain *rd; - int rport, ret = 0; + int rport, ret=0; - if ( !port_is_valid(ld, lport) ) - return -EINVAL; - - lchn = evtchn_from_port(ld, lport); - - spin_lock(&lchn->lock); - - /* Guest cannot send via a Xen-attached event channel. */ - if ( unlikely(consumer_is_xen(lchn)) ) + if ( !data ) { - ret = -EINVAL; - goto out; + if ( !port_is_valid(ld, lport) ) + return -EINVAL; + lchn = evtchn_from_port(ld, lport); + spin_lock(&lchn->lock); } + else + lchn = (struct evtchn *)data; ret = xsm_evtchn_send(XSM_HOOK, ld, lchn); if ( ret ) @@ -696,6 +693,32 @@ int evtchn_send(struct domain *ld, unsigned int lport) } out: + if ( !data ) + spin_unlock(&lchn->lock); + + return ret; +} + +int evtchn_send(struct domain *ld, unsigned int lport) +{ + struct evtchn *lchn; + int ret; + + if ( !port_is_valid(ld, lport) ) + return -EINVAL; + + lchn = evtchn_from_port(ld, lport); + + spin_lock(&lchn->lock); + + if ( unlikely(consumer_is_xen(lchn)) ) + { + printk("evtchn_send failed to send via xen event channel\n"); + return -EINVAL; + } + + ret = raw_evtchn_send(ld, lport, lchn); + spin_unlock(&lchn->lock); return ret; diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index 5008c80..9bd17db 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -45,6 +45,12 @@ void send_guest_pirq(struct domain *, const struct pirq *); /* Send a notification from a given domain's event-channel port. */ int evtchn_send(struct domain *d, unsigned int lport); +/* + * This function is same as evntchn_send() except it does not do xen consumer check + * to allow the events to be sent from xen bound channels. + */ +int raw_evtchn_send(struct domain *ld, unsigned int lport, void *data); + /* Bind a local event-channel port to the specified VCPU. */ long evtchn_bind_vcpu(unsigned int port, unsigned int vcpu_id); From patchwork Tue Feb 21 11:26:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94255 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396464qgi; Tue, 21 Feb 2017 03:28:15 -0800 (PST) X-Received: by 10.107.16.208 with SMTP id 77mr19609298ioq.25.1487676494976; Tue, 21 Feb 2017 03:28:14 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o4si10936390iti.126.2017.02.21.03.28.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:14 -0800 (PST) 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 1cg8aV-0002lx-Ge; Tue, 21 Feb 2017 11:26:31 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8aT-0002kb-O3 for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:29 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id CA/C1-13192-5E32CA85; Tue, 21 Feb 2017 11:26:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRuspftEeU2 EwcZ94hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bZzg2sBQuEKuZMWsPYwNjA38XIxSEkMI1R 4uK0w+wgDovAPGaJ84feMII4EgL9rBL3Z6wEcjiBnBiJz5sOMkHYFRIL9/wCs4UEtCSOnprNC jGqlUniy62LLF2MHBxsAiYSszokQGpEBJQk7q2aDFbPLBAq8e9ZGzuILSwQLPH0wVdmEJtFQF Vi2befzCCtvALeEm072SBWyUncPNcJVsIp4CPxd99Ldoi13hLT7qxgm8AosICRYRWjenFqUVl qka6hXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGYFgxAMEOxp3PnQ4xSnIwKYny ZkutiRDiS8pPqcxILM6ILyrNSS0+xCjDwaEkwTtHCSgnWJSanlqRlpkDDHCYtAQHj5II7xFFo DRvcUFibnFmOkTqFKMux65dl18yCbHk5eelSonzloHMEAApyijNgxsBi7ZLjLJSwryMQEcJ8R SkFuVmlqDKv2IU52BUEubtBJnCk5lXArfpFdARTEBH3PRYCXJESSJCSqqBscJ/6ub13U/3MM9 P8vhoylLPsOKEkeafjhbZSK9HAabp/SvjdtirzZ+du9q7YJ2KiSnnijMfFhp+Ltvwft7Gw+Uv eyStUsVXLF5pHs7xzHdR6Q8Bh8+R7wOefDpX6fJrjUig6dU1LGyHa79NrNwbsSDf5hy/hLfbl ka967MPTozQT454aDHlgRJLcUaioRZzUXEiAN+5fdGxAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-7.tower-21.messagelabs.com!1487676387!58785882!1 X-Originating-IP: [74.125.83.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15075 invoked from network); 21 Feb 2017 11:26:28 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:28 -0000 Received: by mail-pg0-f42.google.com with SMTP id 1so16555103pgi.1 for ; Tue, 21 Feb 2017 03:26:28 -0800 (PST) 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=Z8YomainCsJcOV2QYn0R4tQly77A8VFssvyoNnV+hJ0=; b=S9GeOOccfCjf3YSx7m6g98EuUYxy8XVA4p29eSWyFgvVEPiQKmNgIOeT2KyzCOetxP 97IGnkFDEiFTQ3KbgyG8wanwz50Mm+xGedgdVgnDFvtGUJq4xa6GtA/bw4z23sFLQ0Bu rpBwBYz2fGZwNZULr5SnGveDf1hVybjb4b/ac= 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=Z8YomainCsJcOV2QYn0R4tQly77A8VFssvyoNnV+hJ0=; b=EUtPKeDsvf3YekaT0g/+8faVTiISEDESu8BokS68ew92lrH+yhBe5bFF265UxiLAH4 Kz9nQjbGhP+ix7WZHA9GTfnwQwZ2huGhKMRSGuyt2+4xUe5qKQ9+UpQf5qQVQSGi6XbW t8yUCbZwaBSrGPl6ClMA9JiQ8O1BrEq6ZvNYHloItkZHqV8Lv5rXYaTAIe69QmEqJZju b6wu2XLjObrsaLwDixkYdfVSoMg4lmzXoVccmwEnbqNpMubop3RFXL6SWNRMZ/O8NhNV ViRZqlOYd6HfvN/EwagyBJ0pcEJ4h6mWXTlrl9eE71bJrdPwlGmweSE9+HBsHZR/kOMa kvag== X-Gm-Message-State: AMke39nVzVEX/FM5U2pBUOYJu0P/5qNvnYsQ0ieQFlo6GGpmEKm2M16oECctrqIkDvlBOpZ6 X-Received: by 10.84.229.9 with SMTP id b9mr39309309plk.175.1487676386964; Tue, 21 Feb 2017 03:26:26 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:26 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:01 +0530 Message-Id: <1487676368-22356-5-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 04/11] xen/arm: vpl011: Enable vpl011 emulation for a 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" Based on one of the domain creation flags, the vpl011 emulation will be enabled for the domain. This flag is currently set always but finally it needs to be controlled by the user through some configuration option. Signed-off-by: Bhupinder Thakur --- xen/arch/arm/domain.c | 8 ++++++++ xen/common/domctl.c | 2 ++ xen/include/xen/sched.h | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 7e43691..6fee541 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 "vpl011.h" +#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; +#ifdef CONFIG_VPL011_CONSOLE + if ( domcr_flags & DOMCRF_vpl011_console ) + if ( (rc = domain_vpl011_init(d)) != 0 ) + goto fail; +#endif update_domain_wallclock_time(d); /* diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 12cf4a9..fafc506 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -551,6 +551,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_xs_domain ) domcr_flags |= DOMCRF_xs_domain; + domcr_flags |= DOMCRF_vpl011_console; + d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref, &op->u.createdomain.config); if ( IS_ERR(d) ) diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 063efe6..9e03a60 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_vpl011_console: create domain with pl011 emulation enabled */ +#define _DOMCRF_vpl011_console 7 +#define DOMCRF_vpl011_console (1U<<_DOMCRF_vpl011_console) + /* * 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 Tue Feb 21 11:26:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94257 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396472qgi; Tue, 21 Feb 2017 03:28:17 -0800 (PST) X-Received: by 10.36.200.9 with SMTP id w9mr27470062itf.113.1487676497177; Tue, 21 Feb 2017 03:28:17 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id r30si20056863ioi.31.2017.02.21.03.28.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:17 -0800 (PST) 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 1cg8aZ-0002pK-Vm; Tue, 21 Feb 2017 11:26:35 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8aY-0002o3-Me for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:34 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 0C/43-25657-9E32CA85; Tue, 21 Feb 2017 11:26:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXiVRusq/tceU2 EwZV/nBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8alk1NZC/awVczZvJulgXE2axcjF4eQwAxG ibNrZ4E5LALzmCVufFnBAuJICPSzSsy5tIO9i5EDyImReDM5vouRE8gsk1i0u4kFxBYS0JI4e gpmUiuTxM6e/cwg9WwCJhKzOiRAakQElCTurZrMBGIzC4RK/HvWBjZSWCBa4sE2bpAwi4CqxL FXG1hBbF4Bb4nJtzYwQqySk7h5rpMZxOYU8JH4u+8lO8Rab4lpd1awTWAUWMDIsIpRozi1qCy 1SNfITC+pKDM9oyQ3MTNH19DAWC83tbg4MT01JzGpWC85P3cTIzCs6hkYGHcwNuz1O8QoycGk JMqbLbUmQogvKT+lMiOxOCO+qDQntfgQowwHh5IEr5wSUE6wKDU9tSItMwcY4DBpCQ4eJRHeI 4pAad7igsTc4sx0iNQpRmOOU58uvGTi2LXr8ksmIZa8/LxUKXHe6yClAiClGaV5cINgkXeJUV ZKmJeRgYFBiKcgtSg3swRV/hWjOAejkjBvJ8g9PJl5JXD7XgGdwgR0yk2PlSCnlCQipKQaGM3 kzMr5VVl2L4h5eWzm4+88jkWHpgQ6rhcLzl/4cVZRTpT+EdWjT98nvU+X2DTh0kL/QoFtKeem LRabxsT4a72qVoT68gVHnjNEqzi7islEl/FyHbDnnFv5tiFTufTbl12e84++PaW2b4dsem+69 J9dYgZP2Q5MTTHI/LJ9Zp+6Yu8/K6OWmUosxRmJhlrMRcWJACA9MsS3AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-16.tower-31.messagelabs.com!1487676389!79066021!1 X-Originating-IP: [74.125.83.45] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7901 invoked from network); 21 Feb 2017 11:26:30 -0000 Received: from mail-pg0-f45.google.com (HELO mail-pg0-f45.google.com) (74.125.83.45) by server-16.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:30 -0000 Received: by mail-pg0-f45.google.com with SMTP id s67so23737608pgb.3 for ; Tue, 21 Feb 2017 03:26:30 -0800 (PST) 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=R47FuTVYg+U0X+tcvoTnObURmudGvO30WNDznzMvjJ4=; b=LlPVVfamDYdNGnymidQcOOWnTB+7AQIHUEOle85EbXWTbCc+EcytvA/NSSIrQonMxa udiK+Au1tsVRgzRc3tzpsJ54W/+/OUtegmmIx2zv+QCCWtkdKaVRokEU0vnFwUT+HUC1 WxGx+U6UHbHk5Cu3PY/oCEopB4WlGgolFQjDc= 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=R47FuTVYg+U0X+tcvoTnObURmudGvO30WNDznzMvjJ4=; b=Ws9BvlmSiszSrMdvcTD7PuzJM4cyjk+c1RRR1Rx2jYMu5mC5hbURNGs71R7dqOAPG4 JvVLX16ng8F8VDV16uXNOiVNOeLRYc6/SHg6kyKuMBJEOdCSXr67DijglWhKE8XfyVG7 Sv1cFVOlOqgdfIXf07jtvBM8I4v/8PKGDgGTT602HQbRmgdoZ1ayxYVFOJblsEGshvPs KVAj6SHGmjaYS/ogjdgJVdlBZGUEtrBRTVgKBGpelFPtwsGw6XAIeeEWgDDzgRFmIzMt sbxvMJ79jzFBSHuwxbmOpv5r60QlrGQlr5InTeyhzoG/PdeX72lNKdtoriGjj47Xn6o3 n9Hw== X-Gm-Message-State: AMke39noByBdPM1qHBj4/F7rWCeWY2d/qwnggeIeg9WdC8LJuQaq9AK3j7ASPuH1w9lNX3Mh X-Received: by 10.84.194.1 with SMTP id g1mr5814589pld.98.1487676389261; Tue, 21 Feb 2017 03:26:29 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:28 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:02 +0530 Message-Id: <1487676368-22356-6-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 05/11] xen/arm: vpl011: Initialize nr_spis in vgic_init in Xen to atleast 1 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" Ensure that nr_spis intialized in in vgic_init is atleast 1 to allow allocation of pl011 spi virq. Signed-off-by: Bhupinder Thakur --- xen/arch/arm/vgic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 364d5f0..614b3ec 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -121,6 +121,11 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis) /* Limit the number of virtual SPIs supported to (1020 - 32) = 988 */ if ( nr_spis > (1020 - NR_LOCAL_IRQS) ) return -EINVAL; +#ifdef CONFIG_VPL011_CONSOLE + /* Atleast 1 spi should be available for assigning to vpl011 */ + else if ( nr_spis < (1020 - NR_LOCAL_IRQS) ) + nr_spis += 1; +#endif d->arch.vgic.nr_spis = nr_spis; From patchwork Tue Feb 21 11:26:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94260 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396495qgi; Tue, 21 Feb 2017 03:28:21 -0800 (PST) X-Received: by 10.107.3.195 with SMTP id e64mr1979729ioi.18.1487676501847; Tue, 21 Feb 2017 03:28:21 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e77si1640237ioi.180.2017.02.21.03.28.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:21 -0800 (PST) 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 1cg8aZ-0002or-Nn; Tue, 21 Feb 2017 11:26: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 1cg8aY-0002ng-1j for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:34 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id C1/0D-27165-9E32CA85; Tue, 21 Feb 2017 11:26:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRusr/tCeU2 EwbYmG4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNaP/22m2goXSFWuuTGFtYJwm0sXIxSEkMJNR YtGfBkYQh0VgHrNEe8NadhBHQqCfVWLq4ftMXYycQE6MxL03DawQdqXE5ZmbwWwhAS2Jo6dms 0KMamWS6DizCKibg4NNwERiVocESI2IgJLEvVWTweYwC4RK/HvWxg5iCwskSWxfdZQNxGYRUJ XYsOI/I4jNK+At8fLbBzaIXXISN891MoPYnAI+En/3vWSH2OstMe3OCrYJjAILGBlWMaoXpxa VpRbpmuglFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgQGFgMQ7GDsvux/iFGSg0lJ lDdbak2EEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneOUpAOcGi1PTUirTMHGCIw6QlOHiURHiPK AKleYsLEnOLM9MhUqcYdTl27br8kkmIJS8/L1VKnLcMZIYASFFGaR7cCFi8XWKUlRLmZQQ6So inILUoN7MEVf4VozgHo5Iw736QKTyZeSVwm14BHcEEdMRNj5UgR5QkIqSkGhiPzS5gUp4wr+y i34wYNqmpqnaJ5pqPNaK/G6VPfrG+2eVmTLVRvqnKpS8/LxuY+wXdKH4THPn4sUreq23TPP9e WWp84azLAykDQa/1wRMWBYpGbL2X57oj4Na/f2fMys7MPrWu8vh2IbtY7ljRuqsR796zVtfIv /ytzRp5LS9/lsNFO6Hf5+KVWIozEg21mIuKEwHo9/0RsgIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-21.messagelabs.com!1487676391!35707396!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 18535 invoked from network); 21 Feb 2017 11:26:32 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-6.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:32 -0000 Received: by mail-pg0-f47.google.com with SMTP id b129so34938632pgc.2 for ; Tue, 21 Feb 2017 03:26:32 -0800 (PST) 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=HDHl5lSx7RvXzJkLcvzgBWrfdXi3HHyQWTPd6x1LmTU=; b=TmNhK8U+xptTZs72VxYFmU+S/tIdhZiV3l0zc7iOZqD+c04IcJlcx21qxe2bkyGqg/ D4UIkLoRwyiIolTS/2Ib5767UHG02M2PeeG0hUNCLg3oxu2tEbTXq4aluDpEwAebB/SM MM6xxKJi6EMhGrZuHtAe+/QI+DhqHvfH+1edM= 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=HDHl5lSx7RvXzJkLcvzgBWrfdXi3HHyQWTPd6x1LmTU=; b=K/8uOKiG2JaarljLGXAQLh2XsMwQwX5Qj77hiQvznXxKLm54pFFeGpvae1iN6Q3zg/ THNYOmvYwAHAO5E/KPRMIEtAWOmz4QeUK3F4gT1/cxM3H6eRk6aOqKR/hYjg1DGwSkf4 hDVl/zksQdZXaKTlJo+iBmM6txnz4bksbuc2ExGCCT9wTCBfMWbyIjcvyOt+DnvS1Srq i6NM0L1aFtl9u+GPppWuXsUP2fZq3LHKTluLERBdYzHU0iWpFV7rjxqoA2K/nqGyjxx/ vkYY4xQWw/STsKltM/PF/3DsG910RJdDDwfTnKn9Pll15qxOfuQmLKd6U9i2xq3GODxi nfDg== X-Gm-Message-State: AMke39nyAcQMxTe/+0nGCp6PYns9owfriCBEaAUqPy3C8PtXJBnoCIBJUHQr1dA1Rf+MTgf7 X-Received: by 10.99.143.13 with SMTP id n13mr33526398pgd.10.1487676391527; Tue, 21 Feb 2017 03:26:31 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:31 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:03 +0530 Message-Id: <1487676368-22356-7-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 06/11] xen/arm: vpl011: Add a new pl011 uart node in the guest DT in the toolstack 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 pl011 uart node - Get the pl011 spi virq from Xen using a hvm call - Add a new device tree node in the guest DT for SBSA pl011 uart containing the IRQ (read above) and the MMIO address range to be used by the guest The format for the node is specified in Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt. Signed-off-by: Bhupinder Thakur --- tools/libxl/libxl_arm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..34c7e39 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -130,9 +130,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 +591,38 @@ static int make_hypervisor_node(libxl__gc *gc, void *fdt, return 0; } +static int make_vpl011_uart_node(libxl__gc *gc, void *fdt, + const struct arch_info *ainfo, + struct xc_dom_image *dom, uint64_t irq) +{ + 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, irq, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); + + res = fdt_property_interrupts(gc, fdt, &intr, 1); + if (res) return res; + + 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) { @@ -790,6 +823,7 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info, int rc, res; size_t fdt_size = 0; int pfdt_size = 0; + uint64_t vpl011_irq=0; const libxl_version_info *vers; const struct arch_info *ainfo; @@ -889,6 +923,13 @@ next_resize: FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) ); FDT( make_hypervisor_node(gc, fdt, vers) ); + /* + * get the vpl011 VIRQ and use it for creating a vpl011 node entry + */ + if ( !xc_hvm_param_get(dom->xch, dom->guest_domid, HVM_PARAM_VPL011_VIRQ, + &vpl011_irq) ) + FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom, vpl011_irq) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) ); @@ -933,9 +974,11 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc, val |= GUEST_EVTCHN_PPI; rc = xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CALLBACK_IRQ, val); + if (rc) return rc; + rc = libxl__prepare_dtb(gc, info, state, dom); if (rc) goto out; From patchwork Tue Feb 21 11:26:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94259 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396483qgi; Tue, 21 Feb 2017 03:28:19 -0800 (PST) X-Received: by 10.36.55.145 with SMTP id r139mr25192935itr.12.1487676499887; Tue, 21 Feb 2017 03:28:19 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 192si19972638ioe.138.2017.02.21.03.28.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:19 -0800 (PST) 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 1cg8ac-0002s1-AS; Tue, 21 Feb 2017 11:26:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8ab-0002r8-GQ for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:37 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 4C/41-31649-CE32CA85; Tue, 21 Feb 2017 11:26:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRtsrPtGeU2 EQcd8HovvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPP4zXMBT/kKt4t3M7awHhJsouRi0NIYCaj xI0n29hBHBaBecwSS3/2sYI4EgL9rBLvfrUydjFyAjkxEm2rL7ND2GUS344eYQWxhQS0JI6em g1ltzJJzF9r0MXIwcEmYCIxq0MCJCwioCRxb9VkJhCbWSBU4t+zNrAxwgKBEt+fzWYDsVkEVC X69y8DG8Mr4C2xZv90JohVchI3z3Uyg9icAj4Sf/e9ZIdY5S0x7c4KtgmMAgsYGVYxahSnFpW lFukaWeolFWWmZ5TkJmbm6BoaGOvlphYXJ6an5iQmFesl5+duYgQGVj0DA+MOxqa9focYJTmY lER5s6XWRAjxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4LUDBqqQYFFqempFWmYOMMRh0hIcPEoiv Pkgad7igsTc4sx0iNQpRl2OXbsuv2QSYsnLz0uVEueVBCkSACnKKM2DGwGLt0uMslLCvIwMDA xCPAWpRbmZJajyrxjFORiVhHn3KwFN4cnMK4Hb9AroCCagI256rAQ5oiQRISXVwDh9foOXpm+ FSKh6L3NRlO3GTd8Ms6QEhMznp8zieD6pVNBig0Oh267Vrz/Jnny/+VnXf977Pf9b5n9Oucb6 T+VBHKtq5ZMuUcbZNrG2746FifZGfDQuE/F8XHt103oGkwOxiyr2RpyMSTw5q/bshX9ZDgfj3 xptsTd6IP5tQ+F9vfNqlpuOHlViKc5INNRiLipOBACSwl6LsgIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-31.messagelabs.com!1487676394!85981605!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 20343 invoked from network); 21 Feb 2017 11:26:36 -0000 Received: from mail-pg0-f51.google.com (HELO mail-pg0-f51.google.com) (74.125.83.51) by server-10.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:36 -0000 Received: by mail-pg0-f51.google.com with SMTP id b129so34939204pgc.2 for ; Tue, 21 Feb 2017 03:26:35 -0800 (PST) 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=2bQAjwS6ZOeKwuKo1eY3qabIdVCWaz8XL5Zph2lOB6g=; b=My6txS2sfny6FY0ox0oUlkpti7qiTYAvnMsEyS3NABMsG0i8fNEZW9B/FQN1UBi7yd OgaJBnz6axJOrLfb2zAHwxIGTp4wvpKCBK57qtwp365f92u8EshE28Ts62z2Wm9j/KKo Sj1Y+WJCRpHwQmUtfqYgzVNE/IJlhRqkbRd2I= 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=2bQAjwS6ZOeKwuKo1eY3qabIdVCWaz8XL5Zph2lOB6g=; b=h+AdsTQixpML8927hgSyiirSuhdNxW4vGSUfGu+5Xy0BUf6B0JKPxc60bA+zsvgAN/ 59fa6ianmHMxX2eMrTTFo/1fiO7K61ILh5GSChRZlZQ5V+j0eCyo0EOHK/nqrw9qI+Rx Pl5+9jZPOemDKI+V/I2PNC+hV4qlgY/oZj6gDo9JNXvoNFPNJ92lCxQriIPNSxxjY5Pv 0KN8D5Qgkhg8jK8AMCVKn17pIMEo1AHAyu9yYvQk7heoK/S2dOj4re4YvgCVfzzOhi87 X6maX8Dd3T9YycHAAbd7dqkPyXpjevkp01dY+fkJDLJJEQcg7TMlFjhvFa1kHr4rRc2g 2D3g== X-Gm-Message-State: AMke39n5/xPgY+FPkzVCtKXsjtyoQ/YnLDXVK5ka37fwZYTyQpA3S0+7UEB84HQpKpPDtftz X-Received: by 10.99.178.9 with SMTP id x9mr7304001pge.48.1487676394218; Tue, 21 Feb 2017 03:26:34 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:33 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:04 +0530 Message-Id: <1487676368-22356-8-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 07/11] xen/arm: vpl011: Add two new vpl011 parameters to xenstore X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add two new parameters to the xen store: - 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 for eventing Signed-off-by: Bhupinder Thakur --- tools/libxl/libxl.c | 6 ++++++ tools/libxl/libxl_dom.c | 18 +++++++++++++++++- tools/libxl/libxl_internal.h | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index d400fa2..cc00235 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -3159,6 +3159,12 @@ 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 defined(__arm__) || defined(__aarch64__) + flexarray_append(ro_front, "vpl011-port"); + flexarray_append(ro_front, GCSPRINTF("%"PRIu32, state->vpl011_console_port)); + flexarray_append(ro_front, "vpl011-ring-ref"); + flexarray_append(ro_front, GCSPRINTF("%lu", state->vpl011_console_mfn)); +#endif } 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..39eaff6 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=-1; 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); +#if defined(__arm__) || defined(__aarch64__) + /* get the vpl011 event channel from Xen */ + rc = xc_hvm_param_get(ctx->xch, domid, HVM_PARAM_VPL011_CONSOLE_EVTCHN, + &val); + if ( rc ) + state->vpl011_console_port = -1; + else + state->vpl011_console_port = (uint32_t)val; +#endif + if (info->type == LIBXL_DOMAIN_TYPE_HVM) { hvm_set_conf_params(ctx->xch, domid, info); #if defined(__i386__) || defined(__x86_64__) @@ -727,6 +737,9 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid, dom->flags = flags; dom->console_evtchn = state->console_port; +#if defined(__arm__) || defined(__aarch64__) + dom->vpl011_console_evtchn = state->vpl011_console_port; +#endif dom->console_domid = state->console_domid; dom->xenstore_evtchn = state->store_port; dom->xenstore_domid = state->store_domid; @@ -771,6 +784,9 @@ 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; +#if defined(__arm__) || defined(__aarch64__) + state->vpl011_console_mfn = dom->vpl011_console_pfn; +#endif } else { state->console_mfn = xc_dom_p2m(dom, dom->console_pfn); state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 5f46578..10e262e 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1128,6 +1128,10 @@ typedef struct { uint32_t num_vmemranges; xc_domain_configuration_t config; +#if defined(__arm__) || defined(__aarch64__) + unsigned long vpl011_console_mfn; + uint32_t vpl011_console_port; +#endif } libxl__domain_build_state; _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid, From patchwork Tue Feb 21 11:26:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94261 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396498qgi; Tue, 21 Feb 2017 03:28:22 -0800 (PST) X-Received: by 10.36.57.10 with SMTP id l10mr14177753ita.88.1487676502338; Tue, 21 Feb 2017 03:28:22 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id s84si9354751itd.91.2017.02.21.03.28.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:22 -0800 (PST) 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 1cg8ae-0002uQ-IM; Tue, 21 Feb 2017 11:26:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8ad-0002tH-MC for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:39 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 8F/B1-13524-FE32CA85; Tue, 21 Feb 2017 11:26:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRuspftOeU2 EwdtXAhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aqGT1sBcelK15Oec7awPhHrIuRi0NIYCaj xPaJ19lBHBaBecwSUw4sZwRxJAT6WSV2zjzF1sXIAeTESDw8L93FyAlkVko83LWMEcQWEtCSO HpqNivEpFYmifnb/4LVswmYSMzqkACpERFQkri3ajITiM0sECrx71kbO4gtLJAj8XXSXDCbRU BVYuKVRhYQm1fAW2LdzE42iF1yEjfPdTKD2JwCPhJ/971kh9jrLTHtzgq2CYwCCxgZVjFqFKc WlaUW6Rob6CUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBAYWAxDsYPy7NvAQoyQH k5Iob7bUmgghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErxzlIBygkWp6akVaZk5wBCHSUtw8CiJ8 B5RBErzFhck5hZnpkOkTjHqcuzadfklkxBLXn5eqpQ4bxnIDAGQoozSPLgRsHi7xCgrJczLCH SUEE9BalFuZgmq/CtGcQ5GJWHeTpApPJl5JXCbXgEdwQR0xE2PlSBHlCQipKQaGOuk/78VvsT bxC3udTLXLubIPZvGUp4pvv4PV75uuMe+qXDhYwVTMZ3L3HbTH2ziVZtxivuf9fr9u4RqDz1u EiplqFj1Zt2nDRJJf5OzpYveXtjw7O71ifaBAd8KrTKNpvUbM64KuvL/Y8MpwWzx87ds9KZMt am6fqXpTHqaWxp3aIoLf5LfTSWW4oxEQy3mouJEAK+VEuayAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-27.messagelabs.com!1487676397!35232499!1 X-Originating-IP: [74.125.83.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26482 invoked from network); 21 Feb 2017 11:26:38 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-15.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:38 -0000 Received: by mail-pg0-f42.google.com with SMTP id a123so33308844pgc.0 for ; Tue, 21 Feb 2017 03:26:38 -0800 (PST) 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=lJTOsICBX68lKFw173RStR+IHtO1pJ7S9btQdiO0dHs=; b=SL62Y6l0EoIgzPSctJw+ozQLHvCiILKFprf056UTtCP0eqkLSC/GBBv+EiFx2hEjEZ QCxYbIvJI2s875t6S/CdvIqHKPaZerUoqoxGmuD+k8nGo6p6WLR1kCUPqGzeKxVGY3hR HjqDTFcAzuiBmKYvNRJdtJoKHa3oBQ1f17Gic= 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=lJTOsICBX68lKFw173RStR+IHtO1pJ7S9btQdiO0dHs=; b=VhJAqP6hHRuYpsjSFU7wSsGHEVVLCbxylSX2kD9nFftTY8XVE5ssM7c4dpiDWLBuDd Kb8K8ZJH4LLzjSKelL76ug4A1mLZK7auzOIJRqRY9d0Bfu+fZKU/IEqYPoKLMW+dT0Zy M0YXELz6QXJc2wsf7rkRcwIMCvWz3KR+sZfkC1xzcy/QgagR+E0NbtM80lz02UEujSiP lzJZ0Nl9RTaVLWoaR+Q09+G0oZz4dAYi0P4LyRpFALPaFGdYUtgg+tZmru+owaLzzmWH 57vx/3bPWMEEBGDeDnpSKvSNtmhRYS0gcMcErVZ8MXaQzo6hX25/w6tQEs5RvbCNDFtP CXuA== X-Gm-Message-State: AMke39lGBi2k33F4ecvXz+mFTSra+vl4P4b7YIUSpaVHIuUI7Y8/J/VuRFxwIZJyrPiwvdXc X-Received: by 10.99.171.75 with SMTP id k11mr33992463pgp.16.1487676396697; Tue, 21 Feb 2017 03:26:36 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:36 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:05 +0530 Message-Id: <1487676368-22356-9-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 08/11] xen/arm: vpl011: Allocate a new PFN in the toolstack and pass to Xen using a hvm call 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" Allocates a new pfn, initializes it and passes on to Xen using a hvm call. Another changes is in xc_hvm_param_deprecated_check () to allow new vpl011 HVM params, which have been defined to some deprecated HVM params. Signed-off-by: Bhupinder Thakur --- tools/libxc/include/xc_dom.h | 5 +++++ tools/libxc/xc_dom_arm.c | 7 ++++++- tools/libxc/xc_dom_boot.c | 5 +++++ tools/libxc/xc_domain.c | 3 +++ 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..c763cf1 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -218,6 +218,11 @@ struct xc_dom_image { /* Extra SMBIOS structures passed to HVMLOADER */ struct xc_hvm_firmware_module smbios_module; + +#if defined(__arm__) || defined(__aarch64__) + xen_pfn_t vpl011_console_pfn; + unsigned int vpl011_console_evtchn; +#endif }; /* --- pluggable kernel loader ------------------------------------- */ diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index a7e839e..7060a22 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 VPL011_CONSOLE_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->vpl011_console_pfn = base + VPL011_CONSOLE_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_VPL011_CONSOLE_PFN, + base + VPL011_CONSOLE_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..933e92f 100644 --- a/tools/libxc/xc_dom_boot.c +++ b/tools/libxc/xc_dom_boot.c @@ -227,6 +227,11 @@ int xc_dom_boot_image(struct xc_dom_image *dom) if ( (rc = clear_page(dom, dom->xenstore_pfn)) != 0 ) return rc; +#if defined (__arm__) || defined(__aarch64__) + if ( (rc = clear_page(dom, dom->vpl011_console_pfn)) != 0 ) + return rc; +#endif + /* 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..d881288 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -1337,9 +1337,12 @@ static inline int xc_hvm_param_deprecated_check(uint32_t param) { switch ( param ) { +#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 Tue Feb 21 11:26:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94263 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396544qgi; Tue, 21 Feb 2017 03:28:29 -0800 (PST) X-Received: by 10.36.60.198 with SMTP id m189mr26037175ita.117.1487676509774; Tue, 21 Feb 2017 03:28:29 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id a22si10926543itb.97.2017.02.21.03.28.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:29 -0800 (PST) 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 1cg8ai-0002yX-QO; Tue, 21 Feb 2017 11:26:44 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8ah-0002wm-4N for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:43 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 77/CC-23940-2F32CA85; Tue, 21 Feb 2017 11:26:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXiVRtsovtReU2 EwcHd8hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8afN+/YCg4YVXRc6GdtYLyl2cXIxSEkMJNR YtPdG8xdjJwcLALzmCWWd4SAJCQE+lklVrT0sIEkJARiJDqPvYKyKyS2NjQwgdhCAloSR0/NZ oWY1Mok0b9/JtAkDg42AROJWR0SIDUiAkoS91ZNBqtnFgiV+PesjR3EFgaa8+DvC1aIxaoSR8 /cBDuCV8BH4vSbkywQu+Qkbp7rBItzAsX/7nvJDrHXW2LanRVsExgFFjAyrGLUKE4tKkst0jU 010sqykzPKMlNzMzRNTQw1stNLS5OTE/NSUwq1kvOz93ECAwsBiDYwfjytOchRkkOJiVR3myp NRFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHjnKAHlBItS01Mr0jJzgCEOk5bg4FES4T2iCJTmL S5IzC3OTIdInWI05jh14/RLJo5duy6/ZBJiycvPS5US5y0DmSQAUppRmgc3CBZ7lxhlpYR5GY FOE+IpSC3KzSxBlX/FKM7BqCTMux9kCk9mXgncvldApzABnXLTYyXIKSWJCCmpBsbCST9z8r6 ZvtPna7aoWh6jXLT3KM+rXweD/P+7crNGZhueTnh+T0i4RyhBdpHhD/XNX+JieE629/iuWifu WWE6M/ZwM5v+tDUnNgcqzeb6+t/1aMeFiH0G8z0Wbo9LFHldc/2miZ7pYfWXb1Lf3orzDMzwU VoipaUwl4+n2DGiJLnl6F6tWCWW4oxEQy3mouJEAPJ/W824AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-31.messagelabs.com!1487676399!86652296!1 X-Originating-IP: [74.125.83.52] 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 37964 invoked from network); 21 Feb 2017 11:26:41 -0000 Received: from mail-pg0-f52.google.com (HELO mail-pg0-f52.google.com) (74.125.83.52) by server-14.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:41 -0000 Received: by mail-pg0-f52.google.com with SMTP id a123so33309351pgc.0 for ; Tue, 21 Feb 2017 03:26:41 -0800 (PST) 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=aAlHYLGHl/8fGXWgMpZjzzPz3Pfe9VR3h7jM6DVLEqA=; b=gw+e9LkpSLjljtcxZpQg1ZLUfh7dUSi8dXtnzGDU6J/iCkr33AFk2tRA7/jxhFpG8L WO52H4veiyiNMCqIY38crWa8gKti2zTdSGq1S2s0vchKxAlaz00Q29yfskpj869h26g2 UBbF8wFR9we/FGZXBvx10JpYWpoA53aWn4k/Y= 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=aAlHYLGHl/8fGXWgMpZjzzPz3Pfe9VR3h7jM6DVLEqA=; b=tCnhL2O/s4TKPzYqAsFRgZgMaB2JsI6HHSA5E4q9czeoozvitevewLH0O2oHLEPqsp W+AWkTELBjv0ajZkTQW4HBpn8dtOMkVHpp+3qg2cUo3HGT2/PSXrKbh28FTGWPNQIJEV STQMksQ8Y8SrWucU8lKkBX+puJShP4J9VgOakZaxK5UsuGOSgs7bF3jdNmafxfvQ3Ep8 4DJEV4aDp4Y0QjZfKeszNXgJPLENqn5wzq/rlvO9cD20+Kr3rxu8dzaP0MSt3umgaaGJ YU9bqFsfOm3tyU8hkJYMOIxoVDY2q2RmxWaZNDiR5ESWGtbiCPV9hyJ6SyJzZvzJxtg+ xSRA== X-Gm-Message-State: AMke39laFE6A2bSzU/xtyy0EjuiGWc8QxPXcKolOslwVzlVBTtGWSHmno+CEzCpQp93Lf/Q0 X-Received: by 10.98.75.16 with SMTP id y16mr32596850pfa.23.1487676399273; Tue, 21 Feb 2017 03:26:39 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:38 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:06 +0530 Message-Id: <1487676368-22356-10-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 09/11] xen/arm: vpl011: Modify domain_create_ring in xenconsole to map the ring buffer and event channel 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" Modfication 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 Signed-off-by: Bhupinder Thakur --- tools/console/daemon/io.c | 128 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 110 insertions(+), 18 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 7e6a886..b1aa615 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -101,13 +101,18 @@ struct domain { struct domain *next; char *conspath; int ring_ref; + int vpl011_ring_ref; xenevtchn_port_or_error_t local_port; xenevtchn_port_or_error_t remote_port; + xenevtchn_port_or_error_t vpl011_local_port; + xenevtchn_port_or_error_t vpl011_remote_port; xenevtchn_handle *xce_handle; int xce_pollfd_idx; struct xencons_interface *interface; + struct xencons_interface *vpl011_interface; int event_count; long long next_period; + bool vpl011_initialized; }; static struct domain *dom_head; @@ -529,9 +534,58 @@ static void domain_unmap_interface(struct domain *dom) dom->ring_ref = -1; } +static void domain_unmap_vpl011_interface(struct domain *dom) +{ + if ( dom->vpl011_interface == NULL ) + return; + + if ( xgt_handle && dom->vpl011_ring_ref == -1 ) + xengnttab_unmap(xgt_handle, dom->vpl011_interface, 1); + else + munmap(dom->vpl011_interface, XC_PAGE_SIZE); + dom->vpl011_interface = NULL; + dom->vpl011_ring_ref = -1; +} + +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; + } + + /* initialize the ports */ + *lport = -1; + *rport = -1; + + /* bind to new remote port */ + 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; + } + + /* store new local and remote event channel ports */ + *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, vpl011_remote_port, vpl011_ring_ref; char *type, path[PATH_MAX]; err = xs_gather(xs, dom->conspath, @@ -541,6 +595,20 @@ static int domain_create_ring(struct domain *dom) if (err) goto out; + /* + * if the vpl011 parameters are not available or are not initialized + * the vpl011 console is not available + */ + err = xs_gather(xs, dom->conspath, + "vpl011-ring-ref", "%u", &vpl011_ring_ref, + "vpl011-port", "%i", &vpl011_remote_port, + NULL); + + if ( err || vpl011_ring_ref == -1 ) + dom->vpl011_initialized = false; + else + dom->vpl011_initialized = true; + snprintf(path, sizeof(path), "%s/type", dom->conspath); type = xs_read(xs, XBT_NULL, path, NULL); if (type && strcmp(type, "xenconsoled") != 0) { @@ -553,6 +621,12 @@ static int domain_create_ring(struct domain *dom) if (ring_ref != dom->ring_ref && dom->ring_ref != -1) domain_unmap_interface(dom); + /* If using vpl011 ring_ref and it has changed, remap */ + if ( dom->vpl011_initialized && + vpl011_ring_ref != dom->vpl011_ring_ref && + dom->vpl011_ring_ref != -1 ) + domain_unmap_vpl011_interface(dom); + if (!dom->interface && xgt_handle) { /* Prefer using grant table */ dom->interface = xengnttab_map_grant_ref(xgt_handle, @@ -560,6 +634,8 @@ static int domain_create_ring(struct domain *dom) PROT_READ|PROT_WRITE); dom->ring_ref = -1; } + + /* map PV console ring buffer */ if (!dom->interface) { /* Fall back to xc_map_foreign_range */ dom->interface = xc_map_foreign_range( @@ -573,18 +649,21 @@ static int domain_create_ring(struct domain *dom) dom->ring_ref = ring_ref; } - /* Go no further if port has not changed and we are still bound. */ - if (remote_port == dom->remote_port) { - xc_evtchn_status_t status = { - .dom = DOMID_SELF, - .port = dom->local_port }; - if ((xc_evtchn_status(xc, &status) == 0) && - (status.status == EVTCHNSTAT_interdomain)) + /* map vpl011 console ring buffer */ + if ( dom->vpl011_initialized && !dom->vpl011_interface ) { + + /* Fall back to xc_map_foreign_range */ + dom->vpl011_interface = xc_map_foreign_range( + xc, dom->domid, XC_PAGE_SIZE, + PROT_READ|PROT_WRITE, + (unsigned long)vpl011_ring_ref); + if ( dom->vpl011_interface == NULL ) { + err = EINVAL; goto out; + } + dom->vpl011_ring_ref = vpl011_ring_ref; } - dom->local_port = -1; - dom->remote_port = -1; if (dom->xce_handle != NULL) xenevtchn_close(dom->xce_handle); @@ -596,17 +675,24 @@ 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; + /* bind PV console channel */ + err = bind_event_channel(dom, remote_port, &dom->local_port, &dom->remote_port); + if (err) + { xenevtchn_close(dom->xce_handle); - dom->xce_handle = NULL; goto out; } - dom->local_port = rc; - dom->remote_port = remote_port; + + /* bind vpl011 console channel */ + if ( dom->vpl011_initialized ) + { + err = bind_event_channel(dom, vpl011_remote_port, &dom->vpl011_local_port, &dom->vpl011_remote_port); + if (err) + { + xenevtchn_close(dom->xce_handle); + goto out; + } + } if (dom->master_fd == -1) { if (!domain_create_tty(dom)) { @@ -615,6 +701,9 @@ static int domain_create_ring(struct domain *dom) dom->xce_handle = NULL; dom->local_port = -1; dom->remote_port = -1; + dom->vpl011_local_port = -1; + dom->vpl011_remote_port = -1; + dom->vpl011_initialized = false; goto out; } } @@ -684,8 +773,11 @@ static struct domain *create_domain(int domid) dom->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; dom->ring_ref = -1; + dom->vpl011_ring_ref = -1; dom->local_port = -1; dom->remote_port = -1; + dom->vpl011_local_port = -1; + dom->vpl011_remote_port = -1; if (!watch_domain(dom, true)) goto out; From patchwork Tue Feb 21 11:26:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94262 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396541qgi; Tue, 21 Feb 2017 03:28:29 -0800 (PST) X-Received: by 10.36.52.197 with SMTP id z188mr15868070itz.71.1487676509631; Tue, 21 Feb 2017 03:28:29 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id m77si10940881ita.23.2017.02.21.03.28.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:29 -0800 (PST) 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 1cg8am-00033J-5z; Tue, 21 Feb 2017 11:26:48 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8al-000316-0F for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:47 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id A5/9E-24539-6F32CA85; Tue, 21 Feb 2017 11:26:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNIsWRWlGSWpSXmKPExsXiVRtspvtZeU2 EwdYzshbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a7V8vYCi4KVazcbt7AeIC/i5GTQ0hgGqPE rRPOIDaLwDxmiUfLbLoYuTgkBPpZJXb0/2cESUgIxEgsWPmLqYuRA8iulni2RAiiV0vi6KnZr CD1QgKtTBJ3/y5jBKlhEzCRmNUhAVIjIqAkcW/VZCYQm1kgVOLfszZ2EFtYIEfi9YF/LBB7VS XeTW1iBWnlFfCR2LnNCWKrnMTNc53MIDYnUPjvvpfsEGu9JabdWcE2gVFgASPDKkaN4tSistQ iXSMjvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MwIBiAIIdjGvmBx5ilORgUhLl zZZaEyHEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgtcOGKBCgkWp6akVaZk5wNCGSUtw8CiJ8JqCp HmLCxJzizPTIVKnGHU5du26/JJJiCUvPy9VSpxXEqRIAKQoozQPbgQszi4xykoJ8zICHSXEU5 BalJtZgir/ilGcg1FJmLdTCWgKT2ZeCdymV0BHMAEdcdNjJcgRJYkIKakGRh1O3TrpwvV2X9R KVht/2yDmujzVueqQdInAkuUPD918t5lrxsPqa5vcU8T6NJ9efVN67En6/MjYCQKeZ0tLSngn Jjw9Ne+jUuFGv0Pnw1RSzp04dabkUlRx24wjtZNC7kgy2EQyvoqbFJh6Sm/508Mr5nzneD9x1 3Irzkcfll45peDQdydx/3UlluKMREMt5qLiRACuTaaWrgIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-6.tower-27.messagelabs.com!1487676402!88254834!1 X-Originating-IP: [74.125.83.54] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40396 invoked from network); 21 Feb 2017 11:26:43 -0000 Received: from mail-pg0-f54.google.com (HELO mail-pg0-f54.google.com) (74.125.83.54) by server-6.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:43 -0000 Received: by mail-pg0-f54.google.com with SMTP id 1so16557844pgi.1 for ; Tue, 21 Feb 2017 03:26:43 -0800 (PST) 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=/HUIuOsG3VMFW7Gyk05osXXS6aiRBMMp1KePOUv/lvg=; b=kjVRGzuyttpNVagjY+6mhnO/884ZVB1AXEHb0gjqiQlKa0LI0zAsxm1whMKTfrsPXp 6LfUeHyQnLnppaCdhJTO75KuZRGOYppbZubusjfyTEcAdT1cOuYT2V9Dy1QDgrjGRQdk DhlFvn8IPOIrvkwRB/Jec/nT7WJwe60yr+Xew= 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=/HUIuOsG3VMFW7Gyk05osXXS6aiRBMMp1KePOUv/lvg=; b=T9DEFtGMqxknncPIqJ9Ggh+OL3JI9OE1mM/wcoZnX1VqCMFh3PN7LZTR188OXlzovr 5Fl5kaal17VVAcm4tv0v4ojdS0nlxVI+E02x/me9NiEaTm0vCBEqAiqjV2BaAapg/1ur DkAFY/UClYnKIeTkkOMUgcplAu+ZeBAAZuiHXX8+pvByx0bAjXoIqq0Bsz88sDzLOinj gorRWum46l+dsowEFyC7VCPFqfTVwLyo07I9tzqgs9+OG2V1uXXy07mt1Tj9mXcCoAOp hI+TNy3kqQSJOrsxPFRqkAI01MAhdVxLaO9hWjQUNTef9UNeGrewzImKqGACCgGCPQ8g SwGw== X-Gm-Message-State: AMke39l3vXofGucit4IhGIhygAEAZ4byz8rI8k1vVx8OebKzA6xQEbleVORRSaZ/IGyaae9Q X-Received: by 10.98.141.194 with SMTP id p63mr32644010pfk.185.1487676401953; Tue, 21 Feb 2017 03:26:41 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:41 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:07 +0530 Message-Id: <1487676368-22356-11-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 10/11] xen/arm: vpl011: Modify handle_ring_read and buffer_append to read/append vpl011 data 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" MOdifications in the following functions: - handle_ring_read() - to allow reading data from both PV or vpl011 OUT ring buffers based on which port received the event - buffer_append() - append data received for either PV or vp011 OUT ring buffer Signed-off-by: Bhupinder Thakur --- tools/console/daemon/io.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index b1aa615..4e531e7 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -163,12 +163,11 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } -static void buffer_append(struct domain *dom) +static void buffer_append(struct domain *dom, struct xencons_interface *intf, int port) { struct buffer *buffer = &dom->buffer; XENCONS_RING_IDX cons, prod, size; - struct xencons_interface *intf = dom->interface; - + cons = intf->out_cons; prod = intf->out_prod; xen_mb(); @@ -192,7 +191,8 @@ 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 @@ -961,6 +961,7 @@ static void handle_tty_write(struct domain *dom) static void handle_ring_read(struct domain *dom) { xenevtchn_port_or_error_t port; + struct xencons_interface *intf; if (dom->is_dead) return; @@ -970,7 +971,15 @@ static void handle_ring_read(struct domain *dom) dom->event_count++; - buffer_append(dom); + /* + * select the interface based on the port which the event received + */ + if ( port == dom->vpl011_local_port ) + intf = dom->vpl011_interface; + else + intf = dom->interface; + + buffer_append(dom, intf, port); if (dom->event_count < RATE_LIMIT_ALLOWANCE) (void)xenevtchn_unmask(dom->xce_handle, port); @@ -1161,6 +1170,8 @@ void handle_io(void) d->next_period = now + RATE_LIMIT_PERIOD; if (d->event_count >= RATE_LIMIT_ALLOWANCE) { (void)xenevtchn_unmask(d->xce_handle, d->local_port); + if ( d->vpl011_initialized ) + (void)xenevtchn_unmask(d->xce_handle, d->vpl011_local_port); } d->event_count = 0; } From patchwork Tue Feb 21 11:26:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 94264 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp396555qgi; Tue, 21 Feb 2017 03:28:31 -0800 (PST) X-Received: by 10.107.201.12 with SMTP id z12mr19271432iof.220.1487676511374; Tue, 21 Feb 2017 03:28:31 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id u82si11011032itc.76.2017.02.21.03.28.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 03:28:31 -0800 (PST) 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 1cg8am-00033v-E1; Tue, 21 Feb 2017 11:26:48 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cg8al-00031L-CY for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 11:26:47 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 88/0F-02154-6F32CA85; Tue, 21 Feb 2017 11:26:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRuspftNeU2 Ewdn1rBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a+jWeZClYJVHxtnc3cwHiGt4uRi0NIYAaj xKl139lBHBaBecwSH5ZcYARxJAT6WSXOfW1n7mLkBHJiJJo29LJD2NUSjx52sYHYQgJaEkdPz WaFGNXKJHHxxRGgIg4ONgETiVkdEiA1IgJKEvdWTWYCsZkFQiX+PWsDmyMMNOfSpUtgNouAqs S01oNgu3gFfCQeXLjABrFLTuLmuU6wOCdQ/O++l+wQe70lpt1ZwTaBUWABI8MqRvXi1KKy1CJ dY72kosz0jJLcxMwcXUMDU73c1OLixPTUnMSkYr3k/NxNjMDAYgCCHYx7/zkdYpTkYFIS5c2W WhMhxJeUn1KZkVicEV9UmpNafIhRhoNDSYLXDhioQoJFqempFWmZOcAQh0lLcPAoifAeUQRK8 xYXJOYWZ6ZDpE4x6nLs2nX5JZMQS15+XqqUOK8kyAwBkKKM0jy4EbB4u8QoKyXMywh0lBBPQW pRbmYJqvwrRnEORiVh3v1KQFN4MvNK4Da9AjqCCeiImx4rQY4oSURISTUwRpdf1WRZNkHt8Pe +0raPjEsWrd90Jcc+o2jZr3Nh9icMVnafknOrS/+z/myqhOeyM5/MBNc3Jd+6Z7HAc3tqWAdP 8D3J2Gn+zV3Mvw92+DoK3Tf+bWk+eW/b9H/pxuEMxqsfSi//sNyz3VDqrehRwXdhprGJt5U4b LWrWdVDuzRWx90uFrZRYinOSDTUYi4qTgQAeYyyIrICAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-206.messagelabs.com!1487676404!86074889!1 X-Originating-IP: [74.125.83.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47500 invoked from network); 21 Feb 2017 11:26:45 -0000 Received: from mail-pg0-f42.google.com (HELO mail-pg0-f42.google.com) (74.125.83.42) by server-9.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Feb 2017 11:26:45 -0000 Received: by mail-pg0-f42.google.com with SMTP id s67so23740320pgb.3 for ; Tue, 21 Feb 2017 03:26:45 -0800 (PST) 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=ds5ggo0KYCOoUcx5Ud+Osp3LLdRz+YmCRLT1YsdfZWo=; b=FUpemNZglcGJm+L7CR7OInYxLKVvsG4KGc/MqO/PuNiXmsbMWkZWntAmGRBmoUWon0 sT3Ztpw0jTTKYYAUfk1+AfxErCf13K1lah6lQ4UubnwFRnKigCefIDeQj9KDjRXoneR/ fcNYMSv4+CAObegFcxcEXkr9KiFKIpE4LBbEg= 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=ds5ggo0KYCOoUcx5Ud+Osp3LLdRz+YmCRLT1YsdfZWo=; b=lOcZlFyD+9t4r+f33Q+tFaZ63HQ17lk0jNzNIAYi+LNT3WILi0pZeSIGK7VBQNj+w5 sVNt83itUYmtV0P4LBzPxkMdfUo9WVATRQIEUWO2odZrA9XUfwO7/Mlk1u2jRHRFFaL4 KgyrrBewnAIm1eL/ufP/R4dBjAyuKnGCFPy5Qof+bEzIX99EjTaMEb7ULWua/6B2RMXj yAIwOHrLtC36x4ULzQazI1KfrBy2ycvT67brVDXflDDpqWDT7dHKddcQfUFSE+WEdmhd HeC3v2HKfb+mDQY1Cjq3noWyFFx+M/knNRjwjk2L2hgCVfp3BP8jROuvsGQFx03L/Ihb pYbg== X-Gm-Message-State: AMke39mqcgNr5Zwa4cHv6tPr4WpEmE4xie2BJue95syVYS6TAYDC0Nq3wHSGvfVNWyoqnbY6 X-Received: by 10.98.194.153 with SMTP id w25mr32174191pfk.181.1487676404320; Tue, 21 Feb 2017 03:26:44 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p66sm40508627pfb.88.2017.02.21.03.26.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 03:26:43 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 16:56:08 +0530 Message-Id: <1487676368-22356-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> References: <1487676368-22356-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 11/11] xen/arm: vpl011: Modify handle_tty_read in xenconsole to redirect user data to vpl011 IN ring buffer 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" Modification in handle_tty_read to write the user data to the vpl011 IN ring buffer. Finally this needs to be modified to allow user input for both PV and vpl011 consoles. Signed-off-by: Bhupinder Thakur --- tools/console/daemon/io.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 4e531e7..a59b4c0 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -877,6 +877,9 @@ static int ring_free_bytes(struct domain *dom) struct xencons_interface *intf = dom->interface; XENCONS_RING_IDX cons, prod, space; + if ( dom->vpl011_initialized ) + intf = dom->vpl011_interface; + cons = intf->in_cons; prod = intf->in_prod; xen_mb(); @@ -904,8 +907,9 @@ static void handle_tty_read(struct domain *dom) ssize_t len = 0; char msg[80]; int i; - struct xencons_interface *intf = dom->interface; + struct xencons_interface *intf=dom->interface; XENCONS_RING_IDX prod; + xenevtchn_port_or_error_t port=dom->local_port; if (dom->is_dead) return; @@ -918,6 +922,16 @@ static void handle_tty_read(struct domain *dom) len = sizeof(msg); len = read(dom->master_fd, msg, len); + + /* select the interface based on whether vpl011 console is + * enabled or not + */ + if ( dom->vpl011_initialized ) + { + intf = dom->vpl011_interface; + port = dom->vpl011_local_port; + } + /* * Note: on Solaris, len == 0 means the slave closed, and this * is no problem, but Linux can't handle this usefully, so we @@ -927,13 +941,14 @@ static void handle_tty_read(struct domain *dom) domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); } else if (domain_is_valid(dom->domid)) { prod = intf->in_prod; + for (i = 0; i < len; i++) { intf->in[MASK_XENCONS_IDX(prod++, intf->in)] = msg[i]; } 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);