Skip to contentSkip to conversation

SDM Interface

RFC In review Baptiste Reynal 2 participants 10 messages Mar 18, 2016 – Apr 6, 2016

lore
Share & tools
lore
#0 lore raw

v2 cover SDM Interface

This patch series introduces a new device to QEMU, the SDM (Signal Distribution Module), intended to route inter-processor signals intra and inter QEMU instances.

To be as modular as possible, the device is split between the interface (virtio/platform) and the communication channel (local/socket).

A platform interface has been implemented to allow non-linux operating system (FreeRTOS for example) to use the SDM.

Also, various signals can be defined with hardware operations.

Those signals can be used, for example, to route interrupts or to trigger the boot of another QEMU instance.

When a signal is received on a SDM, it will check if the signal ID is associate to a hardware action that will be executed if found. The hardware action allows the signal to perform some actions (e.g triggering boot) before being forwarded to the operating system.

You can test thoses patches using modules and test application available on https://git.virtualopensystems.com/dev/qemu-het-tools :

- Platform module on branch sdm_test_mod_v1
- Virtio module on branch sdm_test_virtio_mod_v1
- Test application on branch sdm_test_app

QEMU code is avalaible here https://git.virtualopensystems.com/dev/qemu on branch rfc_v2.

Run QEMU instance:

./qemu-system-arm -nographic \
        -kernel zImage \
        -M virt -m 512M \
        -initrd busybox.cpio \
        -object sdm-communication-local,id=localcomm \
        -object sdm-signal,id=interrupt \
        -device sdm-platform,comm=localcomm,master,num-slaves=1,len-signals=1,signals[0]="interrupt" \
        -device sdm-platform,comm=localcomm,len-signals=1,len-signals=1,signals[0]="interrupt"

After loading the corresponding module (insmod sdm_test_mod.ko), you can send signal accross instances using the sdm-test application:
./sdm-test -s 0 0 0x0 0x0 0x0

This patch serie is a follow-up to "[RFC PATCH 0/8] Towards an Heterogeneous QEMU":
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00171.html

This work has been sponsored by Huawei Technologies Duesseldorf GmbH.

Baptiste Reynal (6):
hw/misc: sdm interface
hw/misc: sdm platform device
hw/arm: sysbus-fdt
hw/misc: sdm virtio device
hw/misc: sdm communication local
hw/misc: sdm communication socket

 default-configs/arm-softmmu.mak            |   1 +
 hw/arm/sysbus-fdt.c                        |  62 +++++++
 hw/misc/Makefile.objs                      |   7 +
 hw/misc/sdm-communication-local.c          |  89 ++++++++++
 hw/misc/sdm-communication-socket.c         | 140 +++++++++++++++
 hw/misc/sdm-communication.c                |  55 ++++++
 hw/misc/sdm-device.c                       |  66 ++++++++
 hw/misc/sdm-platform.c                     | 236 ++++++++++++++++++++++++++
 hw/misc/sdm-signal.c                       |  52 ++++++
 hw/virtio/Makefile.objs                    |   1 +
 hw/virtio/virtio-sdm.c                     | 262 +++++++++++++++++++++++++++++
 include/hw/misc/sdm-communication-local.h  |  35 ++++
 include/hw/misc/sdm-communication-socket.h |  42 +++++
 include/hw/misc/sdm-communication.h        |  54 ++++++
 include/hw/misc/sdm-device.h               |  58 +++++++
 include/hw/misc/sdm-platform.h             |  65 +++++++
 include/hw/misc/sdm-signal.h               |  60 +++++++
 include/hw/virtio/virtio-sdm.h             |  60 +++++++
 linux-headers/linux/virtio_sdm.h           |  52 ++++++
 19 files changed, 1397 insertions(+)
 create mode 100644 hw/misc/sdm-communication-local.c
 create mode 100644 hw/misc/sdm-communication-socket.c
 create mode 100644 hw/misc/sdm-communication.c
 create mode 100644 hw/misc/sdm-device.c
 create mode 100644 hw/misc/sdm-platform.c
 create mode 100644 hw/misc/sdm-signal.c
 create mode 100644 hw/virtio/virtio-sdm.c
 create mode 100644 include/hw/misc/sdm-communication-local.h
 create mode 100644 include/hw/misc/sdm-communication-socket.h
 create mode 100644 include/hw/misc/sdm-communication.h
 create mode 100644 include/hw/misc/sdm-device.h
 create mode 100644 include/hw/misc/sdm-platform.h
 create mode 100644 include/hw/misc/sdm-signal.h
 create mode 100644 include/hw/virtio/virtio-sdm.h
 create mode 100644 linux-headers/linux/virtio_sdm.h
