]> rtime.felk.cvut.cz Git - jailhouse.git/log
jailhouse.git
8 years agotools: Rewrap jailhouse help output
Jan Kiszka [Fri, 1 Jan 2016 12:53:06 +0000 (13:53 +0100)]
tools: Rewrap jailhouse help output

Avoid that we exceed 80 characters.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: Add support for command line parameters
Jan Kiszka [Mon, 4 Jan 2016 10:17:11 +0000 (11:17 +0100)]
inmates: Add support for command line parameters

This provides support for parsing string, integer (long long type) and
boolean command line parameters. The former two need to be in the form
of "name=value" so that cmdline_parse_str/int will return the extracted
value. Boolean parameters are just of the form "name", and
cmdline_parse_bool will return true if this pattern is found. Parameters
need to be separated by blanks.

The parameters can be passed to the inmate by loading the string at an
architecture-specific location. That is 0xf0000 on x86 and 0x100 on ARM
so far. Note that the inmate has to reserve an appropriately sized
buffer via the CMDLINE_BUFFER macro.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: Add strlen and strncmp to library
Jan Kiszka [Mon, 4 Jan 2016 10:14:45 +0000 (11:14 +0100)]
inmates: Add strlen and strncmp to library

Add simplistic but generic implementations of strlen and strncmp to the
inmate library. Both will be used for the command line parser.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: Avoid jailhouse/types.h
Jan Kiszka [Sat, 2 Jan 2016 18:39:02 +0000 (19:39 +0100)]
inmates: Avoid jailhouse/types.h

Add missing bool to inmate_common.h and use inmate.h instead of pulling
the hypervisor types header.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: arm: Reduce dependencies on hypervisor gic headers
Jan Kiszka [Mon, 4 Jan 2016 09:50:55 +0000 (10:50 +0100)]
inmates: arm: Reduce dependencies on hypervisor gic headers

We still reuse asm/sysregs.h, but that header comes without further
dependencies, specifically the conflicting jailhouse/types.h.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: Factor out common library header
Jan Kiszka [Sun, 3 Jan 2016 10:25:10 +0000 (11:25 +0100)]
inmates: Factor out common library header

Collect arch-independent parts of inmate.h in a common header, included
by the architecture-specific ones.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: x86: Remove redundant hypercall include
Jan Kiszka [Sat, 2 Jan 2016 20:38:13 +0000 (21:38 +0100)]
inmates: x86: Remove redundant hypercall include

inmate.h takes care of this.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: Provide memset implementation for non-built-in cases
Jan Kiszka [Sat, 2 Jan 2016 18:32:37 +0000 (19:32 +0100)]
inmates: Provide memset implementation for non-built-in cases

This avoids the inline variant of ARM. The new link optimization will
remove what is unused.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: Drop unused library functions during linking
Jan Kiszka [Sat, 2 Jan 2016 18:11:02 +0000 (19:11 +0100)]
inmates: Drop unused library functions during linking

Tiny size optimization: push library functions into separate sections
and drop unused ones during linking.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: arm: Provide mmio_read/write32 via library header
Jan Kiszka [Sat, 2 Jan 2016 16:38:40 +0000 (17:38 +0100)]
inmates: arm: Provide mmio_read/write32 via library header

Avoids the ugly and indirect inclusion of the hypervisor definitions in
gic-demo. We still pull it from there in gic-v2/3, though - to be fixed
later.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agohypervisor, inmates: Remove write-only fields from uart_chip
Jan Kiszka [Sat, 2 Jan 2016 16:16:34 +0000 (17:16 +0100)]
hypervisor, inmates: Remove write-only fields from uart_chip

baudrate and fifo_enabled are never read back.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: x86: Build separate generic pci module
Jan Kiszka [Sat, 2 Jan 2016 16:00:25 +0000 (17:00 +0100)]
inmates: x86: Build separate generic pci module

No need for the ugly include.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: arm: Flatten include path
Jan Kiszka [Sat, 2 Jan 2016 15:46:49 +0000 (16:46 +0100)]
inmates: arm: Flatten include path

Move inmate.h and gic.h one level down, removing "inmates/" from their
path. This allows to reference inmate.h in generic library modules.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: arm: Initialize bss programmatically
Jan Kiszka [Sat, 2 Jan 2016 14:52:08 +0000 (15:52 +0100)]
inmates: arm: Initialize bss programmatically

Aligns ARM with x86: initialize bss with a small assembly loop before
inmate_main is invoked. This allows to move it after other sections,
effectively removing it from the image file.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: arm: Remove useless COMMON notation
Jan Kiszka [Sat, 2 Jan 2016 14:47:19 +0000 (15:47 +0100)]
inmates: arm: Remove useless COMMON notation

