All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/25 v7]  SBSA UART emulation support in Xen
@ 2017-08-07  8:52 Bhupinder Thakur
  2017-08-07  8:52 ` [PATCH 01/25 v7] xen/arm: vpl011: Define common ring buffer helper functions in console.h Bhupinder Thakur
                   ` (25 more replies)
  0 siblings, 26 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:52 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, Jan Beulich,
	Andre Przywara

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_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: Andrew Cooper <andrew.cooper3@citrix.com>
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Tim Deegan <tim@xen.org>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Julien Grall <julien.grall@arm.com>
CC: Andre Przywara <andre.przywara@arm.com>

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

 config/arm32.mk                      |   1 +
 config/arm64.mk                      |   1 +
 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            | 659 +++++++++++++++++++++++------------
 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              |  25 ++
 tools/libxl/libxl.h                  |   5 +
 tools/libxl/libxl_arch.h             |   7 +
 tools/libxl/libxl_arm.c              |  74 ++++
 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                |  48 ++-
 xen/arch/arm/vpl011.c                | 454 ++++++++++++++++++++++++
 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, 1366 insertions(+), 241 deletions(-)
 create mode 100644 xen/arch/arm/vpl011.c
 create mode 100644 xen/include/asm-arm/vpl011.h

-- 
2.7.4


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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* [PATCH 01/25 v7] xen/arm: vpl011: Define common ring buffer helper functions in console.h
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
@ 2017-08-07  8:52 ` Bhupinder Thakur
  2017-08-07  8:52 ` [PATCH 02/25 v7] xen/arm: vpl011: Add SBSA UART emulation in Xen Bhupinder Thakur
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:52 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

DEFINE_XEN_FLEX_RING(xencons) defines common helper functions such as
xencons_queued() to tell the current size of the ring buffer,
xencons_mask() to mask off the index, which are useful helper functions.
pl011 emulation code will use these helper functions.

io/console.h includes io/ring.h which defines DEFINE_XEN_FLEX_RING.

In console/daemon/io.c, string.h had to be included before io/console.h
because ring.h uses string functions.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v4:
- Split this change in a separate patch.

 tools/console/daemon/io.c       | 2 +-
 xen/include/public/io/console.h | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 7e474bb..e8033d2 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -21,6 +21,7 @@
 
 #include "utils.h"
 #include "io.h"
+#include <string.h>
 #include <xenevtchn.h>
 #include <xengnttab.h>
 #include <xenstore.h>
@@ -29,7 +30,6 @@
 
 #include <stdlib.h>
 #include <errno.h>
-#include <string.h>
 #include <poll.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/xen/include/public/io/console.h b/xen/include/public/io/console.h
index e2cd97f..5e45e1c 100644
--- a/xen/include/public/io/console.h
+++ b/xen/include/public/io/console.h
@@ -27,6 +27,8 @@
 #ifndef __XEN_PUBLIC_IO_CONSOLE_H__
 #define __XEN_PUBLIC_IO_CONSOLE_H__
 
+#include "ring.h"
+
 typedef uint32_t XENCONS_RING_IDX;
 
 #define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1))
@@ -38,6 +40,8 @@ struct xencons_interface {
     XENCONS_RING_IDX out_cons, out_prod;
 };
 
+DEFINE_XEN_FLEX_RING(xencons);
+
 #endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */
 
 /*
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 02/25 v7] xen/arm: vpl011: Add SBSA UART emulation in Xen
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
  2017-08-07  8:52 ` [PATCH 01/25 v7] xen/arm: vpl011: Define common ring buffer helper functions in console.h Bhupinder Thakur
@ 2017-08-07  8:52 ` Bhupinder Thakur
  2017-08-07  8:52 ` [PATCH 03/25 v7] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart Bhupinder Thakur
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:52 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, Jan Beulich,
	Andre Przywara

Add emulation code to emulate read/write access to pl011 registers
and pl011 interrupts:

    - Emulate DR read/write by reading and writing from/to the IN
      and OUT ring buffers and raising an event to the backend when
      there is data in the OUT ring buffer and injecting an interrupt
      to the guest when there is data in the IN ring buffer

    - Other registers are related to interrupt management and
      essentially control when interrupts are delivered to the guest

This patch implements the SBSA Generic UART which is a subset of ARM
PL011 UART.

The SBSA Generic UART is covered in Appendix B of
https://static.docs.arm.com/den0029/a/Server_Base_System_Architecture_v3_1_ARM_DEN_0029A.pdf

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Acked-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Tim Deegan <tim@xen.org>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Julien Grall <julien.grall@arm.com>
CC: Andre Przywara <andre.przywara@arm.com>

Changes since v6:
- Removed freeing of mmio_handlers in vpl011_deinit() as the handlers get freed when a domain is 
  destroyed. Since this is a minor change, I have included the reviewed-by and acked-by tags.

Changes since v5:
- use <asm/> instead of <asm-arm/> for including arm specific header files.
- renamed shadow_uartris to shadow_uartmis to indicate that it is masked interrupt status.
- use smp_mb() instead of smp_rmb() in vpl011_write_data().

Changes since v4:
- Renamed vpl011_update() to vpl011_update_interrupt_status() and added logic to avoid
  raising spurious interrupts.
- Used barrier instructions correctly while reading/writing data to the ring buffer.
- Proper lock taken before reading ring buffer indices.

Changes since v3:
- Moved the call to DEFINE_XEN_FLEX_RING from vpl011.h to public/console.h. This macro defines
  standard functions to operate on the ring buffer.
- Lock taken while updating the interrupt mask and clear registers in mmio_write.
- Use gfn_t instead of xen_pfn_t.
- vgic_free_virq called if there is any error in vpl011 initialization.
- mmio handlers freed if there is any error in vpl011 initialization.
- Removed vpl011->initialized flag usage as the same check could be done 
  using vpl011->ring-ref.
- Used return instead of break in the switch handling of emulation of different pl011 registers.
- Renamed vpl011_update_spi() to vpl011_update().

Changes since v2:
- Use generic vreg_reg* for read/write of registers emulating pl011.
- Use generic ring buffer functions defined using DEFINE_XEN_FLEX_RING.
- Renamed the SPI injection function to vpl011_update_spi() to reflect level 
  triggered nature of pl011 interrupts.
- The pl011 register access address should always be the base address of the
  corresponding register as per section B of the SBSA document. For this reason,
  the register range address access is not allowed.

Changes since v1:
- Removed the optimiztion related to sendiing events to xenconsole 
- Use local variables as ring buffer indices while using the ring buffer

 xen/arch/arm/Kconfig             |   7 +
 xen/arch/arm/Makefile            |   1 +
 xen/arch/arm/vpl011.c            | 454 +++++++++++++++++++++++++++++++++++++++
 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 +
 7 files changed, 548 insertions(+)
 create mode 100644 xen/arch/arm/vpl011.c
 create mode 100644 xen/include/asm-arm/vpl011.h

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index d46b98c..f58019d 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -50,6 +50,13 @@ config HAS_ITS
         prompt "GICv3 ITS MSI controller support" if EXPERT = "y"
         depends on HAS_GICV3
 
+config SBSA_VUART_CONSOLE
+	bool "Emulated SBSA UART console support"
+	default y
+	---help---
+	  Allows a guest to use SBSA Generic UART as a console. The
+	  SBSA Generic UART implements a subset of ARM PL011 UART.
+
 endmenu
 
 menu "ARM errata workaround via the alternative framework"
diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 49e1fb2..d9c6ebf 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_HAS_GICV3) += vgic-v3.o
 obj-$(CONFIG_HAS_ITS) += vgic-v3-its.o
 obj-y += vm_event.o
 obj-y += vtimer.o
+obj-$(CONFIG_SBSA_VUART_CONSOLE) += vpl011.o
 obj-y += vpsci.o
 obj-y += vuart.o
 
diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c
new file mode 100644
index 0000000..56d9cbe
--- /dev/null
+++ b/xen/arch/arm/vpl011.c
@@ -0,0 +1,454 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/errno.h>
+#include <xen/event.h>
+#include <xen/guest_access.h>
+#include <xen/init.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/sched.h>
+#include <public/domctl.h>
+#include <public/io/console.h>
+#include <asm/pl011-uart.h>
+#include <asm/vgic-emul.h>
+#include <asm/vpl011.h>
+
+/*
+ * Since pl011 registers are 32-bit registers, all registers
+ * are handled similarly allowing 8-bit, 16-bit and 32-bit
+ * accesses except 64-bit access.
+ */
+static bool vpl011_reg32_check_access(struct hsr_dabt dabt)
+{
+    return (dabt.size != DABT_DOUBLE_WORD);
+}
+
+static void vpl011_update_interrupt_status(struct domain *d)
+{
+    struct vpl011 *vpl011 = &d->arch.vpl011;
+    uint32_t uartmis = vpl011->uartris & vpl011->uartimsc;
+
+    /*
+     * This function is expected to be called with the lock taken.
+     */
+    ASSERT(spin_is_locked(&vpl011->lock));
+
+    /*
+     * TODO: PL011 interrupts are level triggered which means
+     * that interrupt needs to be set/clear instead of being
+     * injected. However, currently vGIC does not handle level
+     * triggered interrupts properly. This function needs to be
+     * revisited once vGIC starts handling level triggered
+     * interrupts.
+     */
+
+    /*
+     * Raise an interrupt only if any additional interrupt
+     * status bit has been set since the last time.
+     */
+    if ( uartmis & ~vpl011->shadow_uartmis )
+        vgic_vcpu_inject_spi(d, GUEST_VPL011_SPI);
+
+    vpl011->shadow_uartmis = uartmis;
+}
+
+static uint8_t vpl011_read_data(struct domain *d)
+{
+    unsigned long flags;
+    uint8_t data = 0;
+    struct vpl011 *vpl011 = &d->arch.vpl011;
+    struct xencons_interface *intf = vpl011->ring_buf;
+    XENCONS_RING_IDX in_cons, in_prod;
+
+    VPL011_LOCK(d, flags);
+
+    in_cons = intf->in_cons;
+    in_prod = intf->in_prod;
+
+    smp_rmb();
+
+    /*
+     * It is expected that there will be data in the ring buffer when this
+     * function is called since the guest is expected to read the data register
+     * only if the TXFE flag is not set.
+     * If the guest still does read when TXFE bit is set then 0 will be returned.
+     */
+    if ( xencons_queued(in_prod, in_cons, sizeof(intf->in)) > 0 )
+    {
+        data = intf->in[xencons_mask(in_cons, sizeof(intf->in))];
+        in_cons += 1;
+        smp_mb();
+        intf->in_cons = in_cons;
+    }
+    else
+        gprintk(XENLOG_ERR, "vpl011: Unexpected IN ring buffer empty\n");
+
+    if ( xencons_queued(in_prod, in_cons, sizeof(intf->in)) == 0 )
+    {
+        vpl011->uartfr |= RXFE;
+        vpl011->uartris &= ~RXI;
+    }
+
+    vpl011->uartfr &= ~RXFF;
+
+    vpl011_update_interrupt_status(d);
+
+    VPL011_UNLOCK(d, flags);
+
+    /*
+     * Send an event to console backend to indicate that data has been
+     * read from the IN ring buffer.
+     */
+    notify_via_xen_event_channel(d, vpl011->evtchn);
+
+    return data;
+}
+
+static void vpl011_write_data(struct domain *d, uint8_t data)
+{
+    unsigned long flags;
+    struct vpl011 *vpl011 = &d->arch.vpl011;
+    struct xencons_interface *intf = vpl011->ring_buf;
+    XENCONS_RING_IDX out_cons, out_prod;
+
+    VPL011_LOCK(d, flags);
+
+    out_cons = intf->out_cons;
+    out_prod = intf->out_prod;
+
+    smp_mb();
+
+    /*
+     * It is expected that the ring is not full when this function is called
+     * as the guest is expected to write to the data register only when the
+     * TXFF flag is not set.
+     * In case the guest does write even when the TXFF flag is set then the
+     * data will be silently dropped.
+     */
+    if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) !=
+         sizeof (intf->out) )
+    {
+        intf->out[xencons_mask(out_prod, sizeof(intf->out))] = data;
+        out_prod += 1;
+        smp_wmb();
+        intf->out_prod = out_prod;
+    }
+    else
+        gprintk(XENLOG_ERR, "vpl011: Unexpected OUT ring buffer full\n");
+
+    if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) ==
+         sizeof (intf->out) )
+    {
+        vpl011->uartfr |= TXFF;
+        vpl011->uartris &= ~TXI;
+    }
+
+    vpl011->uartfr |= BUSY;
+
+    vpl011->uartfr &= ~TXFE;
+
+    vpl011_update_interrupt_status(d);
+
+    VPL011_UNLOCK(d, flags);
+
+    /*
+     * Send an event to console backend to indicate that there is
+     * data in the OUT ring buffer.
+     */
+    notify_via_xen_event_channel(d, vpl011->evtchn);
+}
+
+static int vpl011_mmio_read(struct vcpu *v,
+                            mmio_info_t *info,
+                            register_t *r,
+                            void *priv)
+{
+    struct hsr_dabt dabt = info->dabt;
+    uint32_t vpl011_reg = (uint32_t)(info->gpa - GUEST_PL011_BASE);
+    struct vpl011 *vpl011 = &v->domain->arch.vpl011;
+    struct domain *d = v->domain;
+    unsigned long flags;
+
+    switch ( vpl011_reg )
+    {
+    case DR:
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        *r = vreg_reg32_extract(vpl011_read_data(d), info);
+        return 1;
+
+    case RSR:
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        /* It always returns 0 as there are no physical errors. */
+        *r = 0;
+        return 1;
+
+    case FR:
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        VPL011_LOCK(d, flags);
+        *r = vreg_reg32_extract(vpl011->uartfr, info);
+        VPL011_UNLOCK(d, flags);
+        return 1;
+
+    case RIS:
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        VPL011_LOCK(d, flags);
+        *r = vreg_reg32_extract(vpl011->uartris, info);
+        VPL011_UNLOCK(d, flags);
+        return 1;
+
+    case MIS:
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        VPL011_LOCK(d, flags);
+        *r = vreg_reg32_extract(vpl011->uartris & vpl011->uartimsc,
+                                info);
+        VPL011_UNLOCK(d, flags);
+        return 1;
+
+    case IMSC:
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        VPL011_LOCK(d, flags);
+        *r = vreg_reg32_extract(vpl011->uartimsc, info);
+        VPL011_UNLOCK(d, flags);
+        return 1;
+
+    case ICR:
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        /* Only write is valid. */
+        return 0;
+
+    default:
+        gprintk(XENLOG_ERR, "vpl011: unhandled read r%d offset %#08x\n",
+                dabt.reg, vpl011_reg);
+        return 0;
+    }
+
+    return 1;
+
+bad_width:
+    gprintk(XENLOG_ERR, "vpl011: bad read width %d r%d offset %#08x\n",
+            dabt.size, dabt.reg, vpl011_reg);
+    domain_crash_synchronous();
+    return 0;
+
+}
+
+static int vpl011_mmio_write(struct vcpu *v,
+                             mmio_info_t *info,
+                             register_t r,
+                             void *priv)
+{
+    struct hsr_dabt dabt = info->dabt;
+    uint32_t vpl011_reg = (uint32_t)(info->gpa - GUEST_PL011_BASE);
+    struct vpl011 *vpl011 = &v->domain->arch.vpl011;
+    struct domain *d = v->domain;
+    unsigned long flags;
+
+    switch ( vpl011_reg )
+    {
+    case DR:
+    {
+        uint32_t data = 0;
+
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        vreg_reg32_update(&data, r, info);
+        data &= 0xFF;
+        vpl011_write_data(v->domain, data);
+        return 1;
+    }
+
+    case RSR: /* Nothing to clear. */
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        return 1;
+
+    case FR:
+    case RIS:
+    case MIS:
+        goto write_ignore;
+
+    case IMSC:
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        VPL011_LOCK(d, flags);
+        vreg_reg32_update(&vpl011->uartimsc, r, info);
+        vpl011_update_interrupt_status(v->domain);
+        VPL011_UNLOCK(d, flags);
+        return 1;
+
+    case ICR:
+        if ( !vpl011_reg32_check_access(dabt) ) goto bad_width;
+
+        VPL011_LOCK(d, flags);
+        vreg_reg32_clearbits(&vpl011->uartris, r, info);
+        vpl011_update_interrupt_status(d);
+        VPL011_UNLOCK(d, flags);
+        return 1;
+
+    default:
+        gprintk(XENLOG_ERR, "vpl011: unhandled write r%d offset %#08x\n",
+                dabt.reg, vpl011_reg);
+        return 0;
+    }
+
+write_ignore:
+    return 1;
+
+bad_width:
+    gprintk(XENLOG_ERR, "vpl011: bad write width %d r%d offset %#08x\n",
+            dabt.size, dabt.reg, vpl011_reg);
+    domain_crash_synchronous();
+    return 0;
+
+}
+
+static const struct mmio_handler_ops vpl011_mmio_handler = {
+    .read = vpl011_mmio_read,
+    .write = vpl011_mmio_write,
+};
+
+static void vpl011_data_avail(struct domain *d)
+{
+    unsigned long flags;
+    struct vpl011 *vpl011 = &d->arch.vpl011;
+    struct xencons_interface *intf = vpl011->ring_buf;
+    XENCONS_RING_IDX in_cons, in_prod, out_cons, out_prod;
+    XENCONS_RING_IDX in_ring_qsize, out_ring_qsize;
+
+    VPL011_LOCK(d, flags);
+
+    in_cons = intf->in_cons;
+    in_prod = intf->in_prod;
+    out_cons = intf->out_cons;
+    out_prod = intf->out_prod;
+
+    smp_rmb();
+
+    in_ring_qsize = xencons_queued(in_prod,
+                                   in_cons,
+                                   sizeof(intf->in));
+
+    out_ring_qsize = xencons_queued(out_prod,
+                                    out_cons,
+                                    sizeof(intf->out));
+
+    /* Update the uart rx state if the buffer is not empty. */
+    if ( in_ring_qsize != 0 )
+    {
+        vpl011->uartfr &= ~RXFE;
+        if ( in_ring_qsize == sizeof(intf->in) )
+            vpl011->uartfr |= RXFF;
+        vpl011->uartris |= RXI;
+    }
+
+    /* Update the uart tx state if the buffer is not full. */
+    if ( out_ring_qsize != sizeof(intf->out) )
+    {
+        vpl011->uartfr &= ~TXFF;
+        vpl011->uartris |= TXI;
+        if ( out_ring_qsize == 0 )
+        {
+            vpl011->uartfr &= ~BUSY;
+            vpl011->uartfr |= TXFE;
+        }
+    }
+
+    vpl011_update_interrupt_status(d);
+
+    VPL011_UNLOCK(d, flags);
+}
+
+static void vpl011_notification(struct vcpu *v, unsigned int port)
+{
+    vpl011_data_avail(v->domain);
+}
+
+int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info)
+{
+    int rc;
+    struct vpl011 *vpl011 = &d->arch.vpl011;
+
+    if ( vpl011->ring_buf )
+        return -EINVAL;
+
+    /* Map the guest PFN to Xen address space. */
+    rc =  prepare_ring_for_helper(d,
+                                  gfn_x(info->gfn),
+                                  &vpl011->ring_page,
+                                  &vpl011->ring_buf);
+    if ( rc < 0 )
+        goto out;
+
+    rc = vgic_reserve_virq(d, GUEST_VPL011_SPI);
+    if ( !rc )
+    {
+        rc = -EINVAL;
+        goto out1;
+    }
+
+    rc = alloc_unbound_xen_event_channel(d, 0, info->console_domid,
+                                         vpl011_notification);
+    if ( rc < 0 )
+        goto out2;
+
+    vpl011->evtchn = info->evtchn = rc;
+
+    spin_lock_init(&vpl011->lock);
+
+    register_mmio_handler(d, &vpl011_mmio_handler,
+                          GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL);
+
+    return 0;
+
+out2:
+    vgic_free_virq(d, GUEST_VPL011_SPI);
+
+out1:
+    destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page);
+
+out:
+    return rc;
+}
+
+void domain_vpl011_deinit(struct domain *d)
+{
+    struct vpl011 *vpl011 = &d->arch.vpl011;
+
+    if ( !vpl011->ring_buf )
+        return;
+
+    free_xen_event_channel(d, vpl011->evtchn);
+    destroy_ring_for_helper(&vpl011->ring_buf, vpl011->ring_page);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index 8dfc1d1..1a1145d 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -11,6 +11,7 @@
 #include <public/hvm/params.h>
 #include <xen/serial.h>
 #include <xen/rbtree.h>
+#include <asm-arm/vpl011.h>
 
 struct hvm_domain
 {
@@ -145,6 +146,11 @@ struct arch_domain
     struct {
         uint8_t privileged_call_enabled : 1;
     } monitor;
+
+#ifdef CONFIG_SBSA_VUART_CONSOLE
+    struct vpl011 vpl011;
+#endif
+
 }  __cacheline_aligned;
 
 struct arch_vcpu
diff --git a/xen/include/asm-arm/pl011-uart.h b/xen/include/asm-arm/pl011-uart.h
index 123f477..57e9ec7 100644
--- a/xen/include/asm-arm/pl011-uart.h
+++ b/xen/include/asm-arm/pl011-uart.h
@@ -49,6 +49,8 @@
 /* FR bits */
 #define TXFE   (1<<7) /* TX FIFO empty */
 #define RXFE   (1<<4) /* RX FIFO empty */
+#define TXFF   (1<<5) /* TX FIFO full */
+#define RXFF   (1<<6) /* RX FIFO full */
 #define BUSY   (1<<3) /* Transmit is not complete */
 
 /* LCR_H bits */
diff --git a/xen/include/asm-arm/vpl011.h b/xen/include/asm-arm/vpl011.h
new file mode 100644
index 0000000..1b583da
--- /dev/null
+++ b/xen/include/asm-arm/vpl011.h
@@ -0,0 +1,72 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _VPL011_H_
+#define _VPL011_H_
+
+#include <public/domctl.h>
+#include <public/io/ring.h>
+#include <asm/vreg.h>
+#include <xen/mm.h>
+
+/* helper macros */
+#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)
+
+struct vpl011 {
+    void *ring_buf;
+    struct page_info *ring_page;
+    uint32_t    uartfr;         /* Flag register */
+    uint32_t    uartcr;         /* Control register */
+    uint32_t    uartimsc;       /* Interrupt mask register*/
+    uint32_t    uarticr;        /* Interrupt clear register */
+    uint32_t    uartris;        /* Raw interrupt status register */
+    uint32_t    shadow_uartmis; /* shadow masked interrupt register */
+    spinlock_t  lock;
+    evtchn_port_t evtchn;
+};
+
+struct vpl011_init_info {
+    domid_t console_domid;
+    gfn_t gfn;
+    evtchn_port_t evtchn;
+};
+
+#ifdef CONFIG_SBSA_VUART_CONSOLE
+int domain_vpl011_init(struct domain *d,
+                       struct vpl011_init_info *info);
+void domain_vpl011_deinit(struct domain *d);
+#else
+static inline int domain_vpl011_init(struct domain *d,
+                                     struct vpl011_init_info *info)
+{
+    return -ENOSYS;
+}
+
+static inline void domain_vpl011_deinit(struct domain *d) { }
+#endif
+#endif  /* _VPL011_H_ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index bd974fb..85ab665 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.
@@ -444,6 +448,8 @@ typedef uint64_t xen_callback_t;
 #define GUEST_TIMER_PHYS_NS_PPI 30
 #define GUEST_EVTCHN_PPI        31
 
+#define GUEST_VPL011_SPI        32
+
 /* PSCI functions */
 #define PSCI_cpu_suspend 0
 #define PSCI_cpu_off     1
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 03/25 v7] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
  2017-08-07  8:52 ` [PATCH 01/25 v7] xen/arm: vpl011: Define common ring buffer helper functions in console.h Bhupinder Thakur
  2017-08-07  8:52 ` [PATCH 02/25 v7] xen/arm: vpl011: Add SBSA UART emulation in Xen Bhupinder Thakur
@ 2017-08-07  8:52 ` Bhupinder Thakur
  2017-08-07  8:52 ` [PATCH 04/25 v7] xen/arm: vpl011: Add support for vuart in libxl Bhupinder Thakur
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:52 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

Allocate a new gfn to be used as a ring buffer between xenconsole
and Xen for sending/receiving pl011 console data.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v4:
- Removed xc_get_vuart_gfn() as it is not required since the vpl011 initialization
  function which used this API has been moved to after gfn is allocated.
- I have included the reviewed-by and acked-by tags as there is no change in the
  logic.

Changes since v3:
- Added a new helper function xc_get_vuart_gfn() to return the GFN allocated for
  vpl011.
- Since a new function has been added in this patch, I have not included Stefano's
  reviewed-by and Wei's acked-by tags.

Changes since v2:
- Removed the DOMCTL call to set the GFN as now this information is passed
  in the DOMCTL call to initialize vpl011 emulation.

 tools/libxc/include/xc_dom.h | 2 ++
 tools/libxc/xc_dom_arm.c     | 5 ++++-
 tools/libxc/xc_dom_boot.c    | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
index ce47058..6e06ef1 100644
--- a/tools/libxc/include/xc_dom.h
+++ b/tools/libxc/include/xc_dom.h
@@ -216,6 +216,8 @@ struct xc_dom_image {
 
     /* Extra SMBIOS structures passed to HVMLOADER */
     struct xc_hvm_firmware_module smbios_module;
+
+    xen_pfn_t vuart_gfn;
 };
 
 /* --- pluggable kernel loader ------------------------------------- */
diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c
index e7d4bd0..c981b7a 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 VUART_PFN_OFFSET 3
 
 #define LPAE_SHIFT 9
 
@@ -85,10 +86,12 @@ 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->vuart_gfn = base + VUART_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);
     xc_clear_domain_page(dom->xch, dom->guest_domid, base + MEMACCESS_PFN_OFFSET);
+    xc_clear_domain_page(dom->xch, dom->guest_domid, base + VUART_PFN_OFFSET);
     xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CONSOLE_PFN,
             dom->console_pfn);
     xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_STORE_PFN,
diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c
index c3b44dd..8a376d0 100644
--- a/tools/libxc/xc_dom_boot.c
+++ b/tools/libxc/xc_dom_boot.c
@@ -226,6 +226,8 @@ int xc_dom_boot_image(struct xc_dom_image *dom)
         return rc;
     if ( (rc = clear_page(dom, dom->xenstore_pfn)) != 0 )
         return rc;
+    if ( (rc = clear_page(dom, dom->vuart_gfn)) != 0 )
+        return rc;
 
     /* start info page */
     if ( dom->arch_hooks->start_info )
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 04/25 v7] xen/arm: vpl011: Add support for vuart in libxl
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (2 preceding siblings ...)
  2017-08-07  8:52 ` [PATCH 03/25 v7] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart Bhupinder Thakur
@ 2017-08-07  8:52 ` Bhupinder Thakur
  2017-08-08 13:38   ` Julien Grall
  2017-08-07  8:52 ` [PATCH 05/25 v7] xen/arm: vpl011: Rearrange xen header includes in alphabetical order in domctl.c Bhupinder Thakur
                   ` (21 subsequent siblings)
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:52 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

An option is provided in libxl to enable/disable SBSA vuart while
creating a guest domain.

Libxl now supports a generic vuart console and SBSA uart is a specific type.
In future support can be added for multiple vuart of different types.

User can enable SBSA vuart by adding the following line in the guest
configuration file:

vuart = "sbsa_uart"

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v4:
- Renamed "pl011" to "sbsa_uart".

Changes since v3:
- Added a new config option CONFIG_VUART_CONSOLE to enable/disable vuart console
  support.
- Moved libxl_vuart_type to arch-arm part of libxl_domain_build_info
- Updated xl command help to mention new console type - vuart.

Changes since v2:
- Defined vuart option as an enum instead of a string.
- Removed the domain creation flag defined for vuart and the related code
  to pass on the information while domain creation. Now vpl011 is initialized
  independent of domain creation through new DOMCTL APIs.

 tools/libxl/libxl.h          | 5 +++++
 tools/libxl/libxl_console.c  | 3 +++
 tools/libxl/libxl_dom.c      | 1 +
 tools/libxl/libxl_internal.h | 3 +++
 tools/libxl/libxl_types.idl  | 7 +++++++
 tools/xl/xl_cmdtable.c       | 2 +-
 tools/xl/xl_console.c        | 5 ++++-
 tools/xl/xl_parse.c          | 8 ++++++++
 8 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 229e289..90eaa20 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -306,6 +306,11 @@
 #define LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE 1
 
 /*
+ * LIBXL_HAVE_VUART indicates that the toolstack supports virtual UART.
+ */
+#define LIBXL_HAVE_VUART 1
+
+/*
  * libxl ABI compatibility
  *
  * The only guarantee which libxl makes regarding ABI compatibility
diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index 446e766..853be15 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -67,6 +67,9 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
     case LIBXL_CONSOLE_TYPE_SERIAL:
         cons_type_s = "serial";
         break;
+    case LIBXL_CONSOLE_TYPE_VUART:
+        cons_type_s = "vuart";
+        break;
     default:
         goto out;
     }
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index f54fd49..e0f0d78 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -803,6 +803,7 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
     if (xc_dom_translated(dom)) {
         state->console_mfn = dom->console_pfn;
         state->store_mfn = dom->xenstore_pfn;
+        state->vuart_gfn = dom->vuart_gfn;
     } 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 7247509..6b38453 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1139,6 +1139,9 @@ typedef struct {
     uint32_t num_vmemranges;
 
     xc_domain_configuration_t config;
+
+    xen_pfn_t vuart_gfn;
+    evtchn_port_t vuart_port;
 } libxl__domain_build_state;
 
 _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid,
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 6e80d36..9959efb 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -105,6 +105,7 @@ libxl_console_type = Enumeration("console_type", [
     (0, "UNKNOWN"),
     (1, "SERIAL"),
     (2, "PV"),
+    (3, "VUART"),
     ])
 
 libxl_disk_format = Enumeration("disk_format", [
@@ -240,6 +241,11 @@ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [
     (2, "COLO"),
     ])
 
+libxl_vuart_type = Enumeration("vuart_type", [
+    (0, "unknown"),
+    (1, "sbsa_uart"),
+    ])
+
 #
 # Complex libxl types
 #
@@ -581,6 +587,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
 
 
     ("arch_arm", Struct(None, [("gic_version", libxl_gic_version),
+                               ("vuart", libxl_vuart_type),
                               ])),
     # Alternate p2m is not bound to any architecture or guest type, as it is
     # supported by x86 HVM and ARM support is planned.
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 2c71a9f..3094bce 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -133,7 +133,7 @@ struct cmd_spec cmd_table[] = {
       &main_console, 0, 0,
       "Attach to domain's console",
       "[options] <Domain>\n"
-      "-t <type>       console type, pv or serial\n"
+      "-t <type>       console type, pv , serial or vuart\n"
       "-n <number>     console number"
     },
     { "vncviewer",
diff --git a/tools/xl/xl_console.c b/tools/xl/xl_console.c
index 0508dda..4e65d73 100644
--- a/tools/xl/xl_console.c
+++ b/tools/xl/xl_console.c
@@ -27,6 +27,7 @@ int main_console(int argc, char **argv)
     uint32_t domid;
     int opt = 0, num = 0;
     libxl_console_type type = 0;
+    char *console_names = "pv, serial, vuart";
 
     SWITCH_FOREACH_OPT(opt, "n:t:", NULL, "console", 1) {
     case 't':
@@ -34,8 +35,10 @@ int main_console(int argc, char **argv)
             type = LIBXL_CONSOLE_TYPE_PV;
         else if (!strcmp(optarg, "serial"))
             type = LIBXL_CONSOLE_TYPE_SERIAL;
+        else if (!strcmp(optarg, "vuart"))
+            type = LIBXL_CONSOLE_TYPE_VUART;
         else {
-            fprintf(stderr, "console type supported are: pv, serial\n");
+            fprintf(stderr, "console type supported are: %s\n", console_names);
             return EXIT_FAILURE;
         }
         break;
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 5c2bf17..71588de 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -918,6 +918,14 @@ void parse_config_data(const char *config_source,
     if (!xlu_cfg_get_long (config, "maxvcpus", &l, 0))
         b_info->max_vcpus = l;
 
+    if (!xlu_cfg_get_string(config, "vuart", &buf, 0)) {
+        if (libxl_vuart_type_from_string(buf, &b_info->arch_arm.vuart)) {
+            fprintf(stderr, "ERROR: invalid value \"%s\" for \"vuart\"\n",
+                    buf);
+            exit(1);
+        }
+    }
+
     parse_vnuma_config(config, b_info);
 
     /* Set max_memkb to target_memkb and max_vcpus to avail_vcpus if
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 05/25 v7] xen/arm: vpl011: Rearrange xen header includes in alphabetical order in domctl.c
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (3 preceding siblings ...)
  2017-08-07  8:52 ` [PATCH 04/25 v7] xen/arm: vpl011: Add support for vuart in libxl Bhupinder Thakur