Signature · 1 line
2.7.3
#1 lore raw

RFC v2 1/6 hw/misc: sdm interface

This patch forms the common skeleton code for the SDM interface.

The SDMDevice represents the interface with the machine, the SDMCommunication the communication channel and the SDMSignal represents an action to perform when a signal is received (for example to boot the machine).

---
 default-configs/arm-softmmu.mak     |  1 +
 hw/misc/Makefile.objs               |  4 +++
 hw/misc/sdm-communication.c         | 55 +++++++++++++++++++++++++++++++
 hw/misc/sdm-device.c                | 66 +++++++++++++++++++++++++++++++++++++
 hw/misc/sdm-signal.c                | 52 +++++++++++++++++++++++++++++
 include/hw/misc/sdm-communication.h | 54 ++++++++++++++++++++++++++++++
 include/hw/misc/sdm-device.h        | 58 ++++++++++++++++++++++++++++++++
 include/hw/misc/sdm-signal.h        | 60 +++++++++++++++++++++++++++++++++
 8 files changed, 350 insertions(+)
 create mode 100644 hw/misc/sdm-communication.c
 create mode 100644 hw/misc/sdm-device.c
 create mode 100644 hw/misc/sdm-signal.c
 create mode 100644 include/hw/misc/sdm-communication.h
 create mode 100644 include/hw/misc/sdm-device.h
 create mode 100644 include/hw/misc/sdm-signal.h
default-configs/arm-softmmu.mak +1 -0
index d9b90a5..4002e2b 100644
@@ -109,3 +109,4 @@ CONFIG_IOH3420=y
 CONFIG_I82801B11=y
 CONFIG_ACPI=y
 CONFIG_SMBIOS=y
+CONFIG_SDM=y
hw/misc/Makefile.objs +4 -0
index 4aa76ff..6e73901 100644
@@ -21,6 +21,10 @@ common-obj-$(CONFIG_MACIO) += macio/
 
 obj-$(CONFIG_IVSHMEM) += ivshmem.o
 
+obj-$(CONFIG_SDM) += sdm-device.o
+obj-$(CONFIG_SDM) += sdm-communication.o
+obj-$(CONFIG_SDM) += sdm-signal.o
+
 obj-$(CONFIG_REALVIEW) += arm_sysctl.o
 obj-$(CONFIG_NSERIES) += cbus.o
 obj-$(CONFIG_ECCMEMCTL) += eccmemctl.o
hw/misc/sdm-communication.c new file +55 -0

55 lines not on this page · raw message

hw/misc/sdm-device.c new file +66 -0

66 lines not on this page · raw message

hw/misc/sdm-signal.c new file +52 -0

52 lines not on this page · raw message

include/hw/misc/sdm-communication.h new file +54 -0

54 lines not on this page · raw message

include/hw/misc/sdm-device.h new file +58 -0

58 lines not on this page · raw message

include/hw/misc/sdm-signal.h new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
2.7.3
#2 lore raw

RFC v2 2/6 hw/misc: sdm platform device

In reply to Baptiste Reynal

This is the platform implementation for an SDM device.

Parameters are:
comm=[sdm_communication_id] specifies the communication channel master=[true/false] - configure the SDM device as master or slave num_slaves=[slave_number] - if master is true, specifies the number
of slaves
len-signals=[signals_number] - specifies the number of signals signals[x]=[signal_id] - add a signal to the device, with the ID x

---
 hw/misc/Makefile.objs          |   1 +
 hw/misc/sdm-platform.c         | 236 +++++++++++++++++++++++++++++++++++++++++
 include/hw/misc/sdm-platform.h |  65 ++++++++++++
 3 files changed, 302 insertions(+)
 create mode 100644 hw/misc/sdm-platform.c
 create mode 100644 include/hw/misc/sdm-platform.h
hw/misc/Makefile.objs +1 -0
index 6e73901..fc32161 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_IVSHMEM) += ivshmem.o
 obj-$(CONFIG_SDM) += sdm-device.o
 obj-$(CONFIG_SDM) += sdm-communication.o
 obj-$(CONFIG_SDM) += sdm-signal.o
+obj-$(CONFIG_SDM) += sdm-platform.o
 
 obj-$(CONFIG_REALVIEW) += arm_sysctl.o
 obj-$(CONFIG_NSERIES) += cbus.o
hw/misc/sdm-platform.c new file +236 -0

236 lines not on this page · raw message

include/hw/misc/sdm-platform.h new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
2.7.3
#3 lore raw

