From patchwork Fri Sep 22 08:22: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: 113974 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3011045qgf; Fri, 22 Sep 2017 01:25:59 -0700 (PDT) X-Received: by 10.36.217.201 with SMTP id p192mr6071502itg.28.1506068759295; Fri, 22 Sep 2017 01:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506068759; cv=none; d=google.com; s=arc-20160816; b=u2LLy5T0JUnpMuv/pYfjp2Zdfgzha5WlGgtIrkMtlwXOSiI+8mEZmqmJABnlb2j9Td Fe2NpJUYxLLMCPNXPI6eVOqxCYbXTjM6hHUL0iLZd45FKvV8ezVA/2aBJi6AhH5FNGyj Z1ZGD8CKvRPDY+wGM3T+fIKgeUbxOnzF43um3XhJ5Wu6P1dLJ1g1G9UtwisCau9QMqhn 9djFRBkn9a9QIB2A1mrm4IdVXO1bAaMDEEChsdHroKkkIPc+l//QgHQEPPaXKxtjyUGV UYsQD4oNgby/jwQiXh42Qb4ADhi0sYDrKbBeKOLwC8dXMK+uJOjw46qUybUk0gaUdxEk S8XA== 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=1lD6Aq1mIgTZaI8TuYHsGE2F6NSoAYmeYrjl4xZKrOI=; b=CVSLgL0dHy6g9Vy7nOqzu6tN2b8pIjdJbK1IspyeAmRF2couzkzNCzQgyW93Uz9bbI ZbIwHZgrna9g/rJMZfAoby3rPaw2W0kwovlbdds0FsNaxrAIQV/4FRlCMLm6RhV8qWCo GC5TcSbA7YaG4Kk+wCEyh6pitNQKNJflVfHWoo4joyV8qd9/804VrpEaYOOYxcxtCx6w EiRwne8yQ4T9AUce8WOKOx8OUTrixszipLiKGsErWTAVk9j+JeLdG9eZUzVhbTFESOjg YKF65e56GqhEAVpiW2E8cR2geYXfR0gj6I3i6iIyuKdWSErN3jz/S2YD1HOxRPRO28kI 5bbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YNpEk9HC; 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 g189si3469700ith.72.2017.09.22.01.25.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 01:25:59 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YNpEk9HC; 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 1dvJFK-0003cC-Tl; Fri, 22 Sep 2017 08:23: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 1dvJFK-0003c6-En for xen-devel@lists.xenproject.org; Fri, 22 Sep 2017 08:23:38 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id 9F/8A-02048-988C4C95; Fri, 22 Sep 2017 08:23:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRWlGSWpSXmKPExsXiVRusq9t+4ki kQfsPM4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP5/E2MBXd8Kh7eVG1gfGfdxcjFISQwnVFi 0bo2dhCHRaCdWeLw5X42EEdC4B2LxIT97SxdjJxATp7EtFsr2SDsNIl5Cw4xQ9iVEjcmvGcEs YUEtCSOnprNCjF2B5NE1+Qepi5GDg42AROJWR0SIDUiAkoS91ZNZgKpYRaYyCyx4MdxdpCEsI CdxKdVD8EGsQioSjRsWwMW5xXwlrh+eSU7xDI5iZvnOpknMPIvYGRYxahRnFpUllqka2ygl1S UmZ5RkpuYmaNraGCsl5taXJyYnpqTmFSsl5yfu4kRGEL1DAyMOxg7T/gdYpTkYFIS5X185Eik EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQnenceBcoJFqempFWmZOcBghklLcPAoifCGg6R5iwsSc 4sz0yFSpxi9OY5tuvyHiePHpCtAct+eW0Cy4+ZdILkJTG74/uAPkxBLXn5eqpQ473yQEQIgIz JK8+AWwKLyEqOslDAvIwMDgxBPQWpRbmYJqvwrRnEORiVh3hiQKTyZeSVwd7wCOpEJ6MTy1WA nliQipKQaGHtuKsvLMYt1OFwpLlHWWP/uvcj5UlZ7ue1X+6TKrm7f+2dNy8l9pyTLw/KMfsx+ 0j7Vfkbl2XnFTpP26a58nvrLWmbt7HVqnznZWp+l81c6ybrUPF5o3XYrslzduWrN41kdnRuWR yx6svG+t8zPygf9mvyKb7PLw0syP86QmSG69ULA9yjnM0osxRmJhlrMRcWJAAulJMvFAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-7.tower-31.messagelabs.com!1506068614!108457831!1 X-Originating-IP: [74.125.83.45] X-SpamReason: No, hits=1.3 required=7.0 tests=BODY_RANDOM_LONG,USERPASS X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7851 invoked from network); 22 Sep 2017 08:23:35 -0000 Received: from mail-pg0-f45.google.com (HELO mail-pg0-f45.google.com) (74.125.83.45) by server-7.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Sep 2017 08:23:35 -0000 Received: by mail-pg0-f45.google.com with SMTP id b11so238064pgn.12 for ; Fri, 22 Sep 2017 01:23:35 -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=HtSPUXa+DkN1+hr5GVxe6sAc8N60FG6wl0MzyjCO8eI=; b=YNpEk9HCbyvJ+YoeEEUfAiD6Csnlgvjg320GAwOGsgxvA0CeRzfoJrcdOFUrvANQ3t 2AY6TxX+Zpj4veJyb/wEuoKSQBlD3Si05aKIRy9ZnFkngIcpKFGhtC6E2K3M3ow1o+ff 6gPhJF6Wf+EHYKRikYbEO5yODOMeg+3XEJSWw= 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=HtSPUXa+DkN1+hr5GVxe6sAc8N60FG6wl0MzyjCO8eI=; b=UCs+hOKA7ZXh5obIErxGe7bljCBZRz3R3gM7v+Bp7CYWNd4xlRK+ieqhwwlIV8cib7 +QYJuo/pdATn8uzHiL3jpzQiGA14zfWuHOFTbBj23Zg3PBX7J3AjkPBpuTKKktNU/5m5 wpd1dJxaNGoYYHzjpfa+TXC5oDq4sIbcu4HxxVHG3QCHTlonaycEwm2t9bROuFMV3yjK CF5Mv5UxKUnHL/jzqG8ifj8j7Vc8uOWWE3egHLvTezug+sg4XLlBdEmanGyms2498tCY 6U5V1IWIqQgxJnTyxIG/FfptFtPKhQU2vHdI033i7LQk7Xcq/q3F7Wtl8lGcbYfI4IYW k/NQ== X-Gm-Message-State: AHPjjUjjDPIQEE4fc+5V0peJsYbydECLkToYCskn9rnJM4GAVy7FrTG0 DqxBt02usxWV/7opJ9aFTVOeZJOYW/o= X-Google-Smtp-Source: AOwi7QD4fZYr4fHlwqd37x2P/BjXC/dIm2zinGIpiFD7eFhK/Ns1xeY/COvljwiwaASuL6Z825PaeQ== X-Received: by 10.84.129.226 with SMTP id b89mr8349154plb.42.1506068613690; Fri, 22 Sep 2017 01:23:33 -0700 (PDT) Received: from blr-ubuntu-linaro.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id f74sm5569284pfa.36.2017.09.22.01.23.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 01:23:33 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 22 Sep 2017 13:52:59 +0530 Message-Id: <1506068606-17066-1-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Andre Przywara Subject: [Xen-devel] [PATCH 00/27 v10] 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 UART as as a console. Note that SBSA 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 UART console to the guest, which a user can access using xenconsole. The device tree passed to the guest VM will contain the SBSA UART MMIO address range and an irq for receiving rx/tx 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 SBSA UART by emulating the access to the following 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 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 SBSA UART 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 an event is raised to the backend to read the TX ring buffer. Similarly on reciving an event from xenconsole, Xen injects an interrupt to guest to indicate there is data available in the RX (IN) ring buffer. The SBSA 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 SBSA UART registers and 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 SBSA UART emulation in Xen. 3. Enable SBSA UART 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 SPI IRQ number and MMIO address range for SBSA UART. 3. Call vuart init DOMCTL API to enable SBSA UART 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_v10 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: Andrew Cooper CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall CC: Andre Przywara Bhupinder Thakur (27): 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 maybe_add_console_evtchn_fd function in xenconsole xen/arm: vpl011: Add a new maybe_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 xen/arm: vpl011: Fix the slow early console SBSA UART output xen/arm: vpl011: Correct the logic for asserting/de-asserting SBSA UART TX interrupt docs/man/xl.cfg.pod.5.in | 12 + docs/misc/console.txt | 44 ++- tools/console/Makefile | 3 +- tools/console/client/main.c | 13 +- tools/console/daemon/io.c | 661 +++++++++++++++++++++++------------ tools/libxc/include/xc_dom.h | 2 + tools/libxc/include/xenctrl.h | 20 ++ tools/libxc/xc_dom_arm.c | 5 +- tools/libxc/xc_dom_boot.c | 2 + tools/libxc/xc_domain.c | 27 ++ tools/libxl/libxl.h | 7 + tools/libxl/libxl_arch.h | 7 + tools/libxl/libxl_arm.c | 89 +++++ 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 | 6 + xen/arch/arm/domctl.c | 58 ++- xen/arch/arm/vpl011.c | 496 ++++++++++++++++++++++++++ xen/include/asm-arm/domain.h | 6 + xen/include/asm-arm/pl011-uart.h | 2 + xen/include/asm-arm/vpl011.h | 74 ++++ xen/include/public/arch-arm.h | 6 + xen/include/public/domctl.h | 26 ++ xen/include/public/io/console.h | 4 + 35 files changed, 1444 insertions(+), 241 deletions(-) create mode 100644 xen/arch/arm/vpl011.c create mode 100644 xen/include/asm-arm/vpl011.h