@ 2017-08-07  8:52 ` Bhupinder Thakur
  2017-08-07  8:52 ` [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011 Bhupinder Thakur
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:52 UTC (permalink / raw)
  To: xen-devel; +Cc: Julien Grall, Stefano Stabellini

Rearrange xen header includes in alphabetical order in domctl.c.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
---
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v5:
- Corrected include of <xen/types.h> in alphabetical order.

 xen/arch/arm/domctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
index 971caec..db6838d 100644
--- a/xen/arch/arm/domctl.c
+++ b/xen/arch/arm/domctl.c
@@ -4,12 +4,12 @@
  * Copyright (c) 2012, Citrix Systems
  */
 
-#include <xen/types.h>
-#include <xen/lib.h>
 #include <xen/errno.h>
-#include <xen/sched.h>
 #include <xen/hypercall.h>
 #include <xen/iocap.h>
+#include <xen/lib.h>
+#include <xen/sched.h>
+#include <xen/types.h>
 #include <xsm/xsm.h>
 #include <public/domctl.h>
 
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (4 preceding siblings ...)
  2017-08-07  8:52 ` [PATCH 05/25 v7] xen/arm: vpl011: Rearrange xen header includes in alphabetical order in domctl.c Bhupinder Thakur
@ 2017-08-07  8:52 ` Bhupinder Thakur
  2017-08-07  9:14   ` Jan Beulich
                     ` (2 more replies)
  2017-08-07  8:52 ` [PATCH 07/25 v7] xen/arm: vpl011: Add a new vuart node in the xenstore Bhupinder Thakur
                   ` (19 subsequent siblings)
  25 siblings, 3 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:52 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, Jan Beulich

Add a new domctl API to initialize vpl011. It takes the GFN and console
backend domid as input and returns an event channel to be used for
sending and receiving events from Xen.

Xen will communicate with xenconsole using GFN as the ring buffer and
the event channel to transmit and receive pl011 data on the guest domain's
behalf.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Tim Deegan <tim@xen.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v6:
- Renamed the vuart initialization function to a generic name xc_dom_vuart_init 
- Used domid_t as a type instead of uint32_t for domid
- Checking the vuart type explicitly against vpl011 enum value

Changes since v5:
- xc_dom_vpl011_init() will be compiled for both x86/arm architectures as there
  is nothing architecture specific in this function. This function will return 
  error when called for x86.
- Fixed coding style issues in libxl.

Changes since v4:
- Removed libxl__arch_domain_create_finish().
- Added a new function libxl__arch_build_dom_finish(), which is called at the last
  in libxl__build_dom(). This function calls the vpl011 initialization function now.

Changes since v3:
- Added a new arch specific function libxl__arch_domain_create_finish(), which
  calls the vpl011 initialization function. For x86 this function does not do
  anything.
- domain_vpl011_init() takes a pointer to a structure which contains all the 
  required information such as console_domid, gfn instead of passing parameters
  separately.
- Dropped a DOMCTL API defined for de-initializing vpl011 as that should be
  taken care when the domain is destroyed (and not dependent on userspace 
  libraries/applications).

Changes since v2:
- Replaced the DOMCTL APIs defined for get/set of event channel and GFN with 
  a set of DOMCTL APIs for initializing and de-initializing vpl011 emulation.

 tools/libxc/include/xenctrl.h | 20 ++++++++++++++++++++
 tools/libxc/xc_domain.c       | 25 +++++++++++++++++++++++++
 tools/libxl/libxl_arch.h      |  7 +++++++
 tools/libxl/libxl_arm.c       | 21 +++++++++++++++++++++
 tools/libxl/libxl_dom.c       |  4 ++++
 tools/libxl/libxl_x86.c       |  8 ++++++++
 xen/arch/arm/domain.c         |  6 ++++++
 xen/arch/arm/domctl.c         | 42 ++++++++++++++++++++++++++++++++++++++++++
 xen/include/public/domctl.h   | 21 +++++++++++++++++++++
 9 files changed, 154 insertions(+)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index c7710b8..35bbb3b 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -886,6 +886,26 @@ int xc_vcpu_getcontext(xc_interface *xch,
                        vcpu_guest_context_any_t *ctxt);
 
 /**
+ * This function initializes the vuart emulation and returns
+ * the event to be used by the backend for communicating with
+ * the emulation code.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * #parm type type of vuart
+ * @parm domid the domain to get information from
+ * @parm console_domid the domid of the backend console
+ * @parm gfn the guest pfn to be used as the ring buffer
+ * @parm evtchn the event channel to be used for events
+ * @return 0 on success, negative error on failure
+ */
+int xc_dom_vuart_init(xc_interface *xch,
+                      uint32_t type,
+                      domid_t domid,
+                      domid_t console_domid,
+                      xen_pfn_t gfn,
+                      evtchn_port_t *evtchn);
+
+/**
  * This function returns information about the XSAVE state of a particular
  * vcpu of a domain. If extstate->size and extstate->xfeature_mask are 0,
  * the call is considered a query to retrieve them and the buffer is not
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 3bab4e8..899bbd4 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -343,6 +343,31 @@ int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid,
     return 0;
 }
 
+int xc_dom_vuart_init(xc_interface *xch,
+                      uint32_t type,
+                      domid_t domid,
+                      domid_t console_domid,
+                      xen_pfn_t gfn,
+                      evtchn_port_t *evtchn)
+{
+    DECLARE_DOMCTL;
+    int rc = 0;
+
+    domctl.cmd = XEN_DOMCTL_vuart_op;
+    domctl.domain = (domid_t)domid;
+    domctl.u.vuart_op.cmd = XEN_DOMCTL_VUART_OP_INIT;
+    domctl.u.vuart_op.type = type;
+    domctl.u.vuart_op.console_domid = console_domid;
+    domctl.u.vuart_op.gfn = gfn;
+
+    if ( (rc = do_domctl(xch, &domctl)) < 0 )
+        return rc;
+
+    *evtchn = domctl.u.vuart_op.evtchn;
+
+    return rc;
+}
+
 int xc_domain_getinfo(xc_interface *xch,
                       uint32_t first_domid,
                       unsigned int max_doms,
diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
index 5e1fc60..784ec7f 100644
--- a/tools/libxl/libxl_arch.h
+++ b/tools/libxl/libxl_arch.h
@@ -44,6 +44,13 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
                                       libxl_domain_build_info *info,
                                       struct xc_dom_image *dom);
 
+/* perform any pending hardware initialization */
+_hidden
+int libxl__arch_build_dom_finish(libxl__gc *gc,
+                                 libxl_domain_build_info *info,
+                                 struct xc_dom_image *dom,
+                                 libxl__domain_build_state *state);
+
 /* build vNUMA vmemrange with arch specific information */
 _hidden
 int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc,
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index d842d88..a33d3c9 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -1038,6 +1038,27 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
     return 0;
 }
 
+int libxl__arch_build_dom_finish(libxl__gc *gc,
+                                 libxl_domain_build_info *info,
+                                 struct xc_dom_image *dom,
+                                 libxl__domain_build_state *state)
+{
+    int ret = 0;
+
+    if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) {
+        ret = xc_dom_vuart_init(CTX->xch,
+                                XEN_DOMCTL_VUART_TYPE_VPL011,
+                                dom->guest_domid,
+                                dom->console_domid,
+                                dom->vuart_gfn,
+                                &state->vuart_port);
+        if (ret < 0)
+            LOG(ERROR, "xc_dom_vuart_init failed\n");
+    }
+
+    return ret;
+}
+
 int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc,
                                       uint32_t domid,
                                       libxl_domain_build_info *info,
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index e0f0d78..5f92023 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -702,6 +702,10 @@ static int libxl__build_dom(libxl__gc *gc, uint32_t domid,
         LOGE(ERROR, "xc_dom_gnttab_init failed");
         goto out;
     }
+    if ((ret = libxl__arch_build_dom_finish(gc, info, dom, state)) != 0) {
+        LOGE(ERROR, "libxl__arch_build_dom_finish failed");
+        goto out;
+    }
 
 out:
     return ret != 0 ? ERROR_FAIL : 0;
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index 455f6f0..0aaeded 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -391,6 +391,14 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
     return rc;
 }
 
+int libxl__arch_build_dom_finish(libxl__gc *gc,
+                                 libxl_domain_build_info *info,
+                                 struct xc_dom_image *dom,
+                                 libxl__domain_build_state *state)
+{
+    return 0;
+}
+
 /* Return 0 on success, ERROR_* on failure. */
 int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc,
                                       uint32_t domid,
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 2dc8b0a..2ff8f43 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -862,6 +862,12 @@ int domain_relinquish_resources(struct domain *d)
         if ( ret )
             return ret;
 
+        /*
+         * Release the resources allocated for vpl011 which were
+         * allocated via a DOMCTL call XEN_DOMCTL_vuart_op.
+         */
+        domain_vpl011_deinit(d);
+
         d->arch.relmem = RELMEM_xen;
         /* Fallthrough */
 
diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
index db6838d..c7f650e 100644
--- a/xen/arch/arm/domctl.c
+++ b/xen/arch/arm/domctl.c
@@ -5,9 +5,11 @@
  */
 
 #include <xen/errno.h>
+#include <xen/guest_access.h>
 #include <xen/hypercall.h>
 #include <xen/iocap.h>
 #include <xen/lib.h>
+#include <xen/mm.h>
 #include <xen/sched.h>
 #include <xen/types.h>
 #include <xsm/xsm.h>
@@ -119,6 +121,46 @@ long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
         d->disable_migrate = domctl->u.disable_migrate.disable;
         return 0;
 
+    case XEN_DOMCTL_vuart_op:
+    {
+        int rc;
+        struct xen_domctl_vuart_op *vuart_op = &domctl->u.vuart_op;
+
+        switch(vuart_op->cmd)
+        {
+        case XEN_DOMCTL_VUART_OP_INIT:
+
+            if ( !d->creation_finished )
+            {
+                if (vuart_op->type == XEN_DOMCTL_VUART_TYPE_VPL011)
+                {
+                        struct vpl011_init_info info;
+
+                        info.console_domid = vuart_op->console_domid;
+                        info.gfn = _gfn(vuart_op->gfn);
+
+                        rc = domain_vpl011_init(d, &info);
+                        if ( !rc )
+                        {
+                            vuart_op->evtchn = info.evtchn;
+                            rc = __copy_to_guest(u_domctl, domctl, 1);
+                        }
+                }
+                else
+                        rc = -EINVAL;
+            }
+            else
+                rc = - EPERM;
+
+            break;
+
+        default:
+            rc = -EINVAL;
+            break;
+        }
+
+        return rc;
+    }
     default:
     {
         int rc;
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 0669c31..be2d874 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -36,6 +36,7 @@
 #include "grant_table.h"
 #include "hvm/save.h"
 #include "memory.h"
+#include "event_channel.h"
 
 #define XEN_DOMCTL_INTERFACE_VERSION 0x0000000e
 
@@ -1148,6 +1149,24 @@ struct xen_domctl_psr_cat_op {
     uint32_t target;    /* IN */
     uint64_t data;      /* IN/OUT */
 };
+
+struct xen_domctl_vuart_op {
+#define XEN_DOMCTL_VUART_OP_INIT  0
+        uint32_t cmd;           /* XEN_DOMCTL_VUART_OP_* */
+        domid_t console_domid;  /* IN */
+#define XEN_DOMCTL_VUART_TYPE_VPL011 0
+        uint32_t type;          /* IN - type of vuart.
+                                 *      Currently only vpl011 supported.
+                                 */
+        xen_pfn_t gfn;          /* IN - guest gfn to be used as a
+                                 *      ring buffer.
+                                 */
+        evtchn_port_t evtchn;   /* OUT - remote port of the event
+                                 *       channel used for sending
+                                 *       ring buffer events.
+                                 */
+};
+
 typedef struct xen_domctl_psr_cat_op xen_domctl_psr_cat_op_t;
 DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cat_op_t);
 
@@ -1228,6 +1247,7 @@ struct xen_domctl {
 #define XEN_DOMCTL_monitor_op                    77
 #define XEN_DOMCTL_psr_cat_op                    78
 #define XEN_DOMCTL_soft_reset                    79
+#define XEN_DOMCTL_vuart_op                      80
 #define XEN_DOMCTL_gdbsx_guestmemio            1000
 #define XEN_DOMCTL_gdbsx_pausevcpu             1001
 #define XEN_DOMCTL_gdbsx_unpausevcpu           1002
@@ -1290,6 +1310,7 @@ struct xen_domctl {
         struct xen_domctl_psr_cmt_op        psr_cmt_op;
         struct xen_domctl_monitor_op        monitor_op;
         struct xen_domctl_psr_cat_op        psr_cat_op;
+        struct xen_domctl_vuart_op          vuart_op;
         uint8_t                             pad[128];
     } u;
 };
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 07/25 v7] xen/arm: vpl011: Add a new vuart node in the xenstore
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (5 preceding siblings ...)
  2017-08-07  8:52 ` [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011 Bhupinder Thakur
@ 2017-08-07  8:52 ` Bhupinder Thakur
  2017-08-07  8:53 ` [PATCH 08/25 v7] xen/arm: vpl011: Modify xenconsole to define and use a new console structure Bhupinder Thakur
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:52 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

Add a new vuart console node to xenstore. This node is added at

/local/domain/$DOMID/vuart/0.

The node contains information such as the ring-ref, event channel,
buffer limit and type of console.

Xenconsole reads the node information to setup the ring buffer and
event channel for sending/receiving vuart data.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v4:
-  vuart_device moved inside libxl__device_vuart_add() as a local variable.

Changes since v3:
- Added a backend node for vpl011.
- Removed libxl__device_vuart_add() for HVM guest. It is called only for PV guest.

 tools/libxl/libxl_console.c          | 44 ++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_create.c           |  9 +++++++-
 tools/libxl/libxl_device.c           |  9 ++++++--
 tools/libxl/libxl_internal.h         |  3 +++
 tools/libxl/libxl_types_internal.idl |  1 +
 5 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index 853be15..cdaf7fd 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -344,6 +344,50 @@ out:
     return rc;
 }
 
+int libxl__device_vuart_add(libxl__gc *gc, uint32_t domid,
+                            libxl__device_console *console,
+                            libxl__domain_build_state *state)
+{
+    libxl__device device;
+    flexarray_t *ro_front;
+    flexarray_t *back;
+    int rc;
+
+    ro_front = flexarray_make(gc, 16, 1);
+    back = flexarray_make(gc, 16, 1);
+
+    device.backend_devid = console->devid;
+    device.backend_domid = console->backend_domid;
+    device.backend_kind = LIBXL__DEVICE_KIND_VUART;
+    device.devid = console->devid;
+    device.domid = domid;
+    device.kind = LIBXL__DEVICE_KIND_VUART;
+
+    flexarray_append(back, "frontend-id");
+    flexarray_append(back, GCSPRINTF("%d", domid));
+    flexarray_append(back, "online");
+    flexarray_append(back, "1");
+    flexarray_append(back, "state");
+    flexarray_append(back, GCSPRINTF("%d", XenbusStateInitialising));
+    flexarray_append(back, "protocol");
+    flexarray_append(back, LIBXL_XENCONSOLE_PROTOCOL);
+
+    flexarray_append(ro_front, "port");
+    flexarray_append(ro_front, GCSPRINTF("%"PRIu32, state->vuart_port));
+    flexarray_append(ro_front, "ring-ref");
+    flexarray_append(ro_front, GCSPRINTF("%lu", state->vuart_gfn));
+    flexarray_append(ro_front, "limit");
+    flexarray_append(ro_front, GCSPRINTF("%d", LIBXL_XENCONSOLE_LIMIT));
+    flexarray_append(ro_front, "type");
+    flexarray_append(ro_front, "xenconsoled");
+
+    rc = libxl__device_generic_add(gc, XBT_NULL, &device,
+                                   libxl__xs_kvs_of_flexarray(gc, back),
+                                   NULL,
+                                   libxl__xs_kvs_of_flexarray(gc, ro_front));
+    return rc;
+}
+
 int libxl__init_console_from_channel(libxl__gc *gc,
                                      libxl__device_console *console,
                                      int dev_num,
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 1158303..6c3acb3 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1367,7 +1367,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
     }
     case LIBXL_DOMAIN_TYPE_PV:
     {
-        libxl__device_console console;
+        libxl__device_console console, vuart;
         libxl__device device;
 
         for (i = 0; i < d_config->num_vfbs; i++) {
@@ -1375,6 +1375,13 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
             libxl__device_vkb_add(gc, domid, &d_config->vkbs[i]);
         }
 
+        if (d_config->b_info.arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) {
+            init_console_info(gc, &vuart, 0);
+            vuart.backend_domid = state->console_domid;
+            libxl__device_vuart_add(gc, domid, &vuart, state);
+            libxl__device_console_dispose(&vuart);
+        }
+
         init_console_info(gc, &console, 0);
         console.backend_domid = state->console_domid;
         libxl__device_console_add(gc, domid, &console, state, &device);
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 00356af..3b10c58 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -26,6 +26,9 @@ static char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device)
     if (device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0)
         return GCSPRINTF("%s/console", dom_path);
 
+    if (device->kind == LIBXL__DEVICE_KIND_VUART)
+        return GCSPRINTF("%s/vuart/%d", dom_path, device->devid);
+
     return GCSPRINTF("%s/device/%s/%d", dom_path,
                      libxl__device_kind_to_string(device->kind),
                      device->devid);
@@ -170,7 +173,8 @@ retry_transaction:
          * historically contained other information, such as the
          * vnc-port, which we don't want the guest fiddling with.
          */
-        if (device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0)
+        if ((device->kind == LIBXL__DEVICE_KIND_CONSOLE && device->devid == 0) ||
+            (device->kind == LIBXL__DEVICE_KIND_VUART))
             xs_set_permissions(ctx->xsh, t, frontend_path,
                                ro_frontend_perms, ARRAY_SIZE(ro_frontend_perms));
         else
@@ -800,7 +804,8 @@ void libxl__devices_destroy(libxl__egc *egc, libxl__devices_remove_state *drs)
                 dev->domid = domid;
                 dev->kind = kind;
                 dev->devid = atoi(devs[j]);
-                if (dev->backend_kind == LIBXL__DEVICE_KIND_CONSOLE) {
+                if (dev->backend_kind == LIBXL__DEVICE_KIND_CONSOLE ||
+                    dev->backend_kind == LIBXL__DEVICE_KIND_VUART) {
                     /* Currently console devices can be destroyed
                      * synchronously by just removing xenstore entries,
                      * this is what libxl__device_destroy does.
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 6b38453..3f7cff9 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1206,6 +1206,9 @@ _hidden int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
                                       libxl__device_console *console,
                                       libxl__domain_build_state *state,
                                       libxl__device *device);
+_hidden int libxl__device_vuart_add(libxl__gc *gc, uint32_t domid,
+                                    libxl__device_console *console,
+                                    libxl__domain_build_state *state);
 
 /* Returns 1 if device exists, 0 if not, ERROR_* (<0) on error. */
 _hidden int libxl__device_exists(libxl__gc *gc, xs_transaction_t t,
diff --git a/tools/libxl/libxl_types_internal.idl b/tools/libxl/libxl_types_internal.idl
index 7dc4d0f..c463c33 100644
--- a/tools/libxl/libxl_types_internal.idl
+++ b/tools/libxl/libxl_types_internal.idl
@@ -26,6 +26,7 @@ libxl__device_kind = Enumeration("device_kind", [
     (9, "VUSB"),
     (10, "QUSB"),
     (11, "9PFS"),
+    (12, "VUART"),
     ])
 
 libxl__console_backend = Enumeration("console_backend", [
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 08/25 v7] xen/arm: vpl011: Modify xenconsole to define and use a new console structure
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (6 preceding siblings ...)
  2017-08-07  8:52 ` [PATCH 07/25 v7] xen/arm: vpl011: Add a new vuart node in the xenstore Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-07  8:53 ` [PATCH 09/25 v7] xen/arm: vpl011: Rename the console structure field conspath to xspath Bhupinder Thakur
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

Xenconsole uses a domain structure which contains console specific fields. This
patch defines a new console structure, which would be used by the xenconsole
functions to perform console specific operations like reading/writing data from/to
the console ring buffer or reading/writing data from/to console tty.

This patch is in preparation to support multiple consoles to support vuart console.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v4:
- Moved the following fields from the struct domain to struct console:
  ->xenevtchn_handle *xce_handle;
  ->int xce_pollfd_idx;
  ->int event_count;
  ->long long next_period;

Changes since v3:
- The changes in xenconsole have been split into four patches. This is the first patch
  which modifies the xenconsole to use a new console structure.

Changes since v2:
- Defined a new function console_create_ring() which sets up the ring buffer and 
  event channel a new console. domain_create_ring() uses this function to setup
  a console.
- This patch does not contain vuart specific changes, which would be introduced in
  the next patch.
- Changes for keeping the PV log file name unchanged.

Changes since v1:
- Split the domain struture to a separate console structure
- Modified the functions to operate on the console struture
- Replaced repetitive per console code with generic code

 tools/console/daemon/io.c | 299 +++++++++++++++++++++++++---------------------
 1 file changed, 165 insertions(+), 134 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index e8033d2..30cd167 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -89,25 +89,30 @@ struct buffer {
 	size_t max_capacity;
 };
 
-struct domain {
-	int domid;
+struct console {
 	int master_fd;
 	int master_pollfd_idx;
 	int slave_fd;
 	int log_fd;
-	bool is_dead;
-	unsigned last_seen;
 	struct buffer buffer;
-	struct domain *next;
 	char *conspath;
 	int ring_ref;
-	xenevtchn_port_or_error_t local_port;
-	xenevtchn_port_or_error_t remote_port;
 	xenevtchn_handle *xce_handle;
 	int xce_pollfd_idx;
-	struct xencons_interface *interface;
 	int event_count;
 	long long next_period;
+	xenevtchn_port_or_error_t local_port;
+	xenevtchn_port_or_error_t remote_port;
+	struct xencons_interface *interface;
+	struct domain *d;
+};
+
+struct domain {
+	int domid;
+	bool is_dead;
+	unsigned last_seen;
+	struct domain *next;
+	struct console console;
 };
 
 static struct domain *dom_head;
@@ -160,9 +165,10 @@ static int write_with_timestamp(int fd, const char *data, size_t sz,
 
 static void buffer_append(struct domain *dom)
 {
-	struct buffer *buffer = &dom->buffer;
+	struct console *con = &dom->console;
+	struct buffer *buffer = &con->buffer;
 	XENCONS_RING_IDX cons, prod, size;
-	struct xencons_interface *intf = dom->interface;
+	struct xencons_interface *intf = con->interface;
 
 	cons = intf->out_cons;
 	prod = intf->out_prod;
@@ -187,22 +193,22 @@ static void buffer_append(struct domain *dom)
 
 	xen_mb();
 	intf->out_cons = cons;
-	xenevtchn_notify(dom->xce_handle, dom->local_port);
+	xenevtchn_notify(con->xce_handle, con->local_port);
 
 	/* Get the data to the logfile as early as possible because if
 	 * no one is listening on the console pty then it will fill up
 	 * and handle_tty_write will stop being called.
 	 */
-	if (dom->log_fd != -1) {
+	if (con->log_fd != -1) {
 		int logret;
 		if (log_time_guest) {
 			logret = write_with_timestamp(
-				dom->log_fd,
+				con->log_fd,
 				buffer->data + buffer->size - size,
 				size, &log_time_guest_needts);
 		} else {
 			logret = write_all(
-				dom->log_fd,
+				con->log_fd,
 				buffer->data + buffer->size - size,
 				size);
 		}
@@ -338,14 +344,16 @@ static int create_domain_log(struct domain *dom)
 
 static void domain_close_tty(struct domain *dom)
 {
-	if (dom->master_fd != -1) {
-		close(dom->master_fd);
-		dom->master_fd = -1;
+	struct console *con = &dom->console;
+
+	if (con->master_fd != -1) {
+		close(con->master_fd);
+		con->master_fd = -1;
 	}
 
-	if (dom->slave_fd != -1) {
-		close(dom->slave_fd);
-		dom->slave_fd = -1;
+	if (con->slave_fd != -1) {
+		close(con->slave_fd);
+		con->slave_fd = -1;
 	}
 }
 
@@ -418,11 +426,12 @@ static int domain_create_tty(struct domain *dom)
 	char *data;
 	unsigned int len;
 	struct termios term;
+	struct console *con = &dom->console;
 
-	assert(dom->slave_fd == -1);
-	assert(dom->master_fd == -1);
+	assert(con->slave_fd == -1);
+	assert(con->master_fd == -1);
 
-	if (openpty(&dom->master_fd, &dom->slave_fd, NULL, NULL, NULL) < 0) {
+	if (openpty(&con->master_fd, &con->slave_fd, NULL, NULL, NULL) < 0) {
 		err = errno;
 		dolog(LOG_ERR, "Failed to create tty for domain-%d "
 		      "(errno = %i, %s)",
@@ -430,7 +439,7 @@ static int domain_create_tty(struct domain *dom)
 		return 0;
 	}
 
-	if (tcgetattr(dom->slave_fd, &term) < 0) {
+	if (tcgetattr(con->slave_fd, &term) < 0) {
 		err = errno;
 		dolog(LOG_ERR, "Failed to get tty attributes for domain-%d "
 			"(errno = %i, %s)",
@@ -438,7 +447,7 @@ static int domain_create_tty(struct domain *dom)
 		goto out;
 	}
 	cfmakeraw(&term);
-	if (tcsetattr(dom->slave_fd, TCSANOW, &term) < 0) {
+	if (tcsetattr(con->slave_fd, TCSANOW, &term) < 0) {
 		err = errno;
 		dolog(LOG_ERR, "Failed to set tty attributes for domain-%d "
 			"(errno = %i, %s)",
@@ -446,7 +455,7 @@ static int domain_create_tty(struct domain *dom)
 		goto out;
 	}
 
-	if ((slave = ptsname(dom->master_fd)) == NULL) {
+	if ((slave = ptsname(con->master_fd)) == NULL) {
 		err = errno;
 		dolog(LOG_ERR, "Failed to get slave name for domain-%d "
 		      "(errno = %i, %s)",
@@ -454,18 +463,18 @@ static int domain_create_tty(struct domain *dom)
 		goto out;
 	}
 
-	success = asprintf(&path, "%s/limit", dom->conspath) !=
+	success = asprintf(&path, "%s/limit", con->conspath) !=
 		-1;
 	if (!success)
 		goto out;
 	data = xs_read(xs, XBT_NULL, path, &len);
 	if (data) {
-		dom->buffer.max_capacity = strtoul(data, 0, 0);
+		con->buffer.max_capacity = strtoul(data, 0, 0);
 		free(data);
 	}
 	free(path);
 
-	success = (asprintf(&path, "%s/tty", dom->conspath) != -1);
+	success = (asprintf(&path, "%s/tty", con->conspath) != -1);
 	if (!success)
 		goto out;
 	success = xs_write(xs, XBT_NULL, path, slave, strlen(slave));
@@ -473,7 +482,7 @@ static int domain_create_tty(struct domain *dom)
 	if (!success)
 		goto out;
 
-	if (fcntl(dom->master_fd, F_SETFL, O_NONBLOCK) == -1)
+	if (fcntl(con->master_fd, F_SETFL, O_NONBLOCK) == -1)
 		goto out;
 
 	return 1;
@@ -519,29 +528,32 @@ static int xs_gather(struct xs_handle *xs, const char *dir, ...)
 
 static void domain_unmap_interface(struct domain *dom)
 {
-	if (dom->interface == NULL)
+	struct console *con = &dom->console;
+
+	if (con->interface == NULL)
 		return;
-	if (xgt_handle && dom->ring_ref == -1)
-		xengnttab_unmap(xgt_handle, dom->interface, 1);
+	if (xgt_handle && con->ring_ref == -1)
+		xengnttab_unmap(xgt_handle, con->interface, 1);
 	else
-		munmap(dom->interface, XC_PAGE_SIZE);
-	dom->interface = NULL;
-	dom->ring_ref = -1;
+		munmap(con->interface, XC_PAGE_SIZE);
+	con->interface = NULL;
+	con->ring_ref = -1;
 }
  
 static int domain_create_ring(struct domain *dom)
 {
 	int err, remote_port, ring_ref, rc;
 	char *type, path[PATH_MAX];
+	struct console *con = &dom->console;
 
-	err = xs_gather(xs, dom->conspath,
+	err = xs_gather(xs, con->conspath,
 			"ring-ref", "%u", &ring_ref,
 			"port", "%i", &remote_port,
 			NULL);
 	if (err)
 		goto out;
 
-	snprintf(path, sizeof(path), "%s/type", dom->conspath);
+	snprintf(path, sizeof(path), "%s/type", con->conspath);
 	type = xs_read(xs, XBT_NULL, path, NULL);
 	if (type && strcmp(type, "xenconsoled") != 0) {
 		free(type);
@@ -550,77 +562,77 @@ static int domain_create_ring(struct domain *dom)
 	free(type);
 
 	/* If using ring_ref and it has changed, remap */
-	if (ring_ref != dom->ring_ref && dom->ring_ref != -1)
+	if (ring_ref != con->ring_ref && con->ring_ref != -1)
 		domain_unmap_interface(dom);
 
-	if (!dom->interface && xgt_handle) {
+	if (!con->interface && xgt_handle) {
 		/* Prefer using grant table */
-		dom->interface = xengnttab_map_grant_ref(xgt_handle,
+		con->interface = xengnttab_map_grant_ref(xgt_handle,
 			dom->domid, GNTTAB_RESERVED_CONSOLE,
 			PROT_READ|PROT_WRITE);
-		dom->ring_ref = -1;
+		con->ring_ref = -1;
 	}
-	if (!dom->interface) {
+	if (!con->interface) {
 		/* Fall back to xc_map_foreign_range */
-		dom->interface = xc_map_foreign_range(
+		con->interface = xc_map_foreign_range(
 			xc, dom->domid, XC_PAGE_SIZE,
 			PROT_READ|PROT_WRITE,
 			(unsigned long)ring_ref);
-		if (dom->interface == NULL) {
+		if (con->interface == NULL) {
 			err = EINVAL;
 			goto out;
 		}
-		dom->ring_ref = ring_ref;
+		con->ring_ref = ring_ref;
 	}
 
 	/* Go no further if port has not changed and we are still bound. */
-	if (remote_port == dom->remote_port) {
+	if (remote_port == con->remote_port) {
 		xc_evtchn_status_t status = {
 			.dom = DOMID_SELF,
-			.port = dom->local_port };
+			.port = con->local_port };
 		if ((xc_evtchn_status(xc, &status) == 0) &&
 		    (status.status == EVTCHNSTAT_interdomain))
 			goto out;
 	}
 
-	dom->local_port = -1;
-	dom->remote_port = -1;
-	if (dom->xce_handle != NULL)
-		xenevtchn_close(dom->xce_handle);
+	con->local_port = -1;
+	con->remote_port = -1;
+	if (con->xce_handle != NULL)
+		xenevtchn_close(con->xce_handle);
 
 	/* Opening evtchn independently for each console is a bit
 	 * wasteful, but that's how the code is structured... */
-	dom->xce_handle = xenevtchn_open(NULL, 0);
-	if (dom->xce_handle == NULL) {
+	con->xce_handle = xenevtchn_open(NULL, 0);
+	if (con->xce_handle == NULL) {
 		err = errno;
 		goto out;
 	}
  
-	rc = xenevtchn_bind_interdomain(dom->xce_handle,
+	rc = xenevtchn_bind_interdomain(con->xce_handle,
 		dom->domid, remote_port);
 
 	if (rc == -1) {
 		err = errno;
-		xenevtchn_close(dom->xce_handle);
-		dom->xce_handle = NULL;
+		xenevtchn_close(con->xce_handle);
+		con->xce_handle = NULL;
 		goto out;
 	}
-	dom->local_port = rc;
-	dom->remote_port = remote_port;
+	con->local_port = rc;
+	con->remote_port = remote_port;
 
-	if (dom->master_fd == -1) {
+	if (con->master_fd == -1) {
 		if (!domain_create_tty(dom)) {
 			err = errno;
-			xenevtchn_close(dom->xce_handle);
-			dom->xce_handle = NULL;
-			dom->local_port = -1;
-			dom->remote_port = -1;
+			xenevtchn_close(con->xce_handle);
+			con->xce_handle = NULL;
+			con->local_port = -1;
+			con->remote_port = -1;
 			goto out;
 		}
 	}
 
-	if (log_guest && (dom->log_fd == -1))
-		dom->log_fd = create_domain_log(dom);
+	if (log_guest && (con->log_fd == -1))
+		con->log_fd = create_domain_log(dom);
 
  out:
 	return err;
@@ -630,16 +642,17 @@ static bool watch_domain(struct domain *dom, bool watch)
 {
 	char domid_str[3 + MAX_STRLEN(dom->domid)];
 	bool success;
+	struct console *con = &dom->console;
 
 	snprintf(domid_str, sizeof(domid_str), "dom%u", dom->domid);
 	if (watch) {
-		success = xs_watch(xs, dom->conspath, domid_str);
+		success = xs_watch(xs, con->conspath, domid_str);
 		if (success)
 			domain_create_ring(dom);
 		else
-			xs_unwatch(xs, dom->conspath, domid_str);
+			xs_unwatch(xs, con->conspath, domid_str);
 	} else {
-		success = xs_unwatch(xs, dom->conspath, domid_str);
+		success = xs_unwatch(xs, con->conspath, domid_str);
 	}
 
 	return success;
@@ -651,6 +664,7 @@ static struct domain *create_domain(int domid)
 	struct domain *dom;
 	char *s;
 	struct timespec ts;
+	struct console *con;
 
 	if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) {
 		dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d",
@@ -667,25 +681,26 @@ static struct domain *create_domain(int domid)
 
 	dom->domid = domid;
 
-	dom->conspath = xs_get_domain_path(xs, dom->domid);
-	s = realloc(dom->conspath, strlen(dom->conspath) +
+	con = &dom->console;
+	con->conspath = xs_get_domain_path(xs, dom->domid);
+	s = realloc(con->conspath, strlen(con->conspath) +
 		    strlen("/console") + 1);
 	if (s == NULL)
 		goto out;
-	dom->conspath = s;
-	strcat(dom->conspath, "/console");
+	con->conspath = s;
+	strcat(con->conspath, "/console");
 
-	dom->master_fd = -1;
-	dom->master_pollfd_idx = -1;
-	dom->slave_fd = -1;
-	dom->log_fd = -1;
-	dom->xce_pollfd_idx = -1;
+	con->master_fd = -1;
+	con->master_pollfd_idx = -1;
+	con->slave_fd = -1;
+	con->log_fd = -1;
+	con->xce_pollfd_idx = -1;
 
-	dom->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD;
+	con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD;
 
-	dom->ring_ref = -1;
-	dom->local_port = -1;
-	dom->remote_port = -1;
+	con->ring_ref = -1;
+	con->local_port = -1;
+	con->remote_port = -1;
 
 	if (!watch_domain(dom, true))
 		goto out;
@@ -697,7 +712,7 @@ static struct domain *create_domain(int domid)
 
 	return dom;
  out:
-	free(dom->conspath);
+	free(con->conspath);
 	free(dom);
 	return NULL;
 }
@@ -729,30 +744,34 @@ static void remove_domain(struct domain *dom)
 
 static void cleanup_domain(struct domain *d)
 {
+	struct console *con = &d->console;
+
 	domain_close_tty(d);
 
-	if (d->log_fd != -1) {
-		close(d->log_fd);
-		d->log_fd = -1;
+	if (con->log_fd != -1) {
+		close(con->log_fd);
+		con->log_fd = -1;
 	}
 
-	free(d->buffer.data);
-	d->buffer.data = NULL;
+	free(con->buffer.data);
+	con->buffer.data = NULL;
 
-	free(d->conspath);
-	d->conspath = NULL;
+	free(con->conspath);
+	con->conspath = NULL;
 
 	remove_domain(d);
 }
 
 static void shutdown_domain(struct domain *d)
 {
+	struct console *con = &d->console;
+
 	d->is_dead = true;
 	watch_domain(d, false);
 	domain_unmap_interface(d);
-	if (d->xce_handle != NULL)
-		xenevtchn_close(d->xce_handle);
-	d->xce_handle = NULL;
+	if (con->xce_handle != NULL)
+		xenevtchn_close(con->xce_handle);
+	con->xce_handle = NULL;
 }
 
 static unsigned enum_pass = 0;
@@ -782,7 +801,8 @@ static void enum_domains(void)
 
 static int ring_free_bytes(struct domain *dom)
 {
-	struct xencons_interface *intf = dom->interface;
+	struct console *con = &dom->console;
+	struct xencons_interface *intf = con->interface;
 	XENCONS_RING_IDX cons, prod, space;
 
 	cons = intf->in_cons;
@@ -812,7 +832,8 @@ static void handle_tty_read(struct domain *dom)
 	ssize_t len = 0;
 	char msg[80];
 	int i;
-	struct xencons_interface *intf = dom->interface;
+	struct console *con = &dom->console;
+	struct xencons_interface *intf = con->interface;
 	XENCONS_RING_IDX prod;
 
 	if (dom->is_dead)
@@ -825,7 +846,7 @@ static void handle_tty_read(struct domain *dom)
 	if (len > sizeof(msg))
 		len = sizeof(msg);
 
-	len = read(dom->master_fd, msg, len);
+	len = read(con->master_fd, msg, len);
 	/*
 	 * Note: on Solaris, len == 0 means the slave closed, and this
 	 * is no problem, but Linux can't handle this usefully, so we
@@ -841,7 +862,7 @@ static void handle_tty_read(struct domain *dom)
 		}
 		xen_wmb();
 		intf->in_prod = prod;
-		xenevtchn_notify(dom->xce_handle, dom->local_port);
+		xenevtchn_notify(con->xce_handle, con->local_port);
 	} else {
 		domain_close_tty(dom);
 		shutdown_domain(dom);
@@ -851,37 +872,39 @@ static void handle_tty_read(struct domain *dom)
 static void handle_tty_write(struct domain *dom)
 {
 	ssize_t len;
+	struct console *con = &dom->console;
 
 	if (dom->is_dead)
 		return;
 
-	len = write(dom->master_fd, dom->buffer.data + dom->buffer.consumed,
-		    dom->buffer.size - dom->buffer.consumed);
+	len = write(con->master_fd, con->buffer.data + con->buffer.consumed,
+		    con->buffer.size - con->buffer.consumed);
  	if (len < 1) {
 		dolog(LOG_DEBUG, "Write failed on domain %d: %zd, %d\n",
 		      dom->domid, len, errno);
 		domain_handle_broken_tty(dom, domain_is_valid(dom->domid));
 	} else {
-		buffer_advance(&dom->buffer, len);
+		buffer_advance(&con->buffer, len);
 	}
 }
 
 static void handle_ring_read(struct domain *dom)
 {
 	xenevtchn_port_or_error_t port;
+	struct console *con = &dom->console;
 
 	if (dom->is_dead)
 		return;
 
-	if ((port = xenevtchn_pending(dom->xce_handle)) == -1)
+	if ((port = xenevtchn_pending(con->xce_handle)) == -1)
 		return;
 
-	dom->event_count++;
+	con->event_count++;
 
 	buffer_append(dom);
 
-	if (dom->event_count < RATE_LIMIT_ALLOWANCE)
-		(void)xenevtchn_unmask(dom->xce_handle, port);
+	if (con->event_count < RATE_LIMIT_ALLOWANCE)
+		(void)xenevtchn_unmask(con->xce_handle, port);
 }
 
 static void handle_xs(void)
@@ -948,9 +971,11 @@ static void handle_log_reload(void)
 	if (log_guest) {
 		struct domain *d;
 		for (d = dom_head; d; d = d->next) {
-			if (d->log_fd != -1)
-				close(d->log_fd);
-			d->log_fd = create_domain_log(d);
+			struct console *con = &d->console;
+
+			if (con->log_fd != -1)
+				close(con->log_fd);
+			con->log_fd = create_domain_log(d);
 		}
 	}
 
@@ -1059,48 +1084,52 @@ void handle_io(void)
 		/* Re-calculate any event counter allowances & unblock
 		   domains with new allowance */
 		for (d = dom_head; d; d = d->next) {
+			struct console *con = &d->console;
+
 			/* CS 16257:955ee4fa1345 introduces a 5ms fuzz
 			 * for select(), it is not clear poll() has
 			 * similar behavior (returning a couple of ms
 			 * sooner than requested) as well. Just leave
 			 * the fuzz here. Remove it with a separate
 			 * patch if necessary */
-			if ((now+5) > d->next_period) {
-				d->next_period = now + RATE_LIMIT_PERIOD;
-				if (d->event_count >= RATE_LIMIT_ALLOWANCE) {
-					(void)xenevtchn_unmask(d->xce_handle, d->local_port);
+			if ((now+5) > con->next_period) {
+				con->next_period = now + RATE_LIMIT_PERIOD;
+				if (con->event_count >= RATE_LIMIT_ALLOWANCE) {
+					(void)xenevtchn_unmask(con->xce_handle, con->local_port);
 				}
-				d->event_count = 0;
+				con->event_count = 0;
 			}
 		}
 
 		for (d = dom_head; d; d = d->next) {
-			if (d->event_count >= RATE_LIMIT_ALLOWANCE) {
+			struct console *con = &d->console;
+
+			if (con->event_count >= RATE_LIMIT_ALLOWANCE) {
 				/* Determine if we're going to be the next time slice to expire */
 				if (!next_timeout ||
-				    d->next_period < next_timeout)
-					next_timeout = d->next_period;
-			} else if (d->xce_handle != NULL) {
+				    con->next_period < next_timeout)
+					next_timeout = con->next_period;
+			} else if (con->xce_handle != NULL) {
 				if (discard_overflowed_data ||
-				    !d->buffer.max_capacity ||
-				    d->buffer.size < d->buffer.max_capacity) {
-					int evtchn_fd = xenevtchn_fd(d->xce_handle);
-					d->xce_pollfd_idx = set_fds(evtchn_fd,
+				    !con->buffer.max_capacity ||
+				    con->buffer.size < con->buffer.max_capacity) {
+					int evtchn_fd = xenevtchn_fd(con->xce_handle);
+					con->xce_pollfd_idx = set_fds(evtchn_fd,
 								    POLLIN|POLLPRI);
 				}
 			}
 
-			if (d->master_fd != -1) {
+			if (con->master_fd != -1) {
 				short events = 0;
 				if (!d->is_dead && ring_free_bytes(d))
 					events |= POLLIN;
 
-				if (!buffer_empty(&d->buffer))
+				if (!buffer_empty(&con->buffer))
 					events |= POLLOUT;
 
 				if (events)
-					d->master_pollfd_idx =
-						set_fds(d->master_fd,
+					con->master_pollfd_idx =
+						set_fds(con->master_fd,
 							events|POLLPRI);
 			}
 		}
@@ -1163,33 +1192,35 @@ void handle_io(void)
 		}
 
 		for (d = dom_head; d; d = n) {
+			struct console *con = &d->console;
+
 			n = d->next;
-			if (d->event_count < RATE_LIMIT_ALLOWANCE) {
-				if (d->xce_handle != NULL &&
-				    d->xce_pollfd_idx != -1 &&
-				    !(fds[d->xce_pollfd_idx].revents &
+			if (con->event_count < RATE_LIMIT_ALLOWANCE) {
+				if (con->xce_handle != NULL &&
+				    con->xce_pollfd_idx != -1 &&
+				    !(fds[con->xce_pollfd_idx].revents &
 				      ~(POLLIN|POLLOUT|POLLPRI)) &&
-				      (fds[d->xce_pollfd_idx].revents &
+				      (fds[con->xce_pollfd_idx].revents &
 				       POLLIN))
 				    handle_ring_read(d);
 			}
 
-			if (d->master_fd != -1 && d->master_pollfd_idx != -1) {
-				if (fds[d->master_pollfd_idx].revents &
+			if (con->master_fd != -1 && con->master_pollfd_idx != -1) {
+				if (fds[con->master_pollfd_idx].revents &
 				    ~(POLLIN|POLLOUT|POLLPRI))
 					domain_handle_broken_tty(d,
 						   domain_is_valid(d->domid));
 				else {
-					if (fds[d->master_pollfd_idx].revents &
+					if (fds[con->master_pollfd_idx].revents &
 					    POLLIN)
 						handle_tty_read(d);
-					if (fds[d->master_pollfd_idx].revents &
+					if (fds[con->master_pollfd_idx].revents &
 					    POLLOUT)
 						handle_tty_write(d);
 				}
 			}
 
-			d->xce_pollfd_idx = d->master_pollfd_idx = -1;
+			con->xce_pollfd_idx = con->master_pollfd_idx = -1;
 
 			if (d->last_seen != enum_pass)
 				shutdown_domain(d);
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 09/25 v7] xen/arm: vpl011: Rename the console structure field conspath to xspath
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (7 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 08/25 v7] xen/arm: vpl011: Modify xenconsole to define and use a new console structure Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-07  8:53 ` [PATCH 10/25 v7] xen/arm: vpl011: Modify xenconsole functions to take console structure as input Bhupinder Thakur
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