RFC v2 3/6 hw/arm: sysbus-fdt

In reply to Baptiste Reynal

Added node creation for dynamically instantiated sysbus SDM device. Support added for all ARM machines modeling dynamic sysbus devices instantiation.

---
 hw/arm/sysbus-fdt.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
hw/arm/sysbus-fdt.c +62 -0
index 9d28797..9ad7912 100644
@@ -28,6 +28,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/vfio/vfio-platform.h"
 #include "hw/vfio/vfio-calxeda-xgmac.h"
+#include "hw/misc/sdm-platform.h"
 #include "hw/arm/fdt.h"
 
 /*
@@ -123,9 +124,70 @@ fail_reg:
     return ret;
 }
 
+/**
+ * add_sdm_fdt_node
+ *
+ * Generates a node with following properties:
+ * compatible string, regs, interrupts
+ *
+ */
+static int add_sdm_fdt_node(SysBusDevice *sbdev, void *opaque)
+{
+    PlatformBusFDTData *data = opaque;
+    PlatformBusDevice *pbus = data->pbus;
+    const char sdm_compat[] = "sdm-ipi";
+    void *fdt = data->fdt;
+    const char *parent_node = data->pbus_node_name;
+    char *nodename;
+    int ret = -1;
+    uint32_t *irq_attr, *reg_attr;
+    uint64_t mmio_base, irq_number;
+
+    mmio_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
+    nodename = g_strdup_printf("%s/%s@%" PRIx64, parent_node,
+        TYPE_SDM_PLATFORM, mmio_base);
+    qemu_fdt_add_subnode(fdt, nodename);
+
+    qemu_fdt_setprop(fdt, nodename, "compatible", sdm_compat,
+        sizeof(sdm_compat));
+
+    /**
+     * There is only one MMIO region defined for the SDM device
+     */
+    reg_attr = g_new(uint32_t, 2);
+    mmio_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
+    reg_attr[0] = cpu_to_be32(mmio_base);
+    reg_attr[1] = cpu_to_be32(SDM_PLATFORM_SIZE);
+    ret = qemu_fdt_setprop(fdt, nodename, "reg", reg_attr,
+        2 * sizeof(uint32_t));
+    if (ret) {
+        error_report("could not set reg property of node %s", nodename);
+        goto fail;
+    }
+
+    irq_attr = g_new(uint32_t, 3);
+    irq_number = platform_bus_get_irqn(pbus, sbdev , 0)
+                     + data->irq_start;
+    irq_attr[0] = cpu_to_be32(GIC_FDT_IRQ_TYPE_SPI);
+    irq_attr[1] = cpu_to_be32(irq_number);
+    irq_attr[2] = cpu_to_be32(GIC_FDT_IRQ_FLAGS_EDGE_LO_HI);
+    ret = qemu_fdt_setprop(fdt, nodename, "interrupts",
+        irq_attr, 3 * sizeof(uint32_t));
+    if (ret) {
+        error_report("could not set interrupts property of node %s",
+                nodename);
+    }
+    g_free(irq_attr);
+fail:
+    g_free(reg_attr);
+    g_free(nodename);
+    return ret;
+}
+
 /* list of supported dynamic sysbus devices */
 static const NodeCreationPair add_fdt_node_functions[] = {
     {TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node},
+    {TYPE_SDM_PLATFORM, add_sdm_fdt_node},
     {"", NULL}, /* last element */
 };
 
Signature · 1 line
2.7.3
#4 lore raw

RFC v2 4/6 hw/misc: sdm virtio device

In reply to Baptiste Reynal

This is the virtio implementation for an SDM device.

Parameters are:
comm=[sdm_communication_id] specifies the communication channel master=[true/false] - configure the SDM device as master or slave num_slaves=[slave_number] - if master is true, specifies the number of slaves
len-signals=[signals_number] - specifies the number of signals signals[x]=[signal_id] - add a signal to the device, with the ID x

---
 hw/virtio/Makefile.objs          |   1 +
 hw/virtio/virtio-sdm.c           | 262 +++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/virtio-sdm.h   |  60 +++++++++
 linux-headers/linux/virtio_sdm.h |  52 ++++++++
 4 files changed, 375 insertions(+)
 create mode 100644 hw/virtio/virtio-sdm.c
 create mode 100644 include/hw/virtio/virtio-sdm.h
 create mode 100644 linux-headers/linux/virtio_sdm.h
