]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - jailhouse/ti-jailhouse.git/log
jailhouse/ti-jailhouse.git
3 years agoconfigs: arm64: inmate-k3-j7200-evm: Add inmate device tree ti-jailhouse-0.12 07.01.00.001 07.01.00.002 07.01.00.003 07.01.00.004 07.01.00.005 07.01.00.006 07.02.00.001 07.02.00.002 07.02.00.003 07.02.00.004 07.03.00.000 07.03.00.001 07.03.00.002 07.03.00.003 07.03.00.004 07.03.00.005 08.00.00.000 08.00.00.001 2021.00.001 2021.00.002 2021.00.003
Nikhil Devshatwar [Wed, 15 Jul 2020 11:08:34 +0000 (16:38 +0530)]
configs: arm64: inmate-k3-j7200-evm: Add inmate device tree

Add a device tree for booting Linux into the inmate cell on
k3-j700-evm board. Add basic interconnect skeleton and few
peripherals like UART, MMC and GPIO controllers.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
3 years agoconfigs: arm64: Add Linux demo for k3j7200-evm board
Nikhil Devshatwar [Sat, 11 Jul 2020 14:36:21 +0000 (20:06 +0530)]
configs: arm64: Add Linux demo for k3j7200-evm board

Add the linux demo cell config for k3-j7200-evm board.
Also add the required device tree for booting Linux kernel
in the inmate cell.

Add mem_regions and enable interrupts for for main_uart1,
main_sdhci0, gpio interrupt routers and virtual PCI

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
3 years agoconfigs: arm64: Add inmate demo config for j7200-evm board
Nikhil Devshatwar [Sat, 11 Jul 2020 14:47:30 +0000 (20:17 +0530)]
configs: arm64: Add inmate demo config for j7200-evm board

Add inmate demo cell config for j7200-evm board.
This can be used to run the standard jaiilhouse baremetal
inmate demos like gic-demo, uart-demo and ivshmem-demo.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
3 years agoconfigs: arm64: Add support for k3-j7200-evm board
Nikhil Devshatwar [Sat, 11 Jul 2020 12:52:27 +0000 (18:22 +0530)]
configs: arm64: Add support for k3-j7200-evm board

k3-j7200-evm is the new evaluation module from Texas Instruments
which has the j7200 SoC. It has a dual coreARM Cortex-A72
CPU cores, 4GiB of RAM, 2x Display ports, 6x UART ports,
5x ethernet ports, SD and eMMC interfaces for storage and
many other connectivity and accelerator devices.

J7200 TRM: https://www.ti.com/lit/pdf/spruiu1

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
3 years agotools: ivshmem-demo: Pass peer_id command line 07.00.00.004 07.00.00.005
Nikhil Devshatwar [Mon, 11 May 2020 13:35:05 +0000 (19:05 +0530)]
tools: ivshmem-demo: Pass peer_id command line

Number of peers available on a platform is different.
Do not hard code the target peer_id used for interrupt.
Parse this from the command line argument.

This de-couples the dependency between number of peers.
ivshmem-demo can be run to communicate with desired target

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
3 years agotools: ivshmem-demo: Map memory regions with correct sizes
Nikhil Devshatwar [Mon, 11 May 2020 06:42:58 +0000 (12:12 +0530)]
tools: ivshmem-demo: Map memory regions with correct sizes

ivshmem protocol does not describe a fixed size for the
rw, input and output regions. For each platform, the uio
driver will populate this information in the sysfw.

Extract the size from sysfs maps entries and use it for
mapping different regions.
This will make the demo generic such that it will work on
all platforms with different sizes for ivshmem.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
3 years agoconfigs: k3-am654-inmate-demo: Add ivshmem capability
Nikhil Devshatwar [Mon, 11 May 2020 14:49:32 +0000 (20:19 +0530)]
configs: k3-am654-inmate-demo: Add ivshmem capability

Add a virtual PCI device with IVSHMEM type (id = 1)
Create IVSHMEM regions for 3 peer communication
Enable the vpci_irq for doorbell interrupt

This allows to run the ivshmem-demo baremetal inmate
inside this cell.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
3 years agoconfigs: k3-j721e-evm-inmate-demo: Add ivshmem capability
Nikhil Devshatwar [Mon, 11 May 2020 14:52:17 +0000 (20:22 +0530)]
configs: k3-j721e-evm-inmate-demo: Add ivshmem capability

Add a virtual PCI device with IVSHMEM type (id = 1)
Create IVSHMEM regions for 2 peer communication
Enable the vpci_irq for doorbell interrupt