The console->conspath name is changed to console->xspath as it is
clear from the name that it is referring to xenstore path.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v4:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 30cd167..6f5c69c 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -95,7 +95,7 @@ struct console {
 	int slave_fd;
 	int log_fd;
 	struct buffer buffer;
-	char *conspath;
+	char *xspath;
 	int ring_ref;
 	xenevtchn_handle *xce_handle;
 	int xce_pollfd_idx;
@@ -463,7 +463,7 @@ static int domain_create_tty(struct domain *dom)
 		goto out;
 	}
 
-	success = asprintf(&path, "%s/limit", con->conspath) !=
+	success = asprintf(&path, "%s/limit", con->xspath) !=
 		-1;
 	if (!success)
 		goto out;
@@ -474,7 +474,7 @@ static int domain_create_tty(struct domain *dom)
 	}
 	free(path);
 
-	success = (asprintf(&path, "%s/tty", con->conspath) != -1);
+	success = (asprintf(&path, "%s/tty", con->xspath) != -1);
 	if (!success)
 		goto out;
 	success = xs_write(xs, XBT_NULL, path, slave, strlen(slave));
@@ -546,14 +546,14 @@ static int domain_create_ring(struct domain *dom)
 	char *type, path[PATH_MAX];
 	struct console *con = &dom->console;
 
-	err = xs_gather(xs, con->conspath,
+	err = xs_gather(xs, con->xspath,
 			"ring-ref", "%u", &ring_ref,
 			"port", "%i", &remote_port,
 			NULL);
 	if (err)
 		goto out;
 
-	snprintf(path, sizeof(path), "%s/type", con->conspath);
+	snprintf(path, sizeof(path), "%s/type", con->xspath);
 	type = xs_read(xs, XBT_NULL, path, NULL);
 	if (type && strcmp(type, "xenconsoled") != 0) {
 		free(type);
@@ -646,13 +646,13 @@ static bool watch_domain(struct domain *dom, bool watch)
 
 	snprintf(domid_str, sizeof(domid_str), "dom%u", dom->domid);
 	if (watch) {
-		success = xs_watch(xs, con->conspath, domid_str);
+		success = xs_watch(xs, con->xspath, domid_str);
 		if (success)
 			domain_create_ring(dom);
 		else
-			xs_unwatch(xs, con->conspath, domid_str);
+			xs_unwatch(xs, con->xspath, domid_str);
 	} else {
-		success = xs_unwatch(xs, con->conspath, domid_str);
+		success = xs_unwatch(xs, con->xspath, domid_str);
 	}
 
 	return success;
@@ -682,13 +682,13 @@ static struct domain *create_domain(int domid)
 	dom->domid = domid;
 
 	con = &dom->console;
-	con->conspath = xs_get_domain_path(xs, dom->domid);
-	s = realloc(con->conspath, strlen(con->conspath) +
+	con->xspath = xs_get_domain_path(xs, dom->domid);
+	s = realloc(con->xspath, strlen(con->xspath) +
 		    strlen("/console") + 1);
 	if (s == NULL)
 		goto out;
-	con->conspath = s;
-	strcat(con->conspath, "/console");
+	con->xspath = s;
+	strcat(con->xspath, "/console");
 
 	con->master_fd = -1;
 	con->master_pollfd_idx = -1;
@@ -712,7 +712,7 @@ static struct domain *create_domain(int domid)
 
 	return dom;
  out:
-	free(con->conspath);
+	free(con->xspath);
 	free(dom);
 	return NULL;
 }
@@ -756,8 +756,8 @@ static void cleanup_domain(struct domain *d)
 	free(con->buffer.data);
 	con->buffer.data = NULL;
 
-	free(con->conspath);
-	con->conspath = NULL;
+	free(con->xspath);
+	con->xspath = NULL;
 
 	remove_domain(d);
 }
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 10/25 v7] xen/arm: vpl011: Modify xenconsole functions to take console structure as input
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (8 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 09/25 v7] xen/arm: vpl011: Rename the console structure field conspath to xspath Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-07  8:53 ` [PATCH 11/25 v7] xen/arm: vpl011: Add a new console_init function in xenconsole Bhupinder Thakur
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

Xenconsole functions take domain structure as input. These functions shall be
modified to take console structure as input since these functions typically perform
console specific operations.

Also the console specific functions starting with prefix "domain_" shall be modified
to "console_" to indicate that these are console specific functions.

This patch is in preparation to support multiple consoles to support vuart console.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v3:
- The changes in xenconsole have been split into multiple patches. This is the second patch.

 tools/console/daemon/io.c | 79 +++++++++++++++++++++++------------------------
 1 file changed, 38 insertions(+), 41 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 6f5c69c..a2a3496 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -163,10 +163,10 @@ 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 console *con)
 {
-	struct console *con = &dom->console;
 	struct buffer *buffer = &con->buffer;
+	struct domain *dom = con->d;
 	XENCONS_RING_IDX cons, prod, size;
 	struct xencons_interface *intf = con->interface;
 
@@ -296,12 +296,13 @@ static int create_hv_log(void)
 	return fd;
 }
 
-static int create_domain_log(struct domain *dom)
+static int create_console_log(struct console *con)
 {
 	char logfile[PATH_MAX];
 	char *namepath, *data, *s;
 	int fd;
 	unsigned int len;
+	struct domain *dom = con->d;
 
 	namepath = xs_get_domain_path(xs, dom->domid);
 	s = realloc(namepath, strlen(namepath) + 6);
@@ -342,10 +343,8 @@ static int create_domain_log(struct domain *dom)
 	return fd;
 }
 
-static void domain_close_tty(struct domain *dom)
+static void console_close_tty(struct console *con)
 {
-	struct console *con = &dom->console;
-
 	if (con->master_fd != -1) {
 		close(con->master_fd);
 		con->master_fd = -1;
@@ -417,7 +416,7 @@ void cfmakeraw(struct termios *termios_p)
 }
 #endif /* __sun__ */
 
-static int domain_create_tty(struct domain *dom)
+static int console_create_tty(struct console *con)
 {
 	const char *slave;
 	char *path;
@@ -426,7 +425,7 @@ static int domain_create_tty(struct domain *dom)
 	char *data;
 	unsigned int len;
 	struct termios term;
-	struct console *con = &dom->console;
+	struct domain *dom = con->d;
 
 	assert(con->slave_fd == -1);
 	assert(con->master_fd == -1);
@@ -487,7 +486,7 @@ static int domain_create_tty(struct domain *dom)
 
 	return 1;
 out:
-	domain_close_tty(dom);
+	console_close_tty(con);
 	return 0;
 }
  
@@ -526,10 +525,8 @@ static int xs_gather(struct xs_handle *xs, const char *dir, ...)
 	return ret;
 }
 
-static void domain_unmap_interface(struct domain *dom)
+static void console_unmap_interface(struct console *con)
 {
-	struct console *con = &dom->console;
-
 	if (con->interface == NULL)
 		return;
 	if (xgt_handle && con->ring_ref == -1)
@@ -540,11 +537,11 @@ static void domain_unmap_interface(struct domain *dom)
 	con->ring_ref = -1;
 }
  
-static int domain_create_ring(struct domain *dom)
+static int console_create_ring(struct console *con)
 {
 	int err, remote_port, ring_ref, rc;
 	char *type, path[PATH_MAX];
-	struct console *con = &dom->console;
+	struct domain *dom = con->d;
 
 	err = xs_gather(xs, con->xspath,
 			"ring-ref", "%u", &ring_ref,
@@ -563,7 +560,7 @@ static int domain_create_ring(struct domain *dom)
 
 	/* If using ring_ref and it has changed, remap */
 	if (ring_ref != con->ring_ref && con->ring_ref != -1)
-		domain_unmap_interface(dom);
+		console_unmap_interface(con);
 
 	if (!con->interface && xgt_handle) {
 		/* Prefer using grant table */
@@ -621,7 +618,7 @@ static int domain_create_ring(struct domain *dom)
 	con->remote_port = remote_port;
 
 	if (con->master_fd == -1) {
-		if (!domain_create_tty(dom)) {
+		if (!console_create_tty(con)) {
 			err = errno;
 			xenevtchn_close(con->xce_handle);
 			con->xce_handle = NULL;
@@ -632,7 +629,7 @@ static int domain_create_ring(struct domain *dom)
 	}
 
 	if (log_guest && (con->log_fd == -1))
-		con->log_fd = create_domain_log(dom);
+		con->log_fd = create_console_log(con);
 
  out:
 	return err;
@@ -648,7 +645,7 @@ static bool watch_domain(struct domain *dom, bool watch)
 	if (watch) {
 		success = xs_watch(xs, con->xspath, domid_str);
 		if (success)
-			domain_create_ring(dom);
+			console_create_ring(con);
 		else
 			xs_unwatch(xs, con->xspath, domid_str);
 	} else {
@@ -695,6 +692,7 @@ static struct domain *create_domain(int domid)
 	con->slave_fd = -1;
 	con->log_fd = -1;
 	con->xce_pollfd_idx = -1;
+	con->d = dom;
 
 	con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD;
 
@@ -746,7 +744,7 @@ static void cleanup_domain(struct domain *d)
 {
 	struct console *con = &d->console;
 
-	domain_close_tty(d);
+	console_close_tty(con);
 
 	if (con->log_fd != -1) {
 		close(con->log_fd);
@@ -768,7 +766,7 @@ static void shutdown_domain(struct domain *d)
 
 	d->is_dead = true;
 	watch_domain(d, false);
-	domain_unmap_interface(d);
+	console_unmap_interface(con);
 	if (con->xce_handle != NULL)
 		xenevtchn_close(con->xce_handle);
 	con->xce_handle = NULL;
@@ -799,9 +797,8 @@ static void enum_domains(void)
 	}
 }
 
-static int ring_free_bytes(struct domain *dom)
+static int ring_free_bytes(struct console *con)
 {
-	struct console *con = &dom->console;
 	struct xencons_interface *intf = con->interface;
 	XENCONS_RING_IDX cons, prod, space;
 
@@ -816,30 +813,30 @@ static int ring_free_bytes(struct domain *dom)
 	return (sizeof(intf->in) - space);
 }
 
-static void domain_handle_broken_tty(struct domain *dom, int recreate)
+static void console_handle_broken_tty(struct console *con, int recreate)
 {
-	domain_close_tty(dom);
+	console_close_tty(con);
 
 	if (recreate) {
-		domain_create_tty(dom);
+		console_create_tty(con);
 	} else {
-		shutdown_domain(dom);
+		shutdown_domain(con->d);
 	}
 }
 
-static void handle_tty_read(struct domain *dom)
+static void handle_tty_read(struct console *con)
 {
 	ssize_t len = 0;
 	char msg[80];
 	int i;
-	struct console *con = &dom->console;
 	struct xencons_interface *intf = con->interface;
+	struct domain *dom = con->d;
 	XENCONS_RING_IDX prod;
 
 	if (dom->is_dead)
 		return;
 
-	len = ring_free_bytes(dom);
+	len = ring_free_bytes(con);
 	if (len == 0)
 		return;
 
@@ -853,7 +850,7 @@ static void handle_tty_read(struct domain *dom)
 	 * keep the slave open for the duration.
 	 */
 	if (len < 0) {
-		domain_handle_broken_tty(dom, domain_is_valid(dom->domid));
+		console_handle_broken_tty(con, domain_is_valid(dom->domid));
 	} else if (domain_is_valid(dom->domid)) {
 		prod = intf->in_prod;
 		for (i = 0; i < len; i++) {
@@ -864,15 +861,15 @@ static void handle_tty_read(struct domain *dom)
 		intf->in_prod = prod;
 		xenevtchn_notify(con->xce_handle, con->local_port);
 	} else {
-		domain_close_tty(dom);
+		console_close_tty(con);
 		shutdown_domain(dom);
 	}
 }
 
-static void handle_tty_write(struct domain *dom)
+static void handle_tty_write(struct console *con)
 {
 	ssize_t len;
-	struct console *con = &dom->console;
+	struct domain *dom = con->d;
 
 	if (dom->is_dead)
 		return;
@@ -882,7 +879,7 @@ static void handle_tty_write(struct domain *dom)
  	if (len < 1) {
 		dolog(LOG_DEBUG, "Write failed on domain %d: %zd, %d\n",
 		      dom->domid, len, errno);
-		domain_handle_broken_tty(dom, domain_is_valid(dom->domid));
+		console_handle_broken_tty(con, domain_is_valid(dom->domid));
 	} else {
 		buffer_advance(&con->buffer, len);
 	}
@@ -901,7 +898,7 @@ static void handle_ring_read(struct domain *dom)
 
 	con->event_count++;
 
-	buffer_append(dom);
+	buffer_append(con);
 
 	if (con->event_count < RATE_LIMIT_ALLOWANCE)
 		(void)xenevtchn_unmask(con->xce_handle, port);
@@ -925,7 +922,7 @@ static void handle_xs(void)
 		/* We may get watches firing for domains that have recently
 		   been removed, so dom may be NULL here. */
 		if (dom && dom->is_dead == false)
-			domain_create_ring(dom);
+			console_create_ring(&dom->console);
 	}
 
 	free(vec);
@@ -975,7 +972,7 @@ static void handle_log_reload(void)
 
 			if (con->log_fd != -1)
 				close(con->log_fd);
-			con->log_fd = create_domain_log(d);
+			con->log_fd = create_console_log(con);
 		}
 	}
 
@@ -1121,7 +1118,7 @@ void handle_io(void)
 
 			if (con->master_fd != -1) {
 				short events = 0;
-				if (!d->is_dead && ring_free_bytes(d))
+				if (!d->is_dead && ring_free_bytes(con))
 					events |= POLLIN;
 
 				if (!buffer_empty(&con->buffer))
@@ -1208,15 +1205,15 @@ void handle_io(void)
 			if (con->master_fd != -1 && con->master_pollfd_idx != -1) {
 				if (fds[con->master_pollfd_idx].revents &
 				    ~(POLLIN|POLLOUT|POLLPRI))
-					domain_handle_broken_tty(d,
+					console_handle_broken_tty(con,
 						   domain_is_valid(d->domid));
 				else {
 					if (fds[con->master_pollfd_idx].revents &
 					    POLLIN)
-						handle_tty_read(d);
+						handle_tty_read(con);
 					if (fds[con->master_pollfd_idx].revents &
 					    POLLOUT)
-						handle_tty_write(d);
+						handle_tty_write(con);
 				}
 			}
 
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 11/25 v7] xen/arm: vpl011: Add a new console_init function in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (9 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 10/25 v7] xen/arm: vpl011: Modify xenconsole functions to take console structure as input Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 13:11   ` Wei Liu
  2017-08-07  8:53 ` [PATCH 12/25 v7] xen/arm: vpl011: Add a new buffer_available " Bhupinder Thakur
                   ` (14 subsequent siblings)
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch introduces a new console_init function. This function
initializes the console structure.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 65 ++++++++++++++++++++++++++++-------------------
 1 file changed, 39 insertions(+), 26 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index a2a3496..1da08d7 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -655,20 +655,51 @@ static bool watch_domain(struct domain *dom, bool watch)
 	return success;
 }
 
