]> rtime.felk.cvut.cz Git - jailhouse.git/log
jailhouse.git
8 years agoconfig: Set .debug_console for x86 targets
Jan Kiszka [Tue, 26 Jan 2016 08:24:17 +0000 (09:24 +0100)]
config: Set .debug_console for x86 targets

We will make the debug console UART port configurable via the system
config. Set the corresponding values, they will be ignored so far.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Pull usage check out of vga_write
Jan Kiszka [Sun, 24 Jan 2016 20:28:24 +0000 (21:28 +0100)]
x86: Pull usage check out of vga_write

This makes the code more regular.

Account for the additional contributor at this chance.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Remove redundant typecast
Jan Kiszka [Sun, 24 Jan 2016 20:27:48 +0000 (21:27 +0100)]
x86: Remove redundant typecast

debug_console_base is a void pointer.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Only filter out complete string from KBUILD_AFLAGS
Jan Kiszka [Tue, 26 Jan 2016 07:27:47 +0000 (08:27 +0100)]
arm: Only filter out complete string from KBUILD_AFLAGS

Otherwise we remove those words separately, destroying any
"-include header.h" addition made elsewhere.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore, driver: Pass rounded-up core size in hypervisor header
Jan Kiszka [Mon, 25 Jan 2016 17:20:37 +0000 (18:20 +0100)]
core, driver: Pass rounded-up core size in hypervisor header

Hypervisor and root kernel may have different ideas about PAGE_SIZE.
This will cause wrong hypervisor core size calculations as seen on arm64
with 64K Linux PAGE_SIZE.

Avoid this trap by moving the round-up into the hypervisor code, passing
a ready-to-be-used size value in the header.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoci: Switch to Wily for packages too old in Trusty
Jan Kiszka [Sat, 23 Jan 2016 15:54:38 +0000 (16:54 +0100)]
ci: Switch to Wily for packages too old in Trusty

Vivid is EOL soon, so move on now.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoci: Work around Travis Trusty issue #5326
Jan Kiszka [Fri, 22 Jan 2016 08:52:21 +0000 (09:52 +0100)]
ci: Work around Travis Trusty issue #5326

Current Trusty beta leaves non-system installations of python in the
PATH. Therefore, we fail to find the Mako package during build.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoci: Break the build properly if anything goes wrong
Jan Kiszka [Thu, 21 Jan 2016 18:38:24 +0000 (19:38 +0100)]
ci: Break the build properly if anything goes wrong

If the make failed, we didn't bail out properly so far, leaving false
negatives of test builds behind.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoci: Update build environment to kernel 4.4
Jan Kiszka [Thu, 21 Jan 2016 16:12:12 +0000 (17:12 +0100)]
ci: Update build environment to kernel 4.4

The renovation will be needed when adding arm64 to CI.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoci: Drop COVERITY_SCAN_TOKEN from Travis configuration
Jan Kiszka [Thu, 21 Jan 2016 09:50:31 +0000 (10:50 +0100)]
ci: Drop COVERITY_SCAN_TOKEN from Travis configuration

This is better managed via the Travis CI project settings.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agovga: Add support for VGA text buffer output on x86
Daniel Sangorrin [Thu, 21 Jan 2016 01:31:26 +0000 (10:31 +0900)]
vga: Add support for VGA text buffer output on x86

Hypervisor messages are useful for debugging and are
typically handed out to the serial port. Unfortunately, x86
computers often lack of a serial port. This patch allows
hypervisor messages to be redirected to a screen by leveraging
the traditional VGA text buffer mode.

Signed-off-by: Daniel Sangorrin <daniel.sangorrin@toshiba.co.jp>
[Jan: avoid row_line writeback in panic case, remove redundant braces]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoconsole: rename uart to console
Daniel Sangorrin [Thu, 21 Jan 2016 01:31:25 +0000 (10:31 +0900)]
console: rename uart to console

Jailhouse may support different console devices other than
the UART. For that reason, we adopt a more generic name.

Signed-off-by: Daniel Sangorrin <daniel.sangorrin@toshiba.co.jp>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoconfigs: Update Banana Pi configs to make use of unaligned MMIO regions
Jan Kiszka [Sat, 9 Jan 2016 06:15:59 +0000 (07:15 +0100)]
configs: Update Banana Pi configs to make use of unaligned MMIO regions