We build inmates with -fno-common.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: arm: Move stack page behind the image
Jan Kiszka [Sat, 2 Jan 2016 12:52:27 +0000 (13:52 +0100)]
inmates: arm: Move stack page behind the image

By moving the stack behind other sections, we can shrink the image files
by this page.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: x86: Move loader page tables into rodata section
Jan Kiszka [Fri, 1 Jan 2016 12:19:29 +0000 (13:19 +0100)]
inmates: x86: Move loader page tables into rodata section

This enables the linker to compact the output a bit more, saving between
1500 bytes (32 bit) and 3300 bytes (64 bit) in the F-segment.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Fix comment typo
Jan Kiszka [Fri, 8 Jan 2016 18:30:49 +0000 (19:30 +0100)]
x86: Fix comment typo

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Properly roll back failing IOAPIC cell initialization
Jan Kiszka [Thu, 7 Jan 2016 07:54:17 +0000 (08:54 +0100)]
x86: Properly roll back failing IOAPIC cell initialization

We have to release already allocated resources if ioapic_get_or_add_phys
fails. At least the arch.ioapics array should be freed again, but
possibly also previously claimed root cell IOAPIC pins.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Rename local result variable
Jan Kiszka [Sun, 27 Dec 2015 18:02:43 +0000 (19:02 +0100)]
x86: Rename local result variable

The return value of vtd_emulate_inv_int is not of the typical "0 or
negative error code" but actually returns an IR table index on success.
Avoid any confusions by using the more neutral variable name "result".

No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agotools: config-create: Add stubs for extended capabilities
Jan Kiszka [Thu, 24 Sep 2015 19:53:06 +0000 (21:53 +0200)]
tools: config-create: Add stubs for extended capabilities

Scan the extended capability space of PCI express devices and leave
a stub for anything that is detected. For SR-IOV, the size is already
encoded, other capabilities still need to be filled. This doesn't expand
write permission to any capability yet, standard or extended.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: Tag PCI express extended capability IDs via highest bit
Jan Kiszka [Thu, 24 Sep 2015 19:48:05 +0000 (21:48 +0200)]
core: Tag PCI express extended capability IDs via highest bit

PCI express extended capabilities span a separate ID space. In order to
use the same jailhouse_pci_capability structure as for PCI capabilities
and also to avoid extending the ID field, reserve the highest bit 15 to
tag extended IDs. PCI so far only uses the lowest 5 bits and apparently
expands linearly, so we won't see any conflicts in the foreseeable
future.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: vmx: Micro-cleanup in vcpu_vendor_cell_init
Jan Kiszka [Tue, 11 Aug 2015 04:35:11 +0000 (06:35 +0200)]
x86: vmx: Micro-cleanup in vcpu_vendor_cell_init

Return the error code directly instead of take the indirect route via
pre-initialized err variable. Avoids that some refactoring once destroys
this relationship.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Report only unhandled PIO accesses in the common handler
Jan Kiszka [Mon, 21 Dec 2015 23:29:14 +0000 (00:29 +0100)]
x86: Report only unhandled PIO accesses in the common handler

This aligns vcpu_handle_io_access to vcpu_handle_mmio_access again which
got lost in 46ad4efeb8: errors detected by handlers are already reported
there.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Intercept #AC and #DB to prevent guest-triggered microcode loops
Jan Kiszka [Mon, 21 Dec 2015 23:53:45 +0000 (00:53 +0100)]
x86: Intercept #AC and #DB to prevent guest-triggered microcode loops

This addresses CVE-2015-5307 and CVE-2015-8104 [1] for Jailhouse:
malicious cells may bring VCPUs into a state where the CPU will
infinitely loop over microcode, providing the hypervisor no chance to
interrupt these loops anymore. For this we have to intercept the #DB and
the exceptions to the cell.

If a guest is trapped in an exception loop can be detected by checking
the exception exit statistics which are now recorded: a large number of
exception exists per second (>1 million typically) will indicate this.

[1] http://permalink.gmane.org/gmane.comp.emulators.xen.user/85863

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Refine includes of vcpu.c
Jan Kiszka [Tue, 22 Dec 2015 14:20:39 +0000 (15:20 +0100)]
x86: Refine includes of vcpu.c

We actually need asm/apic.h rather than asm/iommu.h.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Enhance x86_handle_events to x86_check_events
Jan Kiszka [Mon, 21 Dec 2015 23:50:36 +0000 (00:50 +0100)]
x86: Enhance x86_handle_events to x86_check_events

There is now quite some commonality between svm and vmx when it comes to
checking for pending events. Move those parts into x86_check_events,
which becomes the extended version of x86_handle_events. Only a small
difference is now left behind in vmx_check_events(): the preemption
timer has to be disabled before the check.