-
-static struct domain *create_domain(int domid)
+static int console_init(struct console *con, struct domain *dom)
 {
-	struct domain *dom;
 	char *s;
+	int err = -1;
 	struct timespec ts;
-	struct console *con;
 
 	if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) {
 		dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d",
 		      __FILE__, __FUNCTION__, __LINE__);
-		return NULL;
+		return err;
 	}
 
+	con->master_fd = -1;
+	con->master_pollfd_idx = -1;
+	con->slave_fd = -1;
+	con->log_fd = -1;
+	con->ring_ref = -1;
+	con->local_port = -1;
+	con->remote_port = -1;
+	con->xce_pollfd_idx = -1;
+	con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD;
+	con->d = dom;
+	con->xspath = xs_get_domain_path(xs, dom->domid);
+	s = realloc(con->xspath, strlen(con->xspath) +
+		    strlen("/console") + 1);
+	if (s) {
+		con->xspath = s;
+		strcat(con->xspath, "/console");
+		err = 0;
+	}
+
+	return err;
+}
+
+static void console_free(struct console *con)
+{
+	if (con->xspath)
+		free(con->xspath);
+}
+
+static struct domain *create_domain(int domid)
+{
+	struct domain *dom;
+	struct console *con;
+
 	dom = calloc(1, sizeof *dom);
 	if (dom == NULL) {
 		dolog(LOG_ERR, "Out of memory %s:%s():L%d",
@@ -677,28 +708,10 @@ static struct domain *create_domain(int domid)
 	}
 
 	dom->domid = domid;
-
 	con = &dom->console;
-	con->xspath = xs_get_domain_path(xs, dom->domid);
-	s = realloc(con->xspath, strlen(con->xspath) +
-		    strlen("/console") + 1);
-	if (s == NULL)
-		goto out;
-	con->xspath = s;
-	strcat(con->xspath, "/console");
-
-	con->master_fd = -1;
-	con->master_pollfd_idx = -1;
-	con->slave_fd = -1;
-	con->log_fd = -1;
-	con->xce_pollfd_idx = -1;
-	con->d = dom;
-
-	con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD;
 
-	con->ring_ref = -1;
-	con->local_port = -1;
-	con->remote_port = -1;
+	if (console_init(con, dom))
+		goto out;
 
 	if (!watch_domain(dom, true))
 		goto out;
@@ -710,7 +723,7 @@ static struct domain *create_domain(int domid)
 
 	return dom;
  out:
-	free(con->xspath);
+	console_free(con);
 	free(dom);
 	return NULL;
 }
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 12/25 v7] xen/arm: vpl011: Add a new buffer_available function in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (10 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 11/25 v7] xen/arm: vpl011: Add a new console_init function in xenconsole Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-07  8:53 ` [PATCH 13/25 v7] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd " Bhupinder Thakur
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch introduces a new buffer_available function to check if
more data is allowed to be buffered.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 1da08d7..0009bbe 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -163,6 +163,16 @@ static int write_with_timestamp(int fd, const char *data, size_t sz,
 	return 0;
 }
 
+static inline bool buffer_available(struct console *con)
+{
+	if (discard_overflowed_data ||
+	    !con->buffer.max_capacity ||
+	    con->buffer.size < con->buffer.max_capacity)
+		return true;
+	else
+		return false;
+}
+
 static void buffer_append(struct console *con)
 {
 	struct buffer *buffer = &con->buffer;
@@ -1120,9 +1130,7 @@ void handle_io(void)
 				    con->next_period < next_timeout)
 					next_timeout = con->next_period;
 			} else if (con->xce_handle != NULL) {
-				if (discard_overflowed_data ||
-				    !con->buffer.max_capacity ||
-				    con->buffer.size < con->buffer.max_capacity) {
+			        if (buffer_available(con)) {
 					int evtchn_fd = xenevtchn_fd(con->xce_handle);
 					con->xce_pollfd_idx = set_fds(evtchn_fd,
 								    POLLIN|POLLPRI);
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 13/25 v7] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd function in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (11 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 12/25 v7] xen/arm: vpl011: Add a new buffer_available " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 13:12   ` Wei Liu
  2017-08-07  8:53 ` [PATCH 14/25 v7] xen/arm: vpl011: Add a new maybe_add_console_tty_fd " Bhupinder Thakur
                   ` (12 subsequent siblings)
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch introduces a new maybe_add_console_evtchn_fd function. This
function adds the console event channel FD to list of polled FDs.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v6:
- Renamed add_console_evtchn_fd to maybe_add_console_evtchn_fd since it 
  adds the FD to the poll list conditionally.

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 0009bbe..3483252 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -1047,6 +1047,26 @@ static void reset_fds(void)
 		memset(fds, 0, sizeof(struct pollfd) * current_array_size);
 }
 
+static void maybe_add_console_evtchn_fd(struct console *con, void *data)
+{
+	long long next_timeout = *((long long *)data);
+
+	if (con->event_count >= RATE_LIMIT_ALLOWANCE) {
+		/* Determine if we're going to be the next time slice to expire */
+		if (!next_timeout ||
+		    con->next_period < next_timeout)
+			next_timeout = con->next_period;
+	} else if (con->xce_handle != NULL) {
+		if (buffer_available(con)) {
+			int evtchn_fd = xenevtchn_fd(con->xce_handle);
+			con->xce_pollfd_idx = set_fds(evtchn_fd,
+						      POLLIN|POLLPRI);
+		}
+	}
+
+	*((long long *)data) = next_timeout;
+}
+
 void handle_io(void)
 {
 	int ret;
@@ -1124,18 +1144,7 @@ void handle_io(void)
 		for (d = dom_head; d; d = d->next) {
 			struct console *con = &d->console;
 
-			if (con->event_count >= RATE_LIMIT_ALLOWANCE) {
-				/* Determine if we're going to be the next time slice to expire */
-				if (!next_timeout ||
-				    con->next_period < next_timeout)
-					next_timeout = con->next_period;
-			} else if (con->xce_handle != NULL) {
-			        if (buffer_available(con)) {
-					int evtchn_fd = xenevtchn_fd(con->xce_handle);
-					con->xce_pollfd_idx = set_fds(evtchn_fd,
-								    POLLIN|POLLPRI);
-				}
-			}
+			maybe_add_console_evtchn_fd(con, (void *)&next_timeout);
 
 			if (con->master_fd != -1) {
 				short events = 0;
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 14/25 v7] xen/arm: vpl011: Add a new maybe_add_console_tty_fd function in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (12 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 13/25 v7] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 13:12   ` Wei Liu
  2017-08-07  8:53 ` [PATCH 15/25 v7] xen/arm: vpl011: Add a new console_evtchn_unmask " Bhupinder Thakur
                   ` (11 subsequent siblings)
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch introduces a new maybe_add_console_tty_fd function. This function
adds the tty fd to the list of polled fds.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v6:
- Renamed add_console_tty_fd to maybe_add_console_tty_fd since it 
  adds the tty FD to the poll list conditionally.
- I have retained the reviewed-by tag as only the function name has been
  changed.

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 3483252..a0b35da 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -1067,6 +1067,22 @@ static void maybe_add_console_evtchn_fd(struct console *con, void *data)
 	*((long long *)data) = next_timeout;
 }
 
+static void maybe_add_console_tty_fd(struct console *con)
+{
+	if (con->master_fd != -1) {
+		short events = 0;
+		if (!con->d->is_dead && ring_free_bytes(con))
+			events |= POLLIN;
+
+		if (!buffer_empty(&con->buffer))
+			events |= POLLOUT;
+
+		if (events)
+			con->master_pollfd_idx =
+				set_fds(con->master_fd, events|POLLPRI);
+	}
+}
+
 void handle_io(void)
 {
 	int ret;
@@ -1146,19 +1162,7 @@ void handle_io(void)
 
 			maybe_add_console_evtchn_fd(con, (void *)&next_timeout);
 
-			if (con->master_fd != -1) {
-				short events = 0;
-				if (!d->is_dead && ring_free_bytes(con))
-					events |= POLLIN;
-
-				if (!buffer_empty(&con->buffer))
-					events |= POLLOUT;
-
-				if (events)
-					con->master_pollfd_idx =
-						set_fds(con->master_fd,
-							events|POLLPRI);
-			}
+			maybe_add_console_tty_fd(con);
 		}
 
 		/* If any domain has been rate limited, we need to work
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 15/25 v7] xen/arm: vpl011: Add a new console_evtchn_unmask function in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (13 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 14/25 v7] xen/arm: vpl011: Add a new maybe_add_console_tty_fd " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 13:15   ` Wei Liu
  2017-08-07  8:53 ` [PATCH 16/25 v7] xen/arm: vpl011: Add a new handle_console_ring " Bhupinder Thakur
                   ` (10 subsequent siblings)
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch introduces a new console_evtchn_unmask function. This function
unmasks the console event channel if it is masked for some timeout
period.

One optimization that has been done is to merge the two 'for' loops.

One 'for' loop was used to iterate through all domains and
unmask the domain event channels which had been rate limited for a
specified duration.

The other 'for' loop was run to add the event channel fd and the tty fd to
the poll list.

These two 'for' loops were merged so that the these operations can be done
in one iteration instead of two iterations.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 44 +++++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index a0b35da..2dcaee6 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -117,6 +117,11 @@ struct domain {
 
 static struct domain *dom_head;
 
+static inline bool console_enabled(struct console *con)
+{
+	return con->local_port != -1;
+}
+
 static int write_all(int fd, const char* buf, size_t len)
 {
 	while (len) {
@@ -908,6 +913,27 @@ static void handle_tty_write(struct console *con)
 	}
 }
 
+static void console_evtchn_unmask(struct console *con, void *data)
+{
+	long long now = (long long)data;
+
+	if (!console_enabled(con))
+		return;
+
+	/* CS 16257:955ee4fa1345 introduces a 5ms fuzz
+	 * for select(), it is not clear poll() has
+	 * similar behavior (returning a couple of ms
+	 * sooner than requested) as well. Just leave
+	 * the fuzz here. Remove it with a separate
+	 * patch if necessary */
+	if ((now+5) > con->next_period) {
+		con->next_period = now + RATE_LIMIT_PERIOD;
+		if (con->event_count >= RATE_LIMIT_ALLOWANCE)
+			(void)xenevtchn_unmask(con->xce_handle, con->local_port);
+		con->event_count = 0;
+	}
+}
+
 static void handle_ring_read(struct domain *dom)
 {
 	xenevtchn_port_or_error_t port;
@@ -1142,23 +1168,7 @@ void handle_io(void)
 		for (d = dom_head; d; d = d->next) {
 			struct console *con = &d->console;
 
-			/* CS 16257:955ee4fa1345 introduces a 5ms fuzz
-			 * for select(), it is not clear poll() has
-			 * similar behavior (returning a couple of ms
-			 * sooner than requested) as well. Just leave
-			 * the fuzz here. Remove it with a separate
-			 * patch if necessary */
-			if ((now+5) > con->next_period) {
-				con->next_period = now + RATE_LIMIT_PERIOD;
-				if (con->event_count >= RATE_LIMIT_ALLOWANCE) {
-					(void)xenevtchn_unmask(con->xce_handle, con->local_port);
-				}
-				con->event_count = 0;
-			}
-		}
-
-		for (d = dom_head; d; d = d->next) {
-			struct console *con = &d->console;
+			console_evtchn_unmask(con, (void *)now);
 
 			maybe_add_console_evtchn_fd(con, (void *)&next_timeout);
 
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 16/25 v7] xen/arm: vpl011: Add a new handle_console_ring function in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (14 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 15/25 v7] xen/arm: vpl011: Add a new console_evtchn_unmask " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 13:16   ` Wei Liu
  2017-08-07  8:53 ` [PATCH 17/25 v7] xen/arm: vpl011: Add a new handle_console_tty " Bhupinder Thakur
                   ` (9 subsequent siblings)
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch introduces a new handle_console_ring function. This function
reads the data from the ring buffer on receiving an event.

The initialization of event channel poll fd to -1 is moved inside the
handle_console_ring function as they are related. There should be no
change in the behavior as there is no functional change.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 2dcaee6..c361b42 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -934,17 +934,23 @@ static void console_evtchn_unmask(struct console *con, void *data)
 	}
 }
 
-static void handle_ring_read(struct domain *dom)
+static void handle_ring_read(struct console *con)
 {
 	xenevtchn_port_or_error_t port;
-	struct console *con = &dom->console;
 
-	if (dom->is_dead)
+	if (con->d->is_dead)
 		return;
 
 	if ((port = xenevtchn_pending(con->xce_handle)) == -1)
 		return;
 
+	if (port != con->local_port) {
+		dolog(LOG_ERR,
+		      "Event received for invalid port %d, Expected port is %d\n",
+		      port, con->local_port);
+		return;
+	}
+
 	con->event_count++;
 
 	buffer_append(con);
@@ -953,6 +959,21 @@ static void handle_ring_read(struct domain *dom)
 		(void)xenevtchn_unmask(con->xce_handle, port);
 }
 
+static void handle_console_ring(struct console *con)
+{
+	if (con->event_count < RATE_LIMIT_ALLOWANCE) {
+		if (con->xce_handle != NULL &&
+		    con->xce_pollfd_idx != -1 &&
+		    !(fds[con->xce_pollfd_idx].revents &
+		      ~(POLLIN|POLLOUT|POLLPRI)) &&
+		    (fds[con->xce_pollfd_idx].revents &
+		     POLLIN))
+			handle_ring_read(con);
+	}
+
+	con->xce_pollfd_idx = -1;
+}
+
 static void handle_xs(void)
 {
 	char **vec;
@@ -1236,15 +1257,8 @@ void handle_io(void)
 			struct console *con = &d->console;
 
 			n = d->next;
-			if (con->event_count < RATE_LIMIT_ALLOWANCE) {
-				if (con->xce_handle != NULL &&
-				    con->xce_pollfd_idx != -1 &&
-				    !(fds[con->xce_pollfd_idx].revents &
-				      ~(POLLIN|POLLOUT|POLLPRI)) &&
-				      (fds[con->xce_pollfd_idx].revents &
-				       POLLIN))
-				    handle_ring_read(d);
-			}
+
+			handle_console_ring(con);
 
 			if (con->master_fd != -1 && con->master_pollfd_idx != -1) {
 				if (fds[con->master_pollfd_idx].revents &
@@ -1261,7 +1275,7 @@ void handle_io(void)
 				}
 			}
 
-			con->xce_pollfd_idx = con->master_pollfd_idx = -1;
+			con->master_pollfd_idx = -1;
 
 			if (d->last_seen != enum_pass)
 				shutdown_domain(d);
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 17/25 v7] xen/arm: vpl011: Add a new handle_console_tty function in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (15 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 16/25 v7] xen/arm: vpl011: Add a new handle_console_ring " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-07  8:53 ` [PATCH 18/25 v7] xen/arm: vpl011: Add a new console_cleanup " Bhupinder Thakur
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch introduces a new handle_console_tty function. This function
performs read/write from/to console tty.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index c361b42..5c6da31 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -1130,6 +1130,24 @@ static void maybe_add_console_tty_fd(struct console *con)
 	}
 }
 
+static void handle_console_tty(struct console *con)
+{
+	if (con->master_fd != -1 && con->master_pollfd_idx != -1) {
+		if (fds[con->master_pollfd_idx].revents &
+		    ~(POLLIN|POLLOUT|POLLPRI))
+			console_handle_broken_tty(con, domain_is_valid(con->d->domid));
+		else {
+			if (fds[con->master_pollfd_idx].revents &
+			    POLLIN)
+				handle_tty_read(con);
+			if (fds[con->master_pollfd_idx].revents &
+			    POLLOUT)
+				handle_tty_write(con);
+		}
+	}
+	con->master_pollfd_idx = -1;
+}
+
 void handle_io(void)
 {
 	int ret;
@@ -1260,22 +1278,7 @@ void handle_io(void)
 
 			handle_console_ring(con);
 
-			if (con->master_fd != -1 && con->master_pollfd_idx != -1) {
-				if (fds[con->master_pollfd_idx].revents &
-				    ~(POLLIN|POLLOUT|POLLPRI))
-					console_handle_broken_tty(con,
-						   domain_is_valid(d->domid));
-				else {
-					if (fds[con->master_pollfd_idx].revents &
-					    POLLIN)
-						handle_tty_read(con);
-					if (fds[con->master_pollfd_idx].revents &
-					    POLLOUT)
-						handle_tty_write(con);
-				}
-			}
-
-			con->master_pollfd_idx = -1;
+			handle_console_tty(con);
 
 			if (d->last_seen != enum_pass)
 				shutdown_domain(d);
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 18/25 v7] xen/arm: vpl011: Add a new console_cleanup function in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (16 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 17/25 v7] xen/arm: vpl011: Add a new handle_console_tty " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 13:29   ` Wei Liu
  2017-08-07  8:53 ` [PATCH 19/25 v7] xen/arm: vpl011: Add a new console_open_log " Bhupinder Thakur
                   ` (7 subsequent siblings)
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch introduces a new console_cleanup function. This function
frees up the console resources.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v6:
- Removed a null pointer check before calling free() as free() already checks that.

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 5c6da31..ff69e52 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -768,12 +768,8 @@ static void remove_domain(struct domain *dom)
 	}
 }
 
-static void cleanup_domain(struct domain *d)
+static void console_cleanup(struct console *con)
 {
-	struct console *con = &d->console;
-
-	console_close_tty(con);
-
 	if (con->log_fd != -1) {
 		close(con->log_fd);
 		con->log_fd = -1;
@@ -784,6 +780,15 @@ static void cleanup_domain(struct domain *d)
 
 	free(con->xspath);
 	con->xspath = NULL;
+}
+
+static void cleanup_domain(struct domain *d)
+{
+	struct console *con = &d->console;
+
+	console_close_tty(con);
+
+	console_cleanup(con);
 
 	remove_domain(d);
 }
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 19/25 v7] xen/arm: vpl011: Add a new console_open_log function in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (17 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 18/25 v7] xen/arm: vpl011: Add a new console_cleanup " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 13:31   ` Wei Liu
  2017-08-07  8:53 ` [PATCH 20/25 v7] xen/arm: vpl011: Add a new console_close_evtchn " Bhupinder Thakur
                   ` (6 subsequent siblings)
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch introduces a console_open_log console_cleanup function. This function
opens the console log file.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index ff69e52..cfd7273 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -1038,6 +1038,15 @@ static void handle_hv_logs(xenevtchn_handle *xce_handle, bool force)
 		(void)xenevtchn_unmask(xce_handle, port);
 }
 
+static void console_open_log(struct console *con)
+{
+	if (console_enabled(con)) {
+		if (con->log_fd != -1)
+			close(con->log_fd);
+		con->log_fd = create_console_log(con);
+	}
+}
+
 static void handle_log_reload(void)
 {
 	if (log_guest) {
@@ -1045,9 +1054,7 @@ static void handle_log_reload(void)
 		for (d = dom_head; d; d = d->next) {
 			struct console *con = &d->console;
 
-			if (con->log_fd != -1)
-				close(con->log_fd);
-			con->log_fd = create_console_log(con);
+			console_open_log(con);
 		}
 	}
 
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 20/25 v7] xen/arm: vpl011: Add a new console_close_evtchn function in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (18 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 19/25 v7] xen/arm: vpl011: Add a new console_open_log " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-07  8:53 ` [PATCH 21/25 v7] xen/arm: vpl011: Add support for multiple consoles " Bhupinder Thakur
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch introduces a console_close_evtchn function. This function closes
the console event channel.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index cfd7273..71465a0 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -793,6 +793,14 @@ static void cleanup_domain(struct domain *d)
 	remove_domain(d);
 }
 
+static void console_close_evtchn(struct console *con)
+{
+	if (con->xce_handle != NULL)
+		xenevtchn_close(con->xce_handle);
+
+	con->xce_handle = NULL;
+}
+
 static void shutdown_domain(struct domain *d)
 {
 	struct console *con = &d->console;
@@ -800,9 +808,7 @@ static void shutdown_domain(struct domain *d)
 	d->is_dead = true;
 	watch_domain(d, false);
 	console_unmap_interface(con);
-	if (con->xce_handle != NULL)
-		xenevtchn_close(con->xce_handle);
-	con->xce_handle = NULL;
+	console_close_evtchn(con);
 }
 
 static unsigned enum_pass = 0;
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 21/25 v7] xen/arm: vpl011: Add support for multiple consoles in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (19 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 20/25 v7] xen/arm: vpl011: Add a new console_close_evtchn " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 13:48   ` Wei Liu
  2017-08-07  8:53 ` [PATCH 22/25 v7] xen/arm: vpl011: Add support for vuart console " Bhupinder Thakur
                   ` (4 subsequent siblings)
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

This patch adds the support for multiple consoles and introduces the
iterator functions to operate on multiple consoles.

This patch is in preparation to support a new vuart console.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v5:
- Split this patch in multiple smaller patches.

Changes since v4:
- Changes to make event channel handling per console rather than per domain.

Changes since v3:
- The changes in xenconsole have been split into four patches. This is the third patch.

 tools/console/daemon/io.c | 156 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 122 insertions(+), 34 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 71465a0..f60312d 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -90,12 +90,14 @@ struct buffer {
 };
 
 struct console {
+	char *ttyname;
 	int master_fd;
 	int master_pollfd_idx;
 	int slave_fd;
 	int log_fd;
 	struct buffer buffer;
 	char *xspath;
+	char *log_suffix;
 	int ring_ref;
 	xenevtchn_handle *xce_handle;
 	int xce_pollfd_idx;
@@ -107,21 +109,107 @@ struct console {
 	struct domain *d;
 };
 
+struct console_data {
+	char *xsname;
+	char *ttyname;
+	char *log_suffix;
+};
+
+static struct console_data console_data[] = {
+	{
+		.xsname = "/console",
+		.ttyname = "tty",
+		.log_suffix = "",
+	},
+};
+
+#define MAX_CONSOLE (sizeof(console_data)/sizeof(struct console_data))
+
 struct domain {
 	int domid;
 	bool is_dead;
 	unsigned last_seen;
 	struct domain *next;
-	struct console console;
+	struct console console[MAX_CONSOLE];
 };
 
 static struct domain *dom_head;
 
+typedef void (*VOID_ITER_FUNC_ARG1)(struct console *);
+typedef bool (*BOOL_ITER_FUNC_ARG1)(struct console *);
+typedef int (*INT_ITER_FUNC_ARG1)(struct console *);
+typedef void (*VOID_ITER_FUNC_ARG2)(struct console *,  void *);
+typedef int (*INT_ITER_FUNC_ARG3)(struct console *,
+				  struct domain *dom, void **);
+
 static inline bool console_enabled(struct console *con)
 {
 	return con->local_port != -1;
 }
 
+static inline void console_iter_void_arg1(struct domain *d,
+					  VOID_ITER_FUNC_ARG1 iter_func)
+{
+	int i = 0;
+	struct console *con = &d->console[0];
+
+	for (i = 0; i < MAX_CONSOLE; i++, con++) {
+		iter_func(con);
+	}
+}
+
+static inline void console_iter_void_arg2(struct domain *d,
+					  VOID_ITER_FUNC_ARG2 iter_func,
+					  void *iter_data)
+{
+	int i = 0;
+	struct console *con = &d->console[0];
+
+	for (i = 0; i < MAX_CONSOLE; i++, con++) {
+		iter_func(con, iter_data);
+	}
+}
+
+static inline bool console_iter_bool_arg1(struct domain *d,
+					  BOOL_ITER_FUNC_ARG1 iter_func)
+{
+	int i = 0;
+	struct console *con = &d->console[0];
+
+	for (i = 0; i < MAX_CONSOLE; i++, con++) {
+		if (iter_func(con))
+			return true;
+	}
+	return false;
+}
+
+static inline int console_iter_int_arg1(struct domain *d,
+					INT_ITER_FUNC_ARG1 iter_func)
+{
+	int i = 0;
+	struct console *con = &d->console[0];
+
+	for (i = 0; i < MAX_CONSOLE; i++, con++) {
+		if (iter_func(con))
+			return 1;
+	}
+	return 0;
+}
+
+static inline int console_iter_int_arg3(struct domain *d,
+					INT_ITER_FUNC_ARG3 iter_func,
+					void **iter_data)
+{
+	int i = 0;
+	struct console *con = &d->console[0];
+
+	for (i = 0; i < MAX_CONSOLE; i++, con++) {
+		if (iter_func(con, d, iter_data))
+			return 1;
+	}
+	return 0;
+}
+
 static int write_all(int fd, const char* buf, size_t len)
 {
 	while (len) {
@@ -336,7 +424,7 @@ static int create_console_log(struct console *con)
 		return -1;
 	}
 
-	snprintf(logfile, PATH_MAX-1, "%s/guest-%s.log", log_dir, data);
+	snprintf(logfile, PATH_MAX-1, "%s/guest-%s%s.log", log_dir, data, con->log_suffix);
 	free(data);
 	logfile[PATH_MAX-1] = '\0';
 
@@ -488,7 +576,7 @@ static int console_create_tty(struct console *con)
 	}
 	free(path);
 
-	success = (asprintf(&path, "%s/tty", con->xspath) != -1);
+	success = (asprintf(&path, "%s/%s", con->xspath, con->ttyname) != -1);
 	if (!success)
 		goto out;
 	success = xs_write(xs, XBT_NULL, path, slave, strlen(slave));
@@ -654,13 +742,13 @@ static bool watch_domain(struct domain *dom, bool watch)
 {
 	char domid_str[3 + MAX_STRLEN(dom->domid)];
 	bool success;
-	struct console *con = &dom->console;
+	struct console *con = &dom->console[0];
 
 	snprintf(domid_str, sizeof(domid_str), "dom%u", dom->domid);
 	if (watch) {
 		success = xs_watch(xs, con->xspath, domid_str);
 		if (success)
-			console_create_ring(con);
+			console_iter_int_arg1(dom, console_create_ring);
 		else
 			xs_unwatch(xs, con->xspath, domid_str);
 	} else {
@@ -670,11 +758,13 @@ static bool watch_domain(struct domain *dom, bool watch)
 	return success;
 }
 
-static int console_init(struct console *con, struct domain *dom)
+static int console_init(struct console *con, struct domain *dom, void **data)
 {
 	char *s;
 	int err = -1;
 	struct timespec ts;
+	struct console_data **con_data = (struct console_data **)data;
+	char *xsname, *xspath;
 
 	if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) {
 		dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d",
@@ -692,15 +782,21 @@ static int console_init(struct console *con, struct domain *dom)
 	con->xce_pollfd_idx = -1;
 	con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD;
 	con->d = dom;
-	con->xspath = xs_get_domain_path(xs, dom->domid);
-	s = realloc(con->xspath, strlen(con->xspath) +
-		    strlen("/console") + 1);
+	con->ttyname = (*con_data)->ttyname;
+	con->log_suffix = (*con_data)->log_suffix;
+	xsname = (char *)(*con_data)->xsname;
+	xspath = xs_get_domain_path(xs, dom->domid);
+	s = realloc(xspath, strlen(xspath) +
+		    strlen(xsname) + 1);
 	if (s) {
-		con->xspath = s;
-		strcat(con->xspath, "/console");
+		xspath = s;
+		strcat(xspath, xsname);
+		con->xspath = xspath;
 		err = 0;
 	}
 
+	(*con_data)++;
+
 	return err;
 }
 
@@ -713,7 +809,7 @@ static void console_free(struct console *con)
 static struct domain *create_domain(int domid)
 {
 	struct domain *dom;
-	struct console *con;
+	struct console_data *con_data = &console_data[0];
 
 	dom = calloc(1, sizeof *dom);
 	if (dom == NULL) {
@@ -723,9 +819,8 @@ static struct domain *create_domain(int domid)
 	}
 
 	dom->domid = domid;
-	con = &dom->console;
 
-	if (console_init(con, dom))
+	if (console_iter_int_arg3(dom, console_init, (void **)&con_data))
 		goto out;
 
 	if (!watch_domain(dom, true))
@@ -738,7 +833,7 @@ static struct domain *create_domain(int domid)
 
 	return dom;
  out:
-	console_free(con);
+	console_iter_void_arg1(dom, console_free);
 	free(dom);
 	return NULL;
 }
@@ -784,11 +879,9 @@ static void console_cleanup(struct console *con)
 
 static void cleanup_domain(struct domain *d)
 {
-	struct console *con = &d->console;
+	console_iter_void_arg1(d, console_close_tty);
 
-	console_close_tty(con);
-
-	console_cleanup(con);
+	console_iter_void_arg1(d, console_cleanup);
 
 	remove_domain(d);
 }
@@ -803,12 +896,10 @@ static void console_close_evtchn(struct console *con)
 
 static void shutdown_domain(struct domain *d)
 {
-	struct console *con = &d->console;
-
 	d->is_dead = true;
 	watch_domain(d, false);
-	console_unmap_interface(con);
-	console_close_evtchn(con);
+	console_iter_void_arg1(d, console_unmap_interface);
+	console_iter_void_arg1(d, console_close_evtchn);
 }
 
 static unsigned enum_pass = 0;
@@ -1003,7 +1094,7 @@ static void handle_xs(void)
 		/* We may get watches firing for domains that have recently
 		   been removed, so dom may be NULL here. */
 		if (dom && dom->is_dead == false)
-			console_create_ring(&dom->console);
+			console_iter_int_arg1(dom, console_create_ring);
 	}
 
 	free(vec);
@@ -1058,9 +1149,7 @@ static void handle_log_reload(void)
 	if (log_guest) {
 		struct domain *d;
 		for (d = dom_head; d; d = d->next) {
-			struct console *con = &d->console;
-
-			console_open_log(con);
+			console_iter_void_arg1(d, console_open_log);
 		}
 	}
 
@@ -1223,13 +1312,13 @@ void handle_io(void)
 		/* Re-calculate any event counter allowances & unblock
 		   domains with new allowance */
 		for (d = dom_head; d; d = d->next) {
-			struct console *con = &d->console;
 
-			console_evtchn_unmask(con, (void *)now);
+			console_iter_void_arg2(d, console_evtchn_unmask, (void *)now);
 
-			maybe_add_console_evtchn_fd(con, (void *)&next_timeout);
+			console_iter_void_arg2(d, maybe_add_console_evtchn_fd, 
+					       (void *)&next_timeout);
 
-			maybe_add_console_tty_fd(con);
+			console_iter_void_arg1(d, maybe_add_console_tty_fd);
 		}
 
 		/* If any domain has been rate limited, we need to work
@@ -1290,13 +1379,12 @@ void handle_io(void)
 		}
 
 		for (d = dom_head; d; d = n) {
-			struct console *con = &d->console;
 
 			n = d->next;
 
-			handle_console_ring(con);
+			console_iter_void_arg1(d, handle_console_ring);
 
-			handle_console_tty(con);
+			console_iter_void_arg1(d, handle_console_tty);
 
 			if (d->last_seen != enum_pass)
 				shutdown_domain(d);
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 22/25 v7] xen/arm: vpl011: Add support for vuart console in xenconsole
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (20 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 21/25 v7] xen/arm: vpl011: Add support for multiple consoles " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 13:52   ` Wei Liu
  2017-08-07  8:53 ` [PATCH 23/25 v7] xen/arm: vpl011: Add a new vuart console type to xenconsole client Bhupinder Thakur
                   ` (3 subsequent siblings)
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, Jan Beulich

This patch finally adds the support for vuart console. It adds
two new fields in the console initialization:

- optional
- use_gnttab

optional flag tells whether the console is optional.

use_gnttab tells whether the ring buffer should be allocated using
grant table.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Tim Deegan <tim@xen.org>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Julien Grall <julien.grall@arm.com>

Changes since v6:
- Renames prefer_gnttab to use_gnttab

Changes since v4:
- Renamed VUART_CFLAGS- to CFLAGS_vuart- in the Makefile as per the convention.

 config/arm32.mk           |  1 +
 config/arm64.mk           |  1 +
 tools/console/Makefile    |  3 ++-
 tools/console/daemon/io.c | 32 ++++++++++++++++++++++++++++++--
 4 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/config/arm32.mk b/config/arm32.mk
index f95228e..b9f23fe 100644
--- a/config/arm32.mk
+++ b/config/arm32.mk
@@ -1,5 +1,6 @@
 CONFIG_ARM := y
 CONFIG_ARM_32 := y
+CONFIG_VUART_CONSOLE := y
 CONFIG_ARM_$(XEN_OS) := y
 
 CONFIG_XEN_INSTALL_SUFFIX :=
diff --git a/config/arm64.mk b/config/arm64.mk
index aa45772..861d0a4 100644
--- a/config/arm64.mk
+++ b/config/arm64.mk
@@ -1,5 +1,6 @@
 CONFIG_ARM := y
 CONFIG_ARM_64 := y
+CONFIG_VUART_CONSOLE := y
 CONFIG_ARM_$(XEN_OS) := y
 
 CONFIG_XEN_INSTALL_SUFFIX :=
diff --git a/tools/console/Makefile b/tools/console/Makefile
index abe77b2..e7ff8ff 100644
--- a/tools/console/Makefile
+++ b/tools/console/Makefile
@@ -11,6 +11,7 @@ LDLIBS += $(SOCKET_LIBS)
 
 LDLIBS_xenconsoled += $(UTIL_LIBS)
 LDLIBS_xenconsoled += -lrt
+CFLAGS_vuart-$(CONFIG_VUART_CONSOLE) = -DCONFIG_VUART_CONSOLE
 
 BIN      = xenconsoled xenconsole
 
@@ -28,7 +29,7 @@ clean:
 distclean: clean
 
 daemon/main.o: daemon/_paths.h
-daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab)
+daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) $(CFLAGS_vuart-y)
 xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c))
 	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_xenconsoled) $(APPEND_LDFLAGS)
 
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 067eeb5..2817a49 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -107,12 +107,16 @@ struct console {
 	xenevtchn_port_or_error_t remote_port;
 	struct xencons_interface *interface;
 	struct domain *d;
+	bool optional;
+	bool use_gnttab;
 };
 
 struct console_data {
 	char *xsname;
 	char *ttyname;
 	char *log_suffix;
+	bool optional;
+	bool use_gnttab;
 };
 
 static struct console_data console_data[] = {
@@ -120,7 +124,18 @@ static struct console_data console_data[] = {
 		.xsname = "/console",
 		.ttyname = "tty",
 		.log_suffix = "",
+		.optional = false,
+		.use_gnttab = true,
 	},
+#if defined(CONFIG_VUART_CONSOLE)
+	{
+		.xsname = "/vuart/0",
+		.ttyname = "tty",
+		.log_suffix = "-vuart0",
+		.optional = true,
+		.use_gnttab = false,
+	},
+#endif
 };
 
 #define MAX_CONSOLE (sizeof(console_data)/sizeof(struct console_data))
@@ -650,8 +665,17 @@ static int console_create_ring(struct console *con)
 			"ring-ref", "%u", &ring_ref,
 			"port", "%i", &remote_port,
 			NULL);
-	if (err)
+
+	if (err) {
+		/*
+		 * This is a normal condition for optional consoles: they might not be
+		 * present on xenstore at all. In that case, just return without error.
+		*/
+		if (con->optional)
+			err = 0;
+
 		goto out;
+	}
 
 	snprintf(path, sizeof(path), "%s/type", con->xspath);
 	type = xs_read(xs, XBT_NULL, path, NULL);