hw/virtio/Makefile.objs +1 -0
index 19b224a..7e44bc4 100644
@@ -2,6 +2,7 @@ common-obj-y += virtio-rng.o
 common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 common-obj-y += virtio-bus.o
 common-obj-y += virtio-mmio.o
+obj-$(CONFIG_SDM) += virtio-sdm.o
 obj-$(CONFIG_VIRTIO) += dataplane/
 
 obj-y += virtio.o virtio-balloon.o 
hw/virtio/virtio-sdm.c new file +262 -0

262 lines not on this page · raw message

include/hw/virtio/virtio-sdm.h new file +60 -0

60 lines not on this page · raw message

linux-headers/linux/virtio_sdm.h new file +52 -0

52 lines not on this page · raw message

Signature · 1 line
2.7.3
#8 lore raw

RFC v2 5/6 hw/misc: sdm communication local

In reply to Baptiste Reynal

This patch introduces local implementation for SDM devices. It allows a master to communicate with a slave on the same QEMU instance.

Instantiation:
-object sdm-communication-local,id=<id>

---
 hw/misc/Makefile.objs                     |  1 +
 hw/misc/sdm-communication-local.c         | 89 +++++++++++++++++++++++++++++++
 include/hw/misc/sdm-communication-local.h | 35 ++++++++++++
 3 files changed, 125 insertions(+)
 create mode 100644 hw/misc/sdm-communication-local.c
 create mode 100644 include/hw/misc/sdm-communication-local.h
hw/misc/Makefile.objs +1 -0
index fc32161..6327c5a 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_SDM) += sdm-device.o
 obj-$(CONFIG_SDM) += sdm-communication.o
 obj-$(CONFIG_SDM) += sdm-signal.o
 obj-$(CONFIG_SDM) += sdm-platform.o
+obj-$(CONFIG_SDM) += sdm-communication-local.o
 
 obj-$(CONFIG_REALVIEW) += arm_sysctl.o
 obj-$(CONFIG_NSERIES) += cbus.o
hw/misc/sdm-communication-local.c new file +89 -0

89 lines not on this page · raw message

include/hw/misc/sdm-communication-local.h new file +35 -0
new file mode 100644
index 0000000..34d1718
@@ -0,0 +1,35 @@
+/*
+ * SDM Communication Local
+ *
+ * Copyright (C) 2016 - Virtual Open Systems
+ *
+ * Author: Baptiste Reynal <[email protected]>
+ *
+ * This works is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file un the top-level directory.
+ */
+#ifndef HW_SDM_COMM_LOCAL_H
+#define HW_SDM_COMM_LOCAL_H
+
+#include "hw/misc/sdm-communication.h"
+
+#define TYPE_SDM_COMMUNICATION_LOCAL "sdm-communication-local"
+#define SDM_COMMUNICATION_LOCAL(obj) \
+    OBJECT_CHECK(SDMCommunicationLocal, (obj), \
+            TYPE_SDM_COMMUNICATION_LOCAL)
+
+typedef struct SDMCommunicationLocal SDMCommunicationLocal;
+
+/**
+ * @SDMCommunicationLocal
+ *
+ * @parent: opaque parent object container
+ */
+struct SDMCommunicationLocal {
+    /* private */
+    SDMCommunication parent;
+
+    int num_slaves;
+    SDMDevice **slaves;
+};
+#endif
Signature · 1 line
2.7.3
#9 lore raw

RFC v2 6/6 hw/misc: sdm communication socket

In reply to Baptiste Reynal

This is the socket implementation of an SDM communication channel. A master device can communicate with a slave over a socket.

Parameters:
socket=[socket_id] - specifies the multi-client socket

This patch depends on "[RFC v2 1/1] backend: multi-client-socket"

---
 hw/misc/Makefile.objs                      |   1 +
 hw/misc/sdm-communication-socket.c         | 140 +++++++++++++++++++++++++++++
 include/hw/misc/sdm-communication-socket.h |  42 +++++++++
 3 files changed, 183 insertions(+)
 create mode 100644 hw/misc/sdm-communication-socket.c
 create mode 100644 include/hw/misc/sdm-communication-socket.h
hw/misc/Makefile.objs +1 -0
index 6327c5a..b9f75db 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_SDM) += sdm-communication.o
 obj-$(CONFIG_SDM) += sdm-signal.o
 obj-$(CONFIG_SDM) += sdm-platform.o
 obj-$(CONFIG_SDM) += sdm-communication-local.o
+obj-$(CONFIG_SDM) += sdm-communication-socket.o
 
 obj-$(CONFIG_REALVIEW) += arm_sysctl.o
 obj-$(CONFIG_NSERIES) += cbus.o