This allows to run the ivshmem-demo baremetal inmate
inside this cell.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
3 years agoconfigs: k3-am654-idk: Describe separate IVSHMEM regions for demo
Nikhil Devshatwar [Mon, 11 May 2020 14:22:47 +0000 (19:52 +0530)]
configs: k3-am654-idk: Describe separate IVSHMEM regions for demo

Current IVSHMEM regions are described to be used for ivshmem-net
driver. For standalone ivshmem communication, these regions need to
be added explicitly instead of using the macro.

Add regions for a 3 peer IVSHMEM
 (0 = root cell, 1 = baremetal, 2 = linux-demo)

Also change the protocol to UNDEFINED so that the ivshmem-net driver
does not get engaged. Switch bdf = 0 for consistency across all
platforms.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
3 years agoconfigs: k3-j721e-evm: Describe separate IVSHMEM regions for demo
Nikhil Devshatwar [Mon, 11 May 2020 14:15:06 +0000 (19:45 +0530)]
configs: k3-j721e-evm: Describe separate IVSHMEM regions for demo

Current IVSHMEM regions are described to be used for ivshmem-net
driver. For standalone ivshmem communication, these regions need to
be added explicitly instead of using the macro.

Add regions for a 2 peer IVSHMEM communication
 (0 = root cell, 1 = baremetal / linux-demo)

Also change the protocol to UNDEFINED so that the ivshmem-net driver
does not get engaged. Switch bdf = 0 for consistency across all
platforms.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
4 years agoconfigs: arm64: k3-j721e-evm: Fix failure with PCIe
Nikhil Devshatwar [Mon, 9 Mar 2020 08:03:26 +0000 (13:33 +0530)]
configs: arm64: k3-j721e-evm: Fix failure with PCIe

PCI kernel framework requires that all the instances in the
device tree either specify the PCIe domain or none does.

Currently, Jailhouse dynamic overlay describes the PCI domain
which causes problems because root cell DTS does not describe
this.

Fix this by not specifying the domain in root cell config.
Also, fix the size of the PCI target region to match with the
correct description in TRM.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
4 years agoconfigs: arm64: k3-j721e-linux: Add GIC ITS Mem region
Kishon Vijay Abraham I [Fri, 3 Apr 2020 05:26:49 +0000 (10:56 +0530)]
configs: arm64: k3-j721e-linux: Add GIC ITS Mem region

Define the jailhouse_memory region for GIC ITS so that PCIe master
(RC mode) can write to GIC ITS for raising MSI/MSI-X interrupt.
This will be required when PCIe VMAP logic (RC mode) is configured
to route the transactions via PVU.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
4 years agoconfigs: k3-j721e-evm-linux-demo: Remove unsupported device partitioning 07.00.00.002 07.00.00.003 ti2020.00 ti2020.01.00
Nikhil Devshatwar [Thu, 5 Mar 2020 07:25:48 +0000 (12:55 +0530)]
configs: k3-j721e-evm-linux-demo: Remove unsupported device partitioning

In kernel 5.4, support for following is not available:
* D5520 decoder
* GPU virtualization
* DSS display virtualization
Remove these from cell config

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
4 years agoconfigs: arm64: k3-j721e-linux: Add USB mem_regions
Nikhil Devshatwar [Tue, 24 Dec 2019 10:19:07 +0000 (15:49 +0530)]
configs: arm64: k3-j721e-linux: Add USB mem_regions

Define the jailhouse_memory regions for the USB toplevel MMRs
This fixes the crash when root cell or inmate cell tries to
access the USB devices.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
4 years agoarm64: dts: k3-j721e-evm: Add pinmux for main_uart1
Nikhil Devshatwar [Tue, 18 Feb 2020 10:49:50 +0000 (16:19 +0530)]
arm64: dts: k3-j721e-evm: Add pinmux for main_uart1

Add a pinmux DT node for main_uart1.
Describe the pinctrl default state for main_uart1 node.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
4 years agoBump version number v0.12
Jan Kiszka [Tue, 4 Feb 2020 05:07:43 +0000 (06:07 +0100)]
Bump version number

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: arm64: Fix comments in qemu-arm64
Jan Kiszka [Thu, 30 Jan 2020 19:07:24 +0000 (20:07 +0100)]
configs: arm64: Fix comments in qemu-arm64

The device tree remark was copy&pasted, we use mem= for QEMU.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: arm64: Remove vmalloc from command line hint
Jan Kiszka [Wed, 29 Jan 2020 07:02:46 +0000 (08:02 +0100)]
configs: arm64: Remove vmalloc from command line hint

Not needed on arm64 because it starts Jailhouse differently compared to
arm (tk1).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoarm/arm64: Factor out more common parts of jailhouse_hypercall.h
Jan Kiszka [Mon, 27 Jan 2020 15:36:19 +0000 (16:36 +0100)]
arm/arm64: Factor out more common parts of jailhouse_hypercall.h