Just like x86_handle_events, also x86_check_events only works against
the caller's CPU. So remove the cpu_data parameter at this chance.

We can remove the "sipi_vector = -1" after x86_enter_wait_for_sipi now
because we no longer return that value from x86_check_events, and
sipi_vector is not evaluated elsewhere because cpu_data->wait_for_sipi
is true.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Refactor VCPU reset functions
Jan Kiszka [Tue, 22 Dec 2015 13:31:49 +0000 (14:31 +0100)]
x86: Refactor VCPU reset functions

Make vcpu_reset() the one-stop solution by factoring out
vcpu_vendor_reset() that is called by the former and replaces
svm/vmx_vcpu_reset().

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: vmx: Factor out vmx_preemption_timer_set_enable
Jan Kiszka [Fri, 13 Nov 2015 09:20:56 +0000 (10:20 +0100)]
x86: vmx: Factor out vmx_preemption_timer_set_enable

Control both enabling and disabling of the preemption timer from a
single function. This simplifies the code.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: vmx: Move up vmx_disable_preemption_timer unmodified
Jan Kiszka [Fri, 13 Nov 2015 09:22:43 +0000 (10:22 +0100)]
x86: vmx: Move up vmx_disable_preemption_timer unmodified

This prepares the refactoring of that function. No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore, driver: x86: Introduce exception statistics
Jan Kiszka [Fri, 13 Nov 2015 09:09:56 +0000 (10:09 +0100)]
core, driver: x86: Introduce exception statistics

An x86 architecture design flaw requires us to intercept certain
exceptions. Prepare for this by adding a corresponding exit counter.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoREADME: add note about not using the serial port in the guest
Daniel P. Berrange [Thu, 10 Dec 2015 13:40:04 +0000 (13:40 +0000)]
README: add note about not using the serial port in the guest

The Jailhouse qemu-vm.celll config will prevent the root cell
accessing the serial port, so add a note about not using this
for the guest OS console.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agotools: make jailhouse-cell-linux run under Python3
Ralf Ramsauer [Sun, 15 Nov 2015 17:03:02 +0000 (18:03 +0100)]
tools: make jailhouse-cell-linux run under Python3

jailhouse-cell-linux did not run under Python3. This small patch allows
jailhouse-cell-linux to run under both versions: Python2 and Python3

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoRespect size of io bitmap in vcpu_cell_init()
Ralf Ramsauer [Tue, 27 Oct 2015 16:26:24 +0000 (17:26 +0100)]
Respect size of io bitmap in vcpu_cell_init()

Previous code copied the IO bitmap without respect to its actual size.
This patch simplifies the copying process and respects the size of the
destination.

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
[Jan: fine-tuned comments]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: fix erroneous sizeof() usage
Valentine Sinitsyn [Wed, 4 Nov 2015 09:06:11 +0000 (14:06 +0500)]
x86: fix erroneous sizeof() usage

vcpu functions were using sizeof() to determine the size of dynamically
allocated I/O bitmap, which won't work. Assign this value statically per
sub-architecture (Intel or AMD).

Reported-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoDocumentation: articles: LJ-article-04-2015.txt
Xuguo Wang [Thu, 15 Oct 2015 07:13:26 +0000 (15:13 +0800)]
Documentation: articles: LJ-article-04-2015.txt

This document is used for the newbies, so I think the words must
accurate, and command must correct, but in the section of "Configs and
inmates", a command like this :
    sudo tools/jailhouse cell stat apic-demo
but actually the right command is :
    sudo tools/jailhouse cell stats apic-demo
So I send this patch.

Reported-by: Xuguo Wang <huddy1985@gmail.com>
Signed-off-by: Xuguo Wang <huddy1985@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoci: Update Travis Ubuntu environment
Jan Kiszka [Thu, 15 Oct 2015 08:53:20 +0000 (10:53 +0200)]
ci: Update Travis Ubuntu environment

The utopic packages are no longer available, we need vivid. It's also a
good point to try out the beta environment based on trusty in to hope to
reduce the number of updates.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: svm: Remove redundant error report on NPF exits
Jan Kiszka [Thu, 24 Sep 2015 08:01:18 +0000 (10:01 +0200)]
x86: svm: Remove redundant error report on NPF exits

svm_handle_apic_access and vcpu_handle_mmio_access already do the
reporting.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: svm: Do not enable incomplete AVIC support
Jan Kiszka [Thu, 24 Sep 2015 07:58:26 +0000 (09:58 +0200)]
x86: svm: Do not enable incomplete AVIC support

This breaks on hardware with the AVIC feature present.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: svm: Fix broken FS base on deactivation
Jan Kiszka [Fri, 25 Sep 2015 17:47:18 +0000 (19:47 +0200)]
x86: svm: Fix broken FS base on deactivation