@@ -665,7 +689,9 @@ static int console_create_ring(struct console *con)
 	if (ring_ref != con->ring_ref && con->ring_ref != -1)
 		console_unmap_interface(con);
 
-	if (!con->interface && xgt_handle) {
+	if (!con->interface &&
+	    xgt_handle &&
+	    con->use_gnttab) {
 		/* Prefer using grant table */
 		con->interface = xengnttab_map_grant_ref(xgt_handle,
 			dom->domid, GNTTAB_RESERVED_CONSOLE,
@@ -784,6 +810,8 @@ static int console_init(struct console *con, struct domain *dom, void **data)
 	con->d = dom;
 	con->ttyname = (*con_data)->ttyname;
 	con->log_suffix = (*con_data)->log_suffix;
+	con->optional = (*con_data)->optional;
+	con->use_gnttab = (*con_data)->use_gnttab;
 	xsname = (char *)(*con_data)->xsname;
 	xspath = xs_get_domain_path(xs, dom->domid);
 	s = realloc(xspath, strlen(xspath) +
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 23/25 v7] xen/arm: vpl011: Add a new vuart console type to xenconsole client
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (21 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 22/25 v7] xen/arm: vpl011: Add support for vuart console " Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-07  8:53 ` [PATCH 24/25 v7] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree Bhupinder Thakur
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

Add a new console type VUART to connect to guest's emualated vuart
console.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v4:
- Removed the vuart compile time flag so that vuart code is compiled always.

Changes since v3:
- The vuart console support is under CONFIG_VUART_CONSOLE option.
- Since there is a change from last review, I have not included
  reviewed-by tag from Stefano and acked-by tag from Wei.

 tools/console/client/main.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/console/client/main.c b/tools/console/client/main.c
index c340cb7..f92ad3d 100644
--- a/tools/console/client/main.c
+++ b/tools/console/client/main.c
@@ -76,7 +76,7 @@ static void usage(const char *program) {
 	       "\n"
 	       "  -h, --help       display this help and exit\n"
 	       "  -n, --num N      use console number N\n"
-	       "  --type TYPE      console type. must be 'pv' or 'serial'\n"
+	       "  --type TYPE      console type. must be 'pv', 'serial' or 'vuart'\n"
 	       "  --start-notify-fd N file descriptor used to notify parent\n"
 	       , program);
 }
@@ -264,6 +264,7 @@ typedef enum {
        CONSOLE_INVAL,
        CONSOLE_PV,
        CONSOLE_SERIAL,
+       CONSOLE_VUART,
 } console_type;
 
 static struct termios stdin_old_attr;
@@ -344,6 +345,7 @@ int main(int argc, char **argv)
 	char *end;
 	console_type type = CONSOLE_INVAL;
 	bool interactive = 0;
+	char *console_names = "serial, pv, vuart";
 
 	while((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
 		switch(ch) {
@@ -359,9 +361,12 @@ int main(int argc, char **argv)
 				type = CONSOLE_SERIAL;
 			else if (!strcmp(optarg, "pv"))
 				type = CONSOLE_PV;
+			else if (!strcmp(optarg, "vuart"))
+				type = CONSOLE_VUART;
 			else {
 				fprintf(stderr, "Invalid type argument\n");
-				fprintf(stderr, "Console types supported are: serial, pv\n");
+				fprintf(stderr, "Console types supported are: %s\n",
+					console_names);
 				exit(EINVAL);
 			}
 			break;
@@ -437,6 +442,10 @@ int main(int argc, char **argv)
 		else
 			snprintf(path, strlen(dom_path) + strlen("/device/console/%d/tty") + 5, "%s/device/console/%d/tty", dom_path, num);
 	}
+	if (type == CONSOLE_VUART) {
+		snprintf(path, strlen(dom_path) + strlen("/vuart/0/tty") + 1,
+			 "%s/vuart/0/tty", dom_path);
+	}
 
 	/* FIXME consoled currently does not assume domain-0 doesn't have a
 	   console which is good when we break domain-0 up.  To keep us
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 24/25 v7] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (22 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 23/25 v7] xen/arm: vpl011: Add a new vuart console type to xenconsole client Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 14:12   ` Julien Grall
  2017-08-07  8:53 ` [PATCH 25/25 v7] xen/arm: vpl011: Update documentation for vuart console support Bhupinder Thakur
  2017-08-08 15:59 ` [PATCH 00/25 v7] SBSA UART emulation support in Xen Julien Grall
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

The SBSA UART node format is as specified in
Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt and given below:

ARM SBSA defined generic UART
------------------------------
This UART uses a subset of the PL011 registers and consequently lives
in the PL011 driver. It's baudrate and other communication parameters
cannot be adjusted at runtime, so it lacks a clock specifier here.

Required properties:
- compatible: must be "arm,sbsa-uart"
- reg: exactly one register range
- interrupts: exactly one interrupt specifier
- current-speed: the (fixed) baud rate set by the firmware

Currently the baud rate of 115200 has been selected as a default value,
which is one of the valid baud rate settings. Higher baud rate was
selected since an emulated pl011 can support any valid baud rate without
any limitation of the hardware.

A check is added to ensure that user specified irq does not conflict with 
the SPI assgined to vpl011. If there is a conflict then it flags an error.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v6:
- Added a comment explaining why user specified IRQ should not conflict with vpl011
  SPI.
- Checking the vuart type explicitly against vpl011 enum type.
- Removed uart-compat string and using "arm,sbsa-uart" string directly.
- I have retained the reviewed-by/acked-by tags as these are minor changes.

 tools/libxl/libxl_arm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index a33d3c9..6629852 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -43,11 +43,29 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
 {
     uint32_t nr_spis = 0;
     unsigned int i;
+    uint32_t vuart_irq = 0;
+
+    /*
+     * If pl011 vuart is enabled then increment the nr_spis to allow allocation
+     * of SPI VIRQ for pl011.
+     */
+    if (d_config->b_info.arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) {
+        nr_spis += (GUEST_VPL011_SPI - 32) + 1;
+        vuart_irq = GUEST_VPL011_SPI;
+    }
 
     for (i = 0; i < d_config->b_info.num_irqs; i++) {
         uint32_t irq = d_config->b_info.irqs[i];
         uint32_t spi;
 
+        /*
+         * The user specified irq should not conflict with the vpl011 irq.
+         */
+        if (irq == vuart_irq) {
+            LOG(ERROR, "Physical IRQ %u conflicting with pl011 SPI\n", irq);
+            return ERROR_FAIL;
+        }
+
         if (irq < 32)
             continue;
 
@@ -590,6 +608,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)
+{
+    int res;
+    gic_interrupt intr;
+
+    res = fdt_begin_node(fdt, "sbsa-pl011");
+    if (res) return res;
+
+    res = fdt_property_compat(gc, fdt, 1, "arm,sbsa-uart");
+    if (res) return res;
+
+    res = fdt_property_regs(gc, fdt, ROOT_ADDRESS_CELLS, ROOT_SIZE_CELLS,
+                            1,
+                            GUEST_PL011_BASE, GUEST_PL011_SIZE);
+    if (res) return res;
+
+    set_interrupt(intr, GUEST_VPL011_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH);
+
+    res = fdt_property_interrupts(gc, fdt, &intr, 1);
+    if (res) return res;
+
+    /* Use a default baud rate of 115200. */
+    fdt_property_u32(fdt, "current-speed", 115200);
+
+    res = fdt_end_node(fdt);
+    if (res) return res;
+
+    return 0;
+}
+
 static const struct arch_info *get_arch_info(libxl__gc *gc,
                                              const struct xc_dom_image *dom)
 {
@@ -889,6 +939,9 @@ next_resize:
         FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) );
         FDT( make_hypervisor_node(gc, fdt, vers) );
 
+        if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART)
+            FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) );
+
         if (pfdt)
             FDT( copy_partial_fdt(gc, fdt, pfdt) );
 
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 25/25 v7] xen/arm: vpl011: Update documentation for vuart console support
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (23 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 24/25 v7] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree Bhupinder Thakur
@ 2017-08-07  8:53 ` Bhupinder Thakur
  2017-08-08 14:15   ` Julien Grall
  2017-08-08 15:59 ` [PATCH 00/25 v7] SBSA UART emulation support in Xen Julien Grall
  25 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-07  8:53 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, Jan Beulich

1. Update documentation for a new vuart option added.
2. Update documentation about SPI irq reserved for vuart.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---

CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Tim Deegan <tim@xen.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v6:
- Added a new section for vuart usage.
- I have retained the reviewed-by/acked-by tags as this is a limited change. Kindly
  review.

Changes since v4:
- Minor change to rename "pl011" to "sbsa_uart". Since it is a minor change I have
  retained the reviewed-by and acked-by tags.

 docs/man/xl.cfg.pod.5.in | 12 ++++++++++++
 docs/misc/console.txt    | 44 +++++++++++++++++++++++++++++++++-----------
 2 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 79cb2ea..8a38cf7 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1105,6 +1105,9 @@ Allow a guest to access specific physical IRQs.
 It is recommended to only use this option for trusted VMs under
 administrator's control.
 
+If vuart console is enabled then irq 32 is reserved for it. See
+L</vuart="uart"> to know how to enable vuart console.
+
 =item B<max_event_channels=N>
 
 Limit the guest to using at most N event channels (PV interrupts).
@@ -2171,6 +2174,15 @@ the domain was created.
 This requires hardware compatibility with the requested version, either
 natively or via hardware backwards compatibility support.
 
+=item B<vuart="uart">
+
+To enable vuart console, user must specify the following option in the
+VM config file:
+
+vuart = "sbsa_uart"
+
+Currently, only the "sbsa_uart" model is supported for AArch32 and AARCH64.
+
 =back
 
 =head3 x86
diff --git a/docs/misc/console.txt b/docs/misc/console.txt
index 16da805..d081acc 100644
--- a/docs/misc/console.txt
+++ b/docs/misc/console.txt
@@ -19,7 +19,20 @@ The first PV console path in xenstore remains:
 
 /local/domain/$DOMID/console
 
-the other PV consoles follow the conventional xenstore device path and
+The virtual UART console path in xenstore is defined as:
+
+/local/domain/$DOMID/vuart/0
+
+The vuart console provides access to a virtual SBSA UART on ARM64 systems.
+To enable vuart the following line has to be added to the guest configuration
+file:
+
+vuart = "sbsa_uart"
+
+In Linux you can select the virtual SBSA UART by using the "ttyAMA0"
+console instead of "hvc0".
+
+The other PV consoles follow the conventional xenstore device path and
 live in:
 
 /local/domain/$DOMID/device/console/$DEVID.
@@ -61,6 +74,14 @@ output = pty
 The backend will write the pty device name to the "tty" node in the
 console frontend.
 
+For the PV console the tty node is added at
+
+/local/domain/$DOMID/console/tty
+
+For the virtual UART console the tty node is added at
+
+/local/domain/$DOMID/vuart/0/tty
+
 If the toolstack wants a listening Unix domain socket to be created at path
 <path>, a connection accepted and data proxied to the console, it will write:
 
@@ -79,8 +100,8 @@ For example:
 ioemu
 
 The supported values are only xenconsoled or ioemu; xenconsoled has
-several limitations: it can only be used for the first PV console and it
-can only connect to a pty.
+several limitations: it can only be used for the first PV or virtual UART
+console and it can only connect to a pty.
 
 Emulated serials are provided by qemu-dm only to hvm guests; the number
 of emulated serials depends on how many "-serial" command line options
@@ -90,14 +111,15 @@ xenstore in the following path:
 
 /local/domain/$DOMID/serial/$SERIAL_NUM/tty
 
-xenconsole is the tool to connect to a PV console or an emulated serial
-that has a pty as output. Xenconsole takes a domid as parameter plus an
-optional console type (pv for PV consoles or serial for emulated
-serials) and console number. Depending on the type and console
-number, xenconsole will look for the tty node in different xenstore
-paths, as described above.  If the user doesn't specify the console type
-xenconsole will try to guess: if the guest is a pv guest it defaults to
-PV console, if the guest is an hvm guest it defaults to emulated serial.
+xenconsole is the tool to connect to a PV or virtual UART console or an
+emulated serial that has a pty as output. Xenconsole takes a domid as
+parameter plus an optional console type (pv for PV consoles, vuart for
+virtual UART or serial for emulated serials) and console number.
+Depending on the type and console number, xenconsole will look for the tty
+node in different xenstore paths, as described above.  If the user doesn't
+specify the console type xenconsole will try to guess: if the guest is a pv
+guest it defaults to PV console, if the guest is an hvm guest it defaults to
+emulated serial.
 
 By default xl creates a pv console for hvm guests, plus an emulated
 serial if the user specified 'serial = "pty"' in the VM config file.
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* Re: [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011
  2017-08-07  8:52 ` [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011 Bhupinder Thakur
@ 2017-08-07  9:14   ` Jan Beulich
  2017-08-21 10:28     ` Bhupinder Thakur
  2017-08-08 13:11   ` Wei Liu
  2017-08-08 13:56   ` Julien Grall
  2 siblings, 1 reply; 67+ messages in thread
From: Jan Beulich @ 2017-08-07  9:14 UTC (permalink / raw)
  To: bhupinder.thakur
  Cc: sstabellini, wei.liu2, George.Dunlap, andrew.cooper3,
	ian.jackson, tim, julien.grall, xen-devel

>>> Bhupinder Thakur <bhupinder.thakur@linaro.org> 08/07/17 10:55 AM >>>
>@@ -1148,6 +1149,24 @@ struct xen_domctl_psr_cat_op {
>uint32_t target;    /* IN */
>uint64_t data;      /* IN/OUT */
>};
>+
>+struct xen_domctl_vuart_op {
>+#define XEN_DOMCTL_VUART_OP_INIT  0
>+        uint32_t cmd;           /* XEN_DOMCTL_VUART_OP_* */
>+        domid_t console_domid;  /* IN */
>+#define XEN_DOMCTL_VUART_TYPE_VPL011 0
>+        uint32_t type;          /* IN - type of vuart.
>+                                 *      Currently only vpl011 supported.
>+                                 */
>+        xen_pfn_t gfn;          /* IN - guest gfn to be used as a
>+                                 *      ring buffer.
>+                                 */
>+        evtchn_port_t evtchn;   /* OUT - remote port of the event
>+                                 *       channel used for sending
>+                                 *       ring buffer events.
>+                                 */
>+};

Please try to limit the amount of padding needed and make all remaining
padding fields explicit. That should then also make obvious that using
xen_pfn_t in domctl.h is not a good idea (the existing uses are bogus too
afaict - in the getpageframeinfo3 case the handler deals with the differing
width between 32- and 64-bit callers, and the cacheflush one is fine right
now only because it's ARM-only).

Jan


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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 11/25 v7] xen/arm: vpl011: Add a new console_init function in xenconsole
  2017-08-07  8:53 ` [PATCH 11/25 v7] xen/arm: vpl011: Add a new console_init function in xenconsole Bhupinder Thakur
@ 2017-08-08 13:11   ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:11 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Mon, Aug 07, 2017 at 02:23:03PM +0530, Bhupinder Thakur wrote:
[...]
> +static void console_free(struct console *con)
> +{
> +	if (con->xspath)

Pointless check here.

With this fixed:

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011
  2017-08-07  8:52 ` [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011 Bhupinder Thakur
  2017-08-07  9:14   ` Jan Beulich
@ 2017-08-08 13:11   ` Wei Liu
  2017-08-08 13:30     ` Wei Liu
  2017-08-08 13:56   ` Julien Grall
  2 siblings, 1 reply; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:11 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, Jan Beulich, xen-devel

On Mon, Aug 07, 2017 at 02:22:58PM +0530, Bhupinder Thakur wrote:
> Add a new domctl API to initialize vpl011. It takes the GFN and console
> backend domid as input and returns an event channel to be used for
> sending and receiving events from Xen.
> 
> Xen will communicate with xenconsole using GFN as the ring buffer and
> the event channel to transmit and receive pl011 data on the guest domain's
> behalf.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> ---
[...]
> diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
> index 3bab4e8..899bbd4 100644
> --- a/tools/libxc/xc_domain.c
> +++ b/tools/libxc/xc_domain.c
> @@ -343,6 +343,31 @@ int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid,
>      return 0;
>  }
>  
> +int xc_dom_vuart_init(xc_interface *xch,
> +                      uint32_t type,
> +                      domid_t domid,
> +                      domid_t console_domid,
> +                      xen_pfn_t gfn,
> +                      evtchn_port_t *evtchn)
> +{
> +    DECLARE_DOMCTL;
> +    int rc = 0;
> +
> +    domctl.cmd = XEN_DOMCTL_vuart_op;
> +    domctl.domain = (domid_t)domid;

The cast is pointless.

> +    domctl.u.vuart_op.cmd = XEN_DOMCTL_VUART_OP_INIT;
> +    domctl.u.vuart_op.type = type;
> +    domctl.u.vuart_op.console_domid = console_domid;
> +    domctl.u.vuart_op.gfn = gfn;
> +
> +    if ( (rc = do_domctl(xch, &domctl)) < 0 )
> +        return rc;
> +
> +    *evtchn = domctl.u.vuart_op.evtchn;
> +
> +    return rc;
> +}
> +
[...]
>  
> +int libxl__arch_build_dom_finish(libxl__gc *gc,
> +                                 libxl_domain_build_info *info,
> +                                 struct xc_dom_image *dom,
> +                                 libxl__domain_build_state *state)
> +{
> +    int ret = 0;

int rc = 0;

> +
> +    if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) {
> +        ret = xc_dom_vuart_init(CTX->xch,
> +                                XEN_DOMCTL_VUART_TYPE_VPL011,
> +                                dom->guest_domid,
> +                                dom->console_domid,
> +                                dom->vuart_gfn,
> +                                &state->vuart_port);
> +        if (ret < 0)

rc = ERROR_FAIL;

> +            LOG(ERROR, "xc_dom_vuart_init failed\n");
> +    }
> +
> +    return ret;

return rc;

For reasons, see libxl/CODING_STYLE.

> +}
> +
[...]
>                                        uint32_t domid,
> diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
> index db6838d..c7f650e 100644
> --- a/xen/arch/arm/domctl.c
> +++ b/xen/arch/arm/domctl.c
> @@ -5,9 +5,11 @@
>   */
>  
>  #include <xen/errno.h>
> +#include <xen/guest_access.h>
>  #include <xen/hypercall.h>
>  #include <xen/iocap.h>
>  #include <xen/lib.h>
> +#include <xen/mm.h>
>  #include <xen/sched.h>
>  #include <xen/types.h>
>  #include <xsm/xsm.h>
> @@ -119,6 +121,46 @@ long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
>          d->disable_migrate = domctl->u.disable_migrate.disable;
>          return 0;
>  
> +    case XEN_DOMCTL_vuart_op:
> +    {
> +        int rc;
> +        struct xen_domctl_vuart_op *vuart_op = &domctl->u.vuart_op;
> +
> +        switch(vuart_op->cmd)

Coding style.

> +        {
> +        case XEN_DOMCTL_VUART_OP_INIT:
> +
> +            if ( !d->creation_finished )
> +            {
> +                if (vuart_op->type == XEN_DOMCTL_VUART_TYPE_VPL011)
> +                {
> +                        struct vpl011_init_info info;
> +
> +                        info.console_domid = vuart_op->console_domid;
> +                        info.gfn = _gfn(vuart_op->gfn);
> +
> +                        rc = domain_vpl011_init(d, &info);
> +                        if ( !rc )
> +                        {
> +                            vuart_op->evtchn = info.evtchn;
> +                            rc = __copy_to_guest(u_domctl, domctl, 1);
> +                        }
> +                }
> +                else
> +                        rc = -EINVAL;

Indentation.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 13/25 v7] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd function in xenconsole
  2017-08-07  8:53 ` [PATCH 13/25 v7] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd " Bhupinder Thakur
@ 2017-08-08 13:12   ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:12 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Mon, Aug 07, 2017 at 02:23:05PM +0530, Bhupinder Thakur wrote:
> This patch introduces a new maybe_add_console_evtchn_fd function. This
> function adds the console event channel FD to list of polled FDs.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 14/25 v7] xen/arm: vpl011: Add a new maybe_add_console_tty_fd function in xenconsole
  2017-08-07  8:53 ` [PATCH 14/25 v7] xen/arm: vpl011: Add a new maybe_add_console_tty_fd " Bhupinder Thakur
@ 2017-08-08 13:12   ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:12 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Mon, Aug 07, 2017 at 02:23:06PM +0530, Bhupinder Thakur wrote:
> This patch introduces a new maybe_add_console_tty_fd function. This function
> adds the tty fd to the list of polled fds.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 15/25 v7] xen/arm: vpl011: Add a new console_evtchn_unmask function in xenconsole
  2017-08-07  8:53 ` [PATCH 15/25 v7] xen/arm: vpl011: Add a new console_evtchn_unmask " Bhupinder Thakur
@ 2017-08-08 13:15   ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:15 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Mon, Aug 07, 2017 at 02:23:07PM +0530, Bhupinder Thakur wrote:
> This patch introduces a new console_evtchn_unmask function. This function
> unmasks the console event channel if it is masked for some timeout
> period.
> 
> One optimization that has been done is to merge the two 'for' loops.
> 
> One 'for' loop was used to iterate through all domains and
> unmask the domain event channels which had been rate limited for a
> specified duration.
> 
> The other 'for' loop was run to add the event channel fd and the tty fd to
> the poll list.
> 
> These two 'for' loops were merged so that the these operations can be done
> in one iteration instead of two iterations.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 16/25 v7] xen/arm: vpl011: Add a new handle_console_ring function in xenconsole
  2017-08-07  8:53 ` [PATCH 16/25 v7] xen/arm: vpl011: Add a new handle_console_ring " Bhupinder Thakur
@ 2017-08-08 13:16   ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:16 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Mon, Aug 07, 2017 at 02:23:08PM +0530, Bhupinder Thakur wrote:
> This patch introduces a new handle_console_ring function. This function
> reads the data from the ring buffer on receiving an event.
> 
> The initialization of event channel poll fd to -1 is moved inside the
> handle_console_ring function as they are related. There should be no
> change in the behavior as there is no functional change.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 18/25 v7] xen/arm: vpl011: Add a new console_cleanup function in xenconsole
  2017-08-07  8:53 ` [PATCH 18/25 v7] xen/arm: vpl011: Add a new console_cleanup " Bhupinder Thakur
@ 2017-08-08 13:29   ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:29 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Mon, Aug 07, 2017 at 02:23:10PM +0530, Bhupinder Thakur wrote:
> This patch introduces a new console_cleanup function. This function
> frees up the console resources.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011
  2017-08-08 13:11   ` Wei Liu
@ 2017-08-08 13:30     ` Wei Liu
  2017-08-08 13:47       ` Julien Grall
  0 siblings, 1 reply; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:30 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, Jan Beulich, xen-devel

On Tue, Aug 08, 2017 at 02:11:08PM +0100, Wei Liu wrote:
> > +                else
> > +                        rc = -EINVAL;
> 
> Indentation.

Ignore this please.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 19/25 v7] xen/arm: vpl011: Add a new console_open_log function in xenconsole
  2017-08-07  8:53 ` [PATCH 19/25 v7] xen/arm: vpl011: Add a new console_open_log " Bhupinder Thakur
@ 2017-08-08 13:31   ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:31 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Mon, Aug 07, 2017 at 02:23:11PM +0530, Bhupinder Thakur wrote:
> This patch introduces a console_open_log console_cleanup function. This function
> opens the console log file.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 04/25 v7] xen/arm: vpl011: Add support for vuart in libxl
  2017-08-07  8:52 ` [PATCH 04/25 v7] xen/arm: vpl011: Add support for vuart in libxl Bhupinder Thakur
@ 2017-08-08 13:38   ` Julien Grall
  2017-08-08 13:42     ` Julien Grall
  0 siblings, 1 reply; 67+ messages in thread
From: Julien Grall @ 2017-08-08 13:38 UTC (permalink / raw)
  To: Bhupinder Thakur, xen-devel; +Cc: Wei Liu, Stefano Stabellini, Ian Jackson

Hi Bhupinder,

On 07/08/17 09:52, Bhupinder Thakur wrote:
> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index 229e289..90eaa20 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -306,6 +306,11 @@
>  #define LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE 1
>
>  /*
> + * LIBXL_HAVE_VUART indicates that the toolstack supports virtual UART.
> + */
> +#define LIBXL_HAVE_VUART 1

Now that we decide to implement vUART only for ARM, I think the comment 
I made on v1 still stands. I.e that you give the impression this is 
supported for all architectures. But this is not true.

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 04/25 v7] xen/arm: vpl011: Add support for vuart in libxl
  2017-08-08 13:38   ` Julien Grall
@ 2017-08-08 13:42     ` Julien Grall
  0 siblings, 0 replies; 67+ messages in thread
From: Julien Grall @ 2017-08-08 13:42 UTC (permalink / raw)
  To: Bhupinder Thakur, xen-devel; +Cc: Wei Liu, Stefano Stabellini, Ian Jackson



On 08/08/17 14:38, Julien Grall wrote:
> Hi Bhupinder,
>
> On 07/08/17 09:52, Bhupinder Thakur wrote:
>> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
>> index 229e289..90eaa20 100644
>> --- a/tools/libxl/libxl.h
>> +++ b/tools/libxl/libxl.h
>> @@ -306,6 +306,11 @@
>>  #define LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE 1
>>
>>  /*
>> + * LIBXL_HAVE_VUART indicates that the toolstack supports virtual UART.
>> + */
>> +#define LIBXL_HAVE_VUART 1
>
> Now that we decide to implement vUART only for ARM, I think the comment
> I made on v1 still stands. I.e that you give the impression this is
> supported for all architectures. But this is not true.

To complete, I would follow what we did for gic_version:

LIBXL_HAVE_BUILDINFO_ARM_VUART


-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011
  2017-08-08 13:30     ` Wei Liu
@ 2017-08-08 13:47       ` Julien Grall
  0 siblings, 0 replies; 67+ messages in thread
From: Julien Grall @ 2017-08-08 13:47 UTC (permalink / raw)
  To: Wei Liu, Bhupinder Thakur
  Cc: Stefano Stabellini, George Dunlap, Andrew Cooper, Ian Jackson,
	Tim Deegan, Jan Beulich, xen-devel

Hi,

On 08/08/17 14:30, Wei Liu wrote:
> On Tue, Aug 08, 2017 at 02:11:08PM +0100, Wei Liu wrote:
>>> +                else
>>> +                        rc = -EINVAL;
>>
>> Indentation.
>
> Ignore this please.