Split up the MMIO page 0x1c20000 on the Alwinner A20 into CCU,
interrupts controller, GPIOs and the timer. GPIOs are further broken up
to allow assigning port H to the gic-demo cell, along with the CCU (to
control the UART timing).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: Add support for sub-page MMIO regions
Jan Kiszka [Fri, 8 Jan 2016 18:18:34 +0000 (19:18 +0100)]
core: Add support for sub-page MMIO regions

This allows to specify memory regions for MMIO accesses that do not
start or end on page boundaries. Instead of mapping full pages into the
cell, sub-page MMIO requires to intercept the page accesses, validate
all parameters against the target memory region and then perform the
access in hypervisor context, provided the validation was successful.

As the access can now fail in hypervisor context, we need to be more
picky: besides read/write permissions, alignment and access widths can
be checked additionally. These attributes are specified via the
JAILHOUSE_MEM_IO_* flags.

Sub-page MMIO is surely not a fast path. It not only requires world
switches between cell and hypervisor, the current implementation also
uses dynamic mappings. This is easier to implement than a static mapping
scheme, but surely not faster. We may revisit this design later on,
ideally towards a 1:1 mapping scheme.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: Remove memory regions check
Jan Kiszka [Thu, 7 Jan 2016 17:21:55 +0000 (18:21 +0100)]
core: Remove memory regions check

Most of the checks will be removed when adding sub-page memory region
support. We rather need some offline validation outside the hypervisor
eventually.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: Introduce and use mmio_perform_access
Jan Kiszka [Thu, 7 Jan 2016 17:17:18 +0000 (18:17 +0100)]
core: Introduce and use mmio_perform_access

Generalize arm_mmio_perform_access to mmio_perform_access which can also
be used on other architectures, including those with 64-bit MMIO
support.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoarm: Remove useless warning from arm_mmio_perform_access
Jan Kiszka [Thu, 7 Jan 2016 17:10:20 +0000 (18:10 +0100)]
arm: Remove useless warning from arm_mmio_perform_access

This functions is only called with size 1, 2 or 4. This is ensured by
arch_handle_dabt, the only (indirect) caller, which generates the size
accordingly (1 << sas) and filters out sizes > 4.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore: Introduce and use for_each_mem_region
Jan Kiszka [Tue, 5 Jan 2016 14:40:15 +0000 (15:40 +0100)]
core: Introduce and use for_each_mem_region

This iterator simplifies walking over memory regions in cell and system
configs.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Add support for 32-bit displacement in mod 0
Jan Kiszka [Thu, 7 Jan 2016 08:37:17 +0000 (09:37 +0100)]
x86: Add support for 32-bit displacement in mod 0

Easy enough to add: a 32-bit address displacement follows the ModR/M
byte, and nothing else.

Turned out to be useful while testing with a sub-page HPET memory
region.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoTODO: Update CAT-related item
Jan Kiszka [Fri, 14 Aug 2015 06:34:27 +0000 (08:34 +0200)]
TODO: Update CAT-related item

CAT support is now available, but we should add CDP later on (no
hardware available so far to test it).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoconfigs: Add cache region to x86 demo cells
Jan Kiszka [Tue, 11 Aug 2015 07:20:41 +0000 (09:20 +0200)]
configs: Add cache region to x86 demo cells

Assuming we have more than 4 units of L3 cache on systems that support
L3 partitioning, assign the first 2 units (e.g. 2 MB on a Xeon D 1540)
to apic-demo, the 3rd to tiny-demo. Also the non-root Linux config gets
the first 2 units (it cannot run in parallel to the other demos). All
this is for testing the management logic and will later be used to
benchmark the partitioning.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Introduce Cache Allocation Technology support for Intel CPUs
Jan Kiszka [Tue, 11 Aug 2015 07:05:24 +0000 (09:05 +0200)]
x86: Introduce Cache Allocation Technology support for Intel CPUs

CAT is a CPU feature first added to Xeon D and certain Xeon E5 v3
processors. It so far allows to specify access restrictions to the L3
cache, including complete isolation between different entities.

This adds CAT control to Jailhouse on a per-cell level. The user is free
to specify a contiguous access mask for each cell, use that mask
exclusively (typical case), share any overlaps with the root cell
(JAILHOUSE_CACHE_ROOTSHARED), or simply use the root cell mask. If
nothing else is specified, the root cell uses the full cache (until
non-root cells shrink it).