After f93e23934b, we no longer call vmsave, thus will also not find the
right FS base there. This caused sporadic crashes of "jailhouse disable"
on return to userspace.

Fix it by loading the value from the corresponding MSR.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: pci: Fix format string of MMCONFIG error reporting
Jan Kiszka [Fri, 18 Sep 2015 16:06:58 +0000 (18:06 +0200)]
core: pci: Fix format string of MMCONFIG error reporting

The config space address was not printed.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: pci: Fix MMCONFIG handling for root cell
Jan Kiszka [Fri, 18 Sep 2015 16:02:10 +0000 (18:02 +0200)]
core: pci: Fix MMCONFIG handling for root cell

Reorder the initialization in pci_init so that MMCONFIG is set up before
pci_cell_init is invoked for the root cell. Calling pci_cell_init
earlier has the undesired effect that the MMCONFIG region is not
registered for the root cell, and all related accesses will fail with
generic MMIO errors.

This is a regression of e17d52525d.

Reported-by: Yijun Zhu <zhuyijun@huawei.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: x86: Switch apic-demo to TSC time measurement
Jan Kiszka [Wed, 16 Sep 2015 07:41:28 +0000 (09:41 +0200)]
inmates: x86: Switch apic-demo to TSC time measurement

Removes chipset-related latency sources from the APIC timer interrupt
benchmark, enabling extremely low jitters (e.g. < 1µs on a Xeon D-1540).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: x86: Add support for TSC-based timing
Jan Kiszka [Wed, 16 Sep 2015 07:22:23 +0000 (09:22 +0200)]
inmates: x86: Add support for TSC-based timing

Provide a service to calibrate the TSC against the PM timer and read out
the current time in nanoseconds. This service is much faster than the
slow PM timer, and it's also not affected by chipset-induced delays.

Note that the simplistic algorithm only supports measuring relative time
spans of a couple of seconds.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: x86: Make pm_timer_read SMP-safe
Jan Kiszka [Wed, 16 Sep 2015 06:57:19 +0000 (08:57 +0200)]
inmates: x86: Make pm_timer_read SMP-safe

Enable parallel usage of pm_timer_read on different cell CPUs by making
the last value and the overflow sum per-cpu variables.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: Fixed typos in documentation
Christian Loehle [Mon, 14 Sep 2015 13:23:07 +0000 (15:23 +0200)]
core: Fixed typos in documentation

Signed-off-by: Christian Loehle <cloehle@linutronix.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoDocumentation: Document running/locked in sysfs-entries.txt
Christian Loehle [Mon, 14 Sep 2015 13:22:39 +0000 (15:22 +0200)]
Documentation: Document running/locked in sysfs-entries.txt

Signed-off-by: Christian Loehle <cloehle@linutronix.de>
[Jan: wrap long line]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: add missing include to control.h
Antonios Motakis [Wed, 12 Aug 2015 16:22:01 +0000 (18:22 +0200)]
core: add missing include to control.h

Add a missing include to hypervisor/includes/jailhouse/control.h

Signed-off-by: Antonios Motakis <antonios.motakis@huawei.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: add missing include to irqchip.h
Antonios Motakis [Wed, 12 Aug 2015 16:22:00 +0000 (18:22 +0200)]
core: add missing include to irqchip.h

Add a missing include to irqchip.h

Signed-off-by: Antonios Motakis <antonios.motakis@huawei.com>
[Jan: adjust to alphabetic ordering]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: arm: add missing include to gic-common.c
Antonios Motakis [Wed, 12 Aug 2015 16:21:59 +0000 (18:21 +0200)]
core: arm: add missing include to gic-common.c

Add a missing include to gic-common.c

Signed-off-by: Antonios Motakis <antonios.motakis@huawei.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: Clean up asm/bitops.h inclusions
Jan Kiszka [Wed, 19 Aug 2015 21:52:45 +0000 (14:52 -0700)]
core: Clean up asm/bitops.h inclusions

No asm/spinlock.h header need it anymore. If we remove it, we need to
convert the implicit inclusion in arm/mmio.c into an explicit one.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: printk: include asm/bitops.h directly
Antonios Motakis [Wed, 12 Aug 2015 16:21:58 +0000 (18:21 +0200)]
core: printk: include asm/bitops.h directly

Currently the implementation in hypervisor/printk.c assumes asm/bitops.h
will be included by asm/spinlock.h. Since this implementation is using
bitops directly, we include the right header file.

Signed-off-by: Antonios Motakis <antonios.motakis@huawei.com>
[Jan: adjust to alphabetic ordering]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agohypervisor, driver: Added signature for .cell files
Ralf Ramsauer [Thu, 13 Aug 2015 23:23:58 +0000 (01:23 +0200)]
hypervisor, driver: Added signature for .cell files