JAILHOUSE_HVC_CODE is the same, most of the JAILHOUSE_CPU_STAT_VMEXITS_*
are, and when we move struct jailhouse_comm_region, we can save
COMM_REGION_COMMON_PLATFORM_INFO.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoTODO: Update
Jan Kiszka [Mon, 27 Jan 2020 12:57:07 +0000 (13:57 +0100)]
TODO: Update

Add an entry about VT-d modernization, refine the SMMU to-do now that v3
is available, and drop big-endian - not relevant on ARM in the
foreseeable future.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoDocumentation: Update hypervisor interfaces specification
Jan Kiszka [Mon, 27 Jan 2020 05:47:03 +0000 (06:47 +0100)]
Documentation: Update hypervisor interfaces specification

Lots of things changed since the file was last touched. Add the
hypercall ABIs for non-Intel-x86, update the "CPU Get Info" hypercall
with new statistic types, and extend the Comm Region description with
the console and non-x86 extensions added meanwhile.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
4 years agocore: Mark jailhouse_comm_region as packed
Jan Kiszka [Mon, 27 Jan 2020 13:13:21 +0000 (14:13 +0100)]
core: Mark jailhouse_comm_region as packed

Ensure that we do not deviate in alignments, even if the currently
achieved natural one should once be violated.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoarm/arm64: Pad comm region to natural alignment
Jan Kiszka [Sat, 25 Jan 2020 17:17:51 +0000 (18:17 +0100)]
arm/arm64: Pad comm region to natural alignment

Better pad than rely on both sides using the same compiler logic.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: Tune comm region's flags field definition and documentation
Jan Kiszka [Sat, 25 Jan 2020 17:02:57 +0000 (18:02 +0100)]
core: Tune comm region's flags field definition and documentation

This field is static, thus volatile is not appropriate. Rephrase the
field and flags documentation for a clearer wording.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: Introduce JAILHOUSE_MEM_NO_HUGEPAGES memory region flag
Jan Kiszka [Wed, 13 Nov 2019 08:36:23 +0000 (09:36 +0100)]
core: Introduce JAILHOUSE_MEM_NO_HUGEPAGES memory region flag

This allows to mitigate CVE-2018-12207: On affected Intel machines, a
guest can trigger an unrecoverable machine check exception when running
a certain code pattern on an executable huge page. The suggested
mitigation pattern of Intel involves on-demand break-up of huge pages
when the guest tries to execute on them and also consolidating them into
non-executable huge pages dynamically. This pattern is not compatible
with the static and deterministic behavior of Jailhouse.

Therefore, this introduces a memory region flag to exclude huge page
mappings for a region. System configurators can use this flag for
executable regions on affected CPUs, while still allowing huge pages for
non-executable regions.

PAGING_HUGE/NO_HUGE is consistently applied to all caller of
paging_create, using NO_HUGE in case only a size known to be smaller
than a huge page is requested.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: paging: Refactor paging_create/destroy parameters
Jan Kiszka [Wed, 13 Nov 2019 08:29:30 +0000 (09:29 +0100)]
core: paging: Refactor paging_create/destroy parameters

Change the coherent enum into paging_flags in order to allow adding more
in the future. Rename the flags parameter to access_flags for better
differentiation.

Use this chance to align the names and types of local vars that are
forwarded to access_flags with that parameter.

No behavioral changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agotools: config-create: Adjust template to latest changes
Jan Kiszka [Sun, 19 Jan 2020 08:43:01 +0000 (09:43 +0100)]
tools: config-create: Adjust template to latest changes

This was forgotten in 3fac413f0647.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoarm64: Fix initialized return value in pvu_iommu_config_commit
Jan Kiszka [Thu, 16 Jan 2020 07:53:42 +0000 (08:53 +0100)]
arm64: Fix initialized return value in pvu_iommu_config_commit

This is relevant in case there are no stream IDs in a cell config. Found
by Coverity.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoarm-common: gic-v3: ensure LR writes are visible
Chase Conklin [Wed, 15 Jan 2020 17:33:39 +0000 (18:33 +0100)]
arm-common: gic-v3: ensure LR writes are visible

The GICv3 architecture does not guarantee that writes to the list
registers are self-synchronizing. As a result, it is possible for a
valid interrupt to be written into a list register but have the empty
list register status register report that list register as not holding
a valid interrupt. Since the empty list register status registers are
used to indicate which list registers can be used to inject an
interrupt to a cell, it is possible for a valid list register entry to
be overwritten, dropping the corresponding interrupt.

Fixes: 2ce9d14ca4e2 ("arm: GICv3 initialisation")
Signed-off-by: Chase Conklin <chase.conklin@arm.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: fix hugepage splitting in paging_destroy
Chase Conklin [Wed, 15 Jan 2020 17:32:17 +0000 (18:32 +0100)]
core: fix hugepage splitting in paging_destroy