You were right, the indentation is wrong :). It is 8 spaces rather than 4.

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 21/25 v7] xen/arm: vpl011: Add support for multiple consoles in xenconsole
  2017-08-07  8:53 ` [PATCH 21/25 v7] xen/arm: vpl011: Add support for multiple consoles " Bhupinder Thakur
@ 2017-08-08 13:48   ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:48 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Mon, Aug 07, 2017 at 02:23:13PM +0530, Bhupinder Thakur wrote:
> This patch adds the support for multiple consoles and introduces the
> iterator functions to operate on multiple consoles.
> 

Please check all the functions called by the iterator functions to make
sure they have properly guarded against partially constructed states and
uninitialised states. If they don't have such property, they need to be
changed before this patch. If they already have such property, say so in
the commit message.

And some comments below.

> This patch is in preparation to support a new vuart console.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> ---
> CC: Ian Jackson <ian.jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>
> 
> Changes since v5:
> - Split this patch in multiple smaller patches.
> 
> Changes since v4:
> - Changes to make event channel handling per console rather than per domain.
> 
> Changes since v3:
> - The changes in xenconsole have been split into four patches. This is the third patch.
> 
>  tools/console/daemon/io.c | 156 ++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 122 insertions(+), 34 deletions(-)
> 
> diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
> index 71465a0..f60312d 100644
> --- a/tools/console/daemon/io.c
> +++ b/tools/console/daemon/io.c
> @@ -90,12 +90,14 @@ struct buffer {
>  };
>  
>  struct console {
> +	char *ttyname;
>  	int master_fd;
>  	int master_pollfd_idx;
>  	int slave_fd;
>  	int log_fd;
>  	struct buffer buffer;
>  	char *xspath;
> +	char *log_suffix;
>  	int ring_ref;
>  	xenevtchn_handle *xce_handle;
>  	int xce_pollfd_idx;
> @@ -107,21 +109,107 @@ struct console {
>  	struct domain *d;
>  };
>  
> +struct console_data {

console_type?

> +	char *xsname;
> +	char *ttyname;
> +	char *log_suffix;
> +};
> +
> +static struct console_data console_data[] = {
> +	{
> +		.xsname = "/console",
> +		.ttyname = "tty",
> +		.log_suffix = "",
> +	},
> +};
> +
> +#define MAX_CONSOLE (sizeof(console_data)/sizeof(struct console_data))

NUM_CONSOLE_TYPE?

I think we can already have multiple PV consoles, so the original name
you proposed is confusing.

> +
>  struct domain {
>  	int domid;
>  	bool is_dead;
>  	unsigned last_seen;
>  	struct domain *next;
> -	struct console console;
> +	struct console console[MAX_CONSOLE];
>  };
>  
>  static struct domain *dom_head;
>  
> +typedef void (*VOID_ITER_FUNC_ARG1)(struct console *);
> +typedef bool (*BOOL_ITER_FUNC_ARG1)(struct console *);
> +typedef int (*INT_ITER_FUNC_ARG1)(struct console *);
> +typedef void (*VOID_ITER_FUNC_ARG2)(struct console *,  void *);
> +typedef int (*INT_ITER_FUNC_ARG3)(struct console *,
> +				  struct domain *dom, void **);
> +
>  static inline bool console_enabled(struct console *con)
>  {
>  	return con->local_port != -1;
>  }
>  
> +static inline void console_iter_void_arg1(struct domain *d,
> +					  VOID_ITER_FUNC_ARG1 iter_func)
> +{
> +	int i = 0;

unsigned int here and in other functions.

> +	struct console *con = &d->console[0];
> +
> +	for (i = 0; i < MAX_CONSOLE; i++, con++) {
> +		iter_func(con);
> +	}
> +}
> +
[...]
> +
> +static inline int console_iter_int_arg1(struct domain *d,
> +					INT_ITER_FUNC_ARG1 iter_func)
> +{
> +	int i = 0;
> +	struct console *con = &d->console[0];
> +
> +	for (i = 0; i < MAX_CONSOLE; i++, con++) {
> +		if (iter_func(con))
> +			return 1;

Do you maybe want to return the return value of your iterator function?
Otherwise I don't see a point for this function to return int -- using
bool is fine.

And please document what return value means what.

> +	}
> +	return 0;
> +}
> +
> +static inline int console_iter_int_arg3(struct domain *d,
> +					INT_ITER_FUNC_ARG3 iter_func,
> +					void **iter_data)
> +{
> +	int i = 0;
> +	struct console *con = &d->console[0];
> +
> +	for (i = 0; i < MAX_CONSOLE; i++, con++) {
> +		if (iter_func(con, d, iter_data))
> +			return 1;
> +	}
> +	return 0;
> +}
> +
>  static int write_all(int fd, const char* buf, size_t len)
>  {
>  	while (len) {
> @@ -336,7 +424,7 @@ static int create_console_log(struct console *con)
>  		return -1;
>  	}
>  
> -	snprintf(logfile, PATH_MAX-1, "%s/guest-%s.log", log_dir, data);
> +	snprintf(logfile, PATH_MAX-1, "%s/guest-%s%s.log", log_dir, data, con->log_suffix);

Line too long.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 22/25 v7] xen/arm: vpl011: Add support for vuart console in xenconsole
  2017-08-07  8:53 ` [PATCH 22/25 v7] xen/arm: vpl011: Add support for vuart console " Bhupinder Thakur
@ 2017-08-08 13:52   ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-08 13:52 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, Jan Beulich, xen-devel

On Mon, Aug 07, 2017 at 02:23:14PM +0530, Bhupinder Thakur wrote:
> This patch finally adds the support for vuart console. It adds
> two new fields in the console initialization:
> 
> - optional
> - use_gnttab
> 
> optional flag tells whether the console is optional.
> 
> use_gnttab tells whether the ring buffer should be allocated using
> grant table.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

> @@ -665,7 +689,9 @@ static int console_create_ring(struct console *con)
>  	if (ring_ref != con->ring_ref && con->ring_ref != -1)
>  		console_unmap_interface(con);
>  
> -	if (!con->interface && xgt_handle) {
> +	if (!con->interface &&
> +	    xgt_handle &&
> +	    con->use_gnttab) {

You can join all these to one line.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011
  2017-08-07  8:52 ` [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011 Bhupinder Thakur
  2017-08-07  9:14   ` Jan Beulich
  2017-08-08 13:11   ` Wei Liu
@ 2017-08-08 13:56   ` Julien Grall
  2 siblings, 0 replies; 67+ messages in thread
From: Julien Grall @ 2017-08-08 13:56 UTC (permalink / raw)
  To: Bhupinder Thakur, xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich

Hi Bhupinder,

On 07/08/17 09:52, Bhupinder Thakur wrote:
> diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
> index 5e1fc60..784ec7f 100644
> --- a/tools/libxl/libxl_arch.h
> +++ b/tools/libxl/libxl_arch.h
> @@ -44,6 +44,13 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
>                                        libxl_domain_build_info *info,
>                                        struct xc_dom_image *dom);
>
> +/* perform any pending hardware initialization */
> +_hidden
> +int libxl__arch_build_dom_finish(libxl__gc *gc,
> +                                 libxl_domain_build_info *info,
> +                                 struct xc_dom_image *dom,
> +                                 libxl__domain_build_state *state);
> +
>  /* build vNUMA vmemrange with arch specific information */
>  _hidden
>  int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc,
> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> index d842d88..a33d3c9 100644
> --- a/tools/libxl/libxl_arm.c
> +++ b/tools/libxl/libxl_arm.c
> @@ -1038,6 +1038,27 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
>      return 0;
>  }
>
> +int libxl__arch_build_dom_finish(libxl__gc *gc,
> +                                 libxl_domain_build_info *info,
> +                                 struct xc_dom_image *dom,
> +                                 libxl__domain_build_state *state)
> +{
> +    int ret = 0;
> +
> +    if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) {

NIT: You could avoid on level of indentation if you do:

if ( info->arch_arm.vuart != LIBXL_VUART_TYPE_SBSA_UART )
   return 0;

....

> +        ret = xc_dom_vuart_init(CTX->xch,
> +                                XEN_DOMCTL_VUART_TYPE_VPL011,
> +                                dom->guest_domid,
> +                                dom->console_domid,
> +                                dom->vuart_gfn,
> +                                &state->vuart_port);
> +        if (ret < 0)
> +            LOG(ERROR, "xc_dom_vuart_init failed\n");
> +    }
> +
> +    return ret;
> +}
> +
>  int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc,
>                                        uint32_t domid,
>                                        libxl_domain_build_info *info,

[...]

> diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
> index db6838d..c7f650e 100644
> --- a/xen/arch/arm/domctl.c
> +++ b/xen/arch/arm/domctl.c
> @@ -5,9 +5,11 @@
>   */
>
>  #include <xen/errno.h>
> +#include <xen/guest_access.h>
>  #include <xen/hypercall.h>
>  #include <xen/iocap.h>
>  #include <xen/lib.h>
> +#include <xen/mm.h>
>  #include <xen/sched.h>
>  #include <xen/types.h>
>  #include <xsm/xsm.h>
> @@ -119,6 +121,46 @@ long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
>          d->disable_migrate = domctl->u.disable_migrate.disable;
>          return 0;
>
> +    case XEN_DOMCTL_vuart_op:
> +    {
> +        int rc;
> +        struct xen_domctl_vuart_op *vuart_op = &domctl->u.vuart_op;
> +
> +        switch(vuart_op->cmd)
> +        {
> +        case XEN_DOMCTL_VUART_OP_INIT:
> +
> +            if ( !d->creation_finished )
> +            {
> +                if (vuart_op->type == XEN_DOMCTL_VUART_TYPE_VPL011)

Coding style.

> +                {
> +                        struct vpl011_init_info info;

The indentation is wrong.

> +
> +                        info.console_domid = vuart_op->console_domid;
> +                        info.gfn = _gfn(vuart_op->gfn);
> +
> +                        rc = domain_vpl011_init(d, &info);
> +                        if ( !rc )
> +                        {
> +                            vuart_op->evtchn = info.evtchn;
> +                            rc = __copy_to_guest(u_domctl, domctl, 1);
> +                        }
> +                }
> +                else
> +                        rc = -EINVAL;

I think this one should be -EOPNOTSUPP.

> +            }
> +            else
> +                rc = - EPERM;

Can we please avoid the number of nested if? Maybe by introducing a 
function to handle the domctl.

> +
> +            break;
> +
> +        default:
> +            rc = -EINVAL;

Same here.

> +            break;
> +        }
> +
> +        return rc;
> +    }
>      default:
>      {
>          int rc;

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 24/25 v7] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree
  2017-08-07  8:53 ` [PATCH 24/25 v7] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree Bhupinder Thakur
@ 2017-08-08 14:12   ` Julien Grall
  2017-08-08 14:53     ` Bhupinder Thakur
  0 siblings, 1 reply; 67+ messages in thread
From: Julien Grall @ 2017-08-08 14:12 UTC (permalink / raw)
  To: Bhupinder Thakur, xen-devel; +Cc: Wei Liu, Stefano Stabellini, Ian Jackson



On 07/08/17 09:53, Bhupinder Thakur wrote:
> The SBSA UART node format is as specified in
> Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt and given below:
>
> ARM SBSA defined generic UART
> ------------------------------
> This UART uses a subset of the PL011 registers and consequently lives
> in the PL011 driver. It's baudrate and other communication parameters
> cannot be adjusted at runtime, so it lacks a clock specifier here.
>
> Required properties:
> - compatible: must be "arm,sbsa-uart"
> - reg: exactly one register range
> - interrupts: exactly one interrupt specifier
> - current-speed: the (fixed) baud rate set by the firmware
>
> Currently the baud rate of 115200 has been selected as a default value,
> which is one of the valid baud rate settings. Higher baud rate was
> selected since an emulated pl011 can support any valid baud rate without
> any limitation of the hardware.
>
> A check is added to ensure that user specified irq does not conflict with
> the SPI assgined to vpl011. If there is a conflict then it flags an error.
>
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> Acked-by: Wei Liu <wei.liu2@citrix.com>
> ---
> CC: Ian Jackson <ian.jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>
>
> Changes since v6:
> - Added a comment explaining why user specified IRQ should not conflict with vpl011
>   SPI.
> - Checking the vuart type explicitly against vpl011 enum type.
> - Removed uart-compat string and using "arm,sbsa-uart" string directly.
> - I have retained the reviewed-by/acked-by tags as these are minor changes.
>
>  tools/libxl/libxl_arm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
>
> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> index a33d3c9..6629852 100644
> --- a/tools/libxl/libxl_arm.c
> +++ b/tools/libxl/libxl_arm.c
> @@ -43,11 +43,29 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
>  {
>      uint32_t nr_spis = 0;
>      unsigned int i;
> +    uint32_t vuart_irq = 0;
> +
> +    /*
> +     * If pl011 vuart is enabled then increment the nr_spis to allow allocation
> +     * of SPI VIRQ for pl011.
> +     */
> +    if (d_config->b_info.arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) {
> +        nr_spis += (GUEST_VPL011_SPI - 32) + 1;
> +        vuart_irq = GUEST_VPL011_SPI;
> +    }
>
>      for (i = 0; i < d_config->b_info.num_irqs; i++) {
>          uint32_t irq = d_config->b_info.irqs[i];
>          uint32_t spi;
>
> +        /*
> +         * The user specified irq should not conflict with the vpl011 irq.
> +         */

I am sorry but in the changelog you wrote: "Add a comment explaining why 
user specified IRQ should not conflict with vpl011 SPI". But you still 
don't explain why... And I still don't see the TODO requested on v6.

> +        if (irq == vuart_irq) {

Hmmm if vUART is not enabled you would compare to 0. And I don't think 
we should make this assumption in the code. This would also give a 
random error to the user.

It would be better if you introduce a local boolean vuart_enabled to 
know whether you need to check the conflict.

> +            LOG(ERROR, "Physical IRQ %u conflicting with pl011 SPI\n", irq);
> +            return ERROR_FAIL;
> +        }
> +
>          if (irq < 32)
>              continue;
>
> @@ -590,6 +608,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)
> +{
> +    int res;
> +    gic_interrupt intr;
> +
> +    res = fdt_begin_node(fdt, "sbsa-pl011");
> +    if (res) return res;
> +
> +    res = fdt_property_compat(gc, fdt, 1, "arm,sbsa-uart");
> +    if (res) return res;
> +
> +    res = fdt_property_regs(gc, fdt, ROOT_ADDRESS_CELLS, ROOT_SIZE_CELLS,
> +                            1,
> +                            GUEST_PL011_BASE, GUEST_PL011_SIZE);
> +    if (res) return res;
> +
> +    set_interrupt(intr, GUEST_VPL011_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH);
> +
> +    res = fdt_property_interrupts(gc, fdt, &intr, 1);
> +    if (res) return res;
> +
> +    /* Use a default baud rate of 115200. */
> +    fdt_property_u32(fdt, "current-speed", 115200);
> +
> +    res = fdt_end_node(fdt);
> +    if (res) return res;
> +
> +    return 0;
> +}
> +
>  static const struct arch_info *get_arch_info(libxl__gc *gc,
>                                               const struct xc_dom_image *dom)
>  {
> @@ -889,6 +939,9 @@ next_resize:
>          FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) );
>          FDT( make_hypervisor_node(gc, fdt, vers) );
>
> +        if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART)
> +            FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) );
> +
>          if (pfdt)
>              FDT( copy_partial_fdt(gc, fdt, pfdt) );
>
>

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 25/25 v7] xen/arm: vpl011: Update documentation for vuart console support
  2017-08-07  8:53 ` [PATCH 25/25 v7] xen/arm: vpl011: Update documentation for vuart console support Bhupinder Thakur
@ 2017-08-08 14:15   ` Julien Grall
  0 siblings, 0 replies; 67+ messages in thread
From: Julien Grall @ 2017-08-08 14:15 UTC (permalink / raw)
  To: Bhupinder Thakur, xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich

Hi,

On 07/08/17 09:53, Bhupinder Thakur wrote:
> 1. Update documentation for a new vuart option added.
> 2. Update documentation about SPI irq reserved for vuart.
>
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> Acked-by: Wei Liu <wei.liu2@citrix.com>
> ---
>
> CC: Ian Jackson <ian.jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Andrew Cooper <andrew.cooper3@citrix.com>
> CC: George Dunlap <George.Dunlap@eu.citrix.com>
> CC: Jan Beulich <jbeulich@suse.com>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Tim Deegan <tim@xen.org>
> CC: Julien Grall <julien.grall@arm.com>
>
> Changes since v6:
> - Added a new section for vuart usage.
> - I have retained the reviewed-by/acked-by tags as this is a limited change. Kindly
>   review.
>
> Changes since v4:
> - Minor change to rename "pl011" to "sbsa_uart". Since it is a minor change I have
>   retained the reviewed-by and acked-by tags.
>
>  docs/man/xl.cfg.pod.5.in | 12 ++++++++++++
>  docs/misc/console.txt    | 44 +++++++++++++++++++++++++++++++++-----------
>  2 files changed, 45 insertions(+), 11 deletions(-)
>
> diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
> index 79cb2ea..8a38cf7 100644
> --- a/docs/man/xl.cfg.pod.5.in
> +++ b/docs/man/xl.cfg.pod.5.in
> @@ -1105,6 +1105,9 @@ Allow a guest to access specific physical IRQs.
>  It is recommended to only use this option for trusted VMs under
>  administrator's control.
>
> +If vuart console is enabled then irq 32 is reserved for it. See
> +L</vuart="uart"> to know how to enable vuart console.
> +
>  =item B<max_event_channels=N>
>
>  Limit the guest to using at most N event channels (PV interrupts).
> @@ -2171,6 +2174,15 @@ the domain was created.
>  This requires hardware compatibility with the requested version, either
>  natively or via hardware backwards compatibility support.
>
> +=item B<vuart="uart">
> +
> +To enable vuart console, user must specify the following option in the
> +VM config file:
> +
> +vuart = "sbsa_uart"
> +
> +Currently, only the "sbsa_uart" model is supported for AArch32 and AARCH64.

s/AArch32 and AARCH64/Arm/

> +
>  =back
>
>  =head3 x86
> diff --git a/docs/misc/console.txt b/docs/misc/console.txt
> index 16da805..d081acc 100644
> --- a/docs/misc/console.txt
> +++ b/docs/misc/console.txt
> @@ -19,7 +19,20 @@ The first PV console path in xenstore remains:
>
>  /local/domain/$DOMID/console
>
> -the other PV consoles follow the conventional xenstore device path and
> +The virtual UART console path in xenstore is defined as:
> +
> +/local/domain/$DOMID/vuart/0
> +
> +The vuart console provides access to a virtual SBSA UART on ARM64 systems.

s/ARM64/Arm/

> +To enable vuart the following line has to be added to the guest configuration
> +file:
> +
> +vuart = "sbsa_uart"
> +
> +In Linux you can select the virtual SBSA UART by using the "ttyAMA0"
> +console instead of "hvc0".
> +
> +The other PV consoles follow the conventional xenstore device path and
>  live in:
>
>  /local/domain/$DOMID/device/console/$DEVID.
> @@ -61,6 +74,14 @@ output = pty
>  The backend will write the pty device name to the "tty" node in the
>  console frontend.
>
> +For the PV console the tty node is added at
> +
> +/local/domain/$DOMID/console/tty
> +
> +For the virtual UART console the tty node is added at
> +
> +/local/domain/$DOMID/vuart/0/tty
> +
>  If the toolstack wants a listening Unix domain socket to be created at path
>  <path>, a connection accepted and data proxied to the console, it will write:
>
> @@ -79,8 +100,8 @@ For example:
>  ioemu
>
>  The supported values are only xenconsoled or ioemu; xenconsoled has
> -several limitations: it can only be used for the first PV console and it
> -can only connect to a pty.
> +several limitations: it can only be used for the first PV or virtual UART
> +console and it can only connect to a pty.
>
>  Emulated serials are provided by qemu-dm only to hvm guests; the number
>  of emulated serials depends on how many "-serial" command line options
> @@ -90,14 +111,15 @@ xenstore in the following path:
>
>  /local/domain/$DOMID/serial/$SERIAL_NUM/tty
>
> -xenconsole is the tool to connect to a PV console or an emulated serial
> -that has a pty as output. Xenconsole takes a domid as parameter plus an
> -optional console type (pv for PV consoles or serial for emulated
> -serials) and console number. Depending on the type and console
> -number, xenconsole will look for the tty node in different xenstore
> -paths, as described above.  If the user doesn't specify the console type
> -xenconsole will try to guess: if the guest is a pv guest it defaults to
> -PV console, if the guest is an hvm guest it defaults to emulated serial.
> +xenconsole is the tool to connect to a PV or virtual UART console or an
> +emulated serial that has a pty as output. Xenconsole takes a domid as
> +parameter plus an optional console type (pv for PV consoles, vuart for
> +virtual UART or serial for emulated serials) and console number.
> +Depending on the type and console number, xenconsole will look for the tty
> +node in different xenstore paths, as described above.  If the user doesn't
> +specify the console type xenconsole will try to guess: if the guest is a pv
> +guest it defaults to PV console, if the guest is an hvm guest it defaults to
> +emulated serial.
>
>  By default xl creates a pv console for hvm guests, plus an emulated
>  serial if the user specified 'serial = "pty"' in the VM config file.
>

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 24/25 v7] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree
  2017-08-08 14:12   ` Julien Grall
@ 2017-08-08 14:53     ` Bhupinder Thakur
  0 siblings, 0 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-08 14:53 UTC (permalink / raw)
  To: Julien Grall; +Cc: xen-devel, Stefano Stabellini, Ian Jackson, Wei Liu

Hi Julien,


>>
>> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
>> index a33d3c9..6629852 100644
>> --- a/tools/libxl/libxl_arm.c
>> +++ b/tools/libxl/libxl_arm.c
>> @@ -43,11 +43,29 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
>>  {
>>      uint32_t nr_spis = 0;
>>      unsigned int i;
>> +    uint32_t vuart_irq = 0;
>> +
>> +    /*
>> +     * If pl011 vuart is enabled then increment the nr_spis to allow
>> allocation
>> +     * of SPI VIRQ for pl011.
>> +     */
>> +    if (d_config->b_info.arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) {
>> +        nr_spis += (GUEST_VPL011_SPI - 32) + 1;
>> +        vuart_irq = GUEST_VPL011_SPI;
>> +    }
>>
>>      for (i = 0; i < d_config->b_info.num_irqs; i++) {
>>          uint32_t irq = d_config->b_info.irqs[i];
>>          uint32_t spi;
>>
>> +        /*
>> +         * The user specified irq should not conflict with the vpl011
>> irq.
>> +         */
>
>
> I am sorry but in the changelog you wrote: "Add a comment explaining why
> user specified IRQ should not conflict with vpl011 SPI". But you still don't
> explain why... And I still don't see the TODO requested on v6.

ok. So should I mention that if there is a conflict then that
interrupt would not be received correctly by the guest as user expects
certain
behaviour on receiving the specified IRQ?

Can you please elaborate what is the TODO in this case?

>
>> +        if (irq == vuart_irq) {
>
>
> Hmmm if vUART is not enabled you would compare to 0. And I don't think we
> should make this assumption in the code. This would also give a random error
> to the user.
>
I thought that since this is an SPI interrupt it would start with at least 32.

> It would be better if you introduce a local boolean vuart_enabled to know
> whether you need to check the conflict.

ok. I will add a boolean variable.

Regards,
Bhupinder

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
                   ` (24 preceding siblings ...)
  2017-08-07  8:53 ` [PATCH 25/25 v7] xen/arm: vpl011: Update documentation for vuart console support Bhupinder Thakur
@ 2017-08-08 15:59 ` Julien Grall
  2017-08-09 10:58   ` Bhupinder Thakur
  25 siblings, 1 reply; 67+ messages in thread
From: Julien Grall @ 2017-08-08 15:59 UTC (permalink / raw)
  To: Bhupinder Thakur, xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Andre Przywara

Hi Bhupinder,

I gave another and I have a couple of comments.

Booting Linux with earlycon enabled take quite a while. I can see the 
characters coming slower than on the minitel. It seems to be a bit 
better after switching off the bootconsole. Overall Linux is taking ~20 
times to boot with pl011 vs HVC console.

I do agree that pl011 is emulated and therefore you have to trap after 
each character. But 20 times sounds far too much.

After that I tried to stress the emulation a bit with "find ." to get a 
lot of output. And I noticed a lot of message similar to the one below 
on xen console:

d6v0 vpl011: Unexpected OUT ring buffer full

Associated to that the character have been eaten resulting to non-sense log.

A bit above the printk printing this message, there are a comment saying:

     /*
      * It is expected that the ring is not full when this function is 
called
      * as the guest is expected to write to the data register only when the
      * TXFF flag is not set.
      * In case the guest does write even when the TXFF flag is set then the
      * data will be silently dropped.
      */

I am quite surprised that Linux is not looking at the TXFF flags. So 
this needs some investigation.

Cheers,

On 07/08/17 09:52, Bhupinder Thakur wrote:
> 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_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: Andrew Cooper <andrew.cooper3@citrix.com>
> CC: George Dunlap <George.Dunlap@eu.citrix.com>
> CC: Ian Jackson <ian.jackson@eu.citrix.com>
> CC: Jan Beulich <jbeulich@suse.com>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Tim Deegan <tim@xen.org>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Julien Grall <julien.grall@arm.com>
> CC: Andre Przywara <andre.przywara@arm.com>
>
> 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 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
>
>  config/arm32.mk                      |   1 +
>  config/arm64.mk                      |   1 +
>  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            | 659 +++++++++++++++++++++++------------
>  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              |  25 ++
>  tools/libxl/libxl.h                  |   5 +
>  tools/libxl/libxl_arch.h             |   7 +
>  tools/libxl/libxl_arm.c              |  74 ++++
>  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                |  48 ++-
>  xen/arch/arm/vpl011.c                | 454 ++++++++++++++++++++++++
>  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, 1366 insertions(+), 241 deletions(-)
>  create mode 100644 xen/arch/arm/vpl011.c
>  create mode 100644 xen/include/asm-arm/vpl011.h
>

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-08 15:59 ` [PATCH 00/25 v7] SBSA UART emulation support in Xen Julien Grall
@ 2017-08-09 10:58   ` Bhupinder Thakur
  2017-08-09 11:03     ` Wei Liu
                       ` (2 more replies)
  0 siblings, 3 replies; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-09 10:58 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Andre Przywara, xen-devel

Hi Julien,

Thanks for the testing.

On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
> Hi Bhupinder,
>
> I gave another and I have a couple of comments.
>
> Booting Linux with earlycon enabled take quite a while. I can see the
> characters coming slower than on the minitel. It seems to be a bit better
> after switching off the bootconsole. Overall Linux is taking ~20 times to
> boot with pl011 vs HVC console.
>
> I do agree that pl011 is emulated and therefore you have to trap after each
> character. But 20 times sounds far too much.
>
I think this slowness could be due to ratelimiting of the pl011 events
in xenconosle. Currently, the rate limit is
set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).

I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
this change,
I see that the the find command is running faster and smoother.
Earlier the find output would be jerky.

> After that I tried to stress the emulation a bit with "find ." to get a lot
> of output. And I noticed a lot of message similar to the one below on xen
> console:
>
> d6v0 vpl011: Unexpected OUT ring buffer full
>
> Associated to that the character have been eaten resulting to non-sense log.
>
> A bit above the printk printing this message, there are a comment saying:
>
>     /*
>      * It is expected that the ring is not full when this function is called
>      * as the guest is expected to write to the data register only when the
>      * TXFF flag is not set.
>      * In case the guest does write even when the TXFF flag is set then the
>      * data will be silently dropped.
>      */
>
> I am quite surprised that Linux is not looking at the TXFF flags. So this
> needs some investigation.

I ran 'find' but could not reproduce the issue.

I will try to reproduce this issue by reducing the OUT buffer size.

Regards,
Bhupinder

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-09 10:58   ` Bhupinder Thakur
@ 2017-08-09 11:03     ` Wei Liu
  2017-08-10  7:59       ` Bhupinder Thakur
  2017-08-10 14:26     ` Julien Grall
  2017-08-14  7:52     ` Bhupinder Thakur
  2 siblings, 1 reply; 67+ messages in thread
From: Wei Liu @ 2017-08-09 11:03 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, Jan Beulich,
	Andre Przywara, xen-devel

On Wed, Aug 09, 2017 at 04:28:14PM +0530, Bhupinder Thakur wrote:
> Hi Julien,
> 
> Thanks for the testing.
> 
> On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
> > Hi Bhupinder,
> >
> > I gave another and I have a couple of comments.
> >
> > Booting Linux with earlycon enabled take quite a while. I can see the
> > characters coming slower than on the minitel. It seems to be a bit better
> > after switching off the bootconsole. Overall Linux is taking ~20 times to
> > boot with pl011 vs HVC console.
> >
> > I do agree that pl011 is emulated and therefore you have to trap after each
> > character. But 20 times sounds far too much.
> >
> I think this slowness could be due to ratelimiting of the pl011 events
> in xenconosle. Currently, the rate limit is
> set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
> 
> I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
> this change,
> I see that the the find command is running faster and smoother.
> Earlier the find output would be jerky.

Please consider batching the events instead of bumping the limit.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-09 11:03     ` Wei Liu
@ 2017-08-10  7:59       ` Bhupinder Thakur
  2017-08-10 11:40         ` Wei Liu
  0 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-10  7:59 UTC (permalink / raw)
  To: Wei Liu
  Cc: Stefano Stabellini, George Dunlap, Andrew Cooper, Ian Jackson,
	Tim Deegan, Julien Grall, Jan Beulich, Andre Przywara, xen-devel

Hi Wei,

On 9 August 2017 at 16:33, Wei Liu <wei.liu2@citrix.com> wrote:
> On Wed, Aug 09, 2017 at 04:28:14PM +0530, Bhupinder Thakur wrote:
>> Hi Julien,
>>
>> Thanks for the testing.
>>
>> On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
>> > Hi Bhupinder,
>> >
>> > I gave another and I have a couple of comments.
>> >
>> > Booting Linux with earlycon enabled take quite a while. I can see the
>> > characters coming slower than on the minitel. It seems to be a bit better
>> > after switching off the bootconsole. Overall Linux is taking ~20 times to
>> > boot with pl011 vs HVC console.
>> >
>> > I do agree that pl011 is emulated and therefore you have to trap after each
>> > character. But 20 times sounds far too much.
>> >
>> I think this slowness could be due to ratelimiting of the pl011 events
>> in xenconosle. Currently, the rate limit is
>> set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
>>
>> I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
>> this change,
>> I see that the the find command is running faster and smoother.
>> Earlier the find output would be jerky.
>
> Please consider batching the events instead of bumping the limit.

If I try to batch the events then it may delay per character
processing (if no further characters are coming) since we will wait
for more events to come to batch them together. By keeping the rate
limit high, it is ensured that it can handle large burst of events. If
there is sporadic data then the rate limit is not hit.

I am thinking of making the rate limit configuration per console.

Regards,
Bhupinder

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-10  7:59       ` Bhupinder Thakur
@ 2017-08-10 11:40         ` Wei Liu
  2017-08-10 12:40           ` Julien Grall
  0 siblings, 1 reply; 67+ messages in thread
From: Wei Liu @ 2017-08-10 11:40 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, Jan Beulich,
	Andre Przywara, xen-devel