Inserted signature field in struct jailhouse_cell_desc and
jailhouse_system. Jailhouse kernel driver will refuse loading
a system configuration as a cell configuration et vice versa.

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
[Jan: also adjust Linux loader script]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Migrate irqchips to generic MMIO dispatcher
Jan Kiszka [Wed, 5 Aug 2015 10:05:20 +0000 (12:05 +0200)]
arm: Migrate irqchips to generic MMIO dispatcher

Register the GIC distributor and, for the GICv3, also the redistributor
regions with the generic MMIO dispatcher. This allows to drop the GIC-
specific MMIO dispatching from arch_handle_dabt.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Remove return codes from gic[v3]_handle_sgir_write
Jan Kiszka [Wed, 5 Aug 2015 10:03:01 +0000 (12:03 +0200)]
arm: Remove return codes from gic[v3]_handle_sgir_write

Those services always succeed.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Move gic_handle_redist_access unmodified
Jan Kiszka [Wed, 5 Aug 2015 09:58:06 +0000 (11:58 +0200)]
arm: Move gic_handle_redist_access unmodified

We will need it earlier in the module.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Migrate SMP mailbox to generic MMIO dispatcher
Jan Kiszka [Wed, 5 Aug 2015 09:51:36 +0000 (11:51 +0200)]
arm: Migrate SMP mailbox to generic MMIO dispatcher

Where needed, register the SMP mailbox MMIO page with the generic
dispatcher and remove the SMP-specific dispatcher invocation from
arch_handle_dabt.

This further concentrates the Versatile Express-specific SMP services in
that module.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Prepare generic MMIO dispatching
Jan Kiszka [Wed, 5 Aug 2015 09:44:53 +0000 (11:44 +0200)]
arm: Prepare generic MMIO dispatching

Hook up the generic MMIO dispatcher into arch_handle_dabt without
removing existing handlers. This allows for a step-wise migration of
subsystems to the new dispatcher.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: pci: Remove list of MSI-X devices
Jan Kiszka [Wed, 5 Aug 2015 09:30:03 +0000 (11:30 +0200)]
core: pci: Remove list of MSI-X devices

No longer used.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore, x86: pci: Migrate MSI-X emulation to generic MMIO dispatcher
Jan Kiszka [Wed, 5 Aug 2015 09:25:49 +0000 (11:25 +0200)]
core, x86: pci: Migrate MSI-X emulation to generic MMIO dispatcher

Register the MMIO BARs of PCI devices with the generic MMIO dispatcher
and remove direct invocation of pci_mmio_access_handler from
vcpu_handle_mmio_access. This particularly avoid having to scan all
PCI devices of a cell with MSI-X support to find out the target of an
MSI-X access.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: pci: Migrate MMCONFIG access handling to the new MMIO dispatcher
Jan Kiszka [Wed, 5 Aug 2015 09:16:32 +0000 (11:16 +0200)]
core: pci: Migrate MMCONFIG access handling to the new MMIO dispatcher

Register the MMCONFIG memory region, if available, with the generic MMIO
dispatcher and drop the related handler invocation from
pci_mmio_access_handler.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: pci: Drop list of virtual devices
Jan Kiszka [Wed, 5 Aug 2015 09:24:02 +0000 (11:24 +0200)]
core: pci: Drop list of virtual devices

No longer used.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: ivshmem: Migrate to generic MMIO dispatcher
Jan Kiszka [Wed, 5 Aug 2015 09:08:40 +0000 (11:08 +0200)]
core: ivshmem: Migrate to generic MMIO dispatcher

This only migrates the ivshmem parts of the PCI subsystem to the new
MMIO dispatcher, namely its MMIO BAR 0 and the MSI-X BAR 4.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: ivshmem: Move functions unmodified
Jan Kiszka [Mon, 6 Jul 2015 07:20:03 +0000 (09:20 +0200)]
core: ivshmem: Move functions unmodified

We will need ivshmem_write_doorbell, ivshmem_register_mmio and
ivshmem_msix_mmio earlier in the code. Move them up unmodified to
prepare this. No functional change.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Migrate VT-d interrupt remapping emulation to generic MMIO dispatcher
Jan Kiszka [Wed, 5 Aug 2015 08:53:04 +0000 (10:53 +0200)]
x86: Migrate VT-d interrupt remapping emulation to generic MMIO dispatcher

Register the VT-d unit MMIO pages with the dispatcher and drop the
direct handler invocation from vcpu_handle_mmio_access.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Migrate IOAPIC to generic MMIO dispatcher
Jan Kiszka [Wed, 5 Aug 2015 08:46:47 +0000 (10:46 +0200)]
x86: Migrate IOAPIC to generic MMIO dispatcher

