[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 00/11] pl011 emulation support in Xen



PL011 emulation for guests in Xen
=====================================

This feature allows the Xen guests to map their console to a SBSA compliant
pl011 UART as specified in ARM Service Base System architecture, Appendix B. 
Currently, Xen supports paravirtualized (aka PV) and an emulated serial 
consoles. This feature will allow an emulated SBSA pl011 UART console, which 
a user can access using xenconsoled running on dom0.

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 dom0 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
- Control register (CR)         - 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 dom0 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 dom0. 

So essentially Xen handles the data on behalf of domU and dom0. Any data 
written by domU is captured by Xen and written to the TX (OUT) ring buffer 
and a pl011 event is raised to dom0 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.

Note that 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 
dom0 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.

The following changes were done:

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 three new HVM param handlers 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
3. Breakup evtchn_send() to allow sending events for a Xen bound channel 
   (Currently, there is a check which disallows generating events for a Xen 
    bound channel)

4. Enable vpl011 emulation for a domain when it is created

5. Ensuring that nr_spis is atleast 1 to allow allocation of vpl011 spi virq

Toolstack
==========

1. Reading a VIRQ from Xen using a hvm call and using it for adding new device 
   tree node in the guest DT for SBSA pl011 uart containing the IRQ and the 
   MMIO address range to be used by the guest

2. Allocating a new PFN and passing it on to Xen though a hvm call to be used 
   as the IN/OUT ring buffers

3. 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

Xenconsoled
============

1. 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

2. Modificaton to handle_ring_read() and buffer_append () to allow reading data 
   from both PV or vpl011 OUT ring buffers and add to the output buffer

3. Modification in handle_tty_read to write the user data to the vpl011 IN ring
   buffer  

There are still some items which are pending:

1. Adding dynamic enable/disable of pl011 emulation for a guest
2. Add a new console type "pl011" in xenconsoled to allow the user to connect to
either PV/serial/pl011 console.
3. Add checks to ensure that the new hvm params read/written by the guest


Bhupinder Thakur (11):
  xen/arm: vpl011: Add pl011 uart emulation in Xen
  xen/arm: vpl011: Add new hvm params in Xen for ring buffer/event setup
  xen/arm: vpl011: Refactor evtchn_send in Xen to allow sending events
    from a xen bound channel
  xen/arm: vpl011: Enable vpl011 emulation for a domain in Xen
  xen/arm: vpl011: Initialize nr_spis in vgic_init in Xen to atleast 1
  xen/arm: vpl011: Add a new pl011 uart node in the guest DT in the
    toolstack
  xen/arm: vpl011: Add two new vpl011 parameters to xenstore
  xen/arm: vpl011: Allocate a new PFN in the toolstack and pass to Xen
    using a hvm call
  xen/arm: vpl011: Modify domain_create_ring in xenconsole to map the
    ring buffer and event channel
  xen/arm: vpl011: Modify handle_ring_read and buffer_append to
    read/append vpl011 data
  xen/arm: vpl011: Modify handle_tty_read in xenconsole to redirect user
    data to vpl011 IN ring buffer

 tools/console/daemon/io.c       | 168 +++++++++++++++---
 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 +
 tools/libxl/libxl.c             |   6 +
 tools/libxl/libxl_arm.c         |  47 +++++-
 tools/libxl/libxl_dom.c         |  18 +-
 tools/libxl/libxl_internal.h    |   4 +
 xen/arch/arm/Makefile           |   1 +
 xen/arch/arm/domain.c           |   8 +
 xen/arch/arm/hvm.c              |  39 +++++
 xen/arch/arm/vgic.c             |   5 +
 xen/arch/arm/vpl011.c           | 366 ++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/vpl011.h           | 208 +++++++++++++++++++++++
 xen/common/Kconfig              |   6 +
 xen/common/domctl.c             |   2 +
 xen/common/event_channel.c      |  49 ++++--
 xen/include/asm-arm/domain.h    |  15 ++
 xen/include/public/arch-arm.h   |   5 +
 xen/include/public/hvm/params.h |  10 +-
 xen/include/xen/event.h         |   6 +
 xen/include/xen/sched.h         |   4 +
 23 files changed, 944 insertions(+), 43 deletions(-)
 create mode 100644 xen/arch/arm/vpl011.c
 create mode 100644 xen/arch/arm/vpl011.h

-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.