hw/misc/sdm-communication-socket.c new file +140 -0

140 lines not on this page · raw message

include/hw/misc/sdm-communication-socket.h new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.7.3
#5 lore raw

Re: [Qemu-devel] [RFC v2 4/6] hw/misc: sdm virtio device

In reply to Baptiste Reynal
Quoted 12 lines · Baptiste Reynal

This is the virtio implementation for an SDM device.

Parameters are:
comm=[sdm_communication_id] specifies the communication channel master=[true/false] - configure the SDM device as master or slave num_slaves=[slave_number] - if master is true, specifies the number of slaves
len-signals=[signals_number] - specifies the number of signals signals[x]=[signal_id] - add a signal to the device, with the ID x

Quoted 9 lines
---
 hw/virtio/Makefile.objs          |   1 +
 hw/virtio/virtio-sdm.c           | 262 +++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/virtio-sdm.h   |  60 +++++++++
 linux-headers/linux/virtio_sdm.h |  52 ++++++++
 4 files changed, 375 insertions(+)
 create mode 100644 hw/virtio/virtio-sdm.c
 create mode 100644 include/hw/virtio/virtio-sdm.h
 create mode 100644 linux-headers/linux/virtio_sdm.h

Have you posted a draft specification for this device to the VIRTIO Technical Committee?
https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=virtio

Normally the spec should be accepted into VIRTIO before patches can be merged.

Stefan

#6 lore raw

Re: [Qemu-devel] [RFC v2 4/6] hw/misc: sdm virtio device

Quoted 23 lines · Stefan Hajnoczi
Quoted 12 lines · Baptiste Reynal

This is the virtio implementation for an SDM device.

Parameters are:
comm=[sdm_communication_id] specifies the communication channel master=[true/false] - configure the SDM device as master or slave num_slaves=[slave_number] - if master is true, specifies the number of slaves
len-signals=[signals_number] - specifies the number of signals signals[x]=[signal_id] - add a signal to the device, with the ID x

Quoted 9 lines
---
 hw/virtio/Makefile.objs          |   1 +
 hw/virtio/virtio-sdm.c           | 262 +++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/virtio-sdm.h   |  60 +++++++++
 linux-headers/linux/virtio_sdm.h |  52 ++++++++
 4 files changed, 375 insertions(+)
 create mode 100644 hw/virtio/virtio-sdm.c
 create mode 100644 include/hw/virtio/virtio-sdm.h
 create mode 100644 linux-headers/linux/virtio_sdm.h
Quoted 6 lines

Have you posted a draft specification for this device to the VIRTIO Technical Committee?
https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=virtio

Normally the spec should be accepted into VIRTIO before patches can be merged.

Thanks for the comment, I wasn't aware of such process.
I'll wait for some comments on the SDM in general, then I'll send a draft spec to virtio.
Maybe this patchs should be dropped and reintroduced in a future patch series ?

Quoted 2 lines

Stefan

#7 lore raw

Re: [Qemu-devel] [RFC v2 4/6] hw/misc: sdm virtio device

Quoted 28 lines · Baptiste Reynal
Quoted 27 lines · Stefan Hajnoczi
Quoted 12 lines · Baptiste Reynal

This is the virtio implementation for an SDM device.

Parameters are:
comm=[sdm_communication_id] specifies the communication channel master=[true/false] - configure the SDM device as master or slave num_slaves=[slave_number] - if master is true, specifies the number of slaves
len-signals=[signals_number] - specifies the number of signals signals[x]=[signal_id] - add a signal to the device, with the ID x

Quoted 9 lines
---
 hw/virtio/Makefile.objs          |   1 +
 hw/virtio/virtio-sdm.c           | 262 +++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/virtio-sdm.h   |  60 +++++++++
 linux-headers/linux/virtio_sdm.h |  52 ++++++++
 4 files changed, 375 insertions(+)
 create mode 100644 hw/virtio/virtio-sdm.c
 create mode 100644 include/hw/virtio/virtio-sdm.h
 create mode 100644 linux-headers/linux/virtio_sdm.h

Have you posted a draft specification for this device to the VIRTIO Technical Committee?
https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=virtio

Quoted 6 lines
Quoted 2 lines

Normally the spec should be accepted into VIRTIO before patches can be merged.

Thanks for the comment, I wasn't aware of such process.
I'll wait for some comments on the SDM in general, then I'll send a draft spec to virtio.
Maybe this patchs should be dropped and reintroduced in a future patch series ?

These things tend to take time so I suggest doing it in parallel:
publish your QEMU patches while also trying to get your virtio spec change merged.