Register the IOAPIC MMIO pages with the dispatcher and drop the direct
handler invocation from vcpu_handle_mmio_access.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: ioapic: Move ioapic_access_handler unmodified
Jan Kiszka [Mon, 6 Jul 2015 07:18:14 +0000 (09:18 +0200)]
x86: ioapic: Move ioapic_access_handler unmodified

We will make this function static and then need it earlier in the code.
Move it up unmodified to prepare this. No functional change.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Prepare generic MMIO dispatching
Jan Kiszka [Wed, 5 Aug 2015 08:34:19 +0000 (10:34 +0200)]
x86: Prepare generic MMIO dispatching

Hook up the generic MMIO dispatcher into vcpu_handle_mmio_access without
removing existing handlers. This allows for a step-wise migration of
subsystems to the new dispatcher. Note that the return values of current
handlers are compatible with the mmio_result enum.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: Add generic MMIO access dispatching
Jan Kiszka [Wed, 5 Aug 2015 07:19:08 +0000 (09:19 +0200)]
core: Add generic MMIO access dispatching

This introduces the infrastructure for generically dispatching MMIO
accesses. Handlers can now be registered for MMIO regions on a pre-cell
basis, removing the need for probing multiple handlers that decide
themselves if they are in charge.

The backing data structures consist of two sorted tables: one is
describing the region locations and sizes, the other one is holding, in
identical order, the handler and a corresponding opaque parameter.

Dispatching works lock-free and can even run in parallel with region
registration or removal. That latter two steps are protected against
concurrent invocation via a per-cell spinlock.

In order to preallocate sufficient space during cell setup, arch
architecture has to implement arch_mmio_count_regions that calculates
the maximum number of MMIO regions a cell may register during its
lifetime, typically based on static values and the cell configuration.
So far these functions are implemented as dummies because the MMIO
infrastructure is not yet used.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Remove cpu_data parameters from trap handling paths
Jan Kiszka [Wed, 5 Aug 2015 06:50:01 +0000 (08:50 +0200)]
arm: Remove cpu_data parameters from trap handling paths

Traps handling is always CPU-local, and the cpu_data parameters were
also widely unused already.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Remove cpu_data parameters from MMIO handling paths
Jan Kiszka [Wed, 5 Aug 2015 06:39:04 +0000 (08:39 +0200)]
arm: Remove cpu_data parameters from MMIO handling paths

MMIO handling is always CPU-local, thus there is no point in passing the
per_cpu context around.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm, mmio: Introduce generic mmio_access structure
Jan Kiszka [Wed, 5 Aug 2015 06:04:19 +0000 (08:04 +0200)]
arm, mmio: Introduce generic mmio_access structure

Move ARM's mmio_access structure into the generic MMIO header and polish
it for broader use. It will become the keystone of generic MMIO access
dispatching.

No functional changes, but a lot of variable and field renamings in
order to align ARM in advance with the naming scheme's we will use
throughout the whole core soon.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Rework arch_mmio_access to arm_mmio_perform_access
Jan Kiszka [Wed, 5 Aug 2015 05:42:54 +0000 (07:42 +0200)]
arm: Rework arch_mmio_access to arm_mmio_perform_access

First, this is an ARM-specific function, so "arch" is an improper
prefix. And then we always ignored the return value anyway. Drop it and
instead report unsupported sizes via a printk (a candidate for BUG() if
we ever decide to add that).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: vtd: Use pci_get_assigned_device to look up interrupt invalidation targets
Jan Kiszka [Wed, 29 Jul 2015 07:48:09 +0000 (09:48 +0200)]
x86: vtd: Use pci_get_assigned_device to look up interrupt invalidation targets

Stop using the virtual device list which will be removed eventually and
switch to the pci_get_assigned_device service. It is a bit slower than
the current approach, but we don't consider the emulation of interrupt
invalidation requests as fast path. On the positive side, this change
will allow to simplify the PCI layer a bit.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: Split struct cell into generic and arch-dependent parts
Jan Kiszka [Wed, 8 Jul 2015 04:45:39 +0000 (06:45 +0200)]
core: Split struct cell into generic and arch-dependent parts

ARM already did this, now also introduce this split at top level: move
all arch-specific cell states into the substructure arch_cell. This
refactoring simplifies the management of common cell states across all
architectures.

The common struct cell is now defined in jailhouse/cell.h. From now on,
asm/cell.h shall only be included directly by jailhouse/cell.h.

