From patchwork Mon Jul 17 13:06:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107947 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495258qge; Mon, 17 Jul 2017 06:09:33 -0700 (PDT) X-Received: by 10.36.69.220 with SMTP id c89mr5269086itd.54.1500296973038; Mon, 17 Jul 2017 06:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296973; cv=none; d=google.com; s=arc-20160816; b=ixZC+GCwlW3tLyUNhcx7yWTYrxa7HxF2tnygro+qTboza2zamxAvN65khQHT2NPvUk NGBUy2B0ZSdl4FG6z1ZWayOgTMuYMTU3kDKguVKQd2ZMMsIp82qkvPTwgJ++WqsB5yK/ kWxaLv0k0UG7lZ2u+7qmhLfJmLYsxD93YHf6JTzUXO/01ejQVlFhWJfWv4/4S0yy1dvt EVvNqHHZ1Pu6jYLgCRO3XRsd9IFY1ZQGlYdoYOK7aSIOuOv9vUXpdtRpPXoO0Q5OKwn/ FljU3XPt0qn9IQ6iafa+RbsluH6NFLFzdnZkQr6JcfNs/SCBS6FZM63I3fntdpfw8OSL TaGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:message-id:date:to:from:dkim-signature :arc-authentication-results; bh=X5uvHsCYYgFl8eV605mZafjuKZtV2IP0wHtzedBtcDg=; b=BWxFofNd/NR6s37NfJEQuK8YRH1TSfRq0kcSW0+kSdl056qvinprdX01tRbMX0fUn4 zlaYYHJNf6dla5rzOpS+e0MdHqqrDyeRtSbPMqIiNBwjYfUKg7tiemyE8b8XQ36FU/Hz 2O+KaC/vA1yioD+DolxpmvYKNiiw5SdvMF3+MUlyNkwDCqQfiJxuTx5LMrOUItmXcdp+ RFRb3QAZvihOiiGsIjp1UD+DdwaQj/v2VLroLY/VFHsxGmalWdMF8HOo8FjXe4kXVCev cgibAYXyXhzy/IMS6HBXL6Tzg2gIcO1BeAyTJoJeA+WgOxCQGz0uwx8hSiHTPUobpmE7 SHOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=OoIw6gJy; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id z73si8452526iof.144.2017.07.17.06.09.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:33 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=OoIw6gJy; 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 1dX5jw-000471-7T; Mon, 17 Jul 2017 13:07:08 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5ju-00046t-KY for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:06 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id C1/36-01729-976BC695; Mon, 17 Jul 2017 13:07:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXiVRtsoluxLSf S4ORWa4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP09i9sBa3eFZNXTmVuYGy36mLk4hASmM4o 0X1gGxuIwyLQzixxae5JMEdC4B2LxIc/n9i7GDmBnDSJCxtOQdmlEnt+zmIBsYUEtCSOnprNC mG3MknsnunaxcjBwSZgIjGrQwIkLCKgJHFv1WQmkJnMAhcYJX6cf84GkhAWsJVYtuwDE4jNIq Aq8fDDQ3aQXl4Bb4m12/0gVslJ3DzXyTyBkW8BI8MqRvXi1KKy1CJdc72kosz0jJLcxMwcXUM DU73c1OLixPTUnMSkYr3k/NxNjMAwYQCCHYzHJjsfYpTkYFIS5b3Ilh0pxJeUn1KZkVicEV9U mpNafIhRhoNDSYLXfWtOpJBgUWp6akVaZg4wYGHSEhw8SiK81SBp3uKCxNzizHSI1ClGb44Nq 9d/YeK407cBSE46sB1IHvi6A0i+mvD/GxNH0/eP35mEWPLy81KlxHn1QEYIgIzIKM2DWwCLvE uMslLCvIxAJwvxFKQW5WaWoMq/YhTnYFQS5s0EmcKTmVcCd8croBOZgE4U9gU7sSQRISXVwOi xlklCRdzNTObx6RxpJYFD994/VXJwZGwsO9DXK/zNPDXkWpJFRvPEM25tDsILdRw+yf2Y+IyX Xatp3Y39LkvOnlp3f3nJ1QXHJjrWrDJ8n3/hw49vgnqahWddheXKOPhiF6qc01zywvTKAv63N +ZYXko8KmH382j37JLX840L1P4XxGQmOyqxFGckGmoxFxUnAgCFaagOtwIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-206.messagelabs.com!1500296823!101606335!1 X-Originating-IP: [74.125.83.52] X-SpamReason: No, hits=1.3 required=7.0 tests=BODY_RANDOM_LONG,USERPASS X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50625 invoked from network); 17 Jul 2017 13:07:04 -0000 Received: from mail-pg0-f52.google.com (HELO mail-pg0-f52.google.com) (74.125.83.52) by server-5.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:04 -0000 Received: by mail-pg0-f52.google.com with SMTP id u5so17077741pgq.3 for ; Mon, 17 Jul 2017 06:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=3GGRN2DXI+d1BHqJX8DS7+4rxDphYb3dZiSz5kQIUKw=; b=OoIw6gJysZkigPT1Pedo8J5/ntz1hf+f2r0zmCiiJZJjNnfBDKHeyYuzEfZELO2+PA pVjtmeWvTQ7EBH0kMYgXbKWOYchS8pdn1J6uBmqixHTKr1hutzdnhwpCJGZvg/rQK3Hw NRCpI2GeCyyREQ2/kLEHMfaSFZ3xf9c4P6LAE= 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; bh=3GGRN2DXI+d1BHqJX8DS7+4rxDphYb3dZiSz5kQIUKw=; b=VRpU2NTSAdPxFYj7ucA45tdq2jTw0gOLM7N2D6oUqPnmX7zmMV24GGcPlRmp/wmGbC YMMrstY/yysGJPt88ZBjxIlTpgzMFy5T96iHkiEK1xxdo156J5ACOsqfuwuS/71RSb9g MIFhk4wiFkAvt1BVupTQ56IGZ4S6Q5QO3XprZYsG/D3omi/6Gu7L3HgXeqjywTvqtghT dCejFZBhw5JfW1odGdehKWRl56etfQWHJlcVGVhuw0KHPoQ6HE+d4qJ1HPU/trwTqO2j ltHtX6seJVXXIU42dkYcck+Ne4W6U/BpxAzIGbjxJ4UO5tc6WDZ7HfO2OTrjY02jVDoz xRwA== X-Gm-Message-State: AIVw1130/BuceZU8mBFObJZqqvbEccquwL9IKfc2etAqx6+Y5vwNSzFP Rs3MP86c4BcPnB8Jt9W4og== X-Received: by 10.98.66.8 with SMTP id p8mr18782019pfa.4.1500296822658; Mon, 17 Jul 2017 06:07:02 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.06.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:02 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:30 +0530 Message-Id: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 00/25 v6] SBSA UART emulation support 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" SBSA UART emulation for guests in Xen ====================================== Linaro has published VM System specification for ARM Processors, which provides a set of guidelines for both guest OS and hypervisor implementations, such that building OS images according to these guidelines guarantees that those images can also run on hypervisors compliant with this specification. One of the spec requirements is that the hypervisor must provide an emulated SBSA UART as a serial console which meets the minimum requirements in SBSA UART as defined in appendix B of the following ARM Server Base Architecture Document: https://static.docs.arm.com/den0029/a/Server_Base_System_Architecture_v3_1_ARM_DEN_0029A.pdf. This feature allows the Xen guests to use SBSA compliant pl011 UART as as a console. Note that SBSA pl011 UART is a subset of full featured ARM pl011 UART and supports only a subset of registers as mentioned below. It does not support rx/tx DMA. Currently, Xen supports paravirtualized (aka PV console) and an emulated serial consoles. This feature will expose an emulated SBSA pl011 UART console to the guest, which a user can access using xenconsole. The device tree passed to the guest VM will contain the pl011 MMIO address range and an irq for receiving rx/tx pl011 interrupts. The device tree format is specified in Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt. The Xen hypervisor will expose two types of interfaces to the backend and domU. The interface exposed to domU will be an emulated pl011 UART by emulating the access to the following pl011 registers by the guest. - Data register (DR) - RW - Raw interrupt status register (RIS) - RO - Masked interrupt status register (MIS)- RO - Interrupt Mask (IMSC) - RW - Interrupt Clear (ICR) - WO It will also inject the pl011 interrupts to the guest in the following conditions: - incoming data in the rx buffer for the guest - there is space in the tx buffer for the guest to write more data The interface exposed to the backend will be the same PV console interface, which minimizes the changes required in xenconsole to support a new pl011 console. This interface has rx and tx ring buffers and an event channel for sending/receiving events from the backend. So essentially Xen handles the data on behalf of domU and the backend. Any data written by domU is captured by Xen and written to the TX (OUT) ring buffer and a pl011 event is raised to the backend to read the TX ring buffer. Similarly on reciving a pl011 event, Xen injects an interrupt to guest to indicate there is data available in the RX (IN) ring buffer. The pl011 UART state is completely captured in the set of registers mentioned above and this state is updated everytime there is an event from the backend or there is register read/write access from domU. For example, if domU has masked the rx interrupt in the IMSC register, then Xen will not inject an interrupt to guest and will just update the RIS register. Once the interrupt is unmasked by guest, the interrupt will be delivered to the guest. Changes summary: Xen Hypervisor =============== 1. 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. 2. Add a new domctl API to initialize vpl011 emulation in Xen. 3. Enable vpl011 emulation for a domain based on a libxl option passed during domain creation. Toolstack ========== 1. Add a new option "vuart" in the domU configuration file to enable/disable vuart. 2. Create a SBSA UART DT node in the guest device tree. It uses a fixed vpl011 SPI IRQ number and MMIO address. 3. Call vpl011 init DOMCTL API to enable vpl011 emulation. 5. Add a new vuart xenstore node, which contains: - ring-ref - event channel - buffer limit - type Xenconsoled ============ 1. Split the domain structure to support multiple consoles. 2. Modify different APIs such as buffer_append() etc. to operate on the console structure. 3. Add support for handling multiple consoles. 4. Add support for vuart console: The vpl011 changes available at the following repo: url: https://git@git.linaro.org:/people/bhupinder.thakur/xen.git branch: vpl011_v6 Kindly wait for one day to checkout the code from the above URL. There are some TBD items which need to be looked at in the future: 1. Currently UEFI firmware logs the output to hvc console only. How can UEFI firmware be made aware of pl011 console and how it can use it as a console instead of hvc. There was a discussion on this and it was decided that SBSA UART should be used as a debug port by the UEFI firmware so that all debug output is redirected to this port. 2. Linux seems to have hvc console as the default console i.e. if no console is specified then it uses hvc as the console. How can an option be provided in Linux to select either hvc or pl011 as the default console. It was suggeted to use the SPCR in ACPI and the stdout-path option in the device tree to specify the default console. However, currently hvc console is not describable in the ACPI/device tree. This support will have to be added to allow the user to specify the default console. 3. ACPI support for pl011 device. CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Konrad Rzeszutek Wilk Bhupinder Thakur (25): xen/arm: vpl011: Define common ring buffer helper functions in console.h xen/arm: vpl011: Add SBSA UART emulation in Xen xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart xen/arm: vpl011: Add support for vuart in libxl xen/arm: vpl011: Rearrange xen header includes in alphabetical order in domctl.c xen/arm: vpl011: Add a new domctl API to initialize vpl011 xen/arm: vpl011: Add a new vuart node in the xenstore xen/arm: vpl011: Modify xenconsole to define and use a new console structure xen/arm: vpl011: Rename the console structure field conspath to xspath xen/arm: vpl011: Modify xenconsole functions to take console structure as input xen/arm: vpl011: Add a new console_init function in xenconsole xen/arm: vpl011: Add a new buffer_available function in xenconsole xen/arm: vpl011: Add a new add_console_evtchn_fd function in xenconsole xen/arm: vpl011: Add a new add_console_tty_fd function in xenconsole xen/arm: vpl011: Add a new console_evtchn_unmask function in xenconsole xen/arm: vpl011: Add a new handle_console_ring function in xenconsole xen/arm: vpl011: Add a new handle_console_tty function in xenconsole xen/arm: vpl011: Add a new console_cleanup function in xenconsole xen/arm: vpl011: Add a new console_open_log function in xenconsole xen/arm: vpl011: Add a new console_close_evtchn function in xenconsole xen/arm: vpl011: Add support for multiple consoles in xenconsole xen/arm: vpl011: Add support for vuart console in xenconsole xen/arm: vpl011: Add a new vuart console type to xenconsole client xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree xen/arm: vpl011: Update documentation for vuart console support config/arm32.mk | 1 + config/arm64.mk | 1 + docs/man/xl.cfg.pod.5.in | 9 + docs/misc/console.txt | 44 ++- tools/console/Makefile | 3 +- tools/console/client/main.c | 13 +- tools/console/daemon/io.c | 662 ++++++++++++++++++++++++----------- tools/libxc/include/xc_dom.h | 2 + tools/libxc/include/xenctrl.h | 18 + tools/libxc/xc_dom_arm.c | 5 +- tools/libxc/xc_dom_boot.c | 2 + tools/libxc/xc_domain.c | 24 ++ tools/libxl/libxl.h | 6 + tools/libxl/libxl_arch.h | 6 + tools/libxl/libxl_arm.c | 72 +++- tools/libxl/libxl_console.c | 47 +++ tools/libxl/libxl_create.c | 9 +- tools/libxl/libxl_device.c | 9 +- tools/libxl/libxl_dom.c | 5 + tools/libxl/libxl_internal.h | 6 + tools/libxl/libxl_types.idl | 7 + tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_x86.c | 8 + tools/xl/xl_cmdtable.c | 2 +- tools/xl/xl_console.c | 5 +- tools/xl/xl_parse.c | 8 + xen/arch/arm/Kconfig | 7 + xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 5 + xen/arch/arm/domctl.c | 43 ++- xen/arch/arm/vpl011.c | 455 ++++++++++++++++++++++++ xen/include/asm-arm/domain.h | 6 + xen/include/asm-arm/pl011-uart.h | 2 + xen/include/asm-arm/vpl011.h | 72 ++++ xen/include/public/arch-arm.h | 6 + xen/include/public/domctl.h | 21 ++ xen/include/public/io/console.h | 4 + 37 files changed, 1360 insertions(+), 237 deletions(-) create mode 100644 xen/arch/arm/vpl011.c create mode 100644 xen/include/asm-arm/vpl011.h