When unmapping pages, it is not sufficient to compare the size of the
page to the size of the region to be unmapped to know whether a
hugepage needs to be split. That approach does not split hugepages
when the region to be unmapped is larger than a hugepage but does not
cover the entire hugepage, resulting in areas outside the region to be
unmapped and leaving areas inside the region mapped.

Instead of comparing the size of the region to the size of the page,
check if the region overlaps only part of the page and split the
hugepage if it does.

Fixes: 1f7784032531 ("core: Add support for creating page tables with hugepages")
Signed-off-by: Chase Conklin <chase.conklin@arm.com>
[Jan: reduced by two local variables]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoinmates: arm-common: Fix indention
Jan Kiszka [Wed, 15 Jan 2020 16:13:11 +0000 (17:13 +0100)]
inmates: arm-common: Fix indention

Use tab instead of spaces.

Reported-by: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: Add support for Raspberry Pi 4
Jan Kiszka [Wed, 15 Jan 2020 15:58:10 +0000 (16:58 +0100)]
configs: Add support for Raspberry Pi 4

This adds the system config, an inmate demo and a linux demo with dts
for running Jailhouse on the Raspberry Pi 4. Configs are designed for
the smallest, 1 GB variant. Models with more memory needs adjustments
or have to like like having 1 GB only.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: ivshmem: Unconditionally check ID range
Jan Kiszka [Tue, 14 Jan 2020 22:50:29 +0000 (23:50 +0100)]
core: ivshmem: Unconditionally check ID range

This check should not depend on whether we are adding a peer to link or
starting a new one.

Reported-by: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: arm64: k3-j721e-evm: Add stream ids for devices behind IOMMU
Nikhil Devshatwar [Mon, 13 Jan 2020 10:46:47 +0000 (11:46 +0100)]
configs: arm64: k3-j721e-evm: Add stream ids for devices behind IOMMU

Add stream_ids for peripherals which are behind IOMMU instances.
PVU and SMMU-V3 sets up memory mapping for all of these contexts
for correct 2nd stage translation.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: arm64: k3-j721e-evm: Add PVU IOMMU devices in platform_data
Nikhil Devshatwar [Mon, 13 Jan 2020 10:46:46 +0000 (11:46 +0100)]
configs: arm64: k3-j721e-evm: Add PVU IOMMU devices in platform_data

J721e device has 3 instance of PVU which can be used as IOMMU.
Each PVU has a config region and a TLB region where the memory
mapping information is stored.
Describe these as part of the root cell's platform_data.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoarm64: ti-pvu: Add support for ti-pvu iommu unit
Nikhil Devshatwar [Mon, 13 Jan 2020 10:46:45 +0000 (11:46 +0100)]
arm64: ti-pvu: Add support for ti-pvu iommu unit

Add support for Texas Instrument's Peripheral Virtualization Unit
* Define a new IOMMU type and extra fields in the platform_data
* Add new cofig option CONFIG_IOMMU_TI_PVU
* Integrate with the arm iommu support such that multiple types
  of IOMMU can be supported.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
[Jan: moved into arm64 completely, fixed whitespace warnings, fixed includes]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoarm/arm64: Move iommu.o out of arm-common
Jan Kiszka [Mon, 13 Jan 2020 13:22:23 +0000 (14:22 +0100)]
arm/arm64: Move iommu.o out of arm-common

There is no IOMMU support for 32-bit arm, and it's likely to now show up
there anymore. Make the iommu binding module arch-specific so that we
can add calls to the arm64 variant without affecting arm.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: Move amd specific fields in separate struct
Nikhil Devshatwar [Mon, 13 Jan 2020 10:46:44 +0000 (11:46 +0100)]
configs: Move amd specific fields in separate struct

Create a union for all vendor specific fields and move the
amd specific fields in separate struct.
Also update the amd unit references of these fields.

This is to handle multiple iommu devices and their custom fields
separately.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
[Jan: adjusted f2a88xm-hd3.c to new format]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: Update cell_state while destroying the cell
Nikhil Devshatwar [Mon, 13 Jan 2020 10:46:43 +0000 (11:46 +0100)]
core: Update cell_state while destroying the cell

Update the cell_state to SHUT_DOWN as part of the cell_destroy
This will make sure that the memory_unmap calls and unit's
cell_exit calls can see the correct status of the cell.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: arm64: k3-j721e-evm: Add SMMUv3 IOMMU in platform_data
Nikhil Devshatwar [Wed, 8 Jan 2020 11:15:12 +0000 (12:15 +0100)]
configs: arm64: k3-j721e-evm: Add SMMUv3 IOMMU in platform_data

