[PATCH 00/38] Rework ivshmem device to new specification - Part I

39 views
Skip to first unread message

Jan Kiszka

unread,
Jan 6, 2020, 7:19:55 AM1/6/20
to jailho...@googlegroups.com
These changes are fundamental to the inter-cell communication in
Jailhouse. The primary enhancements are:

- multiple peers, up to 12 per link with Jailhouse
- peer state table in shared memory (faster access)
- optional exclusive output regions per peer (unidirectional shared
memory sections)
- multiple interrupt vectors per device (up to 16 with Jailhouse)
- support for unprivileged and faster UIO access under Linux
(page-aligned MMIO registers, one-shot interrupt mode)
- separate PCI device ID (from Siemens pool) to avoid confusion with
QEMU's current ivshmem model

All this have been cooking in WIP state for a long while, the oldest
patch started in later 2016 in fact. While the specification of the
reworked device is still under discussion with the QEMU and virtio
communities, we need to move forward on the Jailhouse side to break the
chicken-egg issue: No specification without prove of its usability.

But the spec is also in a pretty advanced state by now. So, even if
there might be changes needed again after this is merged, to comply with
an ideally virtio-accepted specification, I would not expect major ones
anymore.

The changes are unfortunately invasive to the cell configurations, so
downstream configs needs to be updated. Please study the changes to
similar in-tree configs for the required adjustments. Some of them
should make future changes less invasive.

As this series is already large enough with only the core conversions,
updates and enhancements to inmates in order to exploit and test this
will come as "Part II" on top. What remains usable with this series
alone is ivshmem-net, provided you use the driver included in [1] or
[2].

Also broken for now will be jailhouse-image "latest" build. I have
started to adjust it locally and will make those changes available soon,
at least for testing. I'm not planning to change jailhouse-images in a
way that it continues to work for both 0.11 and current next, though.

But I'm planning for a Jailhouse 0.12 release after both parts are in.
So, in case you have something cooking that should hit that release,
make it ready as well!

Jan

[1] https://github.com/siemens/linux/commits/jailhouse-enabling/5.4
[2] http://git.kiszka.org/?p=linux.git;a=shortlog;h=refs/heads/queues/jailhouse

Jan Kiszka (38):
core: ivshmem: Use Siemens-provided device ID
core: Restrict asm/ivshmem.h to inclusion by jailhouse/ivshmem.h
core: ivshmem: Derive MMIO register region size from cell config
core: ivshmem: Enable unprivileged MMIO register access
configs: Use constants for bar_mask of ivshmem devices
core: ivshmem: Convert MMIO register region to 4K and 32-bit
core: ivshmem: Move MSI-X region into 32-bit BAR1
core: ivshmem: Move shared memory parameters into vendor specific
capability
core: ivshmem: Reorganize MMIO registers
core: ivshmem: Rename IVPOS register to ID
core: ivshmem: Add MAX_PEERS register
configs: Add field for shmem device ID
core: ivshmem: Use device ID from config
core: ivshmem: Add PCI-conforming INTx mask
core: ivshmem: Mask MSI-X vector on reset
core: ivshmem: Reintroduce ivshmem_update_msix
core: ivshmem: Fold ivshmem_write_msix_control into caller
core: ivshmem: Rename ivshmem_data to ivshmem_link
core: ivshmem: Avoid assumption about size of ivshmem_link
core: ivshmem: Introduce link pointer to ivshmem_endpoint
core: ivshmem: Relax peer matching rules
configs: x86: Rework ivshmem settings
configs: Factor out ivshmem memory region macro for network devices
configs: Move ivshmem memory regions at array start
core, configs: ivshmem: Add state table
core: ivshmem: Rework interrupt configuration and injection
core: ivshmem: Re-add target ID to doorbell register
core: ivshmem: Switch to ivshmem_endpoint as parameter of
arch_ivshmem_update_msix
core: ivshmem: Add support for multiple interrupt vectors
configs: Expand number of ivshmem vectors
core: ivshmem: Expand interrupt control to device level
core: ivshmem: Add one-shot interrupt mode
core, configs: ivshmem: Add shared memory output sections support
core, configs: ivshmem: Add multi-peer support
core: ivshmem: Drop revision protocol ID
core: ivshmem: Reorder ivshmem_endpoint fields
Documentation: Add specification of IVSHMEM v2 device
Documentation: Update inter-cell-communication

Documentation/inter-cell-communication.md | 79 ++++
Documentation/inter-cell-communication.txt | 76 ----
Documentation/ivshmem-v2-specification.md | 376 ++++++++++++++++++
configs/arm/bananapi-linux-demo.c | 20 +-
configs/arm/bananapi.c | 19 +-
configs/arm/emtrion-rzg1e-linux-demo.c | 20 +-
configs/arm/emtrion-rzg1e.c | 19 +-
configs/arm/emtrion-rzg1h-linux-demo.c | 20 +-
configs/arm/emtrion-rzg1h.c | 19 +-
configs/arm/emtrion-rzg1m-linux-demo.c | 20 +-
configs/arm/emtrion-rzg1m.c | 19 +-
configs/arm/jetson-tk1-linux-demo.c | 20 +-
configs/arm/jetson-tk1.c | 19 +-
configs/arm/orangepi0-linux-demo.c | 20 +-
configs/arm/orangepi0.c | 19 +-
configs/arm64/amd-seattle-linux-demo.c | 22 +-
configs/arm64/amd-seattle.c | 21 +-
configs/arm64/espressobin-linux-demo.c | 20 +-
configs/arm64/espressobin.c | 19 +-
configs/arm64/hikey-linux-demo.c | 20 +-
configs/arm64/hikey.c | 19 +-
configs/arm64/jetson-tx1-linux-demo.c | 20 +-
configs/arm64/jetson-tx1.c | 20 +-
configs/arm64/k3-am654-idk-linux-demo.c | 19 +-
configs/arm64/k3-am654-idk.c | 19 +-
configs/arm64/k3-j721e-evm-linux-demo.c | 20 +-
configs/arm64/k3-j721e-evm.c | 19 +-
configs/arm64/macchiatobin-linux-demo.c | 20 +-
configs/arm64/macchiatobin.c | 19 +-
configs/arm64/miriac-sbc-ls1046a-linux-demo.c | 24 +-
configs/arm64/miriac-sbc-ls1046a.c | 19 +-
configs/arm64/qemu-arm64-linux-demo.c | 20 +-
configs/arm64/qemu-arm64.c | 19 +-
configs/arm64/ultra96-linux-demo.c | 20 +-
configs/arm64/ultra96.c | 19 +-
configs/arm64/zynqmp-zcu102-linux-demo-2.c | 38 +-
configs/arm64/zynqmp-zcu102-linux-demo.c | 38 +-
configs/arm64/zynqmp-zcu102.c | 36 +-
configs/x86/apic-demo.c | 2 +-
configs/x86/e1000-demo.c | 2 +-
configs/x86/ioapic-demo.c | 2 +-
configs/x86/ivshmem-demo.c | 53 ++-
configs/x86/linux-x86-demo.c | 29 +-
configs/x86/pci-demo.c | 2 +-
configs/x86/qemu-x86.c | 75 ++--
configs/x86/smp-demo.c | 2 +-
configs/x86/tiny-demo.c | 2 +-
hypervisor/arch/arm-common/include/asm/ivshmem.h | 9 +-
hypervisor/arch/arm-common/ivshmem.c | 40 +-
hypervisor/arch/x86/include/asm/ivshmem.h | 9 +-
hypervisor/arch/x86/ivshmem.c | 77 ++--
hypervisor/arch/x86/vtd.c | 2 +-
hypervisor/include/jailhouse/ivshmem.h | 49 ++-
hypervisor/include/jailhouse/pci.h | 3 +-
hypervisor/ivshmem.c | 481 +++++++++++++----------
hypervisor/pci.c | 2 +-
include/jailhouse/cell-config.h | 50 ++-
scripts/header_check | 6 +
58 files changed, 1247 insertions(+), 925 deletions(-)
create mode 100644 Documentation/inter-cell-communication.md
delete mode 100644 Documentation/inter-cell-communication.txt
create mode 100644 Documentation/ivshmem-v2-specification.md

--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:55 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

We deviated too much from the original ivshmem, and we will even more.
Therefore, Siemens reserved the device ID 4106h from its pool under the
PCI vendor ID 110Ah. Start using it.

Note though that the device interface is not yet finalized under this
ID. Every driver developing against it must be prepared to see a moving
target, under Jailhouse as well as other implementations, specifically
for QEMU.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 53644deb..358c5b04 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -29,8 +29,8 @@
#include <jailhouse/processor.h>
#include <jailhouse/percpu.h>

-#define VIRTIO_VENDOR_ID 0x1af4
-#define IVSHMEM_DEVICE_ID 0x1110
+#define PCI_VENDOR_ID_SIEMENS 0x110a
+#define IVSHMEM_DEVICE_ID 0x4106

/* in jailhouse we can not allow dynamic remapping of the actual shared memory
* the location and the size are stored here. A memory-BAR size of 0 will tell
@@ -62,10 +62,10 @@ struct ivshmem_data {
static struct ivshmem_data *ivshmem_list;

static const u32 default_cspace[IVSHMEM_CFG_SIZE / sizeof(u32)] = {
- [0x00/4] = (IVSHMEM_DEVICE_ID << 16) | VIRTIO_VENDOR_ID,
+ [0x00/4] = (IVSHMEM_DEVICE_ID << 16) | PCI_VENDOR_ID_SIEMENS,
[0x04/4] = (PCI_STS_CAPS << 16),
[0x08/4] = PCI_DEV_CLASS_OTHER << 24,
- [0x2c/4] = (IVSHMEM_DEVICE_ID << 16) | VIRTIO_VENDOR_ID,
+ [0x2c/4] = (IVSHMEM_DEVICE_ID << 16) | PCI_VENDOR_ID_SIEMENS,
[0x34/4] = IVSHMEM_CFG_MSIX_CAP,
/* MSI-X capability */
[IVSHMEM_CFG_MSIX_CAP/4] = (IVSHMEM_MSIX_VECTORS - 1) << 16
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:56 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Make sure that unsupported accesses to the MMIO register region do not
raise immediate panic. We should rather ignore them. This allows the
cell OS to hand out the region to unprivileged users.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 41 ++++++++++++++++++-----------------------
1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index f4b698e0..0310cb47 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -90,50 +90,45 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
{
struct ivshmem_endpoint *ive = arg;

- if (mmio->address == IVSHMEM_REG_INTX_CTRL) {
+ switch (mmio->address) {
+ case IVSHMEM_REG_INTX_CTRL:
if (mmio->is_write) {
ive->intx_ctrl_reg = mmio->value & IVSHMEM_INTX_ENABLE;
arch_ivshmem_update_intx(ive);
} else {
mmio->value = ive->intx_ctrl_reg;
}
- return MMIO_HANDLED;
- }
-
- /* read-only IVPosition */
- if (mmio->address == IVSHMEM_REG_IVPOS && !mmio->is_write) {
+ break;
+ case IVSHMEM_REG_IVPOS:
+ /* read-only IVPosition */
mmio->value = ive->ivpos;
- return MMIO_HANDLED;
- }
-
- if (mmio->address == IVSHMEM_REG_DBELL) {
+ break;
+ case IVSHMEM_REG_DBELL:
if (mmio->is_write)
ivshmem_remote_interrupt(ive);
else
mmio->value = 0;
- return MMIO_HANDLED;
- }
-
- if (mmio->address == IVSHMEM_REG_LSTATE) {
+ break;
+ case IVSHMEM_REG_LSTATE:
if (mmio->is_write) {
ive->state = mmio->value;
ivshmem_remote_interrupt(ive);
} else {
mmio->value = ive->state;
}
- return MMIO_HANDLED;
- }
-
- if (mmio->address == IVSHMEM_REG_RSTATE && !mmio->is_write) {
+ break;
+ case IVSHMEM_REG_RSTATE:
+ /* read-only remote state */
spin_lock(&ive->remote_lock);
mmio->value = ive->remote ? ive->remote->state : 0;
spin_unlock(&ive->remote_lock);
- return MMIO_HANDLED;
+ break;
+ default:
+ /* ignore any other access */
+ mmio->value = 0;
+ break;
}
-
- panic_printk("FATAL: Invalid ivshmem register %s, number %02lx\n",
- mmio->is_write ? "write" : "read", mmio->address);
- return MMIO_ERROR;
+ return MMIO_HANDLED;
}

/**
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:56 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

The asm header will gain a dependency on the generic one and, thus,
should no longer be considered for direct inclusion. Adjust the header
check accordingly.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/arm-common/include/asm/ivshmem.h | 5 -----
hypervisor/arch/x86/include/asm/ivshmem.h | 5 -----
scripts/header_check | 6 ++++++
3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/hypervisor/arch/arm-common/include/asm/ivshmem.h b/hypervisor/arch/arm-common/include/asm/ivshmem.h
index cd7c8234..8110ca30 100644
--- a/hypervisor/arch/arm-common/include/asm/ivshmem.h
+++ b/hypervisor/arch/arm-common/include/asm/ivshmem.h
@@ -10,11 +10,6 @@
* the COPYING file in the top-level directory.
*/

-#ifndef _JAILHOUSE_ASM_IVSHMEM_H
-#define _JAILHOUSE_ASM_IVSHMEM_H
-
struct arch_pci_ivshmem {
u16 irq_id;
};
-
-#endif /* !_JAILHOUSE_ASM_IVSHMEM_H */
diff --git a/hypervisor/arch/x86/include/asm/ivshmem.h b/hypervisor/arch/x86/include/asm/ivshmem.h
index 081d4a27..6eb66da1 100644
--- a/hypervisor/arch/x86/include/asm/ivshmem.h
+++ b/hypervisor/arch/x86/include/asm/ivshmem.h
@@ -10,13 +10,8 @@
* the COPYING file in the top-level directory.
*/

-#ifndef _JAILHOUSE_ASM_IVSHMEM_H
-#define _JAILHOUSE_ASM_IVSHMEM_H
-
#include <asm/apic.h>

struct arch_pci_ivshmem {
struct apic_irq_message irq_msg;
};
-
-#endif /* !_JAILHOUSE_ASM_IVSHMEM_H */
diff --git a/scripts/header_check b/scripts/header_check
index 05e08fb3..2fa6e45f 100755
--- a/scripts/header_check
+++ b/scripts/header_check
@@ -42,6 +42,12 @@ test_compile()
prepend="#define __ASSEMBLY__
#include <jailhouse/types.h>"
;;
+ ivshmem.h)
+ if [ "$1" == "asm" ]; then
+ # must be included by jailhouse/ivshmem.h only
+ return
+ fi
+ ;;
traps.h)
if [ "$2" == "hypervisor/arch/arm-common/include/asm/traps.h" ]; then
# must be included by arm{,64}/include/asm/traps.h only
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:56 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

The BAR mask encodes the size of a PCI device resource. Use this to
allow a target-dependent setting via the cell configuration so that
alignment to the cell's page size becomes feasible. This will enable the
cell OS to map the MMIO region as a whole into user space.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 358c5b04..f4b698e0 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -46,7 +46,6 @@
#define IVSHMEM_REG_LSTATE 16
#define IVSHMEM_REG_RSTATE 20

-#define IVSHMEM_BAR0_SIZE 256
/*
* Make the region two times as large as the MSI-X table to guarantee a
* power-of-2 size (encoding constraint of a BAR).
@@ -221,8 +220,13 @@ static int ivshmem_write_command(struct ivshmem_endpoint *ive, u16 val)
}
if (val & PCI_CMD_MEM) {
ive->bar0_address = (*(u64 *)&device->bar[0]) & ~0xfL;
+ /*
+ * Derive the size of region 0 from its BAR mask.
+ * This reasonably assumes that all unmodifiable bits
+ * of the BAR, i.e. all zeros, are in the lower dword.
+ */
mmio_region_register(device->cell, ive->bar0_address,
- IVSHMEM_BAR0_SIZE,
+ ~device->info->bar_mask[0] + 1,
ivshmem_register_mmio, ive);

ive->bar4_address = (*(u64 *)&device->bar[4]) & ~0xfL;
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:56 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Page-alignment is required so that the cell OS can map the region as a
whole to its user space. If a cell may use larger minimal page sizes,
the mask for BAR 0 has to be adjusted accordingly. For now we assume all
are on 4K.