On Thu, Aug 10, 2017 at 01:29:04PM +0530, Bhupinder Thakur wrote:
> Hi Wei,
> 
> On 9 August 2017 at 16:33, Wei Liu <wei.liu2@citrix.com> wrote:
> > On Wed, Aug 09, 2017 at 04:28:14PM +0530, Bhupinder Thakur wrote:
> >> Hi Julien,
> >>
> >> Thanks for the testing.
> >>
> >> On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
> >> > Hi Bhupinder,
> >> >
> >> > I gave another and I have a couple of comments.
> >> >
> >> > Booting Linux with earlycon enabled take quite a while. I can see the
> >> > characters coming slower than on the minitel. It seems to be a bit better
> >> > after switching off the bootconsole. Overall Linux is taking ~20 times to
> >> > boot with pl011 vs HVC console.
> >> >
> >> > I do agree that pl011 is emulated and therefore you have to trap after each
> >> > character. But 20 times sounds far too much.
> >> >
> >> I think this slowness could be due to ratelimiting of the pl011 events
> >> in xenconosle. Currently, the rate limit is
> >> set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
> >>
> >> I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
> >> this change,
> >> I see that the the find command is running faster and smoother.
> >> Earlier the find output would be jerky.
> >
> > Please consider batching the events instead of bumping the limit.
> 
> If I try to batch the events then it may delay per character
> processing (if no further characters are coming) since we will wait
> for more events to come to batch them together. By keeping the rate
> limit high, it is ensured that it can handle large burst of events. If
> there is sporadic data then the rate limit is not hit.