J721e has a single ARM System MMU version3 for 2 stage
address translation of DMA requests from different peripherals.
Add this as iommu unit in the k3-j721e root cell configuration.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoarm64: smmu-v3: Fix crash in arm_smmuv3_cell_init
Nikhil Devshatwar [Wed, 8 Jan 2020 11:15:11 +0000 (12:15 +0100)]
arm64: smmu-v3: Fix crash in arm_smmuv3_cell_init

arm_smmuv3_cell_init and arm_smmuv3_cell_exit calls iterate over all
iommu_units to process the ones with SMMUV3 type.

After the loop, it unconditionally issues commands with first element
of smmu. This causes Unhandled HYP exception  while enabling jailhouse.
Also, it fails to issue commands on the subsequent SMMU units.

Fix this by issuing the sync command only if the iommu is SMMUV3 type.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfig: Remove unused JAILHOUSE_INVALID_STREAMID
Nikhil Devshatwar [Wed, 8 Jan 2020 11:15:10 +0000 (12:15 +0100)]
config: Remove unused JAILHOUSE_INVALID_STREAMID

Stream IDs are now described as arrays.
We do not need the sentinel JAILHOUSE_INVALID_STREAMID.
Remove this unused define.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoDocumentation: Describe ivshmem demos
Jan Kiszka [Mon, 6 Jan 2020 13:59:42 +0000 (14:59 +0100)]
Documentation: Describe ivshmem demos

Handles all currently available demo cases: ivshmem-net, ivshmem-demo
and virtio over ivshmem.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: arm: Add ivshmem-demo support for orangepi0
Jan Kiszka [Sat, 4 Jan 2020 12:48:28 +0000 (13:48 +0100)]
configs: arm: Add ivshmem-demo support for orangepi0

Enhance the root cell config as well as gic-demo and linux-demo with a
3-peers ivshmem device so that ivshmem-demo can be used.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: arm64: Add ivshmem-demo support for qemu-arm64
Jan Kiszka [Sat, 4 Jan 2020 10:16:33 +0000 (11:16 +0100)]
configs: arm64: Add ivshmem-demo support for qemu-arm64

Enhance the root cell config as well as gic-demo and linux-demo with a
3-peers ivshmem device so that ivshmem-demo can be used.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: arm/arm64: Consistently move ivshmem-net devices one PCI slot up
Jan Kiszka [Sun, 5 Jan 2020 12:13:57 +0000 (13:13 +0100)]
configs: arm/arm64: Consistently move ivshmem-net devices one PCI slot up

This free 00:00.0 on the virtual PCI controllers for the demo ivshmem
device. It should come before the networking device because it also uses
memory located before it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs, Documentation: arm/arm64: Rename gic-demo to inmate-demo
Jan Kiszka [Sun, 5 Jan 2020 11:50:38 +0000 (12:50 +0100)]
configs, Documentation: arm/arm64: Rename gic-demo to inmate-demo

This expresses that the configs can already be used for gic and uart
demos, soon more and more also for ivshmem.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: arm/arm64: Remove uart demos
Jan Kiszka [Sun, 5 Jan 2020 11:33:06 +0000 (12:33 +0100)]
configs: arm/arm64: Remove uart demos

Those add no value, compared to the gic-demo configs. They only increase
maintenance efforts.

The emtrion boards only have uart demos, no gic equivalents. Keep those
for now.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agotools: Add ivshmem-demo for Linux/UIO
Jan Kiszka [Sat, 4 Jan 2020 10:15:00 +0000 (11:15 +0100)]
tools: Add ivshmem-demo for Linux/UIO

This does almost the same as inmates/demos/ivshmem-demo.c, just using
the UIO driver for ivshmem under Linux.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoinmates: Rewrite ivshmem-demo
Jan Kiszka [Sat, 4 Jan 2020 10:08:37 +0000 (11:08 +0100)]
inmates: Rewrite ivshmem-demo

Provide a bare-metal demo inmate for the new ivshmem device, exploiting
almost all its features: state table, unidirectional shared memory,
multi-peer support, multiple interrupt vectors. This demo will be
accompanied by a Linux tool in order to span 3-peer demo between root,
bare-metal and a secondary Linux cell.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoinmates: Provide generic enable/disable_irqs
Jan Kiszka [Fri, 3 Jan 2020 21:48:12 +0000 (22:48 +0100)]
inmates: Provide generic enable/disable_irqs

Allows arch-independent inmates to control the interrupt mask.

Drop the unneeded "arch" prefix at this chance.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoinmates: Provide delay_us for all archs
Jan Kiszka [Fri, 3 Jan 2020 21:43:13 +0000 (22:43 +0100)]
inmates: Provide delay_us for all archs