Due to the hardware-induced requirement to have a contiguous bitmask,
shrinking the root mask on cell creation and extending it again on
destruction is not trivial. Not at all.

When creating a new cell, we may punch a hole into the root mask. In
that case, we also remove the lower half from the roor mask and
accumulate those bits in a "freed mask" for reuse once the hole closes
again. And if we are unlucky, adding a cell empties the current root
mask. Then we have to look into the freed mask and switch to it if it's
non-empty.

When restoring the root mask on cell destruction, we choose a simple
algorithm that first collects all released bits in the freed mask, then
try to merge that mask bit-wise with the current root cell mask. On
success we restart the freed mask walk to ensure that all contiguous
bits are merged.

One may wonder why not reallocating masks completely dynamically and
automatically on each reconfiguration, instead of requiring that
explicit allocation via the config? The reason is that we do not want to
invalidate cache allocations of those cells that are not involved in a
reconfiguration.

A lot of complication with this mechanism which looked so simple on
first sight. Let's just hope that there is a noteworthy benefit in
restricting CAT bitmasks in hardware this way.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agocore, tools: Introduce cache regions to the cell configuration
Jan Kiszka [Tue, 11 Aug 2015 06:58:38 +0000 (08:58 +0200)]
core, tools: Introduce cache regions to the cell configuration

Allow to specify regions of caches so that the hypervisor can partition
their usage accordingly whenever the hardware supports this.

The specification of their start location and sizes depend on the
architecture specific partitioning support. So far, only L3 cache types
are definable, either as unified cached or further partitioned into code
and data (to cater Intel's CAT and CDP). As with memory regions, caches
are usually taken from the root cell on non-root cell creation, but they
can also be declared as shared with the root cell.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: vmx: Block write access to CAT MSRs
Jan Kiszka [Tue, 11 Aug 2015 04:40:53 +0000 (06:40 +0200)]
x86: vmx: Block write access to CAT MSRs

Make sure the cells cannot mess around with them, modifying the
configuration the hypervisor chose.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agox86: Add sub-leaf selection parameter to cpuid_*
Jan Kiszka [Tue, 11 Aug 2015 04:32:15 +0000 (06:32 +0200)]
x86: Add sub-leaf selection parameter to cpuid_*

This allows to call cpuid also on specific sub-leaves. Will be used
first for CAT.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: arm: Make LED blinking in gic-demo optional
Jan Kiszka [Sun, 10 Jan 2016 08:42:43 +0000 (09:42 +0100)]
inmates: arm: Make LED blinking in gic-demo optional

This is both a test/demo case for command line parsing on ARM and a
feature to control the LED signal in the gic-demo on Banana Pi. The
green LED will now only blink if "blinking_led" is specified as inmate
command line option.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: x86: Add optional cache pollution to apic-demo
Jan Kiszka [Mon, 4 Jan 2016 10:31:49 +0000 (11:31 +0100)]
inmates: x86: Add optional cache pollution to apic-demo

When "pollute_cache" is specified as command line parameter of the
apic-demo, the demo will fill each cache line with a pattern in each
measurement loop. Up to 512 KB of cache can be polluted this way.

This allows to test L3 cache partitioning features of recent Intel CPUs:
The cache pollution will dirty the L1 and L2 data caches so that the
next loop iteration will access L3. If that cache is shared, latencies
will rise as other cells use the cache as well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agoinmates: x86: Allow to bypass TSC and APIC timer calibration
Jan Kiszka [Mon, 4 Jan 2016 10:28:08 +0000 (11:28 +0100)]
inmates: x86: Allow to bypass TSC and APIC timer calibration

Make use of the command line feature and introduce the "tsc_freq" and
"apic_freq" parameters. When provided, these values are used directly
instead of running calibrations against the PM timer.

This is particularly useful when running micro-benchmarks that are
sensitive to the inherent small variations of the calibrations.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
8 years agotools: jailhouse: Add support for string loading
Jan Kiszka [Mon, 4 Jan 2016 10:25:09 +0000 (11:25 +0100)]
tools: jailhouse: Add support for string loading

Extend the "cell load" command by a variant where a string provided
along with the command is loaded into the cell memory. This can be used
together with the new command line feature to pass parameters to inmates
that support this.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
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>