But do you really need to send an event for every character (that's my
reading of your patch, please correct me if I'm wrong)? Suppose you have
a buffer you can send one event when the buffer is processed.

> 
> I am thinking of making the rate limit configuration per console.
> 

There is the question why vuart is special with regard to other types of
console.

If something is mandated by the spec it should be specifically called
out to justify the decision to bump the rate limit.

> Regards,
> Bhupinder

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-10 11:40         ` Wei Liu
@ 2017-08-10 12:40           ` Julien Grall
  2017-08-10 13:01             ` Wei Liu
  0 siblings, 1 reply; 67+ messages in thread
From: Julien Grall @ 2017-08-10 12:40 UTC (permalink / raw)
  To: Wei Liu, Bhupinder Thakur
  Cc: Stefano Stabellini, George Dunlap, Andrew Cooper, Ian Jackson,
	Tim Deegan, Jan Beulich, Andre Przywara, xen-devel

Hi Wei,

On 10/08/17 12:40, Wei Liu wrote:
> On Thu, Aug 10, 2017 at 01:29:04PM +0530, Bhupinder Thakur wrote:
>> Hi Wei,
>>
>> On 9 August 2017 at 16:33, Wei Liu <wei.liu2@citrix.com> wrote:
>>> On Wed, Aug 09, 2017 at 04:28:14PM +0530, Bhupinder Thakur wrote:
>>>> Hi Julien,
>>>>
>>>> Thanks for the testing.
>>>>
>>>> On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
>>>>> Hi Bhupinder,
>>>>>
>>>>> I gave another and I have a couple of comments.
>>>>>
>>>>> Booting Linux with earlycon enabled take quite a while. I can see the
>>>>> characters coming slower than on the minitel. It seems to be a bit better
>>>>> after switching off the bootconsole. Overall Linux is taking ~20 times to
>>>>> boot with pl011 vs HVC console.
>>>>>
>>>>> I do agree that pl011 is emulated and therefore you have to trap after each
>>>>> character. But 20 times sounds far too much.
>>>>>
>>>> I think this slowness could be due to ratelimiting of the pl011 events
>>>> in xenconosle. Currently, the rate limit is
>>>> set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
>>>>
>>>> I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
>>>> this change,
>>>> I see that the the find command is running faster and smoother.
>>>> Earlier the find output would be jerky.
>>>
>>> Please consider batching the events instead of bumping the limit.
>>
>> If I try to batch the events then it may delay per character
>> processing (if no further characters are coming) since we will wait
>> for more events to come to batch them together. By keeping the rate
>> limit high, it is ensured that it can handle large burst of events. If
>> there is sporadic data then the rate limit is not hit.
>
> But do you really need to send an event for every character (that's my
> reading of your patch, please correct me if I'm wrong)? Suppose you have
> a buffer you can send one event when the buffer is processed.

I am not sure what you mean by buffer here. The interface with the guest 
is a single data register. So characters are written one by one.

>
>>
>> I am thinking of making the rate limit configuration per console.
>>
>
> There is the question why vuart is special with regard to other types of
> console.
>
> If something is mandated by the spec it should be specifically called
> out to justify the decision to bump the rate limit.

I might have other ideas how to improve the speed. I will answer on 
Bhupinder's e-mail.

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-10 12:40           ` Julien Grall
@ 2017-08-10 13:01             ` Wei Liu
  2017-08-10 14:31               ` Julien Grall
  0 siblings, 1 reply; 67+ messages in thread
From: Wei Liu @ 2017-08-10 13:01 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Andre Przywara,
	Bhupinder Thakur, xen-devel

On Thu, Aug 10, 2017 at 01:40:07PM +0100, Julien Grall wrote:
> Hi Wei,
> 
> On 10/08/17 12:40, Wei Liu wrote:
> > On Thu, Aug 10, 2017 at 01:29:04PM +0530, Bhupinder Thakur wrote:
> > > Hi Wei,
> > > 
> > > On 9 August 2017 at 16:33, Wei Liu <wei.liu2@citrix.com> wrote:
> > > > On Wed, Aug 09, 2017 at 04:28:14PM +0530, Bhupinder Thakur wrote:
> > > > > Hi Julien,
> > > > > 
> > > > > Thanks for the testing.
> > > > > 
> > > > > On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
> > > > > > Hi Bhupinder,
> > > > > > 
> > > > > > I gave another and I have a couple of comments.
> > > > > > 
> > > > > > Booting Linux with earlycon enabled take quite a while. I can see the
> > > > > > characters coming slower than on the minitel. It seems to be a bit better
> > > > > > after switching off the bootconsole. Overall Linux is taking ~20 times to
> > > > > > boot with pl011 vs HVC console.
> > > > > > 
> > > > > > I do agree that pl011 is emulated and therefore you have to trap after each
> > > > > > character. But 20 times sounds far too much.
> > > > > > 
> > > > > I think this slowness could be due to ratelimiting of the pl011 events
> > > > > in xenconosle. Currently, the rate limit is
> > > > > set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
> > > > > 
> > > > > I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
> > > > > this change,
> > > > > I see that the the find command is running faster and smoother.
> > > > > Earlier the find output would be jerky.
> > > > 
> > > > Please consider batching the events instead of bumping the limit.
> > > 
> > > If I try to batch the events then it may delay per character
> > > processing (if no further characters are coming) since we will wait
> > > for more events to come to batch them together. By keeping the rate
> > > limit high, it is ensured that it can handle large burst of events. If
> > > there is sporadic data then the rate limit is not hit.
> > 
> > But do you really need to send an event for every character (that's my
> > reading of your patch, please correct me if I'm wrong)? Suppose you have
> > a buffer you can send one event when the buffer is processed.
> 
> I am not sure what you mean by buffer here. The interface with the guest is
> a single data register. So characters are written one by one.

Yes, that's what the guest sees, but that is not necessarily what
xenconsoled sees.

> 
> > 
> > > 
> > > I am thinking of making the rate limit configuration per console.
> > > 
> > 
> > There is the question why vuart is special with regard to other types of
> > console.
> > 
> > If something is mandated by the spec it should be specifically called
> > out to justify the decision to bump the rate limit.
> 
> I might have other ideas how to improve the speed. I will answer on
> Bhupinder's e-mail.
> 

Sure.

> Cheers,
> 
> -- 
> Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-09 10:58   ` Bhupinder Thakur
  2017-08-09 11:03     ` Wei Liu
@ 2017-08-10 14:26     ` Julien Grall
  2017-08-10 16:00       ` Wei Liu
  2017-08-14  7:52     ` Bhupinder Thakur
  2 siblings, 1 reply; 67+ messages in thread
From: Julien Grall @ 2017-08-10 14:26 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Andre Przywara, xen-devel



On 09/08/17 11:58, Bhupinder Thakur wrote:
> Hi Julien,

Hi Bhupinder,

> Thanks for the testing.
>
> On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
>> Hi Bhupinder,
>>
>> I gave another and I have a couple of comments.
>>
>> Booting Linux with earlycon enabled take quite a while. I can see the
>> characters coming slower than on the minitel. It seems to be a bit better
>> after switching off the bootconsole. Overall Linux is taking ~20 times to
>> boot with pl011 vs HVC console.
>>
>> I do agree that pl011 is emulated and therefore you have to trap after each
>> character. But 20 times sounds far too much.
>>
> I think this slowness could be due to ratelimiting of the pl011 events
> in xenconosle. Currently, the rate limit is
> set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
>
> I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
> this change,
> I see that the the find command is running faster and smoother.
> Earlier the find output would be jerky.

I think there might be another solution avoiding increasing the rate limit.

If you look at the earlycon code for pl011 in Linux:

static void pl011_putc(struct uart_port *port, int c)
{
	while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
		cpu_relax();
	if (port->iotype == UPIO_MEM32)
		writel(c, port->membase + UART01x_DR);
	else
		writeb(c, port->membase + UART01x_DR);
	while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
		cpu_relax();
}

Linux will wait the UART to be idle before sending a new character.

Now looking at vpl011 emulation, the busy bit set when a new character 
is queued (see vpl011_write_data). This bit will only be cleared when 
the console daemon will raise an event and the queue is empty (see 
vpl011_data_avail).

This means for earlycon, you will need a round trip Guest -> Xen -> Dom0 
-> Xen -> Guest for each single character. This is a bit 
counterproductive and combined with the limit it makes it worse.

I would take a different approach on the BUSY bit. We can consider the 
queue between Xen and xenconsoled as outside of the UART. If the 
character is queued, then job done. I think this would improve quite a 
lot of the performance.

Also, I would append a new patch at then end of the series rather modify 
patch #1. This would avoid to do more review :).

>
>> After that I tried to stress the emulation a bit with "find ." to get a lot
>> of output. And I noticed a lot of message similar to the one below on xen
>> console:
>>
>> d6v0 vpl011: Unexpected OUT ring buffer full
>>
>> Associated to that the character have been eaten resulting to non-sense log.
>>
>> A bit above the printk printing this message, there are a comment saying:
>>
>>     /*
>>      * It is expected that the ring is not full when this function is called
>>      * as the guest is expected to write to the data register only when the
>>      * TXFF flag is not set.
>>      * In case the guest does write even when the TXFF flag is set then the
>>      * data will be silently dropped.
>>      */
>>
>> I am quite surprised that Linux is not looking at the TXFF flags. So this
>> needs some investigation.
>
> I ran 'find' but could not reproduce the issue.

Sorry I forgot to precise that you need to run find in a directory with 
a lot of files. A good solution would be:

find /

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-10 13:01             ` Wei Liu
@ 2017-08-10 14:31               ` Julien Grall
  2017-08-10 15:36                 ` Wei Liu
  0 siblings, 1 reply; 67+ messages in thread
From: Julien Grall @ 2017-08-10 14:31 UTC (permalink / raw)
  To: Wei Liu
  Cc: Stefano Stabellini, George Dunlap, Andrew Cooper, Ian Jackson,
	Tim Deegan, Jan Beulich, Andre Przywara, Bhupinder Thakur,
	xen-devel

Hi,

On 10/08/17 14:01, Wei Liu wrote:
> On Thu, Aug 10, 2017 at 01:40:07PM +0100, Julien Grall wrote:
>> Hi Wei,
>>
>> On 10/08/17 12:40, Wei Liu wrote:
>>> On Thu, Aug 10, 2017 at 01:29:04PM +0530, Bhupinder Thakur wrote:
>>>> Hi Wei,
>>>>
>>>> On 9 August 2017 at 16:33, Wei Liu <wei.liu2@citrix.com> wrote:
>>>>> On Wed, Aug 09, 2017 at 04:28:14PM +0530, Bhupinder Thakur wrote:
>>>>>> Hi Julien,
>>>>>>
>>>>>> Thanks for the testing.
>>>>>>
>>>>>> On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
>>>>>>> Hi Bhupinder,
>>>>>>>
>>>>>>> I gave another and I have a couple of comments.
>>>>>>>
>>>>>>> Booting Linux with earlycon enabled take quite a while. I can see the
>>>>>>> characters coming slower than on the minitel. It seems to be a bit better
>>>>>>> after switching off the bootconsole. Overall Linux is taking ~20 times to
>>>>>>> boot with pl011 vs HVC console.
>>>>>>>
>>>>>>> I do agree that pl011 is emulated and therefore you have to trap after each
>>>>>>> character. But 20 times sounds far too much.
>>>>>>>
>>>>>> I think this slowness could be due to ratelimiting of the pl011 events
>>>>>> in xenconosle. Currently, the rate limit is
>>>>>> set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
>>>>>>
>>>>>> I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
>>>>>> this change,
>>>>>> I see that the the find command is running faster and smoother.
>>>>>> Earlier the find output would be jerky.
>>>>>
>>>>> Please consider batching the events instead of bumping the limit.
>>>>
>>>> If I try to batch the events then it may delay per character
>>>> processing (if no further characters are coming) since we will wait
>>>> for more events to come to batch them together. By keeping the rate
>>>> limit high, it is ensured that it can handle large burst of events. If
>>>> there is sporadic data then the rate limit is not hit.
>>>
>>> But do you really need to send an event for every character (that's my
>>> reading of your patch, please correct me if I'm wrong)? Suppose you have
>>> a buffer you can send one event when the buffer is processed.
>>
>> I am not sure what you mean by buffer here. The interface with the guest is
>> a single data register. So characters are written one by one.
>
> Yes, that's what the guest sees, but that is not necessarily what
> xenconsoled sees.

I am a bit confused here. What are you suggesting? To send a 
notification every N characters?

In that case when do you assume that the buffer need to be flushed 
before N characters (e.g for the prompt)?

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-10 14:31               ` Julien Grall
@ 2017-08-10 15:36                 ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-10 15:36 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Andre Przywara,
	Bhupinder Thakur, xen-devel

On Thu, Aug 10, 2017 at 03:31:57PM +0100, Julien Grall wrote:
> Hi,
> 
> On 10/08/17 14:01, Wei Liu wrote:
> > On Thu, Aug 10, 2017 at 01:40:07PM +0100, Julien Grall wrote:
> > > Hi Wei,
> > > 
> > > On 10/08/17 12:40, Wei Liu wrote:
> > > > On Thu, Aug 10, 2017 at 01:29:04PM +0530, Bhupinder Thakur wrote:
> > > > > Hi Wei,
> > > > > 
> > > > > On 9 August 2017 at 16:33, Wei Liu <wei.liu2@citrix.com> wrote:
> > > > > > On Wed, Aug 09, 2017 at 04:28:14PM +0530, Bhupinder Thakur wrote:
> > > > > > > Hi Julien,
> > > > > > > 
> > > > > > > Thanks for the testing.
> > > > > > > 
> > > > > > > On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
> > > > > > > > Hi Bhupinder,
> > > > > > > > 
> > > > > > > > I gave another and I have a couple of comments.
> > > > > > > > 
> > > > > > > > Booting Linux with earlycon enabled take quite a while. I can see the
> > > > > > > > characters coming slower than on the minitel. It seems to be a bit better
> > > > > > > > after switching off the bootconsole. Overall Linux is taking ~20 times to
> > > > > > > > boot with pl011 vs HVC console.
> > > > > > > > 
> > > > > > > > I do agree that pl011 is emulated and therefore you have to trap after each
> > > > > > > > character. But 20 times sounds far too much.
> > > > > > > > 
> > > > > > > I think this slowness could be due to ratelimiting of the pl011 events
> > > > > > > in xenconosle. Currently, the rate limit is
> > > > > > > set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
> > > > > > > 
> > > > > > > I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
> > > > > > > this change,
> > > > > > > I see that the the find command is running faster and smoother.
> > > > > > > Earlier the find output would be jerky.
> > > > > > 
> > > > > > Please consider batching the events instead of bumping the limit.
> > > > > 
> > > > > If I try to batch the events then it may delay per character
> > > > > processing (if no further characters are coming) since we will wait
> > > > > for more events to come to batch them together. By keeping the rate
> > > > > limit high, it is ensured that it can handle large burst of events. If
> > > > > there is sporadic data then the rate limit is not hit.
> > > > 
> > > > But do you really need to send an event for every character (that's my
> > > > reading of your patch, please correct me if I'm wrong)? Suppose you have
> > > > a buffer you can send one event when the buffer is processed.
> > > 
> > > I am not sure what you mean by buffer here. The interface with the guest is
> > > a single data register. So characters are written one by one.
> > 
> > Yes, that's what the guest sees, but that is not necessarily what
> > xenconsoled sees.
> 
> I am a bit confused here. What are you suggesting? To send a notification

I think the other email you just sent is quite close to what I would
suggest. I will reply there.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-10 14:26     ` Julien Grall
@ 2017-08-10 16:00       ` Wei Liu
  2017-08-10 16:11         ` Julien Grall
  0 siblings, 1 reply; 67+ messages in thread
From: Wei Liu @ 2017-08-10 16:00 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Andre Przywara,
	Bhupinder Thakur, xen-devel

On Thu, Aug 10, 2017 at 03:26:07PM +0100, Julien Grall wrote:
> 
> 
> On 09/08/17 11:58, Bhupinder Thakur wrote:
> > Hi Julien,
> 
> Hi Bhupinder,
> 
> > Thanks for the testing.
> > 
> > On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
> > > Hi Bhupinder,
> > > 
> > > I gave another and I have a couple of comments.
> > > 
> > > Booting Linux with earlycon enabled take quite a while. I can see the
> > > characters coming slower than on the minitel. It seems to be a bit better
> > > after switching off the bootconsole. Overall Linux is taking ~20 times to
> > > boot with pl011 vs HVC console.
> > > 
> > > I do agree that pl011 is emulated and therefore you have to trap after each
> > > character. But 20 times sounds far too much.
> > > 
> > I think this slowness could be due to ratelimiting of the pl011 events
> > in xenconosle. Currently, the rate limit is
> > set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
> > 
> > I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
> > this change,
> > I see that the the find command is running faster and smoother.
> > Earlier the find output would be jerky.
> 
> I think there might be another solution avoiding increasing the rate limit.
> 
> If you look at the earlycon code for pl011 in Linux:
> 
> static void pl011_putc(struct uart_port *port, int c)
> {
> 	while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
> 		cpu_relax();
> 	if (port->iotype == UPIO_MEM32)
> 		writel(c, port->membase + UART01x_DR);
> 	else
> 		writeb(c, port->membase + UART01x_DR);
> 	while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
> 		cpu_relax();
> }
> 
> Linux will wait the UART to be idle before sending a new character.
> 
> Now looking at vpl011 emulation, the busy bit set when a new character is
> queued (see vpl011_write_data). This bit will only be cleared when the
> console daemon will raise an event and the queue is empty (see
> vpl011_data_avail).
> 
> This means for earlycon, you will need a round trip Guest -> Xen -> Dom0 ->
> Xen -> Guest for each single character. This is a bit counterproductive and
> combined with the limit it makes it worse.
> 
> I would take a different approach on the BUSY bit. We can consider the queue
> between Xen and xenconsoled as outside of the UART. If the character is
> queued, then job done. I think this would improve quite a lot of the
> performance.

Yes. This.

The guest sees a register, which is essentially a synchronous interface
to the guest. The current code, as you already see, will issue one event
for every character. That's excessive.

The interface between Xen and xenconsoled can be asynchronous, it can
opt to queue X characters before sending an event, also setup a oneshot
timer to avoid hanging.

This however has some other implications -- it might not be as reliable
as the original method because data is not guaranteed to hit backend. If
the guest crashes very early on, depending the actual implementation you
might not be able get the data.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-10 16:00       ` Wei Liu
@ 2017-08-10 16:11         ` Julien Grall
  2017-08-10 16:38           ` Wei Liu
  0 siblings, 1 reply; 67+ messages in thread
From: Julien Grall @ 2017-08-10 16:11 UTC (permalink / raw)
  To: Wei Liu
  Cc: Stefano Stabellini, George Dunlap, Ian Jackson, Tim Deegan,
	Andre Przywara, Jan Beulich, Andrew Cooper, Bhupinder Thakur,
	xen-devel



On 10/08/17 17:00, Wei Liu wrote:
> On Thu, Aug 10, 2017 at 03:26:07PM +0100, Julien Grall wrote:
>>
>>
>> On 09/08/17 11:58, Bhupinder Thakur wrote:
>>> Hi Julien,
>>
>> Hi Bhupinder,
>>
>>> Thanks for the testing.
>>>
>>> On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
>>>> Hi Bhupinder,
>>>>
>>>> I gave another and I have a couple of comments.
>>>>
>>>> Booting Linux with earlycon enabled take quite a while. I can see the
>>>> characters coming slower than on the minitel. It seems to be a bit better
>>>> after switching off the bootconsole. Overall Linux is taking ~20 times to
>>>> boot with pl011 vs HVC console.
>>>>
>>>> I do agree that pl011 is emulated and therefore you have to trap after each
>>>> character. But 20 times sounds far too much.
>>>>
>>> I think this slowness could be due to ratelimiting of the pl011 events
>>> in xenconosle. Currently, the rate limit is
>>> set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
>>>
>>> I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
>>> this change,
>>> I see that the the find command is running faster and smoother.
>>> Earlier the find output would be jerky.
>>
>> I think there might be another solution avoiding increasing the rate limit.
>>
>> If you look at the earlycon code for pl011 in Linux:
>>
>> static void pl011_putc(struct uart_port *port, int c)
>> {
>> 	while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
>> 		cpu_relax();
>> 	if (port->iotype == UPIO_MEM32)
>> 		writel(c, port->membase + UART01x_DR);
>> 	else
>> 		writeb(c, port->membase + UART01x_DR);
>> 	while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
>> 		cpu_relax();
>> }
>>
>> Linux will wait the UART to be idle before sending a new character.
>>
>> Now looking at vpl011 emulation, the busy bit set when a new character is
>> queued (see vpl011_write_data). This bit will only be cleared when the
>> console daemon will raise an event and the queue is empty (see
>> vpl011_data_avail).
>>
>> This means for earlycon, you will need a round trip Guest -> Xen -> Dom0 ->
>> Xen -> Guest for each single character. This is a bit counterproductive and
>> combined with the limit it makes it worse.
>>
>> I would take a different approach on the BUSY bit. We can consider the queue
>> between Xen and xenconsoled as outside of the UART. If the character is
>> queued, then job done. I think this would improve quite a lot of the
>> performance.
>
> Yes. This.
>
> The guest sees a register, which is essentially a synchronous interface
> to the guest. The current code, as you already see, will issue one event
> for every character. That's excessive.

I am actually not suggesting to modify that at the moment. I think you 
may have other trouble with the interaction between the user and th 
console by doing that. Imagine you want to print the prompt, it may lag 
a bit before getting it.

The only thing I suggest is to not set the BUSY bit in the UART 
everytime a character is queued.

>
> The interface between Xen and xenconsoled can be asynchronous, it can
> opt to queue X characters before sending an event, also setup a oneshot
> timer to avoid hanging.
>
> This however has some other implications -- it might not be as reliable
> as the original method because data is not guaranteed to hit backend. If
> the guest crashes very early on, depending the actual implementation you
> might not be able get the data.

Would it be possible to ask xenconsoled to dump everything on domain 
crash? Some kind of synchronization.

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-10 16:11         ` Julien Grall
@ 2017-08-10 16:38           ` Wei Liu
  2017-08-10 17:51             ` Julien Grall
  0 siblings, 1 reply; 67+ messages in thread
From: Wei Liu @ 2017-08-10 16:38 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andre Przywara,
	Ian Jackson, Tim Deegan, Jan Beulich, Andrew Cooper,
	Bhupinder Thakur, xen-devel

On Thu, Aug 10, 2017 at 05:11:52PM +0100, Julien Grall wrote:
> 
> 
> On 10/08/17 17:00, Wei Liu wrote:
> > On Thu, Aug 10, 2017 at 03:26:07PM +0100, Julien Grall wrote:
> > > 
> > > 
> > > On 09/08/17 11:58, Bhupinder Thakur wrote:
> > > > Hi Julien,
> > > 
> > > Hi Bhupinder,
> > > 
> > > > Thanks for the testing.
> > > > 
> > > > On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
> > > > > Hi Bhupinder,
> > > > > 
> > > > > I gave another and I have a couple of comments.
> > > > > 
> > > > > Booting Linux with earlycon enabled take quite a while. I can see the
> > > > > characters coming slower than on the minitel. It seems to be a bit better
> > > > > after switching off the bootconsole. Overall Linux is taking ~20 times to
> > > > > boot with pl011 vs HVC console.
> > > > > 
> > > > > I do agree that pl011 is emulated and therefore you have to trap after each
> > > > > character. But 20 times sounds far too much.
> > > > > 
> > > > I think this slowness could be due to ratelimiting of the pl011 events
> > > > in xenconosle. Currently, the rate limit is
> > > > set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
> > > > 
> > > > I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
> > > > this change,
> > > > I see that the the find command is running faster and smoother.
> > > > Earlier the find output would be jerky.
> > > 
> > > I think there might be another solution avoiding increasing the rate limit.
> > > 
> > > If you look at the earlycon code for pl011 in Linux:
> > > 
> > > static void pl011_putc(struct uart_port *port, int c)
> > > {
> > > 	while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
> > > 		cpu_relax();
> > > 	if (port->iotype == UPIO_MEM32)
> > > 		writel(c, port->membase + UART01x_DR);
> > > 	else
> > > 		writeb(c, port->membase + UART01x_DR);
> > > 	while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
> > > 		cpu_relax();
> > > }
> > > 
> > > Linux will wait the UART to be idle before sending a new character.
> > > 
> > > Now looking at vpl011 emulation, the busy bit set when a new character is
> > > queued (see vpl011_write_data). This bit will only be cleared when the
> > > console daemon will raise an event and the queue is empty (see
> > > vpl011_data_avail).
> > > 
> > > This means for earlycon, you will need a round trip Guest -> Xen -> Dom0 ->
> > > Xen -> Guest for each single character. This is a bit counterproductive and
> > > combined with the limit it makes it worse.
> > > 
> > > I would take a different approach on the BUSY bit. We can consider the queue
> > > between Xen and xenconsoled as outside of the UART. If the character is
> > > queued, then job done. I think this would improve quite a lot of the
> > > performance.
> > 
> > Yes. This.
> > 
> > The guest sees a register, which is essentially a synchronous interface
> > to the guest. The current code, as you already see, will issue one event
> > for every character. That's excessive.
> 
> I am actually not suggesting to modify that at the moment. I think you may
> have other trouble with the interaction between the user and th console by
> doing that. Imagine you want to print the prompt, it may lag a bit before
> getting it.
> 
> The only thing I suggest is to not set the BUSY bit in the UART everytime a
> character is queued.
> 

Did you come to that conclusion that this would work by looking at the
spec or Linux source code? I think it should conform to the spec, not a
specific guest. But you're the maintainer, you have the final say.

> > 
> > The interface between Xen and xenconsoled can be asynchronous, it can
> > opt to queue X characters before sending an event, also setup a oneshot
> > timer to avoid hanging.
> > 
> > This however has some other implications -- it might not be as reliable
> > as the original method because data is not guaranteed to hit backend. If
> > the guest crashes very early on, depending the actual implementation you
> > might not be able get the data.
> 
> Would it be possible to ask xenconsoled to dump everything on domain crash?
> Some kind of synchronization.
> 

No, not at the moment. If the data is still in Xen and destroyed,
xenconsoled can't do anything.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-10 16:38           ` Wei Liu
@ 2017-08-10 17:51             ` Julien Grall
  2017-08-15  9:49               ` Wei Liu
  0 siblings, 1 reply; 67+ messages in thread
From: Julien Grall @ 2017-08-10 17:51 UTC (permalink / raw)
  To: Wei Liu
  Cc: Stefano Stabellini, George Dunlap, Ian Jackson, Tim Deegan,
	Andrew Cooper, Jan Beulich, Andre Przywara, Bhupinder Thakur,
	xen-devel



On 10/08/17 17:38, Wei Liu wrote:
> On Thu, Aug 10, 2017 at 05:11:52PM +0100, Julien Grall wrote:
>>
>>
>> On 10/08/17 17:00, Wei Liu wrote:
>>> On Thu, Aug 10, 2017 at 03:26:07PM +0100, Julien Grall wrote:
>>>>
>>>>
>>>> On 09/08/17 11:58, Bhupinder Thakur wrote:
>>>>> Hi Julien,
>>>>
>>>> Hi Bhupinder,
>>>>
>>>>> Thanks for the testing.
>>>>>
>>>>> On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
>>>>>> Hi Bhupinder,
>>>>>>
>>>>>> I gave another and I have a couple of comments.
>>>>>>
>>>>>> Booting Linux with earlycon enabled take quite a while. I can see the
>>>>>> characters coming slower than on the minitel. It seems to be a bit better
>>>>>> after switching off the bootconsole. Overall Linux is taking ~20 times to
>>>>>> boot with pl011 vs HVC console.
>>>>>>
>>>>>> I do agree that pl011 is emulated and therefore you have to trap after each
>>>>>> character. But 20 times sounds far too much.
>>>>>>
>>>>> I think this slowness could be due to ratelimiting of the pl011 events
>>>>> in xenconosle. Currently, the rate limit is
>>>>> set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
>>>>>
>>>>> I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
>>>>> this change,
>>>>> I see that the the find command is running faster and smoother.
>>>>> Earlier the find output would be jerky.
>>>>
>>>> I think there might be another solution avoiding increasing the rate limit.
>>>>
>>>> If you look at the earlycon code for pl011 in Linux:
>>>>
>>>> static void pl011_putc(struct uart_port *port, int c)
>>>> {
>>>> 	while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
>>>> 		cpu_relax();
>>>> 	if (port->iotype == UPIO_MEM32)
>>>> 		writel(c, port->membase + UART01x_DR);
>>>> 	else
>>>> 		writeb(c, port->membase + UART01x_DR);
>>>> 	while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
>>>> 		cpu_relax();
>>>> }
>>>>
>>>> Linux will wait the UART to be idle before sending a new character.
>>>>
>>>> Now looking at vpl011 emulation, the busy bit set when a new character is
>>>> queued (see vpl011_write_data). This bit will only be cleared when the
>>>> console daemon will raise an event and the queue is empty (see
>>>> vpl011_data_avail).
>>>>
>>>> This means for earlycon, you will need a round trip Guest -> Xen -> Dom0 ->
>>>> Xen -> Guest for each single character. This is a bit counterproductive and
>>>> combined with the limit it makes it worse.
>>>>
>>>> I would take a different approach on the BUSY bit. We can consider the queue
>>>> between Xen and xenconsoled as outside of the UART. If the character is
>>>> queued, then job done. I think this would improve quite a lot of the
>>>> performance.
>>>
>>> Yes. This.
>>>
>>> The guest sees a register, which is essentially a synchronous interface
>>> to the guest. The current code, as you already see, will issue one event
>>> for every character. That's excessive.
>>
>> I am actually not suggesting to modify that at the moment. I think you may
>> have other trouble with the interaction between the user and th console by
>> doing that. Imagine you want to print the prompt, it may lag a bit before
>> getting it.
>>
>> The only thing I suggest is to not set the BUSY bit in the UART everytime a
>> character is queued.
>>
>
> Did you come to that conclusion that this would work by looking at the
> spec or Linux source code? I think it should conform to the spec, not a
> specific guest. But you're the maintainer, you have the final say.

I read both the spec and the code. From the spec:

"UART busy. If this bit is set to 1, the UART is busy transmitting data. 
This bit remains set until the
complete byte, including all the stop bits, has been sent from the shift 
register.
This bit is set as soon as the transmit FIFO becomes non-empty, 
regardless of whether the UART is
enabled or not."

Currently, we considered that the shared ring is the FIFO of the UART. 
Meaning that the BUSY bit is set until xenconsoled read everything.

I don't think implementing a FIFO is highly critical in an emulation 
(QEMU does not implement it for instance). And definitely using the 
shared ring brings slow down (involve multiple context switch).

I would suggest to take a different approach where the BUSY is only set 
if we can't add more data in the shared ring. This would be clear as 
soon as the ring has space.

If we really we could implement is small FIFO (the SBSA requested a 
least 32-entry separate for transmit and receive). But I don't think 
this is critically for a first approach.

>
>>>
>>> The interface between Xen and xenconsoled can be asynchronous, it can
>>> opt to queue X characters before sending an event, also setup a oneshot
>>> timer to avoid hanging.
>>>
>>> This however has some other implications -- it might not be as reliable
>>> as the original method because data is not guaranteed to hit backend. If
>>> the guest crashes very early on, depending the actual implementation you
>>> might not be able get the data.
>>
>> Would it be possible to ask xenconsoled to dump everything on domain crash?
>> Some kind of synchronization.
>>
>
> No, not at the moment. If the data is still in Xen and destroyed,
> xenconsoled can't do anything.

The vUART emulation is directly queuing the data, there are no 
intermediate buffer. So all the data would be in the shared ring 
available for xenconsoled to go through.

It would be quite a useful enhancement for when the guest crash.

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-09 10:58   ` Bhupinder Thakur
  2017-08-09 11:03     ` Wei Liu
  2017-08-10 14:26     ` Julien Grall
@ 2017-08-14  7:52     ` Bhupinder Thakur
  2017-08-14 13:54       ` Julien Grall
  2 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-14  7:52 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Andre Przywara, xen-devel

Hi Julien,


>> After that I tried to stress the emulation a bit with "find ." to get a lot
>> of output. And I noticed a lot of message similar to the one below on xen
>> console:
>>
>> d6v0 vpl011: Unexpected OUT ring buffer full
>>
>> Associated to that the character have been eaten resulting to non-sense log.
>>
>> A bit above the printk printing this message, there are a comment saying:
>>
>>     /*
>>      * It is expected that the ring is not full when this function is called
>>      * as the guest is expected to write to the data register only when the
>>      * TXFF flag is not set.
>>      * In case the guest does write even when the TXFF flag is set then the
>>      * data will be silently dropped.
>>      */
>>
>> I am quite surprised that Linux is not looking at the TXFF flags. So this
>> needs some investigation.
>
> I ran 'find' but could not reproduce the issue.
>
> I will try to reproduce this issue by reducing the OUT buffer size.

I could not reproduce the issue with the reduced buffer of 16 bytes
also. I think it may not be reproducible on the foundation model. I am
trying to bring up xen on an ARM machine here to reproduce the issue.

While looking at the pl011 driver in linux, I see one potential case
where the the driver may send more data even when the TX FIFO is full.
It seems the pl011 driver expects that the TX interrupt must be raised
only when at least half of TX FIFO queue is empty.

pl011_tx_chars() calls pl011_tx_char() in a loop for (fifosize/2)
number of times. Since these APIs are getting called in the interrupt
context, pl011_tx_char() does not check for TX FIFO full status
because it expects that fifosize/2 space is available.

In the emulation logic, we should set the TX bit in the status
register only if at least space for 16 bytes is available (since SBSA
fifosize is 32). Currently, we may be setting the TX bit even if there
is space for 1 byte. In that scenario, the driver may write more data
then emulation logic can queue up.

Regards,
Bhupinder

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-14  7:52     ` Bhupinder Thakur
@ 2017-08-14 13:54       ` Julien Grall
  2017-08-22 14:35         ` Julien Grall
  0 siblings, 1 reply; 67+ messages in thread
From: Julien Grall @ 2017-08-14 13:54 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Andre Przywara, xen-devel



On 14/08/17 08:52, Bhupinder Thakur wrote:
> Hi Julien,

Hi Bhupinder,

>
>
>>> After that I tried to stress the emulation a bit with "find ." to get a lot
>>> of output. And I noticed a lot of message similar to the one below on xen
>>> console:
>>>
>>> d6v0 vpl011: Unexpected OUT ring buffer full
>>>
>>> Associated to that the character have been eaten resulting to non-sense log.
>>>
>>> A bit above the printk printing this message, there are a comment saying:
>>>
>>>     /*
>>>      * It is expected that the ring is not full when this function is called
>>>      * as the guest is expected to write to the data register only when the
>>>      * TXFF flag is not set.
>>>      * In case the guest does write even when the TXFF flag is set then the
>>>      * data will be silently dropped.
>>>      */
>>>
>>> I am quite surprised that Linux is not looking at the TXFF flags. So this
>>> needs some investigation.
>>
>> I ran 'find' but could not reproduce the issue.
>>
>> I will try to reproduce this issue by reducing the OUT buffer size.
>
> I could not reproduce the issue with the reduced buffer of 16 bytes
> also. I think it may not be reproducible on the foundation model. I am
> trying to bring up xen on an ARM machine here to reproduce the issue.
>
> While looking at the pl011 driver in linux, I see one potential case
> where the the driver may send more data even when the TX FIFO is full.
> It seems the pl011 driver expects that the TX interrupt must be raised
> only when at least half of TX FIFO queue is empty.
>
> pl011_tx_chars() calls pl011_tx_char() in a loop for (fifosize/2)
> number of times. Since these APIs are getting called in the interrupt
> context, pl011_tx_char() does not check for TX FIFO full status
> because it expects that fifosize/2 space is available.
>
> In the emulation logic, we should set the TX bit in the status
> register only if at least space for 16 bytes is available (since SBSA
> fifosize is 32). Currently, we may be setting the TX bit even if there
> is space for 1 byte. In that scenario, the driver may write more data
> then emulation logic can queue up.

I understand that it is the behavior expected by Linux. However did you 
check it was compliant with the spec?

If I looked at the PL011 (ARM DDI 0183G), the interrupt FIFO level is 
set via UARTIFLS. The reset value is half-way mark (i.e 16 byte).

However, looking at the SBSA, this register is inexistent and I can't 
find anything mentioning the half-way mark. So we need some 
clarification here. Let me ask it.

Meanwhile, trying the half-way mark would be good to see if it helps.

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-10 17:51             ` Julien Grall
@ 2017-08-15  9:49               ` Wei Liu
  2017-08-18 13:30                 ` Julien Grall
  0 siblings, 1 reply; 67+ messages in thread
From: Wei Liu @ 2017-08-15  9:49 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andre Przywara,
	Ian Jackson, Tim Deegan, Jan Beulich, Andrew Cooper,
	Bhupinder Thakur, xen-devel

On Thu, Aug 10, 2017 at 06:51:24PM +0100, Julien Grall wrote:
> 
> 
> On 10/08/17 17:38, Wei Liu wrote:
> > On Thu, Aug 10, 2017 at 05:11:52PM +0100, Julien Grall wrote:
> > > 
> > > 
> > > On 10/08/17 17:00, Wei Liu wrote:
> > > > On Thu, Aug 10, 2017 at 03:26:07PM +0100, Julien Grall wrote:
> > > > > 
> > > > > 
> > > > > On 09/08/17 11:58, Bhupinder Thakur wrote:
> > > > > > Hi Julien,
> > > > > 
> > > > > Hi Bhupinder,
> > > > > 
> > > > > > Thanks for the testing.
> > > > > > 
> > > > > > On 8 August 2017 at 21:29, Julien Grall <julien.grall@arm.com> wrote:
> > > > > > > Hi Bhupinder,
> > > > > > > 
> > > > > > > I gave another and I have a couple of comments.
> > > > > > > 
> > > > > > > Booting Linux with earlycon enabled take quite a while. I can see the
> > > > > > > characters coming slower than on the minitel. It seems to be a bit better
> > > > > > > after switching off the bootconsole. Overall Linux is taking ~20 times to
> > > > > > > boot with pl011 vs HVC console.
> > > > > > > 
> > > > > > > I do agree that pl011 is emulated and therefore you have to trap after each
> > > > > > > character. But 20 times sounds far too much.
> > > > > > > 
> > > > > > I think this slowness could be due to ratelimiting of the pl011 events
> > > > > > in xenconosle. Currently, the rate limit is
> > > > > > set to 30 events per 200 msecs (see RATE_LIMIT_ALLOWANCE/RATE_LIMIT_PERIOD).
> > > > > > 
> > > > > > I increased the rate limit to 600 events (30 * 20) per 200 msecs. With
> > > > > > this change,
> > > > > > I see that the the find command is running faster and smoother.
> > > > > > Earlier the find output would be jerky.
> > > > > 
> > > > > I think there might be another solution avoiding increasing the rate limit.
> > > > > 
> > > > > If you look at the earlycon code for pl011 in Linux:
> > > > > 
> > > > > static void pl011_putc(struct uart_port *port, int c)
> > > > > {
> > > > > 	while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
> > > > > 		cpu_relax();
> > > > > 	if (port->iotype == UPIO_MEM32)
> > > > > 		writel(c, port->membase + UART01x_DR);
> > > > > 	else
> > > > > 		writeb(c, port->membase + UART01x_DR);
> > > > > 	while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
> > > > > 		cpu_relax();
> > > > > }
> > > > > 
> > > > > Linux will wait the UART to be idle before sending a new character.
> > > > > 
> > > > > Now looking at vpl011 emulation, the busy bit set when a new character is
> > > > > queued (see vpl011_write_data). This bit will only be cleared when the
> > > > > console daemon will raise an event and the queue is empty (see
> > > > > vpl011_data_avail).
> > > > > 
> > > > > This means for earlycon, you will need a round trip Guest -> Xen -> Dom0 ->
> > > > > Xen -> Guest for each single character. This is a bit counterproductive and
> > > > > combined with the limit it makes it worse.
> > > > > 
> > > > > I would take a different approach on the BUSY bit. We can consider the queue
> > > > > between Xen and xenconsoled as outside of the UART. If the character is
> > > > > queued, then job done. I think this would improve quite a lot of the
> > > > > performance.
> > > > 
> > > > Yes. This.
> > > > 
> > > > The guest sees a register, which is essentially a synchronous interface
> > > > to the guest. The current code, as you already see, will issue one event
> > > > for every character. That's excessive.
> > > 
> > > I am actually not suggesting to modify that at the moment. I think you may
> > > have other trouble with the interaction between the user and th console by
> > > doing that. Imagine you want to print the prompt, it may lag a bit before
> > > getting it.
> > > 
> > > The only thing I suggest is to not set the BUSY bit in the UART everytime a
> > > character is queued.
> > > 
> > 
> > Did you come to that conclusion that this would work by looking at the
> > spec or Linux source code? I think it should conform to the spec, not a
> > specific guest. But you're the maintainer, you have the final say.
> 
> I read both the spec and the code. From the spec:
> 
> "UART busy. If this bit is set to 1, the UART is busy transmitting data.
> This bit remains set until the
> complete byte, including all the stop bits, has been sent from the shift
> register.
> This bit is set as soon as the transmit FIFO becomes non-empty, regardless
> of whether the UART is
> enabled or not."
> 
> Currently, we considered that the shared ring is the FIFO of the UART.
> Meaning that the BUSY bit is set until xenconsoled read everything.
> 
> I don't think implementing a FIFO is highly critical in an emulation (QEMU
> does not implement it for instance). And definitely using the shared ring
> brings slow down (involve multiple context switch).
> 
> I would suggest to take a different approach where the BUSY is only set if
> we can't add more data in the shared ring. This would be clear as soon as
> the ring has space.
> 
> If we really we could implement is small FIFO (the SBSA requested a least
> 32-entry separate for transmit and receive). But I don't think this is
> critically for a first approach.
> 

Sure, I think this is reasonable.

> > 
> > > > 
> > > > The interface between Xen and xenconsoled can be asynchronous, it can
> > > > opt to queue X characters before sending an event, also setup a oneshot
> > > > timer to avoid hanging.
> > > > 
> > > > This however has some other implications -- it might not be as reliable
> > > > as the original method because data is not guaranteed to hit backend. If
> > > > the guest crashes very early on, depending the actual implementation you
> > > > might not be able get the data.
> > > 
> > > Would it be possible to ask xenconsoled to dump everything on domain crash?
> > > Some kind of synchronization.
> > > 
> > 
> > No, not at the moment. If the data is still in Xen and destroyed,
> > xenconsoled can't do anything.
> 
> The vUART emulation is directly queuing the data, there are no intermediate
> buffer. So all the data would be in the shared ring available for
> xenconsoled to go through.
> 
> It would be quite a useful enhancement for when the guest crash.
> 

What I meant was actually "If the data is still in the ring". There is
no synchronisation between Xen and xenconsoled to let the latter pull
out all data before destroying the guest.

As it stands, if we go with the fully-synchronised approach for now,
that won't be a problem. But when you want to fiddle with the BUSY bit
or any other optimisation -- leaving more data in the ring -- that might
cause data loss.

I'm not against bumping the rate-limit, but I want a justification and
want to consider as many approaches as possible. Ultimately the final
decision is up to you and Stefano.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-15  9:49               ` Wei Liu
@ 2017-08-18 13:30                 ` Julien Grall
  2017-08-18 13:48                   ` Wei Liu
  0 siblings, 1 reply; 67+ messages in thread
From: Julien Grall @ 2017-08-18 13:30 UTC (permalink / raw)
  To: Wei Liu
  Cc: Stefano Stabellini, George Dunlap, Ian Jackson, Tim Deegan,
	Andrew Cooper, Jan Beulich, Andre Przywara, Bhupinder Thakur,
	xen-devel

Hi Wei,

On 15/08/17 10:49, Wei Liu wrote:
> On Thu, Aug 10, 2017 at 06:51:24PM +0100, Julien Grall wrote:
>>>>> The interface between Xen and xenconsoled can be asynchronous, it can
>>>>> opt to queue X characters before sending an event, also setup a oneshot
>>>>> timer to avoid hanging.
>>>>>
>>>>> This however has some other implications -- it might not be as reliable
>>>>> as the original method because data is not guaranteed to hit backend. If
>>>>> the guest crashes very early on, depending the actual implementation you
>>>>> might not be able get the data.
>>>>
>>>> Would it be possible to ask xenconsoled to dump everything on domain crash?
>>>> Some kind of synchronization.
>>>>
>>>
>>> No, not at the moment. If the data is still in Xen and destroyed,
>>> xenconsoled can't do anything.
>>
>> The vUART emulation is directly queuing the data, there are no intermediate
>> buffer. So all the data would be in the shared ring available for
>> xenconsoled to go through.
>>
>> It would be quite a useful enhancement for when the guest crash.
>>
>
> What I meant was actually "If the data is still in the ring". There is
> no synchronisation between Xen and xenconsoled to let the latter pull
> out all data before destroying the guest.

I don't think you would need synchronisation between Xen and xenconsoled 
at domain destruction. Given that xenconsoled would have to unmap the 
page, I was suggesting that it makes sure that cons == prod before 
destroying the instance. So all the character queued would be displayed 
on the console.

>
> As it stands, if we go with the fully-synchronised approach for now,
> that won't be a problem. But when you want to fiddle with the BUSY bit
> or any other optimisation -- leaving more data in the ring -- that might
> cause data loss.

The fully-synchronised solution is far too slow, we are looking at 
optimization to avoid the synchronization for every single character. 
This would leave some potential data loss (max a few characters) if the 
domain crashed.

>
> I'm not against bumping the rate-limit, but I want a justification and
> want to consider as many approaches as possible. Ultimately the final
> decision is up to you and Stefano.

I am not in favor of bumping the rate-limit at the moment. I believe we 
can solve the problem directly in the emulation. I spoke with Bhupinder 
about various solution that seem promising.

Cheers,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-18 13:30                 ` Julien Grall
@ 2017-08-18 13:48                   ` Wei Liu
  0 siblings, 0 replies; 67+ messages in thread
From: Wei Liu @ 2017-08-18 13:48 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andre Przywara,
	Ian Jackson, Tim Deegan, Jan Beulich, Andrew Cooper,
	Bhupinder Thakur, xen-devel

On Fri, Aug 18, 2017 at 02:30:03PM +0100, Julien Grall wrote:
> Hi Wei,
> 
> On 15/08/17 10:49, Wei Liu wrote:
> > On Thu, Aug 10, 2017 at 06:51:24PM +0100, Julien Grall wrote:
> > > > > > The interface between Xen and xenconsoled can be asynchronous, it can
> > > > > > opt to queue X characters before sending an event, also setup a oneshot
> > > > > > timer to avoid hanging.
> > > > > > 
> > > > > > This however has some other implications -- it might not be as reliable
> > > > > > as the original method because data is not guaranteed to hit backend. If
> > > > > > the guest crashes very early on, depending the actual implementation you
> > > > > > might not be able get the data.
> > > > > 
> > > > > Would it be possible to ask xenconsoled to dump everything on domain crash?
> > > > > Some kind of synchronization.
> > > > > 
> > > > 
> > > > No, not at the moment. If the data is still in Xen and destroyed,
> > > > xenconsoled can't do anything.
> > > 
> > > The vUART emulation is directly queuing the data, there are no intermediate
> > > buffer. So all the data would be in the shared ring available for
> > > xenconsoled to go through.
> > > 
> > > It would be quite a useful enhancement for when the guest crash.
> > > 
> > 
> > What I meant was actually "If the data is still in the ring". There is
> > no synchronisation between Xen and xenconsoled to let the latter pull
> > out all data before destroying the guest.
> 
> I don't think you would need synchronisation between Xen and xenconsoled at
> domain destruction. Given that xenconsoled would have to unmap the page, I
> was suggesting that it makes sure that cons == prod before destroying the
> instance. So all the character queued would be displayed on the console.

So this is relying on Dom0 holding a reference to the page so that the
page won't be freed. This sounds plausible.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011
  2017-08-07  9:14   ` Jan Beulich
@ 2017-08-21 10:28     ` Bhupinder Thakur
  2017-08-21 11:56       ` Jan Beulich
  0 siblings, 1 reply; 67+ messages in thread
From: Bhupinder Thakur @ 2017-08-21 10:28 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, xen-devel

Hi Jan,

On 7 August 2017 at 14:44, Jan Beulich <jbeulich@suse.com> wrote:
>>>> Bhupinder Thakur <bhupinder.thakur@linaro.org> 08/07/17 10:55 AM >>>
>>@@ -1148,6 +1149,24 @@ struct xen_domctl_psr_cat_op {
>>uint32_t target;    /* IN */
>>uint64_t data;      /* IN/OUT */
>>};
>>+
>>+struct xen_domctl_vuart_op {
>>+#define XEN_DOMCTL_VUART_OP_INIT  0
>>+        uint32_t cmd;           /* XEN_DOMCTL_VUART_OP_* */
>>+        domid_t console_domid;  /* IN */
>>+#define XEN_DOMCTL_VUART_TYPE_VPL011 0
>>+        uint32_t type;          /* IN - type of vuart.
>>+                                 *      Currently only vpl011 supported.
>>+                                 */
>>+        xen_pfn_t gfn;          /* IN - guest gfn to be used as a
>>+                                 *      ring buffer.
>>+                                 */
>>+        evtchn_port_t evtchn;   /* OUT - remote port of the event
>>+                                 *       channel used for sending
>>+                                 *       ring buffer events.
>>+                                 */
>>+};
>
> Please try to limit the amount of padding needed and make all remaining
> padding fields explicit. That should then also make obvious that using
> xen_pfn_t in domctl.h is not a good idea (the existing uses are bogus too
> afaict - in the getpageframeinfo3 case the handler deals with the differing
> width between 32- and 64-bit callers, and the cacheflush one is fine right
> now only because it's ARM-only).

Please correct me if I understood your comment wrongly.

I believe you are referring to re-ordering the fields in the above
structure so that the structure size is minimised.
Should I use type as unsigned long instead of xen_pfn_t in this structure?

Regards,
Bhupinder

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011
  2017-08-21 10:28     ` Bhupinder Thakur
@ 2017-08-21 11:56       ` Jan Beulich
  0 siblings, 0 replies; 67+ messages in thread
From: Jan Beulich @ 2017-08-21 11:56 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Julien Grall, xen-devel

>>> On 21.08.17 at 12:28, <bhupinder.thakur@linaro.org> wrote:
> Hi Jan,
> 
> On 7 August 2017 at 14:44, Jan Beulich <jbeulich@suse.com> wrote:
>>>>> Bhupinder Thakur <bhupinder.thakur@linaro.org> 08/07/17 10:55 AM >>>
>>>@@ -1148,6 +1149,24 @@ struct xen_domctl_psr_cat_op {
>>>uint32_t target;    /* IN */
>>>uint64_t data;      /* IN/OUT */
>>>};
>>>+
>>>+struct xen_domctl_vuart_op {
>>>+#define XEN_DOMCTL_VUART_OP_INIT  0
>>>+        uint32_t cmd;           /* XEN_DOMCTL_VUART_OP_* */
>>>+        domid_t console_domid;  /* IN */
>>>+#define XEN_DOMCTL_VUART_TYPE_VPL011 0
>>>+        uint32_t type;          /* IN - type of vuart.
>>>+                                 *      Currently only vpl011 supported.
>>>+                                 */
>>>+        xen_pfn_t gfn;          /* IN - guest gfn to be used as a
>>>+                                 *      ring buffer.
>>>+                                 */
>>>+        evtchn_port_t evtchn;   /* OUT - remote port of the event
>>>+                                 *       channel used for sending
>>>+                                 *       ring buffer events.
>>>+                                 */
>>>+};
>>
>> Please try to limit the amount of padding needed and make all remaining
>> padding fields explicit. That should then also make obvious that using
>> xen_pfn_t in domctl.h is not a good idea (the existing uses are bogus too
>> afaict - in the getpageframeinfo3 case the handler deals with the differing
>> width between 32- and 64-bit callers, and the cacheflush one is fine right
>> now only because it's ARM-only).
> 
> Please correct me if I understood your comment wrongly.
> 
> I believe you are referring to re-ordering the fields in the above
> structure so that the structure size is minimised.

Yes.

> Should I use type as unsigned long instead of xen_pfn_t in this structure?

No, uint64_aligned_t is what you want.

Jan


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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/25 v7] SBSA UART emulation support in Xen
  2017-08-14 13:54       ` Julien Grall
@ 2017-08-22 14:35         ` Julien Grall
  0 siblings, 0 replies; 67+ messages in thread
From: Julien Grall @ 2017-08-22 14:35 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Andre Przywara, xen-devel

Hi,

A quick update below.

On 14/08/17 14:54, Julien Grall wrote:
> On 14/08/17 08:52, Bhupinder Thakur wrote:
>> I could not reproduce the issue with the reduced buffer of 16 bytes
>> also. I think it may not be reproducible on the foundation model. I am
>> trying to bring up xen on an ARM machine here to reproduce the issue.
>>
>> While looking at the pl011 driver in linux, I see one potential case
>> where the the driver may send more data even when the TX FIFO is full.
>> It seems the pl011 driver expects that the TX interrupt must be raised
>> only when at least half of TX FIFO queue is empty.
>>
>> pl011_tx_chars() calls pl011_tx_char() in a loop for (fifosize/2)
>> number of times. Since these APIs are getting called in the interrupt
>> context, pl011_tx_char() does not check for TX FIFO full status
>> because it expects that fifosize/2 space is available.
>>
>> In the emulation logic, we should set the TX bit in the status
>> register only if at least space for 16 bytes is available (since SBSA
>> fifosize is 32). Currently, we may be setting the TX bit even if there
>> is space for 1 byte. In that scenario, the driver may write more data
>> then emulation logic can queue up.
>
> I understand that it is the behavior expected by Linux. However did you
> check it was compliant with the spec?
>
> If I looked at the PL011 (ARM DDI 0183G), the interrupt FIFO level is
> set via UARTIFLS. The reset value is half-way mark (i.e 16 byte).
>
> However, looking at the SBSA, this register is inexistent and I can't
> find anything mentioning the half-way mark. So we need some
> clarification here. Let me ask it.
>
> Meanwhile, trying the half-way mark would be good to see if it helps.

I got the confirmation that some clarification is needed in the spec. 
Until this is done, we should assume the halfway mark in our emulation.

Cheers,

>
> Cheers,
>

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

end of thread, other threads:[~2017-08-22 14:36 UTC | newest]

Thread overview: 67+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-07  8:52 [PATCH 00/25 v7] SBSA UART emulation support in Xen Bhupinder Thakur
2017-08-07  8:52 ` [PATCH 01/25 v7] xen/arm: vpl011: Define common ring buffer helper functions in console.h Bhupinder Thakur
2017-08-07  8:52 ` [PATCH 02/25 v7] xen/arm: vpl011: Add SBSA UART emulation in Xen Bhupinder Thakur
2017-08-07  8:52 ` [PATCH 03/25 v7] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart Bhupinder Thakur
2017-08-07  8:52 ` [PATCH 04/25 v7] xen/arm: vpl011: Add support for vuart in libxl Bhupinder Thakur
2017-08-08 13:38   ` Julien Grall
2017-08-08 13:42     ` Julien Grall
2017-08-07  8:52 ` [PATCH 05/25 v7] xen/arm: vpl011: Rearrange xen header includes in alphabetical order in domctl.c Bhupinder Thakur
2017-08-07  8:52 ` [PATCH 06/25 v7] xen/arm: vpl011: Add a new domctl API to initialize vpl011 Bhupinder Thakur
2017-08-07  9:14   ` Jan Beulich
2017-08-21 10:28     ` Bhupinder Thakur
2017-08-21 11:56       ` Jan Beulich
2017-08-08 13:11   ` Wei Liu
2017-08-08 13:30     ` Wei Liu
2017-08-08 13:47       ` Julien Grall
2017-08-08 13:56   ` Julien Grall
2017-08-07  8:52 ` [PATCH 07/25 v7] xen/arm: vpl011: Add a new vuart node in the xenstore Bhupinder Thakur
2017-08-07  8:53 ` [PATCH 08/25 v7] xen/arm: vpl011: Modify xenconsole to define and use a new console structure Bhupinder Thakur
2017-08-07  8:53 ` [PATCH 09/25 v7] xen/arm: vpl011: Rename the console structure field conspath to xspath Bhupinder Thakur
2017-08-07  8:53 ` [PATCH 10/25 v7] xen/arm: vpl011: Modify xenconsole functions to take console structure as input Bhupinder Thakur
2017-08-07  8:53 ` [PATCH 11/25 v7] xen/arm: vpl011: Add a new console_init function in xenconsole Bhupinder Thakur
2017-08-08 13:11   ` Wei Liu
2017-08-07  8:53 ` [PATCH 12/25 v7] xen/arm: vpl011: Add a new buffer_available " Bhupinder Thakur
2017-08-07  8:53 ` [PATCH 13/25 v7] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd " Bhupinder Thakur
2017-08-08 13:12   ` Wei Liu
2017-08-07  8:53 ` [PATCH 14/25 v7] xen/arm: vpl011: Add a new maybe_add_console_tty_fd " Bhupinder Thakur
2017-08-08 13:12   ` Wei Liu
2017-08-07  8:53 ` [PATCH 15/25 v7] xen/arm: vpl011: Add a new console_evtchn_unmask " Bhupinder Thakur
2017-08-08 13:15   ` Wei Liu
2017-08-07  8:53 ` [PATCH 16/25 v7] xen/arm: vpl011: Add a new handle_console_ring " Bhupinder Thakur
2017-08-08 13:16   ` Wei Liu
2017-08-07  8:53 ` [PATCH 17/25 v7] xen/arm: vpl011: Add a new handle_console_tty " Bhupinder Thakur
2017-08-07  8:53 ` [PATCH 18/25 v7] xen/arm: vpl011: Add a new console_cleanup " Bhupinder Thakur
2017-08-08 13:29   ` Wei Liu
2017-08-07  8:53 ` [PATCH 19/25 v7] xen/arm: vpl011: Add a new console_open_log " Bhupinder Thakur
2017-08-08 13:31   ` Wei Liu
2017-08-07  8:53 ` [PATCH 20/25 v7] xen/arm: vpl011: Add a new console_close_evtchn " Bhupinder Thakur
2017-08-07  8:53 ` [PATCH 21/25 v7] xen/arm: vpl011: Add support for multiple consoles " Bhupinder Thakur
2017-08-08 13:48   ` Wei Liu
2017-08-07  8:53 ` [PATCH 22/25 v7] xen/arm: vpl011: Add support for vuart console " Bhupinder Thakur
2017-08-08 13:52   ` Wei Liu
2017-08-07  8:53 ` [PATCH 23/25 v7] xen/arm: vpl011: Add a new vuart console type to xenconsole client Bhupinder Thakur
2017-08-07  8:53 ` [PATCH 24/25 v7] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree Bhupinder Thakur
2017-08-08 14:12   ` Julien Grall
2017-08-08 14:53     ` Bhupinder Thakur
2017-08-07  8:53 ` [PATCH 25/25 v7] xen/arm: vpl011: Update documentation for vuart console support Bhupinder Thakur
2017-08-08 14:15   ` Julien Grall
2017-08-08 15:59 ` [PATCH 00/25 v7] SBSA UART emulation support in Xen Julien Grall
2017-08-09 10:58   ` Bhupinder Thakur
2017-08-09 11:03     ` Wei Liu
2017-08-10  7:59       ` Bhupinder Thakur
2017-08-10 11:40         ` Wei Liu
2017-08-10 12:40           ` Julien Grall
2017-08-10 13:01             ` Wei Liu
2017-08-10 14:31               ` Julien Grall
2017-08-10 15:36                 ` Wei Liu
2017-08-10 14:26     ` Julien Grall
2017-08-10 16:00       ` Wei Liu
2017-08-10 16:11         ` Julien Grall
2017-08-10 16:38           ` Wei Liu
2017-08-10 17:51             ` Julien Grall
2017-08-15  9:49               ` Wei Liu
2017-08-18 13:30                 ` Julien Grall
2017-08-18 13:48                   ` Wei Liu
2017-08-14  7:52     ` Bhupinder Thakur
2017-08-14 13:54       ` Julien Grall
2017-08-22 14:35         ` Julien Grall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.