Implement the ARM version and move the prototype to the common header.
This will allow to use delay_us in arch-independent inmates.

The addition of delay_us justifies the renaming of arm-common/timer.c to
timing.c, also analogously to x86.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoinmates: Make PCI support generic
Jan Kiszka [Fri, 3 Jan 2020 21:34:06 +0000 (22:34 +0100)]
inmates: Make PCI support generic

Provide PCI support for ARM by implementing mmconfig-based
pci_read/write_config and moving shared defines and prototypes into the
common header. pci_msix_set_vector is only implemented as stub on ARM
so far, can be enhanced later.

As mmconfig implies mapping of that MMIO region, pci_init is introduced.
x86 does not need it and only implements a stub in order to allow
arch-independent inmates.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoarm-common: Provide vpci_irq_base via Comm Region
Jan Kiszka [Fri, 3 Jan 2020 20:12:19 +0000 (21:12 +0100)]
arm-common: Provide vpci_irq_base via Comm Region

Allows bare-metal inmates to find the base SPI number of its virtual PCI
host controller.

Increment the ABI revision to conclude this change as well as the
previously generalized vpci_irq_base field.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: Provide pci_mmconfig_base via Comm Region on all archs
Jan Kiszka [Fri, 3 Jan 2020 20:09:27 +0000 (21:09 +0100)]
core: Provide pci_mmconfig_base via Comm Region on all archs

This will simplify PCI support in bare-metal ARM inmates.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoinmates: Generalize gic_enable_irq to irq_enable
Jan Kiszka [Fri, 3 Jan 2020 19:32:41 +0000 (20:32 +0100)]
inmates: Generalize gic_enable_irq to irq_enable

This will allow writing generic inmates that needs to use the service
for ARM. x86 is just a stub.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoinmates: Rework interrupt API
Jan Kiszka [Fri, 3 Jan 2020 19:25:22 +0000 (20:25 +0100)]
inmates: Rework interrupt API

This generalizes the API for initializing the subsystem and registering
a handler with it. x86 now uses the same pattern as the ARM
architectures: There is only one custom handler that is invoked with the
triggered interrupt number as parameter.

Along this, the API functions are changed to use the more readable "irq"
prefix.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: x86: Add virtio block device between qemu-x86 and linux-x86-demo
Jan Kiszka [Tue, 15 Oct 2019 07:10:32 +0000 (09:10 +0200)]
configs: x86: Add virtio block device between qemu-x86 and linux-x86-demo

This enables the root cell to provide a virtio block device via ivshmem
to the non-root Linux cell.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: x86: Add virtio console device between qemu-x86 and linux-x86-demo
Jan Kiszka [Mon, 14 Oct 2019 16:08:47 +0000 (18:08 +0200)]
configs: x86: Add virtio console device between qemu-x86 and linux-x86-demo

This enables the root cell to provide a virtio console via ivshmem to
the non-root Linux cell.

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

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: Add ivshmem protocol defines for virtio to cell-config.h
Jan Kiszka [Mon, 14 Oct 2019 16:08:34 +0000 (18:08 +0200)]
configs: Add ivshmem protocol defines for virtio to cell-config.h

This defines the protocol ID ranges for virtio backends and frontends
along with a view virtio device IDs, allowing to create such devices in
cell configs.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: x86: Add multi-peer ivshmem demo
Jan Kiszka [Mon, 8 Jul 2019 08:56:31 +0000 (10:56 +0200)]
configs: x86: Add multi-peer ivshmem demo