Generic PCI-related fields are moved into the common structure even
though ARM will not use them. That happens for two reasons:
 - 2 of the 3 fields will be removed soon and the remaining one will be
   negligible
 - ARM is expected to gain PCI support as well one day

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: Rework cleanup on cell destruction
Jan Kiszka [Sun, 28 Jun 2015 16:45:09 +0000 (18:45 +0200)]
core: Rework cleanup on cell destruction

Rename destroy_cpu_set to cell_exit and move it into
cell_destroy_internal. The background is that this function will be used
for more cleanups, and the refactoring will avoid cleanup code
duplications.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Do not call vcpu_cell_exit after failing vcpu_vendor_cell_init
Jan Kiszka [Sun, 9 Aug 2015 19:41:36 +0000 (21:41 +0200)]
x86: Do not call vcpu_cell_exit after failing vcpu_vendor_cell_init

Regression of 328e10028d: vcpu_cell_init does not allocate any
resources prior to calling vcpu_vendor_cell_init. So there is no point
of calling vcpu_cell_exit if the vendor init functions failed, because
the latter is already rolling back. Even worse, the I/O bitmap will not
have been allocated, and vcpu_cell_exit will run into a NULL pointer
dereference.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agotools: add hint how to change kernel cmd line
Dmitry Voytik [Tue, 4 Aug 2015 08:43:03 +0000 (10:43 +0200)]
tools: add hint how to change kernel cmd line

Add hint how to modify kernel command line when memmap reservation
is less than needed.

Signed-off-by: Dmitry Voytik <dmitry.voytik@huawei.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agopci: ivshmem: Use consistent parameter names
Jan Kiszka [Wed, 15 Jul 2015 21:16:20 +0000 (23:16 +0200)]
pci: ivshmem: Use consistent parameter names

We spell out "device" everywhere.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoDocumentation: x86: Move PERCPU_SIZE_SHIFT out of documentation scope
Jan Kiszka [Wed, 15 Jul 2015 20:43:48 +0000 (22:43 +0200)]
Documentation: x86: Move PERCPU_SIZE_SHIFT out of documentation scope

This macro is not part of the per-cpu subsystem interface. Silence the
doxygen warning about lacking documentation. No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoDocumentation: Improve hypercall subsystem description
Jan Kiszka [Wed, 29 Jul 2015 06:37:13 +0000 (08:37 +0200)]
Documentation: Improve hypercall subsystem description

Describe so far undocumented functions and also the communication region
structure.

For the latter, we have to expand the generic COMM_REGION_GENERIC_HEADER
macro during a doxygen run. This is achieved by including the generic
header from within the arch-specific one, but only for doxygen
processing. This special treatment is required because doxygen processes
each file directly, even if it should have been processed indirectly
already (here asm/jailhouse_hypercall.h via jailhouse/hypercall.h).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoDocumentation: Remove obsolete doxygen tags
Jan Kiszka [Wed, 15 Jul 2015 20:36:34 +0000 (22:36 +0200)]
Documentation: Remove obsolete doxygen tags

Reported by doxygen 1.8.9.1, e.g.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agogitignore: Group files according to build vs. tool outputs
Jan Kiszka [Tue, 28 Jul 2015 07:20:21 +0000 (09:20 +0200)]
gitignore: Group files according to build vs. tool outputs

Just the make sure we don't lose overview about the motivation for the
rules.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agogitignore: ignore cscope files
Dmitry Voytik [Mon, 27 Jul 2015 14:54:56 +0000 (16:54 +0200)]
gitignore: ignore cscope files

Signed-off-by: Dmitry Voytik <dmitry.voytik@huawei.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agopci: Verify for non-null pci_dev in pci_claim_release
Veaceslav Falico [Wed, 15 Jul 2015 13:56:12 +0000 (15:56 +0200)]
pci: Verify for non-null pci_dev in pci_claim_release

We might not get a valid pci device from pci_get_slot(), and thus panic:

[   95.167003] RIP: 0010:[<ffffffffa000178f>]  [<ffffffffa000178f>] jailhouse_pci_do_all_devices+0xaf/0x1a0 [jailhouse]
...
[   95.167003]  [<ffffffffa0000363>] jailhouse_cell_delete_all+0x33/0xd0 [jailhouse]
[   95.167003]  [<ffffffffa0000be5>] jailhouse_cmd_disable+0xe5/0x120 [jailhouse]
[   95.167003]  [<ffffffffa00011d5>] jailhouse_ioctl+0x65/0x90 [jailhouse]
...

Fix by verifying for non-null device.

Signed-off-by: Veaceslav Falico <veaceslav.falico@huawei.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agotools: Allow python to reside at different paths
Jan Kiszka [Wed, 15 Jul 2015 05:59:16 +0000 (07:59 +0200)]
tools: Allow python to reside at different paths