While at it, reduce the MMIO region to 32-bit which saves one BAR.
64-bit was needlessly wasteful.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 10 ++--------
include/jailhouse/cell-config.h | 4 ++--
2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 0310cb47..884388ca 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -214,12 +214,8 @@ static int ivshmem_write_command(struct ivshmem_endpoint *ive, u16 val)
mmio_region_unregister(device->cell, ive->bar4_address);
}
if (val & PCI_CMD_MEM) {
- ive->bar0_address = (*(u64 *)&device->bar[0]) & ~0xfL;
- /*
- * Derive the size of region 0 from its BAR mask.
- * This reasonably assumes that all unmodifiable bits
- * of the BAR, i.e. all zeros, are in the lower dword.
- */
+ ive->bar0_address = device->bar[0] & ~0xf;
+ /* Derive the size of region 0 from its BAR mask. */
mmio_region_register(device->cell, ive->bar0_address,
~device->info->bar_mask[0] + 1,
ivshmem_register_mmio, ive);
@@ -392,8 +388,6 @@ void ivshmem_reset(struct pci_device *device)
memset(device->bar, 0, sizeof(device->bar));
device->msix_registers.raw = 0;

- device->bar[0] = PCI_BAR_64BIT;
-
memcpy(ive->cspace, &default_cspace, sizeof(default_cspace));

ive->cspace[0x08/4] |= device->info->shmem_protocol << 8;
diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index 7ffe84fe..78726506 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -185,13 +185,13 @@ struct jailhouse_pci_device {

#define JAILHOUSE_IVSHMEM_BAR_MASK_INTX \
{ \
- 0xffffff00, 0xffffffff, 0x00000000, \
+ 0xfffff000, 0x00000000, 0x00000000, \
0x00000000, 0x00000000, 0x00000000, \
}

#define JAILHOUSE_IVSHMEM_BAR_MASK_MSIX \
{ \
- 0xffffff00, 0xffffffff, 0x00000000, \
+ 0xfffff000, 0x00000000, 0x00000000, \
0x00000000, 0xffffffe0, 0xffffffff, \
}

--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:57 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

There are two possible settings for this parameter, one for INTx and one
for MSI-X. Both are invariant for all archs, so let's pull them out of
the config files. That will also simplify upcoming changes.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
configs/arm/bananapi-linux-demo.c | 5 +----
configs/arm/bananapi.c | 5 +----
configs/arm/emtrion-rzg1e-linux-demo.c | 5 +----
configs/arm/emtrion-rzg1e.c | 5 +----
configs/arm/emtrion-rzg1h-linux-demo.c | 5 +----
configs/arm/emtrion-rzg1h.c | 5 +----
configs/arm/emtrion-rzg1m-linux-demo.c | 5 +----
configs/arm/emtrion-rzg1m.c | 5 +----
configs/arm/jetson-tk1-linux-demo.c | 5 +----
configs/arm/jetson-tk1.c | 5 +----
configs/arm/orangepi0-linux-demo.c | 5 +----
configs/arm/orangepi0.c | 5 +----
configs/arm64/amd-seattle-linux-demo.c | 5 +----
configs/arm64/amd-seattle.c | 5 +----
configs/arm64/espressobin-linux-demo.c | 5 +----
configs/arm64/espressobin.c | 5 +----
configs/arm64/hikey-linux-demo.c | 5 +----
configs/arm64/hikey.c | 5 +----
configs/arm64/jetson-tx1-linux-demo.c | 5 +----
configs/arm64/jetson-tx1.c | 5 +----
configs/arm64/k3-am654-idk-linux-demo.c | 5 +----
configs/arm64/k3-am654-idk.c | 5 +----
configs/arm64/k3-j721e-evm-linux-demo.c | 5 +----
configs/arm64/k3-j721e-evm.c | 5 +----
configs/arm64/macchiatobin-linux-demo.c | 5 +----
configs/arm64/macchiatobin.c | 5 +----
configs/arm64/miriac-sbc-ls1046a-linux-demo.c | 6 +-----
configs/arm64/miriac-sbc-ls1046a.c | 5 +----
configs/arm64/qemu-arm64-linux-demo.c | 5 +----
configs/arm64/qemu-arm64.c | 5 +----
configs/arm64/ultra96-linux-demo.c | 5 +----
configs/arm64/ultra96.c | 5 +----
configs/arm64/zynqmp-zcu102-linux-demo-2.c | 10 ++--------
configs/arm64/zynqmp-zcu102-linux-demo.c | 10 ++--------
configs/arm64/zynqmp-zcu102.c | 10 ++--------
configs/x86/ivshmem-demo.c | 5 +----
configs/x86/linux-x86-demo.c | 5 +----
configs/x86/qemu-x86.c | 10 ++--------
include/jailhouse/cell-config.h | 12 ++++++++++++
39 files changed, 54 insertions(+), 169 deletions(-)

diff --git a/configs/arm/bananapi-linux-demo.c b/configs/arm/bananapi-linux-demo.c
index fd1931f3..922d22ac 100644
--- a/configs/arm/bananapi-linux-demo.c
+++ b/configs/arm/bananapi-linux-demo.c
@@ -110,10 +110,7 @@ struct {
{
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/bananapi.c b/configs/arm/bananapi.c
index ffc4589c..475749d8 100644
--- a/configs/arm/bananapi.c
+++ b/configs/arm/bananapi.c
@@ -204,10 +204,7 @@ struct {
{
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 16,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1e-linux-demo.c b/configs/arm/emtrion-rzg1e-linux-demo.c
index 1bf08b66..74b884b4 100644
--- a/configs/arm/emtrion-rzg1e-linux-demo.c
+++ b/configs/arm/emtrion-rzg1e-linux-demo.c
@@ -159,10 +159,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1e.c b/configs/arm/emtrion-rzg1e.c
index e3872cf2..9f06c20c 100644
--- a/configs/arm/emtrion-rzg1e.c
+++ b/configs/arm/emtrion-rzg1e.c
@@ -232,10 +232,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 16,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1h-linux-demo.c b/configs/arm/emtrion-rzg1h-linux-demo.c
index ad2dceeb..e20d3dbb 100644
--- a/configs/arm/emtrion-rzg1h-linux-demo.c
+++ b/configs/arm/emtrion-rzg1h-linux-demo.c
@@ -173,10 +173,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1h.c b/configs/arm/emtrion-rzg1h.c
index 03e1be5b..e38c8fa5 100644
--- a/configs/arm/emtrion-rzg1h.c
+++ b/configs/arm/emtrion-rzg1h.c
@@ -358,10 +358,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 16,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1m-linux-demo.c b/configs/arm/emtrion-rzg1m-linux-demo.c
index d8b8441a..969dbd86 100644
--- a/configs/arm/emtrion-rzg1m-linux-demo.c
+++ b/configs/arm/emtrion-rzg1m-linux-demo.c
@@ -173,10 +173,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1m.c b/configs/arm/emtrion-rzg1m.c
index 84d68f62..aa11cc9b 100644
--- a/configs/arm/emtrion-rzg1m.c
+++ b/configs/arm/emtrion-rzg1m.c
@@ -267,10 +267,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 16,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/jetson-tk1-linux-demo.c b/configs/arm/jetson-tk1-linux-demo.c
index 7ee83f7a..bd209c87 100644
--- a/configs/arm/jetson-tk1-linux-demo.c
+++ b/configs/arm/jetson-tk1-linux-demo.c
@@ -113,10 +113,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/jetson-tk1.c b/configs/arm/jetson-tk1.c
index 7374ef44..343ff2ab 100644
--- a/configs/arm/jetson-tk1.c
+++ b/configs/arm/jetson-tk1.c
@@ -256,10 +256,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 21,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/orangepi0-linux-demo.c b/configs/arm/orangepi0-linux-demo.c
index 49ee10e9..ac620b16 100644
--- a/configs/arm/orangepi0-linux-demo.c
+++ b/configs/arm/orangepi0-linux-demo.c
@@ -101,10 +101,7 @@ struct {
{
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/orangepi0.c b/configs/arm/orangepi0.c
index 5b52f60a..7a1d6da0 100644
--- a/configs/arm/orangepi0.c
+++ b/configs/arm/orangepi0.c
@@ -145,10 +145,7 @@ struct {
{
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 8,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/amd-seattle-linux-demo.c b/configs/arm64/amd-seattle-linux-demo.c
index 5349323c..fb526c3e 100644
--- a/configs/arm64/amd-seattle-linux-demo.c
+++ b/configs/arm64/amd-seattle-linux-demo.c
@@ -141,10 +141,7 @@ struct {
/* 00:0f.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x0078,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0xffffffe0, 0xffffffff,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 6,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
diff --git a/configs/arm64/amd-seattle.c b/configs/arm64/amd-seattle.c
index b5cff3b3..4cd8580f 100644
--- a/configs/arm64/amd-seattle.c
+++ b/configs/arm64/amd-seattle.c
@@ -218,10 +218,7 @@ struct {
/* 00:0f.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x0078,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0xffffffe0, 0xffffffff,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 16,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
diff --git a/configs/arm64/espressobin-linux-demo.c b/configs/arm64/espressobin-linux-demo.c
index 92da96e9..97117201 100644
--- a/configs/arm64/espressobin-linux-demo.c
+++ b/configs/arm64/espressobin-linux-demo.c
@@ -103,10 +103,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/espressobin.c b/configs/arm64/espressobin.c
index a23dc24b..bd6b5b00 100644
--- a/configs/arm64/espressobin.c
+++ b/configs/arm64/espressobin.c
@@ -112,10 +112,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/hikey-linux-demo.c b/configs/arm64/hikey-linux-demo.c
index 76dda9da..073faa54 100644
--- a/configs/arm64/hikey-linux-demo.c
+++ b/configs/arm64/hikey-linux-demo.c
@@ -100,10 +100,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/hikey.c b/configs/arm64/hikey.c
index 7e6bb952..d9a72afb 100644
--- a/configs/arm64/hikey.c
+++ b/configs/arm64/hikey.c
@@ -118,10 +118,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/jetson-tx1-linux-demo.c b/configs/arm64/jetson-tx1-linux-demo.c
index b8698259..cd7e3d8d 100644
--- a/configs/arm64/jetson-tx1-linux-demo.c
+++ b/configs/arm64/jetson-tx1-linux-demo.c
@@ -117,10 +117,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/jetson-tx1.c b/configs/arm64/jetson-tx1.c
index d1fb21b8..646dc8c0 100644
--- a/configs/arm64/jetson-tx1.c
+++ b/configs/arm64/jetson-tx1.c
@@ -396,10 +396,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 42,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/k3-am654-idk-linux-demo.c b/configs/arm64/k3-am654-idk-linux-demo.c
index 5eab1502..ecc81246 100644
--- a/configs/arm64/k3-am654-idk-linux-demo.c
+++ b/configs/arm64/k3-am654-idk-linux-demo.c
@@ -140,10 +140,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/k3-am654-idk.c b/configs/arm64/k3-am654-idk.c
index a951a461..b952283c 100644
--- a/configs/arm64/k3-am654-idk.c
+++ b/configs/arm64/k3-am654-idk.c
@@ -214,10 +214,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/k3-j721e-evm-linux-demo.c b/configs/arm64/k3-j721e-evm-linux-demo.c
index 55938b85..af8299b5 100644
--- a/configs/arm64/k3-j721e-evm-linux-demo.c
+++ b/configs/arm64/k3-j721e-evm-linux-demo.c
@@ -265,10 +265,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/k3-j721e-evm.c b/configs/arm64/k3-j721e-evm.c
index ff6dcff4..78c4074a 100644
--- a/configs/arm64/k3-j721e-evm.c
+++ b/configs/arm64/k3-j721e-evm.c
@@ -352,10 +352,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 3,
.bdf = 0x00,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/macchiatobin-linux-demo.c b/configs/arm64/macchiatobin-linux-demo.c
index 6e18f62f..c2b317eb 100644
--- a/configs/arm64/macchiatobin-linux-demo.c
+++ b/configs/arm64/macchiatobin-linux-demo.c
@@ -111,10 +111,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/macchiatobin.c b/configs/arm64/macchiatobin.c
index 4811e8dd..9237e93d 100644
--- a/configs/arm64/macchiatobin.c
+++ b/configs/arm64/macchiatobin.c
@@ -121,10 +121,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
index ec2531b2..d07b04d0 100644
--- a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
+++ b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
@@ -123,11 +123,7 @@ struct {
{
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
- .bar_mask =
- {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/miriac-sbc-ls1046a.c b/configs/arm64/miriac-sbc-ls1046a.c
index 6f3ad198..d9dcb54f 100644
--- a/configs/arm64/miriac-sbc-ls1046a.c
+++ b/configs/arm64/miriac-sbc-ls1046a.c
@@ -457,10 +457,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = ARRAY_SIZE(config.mem_regions) - 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/qemu-arm64-linux-demo.c b/configs/arm64/qemu-arm64-linux-demo.c
index ed89413b..4f464503 100644
--- a/configs/arm64/qemu-arm64-linux-demo.c
+++ b/configs/arm64/qemu-arm64-linux-demo.c
@@ -104,10 +104,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/qemu-arm64.c b/configs/arm64/qemu-arm64.c
index 79e7cda6..29e87a4c 100644
--- a/configs/arm64/qemu-arm64.c
+++ b/configs/arm64/qemu-arm64.c
@@ -112,10 +112,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/ultra96-linux-demo.c b/configs/arm64/ultra96-linux-demo.c
index 7cbfd772..b24c7fac 100644
--- a/configs/arm64/ultra96-linux-demo.c
+++ b/configs/arm64/ultra96-linux-demo.c
@@ -103,10 +103,7 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/ultra96.c b/configs/arm64/ultra96.c
index bcf08772..1eeed354 100644
--- a/configs/arm64/ultra96.c
+++ b/configs/arm64/ultra96.c
@@ -104,10 +104,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo-2.c b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
index 02ec89e8..749b34b3 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo-2.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
@@ -104,20 +104,14 @@ struct {
/* 00:01.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 1 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
/* 00:02.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 2 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo.c b/configs/arm64/zynqmp-zcu102-linux-demo.c
index c30ed924..3e5e703d 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo.c
@@ -110,20 +110,14 @@ struct {
/* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
/* 00:02.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 2 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102.c b/configs/arm64/zynqmp-zcu102.c
index 9de04d6c..de3e3238 100644
--- a/configs/arm64/zynqmp-zcu102.c
+++ b/configs/arm64/zynqmp-zcu102.c
@@ -127,10 +127,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 0 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
@@ -138,10 +135,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 1,
.bdf = 1 << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/x86/ivshmem-demo.c b/configs/x86/ivshmem-demo.c
index 77b61b6f..f0a8f765 100644
--- a/configs/x86/ivshmem-demo.c
+++ b/configs/x86/ivshmem-demo.c
@@ -83,10 +83,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 0x0000,
.bdf = 0x0f << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0xffffffe0, 0xffffffff,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 2,
},
diff --git a/configs/x86/linux-x86-demo.c b/configs/x86/linux-x86-demo.c
index 2299544e..33fe0f76 100644
--- a/configs/x86/linux-x86-demo.c
+++ b/configs/x86/linux-x86-demo.c
@@ -145,10 +145,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 0x0,
.bdf = 0x0e << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0xffffffe0, 0xffffffff,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
diff --git a/configs/x86/qemu-x86.c b/configs/x86/qemu-x86.c
index 03768f12..58b8b75e 100644
--- a/configs/x86/qemu-x86.c
+++ b/configs/x86/qemu-x86.c
@@ -280,10 +280,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 0x0000,
.bdf = 0x0e << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0xffffffe0, 0xffffffff,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 14,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
@@ -292,10 +289,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 0x0000,
.bdf = 0x0f << 3,
- .bar_mask = {
- 0xffffff00, 0xffffffff, 0x00000000,
- 0x00000000, 0xffffffe0, 0xffffffff,
- },
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 15,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index 6ef9e513..7ffe84fe 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -183,6 +183,18 @@ struct jailhouse_pci_device {
__u8 padding[2];
} __attribute__((packed));

+#define JAILHOUSE_IVSHMEM_BAR_MASK_INTX \
+ { \
+ 0xffffff00, 0xffffffff, 0x00000000, \
+ 0x00000000, 0x00000000, 0x00000000, \
+ }
+
+#define JAILHOUSE_IVSHMEM_BAR_MASK_MSIX \
+ { \
+ 0xffffff00, 0xffffffff, 0x00000000, \
+ 0x00000000, 0xffffffe0, 0xffffffff, \
+ }
+
#define JAILHOUSE_PCI_EXT_CAP 0x8000

#define JAILHOUSE_PCICAPS_WRITE 0x0001
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:58 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This gives us more flexibility in extending the parameters we expose via
the config space. The capability is already layed out to leave holes for
upcoming extensions.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/include/jailhouse/ivshmem.h | 5 ++---
hypervisor/ivshmem.c | 34 +++++++++++++++++++---------------
2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index 59ce2e97..16d0cef0 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -1,7 +1,7 @@
/*
* Jailhouse, a Linux-based partitioning hypervisor
*
- * Copyright (c) Siemens AG, 2014-2016
+ * Copyright (c) Siemens AG, 2014-2019
*
* Authors:
* Henning Schild <henning...@siemens.com>
@@ -18,8 +18,7 @@
#include <asm/ivshmem.h>
#include <asm/spinlock.h>

-#define IVSHMEM_CFG_MSIX_CAP 0x50
-#define IVSHMEM_CFG_SIZE (IVSHMEM_CFG_MSIX_CAP + 12)
+#define IVSHMEM_CFG_SIZE 0x80

#define IVSHMEM_INTX_ENABLE 0x1

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 15592bab..739b91b9 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -1,7 +1,7 @@
/*
* Jailhouse, a Linux-based partitioning hypervisor
*
- * Copyright (c) Siemens AG, 2014-2016
+ * Copyright (c) Siemens AG, 2014-2019
*
* Authors:
* Henning Schild <henning...@siemens.com>
@@ -32,11 +32,13 @@
#define PCI_VENDOR_ID_SIEMENS 0x110a
#define IVSHMEM_DEVICE_ID 0x4106

-/* in jailhouse we can not allow dynamic remapping of the actual shared memory
- * the location and the size are stored here. A memory-BAR size of 0 will tell
- * device drivers that they are dealing with a special ivshmem device */
-#define IVSHMEM_CFG_SHMEM_PTR 0x40
-#define IVSHMEM_CFG_SHMEM_SZ 0x48
+#define IVSHMEM_CFG_VNDR_CAP 0x40
+#define IVSHMEM_CFG_MSIX_CAP (IVSHMEM_CFG_VNDR_CAP + \
+ IVSHMEM_CFG_VNDR_LEN)
+
+#define IVSHMEM_CFG_SHMEM_RW_SZ (IVSHMEM_CFG_VNDR_CAP + 0x08)
+#define IVSHMEM_CFG_SHMEM_ADDR (IVSHMEM_CFG_VNDR_CAP + 0x18)
+#define IVSHMEM_CFG_VNDR_LEN 0x20

#define IVSHMEM_MSIX_VECTORS 1

@@ -65,10 +67,11 @@ static const u32 default_cspace[IVSHMEM_CFG_SIZE / sizeof(u32)] = {
[0x04/4] = (PCI_STS_CAPS << 16),
[0x08/4] = PCI_DEV_CLASS_OTHER << 24,
[0x2c/4] = (IVSHMEM_DEVICE_ID << 16) | PCI_VENDOR_ID_SIEMENS,
- [0x34/4] = IVSHMEM_CFG_MSIX_CAP,
- /* MSI-X capability */
- [IVSHMEM_CFG_MSIX_CAP/4] = (IVSHMEM_MSIX_VECTORS - 1) << 16
- | (0x00 << 8) | PCI_CAP_ID_MSIX,
+ [PCI_CFG_CAPS/4] = IVSHMEM_CFG_VNDR_CAP,
+ [IVSHMEM_CFG_VNDR_CAP/4] = (IVSHMEM_CFG_VNDR_LEN << 16) |
+ (IVSHMEM_CFG_MSIX_CAP << 8) | PCI_CAP_ID_VNDR,
+ [IVSHMEM_CFG_MSIX_CAP/4] = (IVSHMEM_MSIX_VECTORS - 1) << 16 |
+ (0x00 << 8) | PCI_CAP_ID_MSIX,
[(IVSHMEM_CFG_MSIX_CAP + 0x4)/4] = 1,
[(IVSHMEM_CFG_MSIX_CAP + 0x8)/4] = 0x10 * IVSHMEM_MSIX_VECTORS | 1,
};
@@ -397,14 +400,15 @@ void ivshmem_reset(struct pci_device *device)
ive->cspace[PCI_CFG_INT/4] =
(((device->info->bdf >> 3) & 0x3) + 1) << 8;
/* disable MSI-X capability */
- ive->cspace[PCI_CFG_CAPS/4] = 0;
+ ive->cspace[IVSHMEM_CFG_VNDR_CAP/4] &= 0xffff00ff;
}

- ive->cspace[IVSHMEM_CFG_SHMEM_PTR/4] = (u32)ive->shmem->virt_start;
- ive->cspace[IVSHMEM_CFG_SHMEM_PTR/4 + 1] =
+ ive->cspace[IVSHMEM_CFG_SHMEM_RW_SZ/4] = (u32)ive->shmem->size;
+ ive->cspace[IVSHMEM_CFG_SHMEM_RW_SZ/4 + 1] =
+ (u32)(ive->shmem->size >> 32);
+ ive->cspace[IVSHMEM_CFG_SHMEM_ADDR/4] = (u32)ive->shmem->virt_start;
+ ive->cspace[IVSHMEM_CFG_SHMEM_ADDR/4 + 1] =
(u32)(ive->shmem->virt_start >> 32);
- ive->cspace[IVSHMEM_CFG_SHMEM_SZ/4] = (u32)ive->shmem->size;
- ive->cspace[IVSHMEM_CFG_SHMEM_SZ/4 + 1] = (u32)(ive->shmem->size >> 32);

ive->state = 0;
}
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:58 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

A number of changes to the MMIO registers are upcoming. This prepares
the layout for that and renames DBELL to more telling DOORBELL.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 739b91b9..3f023b49 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -48,11 +48,11 @@
*/
#define IVSHMEM_MSIX_SIZE (0x10 * IVSHMEM_MSIX_VECTORS * 2)

-#define IVSHMEM_REG_INTX_CTRL 0
-#define IVSHMEM_REG_IVPOS 8
-#define IVSHMEM_REG_DBELL 12
-#define IVSHMEM_REG_LSTATE 16
-#define IVSHMEM_REG_RSTATE 20
+#define IVSHMEM_REG_IVPOS 0x00
+#define IVSHMEM_REG_INTX_CTRL 0x08
+#define IVSHMEM_REG_DOORBELL 0x0c
+#define IVSHMEM_REG_LSTATE 0x10
+#define IVSHMEM_REG_RSTATE 0x14

struct ivshmem_data {
struct ivshmem_endpoint eps[2];
@@ -106,7 +106,7 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
/* read-only IVPosition */
mmio->value = ive->ivpos;
break;
- case IVSHMEM_REG_DBELL:
+ case IVSHMEM_REG_DOORBELL:
if (mmio->is_write)
ivshmem_remote_interrupt(ive);
else
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:58 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Compact the BAR usage and also reduce the MSI-X region to 32-bit again -
there is no need for 64-bit.

As both the MMIO register and the MSI-X region are now 32-bit, convert
their internal representation in ivshmem_endpoint to an u32 array.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/include/jailhouse/ivshmem.h | 3 +--
hypervisor/include/jailhouse/pci.h | 1 -
hypervisor/ivshmem.c | 36 ++++++++++++++++------------------
include/jailhouse/cell-config.h | 4 ++--
4 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index 8872876e..59ce2e97 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -32,8 +32,7 @@ struct ivshmem_endpoint {
u32 cspace[IVSHMEM_CFG_SIZE / sizeof(u32)];
u32 ivpos;
u32 state;
- u64 bar0_address;
- u64 bar4_address;
+ u32 ioregion[2];
struct pci_device *device;
const struct jailhouse_memory *shmem;
struct ivshmem_endpoint *remote;
diff --git a/hypervisor/include/jailhouse/pci.h b/hypervisor/include/jailhouse/pci.h
index 8f14ec7b..f463381d 100644
--- a/hypervisor/include/jailhouse/pci.h
+++ b/hypervisor/include/jailhouse/pci.h
@@ -23,7 +23,6 @@
#define PCI_CFG_STATUS 0x06
# define PCI_STS_CAPS (1 << 4)
#define PCI_CFG_BAR 0x10
-# define PCI_BAR_64BIT 0x4
#define PCI_CFG_BAR_END 0x27
#define PCI_CFG_ROMBAR 0x30
#define PCI_CFG_CAPS 0x34
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 884388ca..15592bab 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -40,18 +40,18 @@

#define IVSHMEM_MSIX_VECTORS 1

+/*
+ * Make the region two times as large as the MSI-X table to guarantee a
+ * power-of-2 size (encoding constraint of a BAR).
+ */
+#define IVSHMEM_MSIX_SIZE (0x10 * IVSHMEM_MSIX_VECTORS * 2)
+
#define IVSHMEM_REG_INTX_CTRL 0
#define IVSHMEM_REG_IVPOS 8
#define IVSHMEM_REG_DBELL 12
#define IVSHMEM_REG_LSTATE 16
#define IVSHMEM_REG_RSTATE 20

-/*
- * Make the region two times as large as the MSI-X table to guarantee a
- * power-of-2 size (encoding constraint of a BAR).
- */
-#define IVSHMEM_BAR4_SIZE (0x10 * IVSHMEM_MSIX_VECTORS * 2)
-
struct ivshmem_data {
struct ivshmem_endpoint eps[2];
u16 bdf;
@@ -69,8 +69,8 @@ static const u32 default_cspace[IVSHMEM_CFG_SIZE / sizeof(u32)] = {
/* MSI-X capability */
[IVSHMEM_CFG_MSIX_CAP/4] = (IVSHMEM_MSIX_VECTORS - 1) << 16
| (0x00 << 8) | PCI_CAP_ID_MSIX,
- [(IVSHMEM_CFG_MSIX_CAP + 0x4)/4] = 4,
- [(IVSHMEM_CFG_MSIX_CAP + 0x8)/4] = 0x10 * IVSHMEM_MSIX_VECTORS | 4,
+ [(IVSHMEM_CFG_MSIX_CAP + 0x4)/4] = 1,
+ [(IVSHMEM_CFG_MSIX_CAP + 0x8)/4] = 0x10 * IVSHMEM_MSIX_VECTORS | 1,
};

static void ivshmem_remote_interrupt(struct ivshmem_endpoint *ive)
@@ -210,19 +210,19 @@ static int ivshmem_write_command(struct ivshmem_endpoint *ive, u16 val)

if ((val & PCI_CMD_MEM) != (*cmd & PCI_CMD_MEM)) {
if (*cmd & PCI_CMD_MEM) {
- mmio_region_unregister(device->cell, ive->bar0_address);
- mmio_region_unregister(device->cell, ive->bar4_address);
+ mmio_region_unregister(device->cell, ive->ioregion[0]);
+ mmio_region_unregister(device->cell, ive->ioregion[1]);
}
if (val & PCI_CMD_MEM) {
- ive->bar0_address = device->bar[0] & ~0xf;
+ ive->ioregion[0] = device->bar[0] & ~0xf;
/* Derive the size of region 0 from its BAR mask. */
- mmio_region_register(device->cell, ive->bar0_address,
+ mmio_region_register(device->cell, ive->ioregion[0],
~device->info->bar_mask[0] + 1,
ivshmem_register_mmio, ive);

- ive->bar4_address = (*(u64 *)&device->bar[4]) & ~0xfL;
- mmio_region_register(device->cell, ive->bar4_address,
- IVSHMEM_BAR4_SIZE,
+ ive->ioregion[1] = device->bar[1] & ~0xf;
+ mmio_region_register(device->cell, ive->ioregion[1],
+ IVSHMEM_MSIX_SIZE,
ivshmem_msix_mmio, ive);
}
*cmd = (*cmd & ~PCI_CMD_MEM) | (val & PCI_CMD_MEM);
@@ -381,8 +381,8 @@ void ivshmem_reset(struct pci_device *device)
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;

if (ive->cspace[PCI_CFG_COMMAND/4] & PCI_CMD_MEM) {
- mmio_region_unregister(device->cell, ive->bar0_address);
- mmio_region_unregister(device->cell, ive->bar4_address);
+ mmio_region_unregister(device->cell, ive->ioregion[0]);
+ mmio_region_unregister(device->cell, ive->ioregion[1]);
}

memset(device->bar, 0, sizeof(device->bar));
@@ -398,8 +398,6 @@ void ivshmem_reset(struct pci_device *device)
(((device->info->bdf >> 3) & 0x3) + 1) << 8;
/* disable MSI-X capability */
ive->cspace[PCI_CFG_CAPS/4] = 0;
- } else {
- device->bar[4] = PCI_BAR_64BIT;
}

ive->cspace[IVSHMEM_CFG_SHMEM_PTR/4] = (u32)ive->shmem->virt_start;
diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index 78726506..64b59ca2 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -191,8 +191,8 @@ struct jailhouse_pci_device {

#define JAILHOUSE_IVSHMEM_BAR_MASK_MSIX \
{ \
- 0xfffff000, 0x00000000, 0x00000000, \
- 0x00000000, 0xffffffe0, 0xffffffff, \
+ 0xfffff000, 0xffffffe0, 0x00000000, \
+ 0x00000000, 0x00000000, 0x00000000, \
}

#define JAILHOUSE_PCI_EXT_CAP 0x8000
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:59 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This is a more logical name for the register as it returns a unique
identifier of the device.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/include/jailhouse/ivshmem.h | 2 +-
hypervisor/ivshmem.c | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index 16d0cef0..45cd3c4b 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -29,7 +29,7 @@

struct ivshmem_endpoint {
u32 cspace[IVSHMEM_CFG_SIZE / sizeof(u32)];
- u32 ivpos;
+ u32 id;
u32 state;
u32 ioregion[2];
struct pci_device *device;
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 3f023b49..a195140e 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -48,7 +48,7 @@
*/
#define IVSHMEM_MSIX_SIZE (0x10 * IVSHMEM_MSIX_VECTORS * 2)

-#define IVSHMEM_REG_IVPOS 0x00
+#define IVSHMEM_REG_ID 0x00
#define IVSHMEM_REG_INTX_CTRL 0x08
#define IVSHMEM_REG_DOORBELL 0x0c
#define IVSHMEM_REG_LSTATE 0x10
@@ -94,6 +94,10 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
struct ivshmem_endpoint *ive = arg;

switch (mmio->address) {
+ case IVSHMEM_REG_ID:
+ /* read-only ID */
+ mmio->value = ive->id;
+ break;
case IVSHMEM_REG_INTX_CTRL:
if (mmio->is_write) {
ive->intx_ctrl_reg = mmio->value & IVSHMEM_INTX_ENABLE;
@@ -102,10 +106,6 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
mmio->value = ive->intx_ctrl_reg;
}
break;
- case IVSHMEM_REG_IVPOS:
- /* read-only IVPosition */
- mmio->value = ive->ivpos;
- break;
case IVSHMEM_REG_DOORBELL:
if (mmio->is_write)
ivshmem_remote_interrupt(ive);
@@ -366,7 +366,7 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)

ive->device = device;
ive->shmem = mem;
- ive->ivpos = id;
+ ive->id = id;
device->ivshmem_endpoint = ive;
if (remote->device) {
ive->remote = remote;
@@ -440,7 +440,7 @@ void ivshmem_exit(struct pci_device *device)
} else {
for (ivp = &ivshmem_list; *ivp; ivp = &(*ivp)->next) {
iv = *ivp;
- if (&iv->eps[ive->ivpos] == ive) {
+ if (&iv->eps[ive->id] == ive) {
*ivp = iv->next;
page_free(&mem_pool, iv, 1);
break;
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:59 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This allows to set a stable ID that is independent of the cell creation
ordering. Such stability will be needed when defining ID-dependent
unidirectional shared memory regions.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
configs/arm/bananapi-linux-demo.c | 1 +
configs/arm/bananapi.c | 1 +
configs/arm/emtrion-rzg1e-linux-demo.c | 1 +
configs/arm/emtrion-rzg1e.c | 1 +
configs/arm/emtrion-rzg1h-linux-demo.c | 1 +
configs/arm/emtrion-rzg1h.c | 1 +
configs/arm/emtrion-rzg1m-linux-demo.c | 1 +
configs/arm/emtrion-rzg1m.c | 1 +
configs/arm/jetson-tk1-linux-demo.c | 1 +
configs/arm/jetson-tk1.c | 1 +
configs/arm/orangepi0-linux-demo.c | 1 +
configs/arm/orangepi0.c | 1 +
configs/arm64/amd-seattle-linux-demo.c | 1 +
configs/arm64/amd-seattle.c | 1 +
configs/arm64/espressobin-linux-demo.c | 1 +
configs/arm64/espressobin.c | 1 +
configs/arm64/hikey-linux-demo.c | 1 +
configs/arm64/hikey.c | 1 +
configs/arm64/jetson-tx1-linux-demo.c | 1 +
configs/arm64/jetson-tx1.c | 1 +
configs/arm64/k3-am654-idk-linux-demo.c | 1 +
configs/arm64/k3-am654-idk.c | 1 +
configs/arm64/k3-j721e-evm-linux-demo.c | 1 +
configs/arm64/k3-j721e-evm.c | 1 +
configs/arm64/macchiatobin-linux-demo.c | 1 +
configs/arm64/macchiatobin.c | 1 +
configs/arm64/miriac-sbc-ls1046a-linux-demo.c | 1 +
configs/arm64/miriac-sbc-ls1046a.c | 1 +
configs/arm64/qemu-arm64-linux-demo.c | 1 +
configs/arm64/qemu-arm64.c | 1 +
configs/arm64/ultra96-linux-demo.c | 1 +
configs/arm64/ultra96.c | 1 +
configs/arm64/zynqmp-zcu102-linux-demo-2.c | 2 ++
configs/arm64/zynqmp-zcu102-linux-demo.c | 2 ++
configs/arm64/zynqmp-zcu102.c | 2 ++
configs/x86/ivshmem-demo.c | 1 +
configs/x86/linux-x86-demo.c | 1 +
configs/x86/qemu-x86.c | 2 ++
include/jailhouse/cell-config.h | 8 +++++---
39 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/configs/arm/bananapi-linux-demo.c b/configs/arm/bananapi-linux-demo.c
index 922d22ac..070b909e 100644
--- a/configs/arm/bananapi-linux-demo.c
+++ b/configs/arm/bananapi-linux-demo.c
@@ -112,6 +112,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/bananapi.c b/configs/arm/bananapi.c
index 475749d8..73c8ea8e 100644
--- a/configs/arm/bananapi.c
+++ b/configs/arm/bananapi.c
@@ -206,6 +206,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 16,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1e-linux-demo.c b/configs/arm/emtrion-rzg1e-linux-demo.c
index 74b884b4..de984de8 100644
--- a/configs/arm/emtrion-rzg1e-linux-demo.c
+++ b/configs/arm/emtrion-rzg1e-linux-demo.c
@@ -161,6 +161,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1e.c b/configs/arm/emtrion-rzg1e.c
index 9f06c20c..0301e97d 100644
--- a/configs/arm/emtrion-rzg1e.c
+++ b/configs/arm/emtrion-rzg1e.c
@@ -234,6 +234,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 16,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1h-linux-demo.c b/configs/arm/emtrion-rzg1h-linux-demo.c
index e20d3dbb..77234e80 100644
--- a/configs/arm/emtrion-rzg1h-linux-demo.c
+++ b/configs/arm/emtrion-rzg1h-linux-demo.c
@@ -175,6 +175,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1h.c b/configs/arm/emtrion-rzg1h.c
index e38c8fa5..d8eec098 100644
--- a/configs/arm/emtrion-rzg1h.c
+++ b/configs/arm/emtrion-rzg1h.c
@@ -360,6 +360,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 16,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1m-linux-demo.c b/configs/arm/emtrion-rzg1m-linux-demo.c
index 969dbd86..6e028a67 100644
--- a/configs/arm/emtrion-rzg1m-linux-demo.c
+++ b/configs/arm/emtrion-rzg1m-linux-demo.c
@@ -175,6 +175,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1m.c b/configs/arm/emtrion-rzg1m.c
index aa11cc9b..c8ff9ec5 100644
--- a/configs/arm/emtrion-rzg1m.c
+++ b/configs/arm/emtrion-rzg1m.c
@@ -269,6 +269,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 16,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/jetson-tk1-linux-demo.c b/configs/arm/jetson-tk1-linux-demo.c
index bd209c87..cc605058 100644
--- a/configs/arm/jetson-tk1-linux-demo.c
+++ b/configs/arm/jetson-tk1-linux-demo.c
@@ -115,6 +115,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/jetson-tk1.c b/configs/arm/jetson-tk1.c
index 343ff2ab..2e8c0a02 100644
--- a/configs/arm/jetson-tk1.c
+++ b/configs/arm/jetson-tk1.c
@@ -258,6 +258,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 21,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/orangepi0-linux-demo.c b/configs/arm/orangepi0-linux-demo.c
index ac620b16..06dbf559 100644
--- a/configs/arm/orangepi0-linux-demo.c
+++ b/configs/arm/orangepi0-linux-demo.c
@@ -103,6 +103,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/orangepi0.c b/configs/arm/orangepi0.c
index 7a1d6da0..4cd5b49d 100644
--- a/configs/arm/orangepi0.c
+++ b/configs/arm/orangepi0.c
@@ -147,6 +147,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 8,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/amd-seattle-linux-demo.c b/configs/arm64/amd-seattle-linux-demo.c
index fb526c3e..1ced1d7f 100644
--- a/configs/arm64/amd-seattle-linux-demo.c
+++ b/configs/arm64/amd-seattle-linux-demo.c
@@ -144,6 +144,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 6,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/amd-seattle.c b/configs/arm64/amd-seattle.c
index 4cd8580f..a5414d6b 100644
--- a/configs/arm64/amd-seattle.c
+++ b/configs/arm64/amd-seattle.c
@@ -221,6 +221,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 16,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/espressobin-linux-demo.c b/configs/arm64/espressobin-linux-demo.c
index 97117201..d2b19988 100644
--- a/configs/arm64/espressobin-linux-demo.c
+++ b/configs/arm64/espressobin-linux-demo.c
@@ -105,6 +105,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/espressobin.c b/configs/arm64/espressobin.c
index bd6b5b00..e228b373 100644
--- a/configs/arm64/espressobin.c
+++ b/configs/arm64/espressobin.c
@@ -114,6 +114,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/hikey-linux-demo.c b/configs/arm64/hikey-linux-demo.c
index 073faa54..e17e0b04 100644
--- a/configs/arm64/hikey-linux-demo.c
+++ b/configs/arm64/hikey-linux-demo.c
@@ -102,6 +102,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/hikey.c b/configs/arm64/hikey.c
index d9a72afb..e9e2cd5f 100644
--- a/configs/arm64/hikey.c
+++ b/configs/arm64/hikey.c
@@ -120,6 +120,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/jetson-tx1-linux-demo.c b/configs/arm64/jetson-tx1-linux-demo.c
index cd7e3d8d..1b7e1263 100644
--- a/configs/arm64/jetson-tx1-linux-demo.c
+++ b/configs/arm64/jetson-tx1-linux-demo.c
@@ -119,6 +119,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/jetson-tx1.c b/configs/arm64/jetson-tx1.c
index 646dc8c0..e437d85d 100644
--- a/configs/arm64/jetson-tx1.c
+++ b/configs/arm64/jetson-tx1.c
@@ -398,6 +398,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 42,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/k3-am654-idk-linux-demo.c b/configs/arm64/k3-am654-idk-linux-demo.c
index ecc81246..5dab6d8a 100644
--- a/configs/arm64/k3-am654-idk-linux-demo.c
+++ b/configs/arm64/k3-am654-idk-linux-demo.c
@@ -142,6 +142,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 2,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/k3-am654-idk.c b/configs/arm64/k3-am654-idk.c
index b952283c..429ccdca 100644
--- a/configs/arm64/k3-am654-idk.c
+++ b/configs/arm64/k3-am654-idk.c
@@ -216,6 +216,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 2,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/k3-j721e-evm-linux-demo.c b/configs/arm64/k3-j721e-evm-linux-demo.c
index af8299b5..8a2222e1 100644
--- a/configs/arm64/k3-j721e-evm-linux-demo.c
+++ b/configs/arm64/k3-j721e-evm-linux-demo.c
@@ -267,6 +267,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 0,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/k3-j721e-evm.c b/configs/arm64/k3-j721e-evm.c
index 78c4074a..7e0dc031 100644
--- a/configs/arm64/k3-j721e-evm.c
+++ b/configs/arm64/k3-j721e-evm.c
@@ -354,6 +354,7 @@ struct {
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 0,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/macchiatobin-linux-demo.c b/configs/arm64/macchiatobin-linux-demo.c
index c2b317eb..418f3b31 100644
--- a/configs/arm64/macchiatobin-linux-demo.c
+++ b/configs/arm64/macchiatobin-linux-demo.c
@@ -113,6 +113,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/macchiatobin.c b/configs/arm64/macchiatobin.c
index 9237e93d..4eebaa32 100644
--- a/configs/arm64/macchiatobin.c
+++ b/configs/arm64/macchiatobin.c
@@ -123,6 +123,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
index d07b04d0..865fba63 100644
--- a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
+++ b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
@@ -125,6 +125,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/miriac-sbc-ls1046a.c b/configs/arm64/miriac-sbc-ls1046a.c
index d9dcb54f..a5b54ddc 100644
--- a/configs/arm64/miriac-sbc-ls1046a.c
+++ b/configs/arm64/miriac-sbc-ls1046a.c
@@ -459,6 +459,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = ARRAY_SIZE(config.mem_regions) - 1,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/qemu-arm64-linux-demo.c b/configs/arm64/qemu-arm64-linux-demo.c
index 4f464503..b095900f 100644
--- a/configs/arm64/qemu-arm64-linux-demo.c
+++ b/configs/arm64/qemu-arm64-linux-demo.c
@@ -106,6 +106,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/qemu-arm64.c b/configs/arm64/qemu-arm64.c
index 29e87a4c..51543183 100644
--- a/configs/arm64/qemu-arm64.c
+++ b/configs/arm64/qemu-arm64.c
@@ -114,6 +114,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 2,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/ultra96-linux-demo.c b/configs/arm64/ultra96-linux-demo.c
index b24c7fac..ed65ecf5 100644
--- a/configs/arm64/ultra96-linux-demo.c
+++ b/configs/arm64/ultra96-linux-demo.c
@@ -105,6 +105,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/ultra96.c b/configs/arm64/ultra96.c
index 1eeed354..2e038ae6 100644
--- a/configs/arm64/ultra96.c
+++ b/configs/arm64/ultra96.c
@@ -106,6 +106,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 2,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo-2.c b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
index 749b34b3..683bdee4 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo-2.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
@@ -106,6 +106,7 @@ struct {
.bdf = 1 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 2,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
/* 00:02.0 */ {
@@ -113,6 +114,7 @@ struct {
.bdf = 2 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo.c b/configs/arm64/zynqmp-zcu102-linux-demo.c
index 3e5e703d..0b93c799 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo.c
@@ -112,6 +112,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
/* 00:02.0 */ {
@@ -119,6 +120,7 @@ struct {
.bdf = 2 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/zynqmp-zcu102.c b/configs/arm64/zynqmp-zcu102.c
index de3e3238..090470dd 100644
--- a/configs/arm64/zynqmp-zcu102.c
+++ b/configs/arm64/zynqmp-zcu102.c
@@ -129,6 +129,7 @@ struct {
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 3,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
/* 0001:00:00.0 */ {
@@ -137,6 +138,7 @@ struct {
.bdf = 1 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_region = 4,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/x86/ivshmem-demo.c b/configs/x86/ivshmem-demo.c
index f0a8f765..7e0851d1 100644
--- a/configs/x86/ivshmem-demo.c
+++ b/configs/x86/ivshmem-demo.c
@@ -86,6 +86,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 2,
+ .shmem_dev_id = 1,
},
},
};
diff --git a/configs/x86/linux-x86-demo.c b/configs/x86/linux-x86-demo.c
index 33fe0f76..e324c84e 100644
--- a/configs/x86/linux-x86-demo.c
+++ b/configs/x86/linux-x86-demo.c
@@ -148,6 +148,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 3,
+ .shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
#ifdef CONFIG_QEMU_E1000E_ASSIGNMENT
diff --git a/configs/x86/qemu-x86.c b/configs/x86/qemu-x86.c
index 58b8b75e..9b2e0a4e 100644
--- a/configs/x86/qemu-x86.c
+++ b/configs/x86/qemu-x86.c
@@ -283,6 +283,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 14,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
{ /* IVSHMEM (demo) */
@@ -292,6 +293,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 15,
+ .shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
},
},
diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index 64b59ca2..a62fa1ee 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -176,11 +176,13 @@ struct jailhouse_pci_device {
__u16 num_msix_vectors;
__u16 msix_region_size;
__u64 msix_address;
- /** Memory region index of virtual shared memory device. */
+ /** Memory region index of shared memory device. */
__u32 shmem_region;
- /** PCI subclass and interface ID of virtual shared memory device. */
+ /** ID of shared memory device (0..1). */
+ __u8 shmem_dev_id;
+ __u8 padding;
+ /** PCI subclass and interface ID of shared memory device. */
__u16 shmem_protocol;
- __u8 padding[2];
} __attribute__((packed));

#define JAILHOUSE_IVSHMEM_BAR_MASK_INTX \
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:19:59 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Convert the creation order based ID assignment to the one now provided
by the cell configuration.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/include/jailhouse/ivshmem.h | 1 -
hypervisor/ivshmem.c | 13 ++++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index 45cd3c4b..dae67f44 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -29,7 +29,6 @@

struct ivshmem_endpoint {
u32 cspace[IVSHMEM_CFG_SIZE / sizeof(u32)];
- u32 id;
u32 state;
u32 ioregion[2];
struct pci_device *device;
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 7bebaff4..45306b85 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -99,7 +99,7 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
switch (mmio->address) {
case IVSHMEM_REG_ID:
/* read-only ID */
- mmio->value = ive->id;
+ mmio->value = ive->device->info->shmem_dev_id;
break;
case IVSHMEM_REG_MAX_PEERS:
/* read-only number of peers */
@@ -326,7 +326,7 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
struct ivshmem_endpoint *ive, *remote;
struct pci_device *peer_dev;
struct ivshmem_data *iv;
- unsigned int id = 0;
+ unsigned int id;

printk("Adding virtual PCI device %02x:%02x.%x to cell \"%s\"\n",
PCI_BDF_PARAMS(dev_info->bdf), cell->config->name);
@@ -340,8 +340,12 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
if (iv->bdf == dev_info->bdf)
break;

+ id = dev_info->shmem_dev_id;
+
if (iv) {
- id = iv->eps[0].device ? 1 : 0;
+ if (id >= IVSHMEM_MAX_PEERS)
+ return trace_error(-EINVAL);
+
if (iv->eps[id].device)
return trace_error(-EBUSY);

@@ -373,7 +377,6 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)

ive->device = device;
ive->shmem = mem;
- ive->id = id;
device->ivshmem_endpoint = ive;
if (remote->device) {
ive->remote = remote;
@@ -447,7 +450,7 @@ void ivshmem_exit(struct pci_device *device)
} else {
for (ivp = &ivshmem_list; *ivp; ivp = &(*ivp)->next) {
iv = *ivp;
- if (&iv->eps[ive->id] == ive) {
+ if (&iv->eps[ive->device->info->shmem_dev_id] == ive) {

Jan Kiszka

unread,
Jan 6, 2020, 7:19:59 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This allows the guest to discover the maximum number of peers connected
via an ivshmem device. We only support 2 so far.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index a195140e..7bebaff4 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -32,6 +32,8 @@
#define PCI_VENDOR_ID_SIEMENS 0x110a
#define IVSHMEM_DEVICE_ID 0x4106

+#define IVSHMEM_MAX_PEERS 2
+
#define IVSHMEM_CFG_VNDR_CAP 0x40
#define IVSHMEM_CFG_MSIX_CAP (IVSHMEM_CFG_VNDR_CAP + \
IVSHMEM_CFG_VNDR_LEN)
@@ -49,13 +51,14 @@
#define IVSHMEM_MSIX_SIZE (0x10 * IVSHMEM_MSIX_VECTORS * 2)

#define IVSHMEM_REG_ID 0x00
+#define IVSHMEM_REG_MAX_PEERS 0x04
#define IVSHMEM_REG_INTX_CTRL 0x08
#define IVSHMEM_REG_DOORBELL 0x0c
#define IVSHMEM_REG_LSTATE 0x10
#define IVSHMEM_REG_RSTATE 0x14

struct ivshmem_data {
- struct ivshmem_endpoint eps[2];
+ struct ivshmem_endpoint eps[IVSHMEM_MAX_PEERS];
u16 bdf;
struct ivshmem_data *next;
};
@@ -98,6 +101,10 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
/* read-only ID */
mmio->value = ive->id;
break;
+ case IVSHMEM_REG_MAX_PEERS:
+ /* read-only number of peers */
+ mmio->value = IVSHMEM_MAX_PEERS;
+ break;
case IVSHMEM_REG_INTX_CTRL:
if (mmio->is_write) {
ive->intx_ctrl_reg = mmio->value & IVSHMEM_INTX_ENABLE;
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:00 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This function consolidates the check for num_msix_vectors > 0 and
ivshmem_is_msix_masked, leaving arch_ivshmem_update_msix with less work.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/arm-common/ivshmem.c | 7 ++---
hypervisor/arch/x86/ivshmem.c | 4 +--
hypervisor/arch/x86/vtd.c | 2 +-
hypervisor/include/jailhouse/ivshmem.h | 5 ++--
hypervisor/ivshmem.c | 49 ++++++++++++++--------------------
hypervisor/pci.c | 2 +-
6 files changed, 28 insertions(+), 41 deletions(-)

diff --git a/hypervisor/arch/arm-common/ivshmem.c b/hypervisor/arch/arm-common/ivshmem.c
index ccf49aa5..7b98b6da 100644
--- a/hypervisor/arch/arm-common/ivshmem.c
+++ b/hypervisor/arch/arm-common/ivshmem.c
@@ -21,15 +21,12 @@ void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive)
irqchip_set_pending(NULL, irq_id);
}

-int arch_ivshmem_update_msix(struct pci_device *device)
+int arch_ivshmem_update_msix(struct pci_device *device, bool enabled)
{
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
unsigned int irq_id = 0;

- if (device->info->num_msix_vectors == 0)
- return 0;
-
- if (!ivshmem_is_msix_masked(ive)) {
+ if (enabled) {
/* FIXME: validate MSI-X target address */
irq_id = device->msix_vectors[0].data;
if (irq_id < 32 || !irqchip_irq_in_cell(device->cell, irq_id))
diff --git a/hypervisor/arch/x86/ivshmem.c b/hypervisor/arch/x86/ivshmem.c
index c1180012..909b7f8e 100644
--- a/hypervisor/arch/x86/ivshmem.c
+++ b/hypervisor/arch/x86/ivshmem.c
@@ -27,7 +27,7 @@ void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive)
apic_send_irq(irq_msg);
}

-int arch_ivshmem_update_msix(struct pci_device *device)
+int arch_ivshmem_update_msix(struct pci_device *device, bool enabled)
{
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
union x86_msi_vector msi = {
@@ -41,7 +41,7 @@ int arch_ivshmem_update_msix(struct pci_device *device)
ive->arch.irq_msg.valid = 0;
memory_barrier();

- if (ivshmem_is_msix_masked(ive))
+ if (!enabled)
return 0;

irq_msg = x86_pci_translate_msi(device, 0, 0, msi);
diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c
index 2ad7e228..8065d8fe 100644
--- a/hypervisor/arch/x86/vtd.c
+++ b/hypervisor/arch/x86/vtd.c
@@ -400,7 +400,7 @@ static int vtd_emulate_inv_int(unsigned int unit_no, unsigned int index)
device = pci_get_assigned_device(&root_cell, irte_usage->device_id);
/* On x86, ivshmem devices only support MSI-X. */
if (device && device->info->type == JAILHOUSE_PCI_TYPE_IVSHMEM)
- return arch_ivshmem_update_msix(device);
+ return ivshmem_update_msix(device);

irq_msg = iommu_get_remapped_root_int(unit_no, irte_usage->device_id,
irte_usage->vector, index);
diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index a60d4f0f..acf74834 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -48,8 +48,6 @@ enum pci_access ivshmem_pci_cfg_write(struct pci_device *device,
enum pci_access ivshmem_pci_cfg_read(struct pci_device *device, u16 address,
u32 *value);

-bool ivshmem_is_msix_masked(struct ivshmem_endpoint *ive);
-
/**
* Trigger interrupt on ivshmem endpoint.
* @param ive Ivshmem endpoint the interrupt should be raised at.
@@ -59,10 +57,11 @@ void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive);
/**
* Update cached MSI-X state (if any) of the given ivshmem device.
* @param device The device to be updated.
+ * @param enabled True if MSI-X is enabled and unmasked.
*
* @return 0 on success, negative error code otherwise.
*/
-int arch_ivshmem_update_msix(struct pci_device *device);
+int arch_ivshmem_update_msix(struct pci_device *device, bool enabled);

/**
* Update cached INTx state (if any) of the given ivshmem device.
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 0f52e7bd..760163a2 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -91,6 +91,23 @@ static void ivshmem_remote_interrupt(struct ivshmem_endpoint *ive)
spin_unlock(&ive->remote_lock);
}

+int ivshmem_update_msix(struct pci_device *device)
+{
+ struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
+ union pci_msix_registers cap;
+ bool enabled;
+
+ if (device->info->num_msix_vectors == 0)
+ return 0;
+
+ cap.raw = ive->cspace[IVSHMEM_CFG_MSIX_CAP/4];
+ enabled = cap.enable && !cap.fmask &&
+ !ive->device->msix_vectors[0].masked &&
+ ive->cspace[PCI_CFG_COMMAND/4] & PCI_CMD_MASTER;
+
+ return arch_ivshmem_update_msix(device, enabled);
+}
+
static void ivshmem_update_intx(struct ivshmem_endpoint *ive)
{
bool enabled = ive->intx_ctrl_reg & IVSHMEM_INTX_ENABLE;
@@ -150,32 +167,6 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
return MMIO_HANDLED;
}

-/**
- * Check if MSI-X doorbell interrupt is masked.
- * @param ive Ivshmem endpoint the mask should be checked for.
- *
- * @return True if MSI-X interrupt is masked.
- */
-bool ivshmem_is_msix_masked(struct ivshmem_endpoint *ive)
-{
- union pci_msix_registers c;
-
- /* global mask */
- c.raw = ive->cspace[IVSHMEM_CFG_MSIX_CAP/4];
- if (!c.enable || c.fmask)
- return true;
-
- /* local mask */
- if (ive->device->msix_vectors[0].masked)
- return true;
-
- /* PCI Bus Master */
- if (!(ive->cspace[PCI_CFG_COMMAND/4] & PCI_CMD_MASTER))
- return true;
-
- return false;
-}
-
static enum mmio_result ivshmem_msix_mmio(void *arg, struct mmio_access *mmio)
{
struct ivshmem_endpoint *ive = arg;
@@ -196,7 +187,7 @@ static enum mmio_result ivshmem_msix_mmio(void *arg, struct mmio_access *mmio)
} else {
if (mmio->is_write) {
msix_table[mmio->address / 4] = mmio->value;
- if (arch_ivshmem_update_msix(ive->device))
+ if (ivshmem_update_msix(ive->device))
return MMIO_ERROR;
} else {
mmio->value = msix_table[mmio->address / 4];
@@ -222,7 +213,7 @@ static int ivshmem_write_command(struct ivshmem_endpoint *ive, u16 val)

if ((val & PCI_CMD_MASTER) != (*cmd & PCI_CMD_MASTER)) {
*cmd = (*cmd & ~PCI_CMD_MASTER) | (val & PCI_CMD_MASTER);
- err = arch_ivshmem_update_msix(device);
+ err = ivshmem_update_msix(device);
if (err)
return err;
}
@@ -266,7 +257,7 @@ static int ivshmem_write_msix_control(struct ivshmem_endpoint *ive, u32 val)
newval.fmask = p->fmask;
if (ive->cspace[IVSHMEM_CFG_MSIX_CAP/4] != newval.raw) {
ive->cspace[IVSHMEM_CFG_MSIX_CAP/4] = newval.raw;
- return arch_ivshmem_update_msix(ive->device);
+ return ivshmem_update_msix(ive->device);
}
return 0;
}
diff --git a/hypervisor/pci.c b/hypervisor/pci.c
index b1a9613d..0f12e8b7 100644
--- a/hypervisor/pci.c
+++ b/hypervisor/pci.c
@@ -819,7 +819,7 @@ void pci_config_commit(struct cell *cell_added_removed)
goto error;
}
if (device->info->type == JAILHOUSE_PCI_TYPE_IVSHMEM) {
- err = arch_ivshmem_update_msix(device);
+ err = ivshmem_update_msix(device);
if (err) {
cap = NULL;
goto error;
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:00 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This is demanded by the PCI spec.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index ce0bed4c..0f52e7bd 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -425,6 +425,8 @@ void ivshmem_reset(struct pci_device *device)
(((device->info->bdf >> 3) & 0x3) + 1) << 8;
/* disable MSI-X capability */
ive->cspace[IVSHMEM_CFG_VNDR_CAP/4] &= 0xffff00ff;
+ } else {
+ device->msix_vectors[0].masked = 1;
}

ive->cspace[IVSHMEM_CFG_SHMEM_RW_SZ/4] = (u32)ive->shmem->size;
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:00 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Simple enough to add, and newer PCI specs demand this feature anyway:
allow to mask the INTx line via the command register.

For this purpose, factor out ivshmem_update_intx that determines the
state of the line prior to calling arch_ivshmem_update_intx. It also
skips over this call in case num_msix_vectors is non-null, offloading
this check from the arch function. Furthermore, move the calculation if
INTx is enabled and unmasked into that generic ivshmem_update_intx as
well.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/arm-common/ivshmem.c | 7 ++-----
hypervisor/arch/x86/ivshmem.c | 2 +-
hypervisor/include/jailhouse/ivshmem.h | 3 ++-
hypervisor/ivshmem.c | 16 +++++++++++++++-
4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/hypervisor/arch/arm-common/ivshmem.c b/hypervisor/arch/arm-common/ivshmem.c
index 19d300d3..ccf49aa5 100644
--- a/hypervisor/arch/arm-common/ivshmem.c
+++ b/hypervisor/arch/arm-common/ivshmem.c
@@ -41,14 +41,11 @@ int arch_ivshmem_update_msix(struct pci_device *device)
return 0;
}

-void arch_ivshmem_update_intx(struct ivshmem_endpoint *ive)
+void arch_ivshmem_update_intx(struct ivshmem_endpoint *ive, bool enabled)
{
u8 pin = ive->cspace[PCI_CFG_INT/4] >> 8;
struct pci_device *device = ive->device;

- if (device->info->num_msix_vectors != 0)
- return;
-
- ive->arch.irq_id = (ive->intx_ctrl_reg & IVSHMEM_INTX_ENABLE) ?
+ ive->arch.irq_id = enabled ?
(32 + device->cell->config->vpci_irq_base + pin - 1) : 0;
}
diff --git a/hypervisor/arch/x86/ivshmem.c b/hypervisor/arch/x86/ivshmem.c
index 7ec3ea70..c1180012 100644
--- a/hypervisor/arch/x86/ivshmem.c
+++ b/hypervisor/arch/x86/ivshmem.c
@@ -65,6 +65,6 @@ int arch_ivshmem_update_msix(struct pci_device *device)
return 0;
}

-void arch_ivshmem_update_intx(struct ivshmem_endpoint *ive)
+void arch_ivshmem_update_intx(struct ivshmem_endpoint *ive, bool enabled)
{
}
diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index dae67f44..a60d4f0f 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -67,8 +67,9 @@ int arch_ivshmem_update_msix(struct pci_device *device);
/**
* Update cached INTx state (if any) of the given ivshmem device.
* @param ive Ivshmem endpoint to be updated.
+ * @param enabled True if INTx is enabled and unmasked.
*/
-void arch_ivshmem_update_intx(struct ivshmem_endpoint *ive);
+void arch_ivshmem_update_intx(struct ivshmem_endpoint *ive, bool enabled);

/** @} IVSHMEM */
#endif /* !_JAILHOUSE_IVSHMEM_H */
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 45306b85..ce0bed4c 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -91,6 +91,15 @@ static void ivshmem_remote_interrupt(struct ivshmem_endpoint *ive)
spin_unlock(&ive->remote_lock);
}

+static void ivshmem_update_intx(struct ivshmem_endpoint *ive)
+{
+ bool enabled = ive->intx_ctrl_reg & IVSHMEM_INTX_ENABLE;
+ bool masked = ive->cspace[PCI_CFG_COMMAND/4] & PCI_CMD_INTX_OFF;
+
+ if (ive->device->info->num_msix_vectors == 0)
+ arch_ivshmem_update_intx(ive, enabled && !masked);
+}
+
static enum mmio_result ivshmem_register_mmio(void *arg,
struct mmio_access *mmio)
{
@@ -108,7 +117,7 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
case IVSHMEM_REG_INTX_CTRL:
if (mmio->is_write) {
ive->intx_ctrl_reg = mmio->value & IVSHMEM_INTX_ENABLE;
- arch_ivshmem_update_intx(ive);
+ ivshmem_update_intx(ive);
} else {
mmio->value = ive->intx_ctrl_reg;
}
@@ -238,6 +247,11 @@ static int ivshmem_write_command(struct ivshmem_endpoint *ive, u16 val)
*cmd = (*cmd & ~PCI_CMD_MEM) | (val & PCI_CMD_MEM);
}

+ if ((val & PCI_CMD_INTX_OFF) != (*cmd & PCI_CMD_INTX_OFF)) {
+ *cmd = (*cmd & ~PCI_CMD_INTX_OFF) | (val & PCI_CMD_INTX_OFF);
+ ivshmem_update_intx(ive);
+ }
+
return 0;
}

--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:01 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

It does currently fit into one page, but there is no reason to hard-code
this.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index ded50a20..b6f60d25 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -355,7 +355,7 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
"\"%s\" <--> \"%s\"\n",
cell->config->name, peer_dev->cell->config->name);
} else {
- link = page_alloc(&mem_pool, 1);
+ link = page_alloc(&mem_pool, PAGES(sizeof(*link)));
if (!link)
return -ENOMEM;

--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:01 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Represents more clearly what the structure is about: meta data
describing the link between two ivshmem endpoints.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index e270582d..ded50a20 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -57,13 +57,13 @@
#define IVSHMEM_REG_LSTATE 0x10
#define IVSHMEM_REG_RSTATE 0x14

-struct ivshmem_data {
+struct ivshmem_link {
struct ivshmem_endpoint eps[IVSHMEM_MAX_PEERS];
u16 bdf;
- struct ivshmem_data *next;
+ struct ivshmem_link *next;
};

-static struct ivshmem_data *ivshmem_list;
+static struct ivshmem_link *ivshmem_links;

static const u32 default_cspace[IVSHMEM_CFG_SIZE / sizeof(u32)] = {
[0x00/4] = (IVSHMEM_DEVICE_ID << 16) | PCI_VENDOR_ID_SIEMENS,
@@ -317,7 +317,7 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
const struct jailhouse_memory *mem, *peer_mem;
struct ivshmem_endpoint *ive, *remote;
struct pci_device *peer_dev;
- struct ivshmem_data *iv;
+ struct ivshmem_link *link;
unsigned int id;

printk("Adding virtual PCI device %02x:%02x.%x to cell \"%s\"\n",
@@ -328,20 +328,20 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)

mem = jailhouse_cell_mem_regions(cell->config) + dev_info->shmem_region;

- for (iv = ivshmem_list; iv; iv = iv->next)
- if (iv->bdf == dev_info->bdf)
+ for (link = ivshmem_links; link; link = link->next)
+ if (link->bdf == dev_info->bdf)
break;

id = dev_info->shmem_dev_id;

- if (iv) {
+ if (link) {
if (id >= IVSHMEM_MAX_PEERS)
return trace_error(-EINVAL);

- if (iv->eps[id].device)
+ if (link->eps[id].device)
return trace_error(-EBUSY);

- peer_dev = iv->eps[id ^ 1].device;
+ peer_dev = link->eps[id ^ 1].device;
peer_mem = jailhouse_cell_mem_regions(peer_dev->cell->config) +
peer_dev->info->shmem_region;

@@ -355,17 +355,17 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
"\"%s\" <--> \"%s\"\n",
cell->config->name, peer_dev->cell->config->name);
} else {
- iv = page_alloc(&mem_pool, 1);
- if (!iv)
+ link = page_alloc(&mem_pool, 1);
+ if (!link)
return -ENOMEM;

- iv->bdf = dev_info->bdf;
- iv->next = ivshmem_list;
- ivshmem_list = iv;
+ link->bdf = dev_info->bdf;
+ link->next = ivshmem_links;
+ ivshmem_links = link;
}

- ive = &iv->eps[id];
- remote = &iv->eps[id ^ 1];
+ ive = &link->eps[id];
+ remote = &link->eps[id ^ 1];

ive->device = device;
ive->shmem = mem;
@@ -426,7 +426,7 @@ void ivshmem_exit(struct pci_device *device)
{
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
struct ivshmem_endpoint *remote = ive->remote;
- struct ivshmem_data **ivp, *iv;
+ struct ivshmem_link **linkp, *link;

if (remote) {
/*
@@ -442,11 +442,11 @@ void ivshmem_exit(struct pci_device *device)

ive->device = NULL;
} else {
- for (ivp = &ivshmem_list; *ivp; ivp = &(*ivp)->next) {
- iv = *ivp;
- if (&iv->eps[ive->device->info->shmem_dev_id] == ive) {
- *ivp = iv->next;
- page_free(&mem_pool, iv, 1);
+ for (linkp = &ivshmem_links; *linkp; linkp = &(*linkp)->next) {
+ link = *linkp;
+ if (&link->eps[ive->device->info->shmem_dev_id] == ive) {
+ *linkp = link->next;
+ page_free(&mem_pool, link, 1);
break;
}
}
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:01 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Using pci_msix_registers to model the update of the MSI-X control
register does not really simplify the code. Rather use a plain mask that
contains all modifiable bits, PCI_MSIX_CTRL_RW_MASK, and perform the
update in ivshmem_pci_cfg_write directly, analogously to the vendor
capability.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/include/jailhouse/pci.h | 2 ++
hypervisor/ivshmem.c | 21 ++++-----------------
2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/hypervisor/include/jailhouse/pci.h b/hypervisor/include/jailhouse/pci.h
index f463381d..ee530c03 100644
--- a/hypervisor/include/jailhouse/pci.h
+++ b/hypervisor/include/jailhouse/pci.h
@@ -100,6 +100,8 @@ union pci_msix_registers {
/** @publicsection */
} __attribute__((packed));

+#define PCI_MSIX_CTRL_RW_MASK (BIT_MASK(15, 14) << 16)
+
/** MSI-X table entry. See PCI specification. */
union pci_msix_vector {
/** @privatesection */
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 760163a2..e270582d 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -246,22 +246,6 @@ static int ivshmem_write_command(struct ivshmem_endpoint *ive, u16 val)
return 0;
}

-static int ivshmem_write_msix_control(struct ivshmem_endpoint *ive, u32 val)
-{
- union pci_msix_registers *p = (union pci_msix_registers *)&val;
- union pci_msix_registers newval = {
- .raw = ive->cspace[IVSHMEM_CFG_MSIX_CAP/4]
- };
-
- newval.enable = p->enable;
- newval.fmask = p->fmask;
- if (ive->cspace[IVSHMEM_CFG_MSIX_CAP/4] != newval.raw) {
- ive->cspace[IVSHMEM_CFG_MSIX_CAP/4] = newval.raw;
- return ivshmem_update_msix(ive->device);
- }
- return 0;
-}
-
/**
* Handler for MMIO-write-accesses to PCI config space of this virtual device.
* @param device The device that access should be performed on.
@@ -289,7 +273,10 @@ enum pci_access ivshmem_pci_cfg_write(struct pci_device *device,
return PCI_ACCESS_REJECT;
break;
case IVSHMEM_CFG_MSIX_CAP / 4:
- if (ivshmem_write_msix_control(ive, value))
+ ive->cspace[IVSHMEM_CFG_MSIX_CAP/4] &= ~PCI_MSIX_CTRL_RW_MASK;
+ ive->cspace[IVSHMEM_CFG_MSIX_CAP/4] |=
+ value & PCI_MSIX_CTRL_RW_MASK;
+ if (ivshmem_update_msix(device))
return PCI_ACCESS_REJECT;
}
return PCI_ACCESS_DONE;
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:01 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Will be used when looking up an interrupt target by ID.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/include/jailhouse/ivshmem.h | 3 +++
hypervisor/ivshmem.c | 10 +++++-----
2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index acf74834..b62564d8 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -27,11 +27,14 @@
* @{
*/

+struct ivshmem_link;
+
struct ivshmem_endpoint {
u32 cspace[IVSHMEM_CFG_SIZE / sizeof(u32)];
u32 state;
u32 ioregion[2];
struct pci_device *device;
+ struct ivshmem_link *link;
const struct jailhouse_memory *shmem;
struct ivshmem_endpoint *remote;
spinlock_t remote_lock;
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index b6f60d25..e048d136 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -368,6 +368,7 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
remote = &link->eps[id ^ 1];

ive->device = device;
+ ive->link = link;
ive->shmem = mem;
device->ivshmem_endpoint = ive;
if (remote->device) {
@@ -426,7 +427,7 @@ void ivshmem_exit(struct pci_device *device)
{
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
struct ivshmem_endpoint *remote = ive->remote;
- struct ivshmem_link **linkp, *link;
+ struct ivshmem_link **linkp;

if (remote) {
/*
@@ -443,10 +444,9 @@ void ivshmem_exit(struct pci_device *device)
ive->device = NULL;
} else {
for (linkp = &ivshmem_links; *linkp; linkp = &(*linkp)->next) {
- link = *linkp;
- if (&link->eps[ive->device->info->shmem_dev_id] == ive) {
- *linkp = link->next;
- page_free(&mem_pool, link, 1);
+ if (*linkp == ive->link) {
+ *linkp = ive->link->next;
+ page_free(&mem_pool, ive->link, 1);
break;
}
}
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:02 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Align the ivshmem-net size of x86 with arm/arm64 to 1 MB. This will
allow to use the same upcoming memory region macro for all archs. The
smaller demo ivshmem device is moved into the MB below the networking
device. This MB will take further devices later on.

To make space for this, move the demo inmates one MB down in physical
memory.

As we are reordering the memory reservation, also align the PCI device
IDs accordingly, swapping 00:0e.0 and 00:0f.0 for demo and network
device.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
configs/x86/apic-demo.c | 2 +-
configs/x86/e1000-demo.c | 2 +-
configs/x86/ioapic-demo.c | 2 +-
configs/x86/ivshmem-demo.c | 8 ++++----
configs/x86/linux-x86-demo.c | 6 +++---
configs/x86/pci-demo.c | 2 +-
configs/x86/qemu-x86.c | 26 +++++++++++++-------------
configs/x86/smp-demo.c | 2 +-
configs/x86/tiny-demo.c | 2 +-
9 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/configs/x86/apic-demo.c b/configs/x86/apic-demo.c
index 3660a74f..d014f267 100644
--- a/configs/x86/apic-demo.c
+++ b/configs/x86/apic-demo.c
@@ -48,7 +48,7 @@ struct {

.mem_regions = {
/* RAM */ {
- .phys_start = 0x3f000000,
+ .phys_start = 0x3ef00000,
.virt_start = 0,
.size = 0x00100000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
diff --git a/configs/x86/e1000-demo.c b/configs/x86/e1000-demo.c
index 7ea43e38..8ae31220 100644
--- a/configs/x86/e1000-demo.c
+++ b/configs/x86/e1000-demo.c
@@ -51,7 +51,7 @@ struct {

.mem_regions = {
/* RAM */ {
- .phys_start = 0x3ef00000,
+ .phys_start = 0x3ee00000,
.virt_start = 0,
.size = 0x00100000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
diff --git a/configs/x86/ioapic-demo.c b/configs/x86/ioapic-demo.c
index 60745cb5..863b3ea7 100644
--- a/configs/x86/ioapic-demo.c
+++ b/configs/x86/ioapic-demo.c
@@ -49,7 +49,7 @@ struct {

.mem_regions = {
/* RAM */ {
- .phys_start = 0x3ef00000,
+ .phys_start = 0x3ee00000,
.virt_start = 0,
.size = 0x00100000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
diff --git a/configs/x86/ivshmem-demo.c b/configs/x86/ivshmem-demo.c
index 7e0851d1..c6c1f4c2 100644
--- a/configs/x86/ivshmem-demo.c
+++ b/configs/x86/ivshmem-demo.c
@@ -51,7 +51,7 @@ struct {

.mem_regions = {
/* RAM */ {
- .phys_start = 0x3f000000,
+ .phys_start = 0x3ee00000,
.virt_start = 0,
.size = 0x00100000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
@@ -65,8 +65,8 @@ struct {
},
/* IVSHMEM shared memory region */
{
- .phys_start = 0x3f1ff000,
- .virt_start = 0x3f1ff000,
+ .phys_start = 0x3f0f0000,
+ .virt_start = 0x3f0f0000,
.size = 0x1000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_ROOTSHARED,
@@ -82,7 +82,7 @@ struct {
{
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 0x0000,
- .bdf = 0x0f << 3,
+ .bdf = 0x0e << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 2,
diff --git a/configs/x86/linux-x86-demo.c b/configs/x86/linux-x86-demo.c
index e324c84e..69ea2bfa 100644
--- a/configs/x86/linux-x86-demo.c
+++ b/configs/x86/linux-x86-demo.c
@@ -71,7 +71,7 @@ struct {
/* high RAM */ {
.phys_start = 0x3a700000,
.virt_start = 0x00200000,
- .size = 0x4a00000,
+ .size = 0x4900000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
@@ -80,7 +80,7 @@ struct {
{
.phys_start = 0x3f100000,
.virt_start = 0x3f100000,
- .size = 0xff000,
+ .size = 0x100000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_ROOTSHARED,
},
@@ -144,7 +144,7 @@ struct {
{
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 0x0,
- .bdf = 0x0e << 3,
+ .bdf = 0x0f << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
.shmem_region = 3,
diff --git a/configs/x86/pci-demo.c b/configs/x86/pci-demo.c
index 92fba8e5..a4115744 100644
--- a/configs/x86/pci-demo.c
+++ b/configs/x86/pci-demo.c
@@ -51,7 +51,7 @@ struct {

.mem_regions = {
/* RAM */ {
- .phys_start = 0x3ef00000,
+ .phys_start = 0x3ee00000,
.virt_start = 0,
.size = 0x00100000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
diff --git a/configs/x86/qemu-x86.c b/configs/x86/qemu-x86.c
index 9b2e0a4e..9621370c 100644
--- a/configs/x86/qemu-x86.c
+++ b/configs/x86/qemu-x86.c
@@ -84,7 +84,7 @@ struct {
/* RAM (inmates) */ {
.phys_start = 0x3a600000,
.virt_start = 0x3a600000,
- .size = 0x4b00000,
+ .size = 0x4a00000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA,
},
@@ -171,18 +171,18 @@ struct {
.size = 0x1000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
},
- /* IVSHMEM shared memory region (networking) */
+ /* IVSHMEM shared memory region (demo) */
{
- .phys_start = 0x3f100000,
- .virt_start = 0x3f100000,
- .size = 0xff000,
+ .phys_start = 0x3f0f0000,
+ .virt_start = 0x3f0f0000,
+ .size = 0x1000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
},
- /* IVSHMEM shared memory region (demo) */
+ /* IVSHMEM shared memory region (networking) */
{
- .phys_start = 0x3f1ff000,
- .virt_start = 0x3f1ff000,
- .size = 0x1000,
+ .phys_start = 0x3f100000,
+ .virt_start = 0x3f100000,
+ .size = 0x100000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
},
},
@@ -276,7 +276,7 @@ struct {
.msix_region_size = 0x1000,
.msix_address = 0xfebda000,
},
- { /* IVSHMEM (networking) */
+ { /* IVSHMEM (demo) */
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 0x0000,
.bdf = 0x0e << 3,
@@ -284,9 +284,9 @@ struct {
.num_msix_vectors = 1,
.shmem_region = 14,
.shmem_dev_id = 0,
- .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
+ .shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
},
- { /* IVSHMEM (demo) */
+ { /* IVSHMEM (networking) */
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 0x0000,
.bdf = 0x0f << 3,
@@ -294,7 +294,7 @@ struct {
.num_msix_vectors = 1,
.shmem_region = 15,
.shmem_dev_id = 0,
- .shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
+ .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},

diff --git a/configs/x86/smp-demo.c b/configs/x86/smp-demo.c
index e3ba41fd..35bf9504 100644
--- a/configs/x86/smp-demo.c
+++ b/configs/x86/smp-demo.c
@@ -47,7 +47,7 @@ struct {

.mem_regions = {
/* RAM */ {
- .phys_start = 0x3ef00000,
+ .phys_start = 0x3ee00000,
.virt_start = 0,
.size = 0x00100000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
diff --git a/configs/x86/tiny-demo.c b/configs/x86/tiny-demo.c
index c36a73db..464c7acb 100644
--- a/configs/x86/tiny-demo.c
+++ b/configs/x86/tiny-demo.c
@@ -50,7 +50,7 @@ struct {

.mem_regions = {
/* RAM */ {
- .phys_start = 0x3ef00000,
+ .phys_start = 0x3ee00000,
.virt_start = 0,
.size = 0x00100000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:02 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This helps with defining the default case of the memory region that an
ivshmem network device needs. Just provide the start address, and
JAILHOUSE_SHMEM_NET_REGIONS will create a shared 1 MB region. The macro
already takes the device ID in order to be prepared for upcoming
unidirectional regions.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
configs/arm/bananapi-linux-demo.c | 9 ++-------
configs/arm/bananapi.c | 8 ++------
configs/arm/emtrion-rzg1e-linux-demo.c | 9 ++-------
configs/arm/emtrion-rzg1e.c | 8 ++------
configs/arm/emtrion-rzg1h-linux-demo.c | 9 ++-------
configs/arm/emtrion-rzg1h.c | 8 ++------
configs/arm/emtrion-rzg1m-linux-demo.c | 9 ++-------
configs/arm/emtrion-rzg1m.c | 8 ++------
configs/arm/jetson-tk1-linux-demo.c | 9 ++-------
configs/arm/jetson-tk1.c | 8 ++------
configs/arm/orangepi0-linux-demo.c | 9 ++-------
configs/arm/orangepi0.c | 8 ++------
configs/arm64/amd-seattle-linux-demo.c | 9 ++-------
configs/arm64/amd-seattle.c | 8 ++------
configs/arm64/espressobin-linux-demo.c | 9 ++-------
configs/arm64/espressobin.c | 8 ++------
configs/arm64/hikey-linux-demo.c | 9 ++-------
configs/arm64/hikey.c | 8 ++------
configs/arm64/jetson-tx1-linux-demo.c | 9 ++-------
configs/arm64/jetson-tx1.c | 8 ++------
configs/arm64/k3-am654-idk-linux-demo.c | 8 ++------
configs/arm64/k3-am654-idk.c | 8 ++------
configs/arm64/k3-j721e-evm-linux-demo.c | 9 ++-------
configs/arm64/k3-j721e-evm.c | 8 ++------
configs/arm64/macchiatobin-linux-demo.c | 9 ++-------
configs/arm64/macchiatobin.c | 8 ++------
configs/arm64/miriac-sbc-ls1046a-linux-demo.c | 9 ++-------
configs/arm64/miriac-sbc-ls1046a.c | 8 ++------
configs/arm64/qemu-arm64-linux-demo.c | 9 ++-------
configs/arm64/qemu-arm64.c | 8 ++------
configs/arm64/ultra96-linux-demo.c | 9 ++-------
configs/arm64/ultra96.c | 8 ++------
configs/arm64/zynqmp-zcu102-linux-demo-2.c | 18 ++++--------------
configs/arm64/zynqmp-zcu102-linux-demo.c | 18 ++++--------------
configs/arm64/zynqmp-zcu102.c | 16 ++++------------
configs/x86/linux-x86-demo.c | 8 +-------
configs/x86/qemu-x86.c | 7 +------
include/jailhouse/cell-config.h | 9 +++++++++
38 files changed, 87 insertions(+), 260 deletions(-)

diff --git a/configs/arm/bananapi-linux-demo.c b/configs/arm/bananapi-linux-demo.c
index 070b909e..474ad6d1 100644
--- a/configs/arm/bananapi-linux-demo.c
+++ b/configs/arm/bananapi-linux-demo.c
@@ -81,13 +81,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm/bananapi.c b/configs/arm/bananapi.c
index 73c8ea8e..7f7393ff 100644
--- a/configs/arm/bananapi.c
+++ b/configs/arm/bananapi.c
@@ -182,12 +182,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
diff --git a/configs/arm/emtrion-rzg1e-linux-demo.c b/configs/arm/emtrion-rzg1e-linux-demo.c
index de984de8..4dbaecff 100644
--- a/configs/arm/emtrion-rzg1e-linux-demo.c
+++ b/configs/arm/emtrion-rzg1e-linux-demo.c
@@ -116,13 +116,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm/emtrion-rzg1e.c b/configs/arm/emtrion-rzg1e.c
index 0301e97d..744e7aeb 100644
--- a/configs/arm/emtrion-rzg1e.c
+++ b/configs/arm/emtrion-rzg1e.c
@@ -196,12 +196,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
diff --git a/configs/arm/emtrion-rzg1h-linux-demo.c b/configs/arm/emtrion-rzg1h-linux-demo.c
index 77234e80..b8b1c869 100644
--- a/configs/arm/emtrion-rzg1h-linux-demo.c
+++ b/configs/arm/emtrion-rzg1h-linux-demo.c
@@ -130,13 +130,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm/emtrion-rzg1h.c b/configs/arm/emtrion-rzg1h.c
index d8eec098..95c21d67 100644
--- a/configs/arm/emtrion-rzg1h.c
+++ b/configs/arm/emtrion-rzg1h.c
@@ -322,12 +322,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
diff --git a/configs/arm/emtrion-rzg1m-linux-demo.c b/configs/arm/emtrion-rzg1m-linux-demo.c
index 6e028a67..5e166fa5 100644
--- a/configs/arm/emtrion-rzg1m-linux-demo.c
+++ b/configs/arm/emtrion-rzg1m-linux-demo.c
@@ -130,13 +130,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm/emtrion-rzg1m.c b/configs/arm/emtrion-rzg1m.c
index c8ff9ec5..41bccba9 100644
--- a/configs/arm/emtrion-rzg1m.c
+++ b/configs/arm/emtrion-rzg1m.c
@@ -231,12 +231,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
diff --git a/configs/arm/jetson-tk1-linux-demo.c b/configs/arm/jetson-tk1-linux-demo.c
index cc605058..1fe3636a 100644
--- a/configs/arm/jetson-tk1-linux-demo.c
+++ b/configs/arm/jetson-tk1-linux-demo.c
@@ -77,13 +77,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0xfbf00000,
- .virt_start = 0xfbf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0xfbf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm/jetson-tk1.c b/configs/arm/jetson-tk1.c
index 2e8c0a02..187e82a2 100644
--- a/configs/arm/jetson-tk1.c
+++ b/configs/arm/jetson-tk1.c
@@ -226,12 +226,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0xfbf00000,
- .virt_start = 0xfbf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0xfbf00000, 0),
},

.irqchips = {
diff --git a/configs/arm/orangepi0-linux-demo.c b/configs/arm/orangepi0-linux-demo.c
index 06dbf559..7d3022a3 100644
--- a/configs/arm/orangepi0-linux-demo.c
+++ b/configs/arm/orangepi0-linux-demo.c
@@ -72,13 +72,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x4f700000,
- .virt_start = 0x4f700000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x4f700000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm/orangepi0.c b/configs/arm/orangepi0.c
index 4cd5b49d..5e654a01 100644
--- a/configs/arm/orangepi0.c
+++ b/configs/arm/orangepi0.c
@@ -123,12 +123,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x4f700000,
- .virt_start = 0x4f700000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x4f700000, 0),
},

.irqchips = {
diff --git a/configs/arm64/amd-seattle-linux-demo.c b/configs/arm64/amd-seattle-linux-demo.c
index 1ced1d7f..df44b76e 100644
--- a/configs/arm64/amd-seattle-linux-demo.c
+++ b/configs/arm64/amd-seattle-linux-demo.c
@@ -91,13 +91,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x83e4000000,
- .virt_start = 0x83e4000000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x83e4000000, 1),
/* v2m */ {
.phys_start = 0xe1180000,
.virt_start = 0xe1180000,
diff --git a/configs/arm64/amd-seattle.c b/configs/arm64/amd-seattle.c
index a5414d6b..dd22b324 100644
--- a/configs/arm64/amd-seattle.c
+++ b/configs/arm64/amd-seattle.c
@@ -176,12 +176,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x83e4000000,
- .virt_start = 0x83e4000000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x83e4000000, 0),
},
.irqchips = {
/* GIC */ {
diff --git a/configs/arm64/espressobin-linux-demo.c b/configs/arm64/espressobin-linux-demo.c
index d2b19988..87d0db41 100644
--- a/configs/arm64/espressobin-linux-demo.c
+++ b/configs/arm64/espressobin-linux-demo.c
@@ -71,13 +71,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x3fb00000,
- .virt_start = 0x3fb00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x3fb00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm64/espressobin.c b/configs/arm64/espressobin.c
index e228b373..e606beae 100644
--- a/configs/arm64/espressobin.c
+++ b/configs/arm64/espressobin.c
@@ -89,12 +89,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */ {
- .phys_start = 0x3fb00000,
- .virt_start = 0x3fb00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x3fb00000, 0),
},

.irqchips = {
diff --git a/configs/arm64/hikey-linux-demo.c b/configs/arm64/hikey-linux-demo.c
index e17e0b04..384f8be8 100644
--- a/configs/arm64/hikey-linux-demo.c
+++ b/configs/arm64/hikey-linux-demo.c
@@ -71,13 +71,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm64/hikey.c b/configs/arm64/hikey.c
index e9e2cd5f..2e0ddc64 100644
--- a/configs/arm64/hikey.c
+++ b/configs/arm64/hikey.c
@@ -95,12 +95,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
diff --git a/configs/arm64/jetson-tx1-linux-demo.c b/configs/arm64/jetson-tx1-linux-demo.c
index 1b7e1263..aeed067a 100644
--- a/configs/arm64/jetson-tx1-linux-demo.c
+++ b/configs/arm64/jetson-tx1-linux-demo.c
@@ -81,13 +81,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x17bf00000,
- .virt_start = 0x17bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x17bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm64/jetson-tx1.c b/configs/arm64/jetson-tx1.c
index e437d85d..a525d2b8 100644
--- a/configs/arm64/jetson-tx1.c
+++ b/configs/arm64/jetson-tx1.c
@@ -367,12 +367,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x17bf00000,
- .virt_start = 0x17bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x17bf00000, 0),
},
.irqchips = {
/* GIC */ {
diff --git a/configs/arm64/k3-am654-idk-linux-demo.c b/configs/arm64/k3-am654-idk-linux-demo.c
index 5dab6d8a..0c39dd29 100644
--- a/configs/arm64/k3-am654-idk-linux-demo.c
+++ b/configs/arm64/k3-am654-idk-linux-demo.c
@@ -70,12 +70,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region for 00:00.0 */ {
- .phys_start = 0x8dfb00000,
- .virt_start = 0x8dfb00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x8dfb00000, 1),
/* MCU UART0 */ {
.phys_start = 0x40a00000,
.virt_start = 0x40a00000,
diff --git a/configs/arm64/k3-am654-idk.c b/configs/arm64/k3-am654-idk.c
index 429ccdca..750657e8 100644
--- a/configs/arm64/k3-am654-idk.c
+++ b/configs/arm64/k3-am654-idk.c
@@ -79,12 +79,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */ {
- .phys_start = 0x8dfb00000,
- .virt_start = 0x8dfb00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x8dfb00000, 0),
/* RAM. Reserved for inmates */ {
.phys_start = 0x8E0000000,
.virt_start = 0x8E0000000,
diff --git a/configs/arm64/k3-j721e-evm-linux-demo.c b/configs/arm64/k3-j721e-evm-linux-demo.c
index 8a2222e1..58b5f2c4 100644
--- a/configs/arm64/k3-j721e-evm-linux-demo.c
+++ b/configs/arm64/k3-j721e-evm-linux-demo.c
@@ -54,13 +54,8 @@ struct {
},

.mem_regions = {
- /* IVSHMEM shared memory region for 00:00.0 */ {
- .phys_start = 0x89fe00000,
- .virt_start = 0x89fe00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x89fe00000, 1),
/* ctrl mmr */ {
.phys_start = 0x00100000,
.virt_start = 0x00100000,
diff --git a/configs/arm64/k3-j721e-evm.c b/configs/arm64/k3-j721e-evm.c
index 7e0dc031..65afe570 100644
--- a/configs/arm64/k3-j721e-evm.c
+++ b/configs/arm64/k3-j721e-evm.c
@@ -67,12 +67,8 @@ struct {
},

.mem_regions = {
- /* IVSHMEM shared memory region for 00:00.0 */ {
- .phys_start = 0x89fe00000,
- .virt_start = 0x89fe00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x89fe00000, 0),
/* ctrl mmr */ {
.phys_start = 0x00100000,
.virt_start = 0x00100000,
diff --git a/configs/arm64/macchiatobin-linux-demo.c b/configs/arm64/macchiatobin-linux-demo.c
index 418f3b31..629da548 100644
--- a/configs/arm64/macchiatobin-linux-demo.c
+++ b/configs/arm64/macchiatobin-linux-demo.c
@@ -79,13 +79,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x13fb00000,
- .virt_start = 0x13fb00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x13fb00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm64/macchiatobin.c b/configs/arm64/macchiatobin.c
index 4eebaa32..12df0a7a 100644
--- a/configs/arm64/macchiatobin.c
+++ b/configs/arm64/macchiatobin.c
@@ -98,12 +98,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */ {
- .phys_start = 0x13fb00000,
- .virt_start = 0x13fb00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x13fb00000, 0),
},

.irqchips = {
diff --git a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
index 865fba63..cd60959c 100644
--- a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
+++ b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
@@ -82,13 +82,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_COMM_REGION,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0xc0400000,
- .virt_start = 0xc0400000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0xc0400000, 1),
},

.irqchips = {
diff --git a/configs/arm64/miriac-sbc-ls1046a.c b/configs/arm64/miriac-sbc-ls1046a.c
index a5b54ddc..ce67cba1 100644
--- a/configs/arm64/miriac-sbc-ls1046a.c
+++ b/configs/arm64/miriac-sbc-ls1046a.c
@@ -427,12 +427,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_IO,
},
- /* IVSHMEM shared memory region for 00:00.0 */ {
- .phys_start = 0xc0400000,
- .virt_start = 0xc0400000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0xc0400000, 0),
},

.irqchips = {
diff --git a/configs/arm64/qemu-arm64-linux-demo.c b/configs/arm64/qemu-arm64-linux-demo.c
index b095900f..00cf6b99 100644
--- a/configs/arm64/qemu-arm64-linux-demo.c
+++ b/configs/arm64/qemu-arm64-linux-demo.c
@@ -72,13 +72,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7fb00000,
- .virt_start = 0x7fb00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7fb00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm64/qemu-arm64.c b/configs/arm64/qemu-arm64.c
index 51543183..015f47d6 100644
--- a/configs/arm64/qemu-arm64.c
+++ b/configs/arm64/qemu-arm64.c
@@ -82,12 +82,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */ {
- .phys_start = 0x7fb00000,
- .virt_start = 0x7fb00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7fb00000, 0),
/* "physical" PCI ECAM */ {
.phys_start = 0x4010000000,
.virt_start = 0x4010000000,
diff --git a/configs/arm64/ultra96-linux-demo.c b/configs/arm64/ultra96-linux-demo.c
index ed65ecf5..78262146 100644
--- a/configs/arm64/ultra96-linux-demo.c
+++ b/configs/arm64/ultra96-linux-demo.c
@@ -71,13 +71,8 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm64/ultra96.c b/configs/arm64/ultra96.c
index 2e038ae6..c62c3a6b 100644
--- a/configs/arm64/ultra96.c
+++ b/configs/arm64/ultra96.c
@@ -81,12 +81,8 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */ {
- .phys_start = 0x7bf00000,
- .virt_start = 0x7bf00000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo-2.c b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
index 683bdee4..dfae6404 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo-2.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
@@ -65,20 +65,10 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x800500000,
- .virt_start = 0x800500000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x800700000,
- .virt_start = 0x800700000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region for 00:01.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800500000, 1),
+ /* IVSHMEM shared memory region for 00:02.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800700000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo.c b/configs/arm64/zynqmp-zcu102-linux-demo.c
index 0b93c799..de11c5c2 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo.c
@@ -71,20 +71,10 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x800400000,
- .virt_start = 0x800400000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
- /* IVSHMEM shared memory region */ {
- .phys_start = 0x800700000,
- .virt_start = 0x800700000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800400000, 1),
+ /* IVSHMEM shared memory region for 00:02.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800700000, 0),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
diff --git a/configs/arm64/zynqmp-zcu102.c b/configs/arm64/zynqmp-zcu102.c
index 090470dd..d009b00d 100644
--- a/configs/arm64/zynqmp-zcu102.c
+++ b/configs/arm64/zynqmp-zcu102.c
@@ -91,18 +91,10 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */ {
- .phys_start = 0x800400000,
- .virt_start = 0x800400000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
- /* IVSHMEM shared memory region for 00:01.0 */ {
- .phys_start = 0x800500000,
- .virt_start = 0x800500000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ /* IVSHMEM shared memory region for 0001:00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800400000, 0),
+ /* IVSHMEM shared memory region for 0001:00:01.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800500000, 0),
/* PCI host bridge */ {
.phys_start = 0x8000000000,
.virt_start = 0x8000000000,
diff --git a/configs/x86/linux-x86-demo.c b/configs/x86/linux-x86-demo.c
index 69ea2bfa..6d076c67 100644
--- a/configs/x86/linux-x86-demo.c
+++ b/configs/x86/linux-x86-demo.c
@@ -77,13 +77,7 @@ struct {
JAILHOUSE_MEM_LOADABLE,
},
/* IVSHMEM shared memory region */
- {
- .phys_start = 0x3f100000,
- .virt_start = 0x3f100000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
+ JAILHOUSE_SHMEM_NET_REGIONS(0x3f100000, 1),
#ifdef CONFIG_QEMU_E1000E_ASSIGNMENT
/* MemRegion: feb40000-feb7ffff : 0000:00:02.0 */
{
diff --git a/configs/x86/qemu-x86.c b/configs/x86/qemu-x86.c
index 9621370c..2dcaa481 100644
--- a/configs/x86/qemu-x86.c
+++ b/configs/x86/qemu-x86.c
@@ -179,12 +179,7 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
},
/* IVSHMEM shared memory region (networking) */
- {
- .phys_start = 0x3f100000,
- .virt_start = 0x3f100000,
- .size = 0x100000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
+ JAILHOUSE_SHMEM_NET_REGIONS(0x3f100000, 0),
},

.irqchips = {
diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index a62fa1ee..f82bbe8d 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -129,6 +129,15 @@ struct jailhouse_memory {
__u64 flags;
} __attribute__((packed));

+#define JAILHOUSE_SHMEM_NET_REGIONS(start, dev_id) \
+ { \
+ .phys_start = start, \
+ .virt_start = start, \
+ .size = 0x100000, \
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | \
+ JAILHOUSE_MEM_ROOTSHARED, \
+ }
+
#define JAILHOUSE_MEMORY_IS_SUBPAGE(mem) \
((mem)->virt_start & PAGE_OFFS_MASK || (mem)->size & PAGE_OFFS_MASK)

--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:02 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Only match based on BDF from now one. We will rework the number of
shared memory regions, and matching them all will an enormous effort.
This should rather be pushed eventually into an offline check.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index e048d136..8d8481c7 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -17,7 +17,7 @@
*
* The implementation in Jailhouse provides a shared memory device between
* exactly 2 cells. The link between the two PCI devices is established by
- * choosing the same BDF, memory location, and memory size.
+ * choosing the same BDF.
*/

#include <jailhouse/ivshmem.h>
@@ -314,8 +314,8 @@ enum pci_access ivshmem_pci_cfg_read(struct pci_device *device, u16 address,
int ivshmem_init(struct cell *cell, struct pci_device *device)
{
const struct jailhouse_pci_device *dev_info = device->info;
- const struct jailhouse_memory *mem, *peer_mem;
struct ivshmem_endpoint *ive, *remote;
+ const struct jailhouse_memory *mem;
struct pci_device *peer_dev;
struct ivshmem_link *link;
unsigned int id;
@@ -342,14 +342,6 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
return trace_error(-EBUSY);

peer_dev = link->eps[id ^ 1].device;
- peer_mem = jailhouse_cell_mem_regions(peer_dev->cell->config) +
- peer_dev->info->shmem_region;
-
- /* check that the regions and protocols of both peers match */
- if (peer_mem->phys_start != mem->phys_start ||
- peer_mem->size != mem->size ||
- peer_dev->info->shmem_protocol != dev_info->shmem_protocol)
- return trace_error(-EINVAL);

printk("Shared memory connection established: "
"\"%s\" <--> \"%s\"\n",
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:02 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Simplifies index calculation and reduces risk of errors. The only
downside is that regions are no longer ordered according to their
physical addresses.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
configs/arm/bananapi-linux-demo.c | 6 +++---
configs/arm/bananapi.c | 6 +++---
configs/arm/emtrion-rzg1e-linux-demo.c | 6 +++---
configs/arm/emtrion-rzg1e.c | 6 +++---
configs/arm/emtrion-rzg1h-linux-demo.c | 6 +++---
configs/arm/emtrion-rzg1h.c | 6 +++---
configs/arm/emtrion-rzg1m-linux-demo.c | 6 +++---
configs/arm/emtrion-rzg1m.c | 6 +++---
configs/arm/jetson-tk1-linux-demo.c | 6 +++---
configs/arm/jetson-tk1.c | 6 +++---
configs/arm/orangepi0-linux-demo.c | 6 +++---
configs/arm/orangepi0.c | 6 +++---
configs/arm64/amd-seattle-linux-demo.c | 6 +++---
configs/arm64/amd-seattle.c | 6 +++---
configs/arm64/espressobin-linux-demo.c | 6 +++---
configs/arm64/espressobin.c | 6 +++---
configs/arm64/hikey-linux-demo.c | 6 +++---
configs/arm64/hikey.c | 6 +++---
configs/arm64/jetson-tx1-linux-demo.c | 6 +++---
configs/arm64/jetson-tx1.c | 7 +++----
configs/arm64/k3-am654-idk-linux-demo.c | 6 +++---
configs/arm64/k3-am654-idk.c | 6 +++---
configs/arm64/macchiatobin-linux-demo.c | 6 +++---
configs/arm64/macchiatobin.c | 6 +++---
configs/arm64/miriac-sbc-ls1046a-linux-demo.c | 6 +++---
configs/arm64/miriac-sbc-ls1046a.c | 6 +++---
configs/arm64/qemu-arm64-linux-demo.c | 6 +++---
configs/arm64/qemu-arm64.c | 6 +++---
configs/arm64/ultra96-linux-demo.c | 6 +++---
configs/arm64/ultra96.c | 6 +++---
configs/arm64/zynqmp-zcu102-linux-demo-2.c | 12 ++++++------
configs/arm64/zynqmp-zcu102-linux-demo.c | 12 ++++++------
configs/arm64/zynqmp-zcu102.c | 12 ++++++------
configs/x86/ivshmem-demo.c | 18 +++++++++---------
configs/x86/linux-x86-demo.c | 6 +++---
configs/x86/qemu-x86.c | 22 +++++++++++-----------
36 files changed, 131 insertions(+), 132 deletions(-)

diff --git a/configs/arm/bananapi-linux-demo.c b/configs/arm/bananapi-linux-demo.c
index 474ad6d1..a6714736 100644
--- a/configs/arm/bananapi-linux-demo.c
+++ b/configs/arm/bananapi-linux-demo.c
@@ -52,6 +52,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* CCU (HACK) */ {
.phys_start = 0x01c2006c,
.virt_start = 0x01c2006c,
@@ -81,8 +83,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -106,7 +106,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 4,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/bananapi.c b/configs/arm/bananapi.c
index 7f7393ff..3dd3a2a3 100644
--- a/configs/arm/bananapi.c
+++ b/configs/arm/bananapi.c
@@ -70,6 +70,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
/* SPI */ {
.phys_start = 0x01c05000,
.virt_start = 0x01c05000,
@@ -182,8 +184,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
@@ -201,7 +201,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 16,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1e-linux-demo.c b/configs/arm/emtrion-rzg1e-linux-demo.c
index 4dbaecff..5b24db92 100644
--- a/configs/arm/emtrion-rzg1e-linux-demo.c
+++ b/configs/arm/emtrion-rzg1e-linux-demo.c
@@ -51,6 +51,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* RST, MODEMR */ {
.phys_start = 0xe6160060,
.virt_start = 0xe6160060,
@@ -116,8 +118,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -155,7 +155,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 4,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1e.c b/configs/arm/emtrion-rzg1e.c
index 744e7aeb..528b2f45 100644
--- a/configs/arm/emtrion-rzg1e.c
+++ b/configs/arm/emtrion-rzg1e.c
@@ -70,6 +70,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
/* CPG */ {
.phys_start = 0xe6150000,
.virt_start = 0xe6150000,
@@ -196,8 +198,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
@@ -229,7 +229,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 16,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1h-linux-demo.c b/configs/arm/emtrion-rzg1h-linux-demo.c
index b8b1c869..c971bcc0 100644
--- a/configs/arm/emtrion-rzg1h-linux-demo.c
+++ b/configs/arm/emtrion-rzg1h-linux-demo.c
@@ -51,6 +51,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* RST, MODEMR */ {
.phys_start = 0xe6160060,
.virt_start = 0xe6160060,
@@ -130,8 +132,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -169,7 +169,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 4,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1h.c b/configs/arm/emtrion-rzg1h.c
index 95c21d67..c2b3e16a 100644
--- a/configs/arm/emtrion-rzg1h.c
+++ b/configs/arm/emtrion-rzg1h.c
@@ -70,6 +70,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
/* SYS-DMAC */ {
.phys_start = 0xe6700000,
.virt_start = 0xe6700000,
@@ -322,8 +324,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
@@ -355,7 +355,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 16,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1m-linux-demo.c b/configs/arm/emtrion-rzg1m-linux-demo.c
index 5e166fa5..1dc57b4c 100644
--- a/configs/arm/emtrion-rzg1m-linux-demo.c
+++ b/configs/arm/emtrion-rzg1m-linux-demo.c
@@ -51,6 +51,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* RST, MODEMR */ {
.phys_start = 0xe6160060,
.virt_start = 0xe6160060,
@@ -130,8 +132,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -169,7 +169,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 4,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1m.c b/configs/arm/emtrion-rzg1m.c
index 41bccba9..21d05116 100644
--- a/configs/arm/emtrion-rzg1m.c
+++ b/configs/arm/emtrion-rzg1m.c
@@ -70,6 +70,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
/* Thermal Sensor */ {
.phys_start = 0xe61f0000,
.virt_start = 0xe61f0000,
@@ -231,8 +233,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
@@ -264,7 +264,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 16,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/jetson-tk1-linux-demo.c b/configs/arm/jetson-tk1-linux-demo.c
index 1fe3636a..2e0a898c 100644
--- a/configs/arm/jetson-tk1-linux-demo.c
+++ b/configs/arm/jetson-tk1-linux-demo.c
@@ -53,6 +53,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0xfbf00000, 1),
/* UART */ {
.phys_start = 0x70006000,
.virt_start = 0x70006000,
@@ -77,8 +79,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0xfbf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -109,7 +109,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/jetson-tk1.c b/configs/arm/jetson-tk1.c
index 187e82a2..18a36449 100644
--- a/configs/arm/jetson-tk1.c
+++ b/configs/arm/jetson-tk1.c
@@ -74,6 +74,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0xfbf00000, 0),
/* PCIe */ {
.phys_start = 0x01000000,
.virt_start = 0x01000000,
@@ -226,8 +228,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0xfbf00000, 0),
},

.irqchips = {
@@ -253,7 +253,7 @@ struct {
.domain = 1,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 21,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/orangepi0-linux-demo.c b/configs/arm/orangepi0-linux-demo.c
index 7d3022a3..1b0a27f6 100644
--- a/configs/arm/orangepi0-linux-demo.c
+++ b/configs/arm/orangepi0-linux-demo.c
@@ -50,6 +50,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x4f700000, 1),
/* UART 0-3 */ {
.phys_start = 0x01c28000,
.virt_start = 0x01c28000,
@@ -72,8 +74,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x4f700000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -97,7 +97,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/orangepi0.c b/configs/arm/orangepi0.c
index 5e654a01..441f211c 100644
--- a/configs/arm/orangepi0.c
+++ b/configs/arm/orangepi0.c
@@ -67,6 +67,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x4f700000, 0),
/* MMIO 1 (permissive) */ {
.phys_start = 0x01c00000,
.virt_start = 0x01c00000,
@@ -123,8 +125,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x4f700000, 0),
},

.irqchips = {
@@ -142,7 +142,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 8,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/amd-seattle-linux-demo.c b/configs/arm64/amd-seattle-linux-demo.c
index df44b76e..b6c6b2e0 100644
--- a/configs/arm64/amd-seattle-linux-demo.c
+++ b/configs/arm64/amd-seattle-linux-demo.c
@@ -47,6 +47,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x83e4000000, 1),
/* UART */ {
.phys_start = 0xe1010000,
.virt_start = 0xe1010000,
@@ -91,8 +93,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x83e4000000, 1),
/* v2m */ {
.phys_start = 0xe1180000,
.virt_start = 0xe1180000,
@@ -138,7 +138,7 @@ struct {
.bdf = 0x0078,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 6,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/amd-seattle.c b/configs/arm64/amd-seattle.c
index dd22b324..37cbb91a 100644
--- a/configs/arm64/amd-seattle.c
+++ b/configs/arm64/amd-seattle.c
@@ -64,6 +64,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x83e4000000, 0),
/* gpio */ {
.phys_start = 0xe0030000,
.virt_start = 0xe0030000,
@@ -176,8 +178,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x83e4000000, 0),
},
.irqchips = {
/* GIC */ {
@@ -216,7 +216,7 @@ struct {
.bdf = 0x0078,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 16,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/espressobin-linux-demo.c b/configs/arm64/espressobin-linux-demo.c
index 87d0db41..dc12d2b3 100644
--- a/configs/arm64/espressobin-linux-demo.c
+++ b/configs/arm64/espressobin-linux-demo.c
@@ -49,6 +49,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x3fb00000, 1),
/* UART */ {
.phys_start = 0xd0012000,
.virt_start = 0xd0012000,
@@ -71,8 +73,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x3fb00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -99,7 +99,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/espressobin.c b/configs/arm64/espressobin.c
index e606beae..c9e62077 100644
--- a/configs/arm64/espressobin.c
+++ b/configs/arm64/espressobin.c
@@ -68,6 +68,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x3fb00000, 0),
/* MMIO (permissive) */ {
.phys_start = 0xd0000000,
.virt_start = 0xd0000000,
@@ -89,8 +91,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x3fb00000, 0),
},

.irqchips = {
@@ -109,7 +109,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/hikey-linux-demo.c b/configs/arm64/hikey-linux-demo.c
index 384f8be8..d6cc9f2d 100644
--- a/configs/arm64/hikey-linux-demo.c
+++ b/configs/arm64/hikey-linux-demo.c
@@ -49,6 +49,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* UART 3 */ {
.phys_start = 0xf7113000,
.virt_start = 0xf7113000,
@@ -71,8 +73,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -96,7 +96,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/hikey.c b/configs/arm64/hikey.c
index 2e0ddc64..057dcd05 100644
--- a/configs/arm64/hikey.c
+++ b/configs/arm64/hikey.c
@@ -67,6 +67,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
/* MMIO (permissive) */ {
.phys_start = 0xf4100000,
.virt_start = 0xf4100000,
@@ -95,8 +97,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
@@ -115,7 +115,7 @@ struct {
.domain = 1,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 4,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/jetson-tx1-linux-demo.c b/configs/arm64/jetson-tx1-linux-demo.c
index aeed067a..b0518c4d 100644
--- a/configs/arm64/jetson-tx1-linux-demo.c
+++ b/configs/arm64/jetson-tx1-linux-demo.c
@@ -58,6 +58,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x17bf00000, 1),
/* UART */ {
.phys_start = 0x70006000,
.virt_start = 0x70006000,
@@ -81,8 +83,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x17bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -113,7 +113,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/jetson-tx1.c b/configs/arm64/jetson-tx1.c
index a525d2b8..60a8906d 100644
--- a/configs/arm64/jetson-tx1.c
+++ b/configs/arm64/jetson-tx1.c
@@ -72,7 +72,8 @@ struct {


.mem_regions = {
-
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x17bf00000, 0),
/* APE 1 */ {
.phys_start = 0x00000000,
.virt_start = 0x00000000,
@@ -367,8 +368,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x17bf00000, 0),
},
.irqchips = {
/* GIC */ {
@@ -393,7 +392,7 @@ struct {
.domain = 1,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 42,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/k3-am654-idk-linux-demo.c b/configs/arm64/k3-am654-idk-linux-demo.c
index 0c39dd29..d546add6 100644
--- a/configs/arm64/k3-am654-idk-linux-demo.c
+++ b/configs/arm64/k3-am654-idk-linux-demo.c
@@ -54,6 +54,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x8dfb00000, 1),
/* RAM load */ {
.phys_start = 0x8FFFF0000,
.virt_start = 0x0,
@@ -70,8 +72,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region for 00:00.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x8dfb00000, 1),
/* MCU UART0 */ {
.phys_start = 0x40a00000,
.virt_start = 0x40a00000,
@@ -137,7 +137,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 2,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/k3-am654-idk.c b/configs/arm64/k3-am654-idk.c
index 750657e8..4dea206a 100644
--- a/configs/arm64/k3-am654-idk.c
+++ b/configs/arm64/k3-am654-idk.c
@@ -65,6 +65,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x8dfb00000, 0),
/* RAM */ {
.phys_start = 0x80000000,
.virt_start = 0x80000000,
@@ -79,8 +81,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x8dfb00000, 0),
/* RAM. Reserved for inmates */ {
.phys_start = 0x8E0000000,
.virt_start = 0x8E0000000,
@@ -211,7 +211,7 @@ struct {
.domain = 1,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 2,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/macchiatobin-linux-demo.c b/configs/arm64/macchiatobin-linux-demo.c
index 629da548..9da732d9 100644
--- a/configs/arm64/macchiatobin-linux-demo.c
+++ b/configs/arm64/macchiatobin-linux-demo.c
@@ -50,6 +50,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x13fb00000, 1),
/* UART */ {
.phys_start = 0xf0512000,
.virt_start = 0xf0512000,
@@ -79,8 +81,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x13fb00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -107,7 +107,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 4,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/macchiatobin.c b/configs/arm64/macchiatobin.c
index 12df0a7a..893b116d 100644
--- a/configs/arm64/macchiatobin.c
+++ b/configs/arm64/macchiatobin.c
@@ -70,6 +70,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x13fb00000, 0),
/* MMIO (permissive) */ {
.phys_start = 0xf0300000,
.virt_start = 0xf0300000,
@@ -98,8 +100,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x13fb00000, 0),
},

.irqchips = {
@@ -118,7 +118,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 4,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
index cd60959c..71981611 100644
--- a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
+++ b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
@@ -51,6 +51,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0xc0400000, 1),
/* DUART1 */
{
.phys_start = 0x21c0000,
@@ -82,8 +84,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_COMM_REGION,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0xc0400000, 1),
},

.irqchips = {
@@ -119,7 +119,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 4,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/miriac-sbc-ls1046a.c b/configs/arm64/miriac-sbc-ls1046a.c
index ce67cba1..1e3aa9c4 100644
--- a/configs/arm64/miriac-sbc-ls1046a.c
+++ b/configs/arm64/miriac-sbc-ls1046a.c
@@ -72,6 +72,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0xc0400000, 0),
/* DDR memory controller */ {
.phys_start = 0x01080000,
.virt_start = 0x01080000,
@@ -427,8 +429,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_IO,
},
- /* IVSHMEM shared memory region for 00:00.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0xc0400000, 0),
},

.irqchips = {
@@ -454,7 +454,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = ARRAY_SIZE(config.mem_regions) - 1,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/qemu-arm64-linux-demo.c b/configs/arm64/qemu-arm64-linux-demo.c
index 00cf6b99..e0c95039 100644
--- a/configs/arm64/qemu-arm64-linux-demo.c
+++ b/configs/arm64/qemu-arm64-linux-demo.c
@@ -50,6 +50,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7fb00000, 1),
/* UART */ {
.phys_start = 0x09000000,
.virt_start = 0x09000000,
@@ -72,8 +74,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7fb00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -100,7 +100,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/qemu-arm64.c b/configs/arm64/qemu-arm64.c
index 015f47d6..4b0826cd 100644
--- a/configs/arm64/qemu-arm64.c
+++ b/configs/arm64/qemu-arm64.c
@@ -68,6 +68,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7fb00000, 0),
/* MMIO (permissive) */ {
.phys_start = 0x09000000,
.virt_start = 0x09000000,
@@ -82,8 +84,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7fb00000, 0),
/* "physical" PCI ECAM */ {
.phys_start = 0x4010000000,
.virt_start = 0x4010000000,
@@ -109,7 +109,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 2,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/ultra96-linux-demo.c b/configs/arm64/ultra96-linux-demo.c
index 78262146..4aea2922 100644
--- a/configs/arm64/ultra96-linux-demo.c
+++ b/configs/arm64/ultra96-linux-demo.c
@@ -49,6 +49,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* UART */ {
.phys_start = 0xff010000,
.virt_start = 0xff010000,
@@ -71,8 +73,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -99,7 +99,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/ultra96.c b/configs/arm64/ultra96.c
index c62c3a6b..ef49b824 100644
--- a/configs/arm64/ultra96.c
+++ b/configs/arm64/ultra96.c
@@ -67,6 +67,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
/* MMIO (permissive) */ {
.phys_start = 0xfd000000,
.virt_start = 0xfd000000,
@@ -81,8 +83,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 00:00.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x7bf00000, 0),
},

.irqchips = {
@@ -101,7 +101,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 2,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo-2.c b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
index dfae6404..5248952d 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo-2.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
@@ -50,6 +50,10 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region for 00:01.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800500000, 1),
+ /* IVSHMEM shared memory region for 00:02.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800700000, 1),
/* RAM */ {
.phys_start = 0x800610000,
.virt_start = 0,
@@ -65,10 +69,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region for 00:01.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x800500000, 1),
- /* IVSHMEM shared memory region for 00:02.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x800700000, 1),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -95,7 +95,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 1 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 2,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
@@ -103,7 +103,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 2 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 1,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo.c b/configs/arm64/zynqmp-zcu102-linux-demo.c
index de11c5c2..f9b804a4 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo.c
@@ -49,6 +49,10 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region for 00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800400000, 1),
+ /* IVSHMEM shared memory region for 00:02.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800700000, 0),
/* UART */ {
.phys_start = 0xff010000,
.virt_start = 0xff010000,
@@ -71,10 +75,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region for 00:00.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x800400000, 1),
- /* IVSHMEM shared memory region for 00:02.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x800700000, 0),
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
@@ -101,7 +101,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
@@ -109,7 +109,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 2 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 4,
+ .shmem_region = 1,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102.c b/configs/arm64/zynqmp-zcu102.c
index d009b00d..efd81389 100644
--- a/configs/arm64/zynqmp-zcu102.c
+++ b/configs/arm64/zynqmp-zcu102.c
@@ -70,6 +70,10 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region for 0001:00:00.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800400000, 0),
+ /* IVSHMEM shared memory region for 0001:00:01.0 */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x800500000, 0),
/* MMIO (permissive) */ {
.phys_start = 0xfd000000,
.virt_start = 0xfd000000,
@@ -91,10 +95,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE,
},
- /* IVSHMEM shared memory region for 0001:00:00.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x800400000, 0),
- /* IVSHMEM shared memory region for 0001:00:01.0 */
- JAILHOUSE_SHMEM_NET_REGIONS(0x800500000, 0),
/* PCI host bridge */ {
.phys_start = 0x8000000000,
.virt_start = 0x8000000000,
@@ -120,7 +120,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
@@ -129,7 +129,7 @@ struct {
.domain = 1,
.bdf = 1 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 4,
+ .shmem_region = 1,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/x86/ivshmem-demo.c b/configs/x86/ivshmem-demo.c
index c6c1f4c2..e53965ff 100644
--- a/configs/x86/ivshmem-demo.c
+++ b/configs/x86/ivshmem-demo.c
@@ -50,6 +50,14 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ {
+ .phys_start = 0x3f0f0000,
+ .virt_start = 0x3f0f0000,
+ .size = 0x1000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_ROOTSHARED,
+ },
/* RAM */ {
.phys_start = 0x3ee00000,
.virt_start = 0,
@@ -63,14 +71,6 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_COMM_REGION,
},
- /* IVSHMEM shared memory region */
- {
- .phys_start = 0x3f0f0000,
- .virt_start = 0x3f0f0000,
- .size = 0x1000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
},

.pio_regions = {
@@ -85,7 +85,7 @@ struct {
.bdf = 0x0e << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 2,
+ .shmem_region = 0,
.shmem_dev_id = 1,
},
},
diff --git a/configs/x86/linux-x86-demo.c b/configs/x86/linux-x86-demo.c
index 6d076c67..70cfc4ad 100644
--- a/configs/x86/linux-x86-demo.c
+++ b/configs/x86/linux-x86-demo.c
@@ -54,6 +54,8 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x3f100000, 1),
/* low RAM */ {
.phys_start = 0x3a600000,
.virt_start = 0,
@@ -76,8 +78,6 @@ struct {
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
- /* IVSHMEM shared memory region */
- JAILHOUSE_SHMEM_NET_REGIONS(0x3f100000, 1),
#ifdef CONFIG_QEMU_E1000E_ASSIGNMENT
/* MemRegion: feb40000-feb7ffff : 0000:00:02.0 */
{
@@ -141,7 +141,7 @@ struct {
.bdf = 0x0f << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 3,
+ .shmem_region = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/x86/qemu-x86.c b/configs/x86/qemu-x86.c
index 2dcaa481..4aa789b1 100644
--- a/configs/x86/qemu-x86.c
+++ b/configs/x86/qemu-x86.c
@@ -74,6 +74,15 @@ struct {
},

.mem_regions = {
+ /* IVSHMEM shared memory region (demo) */
+ {
+ .phys_start = 0x3f0f0000,
+ .virt_start = 0x3f0f0000,
+ .size = 0x1000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
+ },
+ /* IVSHMEM shared memory region (networking) */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x3f100000, 0),
/* RAM */ {
.phys_start = 0x0,
.virt_start = 0x0,
@@ -171,15 +180,6 @@ struct {
.size = 0x1000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
},
- /* IVSHMEM shared memory region (demo) */
- {
- .phys_start = 0x3f0f0000,
- .virt_start = 0x3f0f0000,
- .size = 0x1000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
- },
- /* IVSHMEM shared memory region (networking) */
- JAILHOUSE_SHMEM_NET_REGIONS(0x3f100000, 0),
},

.irqchips = {
@@ -277,7 +277,7 @@ struct {
.bdf = 0x0e << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 14,
+ .shmem_region = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
},
@@ -287,7 +287,7 @@ struct {
.bdf = 0x0f << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 15,
+ .shmem_region = 1,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:03 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Replace the register-based remote state read-back with a state table
that is located in read-only shared memory. Every peer has an entry in
this table. The entry position is based on the ID. This way, all peers
can read the other's state without causing a VM exit.

The state table is located at the beginning of the share memory region.
Its mapping size can be retrieved via a register in the the vendor cap.

The cell config format for PCI devices is extended: shmem_region becomes
shmem_regions_start, pointing to two memory regions now, the read-only
state table and the read/write shared memory. The two memory regions
must be consecutive because the size of the first one is used by ivshmem
drivers to derive the offset of the second one.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
configs/arm/bananapi-linux-demo.c | 4 +-
configs/arm/bananapi.c | 4 +-
configs/arm/emtrion-rzg1e-linux-demo.c | 4 +-
configs/arm/emtrion-rzg1e.c | 4 +-
configs/arm/emtrion-rzg1h-linux-demo.c | 4 +-
configs/arm/emtrion-rzg1h.c | 2 +-
configs/arm/emtrion-rzg1m-linux-demo.c | 4 +-
configs/arm/emtrion-rzg1m.c | 4 +-
configs/arm/jetson-tk1-linux-demo.c | 4 +-
configs/arm/jetson-tk1.c | 4 +-
configs/arm/orangepi0-linux-demo.c | 4 +-
configs/arm/orangepi0.c | 4 +-
configs/arm64/amd-seattle-linux-demo.c | 4 +-
configs/arm64/amd-seattle.c | 4 +-
configs/arm64/espressobin-linux-demo.c | 4 +-
configs/arm64/espressobin.c | 4 +-
configs/arm64/hikey-linux-demo.c | 4 +-
configs/arm64/hikey.c | 4 +-
configs/arm64/jetson-tx1-linux-demo.c | 4 +-
configs/arm64/jetson-tx1.c | 4 +-
configs/arm64/k3-am654-idk-linux-demo.c | 4 +-
configs/arm64/k3-am654-idk.c | 4 +-
configs/arm64/k3-j721e-evm-linux-demo.c | 4 +-
configs/arm64/k3-j721e-evm.c | 4 +-
configs/arm64/macchiatobin-linux-demo.c | 4 +-
configs/arm64/macchiatobin.c | 4 +-
configs/arm64/miriac-sbc-ls1046a-linux-demo.c | 7 ++-
configs/arm64/miriac-sbc-ls1046a.c | 4 +-
configs/arm64/qemu-arm64-linux-demo.c | 4 +-
configs/arm64/qemu-arm64.c | 4 +-
configs/arm64/ultra96-linux-demo.c | 4 +-
configs/arm64/ultra96.c | 4 +-
configs/arm64/zynqmp-zcu102-linux-demo-2.c | 6 +--
configs/arm64/zynqmp-zcu102-linux-demo.c | 6 +--
configs/arm64/zynqmp-zcu102.c | 6 +--
configs/x86/ivshmem-demo.c | 12 +++--
configs/x86/linux-x86-demo.c | 8 ++--
configs/x86/qemu-x86.c | 16 +++++--
hypervisor/ivshmem.c | 69 +++++++++++++++++----------
include/jailhouse/cell-config.h | 12 +++--
40 files changed, 150 insertions(+), 114 deletions(-)

diff --git a/configs/arm/bananapi-linux-demo.c b/configs/arm/bananapi-linux-demo.c
index a6714736..1b609902 100644
--- a/configs/arm/bananapi-linux-demo.c
+++ b/configs/arm/bananapi-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[7];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -106,7 +106,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/bananapi.c b/configs/arm/bananapi.c
index 3dd3a2a3..fdf8978b 100644
--- a/configs/arm/bananapi.c
+++ b/configs/arm/bananapi.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[17];
+ struct jailhouse_memory mem_regions[18];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -201,7 +201,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1e-linux-demo.c b/configs/arm/emtrion-rzg1e-linux-demo.c
index 5b24db92..c946f6d0 100644
--- a/configs/arm/emtrion-rzg1e-linux-demo.c
+++ b/configs/arm/emtrion-rzg1e-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[11];
+ struct jailhouse_memory mem_regions[12];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -155,7 +155,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1e.c b/configs/arm/emtrion-rzg1e.c
index 528b2f45..5b3bf03c 100644
--- a/configs/arm/emtrion-rzg1e.c
+++ b/configs/arm/emtrion-rzg1e.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[19];
+ struct jailhouse_memory mem_regions[20];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -229,7 +229,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1h-linux-demo.c b/configs/arm/emtrion-rzg1h-linux-demo.c
index c971bcc0..623f8886 100644
--- a/configs/arm/emtrion-rzg1h-linux-demo.c
+++ b/configs/arm/emtrion-rzg1h-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[13];
+ struct jailhouse_memory mem_regions[14];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -169,7 +169,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1h.c b/configs/arm/emtrion-rzg1h.c
index c2b3e16a..9ab36d25 100644
--- a/configs/arm/emtrion-rzg1h.c
+++ b/configs/arm/emtrion-rzg1h.c
@@ -355,7 +355,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1m-linux-demo.c b/configs/arm/emtrion-rzg1m-linux-demo.c
index 1dc57b4c..73ad3c5b 100644
--- a/configs/arm/emtrion-rzg1m-linux-demo.c
+++ b/configs/arm/emtrion-rzg1m-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[13];
+ struct jailhouse_memory mem_regions[14];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -169,7 +169,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/emtrion-rzg1m.c b/configs/arm/emtrion-rzg1m.c
index 21d05116..4c6b7c58 100644
--- a/configs/arm/emtrion-rzg1m.c
+++ b/configs/arm/emtrion-rzg1m.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[24];
+ struct jailhouse_memory mem_regions[25];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -264,7 +264,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/jetson-tk1-linux-demo.c b/configs/arm/jetson-tk1-linux-demo.c
index 2e0a898c..48844a66 100644
--- a/configs/arm/jetson-tk1-linux-demo.c
+++ b/configs/arm/jetson-tk1-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -109,7 +109,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/jetson-tk1.c b/configs/arm/jetson-tk1.c
index 18a36449..ca368fcf 100644
--- a/configs/arm/jetson-tk1.c
+++ b/configs/arm/jetson-tk1.c
@@ -21,7 +21,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[22];
+ struct jailhouse_memory mem_regions[23];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -253,7 +253,7 @@ struct {
.domain = 1,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/orangepi0-linux-demo.c b/configs/arm/orangepi0-linux-demo.c
index 1b0a27f6..09087a28 100644
--- a/configs/arm/orangepi0-linux-demo.c
+++ b/configs/arm/orangepi0-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -97,7 +97,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm/orangepi0.c b/configs/arm/orangepi0.c
index 441f211c..b878f70c 100644
--- a/configs/arm/orangepi0.c
+++ b/configs/arm/orangepi0.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[9];
+ struct jailhouse_memory mem_regions[10];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -142,7 +142,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/amd-seattle-linux-demo.c b/configs/arm64/amd-seattle-linux-demo.c
index b6c6b2e0..7acae6e1 100644
--- a/configs/arm64/amd-seattle-linux-demo.c
+++ b/configs/arm64/amd-seattle-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[9];
+ struct jailhouse_memory mem_regions[10];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -138,7 +138,7 @@ struct {
.bdf = 0x0078,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/amd-seattle.c b/configs/arm64/amd-seattle.c
index 37cbb91a..5d810a64 100644
--- a/configs/arm64/amd-seattle.c
+++ b/configs/arm64/amd-seattle.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[17];
+ struct jailhouse_memory mem_regions[18];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[3];
} __attribute__((packed)) config = {
@@ -216,7 +216,7 @@ struct {
.bdf = 0x0078,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/espressobin-linux-demo.c b/configs/arm64/espressobin-linux-demo.c
index dc12d2b3..2d84665c 100644
--- a/configs/arm64/espressobin-linux-demo.c
+++ b/configs/arm64/espressobin-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -99,7 +99,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/espressobin.c b/configs/arm64/espressobin.c
index c9e62077..082c9479 100644
--- a/configs/arm64/espressobin.c
+++ b/configs/arm64/espressobin.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[4];
+ struct jailhouse_memory mem_regions[5];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -109,7 +109,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/hikey-linux-demo.c b/configs/arm64/hikey-linux-demo.c
index d6cc9f2d..623b4b5b 100644
--- a/configs/arm64/hikey-linux-demo.c
+++ b/configs/arm64/hikey-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -96,7 +96,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/hikey.c b/configs/arm64/hikey.c
index 057dcd05..c570e905 100644
--- a/configs/arm64/hikey.c
+++ b/configs/arm64/hikey.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -115,7 +115,7 @@ struct {
.domain = 1,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/jetson-tx1-linux-demo.c b/configs/arm64/jetson-tx1-linux-demo.c
index b0518c4d..cb4c356c 100644
--- a/configs/arm64/jetson-tx1-linux-demo.c
+++ b/configs/arm64/jetson-tx1-linux-demo.c
@@ -25,7 +25,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -113,7 +113,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/jetson-tx1.c b/configs/arm64/jetson-tx1.c
index 60a8906d..801a5774 100644
--- a/configs/arm64/jetson-tx1.c
+++ b/configs/arm64/jetson-tx1.c
@@ -21,7 +21,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[43];
+ struct jailhouse_memory mem_regions[44];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -392,7 +392,7 @@ struct {
.domain = 1,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/k3-am654-idk-linux-demo.c b/configs/arm64/k3-am654-idk-linux-demo.c
index d546add6..bea2c984 100644
--- a/configs/arm64/k3-am654-idk-linux-demo.c
+++ b/configs/arm64/k3-am654-idk-linux-demo.c
@@ -23,7 +23,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[9];
+ struct jailhouse_memory mem_regions[10];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -137,7 +137,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/k3-am654-idk.c b/configs/arm64/k3-am654-idk.c
index 4dea206a..85f663f1 100644
--- a/configs/arm64/k3-am654-idk.c
+++ b/configs/arm64/k3-am654-idk.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[15];
+ struct jailhouse_memory mem_regions[16];
struct jailhouse_irqchip irqchips[5];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -211,7 +211,7 @@ struct {
.domain = 1,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/k3-j721e-evm-linux-demo.c b/configs/arm64/k3-j721e-evm-linux-demo.c
index 58b5f2c4..ec0e3a39 100644
--- a/configs/arm64/k3-j721e-evm-linux-demo.c
+++ b/configs/arm64/k3-j721e-evm-linux-demo.c
@@ -24,7 +24,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[22];
+ struct jailhouse_memory mem_regions[23];
struct jailhouse_irqchip irqchips[4];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -261,7 +261,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/k3-j721e-evm.c b/configs/arm64/k3-j721e-evm.c
index 65afe570..f22e9962 100644
--- a/configs/arm64/k3-j721e-evm.c
+++ b/configs/arm64/k3-j721e-evm.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[33];
+ struct jailhouse_memory mem_regions[34];
struct jailhouse_irqchip irqchips[6];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -349,7 +349,7 @@ struct {
.domain = 3,
.bdf = 0x00,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/macchiatobin-linux-demo.c b/configs/arm64/macchiatobin-linux-demo.c
index 9da732d9..2ebabb0d 100644
--- a/configs/arm64/macchiatobin-linux-demo.c
+++ b/configs/arm64/macchiatobin-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[7];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -107,7 +107,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/macchiatobin.c b/configs/arm64/macchiatobin.c
index 893b116d..2fca01a2 100644
--- a/configs/arm64/macchiatobin.c
+++ b/configs/arm64/macchiatobin.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -118,7 +118,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
index 71981611..9eb96734 100644
--- a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
+++ b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -114,12 +114,11 @@ struct {

.pci_devices =
{
- /* 00:00.0 */
- {
+ /* 00:00.0 */ {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/miriac-sbc-ls1046a.c b/configs/arm64/miriac-sbc-ls1046a.c
index 1e3aa9c4..ea64d44a 100644
--- a/configs/arm64/miriac-sbc-ls1046a.c
+++ b/configs/arm64/miriac-sbc-ls1046a.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[52];
+ struct jailhouse_memory mem_regions[53];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -454,7 +454,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/qemu-arm64-linux-demo.c b/configs/arm64/qemu-arm64-linux-demo.c
index e0c95039..c3b06c11 100644
--- a/configs/arm64/qemu-arm64-linux-demo.c
+++ b/configs/arm64/qemu-arm64-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -100,7 +100,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/qemu-arm64.c b/configs/arm64/qemu-arm64.c
index 4b0826cd..786bddb2 100644
--- a/configs/arm64/qemu-arm64.c
+++ b/configs/arm64/qemu-arm64.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[4];
+ struct jailhouse_memory mem_regions[5];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -109,7 +109,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/ultra96-linux-demo.c b/configs/arm64/ultra96-linux-demo.c
index 4aea2922..a9ce834e 100644
--- a/configs/arm64/ultra96-linux-demo.c
+++ b/configs/arm64/ultra96-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -99,7 +99,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/ultra96.c b/configs/arm64/ultra96.c
index ef49b824..890c121c 100644
--- a/configs/arm64/ultra96.c
+++ b/configs/arm64/ultra96.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[3];
+ struct jailhouse_memory mem_regions[4];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
@@ -101,7 +101,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo-2.c b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
index 5248952d..a02da41d 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo-2.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[7];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[2];
} __attribute__((packed)) config = {
@@ -95,7 +95,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 1 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
@@ -103,7 +103,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 2 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 1,
+ .shmem_regions_start = 2,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo.c b/configs/arm64/zynqmp-zcu102-linux-demo.c
index f9b804a4..d11d7c64 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[2];
} __attribute__((packed)) config = {
@@ -101,7 +101,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
@@ -109,7 +109,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 2 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 1,
+ .shmem_regions_start = 2,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102.c b/configs/arm64/zynqmp-zcu102.c
index efd81389..1eb165af 100644
--- a/configs/arm64/zynqmp-zcu102.c
+++ b/configs/arm64/zynqmp-zcu102.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[2];
} __attribute__((packed)) config = {
@@ -120,7 +120,7 @@ struct {
.domain = 1,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
@@ -129,7 +129,7 @@ struct {
.domain = 1,
.bdf = 1 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_region = 1,
+ .shmem_regions_start = 2,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/x86/ivshmem-demo.c b/configs/x86/ivshmem-demo.c
index e53965ff..0e0644b9 100644
--- a/configs/x86/ivshmem-demo.c
+++ b/configs/x86/ivshmem-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[3];
+ struct jailhouse_memory mem_regions[4];
struct jailhouse_pio pio_regions[2];
struct jailhouse_pci_device pci_devices[1];
struct jailhouse_pci_capability pci_caps[0];
@@ -50,11 +50,17 @@ struct {
},

.mem_regions = {
- /* IVSHMEM shared memory region */
+ /* IVSHMEM shared memory regions (demo) */
{
.phys_start = 0x3f0f0000,
.virt_start = 0x3f0f0000,
.size = 0x1000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
+ },
+ {
+ .phys_start = 0x3f0f1000,
+ .virt_start = 0x3f0f1000,
+ .size = 0x9000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_ROOTSHARED,
},
@@ -85,7 +91,7 @@ struct {
.bdf = 0x0e << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
},
},
diff --git a/configs/x86/linux-x86-demo.c b/configs/x86/linux-x86-demo.c
index 70cfc4ad..468f01f7 100644
--- a/configs/x86/linux-x86-demo.c
+++ b/configs/x86/linux-x86-demo.c
@@ -19,9 +19,9 @@ struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
#ifdef CONFIG_QEMU_E1000E_ASSIGNMENT
- struct jailhouse_memory mem_regions[8];
+ struct jailhouse_memory mem_regions[9];
#else
- struct jailhouse_memory mem_regions[4];
+ struct jailhouse_memory mem_regions[5];
#endif
struct jailhouse_cache cache_regions[1];
struct jailhouse_irqchip irqchips[1];
@@ -54,7 +54,7 @@ struct {
},

.mem_regions = {
- /* IVSHMEM shared memory region */
+ /* IVSHMEM shared memory regions (networking) */
JAILHOUSE_SHMEM_NET_REGIONS(0x3f100000, 1),
/* low RAM */ {
.phys_start = 0x3a600000,
@@ -141,7 +141,7 @@ struct {
.bdf = 0x0f << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/x86/qemu-x86.c b/configs/x86/qemu-x86.c
index 4aa789b1..1c6f0d84 100644
--- a/configs/x86/qemu-x86.c
+++ b/configs/x86/qemu-x86.c
@@ -22,7 +22,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[16];
+ struct jailhouse_memory mem_regions[18];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pio pio_regions[12];
struct jailhouse_pci_device pci_devices[9];
@@ -74,14 +74,20 @@ struct {
},

.mem_regions = {
- /* IVSHMEM shared memory region (demo) */
+ /* IVSHMEM shared memory regions (demo) */
{
.phys_start = 0x3f0f0000,
.virt_start = 0x3f0f0000,
.size = 0x1000,
+ .flags = JAILHOUSE_MEM_READ,
+ },
+ {
+ .phys_start = 0x3f0f1000,
+ .virt_start = 0x3f0f1000,
+ .size = 0x9000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
},
- /* IVSHMEM shared memory region (networking) */
+ /* IVSHMEM shared memory regions (networking) */
JAILHOUSE_SHMEM_NET_REGIONS(0x3f100000, 0),
/* RAM */ {
.phys_start = 0x0,
@@ -277,7 +283,7 @@ struct {
.bdf = 0x0e << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 0,
+ .shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
},
@@ -287,7 +293,7 @@ struct {
.bdf = 0x0f << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 1,
- .shmem_region = 1,
+ .shmem_regions_start = 2,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 8d8481c7..8d3dae00 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -38,6 +38,7 @@
#define IVSHMEM_CFG_MSIX_CAP (IVSHMEM_CFG_VNDR_CAP + \
IVSHMEM_CFG_VNDR_LEN)

+#define IVSHMEM_CFG_SHMEM_STATE_TAB_SZ (IVSHMEM_CFG_VNDR_CAP + 0x04)
#define IVSHMEM_CFG_SHMEM_RW_SZ (IVSHMEM_CFG_VNDR_CAP + 0x08)
#define IVSHMEM_CFG_SHMEM_ADDR (IVSHMEM_CFG_VNDR_CAP + 0x18)
#define IVSHMEM_CFG_VNDR_LEN 0x20
@@ -54,8 +55,7 @@
#define IVSHMEM_REG_MAX_PEERS 0x04
#define IVSHMEM_REG_INTX_CTRL 0x08
#define IVSHMEM_REG_DOORBELL 0x0c
-#define IVSHMEM_REG_LSTATE 0x10
-#define IVSHMEM_REG_RSTATE 0x14
+#define IVSHMEM_REG_STATE 0x10

struct ivshmem_link {
struct ivshmem_endpoint eps[IVSHMEM_MAX_PEERS];
@@ -91,6 +91,31 @@ static void ivshmem_remote_interrupt(struct ivshmem_endpoint *ive)
spin_unlock(&ive->remote_lock);
}

+static void ivshmem_write_state(struct ivshmem_endpoint *ive, u32 new_state)
+{
+ const struct jailhouse_pci_device *dev_info = ive->device->info;
+ u32 *state_table = (u32 *)TEMPORARY_MAPPING_BASE;
+
+ /*
+ * Cannot fail: upper levels of page table were already created by
+ * paging_init, and we always map single pages, thus only update the
+ * leaf entry and do not have to deal with huge pages.
+ */
+ paging_create(&this_cpu_data()->pg_structs,
+ ive->shmem[0].phys_start, PAGE_SIZE,
+ (unsigned long)state_table, PAGE_DEFAULT_FLAGS,
+ PAGING_NON_COHERENT);
+
+ state_table[dev_info->shmem_dev_id] = new_state;
+ memory_barrier();
+
+ if (ive->state != new_state) {
+ ive->state = new_state;
+
+ ivshmem_remote_interrupt(ive);
+ }
+}
+
int ivshmem_update_msix(struct pci_device *device)
{
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
@@ -145,19 +170,11 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
else
mmio->value = 0;
break;
- case IVSHMEM_REG_LSTATE:
- if (mmio->is_write) {
- ive->state = mmio->value;
- ivshmem_remote_interrupt(ive);
- } else {
+ case IVSHMEM_REG_STATE:
+ if (mmio->is_write)
+ ivshmem_write_state(ive, mmio->value);
+ else
mmio->value = ive->state;
- }
- break;
- case IVSHMEM_REG_RSTATE:
- /* read-only remote state */
- spin_lock(&ive->remote_lock);
- mmio->value = ive->remote ? ive->remote->state : 0;
- spin_unlock(&ive->remote_lock);
break;
default:
/* ignore any other access */
@@ -315,7 +332,6 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
{
const struct jailhouse_pci_device *dev_info = device->info;
struct ivshmem_endpoint *ive, *remote;
- const struct jailhouse_memory *mem;
struct pci_device *peer_dev;
struct ivshmem_link *link;
unsigned int id;
@@ -323,11 +339,10 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
printk("Adding virtual PCI device %02x:%02x.%x to cell \"%s\"\n",
PCI_BDF_PARAMS(dev_info->bdf), cell->config->name);

- if (dev_info->shmem_region >= cell->config->num_memory_regions)
+ if (dev_info->shmem_regions_start + 2 >
+ cell->config->num_memory_regions)
return trace_error(-EINVAL);

- mem = jailhouse_cell_mem_regions(cell->config) + dev_info->shmem_region;
-
for (link = ivshmem_links; link; link = link->next)
if (link->bdf == dev_info->bdf)
break;
@@ -361,7 +376,8 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)

ive->device = device;
ive->link = link;
- ive->shmem = mem;
+ ive->shmem = jailhouse_cell_mem_regions(cell->config) +
+ dev_info->shmem_regions_start;
device->ivshmem_endpoint = ive;
if (remote->device) {
ive->remote = remote;
@@ -400,14 +416,17 @@ void ivshmem_reset(struct pci_device *device)
device->msix_vectors[0].masked = 1;
}

- ive->cspace[IVSHMEM_CFG_SHMEM_RW_SZ/4] = (u32)ive->shmem->size;
+ ive->cspace[IVSHMEM_CFG_SHMEM_STATE_TAB_SZ/4] = (u32)ive->shmem[0].size;
+
+ ive->cspace[IVSHMEM_CFG_SHMEM_RW_SZ/4] = (u32)ive->shmem[1].size;
ive->cspace[IVSHMEM_CFG_SHMEM_RW_SZ/4 + 1] =
- (u32)(ive->shmem->size >> 32);
- ive->cspace[IVSHMEM_CFG_SHMEM_ADDR/4] = (u32)ive->shmem->virt_start;
+ (u32)(ive->shmem[1].size >> 32);
+
+ ive->cspace[IVSHMEM_CFG_SHMEM_ADDR/4] = (u32)ive->shmem[0].virt_start;
ive->cspace[IVSHMEM_CFG_SHMEM_ADDR/4 + 1] =
- (u32)(ive->shmem->virt_start >> 32);
+ (u32)(ive->shmem[0].virt_start >> 32);

- ive->state = 0;
+ ivshmem_write_state(ive, 0);
}

/**
@@ -431,7 +450,7 @@ void ivshmem_exit(struct pci_device *device)
remote->remote = NULL;
spin_unlock(&remote->remote_lock);

- ivshmem_remote_interrupt(ive);
+ ivshmem_write_state(ive, 0);

ive->device = NULL;
} else {
diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index f82bbe8d..da100e18 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -133,7 +133,13 @@ struct jailhouse_memory {
{ \
.phys_start = start, \
.virt_start = start, \
- .size = 0x100000, \
+ .size = 0x1000, \
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED, \
+ }, \
+ { \
+ .phys_start = (start) + 0x1000, \
+ .virt_start = (start) + 0x1000, \
+ .size = 0xff000, \
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | \
JAILHOUSE_MEM_ROOTSHARED, \
}
@@ -185,8 +191,8 @@ struct jailhouse_pci_device {
__u16 num_msix_vectors;
__u16 msix_region_size;
__u64 msix_address;
- /** Memory region index of shared memory device. */
- __u32 shmem_region;
+ /** First memory region index of shared memory device. */
+ __u32 shmem_regions_start;
/** ID of shared memory device (0..1). */
__u8 shmem_dev_id;
__u8 padding;
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:04 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Revamp data structure, updating and locking around ivshmem interrupt
injection.

The structure arch_pci_ivshmem is renamed to arch_ivshmem_irq_cache to
clarify the purpose of this. This allows to invalidate the case
generically by setting it to 0.

The remote_lock is redefined as irq_lock, now protecting cache update
and usage as well as serializing updates with injections. We do not need
a lock around ivshmem_endpoint::remote updates because the pointer will
never reference an object that is no longer existing after removal.
Instead, the update of irq_cache while holding irq_lock now acts as
barrier.

Furthermore, ensure irq_cache invalidation on device reset. Not
performing that step so far could have caused bogus interrupt delivery
between cell reset and ivshmem device re-initialization.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/arm-common/include/asm/ivshmem.h | 4 +-
hypervisor/arch/arm-common/ivshmem.c | 20 +++++--
hypervisor/arch/x86/include/asm/ivshmem.h | 4 +-
hypervisor/arch/x86/ivshmem.c | 67 ++++++++++--------------
hypervisor/include/jailhouse/ivshmem.h | 6 ++-
hypervisor/ivshmem.c | 39 +++++++++-----
6 files changed, 79 insertions(+), 61 deletions(-)

diff --git a/hypervisor/arch/arm-common/include/asm/ivshmem.h b/hypervisor/arch/arm-common/include/asm/ivshmem.h
index 8110ca30..a6ff33df 100644
--- a/hypervisor/arch/arm-common/include/asm/ivshmem.h
+++ b/hypervisor/arch/arm-common/include/asm/ivshmem.h
@@ -10,6 +10,6 @@
* the COPYING file in the top-level directory.
*/

-struct arch_pci_ivshmem {
- u16 irq_id;
+struct arch_ivshmem_irq_cache {
+ u16 id;
};
diff --git a/hypervisor/arch/arm-common/ivshmem.c b/hypervisor/arch/arm-common/ivshmem.c
index 7b98b6da..986eb2cb 100644
--- a/hypervisor/arch/arm-common/ivshmem.c
+++ b/hypervisor/arch/arm-common/ivshmem.c
@@ -1,7 +1,7 @@
/*
* Jailhouse, a Linux-based partitioning hypervisor
*
- * Copyright (c) Siemens AG, 2016
+ * Copyright (c) Siemens AG, 2016-2019
*
* Author:
* Jan Kiszka <jan.k...@siemens.com>
@@ -15,7 +15,7 @@

void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive)
{
- unsigned int irq_id = ive->arch.irq_id;
+ unsigned int irq_id = ive->irq_cache.id;

if (irq_id)
irqchip_set_pending(NULL, irq_id);
@@ -33,7 +33,13 @@ int arch_ivshmem_update_msix(struct pci_device *device, bool enabled)
return -EPERM;
}

- ive->arch.irq_id = irq_id;
+ /*
+ * Lock used as barrier, ensuring all interrupts triggered after return
+ * use the new setting.
+ */
+ spin_lock(&ive->irq_lock);
+ ive->irq_cache.id = irq_id;
+ spin_unlock(&ive->irq_lock);

return 0;
}
@@ -43,6 +49,12 @@ void arch_ivshmem_update_intx(struct ivshmem_endpoint *ive, bool enabled)
u8 pin = ive->cspace[PCI_CFG_INT/4] >> 8;
struct pci_device *device = ive->device;

- ive->arch.irq_id = enabled ?
+ /*
+ * Lock used as barrier, ensuring all interrupts triggered after return
+ * use the new setting.
+ */
+ spin_lock(&ive->irq_lock);
+ ive->irq_cache.id = enabled ?
(32 + device->cell->config->vpci_irq_base + pin - 1) : 0;
+ spin_unlock(&ive->irq_lock);
}
diff --git a/hypervisor/arch/x86/include/asm/ivshmem.h b/hypervisor/arch/x86/include/asm/ivshmem.h
index 6eb66da1..bf9e61f0 100644
--- a/hypervisor/arch/x86/include/asm/ivshmem.h
+++ b/hypervisor/arch/x86/include/asm/ivshmem.h
@@ -12,6 +12,6 @@

#include <asm/apic.h>

-struct arch_pci_ivshmem {
- struct apic_irq_message irq_msg;
+struct arch_ivshmem_irq_cache {
+ struct apic_irq_message msg;
};
diff --git a/hypervisor/arch/x86/ivshmem.c b/hypervisor/arch/x86/ivshmem.c
index 909b7f8e..3692271c 100644
--- a/hypervisor/arch/x86/ivshmem.c
+++ b/hypervisor/arch/x86/ivshmem.c
@@ -1,10 +1,11 @@
/*
* Jailhouse, a Linux-based partitioning hypervisor
*
- * Copyright (c) Siemens AG, 2014-2016
+ * Copyright (c) Siemens AG, 2014-2019
*
* Author:
* Henning Schild <henning...@siemens.com>
+ * Jan Kiszka <jan.k...@siemens.com>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
@@ -18,49 +19,39 @@

void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive)
{
- /* Get a copy of the struct before using it. */
- struct apic_irq_message irq_msg = ive->arch.irq_msg;
-
- /* The read barrier makes sure the copy is consistent. */
- memory_load_barrier();
- if (irq_msg.valid)
- apic_send_irq(irq_msg);
+ if (ive->irq_cache.msg.valid)
+ apic_send_irq(ive->irq_cache.msg);
}

int arch_ivshmem_update_msix(struct pci_device *device, bool enabled)
{
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
- union x86_msi_vector msi = {
- .raw.address = device->msix_vectors[0].address,
- .raw.data = device->msix_vectors[0].data,
- };
- struct apic_irq_message irq_msg;
-
- /* before doing anything mark the cached irq_msg as invalid,
- * on success it will be valid on return. */
- ive->arch.irq_msg.valid = 0;
- memory_barrier();
-
- if (!enabled)
- return 0;
-
- irq_msg = x86_pci_translate_msi(device, 0, 0, msi);
- if (!irq_msg.valid)
- return 0;
-
- if (!apic_filter_irq_dest(device->cell, &irq_msg)) {
- panic_printk("FATAL: ivshmem MSI-X target outside of "
- "cell \"%s\" device %02x:%02x.%x\n",
- device->cell->config->name,
- PCI_BDF_PARAMS(device->info->bdf));
- return -EPERM;
+ struct apic_irq_message irq_msg = { .valid = 0 };
+ union x86_msi_vector msi;
+
+ if (enabled) {
+ msi.raw.address = device->msix_vectors[0].address;
+ msi.raw.data = device->msix_vectors[0].data;
+
+ irq_msg = x86_pci_translate_msi(device, 0, 0, msi);
+
+ if (irq_msg.valid &&
+ !apic_filter_irq_dest(device->cell, &irq_msg)) {
+ panic_printk("FATAL: ivshmem MSI-X target outside of "
+ "cell \"%s\" device %02x:%02x.%x\n",
+ device->cell->config->name,
+ PCI_BDF_PARAMS(device->info->bdf));
+ return -EPERM;
+ }
}
- /* now copy the whole struct into our cache and mark the cache
- * valid at the end */
- irq_msg.valid = 0;
- ive->arch.irq_msg = irq_msg;
- memory_barrier();
- ive->arch.irq_msg.valid = 1;
+
+ /*
+ * Lock used as barrier, ensuring all interrupts triggered after return
+ * use the new setting.
+ */
+ spin_lock(&ive->irq_lock);
+ ive->irq_cache.msg = irq_msg;
+ spin_unlock(&ive->irq_lock);

return 0;
}
diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index b62564d8..fe641dd0 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -31,14 +31,16 @@ struct ivshmem_link;

struct ivshmem_endpoint {
u32 cspace[IVSHMEM_CFG_SIZE / sizeof(u32)];
+ /** Lock protecting accesses to irq_cache, also synchronizing
+ * interrupt submissions with device shutdown. */
+ spinlock_t irq_lock;
+ struct arch_ivshmem_irq_cache irq_cache;
u32 state;
u32 ioregion[2];
struct pci_device *device;
struct ivshmem_link *link;
const struct jailhouse_memory *shmem;
struct ivshmem_endpoint *remote;
- spinlock_t remote_lock;
- struct arch_pci_ivshmem arch;
u32 intx_ctrl_reg;
};

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 8d3dae00..bcc20ed2 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -81,14 +81,18 @@ static const u32 default_cspace[IVSHMEM_CFG_SIZE / sizeof(u32)] = {

static void ivshmem_remote_interrupt(struct ivshmem_endpoint *ive)
{
+ struct ivshmem_endpoint *remote = ive->remote;
+
+ if (!remote)
+ return;
+
/*
- * Hold the remote lock while sending the interrupt so that
- * ivshmem_exit can synchronize on the completion of the delivery.
+ * Hold the IRQ lock while sending the interrupt so that ivshmem_exit
+ * can synchronize on the completion of the delivery.
*/
- spin_lock(&ive->remote_lock);
- if (ive->remote)
- arch_ivshmem_trigger_interrupt(ive->remote);
- spin_unlock(&ive->remote_lock);
+ spin_lock(&remote->irq_lock);
+ arch_ivshmem_trigger_interrupt(remote);
+ spin_unlock(&remote->irq_lock);
}

static void ivshmem_write_state(struct ivshmem_endpoint *ive, u32 new_state)
@@ -394,6 +398,14 @@ void ivshmem_reset(struct pci_device *device)
{
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;

+ /*
+ * Hold the spinlock while invalidating in order to synchronize with
+ * any in-flight interrupt from remote sides.
+ */
+ spin_lock(&ive->irq_lock);
+ memset(&ive->irq_cache, 0, sizeof(ive->irq_cache));
+ spin_unlock(&ive->irq_lock);
+
if (ive->cspace[PCI_CFG_COMMAND/4] & PCI_CMD_MEM) {
mmio_region_unregister(device->cell, ive->ioregion[0]);
mmio_region_unregister(device->cell, ive->ioregion[1]);
@@ -440,15 +452,16 @@ void ivshmem_exit(struct pci_device *device)
struct ivshmem_endpoint *remote = ive->remote;
struct ivshmem_link **linkp;

+ /*
+ * Hold the spinlock while invalidating in order to synchronize with
+ * any in-flight interrupt from remote sides.
+ */
+ spin_lock(&ive->irq_lock);
+ memset(&ive->irq_cache, 0, sizeof(ive->irq_cache));
+ spin_unlock(&ive->irq_lock);
+
if (remote) {
- /*
- * The spinlock synchronizes the disconnection of the remote
- * device with any in-flight interrupts targeting the device
- * to be destroyed.
- */
- spin_lock(&remote->remote_lock);
remote->remote = NULL;
- spin_unlock(&remote->remote_lock);

ivshmem_write_state(ive, 0);

--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:04 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This allows to spread out state-related interrupts (always vector 0) and
other sources (e.g. RX/TX). The doorbell register accepts the desired
vector in its lower 16 bits, ignoring anything that is not supported by
the peers.

The MSI-X MMIO region is expanded to hold the maximum possible number of
vectors (currently 16). This static sizing keeps the hypervisor simple.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/arm-common/include/asm/ivshmem.h | 2 +-
hypervisor/arch/arm-common/ivshmem.c | 14 +++---
hypervisor/arch/x86/include/asm/ivshmem.h | 2 +-
hypervisor/arch/x86/ivshmem.c | 18 ++++---
hypervisor/arch/x86/vtd.c | 2 +-
hypervisor/include/jailhouse/ivshmem.h | 16 ++++--
hypervisor/ivshmem.c | 63 +++++++++++++++++-------
include/jailhouse/cell-config.h | 2 +-
8 files changed, 79 insertions(+), 40 deletions(-)

diff --git a/hypervisor/arch/arm-common/include/asm/ivshmem.h b/hypervisor/arch/arm-common/include/asm/ivshmem.h
index a6ff33df..655ad704 100644
--- a/hypervisor/arch/arm-common/include/asm/ivshmem.h
+++ b/hypervisor/arch/arm-common/include/asm/ivshmem.h
@@ -11,5 +11,5 @@
*/

struct arch_ivshmem_irq_cache {
- u16 id;
+ u16 id[IVSHMEM_MSIX_VECTORS];
};
diff --git a/hypervisor/arch/arm-common/ivshmem.c b/hypervisor/arch/arm-common/ivshmem.c
index d9622c39..98206f05 100644
--- a/hypervisor/arch/arm-common/ivshmem.c
+++ b/hypervisor/arch/arm-common/ivshmem.c
@@ -13,22 +13,24 @@
#include <jailhouse/ivshmem.h>
#include <asm/irqchip.h>

-void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive)
+void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive,
+ unsigned int vector)
{
- unsigned int irq_id = ive->irq_cache.id;
+ unsigned int irq_id = ive->irq_cache.id[vector];

if (irq_id)
irqchip_set_pending(NULL, irq_id);
}

-int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, bool enabled)
+int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, unsigned int vector,
+ bool enabled)
{
struct pci_device *device = ive->device;
unsigned int irq_id = 0;

if (enabled) {
/* FIXME: validate MSI-X target address */
- irq_id = device->msix_vectors[0].data;
+ irq_id = device->msix_vectors[vector].data;
if (irq_id < 32 || !irqchip_irq_in_cell(device->cell, irq_id))
return -EPERM;
}
@@ -38,7 +40,7 @@ int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, bool enabled)
* use the new setting.
*/
spin_lock(&ive->irq_lock);
- ive->irq_cache.id = irq_id;
+ ive->irq_cache.id[vector] = irq_id;
spin_unlock(&ive->irq_lock);

return 0;
@@ -54,7 +56,7 @@ void arch_ivshmem_update_intx(struct ivshmem_endpoint *ive, bool enabled)
* use the new setting.
*/
spin_lock(&ive->irq_lock);
- ive->irq_cache.id = enabled ?
+ ive->irq_cache.id[0] = enabled ?
(32 + device->cell->config->vpci_irq_base + pin - 1) : 0;
spin_unlock(&ive->irq_lock);
}
diff --git a/hypervisor/arch/x86/include/asm/ivshmem.h b/hypervisor/arch/x86/include/asm/ivshmem.h
index bf9e61f0..69662b70 100644
--- a/hypervisor/arch/x86/include/asm/ivshmem.h
+++ b/hypervisor/arch/x86/include/asm/ivshmem.h
@@ -13,5 +13,5 @@
#include <asm/apic.h>

struct arch_ivshmem_irq_cache {
- struct apic_irq_message msg;
+ struct apic_irq_message msg[IVSHMEM_MSIX_VECTORS];
};
diff --git a/hypervisor/arch/x86/ivshmem.c b/hypervisor/arch/x86/ivshmem.c
index 51d63db9..62c1808e 100644
--- a/hypervisor/arch/x86/ivshmem.c
+++ b/hypervisor/arch/x86/ivshmem.c
@@ -17,23 +17,25 @@
#include <jailhouse/printk.h>
#include <asm/pci.h>

-void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive)
+void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive,
+ unsigned int vector)
{
- if (ive->irq_cache.msg.valid)
- apic_send_irq(ive->irq_cache.msg);
+ if (ive->irq_cache.msg[vector].valid)
+ apic_send_irq(ive->irq_cache.msg[vector]);
}

-int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, bool enabled)
+int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, unsigned int vector,
+ bool enabled)
{
struct apic_irq_message irq_msg = { .valid = 0 };
struct pci_device *device = ive->device;
union x86_msi_vector msi;

if (enabled) {
- msi.raw.address = device->msix_vectors[0].address;
- msi.raw.data = device->msix_vectors[0].data;
+ msi.raw.address = device->msix_vectors[vector].address;
+ msi.raw.data = device->msix_vectors[vector].data;

- irq_msg = x86_pci_translate_msi(device, 0, 0, msi);
+ irq_msg = x86_pci_translate_msi(device, vector, 0, msi);

if (irq_msg.valid &&
!apic_filter_irq_dest(device->cell, &irq_msg)) {
@@ -50,7 +52,7 @@ int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, bool enabled)
* use the new setting.
*/
spin_lock(&ive->irq_lock);
- ive->irq_cache.msg = irq_msg;
+ ive->irq_cache.msg[vector] = irq_msg;
spin_unlock(&ive->irq_lock);

return 0;
diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c
index 8065d8fe..377aa00d 100644
--- a/hypervisor/arch/x86/vtd.c
+++ b/hypervisor/arch/x86/vtd.c
@@ -400,7 +400,7 @@ static int vtd_emulate_inv_int(unsigned int unit_no, unsigned int index)
device = pci_get_assigned_device(&root_cell, irte_usage->device_id);
/* On x86, ivshmem devices only support MSI-X. */
if (device && device->info->type == JAILHOUSE_PCI_TYPE_IVSHMEM)
- return ivshmem_update_msix(device);
+ return ivshmem_update_msix_vector(device, irte_usage->vector);

irq_msg = iommu_get_remapped_root_int(unit_no, irte_usage->device_id,
irte_usage->vector, index);
diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index 5de45e73..aa5472ac 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -15,9 +15,12 @@
#define _JAILHOUSE_IVSHMEM_H

#include <jailhouse/pci.h>
-#include <asm/ivshmem.h>
#include <asm/spinlock.h>

+#define IVSHMEM_MSIX_VECTORS PCI_EMBEDDED_MSIX_VECTS
+
+#include <asm/ivshmem.h>
+
#define IVSHMEM_CFG_SIZE 0x80

#define IVSHMEM_INTX_ENABLE 0x1
@@ -47,6 +50,7 @@ struct ivshmem_endpoint {
int ivshmem_init(struct cell *cell, struct pci_device *device);
void ivshmem_reset(struct pci_device *device);
void ivshmem_exit(struct pci_device *device);
+int ivshmem_update_msix_vector(struct pci_device *device, unsigned int vector);
int ivshmem_update_msix(struct pci_device *device);
enum pci_access ivshmem_pci_cfg_write(struct pci_device *device,
unsigned int row, u32 mask, u32 value);
@@ -56,17 +60,21 @@ enum pci_access ivshmem_pci_cfg_read(struct pci_device *device, u16 address,
/**
* Trigger interrupt on ivshmem endpoint.
* @param ive Ivshmem endpoint the interrupt should be raised at.
+ * @param vector Interrupt vector to trigger.
*/
-void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive);
+void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive,
+ unsigned int vector);

/**
- * Update cached MSI-X state (if any) of the given ivshmem device.
+ * Update cached MSI-X state (if any) of the given ivshmem device and vector.
* @param ive Ivshmem endpoint to be updated.
+ * @param vector Interrupt vector to update.
* @param enabled True if MSI-X is enabled and unmasked.
*
* @return 0 on success, negative error code otherwise.
*/
-int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, bool enabled);
+int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, unsigned int vector,
+ bool enabled);

/**
* Update cached INTx state (if any) of the given ivshmem device.
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 293dedc5..46a18d0d 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -43,8 +43,6 @@
#define IVSHMEM_CFG_SHMEM_ADDR (IVSHMEM_CFG_VNDR_CAP + 0x18)
#define IVSHMEM_CFG_VNDR_LEN 0x20

-#define IVSHMEM_MSIX_VECTORS 1
-
/*
* Make the region two times as large as the MSI-X table to guarantee a
* power-of-2 size (encoding constraint of a BAR).
@@ -73,20 +71,20 @@ static const u32 default_cspace[IVSHMEM_CFG_SIZE / sizeof(u32)] = {
[PCI_CFG_CAPS/4] = IVSHMEM_CFG_VNDR_CAP,
[IVSHMEM_CFG_VNDR_CAP/4] = (IVSHMEM_CFG_VNDR_LEN << 16) |
(IVSHMEM_CFG_MSIX_CAP << 8) | PCI_CAP_ID_VNDR,
- [IVSHMEM_CFG_MSIX_CAP/4] = (IVSHMEM_MSIX_VECTORS - 1) << 16 |
- (0x00 << 8) | PCI_CAP_ID_MSIX,
+ [IVSHMEM_CFG_MSIX_CAP/4] = (0x00 << 8) | PCI_CAP_ID_MSIX,
[(IVSHMEM_CFG_MSIX_CAP + 0x4)/4] = 1,
[(IVSHMEM_CFG_MSIX_CAP + 0x8)/4] = 0x10 * IVSHMEM_MSIX_VECTORS | 1,
};

-static void ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive)
+static void ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive,
+ unsigned int vector)
{
/*
* Hold the IRQ lock while sending the interrupt so that ivshmem_exit
* can synchronize on the completion of the delivery.
*/
spin_lock(&ive->irq_lock);
- arch_ivshmem_trigger_interrupt(ive);
+ arch_ivshmem_trigger_interrupt(ive, vector);
spin_unlock(&ive->irq_lock);
}

@@ -113,25 +111,33 @@ static void ivshmem_write_state(struct ivshmem_endpoint *ive, u32 new_state)
ive->state = new_state;

target_ive = &ive->link->eps[dev_info->shmem_dev_id ^ 1];
- ivshmem_trigger_interrupt(target_ive);
+ ivshmem_trigger_interrupt(target_ive, 0);
}
}

-int ivshmem_update_msix(struct pci_device *device)
+int ivshmem_update_msix_vector(struct pci_device *device, unsigned int vector)
{
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
union pci_msix_registers cap;
bool enabled;

- if (device->info->num_msix_vectors == 0)
- return 0;
-
cap.raw = ive->cspace[IVSHMEM_CFG_MSIX_CAP/4];
enabled = cap.enable && !cap.fmask &&
- !ive->device->msix_vectors[0].masked &&
+ !device->msix_vectors[vector].masked &&
ive->cspace[PCI_CFG_COMMAND/4] & PCI_CMD_MASTER;

- return arch_ivshmem_update_msix(ive, enabled);
+ return arch_ivshmem_update_msix(ive, vector, enabled);
+}
+
+int ivshmem_update_msix(struct pci_device *device)
+{
+ unsigned int vector, num_vectors = device->info->num_msix_vectors;
+ int err = 0;
+
+ for (vector = 0; vector < num_vectors && !err; vector++)
+ err = ivshmem_update_msix_vector(device, vector);
+
+ return err;
}

static void ivshmem_update_intx(struct ivshmem_endpoint *ive)
@@ -147,7 +153,7 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
struct mmio_access *mmio)
{
struct ivshmem_endpoint *target_ive, *ive = arg;
- unsigned int target;
+ unsigned int num_vectors, vector, target;

switch (mmio->address) {
case IVSHMEM_REG_ID:
@@ -168,13 +174,26 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
break;
case IVSHMEM_REG_DOORBELL:
if (mmio->is_write) {
+ /*
+ * All peers have the same number of MSI-X vectors,
+ * thus we can derive the limit from the local device.
+ */
+ num_vectors = ive->device->info->num_msix_vectors;
+ if (num_vectors == 0)
+ num_vectors = 1; /* INTx means one vector */
+
+ vector = GET_FIELD(mmio->value, 15, 0);
+ /* ignore out-of-range requests */
+ if (vector >= num_vectors)
+ break;
+
target = GET_FIELD(mmio->value, 31, 16);
if (target >= IVSHMEM_MAX_PEERS)
break;

target_ive = &ive->link->eps[target];

- ivshmem_trigger_interrupt(target_ive);
+ ivshmem_trigger_interrupt(target_ive, vector);
} else {
mmio->value = 0;
}
@@ -195,6 +214,7 @@ static enum mmio_result ivshmem_register_mmio(void *arg,

static enum mmio_result ivshmem_msix_mmio(void *arg, struct mmio_access *mmio)
{
+ unsigned int vector = mmio->address / sizeof(union pci_msix_vector);
struct ivshmem_endpoint *ive = arg;
u32 *msix_table = (u32 *)ive->device->msix_vectors;

@@ -211,9 +231,11 @@ static enum mmio_result ivshmem_msix_mmio(void *arg, struct mmio_access *mmio)
}
/* MSI-X Table */
} else {
+ if (vector >= ive->device->info->num_msix_vectors)
+ goto fail;
if (mmio->is_write) {
msix_table[mmio->address / 4] = mmio->value;
- if (ivshmem_update_msix(ive->device))
+ if (ivshmem_update_msix_vector(ive->device, vector))
return MMIO_ERROR;
} else {
mmio->value = msix_table[mmio->address / 4];
@@ -349,7 +371,8 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
PCI_BDF_PARAMS(dev_info->bdf), cell->config->name);

if (dev_info->shmem_regions_start + 2 >
- cell->config->num_memory_regions)
+ cell->config->num_memory_regions ||
+ dev_info->num_msix_vectors > IVSHMEM_MSIX_VECTORS)
return trace_error(-EINVAL);

for (link = ivshmem_links; link; link = link->next)
@@ -402,6 +425,7 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
void ivshmem_reset(struct pci_device *device)
{
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
+ unsigned int n;

/*
* Hold the spinlock while invalidating in order to synchronize with
@@ -430,7 +454,10 @@ void ivshmem_reset(struct pci_device *device)
/* disable MSI-X capability */
ive->cspace[IVSHMEM_CFG_VNDR_CAP/4] &= 0xffff00ff;
} else {
- device->msix_vectors[0].masked = 1;
+ ive->cspace[IVSHMEM_CFG_MSIX_CAP/4] |=
+ (device->info->num_msix_vectors - 1) << 16;
+ for (n = 0; n < device->info->num_msix_vectors; n++)
+ device->msix_vectors[n].masked = 1;
}

ive->cspace[IVSHMEM_CFG_SHMEM_STATE_TAB_SZ/4] = (u32)ive->shmem[0].size;
diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index da100e18..10ac60f9 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -208,7 +208,7 @@ struct jailhouse_pci_device {

#define JAILHOUSE_IVSHMEM_BAR_MASK_MSIX \
{ \
- 0xfffff000, 0xffffffe0, 0x00000000, \
+ 0xfffff000, 0xfffffe00, 0x00000000, \
0x00000000, 0x00000000, 0x00000000, \
}

--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:04 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

For the sake of consistency: ivshmem-internal functions should use the
ivshmem_endpoint, external ones pci_device.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/arm-common/ivshmem.c | 4 ++--
hypervisor/arch/x86/ivshmem.c | 4 ++--
hypervisor/include/jailhouse/ivshmem.h | 4 ++--
hypervisor/ivshmem.c | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hypervisor/arch/arm-common/ivshmem.c b/hypervisor/arch/arm-common/ivshmem.c
index 986eb2cb..d9622c39 100644
--- a/hypervisor/arch/arm-common/ivshmem.c
+++ b/hypervisor/arch/arm-common/ivshmem.c
@@ -21,9 +21,9 @@ void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive)
irqchip_set_pending(NULL, irq_id);
}

-int arch_ivshmem_update_msix(struct pci_device *device, bool enabled)
+int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, bool enabled)
{
- struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
+ struct pci_device *device = ive->device;
unsigned int irq_id = 0;

if (enabled) {
diff --git a/hypervisor/arch/x86/ivshmem.c b/hypervisor/arch/x86/ivshmem.c
index 3692271c..51d63db9 100644
--- a/hypervisor/arch/x86/ivshmem.c
+++ b/hypervisor/arch/x86/ivshmem.c
@@ -23,10 +23,10 @@ void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive)
apic_send_irq(ive->irq_cache.msg);
}

-int arch_ivshmem_update_msix(struct pci_device *device, bool enabled)
+int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, bool enabled)
{
- struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
struct apic_irq_message irq_msg = { .valid = 0 };
+ struct pci_device *device = ive->device;
union x86_msi_vector msi;

if (enabled) {
diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index fe641dd0..5de45e73 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -61,12 +61,12 @@ void arch_ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive);

/**
* Update cached MSI-X state (if any) of the given ivshmem device.
- * @param device The device to be updated.
+ * @param ive Ivshmem endpoint to be updated.
* @param enabled True if MSI-X is enabled and unmasked.
*
* @return 0 on success, negative error code otherwise.
*/
-int arch_ivshmem_update_msix(struct pci_device *device, bool enabled);
+int arch_ivshmem_update_msix(struct ivshmem_endpoint *ive, bool enabled);

/**
* Update cached INTx state (if any) of the given ivshmem device.
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 72699437..293dedc5 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -131,7 +131,7 @@ int ivshmem_update_msix(struct pci_device *device)
!ive->device->msix_vectors[0].masked &&
ive->cspace[PCI_CFG_COMMAND/4] & PCI_CMD_MASTER;

- return arch_ivshmem_update_msix(device, enabled);
+ return arch_ivshmem_update_msix(ive, enabled);
}

static void ivshmem_update_intx(struct ivshmem_endpoint *ive)
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:04 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Just like the original ivshmem, use the upper 16 bits of the value
written to the doorbell register. This allows both self signaling and
lays the ground for multi-peer support.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index bcc20ed2..72699437 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -79,26 +79,22 @@ static const u32 default_cspace[IVSHMEM_CFG_SIZE / sizeof(u32)] = {
[(IVSHMEM_CFG_MSIX_CAP + 0x8)/4] = 0x10 * IVSHMEM_MSIX_VECTORS | 1,
};

-static void ivshmem_remote_interrupt(struct ivshmem_endpoint *ive)
+static void ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive)
{
- struct ivshmem_endpoint *remote = ive->remote;
-
- if (!remote)
- return;
-
/*
* Hold the IRQ lock while sending the interrupt so that ivshmem_exit
* can synchronize on the completion of the delivery.
*/
- spin_lock(&remote->irq_lock);
- arch_ivshmem_trigger_interrupt(remote);
- spin_unlock(&remote->irq_lock);
+ spin_lock(&ive->irq_lock);
+ arch_ivshmem_trigger_interrupt(ive);
+ spin_unlock(&ive->irq_lock);
}

static void ivshmem_write_state(struct ivshmem_endpoint *ive, u32 new_state)
{
const struct jailhouse_pci_device *dev_info = ive->device->info;
u32 *state_table = (u32 *)TEMPORARY_MAPPING_BASE;
+ struct ivshmem_endpoint *target_ive;

/*
* Cannot fail: upper levels of page table were already created by
@@ -116,7 +112,8 @@ static void ivshmem_write_state(struct ivshmem_endpoint *ive, u32 new_state)
if (ive->state != new_state) {
ive->state = new_state;

- ivshmem_remote_interrupt(ive);
+ target_ive = &ive->link->eps[dev_info->shmem_dev_id ^ 1];
+ ivshmem_trigger_interrupt(target_ive);
}
}

@@ -149,7 +146,8 @@ static void ivshmem_update_intx(struct ivshmem_endpoint *ive)
static enum mmio_result ivshmem_register_mmio(void *arg,
struct mmio_access *mmio)
{
- struct ivshmem_endpoint *ive = arg;
+ struct ivshmem_endpoint *target_ive, *ive = arg;
+ unsigned int target;

switch (mmio->address) {
case IVSHMEM_REG_ID:
@@ -169,10 +167,17 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
}
break;
case IVSHMEM_REG_DOORBELL:
- if (mmio->is_write)
- ivshmem_remote_interrupt(ive);
- else
+ if (mmio->is_write) {
+ target = GET_FIELD(mmio->value, 31, 16);
+ if (target >= IVSHMEM_MAX_PEERS)
+ break;
+
+ target_ive = &ive->link->eps[target];
+
+ ivshmem_trigger_interrupt(target_ive);
+ } else {
mmio->value = 0;
+ }
break;
case IVSHMEM_REG_STATE:
if (mmio->is_write)
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:05 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This will allow to introduce a one-shot mode later on.

The reworked interrupt control register starts disabled on reset.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/include/jailhouse/ivshmem.h | 8 ++++----
hypervisor/ivshmem.c | 29 +++++++++++++++++++++--------
2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index aa5472ac..544432d0 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -23,7 +23,7 @@

#define IVSHMEM_CFG_SIZE 0x80

-#define IVSHMEM_INTX_ENABLE 0x1
+#define IVSHMEM_INT_ENABLE 0x1

/**
* @defgroup IVSHMEM ivshmem
@@ -34,9 +34,10 @@ struct ivshmem_link;

struct ivshmem_endpoint {
u32 cspace[IVSHMEM_CFG_SIZE / sizeof(u32)];
- /** Lock protecting accesses to irq_cache, also synchronizing
- * interrupt submissions with device shutdown. */
+ /** Lock protecting accesses to irq_cache and int_ctrl_reg, also
+ * synchronizing interrupt submissions with device shutdown. */
spinlock_t irq_lock;
+ u32 int_ctrl_reg;
struct arch_ivshmem_irq_cache irq_cache;
u32 state;
u32 ioregion[2];
@@ -44,7 +45,6 @@ struct ivshmem_endpoint {
struct ivshmem_link *link;
const struct jailhouse_memory *shmem;
struct ivshmem_endpoint *remote;
- u32 intx_ctrl_reg;
};

int ivshmem_init(struct cell *cell, struct pci_device *device);
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 46a18d0d..a7c8aeae 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -51,7 +51,7 @@

#define IVSHMEM_REG_ID 0x00
#define IVSHMEM_REG_MAX_PEERS 0x04
-#define IVSHMEM_REG_INTX_CTRL 0x08
+#define IVSHMEM_REG_INT_CTRL 0x08
#define IVSHMEM_REG_DOORBELL 0x0c
#define IVSHMEM_REG_STATE 0x10

@@ -81,10 +81,14 @@ static void ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive,
{
/*
* Hold the IRQ lock while sending the interrupt so that ivshmem_exit
- * can synchronize on the completion of the delivery.
+ * and ivshmem_register_mmio can synchronize on the completion of the
+ * delivery.
*/
spin_lock(&ive->irq_lock);
- arch_ivshmem_trigger_interrupt(ive, vector);
+
+ if (ive->int_ctrl_reg & IVSHMEM_INT_ENABLE)
+ arch_ivshmem_trigger_interrupt(ive, vector);
+
spin_unlock(&ive->irq_lock);
}

@@ -142,11 +146,10 @@ int ivshmem_update_msix(struct pci_device *device)

static void ivshmem_update_intx(struct ivshmem_endpoint *ive)
{
- bool enabled = ive->intx_ctrl_reg & IVSHMEM_INTX_ENABLE;
bool masked = ive->cspace[PCI_CFG_COMMAND/4] & PCI_CMD_INTX_OFF;

if (ive->device->info->num_msix_vectors == 0)
- arch_ivshmem_update_intx(ive, enabled && !masked);
+ arch_ivshmem_update_intx(ive, !masked);
}

static enum mmio_result ivshmem_register_mmio(void *arg,
@@ -164,12 +167,21 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
/* read-only number of peers */
mmio->value = IVSHMEM_MAX_PEERS;
break;
- case IVSHMEM_REG_INTX_CTRL:
+ case IVSHMEM_REG_INT_CTRL:
if (mmio->is_write) {
- ive->intx_ctrl_reg = mmio->value & IVSHMEM_INTX_ENABLE;
+ /*
+ * The spinlock acts as barrier, ensuring that
+ * interrupts are disabled on return.
+ */
+ spin_lock(&ive->irq_lock);
+ ive->int_ctrl_reg = mmio->value & IVSHMEM_INT_ENABLE;
+ spin_unlock(&ive->irq_lock);
+
ivshmem_update_intx(ive);
+ if (ivshmem_update_msix(ive->device))
+ return MMIO_ERROR;
} else {
- mmio->value = ive->intx_ctrl_reg;
+ mmio->value = ive->int_ctrl_reg;
}
break;
case IVSHMEM_REG_DOORBELL:
@@ -432,6 +444,7 @@ void ivshmem_reset(struct pci_device *device)
* any in-flight interrupt from remote sides.
*/
spin_lock(&ive->irq_lock);
+ ive->int_ctrl_reg = 0;
memset(&ive->irq_cache, 0, sizeof(ive->irq_cache));
spin_unlock(&ive->irq_lock);

--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:05 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Add a control flag to the vendor capability that allows to switch
interrupt delivery into a one-shot mode: If enabled, the interrupt
control register is reset after each delivery.

This feature is useful for guests that want to throttle the delivery of
ivshmem interrupts to unprivileged users. The most prominent example is
the UIO framework of Linux. It receives interrupts of UIO devices in the
kernel on behalf of the user process, disables further events and
signals the arrival to the process. That one has to re-enable interrupts
in the device. Thus, it's scheduling naturally throttles the interrupt
arrival rate. With ivshmem, this procedure requires two VM exits per
interrupts when only using the related control register. With the
one-shot mode, one exit can be avoided.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/ivshmem.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index a7c8aeae..7e376e4e 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -43,6 +43,8 @@
#define IVSHMEM_CFG_SHMEM_ADDR (IVSHMEM_CFG_VNDR_CAP + 0x18)
#define IVSHMEM_CFG_VNDR_LEN 0x20

+#define IVSHMEM_CFG_ONESHOT_INT (1 << 24)
+
/*
* Make the region two times as large as the MSI-X table to guarantee a
* power-of-2 size (encoding constraint of a BAR).
@@ -86,8 +88,13 @@ static void ivshmem_trigger_interrupt(struct ivshmem_endpoint *ive,
*/
spin_lock(&ive->irq_lock);

- if (ive->int_ctrl_reg & IVSHMEM_INT_ENABLE)
+ if (ive->int_ctrl_reg & IVSHMEM_INT_ENABLE) {
+ if (ive->cspace[IVSHMEM_CFG_VNDR_CAP/4] &
+ IVSHMEM_CFG_ONESHOT_INT)
+ ive->int_ctrl_reg = 0;
+
arch_ivshmem_trigger_interrupt(ive, vector);
+ }

spin_unlock(&ive->irq_lock);
}
@@ -338,6 +345,12 @@ enum pci_access ivshmem_pci_cfg_write(struct pci_device *device,
value & PCI_MSIX_CTRL_RW_MASK;
if (ivshmem_update_msix(device))
return PCI_ACCESS_REJECT;
+ break;
+ case IVSHMEM_CFG_VNDR_CAP / 4:
+ ive->cspace[IVSHMEM_CFG_VNDR_CAP/4] &= ~IVSHMEM_CFG_ONESHOT_INT;
+ ive->cspace[IVSHMEM_CFG_VNDR_CAP/4] |=
+ value & IVSHMEM_CFG_ONESHOT_INT;
+ break;
}
return PCI_ACCESS_DONE;
}
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:05 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

The network devices have a use case for up to 2 (config, rx/tx). And the
user-defined ones should get the maximum supported, i.e. 16.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
configs/arm64/amd-seattle-linux-demo.c | 2 +-
configs/arm64/amd-seattle.c | 2 +-
configs/x86/ivshmem-demo.c | 3 ++-
configs/x86/linux-x86-demo.c | 2 +-
configs/x86/qemu-x86.c | 4 ++--
5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/configs/arm64/amd-seattle-linux-demo.c b/configs/arm64/amd-seattle-linux-demo.c
index 7acae6e1..3da6a2e7 100644
--- a/configs/arm64/amd-seattle-linux-demo.c
+++ b/configs/arm64/amd-seattle-linux-demo.c
@@ -137,7 +137,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x0078,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
- .num_msix_vectors = 1,
+ .num_msix_vectors = 2,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
diff --git a/configs/arm64/amd-seattle.c b/configs/arm64/amd-seattle.c
index 5d810a64..44dedeb1 100644
--- a/configs/arm64/amd-seattle.c
+++ b/configs/arm64/amd-seattle.c
@@ -215,7 +215,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 0x0078,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
- .num_msix_vectors = 1,
+ .num_msix_vectors = 2,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
diff --git a/configs/x86/ivshmem-demo.c b/configs/x86/ivshmem-demo.c
index 0e0644b9..e7440f01 100644
--- a/configs/x86/ivshmem-demo.c
+++ b/configs/x86/ivshmem-demo.c
@@ -90,9 +90,10 @@ struct {
.domain = 0x0000,
.bdf = 0x0e << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
- .num_msix_vectors = 1,
+ .num_msix_vectors = 16,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
},
},
};
diff --git a/configs/x86/linux-x86-demo.c b/configs/x86/linux-x86-demo.c
index 468f01f7..b9cc7c68 100644
--- a/configs/x86/linux-x86-demo.c
+++ b/configs/x86/linux-x86-demo.c
@@ -140,7 +140,7 @@ struct {
.domain = 0x0,
.bdf = 0x0f << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
- .num_msix_vectors = 1,
+ .num_msix_vectors = 2,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
diff --git a/configs/x86/qemu-x86.c b/configs/x86/qemu-x86.c
index 1c6f0d84..ea642292 100644
--- a/configs/x86/qemu-x86.c
+++ b/configs/x86/qemu-x86.c
@@ -282,7 +282,7 @@ struct {
.domain = 0x0000,
.bdf = 0x0e << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
- .num_msix_vectors = 1,
+ .num_msix_vectors = 16,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
@@ -292,7 +292,7 @@ struct {
.domain = 0x0000,
.bdf = 0x0f << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
- .num_msix_vectors = 1,
+ .num_msix_vectors = 2,
.shmem_regions_start = 2,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:06 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This is a rewrite, pointing to the spec document for details on the
device, describing the new configuration format. The demo section is
left blank until the related ivshmem-demos are updated.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
Documentation/inter-cell-communication.md | 79 ++++++++++++++++++++++++++++++
Documentation/inter-cell-communication.txt | 76 ----------------------------
2 files changed, 79 insertions(+), 76 deletions(-)
create mode 100644 Documentation/inter-cell-communication.md
delete mode 100644 Documentation/inter-cell-communication.txt

diff --git a/Documentation/inter-cell-communication.md b/Documentation/inter-cell-communication.md
new file mode 100644
index 00000000..02136de2
--- /dev/null
+++ b/Documentation/inter-cell-communication.md
@@ -0,0 +1,79 @@
+Inter-Cell communication of the Jailhouse Hypervisor
+====================================================
+
+The hypervisor isolates cells but sometimes there is a need to exchange data
+between cells. For that purpose Jailhouse provides shared memory and signaling
+between cells via virtual ivshmem PCI devices. This device type is specified
+in [1].
+
+
+Adding Inter-cell communication
+-------------------------------
+
+In order to set up a communication channel between two or more cells you first
+have to add memory regions to both cells. Each cell needs the follow regions:
+
+ - read-only region to hold state table, generally one page large
+ - one region that is read/writable for all peers
+ - one output region per peer that is only read-writeable for one of them
+
+With 2 peers connected, this means a consecutive series of 4 regions needs to
+be created. When connecting 3 peers, 5 regions are needed, and so on. All
+regions must also be consecutive in guest-physical memory because only the
+address for the first region is communicated to the guest.
+
+The second, common read-write region is optional and can be zero-sized. Also
+the output regions are optional. All output regions must have the same size.
+Write permission to the first output region must only be granted to the cell
+that has the ivshmem device ID 0, write permission to the second region must be
+granted to ID 1, and so forth.
+
+Non-root cells sharing memory with the root cell need the memory flag
+`JAILHOUSE_MEM_ROOTSHARED` on the region.
+
+To define the memory regions of an ivshmem-net device, the macro
+`JAILHOUSE_SHMEM_NET_REGIONS(base_address, id)` is provided. It uses 1 MB of
+memory at the specified base address and assigns access according to the
+specified ID. Shared memory based network devices only connect 2 peers, thus
+4 memory regions will be added.
+
+After creating the memory regions, also a PCI device needs to be added to each
+connected cell. Set the device type to `JAILHOUSE_PCI_TYPE_IVSHMEM`. The `bdf`
+field must specify an unused bus-device-function slot on a physical or virtual
+PCI controller. All connected peers must use the same `bdf` value in order to
+establish the link. They may use different `domain` values, though.
+
+Set the bar_mask to either `JAILHOUSE_IVSHMEM_BAR_MASK_MSIX` or
+`JAILHOUSE_IVSHMEM_BAR_MASK_INTX`, depending on whether MSI-X is available or
+not. When MSI-X is used, num_msix_vectors must be set according to the needs of
+the shared memory protocol used on the link. For ivshmem networking, grant 2
+vectors.
+
+Further fields needed:
+ - `shmem_regions_start` - index of first shared memory region used by device
+ - `shmem_dev_id` - ID of the peer (0..`shmem_peers`-1)
+ - `shmem_peers` - maximum number of connected peers
+ - `shmem_protocol` - shared memory protocol used over the link
+
+Set `shmem_protocol` to JAILHOUSE_SHMEM_PROTO_VETH for ivshmem networking, use
+`JAILHOUSE_SHMEM_PROTO_UNDEFINED` for custom protocols, or pick an ID from the
+custom range defined in [1].
+
+You may also need to set the `iommu` field to match the IOMMU unit that the
+guest expects based on the `bdf` value. Try 1 if MSI-X interrupts do not make
+it when using 0.
+
+For an example have a look at the cell configuration files `qemu-x86.c`,
+`ivshmem-demo.c`, and `linux-x86-demo.c` in `configs/x86`.
+
+
+Demo code
+---------
+
+TODO
+
+
+References
+----------
+
+[1] Documentation/ivshmem-v2-specification.md
diff --git a/Documentation/inter-cell-communication.txt b/Documentation/inter-cell-communication.txt
deleted file mode 100644
index 475ca500..00000000
--- a/Documentation/inter-cell-communication.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-Inter-Cell communication of the Jailhouse Hypervisor
-====================================================
-
-The hypervisor isolates cells but sometimes there is a need to exchange data
-between cells. For that purpose Jailhouse provides shared memory and signaling
-between cells.
-
-One channel is always between exactly two cells, there is no 1:n or n:m
-communication.
-
-The interface used between the cell and the hypervisor
-------------------------------------------------------
-
-One end of such a communication channel is modeled as a PCI device that a cell
-can discover on it's PCI bus. The device model used closely follows the
-"ivshmem" device known from Qemu (see qemu docs/specs/ivshmem_device_spec.txt
-and https://gitorious.org/nahanni/).
-The device implemented by jailhouse supports MSI-X for signaling. While the
-spec would allow for multiple interrupts, Jailhouse supports exactly one per
-virtual device.
-
-The ivshmem device implemented by the jailhouse hypervisor is different to the
-mentioned specification in several regards. One is that the location and the
-size of the shared memory region itself are not encoded in a PCI BAR. Device
-drivers get the relevant information by accessing custom PCI config space
-registers. See hypervisor/pci_ivshmem.c IVSHMEM_CFG_SHMEM_* or the ivshmem demo
-in the inmates directory.
-
-To facilitate state synchronisation between cells, two additional MMIO
-registers are provided:
-
- Offset Size Access Reset Function
- 16 4 read/write 0 Local state (LSTATE)
- 20 4 read-only 0 Remote state (RSTATE)
-
-Local state: Current value is visible as RSTATE in the connected cell.
-Writes trigger the doorbell as by writing to the Doorbell register.
-
-Remote state: Returns the current value of the LSTATE register in the
-connected cell, zero if no peer is connected.
-
-Moreover, the PCI Class Code field of the Jailhouse ivshmem device differs from
-the one used by the original device. The base class code (top byte) is 0xff.
-The subclass code (middle byte) is tunable via the cell configuration to encode
-the protocol that the connected cells are expected to implement over the shared
-memory. The programming interface code (low byte) is tunable as well and is
-supposed to encode possible revisions of that protocol.
-
-Adding Inter-cell communication to cells
-----------------------------------------
-
-In order to set up a communication channel between two cells you first have to
-add a memory region to both cells. Add a read/write region with matching size
-and physical address to both cells. Non-root cells sharing memory with the
-root cell need the memory flag "JAILHOUSE_MEM_ROOTSHARED" on the region.
-To allow cells to discover shared memory and send each other MSIs you also
-need to add a virtual PCI device to both cells. The "type" should be set to
-"JAILHOUSE_PCI_TYPE_IVSHMEM" and "shmem_region" should be set to the index
-of the memory region. "num_msix_vectors" should be set to 1 and for your root
-cell config you should make sure that "iommu" is set to the correct value,
- try using the same value that works for the other pci devices.
-The link between two such virtual PCI devices is established by using the same
-"bdf". The size and location of the shared memory can be configured freely but
-you have to make sure that the values match on both sides. The "shmem_protocol"
-has to match as well.
-For an example have a look at the cell configuration files of qemu and the
-ivshmem-demo.
-
-Demo code
----------
-
-You can go ahead and connect two non-root cells and run the ivshmem-demo. They
-will send each other interrupts.
-For the root cell you can find some test code in the following git repository:
-https://github.com/henning-schild-work/ivshmem-guest-code
-Check out the jailhouse branch and have a look at README.jailhouse.
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:06 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Drop the possibility to carry ivshmem protocol revision numbers in the
scarce 16-bit space of the protocol ID. Rather force users to either to
revision management inside the protocol (e.g. via shared memory) or use
a new protocol ID in case of incompatible changes - or even avoid such
incompatible changes. This frees more space that we will need when we
want to map virtio device types into this namespace.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
include/jailhouse/cell-config.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index 6d397d9c..7694c296 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -182,8 +182,8 @@ struct jailhouse_irqchip {
#define JAILHOUSE_PCI_TYPE_IVSHMEM 0x03

#define JAILHOUSE_SHMEM_PROTO_UNDEFINED 0x0000
-#define JAILHOUSE_SHMEM_PROTO_VETH 0x0100
-#define JAILHOUSE_SHMEM_PROTO_CUSTOM 0x8000 /* 0x80xx..0xffxx */
+#define JAILHOUSE_SHMEM_PROTO_VETH 0x0001
+#define JAILHOUSE_SHMEM_PROTO_CUSTOM 0x4000 /* 0x4000..0x7fff */

struct jailhouse_pci_device {
__u8 type;
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:06 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This adds optional peer-specific output sections to the shared memory
region. Each peer will get its own read/write section that other peers
can only read from. The benefit of such model is that senders can be
sure their messages cannot be concurrently modified by other peers while
they are creating and before they may have signed them. Having a
private section avoids to need to copy in complete messages in integrity
sensitive scenarios.

These output sections are located after the common read/write section.
Their presence is signaled by non-zero value in the output section size
register.

Consequently, all configs need to append two memory regions per ivshmem
device. We switch all ivshmem-net users to this unidirectional model,
setting their common read/write section to zero.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
configs/arm/bananapi-linux-demo.c | 2 +-
configs/arm/bananapi.c | 2 +-
configs/arm/emtrion-rzg1e-linux-demo.c | 2 +-
configs/arm/emtrion-rzg1e.c | 2 +-
configs/arm/emtrion-rzg1h-linux-demo.c | 2 +-
configs/arm/emtrion-rzg1h.c | 2 +-
configs/arm/emtrion-rzg1m-linux-demo.c | 2 +-
configs/arm/emtrion-rzg1m.c | 2 +-
configs/arm/jetson-tk1-linux-demo.c | 2 +-
configs/arm/jetson-tk1.c | 2 +-
configs/arm/orangepi0-linux-demo.c | 2 +-
configs/arm/orangepi0.c | 2 +-
configs/arm64/amd-seattle-linux-demo.c | 2 +-
configs/arm64/amd-seattle.c | 2 +-
configs/arm64/espressobin-linux-demo.c | 2 +-
configs/arm64/espressobin.c | 2 +-
configs/arm64/hikey-linux-demo.c | 2 +-
configs/arm64/hikey.c | 2 +-
configs/arm64/jetson-tx1-linux-demo.c | 2 +-
configs/arm64/jetson-tx1.c | 2 +-
configs/arm64/k3-am654-idk-linux-demo.c | 2 +-
configs/arm64/k3-am654-idk.c | 2 +-
configs/arm64/k3-j721e-evm-linux-demo.c | 2 +-
configs/arm64/k3-j721e-evm.c | 2 +-
configs/arm64/macchiatobin-linux-demo.c | 2 +-
configs/arm64/macchiatobin.c | 2 +-
configs/arm64/miriac-sbc-ls1046a-linux-demo.c | 2 +-
configs/arm64/miriac-sbc-ls1046a.c | 2 +-
configs/arm64/qemu-arm64-linux-demo.c | 2 +-
configs/arm64/qemu-arm64.c | 2 +-
configs/arm64/ultra96-linux-demo.c | 2 +-
configs/arm64/ultra96.c | 2 +-
configs/arm64/zynqmp-zcu102-linux-demo-2.c | 4 ++--
configs/arm64/zynqmp-zcu102-linux-demo.c | 4 ++--
configs/arm64/zynqmp-zcu102.c | 4 ++--
configs/x86/ivshmem-demo.c | 15 ++++++++++++++-
configs/x86/linux-x86-demo.c | 4 ++--
configs/x86/qemu-x86.c | 16 ++++++++++++++--
hypervisor/ivshmem.c | 5 +++++
include/jailhouse/cell-config.h | 14 +++++++++++---
40 files changed, 84 insertions(+), 46 deletions(-)

diff --git a/configs/arm/bananapi-linux-demo.c b/configs/arm/bananapi-linux-demo.c
index 1b609902..07895829 100644
--- a/configs/arm/bananapi-linux-demo.c
+++ b/configs/arm/bananapi-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[7];
+ struct jailhouse_memory mem_regions[9];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/bananapi.c b/configs/arm/bananapi.c
index fdf8978b..1fc293a1 100644
--- a/configs/arm/bananapi.c
+++ b/configs/arm/bananapi.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[18];
+ struct jailhouse_memory mem_regions[20];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/emtrion-rzg1e-linux-demo.c b/configs/arm/emtrion-rzg1e-linux-demo.c
index c946f6d0..01a49cd0 100644
--- a/configs/arm/emtrion-rzg1e-linux-demo.c
+++ b/configs/arm/emtrion-rzg1e-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[12];
+ struct jailhouse_memory mem_regions[14];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/emtrion-rzg1e.c b/configs/arm/emtrion-rzg1e.c
index 5b3bf03c..c9c86e7c 100644
--- a/configs/arm/emtrion-rzg1e.c
+++ b/configs/arm/emtrion-rzg1e.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[20];
+ struct jailhouse_memory mem_regions[22];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/emtrion-rzg1h-linux-demo.c b/configs/arm/emtrion-rzg1h-linux-demo.c
index 623f8886..34749b29 100644
--- a/configs/arm/emtrion-rzg1h-linux-demo.c
+++ b/configs/arm/emtrion-rzg1h-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[14];
+ struct jailhouse_memory mem_regions[16];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/emtrion-rzg1h.c b/configs/arm/emtrion-rzg1h.c
index 9ab36d25..92d7e83b 100644
--- a/configs/arm/emtrion-rzg1h.c
+++ b/configs/arm/emtrion-rzg1h.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[38];
+ struct jailhouse_memory mem_regions[40];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/emtrion-rzg1m-linux-demo.c b/configs/arm/emtrion-rzg1m-linux-demo.c
index 73ad3c5b..dedeac03 100644
--- a/configs/arm/emtrion-rzg1m-linux-demo.c
+++ b/configs/arm/emtrion-rzg1m-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[14];
+ struct jailhouse_memory mem_regions[16];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/emtrion-rzg1m.c b/configs/arm/emtrion-rzg1m.c
index 4c6b7c58..9f937549 100644
--- a/configs/arm/emtrion-rzg1m.c
+++ b/configs/arm/emtrion-rzg1m.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[25];
+ struct jailhouse_memory mem_regions[27];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/jetson-tk1-linux-demo.c b/configs/arm/jetson-tk1-linux-demo.c
index 48844a66..016e4bc8 100644
--- a/configs/arm/jetson-tk1-linux-demo.c
+++ b/configs/arm/jetson-tk1-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/jetson-tk1.c b/configs/arm/jetson-tk1.c
index ca368fcf..8edbcb39 100644
--- a/configs/arm/jetson-tk1.c
+++ b/configs/arm/jetson-tk1.c
@@ -21,7 +21,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[23];
+ struct jailhouse_memory mem_regions[25];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/orangepi0-linux-demo.c b/configs/arm/orangepi0-linux-demo.c
index 09087a28..b1a3b068 100644
--- a/configs/arm/orangepi0-linux-demo.c
+++ b/configs/arm/orangepi0-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm/orangepi0.c b/configs/arm/orangepi0.c
index b878f70c..afc96a8f 100644
--- a/configs/arm/orangepi0.c
+++ b/configs/arm/orangepi0.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[10];
+ struct jailhouse_memory mem_regions[12];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/amd-seattle-linux-demo.c b/configs/arm64/amd-seattle-linux-demo.c
index 3da6a2e7..15dd43e7 100644
--- a/configs/arm64/amd-seattle-linux-demo.c
+++ b/configs/arm64/amd-seattle-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[10];
+ struct jailhouse_memory mem_regions[12];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/amd-seattle.c b/configs/arm64/amd-seattle.c
index 44dedeb1..c6a7a07f 100644
--- a/configs/arm64/amd-seattle.c
+++ b/configs/arm64/amd-seattle.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[18];
+ struct jailhouse_memory mem_regions[20];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[3];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/espressobin-linux-demo.c b/configs/arm64/espressobin-linux-demo.c
index 2d84665c..55c8ab77 100644
--- a/configs/arm64/espressobin-linux-demo.c
+++ b/configs/arm64/espressobin-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/espressobin.c b/configs/arm64/espressobin.c
index 082c9479..43445393 100644
--- a/configs/arm64/espressobin.c
+++ b/configs/arm64/espressobin.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[7];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/hikey-linux-demo.c b/configs/arm64/hikey-linux-demo.c
index 623b4b5b..410863c3 100644
--- a/configs/arm64/hikey-linux-demo.c
+++ b/configs/arm64/hikey-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/hikey.c b/configs/arm64/hikey.c
index c570e905..9da2a6dd 100644
--- a/configs/arm64/hikey.c
+++ b/configs/arm64/hikey.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/jetson-tx1-linux-demo.c b/configs/arm64/jetson-tx1-linux-demo.c
index cb4c356c..5cfd9bad 100644
--- a/configs/arm64/jetson-tx1-linux-demo.c
+++ b/configs/arm64/jetson-tx1-linux-demo.c
@@ -25,7 +25,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/jetson-tx1.c b/configs/arm64/jetson-tx1.c
index 801a5774..c0df4557 100644
--- a/configs/arm64/jetson-tx1.c
+++ b/configs/arm64/jetson-tx1.c
@@ -21,7 +21,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[44];
+ struct jailhouse_memory mem_regions[46];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/k3-am654-idk-linux-demo.c b/configs/arm64/k3-am654-idk-linux-demo.c
index bea2c984..54b84da6 100644
--- a/configs/arm64/k3-am654-idk-linux-demo.c
+++ b/configs/arm64/k3-am654-idk-linux-demo.c
@@ -23,7 +23,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[10];
+ struct jailhouse_memory mem_regions[12];
struct jailhouse_irqchip irqchips[3];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/k3-am654-idk.c b/configs/arm64/k3-am654-idk.c
index 85f663f1..66914031 100644
--- a/configs/arm64/k3-am654-idk.c
+++ b/configs/arm64/k3-am654-idk.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[16];
+ struct jailhouse_memory mem_regions[18];
struct jailhouse_irqchip irqchips[5];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/k3-j721e-evm-linux-demo.c b/configs/arm64/k3-j721e-evm-linux-demo.c
index ec0e3a39..17cdc5ce 100644
--- a/configs/arm64/k3-j721e-evm-linux-demo.c
+++ b/configs/arm64/k3-j721e-evm-linux-demo.c
@@ -24,7 +24,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[23];
+ struct jailhouse_memory mem_regions[25];
struct jailhouse_irqchip irqchips[4];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/k3-j721e-evm.c b/configs/arm64/k3-j721e-evm.c
index f22e9962..27c35960 100644
--- a/configs/arm64/k3-j721e-evm.c
+++ b/configs/arm64/k3-j721e-evm.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[34];
+ struct jailhouse_memory mem_regions[36];
struct jailhouse_irqchip irqchips[6];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/macchiatobin-linux-demo.c b/configs/arm64/macchiatobin-linux-demo.c
index 2ebabb0d..71d084ee 100644
--- a/configs/arm64/macchiatobin-linux-demo.c
+++ b/configs/arm64/macchiatobin-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[7];
+ struct jailhouse_memory mem_regions[9];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/macchiatobin.c b/configs/arm64/macchiatobin.c
index 2fca01a2..5b5aa491 100644
--- a/configs/arm64/macchiatobin.c
+++ b/configs/arm64/macchiatobin.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
index 9eb96734..4f8cd3c2 100644
--- a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
+++ b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/miriac-sbc-ls1046a.c b/configs/arm64/miriac-sbc-ls1046a.c
index ea64d44a..c2884d59 100644
--- a/configs/arm64/miriac-sbc-ls1046a.c
+++ b/configs/arm64/miriac-sbc-ls1046a.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[53];
+ struct jailhouse_memory mem_regions[55];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/qemu-arm64-linux-demo.c b/configs/arm64/qemu-arm64-linux-demo.c
index c3b06c11..000c4f32 100644
--- a/configs/arm64/qemu-arm64-linux-demo.c
+++ b/configs/arm64/qemu-arm64-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/qemu-arm64.c b/configs/arm64/qemu-arm64.c
index 786bddb2..1436464d 100644
--- a/configs/arm64/qemu-arm64.c
+++ b/configs/arm64/qemu-arm64.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[7];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/ultra96-linux-demo.c b/configs/arm64/ultra96-linux-demo.c
index a9ce834e..ed891766 100644
--- a/configs/arm64/ultra96-linux-demo.c
+++ b/configs/arm64/ultra96-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[6];
+ struct jailhouse_memory mem_regions[8];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/ultra96.c b/configs/arm64/ultra96.c
index 890c121c..831c6d31 100644
--- a/configs/arm64/ultra96.c
+++ b/configs/arm64/ultra96.c
@@ -18,7 +18,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[4];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo-2.c b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
index a02da41d..c0912c1d 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo-2.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[7];
+ struct jailhouse_memory mem_regions[11];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[2];
} __attribute__((packed)) config = {
@@ -103,7 +103,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 2 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_regions_start = 2,
+ .shmem_regions_start = 4,
.shmem_dev_id = 1,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo.c b/configs/arm64/zynqmp-zcu102-linux-demo.c
index d11d7c64..046d2b49 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[8];
+ struct jailhouse_memory mem_regions[12];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[2];
} __attribute__((packed)) config = {
@@ -109,7 +109,7 @@ struct {
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.bdf = 2 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_regions_start = 2,
+ .shmem_regions_start = 4,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/arm64/zynqmp-zcu102.c b/configs/arm64/zynqmp-zcu102.c
index 1eb165af..4dcb313f 100644
--- a/configs/arm64/zynqmp-zcu102.c
+++ b/configs/arm64/zynqmp-zcu102.c
@@ -20,7 +20,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[8];
+ struct jailhouse_memory mem_regions[12];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pci_device pci_devices[2];
} __attribute__((packed)) config = {
@@ -129,7 +129,7 @@ struct {
.domain = 1,
.bdf = 1 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_regions_start = 2,
+ .shmem_regions_start = 4,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/configs/x86/ivshmem-demo.c b/configs/x86/ivshmem-demo.c
index e7440f01..eb77ccae 100644
--- a/configs/x86/ivshmem-demo.c
+++ b/configs/x86/ivshmem-demo.c
@@ -19,7 +19,7 @@
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[4];
+ struct jailhouse_memory mem_regions[6];
struct jailhouse_pio pio_regions[2];
struct jailhouse_pci_device pci_devices[1];
struct jailhouse_pci_capability pci_caps[0];
@@ -64,6 +64,19 @@ struct {
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_ROOTSHARED,
},
+ {
+ .phys_start = 0x3f0fa000,
+ .virt_start = 0x3f0fa000,
+ .size = 0x2000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
+ },
+ {
+ .phys_start = 0x3f0fc000,
+ .virt_start = 0x3f0fc000,
+ .size = 0x2000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_ROOTSHARED,
+ },
/* RAM */ {
.phys_start = 0x3ee00000,
.virt_start = 0,
diff --git a/configs/x86/linux-x86-demo.c b/configs/x86/linux-x86-demo.c
index b9cc7c68..c03b2b48 100644
--- a/configs/x86/linux-x86-demo.c
+++ b/configs/x86/linux-x86-demo.c
@@ -19,9 +19,9 @@ struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
#ifdef CONFIG_QEMU_E1000E_ASSIGNMENT
- struct jailhouse_memory mem_regions[9];
+ struct jailhouse_memory mem_regions[11];
#else
- struct jailhouse_memory mem_regions[5];
+ struct jailhouse_memory mem_regions[7];
#endif
struct jailhouse_cache cache_regions[1];
struct jailhouse_irqchip irqchips[1];
diff --git a/configs/x86/qemu-x86.c b/configs/x86/qemu-x86.c
index ea642292..b4869fba 100644
--- a/configs/x86/qemu-x86.c
+++ b/configs/x86/qemu-x86.c
@@ -22,7 +22,7 @@
struct {
struct jailhouse_system header;
__u64 cpus[1];
- struct jailhouse_memory mem_regions[18];
+ struct jailhouse_memory mem_regions[22];
struct jailhouse_irqchip irqchips[1];
struct jailhouse_pio pio_regions[12];
struct jailhouse_pci_device pci_devices[9];
@@ -87,6 +87,18 @@ struct {
.size = 0x9000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
},
+ {
+ .phys_start = 0x3f0fa000,
+ .virt_start = 0x3f0fa000,
+ .size = 0x2000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
+ },
+ {
+ .phys_start = 0x3f0fc000,
+ .virt_start = 0x3f0fc000,
+ .size = 0x2000,
+ .flags = JAILHOUSE_MEM_READ,
+ },
/* IVSHMEM shared memory regions (networking) */
JAILHOUSE_SHMEM_NET_REGIONS(0x3f100000, 0),
/* RAM */ {
@@ -293,7 +305,7 @@ struct {
.bdf = 0x0f << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_MSIX,
.num_msix_vectors = 2,
- .shmem_regions_start = 2,
+ .shmem_regions_start = 4,
.shmem_dev_id = 0,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index 7e376e4e..f42a5bcb 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -40,6 +40,7 @@

#define IVSHMEM_CFG_SHMEM_STATE_TAB_SZ (IVSHMEM_CFG_VNDR_CAP + 0x04)
#define IVSHMEM_CFG_SHMEM_RW_SZ (IVSHMEM_CFG_VNDR_CAP + 0x08)
+#define IVSHMEM_CFG_SHMEM_OUTPUT_SZ (IVSHMEM_CFG_VNDR_CAP + 0x10)
#define IVSHMEM_CFG_SHMEM_ADDR (IVSHMEM_CFG_VNDR_CAP + 0x18)
#define IVSHMEM_CFG_VNDR_LEN 0x20

@@ -492,6 +493,10 @@ void ivshmem_reset(struct pci_device *device)
ive->cspace[IVSHMEM_CFG_SHMEM_RW_SZ/4 + 1] =
(u32)(ive->shmem[1].size >> 32);

+ ive->cspace[IVSHMEM_CFG_SHMEM_OUTPUT_SZ/4] = (u32)ive->shmem[2].size;
+ ive->cspace[IVSHMEM_CFG_SHMEM_OUTPUT_SZ/4 + 1] =
+ (u32)(ive->shmem[2].size >> 32);
+
ive->cspace[IVSHMEM_CFG_SHMEM_ADDR/4] = (u32)ive->shmem[0].virt_start;
ive->cspace[IVSHMEM_CFG_SHMEM_ADDR/4 + 1] =
(u32)(ive->shmem[0].virt_start >> 32);
diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index 10ac60f9..bf717bae 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -136,12 +136,20 @@ struct jailhouse_memory {
.size = 0x1000, \
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED, \
}, \
+ { 0 }, \
{ \
.phys_start = (start) + 0x1000, \
.virt_start = (start) + 0x1000, \
- .size = 0xff000, \
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | \
- JAILHOUSE_MEM_ROOTSHARED, \
+ .size = 0x7f000, \
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED | \
+ ((dev_id == 0) ? JAILHOUSE_MEM_WRITE : 0), \
+ }, \
+ { \
+ .phys_start = (start) + 0x80000, \
+ .virt_start = (start) + 0x80000, \
+ .size = 0x7f000, \
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED | \
+ ((dev_id == 1) ? JAILHOUSE_MEM_WRITE : 0), \
}

#define JAILHOUSE_MEMORY_IS_SUBPAGE(mem) \
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:06 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Add a WiP specification for the new IVSHMEM version. This documents the
current state and should not be considered stable at this point.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
Documentation/ivshmem-v2-specification.md | 376 ++++++++++++++++++++++++++++++
1 file changed, 376 insertions(+)
create mode 100644 Documentation/ivshmem-v2-specification.md

diff --git a/Documentation/ivshmem-v2-specification.md b/Documentation/ivshmem-v2-specification.md
new file mode 100644
index 00000000..d93cb22b
--- /dev/null
+++ b/Documentation/ivshmem-v2-specification.md
@@ -0,0 +1,376 @@
+IVSHMEM Device Specification
+============================
+
+** NOTE: THIS IS WORK-IN-PROGRESS, NOT YET A STABLE INTERFACE SPECIFICATION! **
+
+The goal of the Inter-VM Shared Memory (IVSHMEM) device model is to
+define the minimally needed building blocks a hypervisor has to
+provide for enabling guest-to-guest communication. The details of
+communication protocols shall remain opaque to the hypervisor so that
+guests are free to define them as simple or sophisticated as they
+need.
+
+For that purpose, the IVSHMEM provides the following features to its
+users:
+
+- Interconnection between up to 65536 peers
+
+- Multi-purpose shared memory region
+
+ - common read/writable section
+
+ - output sections that are read/writable for one peer and only
+ readable for the others
+
+ - section with peer states
+
+- Event signaling via interrupt to remote sides
+
+- Support for life-cycle management via state value exchange and
+ interrupt notification on changes, backed by a shared memory
+ section
+
+- Free choice of protocol to be used on top
+
+- Protocol type declaration
+
+- Register can be implemented either memory-mapped or via I/O,
+ depending on platform support and lower VM-exit costs
+
+- Unprivileged access to memory-mapped or I/O registers feasible
+
+- Single discovery and configuration via standard PCI, no complexity
+ by additionally defining a platform device model
+
+
+Hypervisor Model
+----------------
+
+In order to provide a consistent link between peers, all connected
+instances of IVSHMEM devices need to be configured, created and run
+by the hypervisor according to the following requirements:
+
+- The instances of the device shall appear as a PCI device to their
+ users.
+
+- The read/write shared memory section has to be of the same size for
+ all peers. The size can be zero.
+
+- If shared memory output sections are present (non-zero section
+ size), there must be one reserved for each peer with exclusive
+ write access. All output sections must have the same size and must
+ be readable for all peers.
+
+- The State Table must have the same size for all peers, must be
+ large enough to hold the state values of all peers, and must be
+ read-only for the user.
+
+- State register changes (explicit writes, peer resets) have to be
+ propagated to the other peers by updating the corresponding State
+ Table entry and issuing an interrupt to all other peers if they
+ enabled reception.
+
+- Interrupts events triggered by a peer have to be delivered to the
+ target peer, provided the receiving side is valid and has enabled
+ the reception.
+
+- All peers must have the same interrupt delivery features available,
+ i.e. MSI-X with the same maximum number of vectors on platforms
+ supporting this mechanism, otherwise INTx with one vector.
+
+
+Guest-side Programming Model
+----------------------------
+
+An IVSHMEM device appears as a PCI device to its users. Unless
+otherwise noted, it conforms to the PCI Local Bus Specification,
+Revision 3.0. As such, it is discoverable via the PCI configuration
+space and provides a number of standard and custom PCI configuration
+registers.
+
+### Shared Memory Region Layout
+
+The shared memory region is divided into several sections.
+
+ +-----------------------------+ -
+ | | :
+ | Output Section for peer n-1 | : Output Section Size
+ | (n = Maximum Peers) | :
+ +-----------------------------+ -
+ : :
+ : :
+ : :
+ +-----------------------------+ -
+ | | :
+ | Output Section for peer 1 | : Output Section Size
+ | | :
+ +-----------------------------+ -
+ | | :
+ | Output Section for peer 0 | : Output Section Size
+ | | :
+ +-----------------------------+ -
+ | | :
+ | Read/Write Section | : R/W Section Size
+ | | :
+ +-----------------------------+ -
+ | | :
+ | State Table | : State Table Size
+ | | :
+ +-----------------------------+ <-- Shared memory base address
+
+The first section consists of the mandatory State Table. Its size is
+defined by the State Table Size register and cannot be zero. This
+section is read-only for all peers.
+
+The second section consists of shared memory that is read/writable
+for all peers. Its size is defined by the R/W Section Size register.
+A size of zero is permitted.
+
+The third and following sections are output sections, one for each
+peer. Their sizes are all identical. The size of a single output
+section is defined by the Output Section Size register. An output
+section is read/writable for the corresponding peer and read-only for
+all other peers. E.g., only the peer with ID 3 can write to the
+fourths output section, but all peers can read from this section.
+
+All sizes have to be rounded up to multiples of a mappable page in
+order to allow access control according to the section restrictions.
+
+### Configuration Space Registers
+
+#### Header Registers
+
+| Offset | Register | Content |
+|-------:|:-----------------------|:-----------------------------------------------------|
+| 00h | Vendor ID | 110Ah |
+| 02h | Device ID | 4106h |
+| 04h | Command Register | 0000h on reset, writable bits are: |
+| | | Bit 0: I/O Space (if Register Region uses I/O) |
+| | | Bit 1: Memory Space (if Register Region uses Memory) |
+| | | Bit 3: Bus Master |
+| | | Bit 10: INTx interrupt disable |
+| | | Writes to other bits are ignored |
+| 06h | Status Register | 0010h, static value |
+| | | In deviation to the PCI specification, the Interrupt |
+| | | Status (bit 3) is never set |
+| 08h | Revision ID | 00h |
+| 09h | Class Code, Interface | Protocol Type bits 0-7, see [Protocols](#Protocols) |
+| 0Ah | Class Code, Sub-Class | Protocol Type bits 8-15, see [Protocols](#Protocols) |
+| 0Bh | Class Code, Base Class | FFh |
+| 0Eh | Header Type | 00h |
+| 10h | BAR 0 | MMIO or I/O register region |
+| 14h | BAR 1 | MSI-X region |
+| 18h | BAR 2 (with BAR 3) | optional: 64-bit shared memory region |
+| 2Ch | Subsystem Vendor ID | same as Vendor ID, or provider-specific value |
+| 2Eh | Subsystem ID | same as Device ID, or provider-specific value |
+| 34h | Capability Pointer | First capability |
+| 3Eh | Interrupt Pin | 01h-04h, must be 00h if MSI-X is available |
+
+The INTx status bit is never set by an implementation. Users of the
+IVSHMEM device are instead expected to derive the event state from
+protocol-specific information kept in the shared memory. This
+approach is significantly faster, and the complexity of
+register-based status tracking can be avoided.
+
+If BAR 2 is not present, the shared memory region is not relocatable
+by the user. In that case, the hypervisor has to implement the Base
+Address register in the vendor-specific capability.
+
+Subsystem IDs shall encode the provider (hypervisor) in order to
+allow identifying potential deviating implementations in case this
+should ever be required.
+
+If its platform supports MSI-X, an implementation of the IVSHMEM
+device must provide this interrupt model and must not expose INTx
+support.
+
+Other header registers may not be implemented. If not implemented,
+they return 0 on read and ignore write accesses.
+
+#### Vendor Specific Capability (ID 09h)
+
+This capability must always be present.
+
+| Offset | Register | Content |
+|-------:|:--------------------|:-----------------------------------------------|
+| 00h | ID | 09h |
+| 01h | Next Capability | Pointer to next capability or 00h |
+| 02h | Length | 20h if Base Address is present, 18h otherwise |
+| 03h | Privileged Control | Bit 0 (read/write): one-shot interrupt mode |
+| | | Bits 1-7: Reserved (0 on read, writes ignored) |
+| 04h | State Table Size | 32-bit size of read-only State Table |
+| 08h | R/W Section Size | 64-bit size of common read/write section |
+| 10h | Output Section Size | 64-bit size of output sections |
+| 18h | Base Address | optional: 64-bit base address of shared memory |
+
+All registers are read-only. Writes are ignored, except to bit 0 of
+the Privileged Control register.
+
+When bit 0 in the Privileged Control register is set to 1, the device
+clears bit 0 in the Interrupt Control register on each interrupt
+delivery. This enables automatic interrupt throttling when
+re-enabling shall be performed by a scheduled unprivileged instance
+on the user side.
+
+An IVSHMEM device may not support a relocatable shared memory region.
+This support the hypervisor in locking down the guest-to-host address
+mapping and simplifies the runtime logic. In such a case, BAR 2 must
+not be implemented by the hypervisor. Instead, the Base Address
+register has to be implemented to report the location of the shared
+memory region in the user's address space.
+
+A non-existing shared memory section has to report zero in its
+Section Size register.
+
+#### MSI-X Capability (ID 11h)
+
+On platforms supporting MSI-X, IVSHMEM has to provide interrupt
+delivery via this mechanism. In that case, the MSI-X capability is
+present while the legacy INTx delivery mechanism is not available,
+and the Interrupt Pin configuration register returns 0.
+
+The IVSHMEM device has no notion of pending interrupts. Therefore,
+reading from the MSI-X Pending Bit Array will always return 0. Users
+of the IVSHMEM device are instead expected to derive the event state
+from protocol-specific information kept in the shared memory. This
+approach is significantly faster, and the complexity of
+register-based status tracking can be avoided.
+
+The corresponding MSI-X MMIO region is configured via BAR 1.
+
+The MSI-X table size reported by the MSI-X capability structure is
+identical for all peers.
+
+### Register Region
+
+The register region may be implemented as MMIO or I/O.
+
+When implementing it as MMIO, the hypervisor has to ensure that the
+register region can be mapped as a single page into the address space
+of the user, without causing potential overlaps with other resources.
+Write accesses to MMIO region offsets that are not backed by
+registers have to be ignored, read accesses have to return 0. This
+enables the user to hand out the complete region, along with the
+shared memory, to an unprivileged instance.
+
+The region location in the user's physical address space is
+configured via BAR 0. The following table visualizes the region
+layout:
+
+| Offset | Register |
+|-------:|:--------------------------------------------------------------------|
+| 00h | ID |
+| 04h | Maximum Peers |
+| 08h | Interrupt Control |
+| 0Ch | Doorbell |
+| 10h | State |
+
+All registers support only aligned 32-bit accesses.
+
+#### ID Register (Offset 00h)
+
+Read-only register that reports the ID of the local device. It is
+unique for all of the connected devices and remains unchanged over
+their lifetime.
+
+#### Maximum Peers Register (Offset 04h)
+
+Read-only register that reports the maximum number of possible peers
+(including the local one). The permitted range is between 2 and 65536
+and remains constant over the lifetime of all peers.
+
+#### Interrupt Control Register (Offset 08h)
+
+This read/write register controls the generation of interrupts
+whenever a peer writes to the Doorbell register or changes its state.
+
+| Bits | Content |
+|-----:|:----------------------------------------------------------------------|
+| 0 | 1: Enable interrupt generation |
+| 1-31 | Reserved (0 on read, writes ignored) |
+
+Note that bit 0 is reset to 0 on interrupt delivery if one-shot
+interrupt mode is enabled in the Enhanced Features register.
+
+The value of this register after device reset is 0.
+
+#### Doorbell Register (Offset 0Ch)
+
+Write-only register that triggers an interrupt vector in the target
+device if it is enabled there.
+
+| Bits | Content |
+|------:|:---------------------------------------------------------------------|
+| 0-15 | Vector number |
+| 16-31 | Target ID |
+
+Writing a vector number that is not enabled by the target has no
+effect. The peers can derive the number of available vectors from
+their own device capabilities because the provider is required to
+expose an identical number of vectors to all connected peers. The
+peers are expected to define or negotiate the used ones via the
+selected protocol.
+
+Addressing a non-existing or inactive target has no effect. Peers can
+identify active targets via the State Table.
+
+The behavior on reading from this register is undefined.
+
+#### State Register (Offset 10h)
+
+Read/write register that defines the state of the local device.
+Writing to this register sets the state and triggers MSI-X vector 0
+or the INTx interrupt, respectively, on the remote device if the
+written state value differs from the previous one. Users of peer
+devices can read the value written to this register from the State
+Table. They are expected differentiate state change interrupts from
+doorbell events by comparing the new state value with a locally
+stored copy.
+
+The value of this register after device reset is 0. The semantic of
+all other values can be defined freely by the chosen protocol.
+
+### State Table
+
+The State Table is a read-only section at the beginning of the shared
+memory region. It contains a 32-bit state value for each of the
+peers. Locating the table in shared memory allows fast checking of
+remote states without register accesses.
+
+The table is updated on each state change of a peers. Whenever a user
+of an IVSHMEM device writes a value to the Local State register, this
+value is copied into the corresponding entry of the State Table. When
+a IVSHMEM device is reset or disconnected from the other peers, zero
+is written into the corresponding table entry. The initial content of
+the table is all zeros.
+
+ +--------------------------------+
+ | 32-bit state value of peer n-1 |
+ +--------------------------------+
+ : :
+ +--------------------------------+
+ | 32-bit state value of peer 1 |
+ +--------------------------------+
+ | 32-bit state value of peer 0 |
+ +--------------------------------+ <-- Shared memory base address
+
+
+Protocols
+---------
+
+The IVSHMEM device shall support the peers of a connection in
+agreeing on the protocol used over the shared memory devices. For
+that purpose, the interface byte (offset 09h) and the sub-class byte
+(offset 0Ah) of the Class Code register encodes a 16-bit protocol
+type for the users. The following type values are defined:
+
+| Protocol Type | Description |
+|--------------:|:-------------------------------------------------------------|
+| 0000h | Undefined type |
+| 0001h | Virtual peer-to-peer Ethernet |
+| 0002h-3FFFh | Reserved |
+| 4000h-7FFFh | User-defined protocols |
+| 8000h-BFFFh | Virtio over Shared Memory, front-end peer |
+| C000h-FFFFh | Virtio over Shared Memory, back-end peer |
+
+Details of the protocols are not in the scope of this specification.
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:06 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Move state and ioregion to the end because they are not needed in
hot-paths.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/include/jailhouse/ivshmem.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index 61773799..9153d4a1 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -39,11 +39,11 @@ struct ivshmem_endpoint {
spinlock_t irq_lock;
u32 int_ctrl_reg;
struct arch_ivshmem_irq_cache irq_cache;
- u32 state;
- u32 ioregion[2];
struct pci_device *device;
struct ivshmem_link *link;
const struct jailhouse_memory *shmem;
+ u32 ioregion[2];
+ u32 state;
};

int ivshmem_init(struct cell *cell, struct pci_device *device);
--
2.16.4

Jan Kiszka

unread,
Jan 6, 2020, 7:20:06 AM1/6/20
to jailho...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

So far, it seemed restricting our ivshmem implementation to 2 peers
would both simplify it significantly and fulfill the vast majority of
use cases. Both turned out to be wrong assumption.

First of all, there are users with custom protocols that like to set up
a single ivshmem device between, e.g., the root cell and multiple
non-root cells. They would currently have to create one device pair per
link. This overcomes the limitation.

At the same time, the implementation turned out to be rather simple. We
basically just need to broadcast config change interrupts and rework the
bookkeeping so that an ivshmem_link is only destroyed with the last user
disappears. The rest was already refactored to account for multiple
peers.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
configs/arm/bananapi-linux-demo.c | 1 +
configs/arm/bananapi.c | 1 +
configs/arm/emtrion-rzg1e-linux-demo.c | 1 +
configs/arm/emtrion-rzg1e.c | 1 +
configs/arm/emtrion-rzg1h-linux-demo.c | 1 +
configs/arm/emtrion-rzg1h.c | 1 +
configs/arm/emtrion-rzg1m-linux-demo.c | 1 +
configs/arm/emtrion-rzg1m.c | 1 +
configs/arm/jetson-tk1-linux-demo.c | 1 +
configs/arm/jetson-tk1.c | 1 +
configs/arm/orangepi0-linux-demo.c | 1 +
configs/arm/orangepi0.c | 1 +
configs/arm64/amd-seattle-linux-demo.c | 1 +
configs/arm64/amd-seattle.c | 1 +
configs/arm64/espressobin-linux-demo.c | 1 +
configs/arm64/espressobin.c | 1 +
configs/arm64/hikey-linux-demo.c | 1 +
configs/arm64/hikey.c | 1 +
configs/arm64/jetson-tx1-linux-demo.c | 1 +
configs/arm64/jetson-tx1.c | 1 +
configs/arm64/k3-am654-idk-linux-demo.c | 1 +
configs/arm64/k3-am654-idk.c | 1 +
configs/arm64/k3-j721e-evm-linux-demo.c | 1 +
configs/arm64/k3-j721e-evm.c | 1 +
configs/arm64/macchiatobin-linux-demo.c | 1 +
configs/arm64/macchiatobin.c | 1 +
configs/arm64/miriac-sbc-ls1046a-linux-demo.c | 1 +
configs/arm64/miriac-sbc-ls1046a.c | 1 +
configs/arm64/qemu-arm64-linux-demo.c | 1 +
configs/arm64/qemu-arm64.c | 1 +
configs/arm64/ultra96-linux-demo.c | 1 +
configs/arm64/ultra96.c | 1 +
configs/arm64/zynqmp-zcu102-linux-demo-2.c | 2 +
configs/arm64/zynqmp-zcu102-linux-demo.c | 2 +
configs/arm64/zynqmp-zcu102.c | 2 +
configs/x86/ivshmem-demo.c | 1 +
configs/x86/linux-x86-demo.c | 1 +
configs/x86/qemu-x86.c | 2 +
hypervisor/include/jailhouse/ivshmem.h | 1 -
hypervisor/ivshmem.c | 67 ++++++++++++++-------------
include/jailhouse/cell-config.h | 5 +-
41 files changed, 79 insertions(+), 36 deletions(-)

diff --git a/configs/arm/bananapi-linux-demo.c b/configs/arm/bananapi-linux-demo.c
index 07895829..0aecdbcc 100644
--- a/configs/arm/bananapi-linux-demo.c
+++ b/configs/arm/bananapi-linux-demo.c
@@ -108,6 +108,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/bananapi.c b/configs/arm/bananapi.c
index 1fc293a1..a59fc869 100644
--- a/configs/arm/bananapi.c
+++ b/configs/arm/bananapi.c
@@ -203,6 +203,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1e-linux-demo.c b/configs/arm/emtrion-rzg1e-linux-demo.c
index 01a49cd0..ee3cf79f 100644
--- a/configs/arm/emtrion-rzg1e-linux-demo.c
+++ b/configs/arm/emtrion-rzg1e-linux-demo.c
@@ -157,6 +157,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1e.c b/configs/arm/emtrion-rzg1e.c
index c9c86e7c..c1c01b3d 100644
--- a/configs/arm/emtrion-rzg1e.c
+++ b/configs/arm/emtrion-rzg1e.c
@@ -231,6 +231,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1h-linux-demo.c b/configs/arm/emtrion-rzg1h-linux-demo.c
index 34749b29..c175e206 100644
--- a/configs/arm/emtrion-rzg1h-linux-demo.c
+++ b/configs/arm/emtrion-rzg1h-linux-demo.c
@@ -171,6 +171,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1h.c b/configs/arm/emtrion-rzg1h.c
index 92d7e83b..c020372d 100644
--- a/configs/arm/emtrion-rzg1h.c
+++ b/configs/arm/emtrion-rzg1h.c
@@ -357,6 +357,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1m-linux-demo.c b/configs/arm/emtrion-rzg1m-linux-demo.c
index dedeac03..083777df 100644
--- a/configs/arm/emtrion-rzg1m-linux-demo.c
+++ b/configs/arm/emtrion-rzg1m-linux-demo.c
@@ -171,6 +171,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/emtrion-rzg1m.c b/configs/arm/emtrion-rzg1m.c
index 9f937549..e0a8a1c3 100644
--- a/configs/arm/emtrion-rzg1m.c
+++ b/configs/arm/emtrion-rzg1m.c
@@ -266,6 +266,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/jetson-tk1-linux-demo.c b/configs/arm/jetson-tk1-linux-demo.c
index 016e4bc8..010d2022 100644
--- a/configs/arm/jetson-tk1-linux-demo.c
+++ b/configs/arm/jetson-tk1-linux-demo.c
@@ -111,6 +111,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/jetson-tk1.c b/configs/arm/jetson-tk1.c
index 8edbcb39..3a6eb1fa 100644
--- a/configs/arm/jetson-tk1.c
+++ b/configs/arm/jetson-tk1.c
@@ -255,6 +255,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/orangepi0-linux-demo.c b/configs/arm/orangepi0-linux-demo.c
index b1a3b068..5ea4e34d 100644
--- a/configs/arm/orangepi0-linux-demo.c
+++ b/configs/arm/orangepi0-linux-demo.c
@@ -99,6 +99,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm/orangepi0.c b/configs/arm/orangepi0.c
index afc96a8f..9aa2876c 100644
--- a/configs/arm/orangepi0.c
+++ b/configs/arm/orangepi0.c
@@ -144,6 +144,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/amd-seattle-linux-demo.c b/configs/arm64/amd-seattle-linux-demo.c
index 15dd43e7..f4ed12d7 100644
--- a/configs/arm64/amd-seattle-linux-demo.c
+++ b/configs/arm64/amd-seattle-linux-demo.c
@@ -140,6 +140,7 @@ struct {
.num_msix_vectors = 2,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/amd-seattle.c b/configs/arm64/amd-seattle.c
index c6a7a07f..6409d934 100644
--- a/configs/arm64/amd-seattle.c
+++ b/configs/arm64/amd-seattle.c
@@ -218,6 +218,7 @@ struct {
.num_msix_vectors = 2,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/espressobin-linux-demo.c b/configs/arm64/espressobin-linux-demo.c
index 55c8ab77..75602beb 100644
--- a/configs/arm64/espressobin-linux-demo.c
+++ b/configs/arm64/espressobin-linux-demo.c
@@ -101,6 +101,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/espressobin.c b/configs/arm64/espressobin.c
index 43445393..d17c9db3 100644
--- a/configs/arm64/espressobin.c
+++ b/configs/arm64/espressobin.c
@@ -111,6 +111,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/hikey-linux-demo.c b/configs/arm64/hikey-linux-demo.c
index 410863c3..2bdca488 100644
--- a/configs/arm64/hikey-linux-demo.c
+++ b/configs/arm64/hikey-linux-demo.c
@@ -98,6 +98,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/hikey.c b/configs/arm64/hikey.c
index 9da2a6dd..f8a6c2a2 100644
--- a/configs/arm64/hikey.c
+++ b/configs/arm64/hikey.c
@@ -117,6 +117,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/jetson-tx1-linux-demo.c b/configs/arm64/jetson-tx1-linux-demo.c
index 5cfd9bad..e51549b6 100644
--- a/configs/arm64/jetson-tx1-linux-demo.c
+++ b/configs/arm64/jetson-tx1-linux-demo.c
@@ -115,6 +115,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/jetson-tx1.c b/configs/arm64/jetson-tx1.c
index c0df4557..2798fed8 100644
--- a/configs/arm64/jetson-tx1.c
+++ b/configs/arm64/jetson-tx1.c
@@ -394,6 +394,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/k3-am654-idk-linux-demo.c b/configs/arm64/k3-am654-idk-linux-demo.c
index 54b84da6..ceb4eca2 100644
--- a/configs/arm64/k3-am654-idk-linux-demo.c
+++ b/configs/arm64/k3-am654-idk-linux-demo.c
@@ -139,6 +139,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/k3-am654-idk.c b/configs/arm64/k3-am654-idk.c
index 66914031..9ac32dbb 100644
--- a/configs/arm64/k3-am654-idk.c
+++ b/configs/arm64/k3-am654-idk.c
@@ -213,6 +213,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/k3-j721e-evm-linux-demo.c b/configs/arm64/k3-j721e-evm-linux-demo.c
index 17cdc5ce..27662452 100644
--- a/configs/arm64/k3-j721e-evm-linux-demo.c
+++ b/configs/arm64/k3-j721e-evm-linux-demo.c
@@ -263,6 +263,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/k3-j721e-evm.c b/configs/arm64/k3-j721e-evm.c
index 27c35960..b180d272 100644
--- a/configs/arm64/k3-j721e-evm.c
+++ b/configs/arm64/k3-j721e-evm.c
@@ -351,6 +351,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/macchiatobin-linux-demo.c b/configs/arm64/macchiatobin-linux-demo.c
index 71d084ee..b1c475f4 100644
--- a/configs/arm64/macchiatobin-linux-demo.c
+++ b/configs/arm64/macchiatobin-linux-demo.c
@@ -109,6 +109,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/macchiatobin.c b/configs/arm64/macchiatobin.c
index 5b5aa491..0b79409e 100644
--- a/configs/arm64/macchiatobin.c
+++ b/configs/arm64/macchiatobin.c
@@ -120,6 +120,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
index 4f8cd3c2..27fa5064 100644
--- a/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
+++ b/configs/arm64/miriac-sbc-ls1046a-linux-demo.c
@@ -120,6 +120,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/miriac-sbc-ls1046a.c b/configs/arm64/miriac-sbc-ls1046a.c
index c2884d59..93279716 100644
--- a/configs/arm64/miriac-sbc-ls1046a.c
+++ b/configs/arm64/miriac-sbc-ls1046a.c
@@ -456,6 +456,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/qemu-arm64-linux-demo.c b/configs/arm64/qemu-arm64-linux-demo.c
index 000c4f32..90e686ba 100644
--- a/configs/arm64/qemu-arm64-linux-demo.c
+++ b/configs/arm64/qemu-arm64-linux-demo.c
@@ -102,6 +102,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/qemu-arm64.c b/configs/arm64/qemu-arm64.c
index 1436464d..a75b60f7 100644
--- a/configs/arm64/qemu-arm64.c
+++ b/configs/arm64/qemu-arm64.c
@@ -111,6 +111,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/ultra96-linux-demo.c b/configs/arm64/ultra96-linux-demo.c
index ed891766..94fa51ba 100644
--- a/configs/arm64/ultra96-linux-demo.c
+++ b/configs/arm64/ultra96-linux-demo.c
@@ -101,6 +101,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/ultra96.c b/configs/arm64/ultra96.c
index 831c6d31..83762c41 100644
--- a/configs/arm64/ultra96.c
+++ b/configs/arm64/ultra96.c
@@ -103,6 +103,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo-2.c b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
index c0912c1d..da4d1162 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo-2.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo-2.c
@@ -97,6 +97,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
/* 00:02.0 */ {
@@ -105,6 +106,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 4,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/zynqmp-zcu102-linux-demo.c b/configs/arm64/zynqmp-zcu102-linux-demo.c
index 046d2b49..9e8ba801 100644
--- a/configs/arm64/zynqmp-zcu102-linux-demo.c
+++ b/configs/arm64/zynqmp-zcu102-linux-demo.c
@@ -103,6 +103,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
/* 00:02.0 */ {
@@ -111,6 +112,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 4,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/arm64/zynqmp-zcu102.c b/configs/arm64/zynqmp-zcu102.c
index 4dcb313f..0130c0da 100644
--- a/configs/arm64/zynqmp-zcu102.c
+++ b/configs/arm64/zynqmp-zcu102.c
@@ -122,6 +122,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
/* 0001:00:00.0 */ {
@@ -131,6 +132,7 @@ struct {
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 4,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/configs/x86/ivshmem-demo.c b/configs/x86/ivshmem-demo.c
index eb77ccae..cea555c9 100644
--- a/configs/x86/ivshmem-demo.c
+++ b/configs/x86/ivshmem-demo.c
@@ -106,6 +106,7 @@ struct {
.num_msix_vectors = 16,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
},
},
diff --git a/configs/x86/linux-x86-demo.c b/configs/x86/linux-x86-demo.c
index c03b2b48..5f9d8ed8 100644
--- a/configs/x86/linux-x86-demo.c
+++ b/configs/x86/linux-x86-demo.c
@@ -143,6 +143,7 @@ struct {
.num_msix_vectors = 2,
.shmem_regions_start = 0,
.shmem_dev_id = 1,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
#ifdef CONFIG_QEMU_E1000E_ASSIGNMENT
diff --git a/configs/x86/qemu-x86.c b/configs/x86/qemu-x86.c
index b4869fba..d5ba1764 100644
--- a/configs/x86/qemu-x86.c
+++ b/configs/x86/qemu-x86.c
@@ -297,6 +297,7 @@ struct {
.num_msix_vectors = 16,
.shmem_regions_start = 0,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
},
{ /* IVSHMEM (networking) */
@@ -307,6 +308,7 @@ struct {
.num_msix_vectors = 2,
.shmem_regions_start = 4,
.shmem_dev_id = 0,
+ .shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
index 544432d0..61773799 100644
--- a/hypervisor/include/jailhouse/ivshmem.h
+++ b/hypervisor/include/jailhouse/ivshmem.h
@@ -44,7 +44,6 @@ struct ivshmem_endpoint {
struct pci_device *device;
struct ivshmem_link *link;
const struct jailhouse_memory *shmem;
- struct ivshmem_endpoint *remote;
};

int ivshmem_init(struct cell *cell, struct pci_device *device);
diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index f42a5bcb..189dae6a 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -16,7 +16,7 @@
* shared memory and interrupts based on MSI-X.
*
* The implementation in Jailhouse provides a shared memory device between
- * exactly 2 cells. The link between the two PCI devices is established by
+ * 2 or more cells. The link between the PCI devices is established by
* choosing the same BDF.
*/

@@ -32,7 +32,7 @@
#define PCI_VENDOR_ID_SIEMENS 0x110a
#define IVSHMEM_DEVICE_ID 0x4106

-#define IVSHMEM_MAX_PEERS 2
+#define IVSHMEM_MAX_PEERS 12

#define IVSHMEM_CFG_VNDR_CAP 0x40
#define IVSHMEM_CFG_MSIX_CAP (IVSHMEM_CFG_VNDR_CAP + \
@@ -60,6 +60,7 @@

struct ivshmem_link {
struct ivshmem_endpoint eps[IVSHMEM_MAX_PEERS];
+ unsigned int peers;
u16 bdf;
struct ivshmem_link *next;
};
@@ -105,6 +106,7 @@ static void ivshmem_write_state(struct ivshmem_endpoint *ive, u32 new_state)
const struct jailhouse_pci_device *dev_info = ive->device->info;
u32 *state_table = (u32 *)TEMPORARY_MAPPING_BASE;
struct ivshmem_endpoint *target_ive;
+ unsigned int id;

/*
* Cannot fail: upper levels of page table were already created by
@@ -122,8 +124,11 @@ static void ivshmem_write_state(struct ivshmem_endpoint *ive, u32 new_state)
if (ive->state != new_state) {
ive->state = new_state;

- target_ive = &ive->link->eps[dev_info->shmem_dev_id ^ 1];
- ivshmem_trigger_interrupt(target_ive, 0);
+ for (id = 0; id < dev_info->shmem_peers; id++) {
+ target_ive = &ive->link->eps[id];
+ if (target_ive != ive)
+ ivshmem_trigger_interrupt(target_ive, 0);
+ }
}
}

@@ -173,7 +178,7 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
break;
case IVSHMEM_REG_MAX_PEERS:
/* read-only number of peers */
- mmio->value = IVSHMEM_MAX_PEERS;
+ mmio->value = ive->device->info->shmem_peers;
break;
case IVSHMEM_REG_INT_CTRL:
if (mmio->is_write) {
@@ -388,15 +393,15 @@ enum pci_access ivshmem_pci_cfg_read(struct pci_device *device, u16 address,
int ivshmem_init(struct cell *cell, struct pci_device *device)
{
const struct jailhouse_pci_device *dev_info = device->info;
- struct ivshmem_endpoint *ive, *remote;
- struct pci_device *peer_dev;
+ struct ivshmem_endpoint *ive;
struct ivshmem_link *link;
- unsigned int id;
+ unsigned int peer_id, id;
+ struct pci_device *peer;

printk("Adding virtual PCI device %02x:%02x.%x to cell \"%s\"\n",
PCI_BDF_PARAMS(dev_info->bdf), cell->config->name);

- if (dev_info->shmem_regions_start + 2 >
+ if (dev_info->shmem_regions_start + 2 + dev_info->shmem_peers >
cell->config->num_memory_regions ||
dev_info->num_msix_vectors > IVSHMEM_MSIX_VECTORS)
return trace_error(-EINVAL);
@@ -414,11 +419,12 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
if (link->eps[id].device)
return trace_error(-EBUSY);

- peer_dev = link->eps[id ^ 1].device;
-
- printk("Shared memory connection established: "
- "\"%s\" <--> \"%s\"\n",
- cell->config->name, peer_dev->cell->config->name);
+ printk("Shared memory connection established, peer cells:\n");
+ for (peer_id = 0; peer_id < IVSHMEM_MAX_PEERS; peer_id++) {
+ peer = link->eps[peer_id].device;
+ if (peer && peer_id != id)
+ printk(" \"%s\"\n", peer->cell->config->name);
+ }
} else {
link = page_alloc(&mem_pool, PAGES(sizeof(*link)));
if (!link)
@@ -429,18 +435,14 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
ivshmem_links = link;
}

- ive = &link->eps[id];
- remote = &link->eps[id ^ 1];
+ link->peers++;
+ ive = &link->eps[dev_info->shmem_dev_id];

ive->device = device;
ive->link = link;
ive->shmem = jailhouse_cell_mem_regions(cell->config) +
dev_info->shmem_regions_start;
device->ivshmem_endpoint = ive;
- if (remote->device) {
- ive->remote = remote;
- remote->remote = ive;
- }

device->cell = cell;
pci_reset_device(device);
@@ -512,7 +514,6 @@ void ivshmem_reset(struct pci_device *device)
void ivshmem_exit(struct pci_device *device)
{
struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
- struct ivshmem_endpoint *remote = ive->remote;
struct ivshmem_link **linkp;

/*
@@ -523,19 +524,19 @@ void ivshmem_exit(struct pci_device *device)
memset(&ive->irq_cache, 0, sizeof(ive->irq_cache));
spin_unlock(&ive->irq_lock);

- if (remote) {
- remote->remote = NULL;
+ ivshmem_write_state(ive, 0);

- ivshmem_write_state(ive, 0);
+ ive->device = NULL;

- ive->device = NULL;
- } else {
- for (linkp = &ivshmem_links; *linkp; linkp = &(*linkp)->next) {
- if (*linkp == ive->link) {
- *linkp = ive->link->next;
- page_free(&mem_pool, ive->link, 1);
- break;
- }
- }
+ if (--ive->link->peers > 0)
+ return;
+
+ for (linkp = &ivshmem_links; *linkp; linkp = &(*linkp)->next) {
+ if (*linkp != ive->link)
+ continue;
+
+ *linkp = ive->link->next;
+ page_free(&mem_pool, ive->link, PAGES(sizeof(*ive->link)));
+ break;
}
}
diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index bf717bae..6d397d9c 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -201,9 +201,10 @@ struct jailhouse_pci_device {
__u64 msix_address;
/** First memory region index of shared memory device. */
__u32 shmem_regions_start;
- /** ID of shared memory device (0..1). */
+ /** ID of shared memory device (0..shmem_peers-1). */
__u8 shmem_dev_id;
- __u8 padding;
+ /** Maximum number of peers connected via this shared memory device. */
+ __u8 shmem_peers;
/** PCI subclass and interface ID of shared memory device. */
__u16 shmem_protocol;
} __attribute__((packed));
--
2.16.4

Ralf Ramsauer

unread,
Jan 14, 2020, 9:25:46 AM1/14/20
to Jan Kiszka, jailho...@googlegroups.com


On 1/6/20 1:17 PM, Jan Kiszka wrote:
> From: Jan Kiszka <jan.k...@siemens.com>
>
> Convert the creation order based ID assignment to the one now provided
> by the cell configuration.
>
> Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
> ---
> hypervisor/include/jailhouse/ivshmem.h | 1 -
> hypervisor/ivshmem.c | 13 ++++++++-----
> 2 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/hypervisor/include/jailhouse/ivshmem.h b/hypervisor/include/jailhouse/ivshmem.h
> index 45cd3c4b..dae67f44 100644
> --- a/hypervisor/include/jailhouse/ivshmem.h
> +++ b/hypervisor/include/jailhouse/ivshmem.h
> @@ -29,7 +29,6 @@
>
> struct ivshmem_endpoint {
> u32 cspace[IVSHMEM_CFG_SIZE / sizeof(u32)];
> - u32 id;
> u32 state;
> u32 ioregion[2];
> struct pci_device *device;
> diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
> index 7bebaff4..45306b85 100644
> --- a/hypervisor/ivshmem.c
> +++ b/hypervisor/ivshmem.c
> @@ -99,7 +99,7 @@ static enum mmio_result ivshmem_register_mmio(void *arg,
> switch (mmio->address) {
> case IVSHMEM_REG_ID:
> /* read-only ID */
> - mmio->value = ive->id;
> + mmio->value = ive->device->info->shmem_dev_id;
> break;
> case IVSHMEM_REG_MAX_PEERS:
> /* read-only number of peers */
> @@ -326,7 +326,7 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
> struct ivshmem_endpoint *ive, *remote;
> struct pci_device *peer_dev;
> struct ivshmem_data *iv;
> - unsigned int id = 0;
> + unsigned int id;
>
> printk("Adding virtual PCI device %02x:%02x.%x to cell \"%s\"\n",
> PCI_BDF_PARAMS(dev_info->bdf), cell->config->name);
> @@ -340,8 +340,12 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
> if (iv->bdf == dev_info->bdf)
> break;
>
> + id = dev_info->shmem_dev_id;
> +
> if (iv) {
> - id = iv->eps[0].device ? 1 : 0;
> + if (id >= IVSHMEM_MAX_PEERS)
> + return trace_error(-EINVAL);
> +

Shouldn't this check happen unconditionally? IOW, directly after setting
the id from the configuration.

Ralf

> if (iv->eps[id].device)
> return trace_error(-EBUSY);
>
> @@ -373,7 +377,6 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
>
> ive->device = device;
> ive->shmem = mem;
> - ive->id = id;
> device->ivshmem_endpoint = ive;
> if (remote->device) {
> ive->remote = remote;
> @@ -447,7 +450,7 @@ void ivshmem_exit(struct pci_device *device)
> } else {
> for (ivp = &ivshmem_list; *ivp; ivp = &(*ivp)->next) {
> iv = *ivp;
> - if (&iv->eps[ive->id] == ive) {
> + if (&iv->eps[ive->device->info->shmem_dev_id] == ive) {
> *ivp = iv->next;
> page_free(&mem_pool, iv, 1);
> break;
>

Ralf Ramsauer

unread,
Jan 14, 2020, 9:26:48 AM1/14/20
to Jan Kiszka, jailho...@googlegroups.com
[...]

On 1/6/20 1:18 PM, Jan Kiszka wrote:
> diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
> index a62fa1ee..f82bbe8d 100644
> --- a/include/jailhouse/cell-config.h
> +++ b/include/jailhouse/cell-config.h
> @@ -129,6 +129,15 @@ struct jailhouse_memory {
> __u64 flags;
> } __attribute__((packed));
>
> +#define JAILHOUSE_SHMEM_NET_REGIONS(start, dev_id) \
> + { \
> + .phys_start = start, \
> + .virt_start = start, \
> + .size = 0x100000, \
> + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | \
> + JAILHOUSE_MEM_ROOTSHARED, \
> + }
> +

In the end of the series, this makes calculation of .num_memory_region
unintuitive: the macro will eventually roll out to four memory regions.
Would it make sense to introduce a macro that denotes the number of
regions that are created by JAILHOUSE_SHMEM_NET_REGIONS?

Ralf

Ralf Ramsauer

unread,
Jan 14, 2020, 9:27:44 AM1/14/20
to Jan Kiszka, jailho...@googlegroups.com


On 1/6/20 1:18 PM, Jan Kiszka wrote:
> From: Jan Kiszka <jan.k...@siemens.com>
>
> Simplifies index calculation and reduces risk of errors. The only
> downside is that regions are no longer ordered according to their
> physical addresses.

We have 64 bit for flags. Instead of moving those memory regions to the
top, we could also use .flags as unique tags. We wouldn't have to care
any longer about there exact place inside the config.

I think of something like

/* IVSHMEM shared memory region */
JAILHOUSE_SHMEM_NET_REGIONS(0xc0fe, 0x7bf00000, 0),

[...]

.shmem_tag = 0xc0fe,

[...]

What do you think?

Ralf

Jan Kiszka

unread,
Jan 14, 2020, 9:30:31 AM1/14/20
to Ralf Ramsauer, jailho...@googlegroups.com
Good catch! Will fix on top.

Jan

>
> Ralf
>
>> if (iv->eps[id].device)
>> return trace_error(-EBUSY);
>>
>> @@ -373,7 +377,6 @@ int ivshmem_init(struct cell *cell, struct pci_device *device)
>>
>> ive->device = device;
>> ive->shmem = mem;
>> - ive->id = id;
>> device->ivshmem_endpoint = ive;
>> if (remote->device) {
>> ive->remote = remote;
>> @@ -447,7 +450,7 @@ void ivshmem_exit(struct pci_device *device)
>> } else {
>> for (ivp = &ivshmem_list; *ivp; ivp = &(*ivp)->next) {
>> iv = *ivp;
>> - if (&iv->eps[ive->id] == ive) {
>> + if (&iv->eps[ive->device->info->shmem_dev_id] == ive) {
>> *ivp = iv->next;
>> page_free(&mem_pool, iv, 1);
>> break;
>>

--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

Jan Kiszka

unread,
Jan 14, 2020, 9:36:29 AM1/14/20
to Ralf Ramsauer, jailho...@googlegroups.com
On 14.01.20 15:27, Ralf Ramsauer wrote:
>
>
> On 1/6/20 1:18 PM, Jan Kiszka wrote:
>> From: Jan Kiszka <jan.k...@siemens.com>
>>
>> Simplifies index calculation and reduces risk of errors. The only
>> downside is that regions are no longer ordered according to their
>> physical addresses.
>
> We have 64 bit for flags. Instead of moving those memory regions to the
> top, we could also use .flags as unique tags. We wouldn't have to care
> any longer about there exact place inside the config.
>
> I think of something like
>
> /* IVSHMEM shared memory region */
> JAILHOUSE_SHMEM_NET_REGIONS(0xc0fe, 0x7bf00000, 0),
>
> [...]
>
> .shmem_tag = 0xc0fe,
>
> [...]
>
> What do you think?

Would imply searching for the regions in the hypervisor - doable but
IMHO not worth the benefit. I would eventuelly rather like to see some
offline tool generating all that magic.

Keep in mind that we use index-based addressing for PCI caps as well.

Jan

Jan Kiszka

unread,
Jan 14, 2020, 9:37:18 AM1/14/20
to Ralf Ramsauer, jailho...@googlegroups.com
What exactly do you propose? JAILHOUSE_SHMEM_NET_FOUR_REGIONS?

Ralf Ramsauer

unread,
Jan 14, 2020, 9:59:46 AM1/14/20
to Jan Kiszka, jailho...@googlegroups.com
#define THREE 3

... No. This macro will change as soon as we have support for more than
two peers. If I understood the code correctly, then the number of
regions depends on the number of peers.

e.g.:

#define JAILHOUSE_SHMEM_NO_REGIONS(peers) (2 + peers)

[...]

.num_memory_regions = [123 + JAILHOUSE_SHMEM_NO_REGIONS(2) + ...]

Ralf

Jan Kiszka

unread,
Jan 14, 2020, 11:42:41 AM1/14/20
to Ralf Ramsauer, jailho...@googlegroups.com
Ah, ok. Feel free to propose that on top, at least the helper with one
or two users. The hard part of that is always editing the configs. I've
edited too many in the recent weeks...
Reply all
Reply to author
Forward
0 new messages