Add the demo ivshmem device also to the linux-x86-demo and make it
3-peers (root, ivshmem-demo, linux-x86-demo). This allows to test and
demonstrate the new multi-peer feature. For that, we need to move
ivshmem-demo on the 2nd CPU and shrink the RAM of the linux-x86-demo by
2 MB.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoDocumentation: Update inter-cell-communication
Jan Kiszka [Mon, 6 Jan 2020 11:30:37 +0000 (12:30 +0100)]
Documentation: Update inter-cell-communication

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.kiszka@siemens.com>
4 years agoDocumentation: Add specification of IVSHMEM v2 device
Jan Kiszka [Sat, 14 Jan 2017 09:07:20 +0000 (10:07 +0100)]
Documentation: Add specification of IVSHMEM v2 device

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.kiszka@siemens.com>
4 years agocore: ivshmem: Reorder ivshmem_endpoint fields
Jan Kiszka [Mon, 8 Jul 2019 08:54:21 +0000 (10:54 +0200)]
core: ivshmem: Reorder ivshmem_endpoint fields

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

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: ivshmem: Drop revision protocol ID
Jan Kiszka [Sun, 7 Jul 2019 20:47:09 +0000 (22:47 +0200)]
core: ivshmem: Drop revision protocol ID

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.kiszka@siemens.com>
4 years agocore, configs: ivshmem: Add multi-peer support
Jan Kiszka [Sun, 7 Jul 2019 18:14:12 +0000 (20:14 +0200)]
core, configs: ivshmem: Add multi-peer support

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.kiszka@siemens.com>
4 years agocore, configs: ivshmem: Add shared memory output sections support
Jan Kiszka [Sun, 7 Jul 2019 17:54:54 +0000 (19:54 +0200)]
core, configs: ivshmem: Add shared memory output sections support

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.kiszka@siemens.com>
4 years agocore: ivshmem: Add one-shot interrupt mode
Jan Kiszka [Sun, 7 Jul 2019 16:29:00 +0000 (18:29 +0200)]
core: ivshmem: Add one-shot interrupt mode

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.kiszka@siemens.com>
4 years agocore: ivshmem: Expand interrupt control to device level
Jan Kiszka [Sun, 7 Jul 2019 16:21:46 +0000 (18:21 +0200)]
core: ivshmem: Expand interrupt control to device level

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.kiszka@siemens.com>
4 years agoconfigs: Expand number of ivshmem vectors
Jan Kiszka [Sat, 6 Jul 2019 14:14:36 +0000 (16:14 +0200)]
configs: Expand number of ivshmem vectors

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.kiszka@siemens.com>
4 years agocore: ivshmem: Add support for multiple interrupt vectors
Jan Kiszka [Mon, 1 Jul 2019 06:17:07 +0000 (08:17 +0200)]
core: ivshmem: Add support for multiple interrupt vectors

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.kiszka@siemens.com>
4 years agocore: ivshmem: Switch to ivshmem_endpoint as parameter of arch_ivshmem_update_msix
Jan Kiszka [Sat, 6 Jul 2019 13:48:53 +0000 (15:48 +0200)]
core: ivshmem: Switch to ivshmem_endpoint as parameter of arch_ivshmem_update_msix

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

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: ivshmem: Re-add target ID to doorbell register
Jan Kiszka [Sun, 30 Jun 2019 19:15:52 +0000 (21:15 +0200)]
core: ivshmem: Re-add target ID to doorbell register

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.kiszka@siemens.com>
4 years agocore: ivshmem: Rework interrupt configuration and injection
Jan Kiszka [Fri, 21 Jun 2019 12:28:43 +0000 (14:28 +0200)]
core: ivshmem: Rework interrupt configuration and injection

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.kiszka@siemens.com>
4 years agocore, configs: ivshmem: Add state table
Jan Kiszka [Sat, 29 Jun 2019 10:39:43 +0000 (12:39 +0200)]
core, configs: ivshmem: Add state table

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.kiszka@siemens.com>
4 years agoconfigs: Move ivshmem memory regions at array start
Jan Kiszka [Thu, 26 Dec 2019 20:23:56 +0000 (21:23 +0100)]
configs: Move ivshmem memory regions at array start

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.kiszka@siemens.com>
4 years agoconfigs: Factor out ivshmem memory region macro for network devices
Jan Kiszka [Thu, 26 Dec 2019 18:49:48 +0000 (19:49 +0100)]
configs: Factor out ivshmem memory region macro for network devices

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.kiszka@siemens.com>
4 years agoconfigs: x86: Rework ivshmem settings
Jan Kiszka [Fri, 27 Dec 2019 18:04:41 +0000 (19:04 +0100)]
configs: x86: Rework ivshmem settings

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.kiszka@siemens.com>
4 years agocore: ivshmem: Relax peer matching rules
Jan Kiszka [Mon, 8 Jul 2019 08:47:56 +0000 (10:47 +0200)]
core: ivshmem: Relax peer matching rules

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.kiszka@siemens.com>
4 years agocore: ivshmem: Introduce link pointer to ivshmem_endpoint
Jan Kiszka [Sat, 31 Dec 2016 09:27:27 +0000 (10:27 +0100)]
core: ivshmem: Introduce link pointer to ivshmem_endpoint

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

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: ivshmem: Avoid assumption about size of ivshmem_link
Jan Kiszka [Sun, 7 Jul 2019 15:29:51 +0000 (17:29 +0200)]
core: ivshmem: Avoid assumption about size of ivshmem_link

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

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: ivshmem: Rename ivshmem_data to ivshmem_link
Jan Kiszka [Sat, 31 Dec 2016 09:26:00 +0000 (10:26 +0100)]
core: ivshmem: Rename ivshmem_data to ivshmem_link

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

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: ivshmem: Fold ivshmem_write_msix_control into caller
Jan Kiszka [Sat, 31 Dec 2016 12:06:06 +0000 (13:06 +0100)]
core: ivshmem: Fold ivshmem_write_msix_control into caller

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.kiszka@siemens.com>
4 years agocore: ivshmem: Reintroduce ivshmem_update_msix
Jan Kiszka [Sat, 31 Dec 2016 11:01:25 +0000 (12:01 +0100)]
core: ivshmem: Reintroduce ivshmem_update_msix

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.kiszka@siemens.com>
4 years agocore: ivshmem: Mask MSI-X vector on reset
Jan Kiszka [Sun, 7 Jul 2019 15:32:04 +0000 (17:32 +0200)]
core: ivshmem: Mask MSI-X vector on reset