This is the more flexible shebang as it allows the interpreter binary to
be located at different paths than just /usr/bin.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Improve reporting of unhandled HYP exits
Jan Kiszka [Tue, 14 Jul 2015 05:32:52 +0000 (07:32 +0200)]
arm: Improve reporting of unhandled HYP exits

Add a simple register dump and unify the reporting format. Specifically
useful to debug hypervisor crashes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore, inmates: Move \r injection into console_write / arch_dbg_write
Jan Kiszka [Tue, 14 Jul 2015 05:16:50 +0000 (07:16 +0200)]
core, inmates: Move \r injection into console_write / arch_dbg_write

This moves the injection of \r on \n into the console_write and
arch_dbg_write implementations, causing some minor duplication but also
fixing injection for %s strings. Furthermore, this allows to skip the
injection for consoles the may not need it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Use more panic_printk for fatal error messages
Jan Kiszka [Tue, 14 Jul 2015 05:29:35 +0000 (07:29 +0200)]
arm: Use more panic_printk for fatal error messages

Fatal errors that will leave CPUs unusable and may occur in parallel on
multiple CPUs should be reported via panic_printk to maintain
readability of the output. Adjust some locations for unexpected HYP
exits and failing PSCI_CPU_OFF.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Unmap virtual GIC on cell destruction
Jan Kiszka [Mon, 13 Jul 2015 07:06:54 +0000 (09:06 +0200)]
arm: Unmap virtual GIC on cell destruction

This fixes a leak on cell destruction because we left the GICv2 mapped,
thus didn't free all paging structures. This also means we need to run
the irqchip cleanup before the cell MMU destruction.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Use paging_create instead of arch_map_memory_region for GICv2 mapping
Jan Kiszka [Mon, 13 Jul 2015 07:05:01 +0000 (09:05 +0200)]
arm: Use paging_create instead of arch_map_memory_region for GICv2 mapping

It's actually simpler to invoke paging_create directly instead of
preparing arguments for arch_map_memory_region first.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Account for errors during irqchip cell_init
Jan Kiszka [Mon, 13 Jul 2015 07:01:51 +0000 (09:01 +0200)]
arm: Account for errors during irqchip cell_init

The cell_init callback of GICv2 should report the result of the mapping
request, thus needs a channel to return an error code. Extend the call
chain accordingly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Fix arm_page_table_empty
Jan Kiszka [Mon, 13 Jul 2015 06:40:52 +0000 (08:40 +0200)]
arm: Fix arm_page_table_empty

The size of a pt_entry_t is a reference to an entry, not the entry type
itself. So we were calculating with an entry size of 4 instead of 8,
overrunning the table during empty checks. This specifically caused
page leakages during cell destruction.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: smp: Remove unused type field from smp_ops
Jan Kiszka [Sun, 12 Jul 2015 09:07:07 +0000 (11:07 +0200)]
arm: smp: Remove unused type field from smp_ops

Was never read and actually initialized incorrectly for sun7i and
tegra124.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: smp: Concentrate non-PSCI logic in Versatile Express module
Jan Kiszka [Sun, 12 Jul 2015 08:25:21 +0000 (10:25 +0200)]
arm: smp: Concentrate non-PSCI logic in Versatile Express module

We only keep the non-PSCI CPU hotplug support around for the sake of
old Versatile Express boards/models. No new boards will be accepted that
do not support the PSCI standard. Therefore, concentrate all functions
that were once considered reusable in the smp-vexpress module, folding
them into their only callers.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Fix comment of switch_exception_level
Jan Kiszka [Sun, 12 Jul 2015 08:24:00 +0000 (10:24 +0200)]
arm: Fix comment of switch_exception_level

The referenced function is actually called setup_mmu_el2.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Move cpu_switch_el2 into calling module
Jan Kiszka [Sun, 12 Jul 2015 08:20:23 +0000 (10:20 +0200)]
arm: Move cpu_switch_el2 into calling module

Uninlined functions should not be defined in headers. No functional
changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Fix coding style of asm blocks
Jan Kiszka [Sun, 12 Jul 2015 08:22:46 +0000 (10:22 +0200)]
arm: Fix coding style of asm blocks

This aligns them with our (kernel) coding style: indent multi-line asm
blocks, end each line with \n\t in multi-line blocks, remove the ending
in single-line statements. No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Fix header_check errors
Jan Kiszka [Wed, 8 Jul 2015 09:02:33 +0000 (11:02 +0200)]
arm: Fix header_check errors

Add missing includes and struct cell forward declaration.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: vmx: Remove some no longer needed includes
Jan Kiszka [Wed, 8 Jul 2015 04:27:49 +0000 (06:27 +0200)]
x86: vmx: Remove some no longer needed includes

These headers no longer contribute anything vmx.c depends on - or never
did at all.

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