This is demanded by the PCI spec.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: ivshmem: Add PCI-conforming INTx mask
Jan Kiszka [Thu, 22 Dec 2016 09:00:53 +0000 (10:00 +0100)]
core: ivshmem: Add PCI-conforming INTx mask

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.kiszka@siemens.com>
4 years agocore: ivshmem: Use device ID from config
Jan Kiszka [Sat, 15 Jun 2019 10:36:04 +0000 (12:36 +0200)]
core: ivshmem: Use device ID from config

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

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agoconfigs: Add field for shmem device ID
Jan Kiszka [Sat, 15 Jun 2019 12:48:06 +0000 (14:48 +0200)]
configs: Add field for shmem device ID

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.kiszka@siemens.com>
4 years agocore: ivshmem: Add MAX_PEERS register
Jan Kiszka [Sat, 15 Jun 2019 13:30:23 +0000 (15:30 +0200)]
core: ivshmem: Add MAX_PEERS register

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.kiszka@siemens.com>
4 years agocore: ivshmem: Rename IVPOS register to ID
Jan Kiszka [Sun, 1 Jan 2017 07:16:34 +0000 (08:16 +0100)]
core: ivshmem: Rename IVPOS register to ID

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

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
4 years agocore: ivshmem: Reorganize MMIO registers
Jan Kiszka [Sat, 15 Jun 2019 09:55:36 +0000 (11:55 +0200)]
core: ivshmem: Reorganize MMIO registers

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.kiszka@siemens.com>
4 years agocore: ivshmem: Move shared memory parameters into vendor specific capability
Jan Kiszka [Wed, 30 Nov 2016 22:13:54 +0000 (23:13 +0100)]
core: ivshmem: Move shared memory parameters into vendor specific capability

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.kiszka@siemens.com>
4 years agocore: ivshmem: Move MSI-X region into 32-bit BAR1
Jan Kiszka [Sat, 15 Jun 2019 20:24:19 +0000 (22:24 +0200)]
core: ivshmem: Move MSI-X region into 32-bit BAR1

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.kiszka@siemens.com>
4 years agocore: ivshmem: Convert MMIO register region to 4K and 32-bit
Jan Kiszka [Thu, 22 Dec 2016 08:24:14 +0000 (09:24 +0100)]
core: ivshmem: Convert MMIO register region to 4K and 32-bit

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.kiszka@siemens.com>
4 years agoconfigs: Use constants for bar_mask of ivshmem devices
Jan Kiszka [Thu, 26 Dec 2019 17:39:19 +0000 (18:39 +0100)]
configs: Use constants for bar_mask of ivshmem devices

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.kiszka@siemens.com>
4 years agocore: ivshmem: Enable unprivileged MMIO register access
Jan Kiszka [Thu, 22 Dec 2016 08:22:34 +0000 (09:22 +0100)]
core: ivshmem: Enable unprivileged MMIO register access

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.kiszka@siemens.com>
4 years agocore: ivshmem: Derive MMIO register region size from cell config
Jan Kiszka [Fri, 2 Dec 2016 15:16:58 +0000 (16:16 +0100)]
core: ivshmem: Derive MMIO register region size from cell config

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.kiszka@siemens.com>
4 years agocore: Restrict asm/ivshmem.h to inclusion by jailhouse/ivshmem.h
Jan Kiszka [Sat, 24 Dec 2016 14:15:32 +0000 (15:15 +0100)]
core: Restrict asm/ivshmem.h to inclusion by jailhouse/ivshmem.h

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.kiszka@siemens.com>
4 years agocore: ivshmem: Use Siemens-provided device ID
Jan Kiszka [Sat, 23 Nov 2019 08:05:35 +0000 (09:05 +0100)]
core: ivshmem: Use Siemens-provided device ID

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.kiszka@siemens.com>
4 years agocore: Use PAGE_OFFS_MASK consistently
Jan Kiszka [Mon, 6 Jan 2020 09:11:59 +0000 (10:11 +0100)]
core: Use PAGE_OFFS_MASK consistently

Replace remaining ~PAGE_MASK patterns with the more readable
PAGE_OFFS_MASK.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>