]> rtime.felk.cvut.cz Git - jailhouse.git/log
jailhouse.git
9 years agoconfigs: Tune memory regions of H87i
Jan Kiszka [Tue, 22 Jul 2014 19:08:13 +0000 (21:08 +0200)]
configs: Tune memory regions of H87i

ACPI was off by one page, and two regions overlapped, exposing too much
access.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Enable MMCONFIG moderation for QEMU Q35 and H87i
Jan Kiszka [Tue, 22 Jul 2014 12:29:45 +0000 (14:29 +0200)]
configs: Enable MMCONFIG moderation for QEMU Q35 and H87i

Exclude the MMCONFIG regions from memory regions so that Jailhouse can
intercept accesses. Not yet converted is the H700 config.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Increase remapping region size
Jan Kiszka [Tue, 22 Jul 2014 16:57:06 +0000 (18:57 +0200)]
x86: Increase remapping region size

If we have to map the MMCONFIG space of a complete PCI section, we run
out of remapping space. 4 means 128K pages, more than enough for now.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Don't match MMIO accesses if there is no MMCONFIG space
Jan Kiszka [Tue, 22 Jul 2014 16:53:16 +0000 (18:53 +0200)]
core: Don't match MMIO accesses if there is no MMCONFIG space

Without this additional check, we will use addr >= (u64)-1 as upper
boundary if there is no MMCONFIG, which is almost always true.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Fix error handling of MMCONFIG setup
Jan Kiszka [Tue, 22 Jul 2014 16:48:19 +0000 (18:48 +0200)]
core: Fix error handling of MMCONFIG setup

If we have an MMCONFIG region, we must either successfully map it or
fail the initialization. Succeeding without setting up pci_space will
cause crashes later on when accessing it on behalf of a cell.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Enable unwinding from exception handler
Jan Kiszka [Tue, 22 Jul 2014 16:37:40 +0000 (18:37 +0200)]
x86: Enable unwinding from exception handler

Preserve the .eh_frame section for the linked hypervisor objection and
only remove it from the binary. Then add .cfi directives to the
exception entry code. This enables to use a debugger for unwinding from
the exception handler to the causing function and beyond (not perfect
due to missing stack frames, though).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Minimize scope of pci_lock
Jan Kiszka [Mon, 21 Jul 2014 21:03:17 +0000 (23:03 +0200)]
x86: Minimize scope of pci_lock

Move PIO accesses and the related spinlock into data_port_in/out_handler
in order to reduce the lock contention time.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Rework PCI config space access handling
Jan Kiszka [Mon, 21 Jul 2014 18:22:08 +0000 (20:22 +0200)]
core: Rework PCI config space access handling

Move more logic into generic code by extending the write handler to
pci_cfg_write_moderate and introducing pci_cfg_read_moderate. These
handlers are responsible for any config space access, including to
unowned or non-existent devices. They can reject the access, return an
emulated value on read or a real value to be written to hardware, or
they instruct the caller to perform the access directly.

We already pass a reference to the issuing cell to the access handlers.
It stays unused for now but will be needed by succeeding changes. So
add it now to avoid changing API and callers once again later on.

This commit lays the foundation for capability access moderation and,
specifically, MSI/MSI-X emulation.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Reject PCI config space writes to unowned devices
Jan Kiszka [Mon, 21 Jul 2014 18:37:45 +0000 (20:37 +0200)]
x86: Reject PCI config space writes to unowned devices

Align the PIO path with MMIO accesses: We should report any write to a
non-existing or unowned device as failure than silently swallowing it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Clean up PIO bitmaps
Jan Kiszka [Sun, 20 Jul 2014 10:29:08 +0000 (12:29 +0200)]
configs: Clean up PIO bitmaps

Remove unneeded access permissions to PIC1 from all config. DMA and IDE
access is only relevant to QEMU in PIIX2 mode, so drop this from real
machines and the config template. ACPI access is also not needed during
typical operation, nor is it safe.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Simplify config field accessors
Jan Kiszka [Sun, 20 Jul 2014 09:49:53 +0000 (11:49 +0200)]
core: Simplify config field accessors

Express config field accessors by using the accessor of the previous
field. This removes duplicate statements for field sizes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoUpdate TODO list
Jan Kiszka [Tue, 22 Jul 2014 12:29:10 +0000 (14:29 +0200)]
Update TODO list

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Re-park CPU while in wait-for-SIPI state
Jan Kiszka [Wed, 23 Jul 2014 15:49:30 +0000 (17:49 +0200)]
x86: Re-park CPU while in wait-for-SIPI state

We may receive IPIs, e.g. to stop the CPU, while in wait-for-SIPI state.
In this case, we must park the CPU again before leaving
x86_handle_events. Currently, we resume CPU execution erroneously.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: config-create: close output file before exiting from script
Henning Schild [Tue, 15 Jul 2014 11:35:30 +0000 (13:35 +0200)]
tools: config-create: close output file before exiting from script

Maybe not strictly required in that case, but open should always be
followed by close.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: config-create: set default root cell name to RootCell
Henning Schild [Tue, 15 Jul 2014 11:27:17 +0000 (13:27 +0200)]
tools: config-create: set default root cell name to RootCell

The cell name could end up as an empty string because it was derived
from optional input files. In fact just giving the root cell a fixed
default name seems to make more sense than to generate a name or require
users to provide one.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: cell-list: make python3 compatible
Henning Schild [Mon, 21 Jul 2014 14:40:14 +0000 (16:40 +0200)]
tools: cell-list: make python3 compatible

Avoid python2 only functions.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: config-create: refuse to generate config if jailhouse is enabled
Henning Schild [Fri, 11 Jul 2014 14:19:27 +0000 (16:19 +0200)]
tools: config-create: refuse to generate config if jailhouse is enabled

The input files used by the configuration generator might look different
on a system where jailhouse is enabled. Think missing cpus, pci devices etc.
Refuse to work with potentially corrupt input data.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
[Jan: add python2 compatibility]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: config-create: fix cpu counting
Henning Schild [Fri, 11 Jul 2014 12:56:13 +0000 (14:56 +0200)]
tools: config-create: fix cpu counting

Count the number of cpus based on another file to detect offline ones as
well. (cpu*/topology/core_id does not exists for offline cpus)

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Add PCI demo using an Intel HDA
Jan Kiszka [Fri, 18 Jul 2014 08:21:40 +0000 (10:21 +0200)]
inmates: Add PCI demo using an Intel HDA

This demonstrates the setup of a PCI device including MSI.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Add delay_us service to timing library
Jan Kiszka [Sat, 19 Jul 2014 14:05:06 +0000 (16:05 +0200)]
inmates: Add delay_us service to timing library

This performs a busy-wait for the specified microseconds.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Add PCI services to inmates framework
Jan Kiszka [Fri, 18 Jul 2014 07:50:21 +0000 (09:50 +0200)]
inmates: Add PCI services to inmates framework

Provide library services for PCI config space access, bus scanning,
capability scanning (non-extended only so far) and MSI vector
programming (MSI-X to be added later).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Add primitive 32-bit demo
Jan Kiszka [Thu, 17 Jul 2014 19:24:58 +0000 (21:24 +0200)]
inmates: Add primitive 32-bit demo

This only demonstrates the capability to build inmates which come up in
32-bit mode. Note that not all library services support this already.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Halt on return from inmate_main
Jan Kiszka [Thu, 17 Jul 2014 19:21:22 +0000 (21:21 +0200)]
inmates: Halt on return from inmate_main

Remove the need for explicit clt;hlt from the inmates, moving this to
header code.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Add IOAPIC demo
Jan Kiszka [Thu, 17 Jul 2014 18:50:33 +0000 (20:50 +0200)]
inmates: Add IOAPIC demo

Simply demonstration and test for using the IOAPIC within an non-root
cell: Rob the ACPI IRQ and wait for events on this line, e.g. a power
button push. Read the warning before using it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Add IOAPIC service to inmates framework
Jan Kiszka [Thu, 17 Jul 2014 18:30:24 +0000 (20:30 +0200)]
inmates: Add IOAPIC service to inmates framework

This provides the functionality for programing an assigned IOAPIC pin to
send standard IRQs to the caller's CPU. Just enough for basic IOAPIC
usage.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Provide missing PIO accessors
Jan Kiszka [Thu, 17 Jul 2014 18:28:54 +0000 (20:28 +0200)]
inmates: Provide missing PIO accessors

Add inw, outw and outl.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Add memory services to inmates framework
Jan Kiszka [Thu, 17 Jul 2014 15:18:21 +0000 (17:18 +0200)]
inmates: Add memory services to inmates framework

This adds a primitive memory allocator (without release) and a page
mapper (without unmap) to the inmates library. MMIO accessors are also
included. Those used for intercepted resources are encoded in assembly
to ensure that only supported instructions are used. With these
services, inmates can now access memory-mapped devices.

The allocator uses the lower memory starting from the first page.
Document this as well as the remaining memory layout.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Truly terminate apic-demo on second attempt
Jan Kiszka [Wed, 16 Jul 2014 20:07:36 +0000 (22:07 +0200)]
inmates: Truly terminate apic-demo on second attempt

More consistent demo: Reject the first shutdown request and keep running
until the second arrives. Then terminate directly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Factor out timing services
Jan Kiszka [Wed, 16 Jul 2014 19:54:08 +0000 (21:54 +0200)]
inmates: Factor out timing services

Move the APIC timer services together with PM timer access into a timing
library module.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Factor our interrupt library services
Jan Kiszka [Wed, 16 Jul 2014 19:49:25 +0000 (21:49 +0200)]
inmates: Factor our interrupt library services

This simplifies registering interrupt handlers and also moves the EOI
ACK into library code. Only 64-bit support so far. Still, we need to fix
the definition of s64/u64 and make read/write_msr compatible with 32-bit
builds.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Map Comm Region always at 0x100000 for inmates framework
Jan Kiszka [Wed, 16 Jul 2014 11:46:49 +0000 (13:46 +0200)]
inmates: Map Comm Region always at 0x100000 for inmates framework

Standardize mapping and access to the Comm Region within the inmates
framework. Reduces the work to be done for new inmates. We will move it
higher once paging services are available so that larger inmates can be
created.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Refactor folder structure
Jan Kiszka [Wed, 16 Jul 2014 11:05:42 +0000 (13:05 +0200)]
inmates: Refactor folder structure

Move common code into inmates/lib and showcases into a inmates/demos to
prepare for a reusable and extensible inmates framework. Also split
along architecture dependencies, we will get code for non-x86 as well
one day.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Handle more SIB cases in MMIO instruction parser
Jan Kiszka [Mon, 21 Jul 2014 06:48:07 +0000 (08:48 +0200)]
x86: Handle more SIB cases in MMIO instruction parser

This adds, among other things, support for using r12 as address register
in MMIO accesses. And it actually simplifies the code. We can ignore SS
and index in MOD 0 as these only affect the memory address we obtain
differently.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Fix emulated X2APIC ID reading
Jan Kiszka [Fri, 18 Jul 2014 16:30:22 +0000 (18:30 +0200)]
x86: Fix emulated X2APIC ID reading

The xAPIC reports its ID in different bits than the x2APIC. Account for
this when emulating x2APIC accesses by calling the read_id handler.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add support for REX.B to MMIO instruction parser
Jan Kiszka [Thu, 17 Jul 2014 18:48:12 +0000 (20:48 +0200)]
x86: Add support for REX.B to MMIO instruction parser

In none of the supported modes, REX.B is relevant for us because we
obtain the memory address - which it influences by selecting the address
register - differently. Therefore, we can ignore this bit, extending the
set of supported MMIO instructions.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Fix name of sib.base
Jan Kiszka [Thu, 17 Jul 2014 18:47:22 +0000 (20:47 +0200)]
x86: Fix name of sib.base

It's called "base" in the spec.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Fix argument widths of hypercall ABI
Jan Kiszka [Tue, 8 Jul 2014 06:06:21 +0000 (08:06 +0200)]
x86: Fix argument widths of hypercall ABI

The x86 hypercall ABI defined 64-bit arguments and return codes so far.
However, our interface header took and returned only 32 bits. This
slipped through unnoticed because usually no physical addresses beyond
4G are passed to the Cell Create hypercall, the only place where it
practically matters.

Fix the issue and extend the ABI to support also 32-bit callers. We
define hypercall code and return value to be 32 bits, argument width are
now corresponding the the callers mode: 64 bits in IA-32e mode, 32 bits
otherwise. While the root cell still has to be in 64-bit mode, non-root
cells in other modes are now fine to invoke the hypercalls as well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Clear APIC on every SIPI event
Jan Kiszka [Mon, 7 Jul 2014 17:01:00 +0000 (19:01 +0200)]
x86: Clear APIC on every SIPI event

The current logic only ensures that we clear the APIC when the CPU
enters the virtual wait-for-SIPI state. However, this does not cover the
case when we transfer a CPU from the root to a non-root cell. We only
stop the CPU for this, and reset it directly via a pseudo SIPI. This
change moves the clearing to the point where we are about to deliver the
SIPI.

The change has the positive side effect of moving potentially costly
APIC clearing out of the control_lock.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Simplify IPI processing with logical APIC IDs
Jan Kiszka [Mon, 7 Jul 2014 16:11:14 +0000 (18:11 +0200)]
x86: Simplify IPI processing with logical APIC IDs

We now have ffsl available, so we can avoid inverting the mask and
looking for zero bits.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: config-create: include PM timer in root cell config
Henning Schild [Mon, 7 Jul 2014 15:48:51 +0000 (17:48 +0200)]
tools: config-create: include PM timer in root cell config

Add the PM timer to configurations created with jailhouse config create.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: Add configuration generator
Henning Schild [Mon, 7 Jul 2014 10:46:00 +0000 (12:46 +0200)]
tools: Add configuration generator

Adding a helper script to generate a configuration for the root cell.
The script can also generate another script to collect all the necessary
files on a remote machine.
Both scripts can be accessed through the jailhouse command.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Drop Celsius W420
Jan Kiszka [Mon, 7 Jul 2014 10:14:09 +0000 (12:14 +0200)]
configs: Drop Celsius W420

No machine of this type in reach, so we cannot update to recent config
extensions. Also, we will soon focus on auto-generated configs.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoUpdate TODO list
Jan Kiszka [Sun, 6 Jul 2014 20:29:14 +0000 (22:29 +0200)]
Update TODO list

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Add Q35 machine support to QEMU VM
Jan Kiszka [Sun, 6 Jul 2014 14:41:17 +0000 (16:41 +0200)]
configs: Add Q35 machine support to QEMU VM

Add required PCI devices to the QEMU config so that it both works with
the default i440FX and the newer Q35 machine. This is transitional until
Q35 gains VT-d support, then we will drop i440FX bits.

Open the whole 0xC0xx port range for PCI devices to be more tolerant
regarding ordering or other changes.

At this chance, drop the unneeded permission to talk to the first legacy
PIC.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates/configs: Pick up PM timer address from Comm Region
Jan Kiszka [Sun, 6 Jul 2014 09:32:14 +0000 (11:32 +0200)]
inmates/configs: Pick up PM timer address from Comm Region

Instead of probing it, use the information that is now provided via the
Communication Region. This requires to map the region also into the
tiny-demo cell.

We can now drop all explicit port permissions from the inmate's cell
configurations as this is now done automatically by the hypervisor.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Provide PM timer access to all cells
Jan Kiszka [Sun, 6 Jul 2014 09:06:07 +0000 (11:06 +0200)]
x86: Provide PM timer access to all cells

Export the PM timer address via the Communication Region to non-root
cells and allow access to that port for all cells. This is safe as the
PM timer hardware is specified to be read-only.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Specify PM timer addresses
Jan Kiszka [Sun, 6 Jul 2014 09:29:47 +0000 (11:29 +0200)]
configs: Specify PM timer addresses

Specify the location of the PM timer. For QEMU VMs, we already use the
address of upcoming release 2.1.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Allow to specify the PM timer address via the system configuration
Jan Kiszka [Sun, 6 Jul 2014 09:37:48 +0000 (11:37 +0200)]
x86: Allow to specify the PM timer address via the system configuration

This enables the hypervisor to forward the information to non-root cells
and to permit access to the resource. We could also parse the ACPI table
in the hypervisor, but this approach is much simpler.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Drop redundant vmx_invept
Jan Kiszka [Sat, 5 Jul 2014 06:48:59 +0000 (08:48 +0200)]
x86: Drop redundant vmx_invept

No need to call invept also on vmx_cell_init. We already perform this
for all cpus involved in a cell creation (root and new cell cpus) via
arch_config_commit.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Enable RDTSCP for the cells
Jan Kiszka [Mon, 30 Jun 2014 15:01:58 +0000 (17:01 +0200)]
x86: Enable RDTSCP for the cells

If the CPU support RDTSCP, we must enable this feature for cell usage or
they will receive unexpected #UD.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Fix vtd constants
Jan Kiszka [Sun, 29 Jun 2014 10:45:21 +0000 (12:45 +0200)]
x86: Fix vtd constants

Regressions of 9104461829: off-by-one for the CCMD context, and the
IOTLB_IIRG accidentally became the IAIG.

Found by Le Tan via his VT-d emulation prototype for QEMU.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: Add cell statistics viewer
Jan Kiszka [Fri, 20 Jun 2014 23:06:41 +0000 (01:06 +0200)]
tools: Add cell statistics viewer

Add a tool extension to view cell statistics via a basic curses-based
user interface.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: Prepare further command line tool extensions
Jan Kiszka [Fri, 20 Jun 2014 23:05:03 +0000 (01:05 +0200)]
tools: Prepare further command line tool extensions

Allow to add more extension scripts to the command line tool. We define
a structure that describes an extension by command / subcommand and
provides help to be displayed by the tool. The extension script itself
has to be called jailhouse-<command>-<subcommand>. We look for it in
$PATH, extended by the tool's directory and /usr/lib/jailhouse.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agodriver: Export cell statistics via sysfs
Jan Kiszka [Sat, 14 Jun 2014 06:55:18 +0000 (08:55 +0200)]
driver: Export cell statistics via sysfs

Provide an accumulation of per-CPU statistics for each cell via sysfs.
This can help analyzing potential performance issues of Jailhouse cells.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Add support for per-CPU statistics
Jan Kiszka [Sat, 14 Jun 2014 06:52:39 +0000 (08:52 +0200)]
core: Add support for per-CPU statistics

Record VM exits on a per-CPU basis and export this information via the
"CPU Get Info" hypercall.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore/driver: Extend "CPU Get State" to "CPU Get Info" hypercall
Jan Kiszka [Sat, 14 Jun 2014 06:36:57 +0000 (08:36 +0200)]
core/driver: Extend "CPU Get State" to "CPU Get Info" hypercall

Add a second argument to control which per-cpu information shall be
retrieved via JAILHOUSE_HC_CPU_GET_INFO. For now there will only be
JAILHOUSE_CPU_INFO_STATE, providing the original hypercall service.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore/driver: Reintroduce a second hypercall argument
Jan Kiszka [Fri, 13 Jun 2014 18:32:08 +0000 (20:32 +0200)]
core/driver: Reintroduce a second hypercall argument

Now we have the use case: GET_CPU_INFO will take two arguments, so
reintroduce the capability to pass them. But not more. For now.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore/configs/driver: Rename jailhouse_system::system to root_cell
Jan Kiszka [Fri, 13 Jun 2014 13:16:29 +0000 (15:16 +0200)]
core/configs/driver: Rename jailhouse_system::system to root_cell

Now that we have a terminology for the first cell, use it. No functional
change, but local configs will require adjustments.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Clean up jailhouse_system_config_size
Jan Kiszka [Fri, 13 Jun 2014 13:08:27 +0000 (15:08 +0200)]
core: Clean up jailhouse_system_config_size

Instead of open-coding the content of struct jailhouse_system for
calculating its size, simply adjust sizeof(*system) by that part of
system->system that is already included in jailhouse_cell_config_size().
Simplifies future extensions of struct jailhouse_system.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Make PAGE_ALIGN macro robust against complex parameter
Jan Kiszka [Fri, 13 Jun 2014 13:05:39 +0000 (15:05 +0200)]
core: Make PAGE_ALIGN macro robust against complex parameter

Separate the parameter expression from the macro's own calculation.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Make use of IOAPIC moderation
Jan Kiszka [Tue, 3 Jun 2014 09:17:02 +0000 (11:17 +0200)]
configs: Make use of IOAPIC moderation

Remove the IOAPIC page from the memory regions and add the IOAPIC as
irqchip instead.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add support for IOAPIC access control
Jan Kiszka [Mon, 2 Jun 2014 10:17:48 +0000 (12:17 +0200)]
x86: Add support for IOAPIC access control

This adds basic access control to the IOAPIC. Based on the IRQ chip
configuration, we permit or deny writing to redirection table entries.
This may require integration with interrupt remapping later on.

We furthermore allow reads from other valid IOAPIC registers but deny
any other write accesses.

EOI writing is currently passed through. This will have to be revisited
as well when interrupt remapping is added.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add support for Mod 1 to MMIO parser
Jan Kiszka [Tue, 3 Jun 2014 08:25:50 +0000 (10:25 +0200)]
x86: Add support for Mod 1 to MMIO parser

The only difference to Mod 2 is the length of the displacement: 1
instead of 4 bytes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore/configs: Change IRQ line access control modeling
Jan Kiszka [Mon, 2 Jun 2014 10:11:27 +0000 (12:11 +0200)]
core/configs: Change IRQ line access control modeling

Change the configuration file to manage access to IRQ lines at IRQ chip
level. Each IRQ chip config entry consists an address, typically the
chip's MMIO address, a unique identifier that will be used for interrupt
remapping on x86, and a bitmap controlling access to individual IRQ pins
of that chip. This will simplify access control checks to IRQ chips.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Park a CPU when a VM entry failed
Jan Kiszka [Wed, 11 Jun 2014 17:31:16 +0000 (19:31 +0200)]
x86: Park a CPU when a VM entry failed

Do not give up a CPU if only VM entry failed. For whatever reason, we
may have loaded an invalid CPU state from which we can still recover by
resetting the virtual CPU. This also simplifies the exit handling.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Clean up vtd_init_fault_nmi, vtd_check_pending_faults and related MSI constants
Jan Kiszka [Sat, 7 Jun 2014 11:43:08 +0000 (13:43 +0200)]
x86: Clean up vtd_init_fault_nmi, vtd_check_pending_faults and related MSI constants

Coding style fixes and clarifications of the comments. No functional
changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Avoid warning on passing volatile pointers to page_map_hvirt2phys
Jan Kiszka [Sat, 7 Jun 2014 09:43:44 +0000 (11:43 +0200)]
core: Avoid warning on passing volatile pointers to page_map_hvirt2phys

This allows to swallow every pointer type without explicit casts.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Extend vtd_init_fault_reporting to vtd_init_unit
Jan Kiszka [Sat, 7 Jun 2014 08:19:20 +0000 (10:19 +0200)]
x86: Extend vtd_init_fault_reporting to vtd_init_unit

Move the root table pointer setup from vtd_config_commit. More logic
will be added later.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Clean up vtd_init_fault_reporting
Jan Kiszka [Sat, 7 Jun 2014 06:47:23 +0000 (08:47 +0200)]
x86: Clean up vtd_init_fault_reporting

Remove the unneeded return code, compact the code and do some style
cleanups.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Drop redundant call to vtd_init_fault_nmi
Jan Kiszka [Sat, 7 Jun 2014 06:40:42 +0000 (08:40 +0200)]
x86: Drop redundant call to vtd_init_fault_nmi

We already call this at the end of vtd_init via root cell
initialization.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Refactor vtd constant definitions
Jan Kiszka [Fri, 6 Jun 2014 07:05:11 +0000 (09:05 +0200)]
x86: Refactor vtd constant definitions

Make use of BIT_MASK and refactor the constant definitions used for vtd
into a consistent form that is more easily verifiable against the spec.
Drop some unused constants.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Simplify vtd_get_fault_rec_reg_addr
Jan Kiszka [Fri, 6 Jun 2014 06:47:49 +0000 (08:47 +0200)]
x86: Simplify vtd_get_fault_rec_reg_addr

The logic remains readable when written in a single statement.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Generic memory region mapping for cell creation with rollback on errors
Jan Kiszka [Thu, 5 Jun 2014 14:42:36 +0000 (16:42 +0200)]
core: Generic memory region mapping for cell creation with rollback on errors

Pull the memory region mappings that currently happen in vmx and vtd
into generic code paths. This allows us to properly roll back on errors
during cell creation.

We now perform the arch-specific cell initialization first, then
transfer CPUs and finally remap the memory regions. For the rollback, we
can simply use the infrastructure available for cell destruction, both
at generic level as well as inside vmx/vtd.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Pull root cell initialization into vmx/vtd_init
Jan Kiszka [Fri, 6 Jun 2014 12:38:10 +0000 (14:38 +0200)]
x86: Pull root cell initialization into vmx/vtd_init

Provides a micro-simplification regarding error handling and belongs
together conceptually anyway.

Some constant name shortening is required to avoid line wrappings.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Do not flush hypervisor TLB on unrelated page table changes
Jan Kiszka [Sun, 15 Jun 2014 05:35:26 +0000 (07:35 +0200)]
core: Do not flush hypervisor TLB on unrelated page table changes

Only when working against the hypervisor page table in page_map_create
and page_map_destroy, we actually need to flush TLBs. Other page tables
require arch-specific flushings that we perform on arch_config_commit.

This measurably speeds up Jailhouse activation, e.g., when a significant
number of EPT and VT-d page table changes are performed.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Drop TLB flushes on cell configuration changes
Jan Kiszka [Sun, 15 Jun 2014 05:17:42 +0000 (07:17 +0200)]
x86: Drop TLB flushes on cell configuration changes

The host TLB only requires flushing on hypervisor page table changes.
These only happen on the CPU that performs guest configurations changes
and only for mapping regions that are per-CPU. This is already handled
by flushes in page_map_create/destroy.

Hypervisor page mappings that are relevant for all CPUs are created
during setup. This is done on the setup master CPU before any other CPU
is initializing and flushing its caches by switching to the hypervisor
page table.

So we can drop x86_tlb_flush_all altogether. Rename the flush_caches
flag to flush_virt_caches to reflect that we only request guest-to-host
cache invalidations.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Introduce arch_config_commit
Jan Kiszka [Fri, 6 Jun 2014 09:08:03 +0000 (11:08 +0200)]
core: Introduce arch_config_commit

This function allows us to consistently flush affected caches after
configuration changes. We did this after cell creation, partially did it
after destruction, but forgot about it on load/start. Flushing is now
extended to the CPU performing the changes as well as all CPUs of a
created or destroyed cell.

This change also enables the split-up of IOMMU activation and related
root cell and memory region mapping setup, a precondition for generic
memory region mapping.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Remove some unneeded local caching of cell->config
Jan Kiszka [Thu, 5 Jun 2014 15:04:28 +0000 (17:04 +0200)]
x86: Remove some unneeded local caching of cell->config

No hot-paths, we can save the local variables.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Guard vtd_add_device_to_cell against addition of existing devices
Jan Kiszka [Thu, 5 Jun 2014 14:36:42 +0000 (16:36 +0200)]
x86: Guard vtd_add_device_to_cell against addition of existing devices

Avoid that we add an already registered device to a cell, specifically
that we report this to the console. This case can happen soon when
rolling back failed cell creations.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Factor out cell_destroy_internal
Jan Kiszka [Thu, 5 Jun 2014 14:18:28 +0000 (16:18 +0200)]
core: Factor out cell_destroy_internal

We will reuse it to roll back failed cell creations.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Replace shrinking_set with root_cell.cpu_set in cell_create
Jan Kiszka [Thu, 5 Jun 2014 14:09:10 +0000 (16:09 +0200)]
core: Replace shrinking_set with root_cell.cpu_set in cell_create

Let's make it clear: the set we shrink is always the one of the root cell.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore/configs: Clean up config structure alignment/packing
Jan Kiszka [Thu, 5 Jun 2014 16:25:39 +0000 (18:25 +0200)]
core/configs: Clean up config structure alignment/packing

Instead of spreading aligned(1), we rather need to pack all config
structures and also the containers we define in the config files
themselves. Clean this up, also dropping the now unneeded padding from
jailhouse_cell_desc.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Fold vmx/vtd_root_cell_shrink into vmx/vtd_cell_init
Jan Kiszka [Fri, 6 Jun 2014 14:19:39 +0000 (16:19 +0200)]
x86: Fold vmx/vtd_root_cell_shrink into vmx/vtd_cell_init

This primarily fixes a regression of 46ab6c2f1e: Due to that reordering,
we were first adding devices to a new cell, then removing them from the
root cell which effectively disabled them in the context table.

Analyzing the content of vmx/vtd_root_cell_shrink, we are better off
folding them into the corresponding cell_init functions. We fix the
ordering issue while doing this.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Move vtd_remove_device_from_cell
Jan Kiszka [Fri, 6 Jun 2014 15:20:58 +0000 (17:20 +0200)]
x86: Move vtd_remove_device_from_cell

Move vtd_remove_device_from_cell unmodified. We will need it earlier.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Make vtd_remove_device_from_cell more robust against non-existent devices
Jan Kiszka [Fri, 6 Jun 2014 16:58:53 +0000 (18:58 +0200)]
x86: Make vtd_remove_device_from_cell more robust against non-existent devices

Do not crash if we call vtd_remove_device_from_cell for a device that is
not added to a cell, and there is even no corresponding context table.
This allows to use vtd_remove_device_from_cell e.g. for rollbacks of
half-done configurations after an error occurred.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Rework evaluation of MSR_IA32_VMX_TRUE_*_CTLS
Jan Kiszka [Sat, 14 Jun 2014 07:36:08 +0000 (09:36 +0200)]
x86: Rework evaluation of MSR_IA32_VMX_TRUE_*_CTLS

The SDM recommends to keep default1-class controls enabled if they are
unknown to the VMM. This applies to most of those bits. Even worse, by
using the TRUE_*_CTLS, we kept DEBUG_CONTROLS saving/loading disabled on
most machines, corrupting the related states on vmexit.

Switch to the "untrue" capability MSRs, except for CR3 loading/storing,
which will ensure that default1 bits are kept enabled also on future
CPUs.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Properly clear IA32_DEBUGCTL on VMCS setup and reset
Jan Kiszka [Thu, 12 Jun 2014 08:24:48 +0000 (10:24 +0200)]
x86: Properly clear IA32_DEBUGCTL on VMCS setup and reset

We do not migrate this MSR, but we should at least clear it to avoid any
undefined behavior.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Fix VT-d fault NMI programming for x2APIC mode
Jan Kiszka [Sat, 7 Jun 2014 11:41:11 +0000 (13:41 +0200)]
x86: Fix VT-d fault NMI programming for x2APIC mode

Bits 7:0 of the upper address register must be zero.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Add BIT_MASK macro and document BYTE_MASK
Jan Kiszka [Fri, 6 Jun 2014 06:07:01 +0000 (08:07 +0200)]
core: Add BIT_MASK macro and document BYTE_MASK

BIT_MASK will help defining constants according to hardware
specifications when bits [m:n] (m > n) form a field in a register or
data structure entry. Document also the BYTE_MASK macro at this chance.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Fix reading of vtd fault-recording register offset
Jan Kiszka [Fri, 6 Jun 2014 06:38:41 +0000 (08:38 +0200)]
x86: Fix reading of vtd fault-recording register offset

The capability register is 64 bit wide.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Drop root_cell argument from arch_init_early/late
Jan Kiszka [Tue, 3 Jun 2014 14:09:16 +0000 (16:09 +0200)]
core: Drop root_cell argument from arch_init_early/late

root_cell is already globally available, no need to pass it around.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Report details on string/REP-prefixed PIO access
Jan Kiszka [Wed, 4 Jun 2014 06:45:46 +0000 (08:45 +0200)]
x86: Report details on string/REP-prefixed PIO access

Do not just silently return an error code without telling the user what
kind of vmexit handling just failed.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Report APIC access on MMIO parsing error
Jan Kiszka [Wed, 4 Jun 2014 06:43:57 +0000 (08:43 +0200)]
x86: Report APIC access on MMIO parsing error

This ensures that the context of the MMIO access is clear.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Further improve EPT error reporting
Jan Kiszka [Mon, 2 Jun 2014 10:09:53 +0000 (12:09 +0200)]
x86: Further improve EPT error reporting

Avoid double error reporting in vmx_handle_ept_violation if an access
handler already did this. Also correct the access direction message, it
was inverted.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Provide details on PCI MMCONFIG access violations
Jan Kiszka [Mon, 2 Jun 2014 09:57:21 +0000 (11:57 +0200)]
core: Provide details on PCI MMCONFIG access violations

Support the user in parsing MMCONFIG write rejections by decoding the
BDF and providing the accesses register number.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoTODO: Update and detail list
Jan Kiszka [Mon, 2 Jun 2014 09:13:45 +0000 (11:13 +0200)]
TODO: Update and detail list

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agodoc: update README
Henning Schild [Wed, 28 May 2014 11:44:52 +0000 (13:44 +0200)]
doc: update README

The README had one line where the old jailhouse syntax was still used,
update it to the new syntax.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Avoid crashes under QEMU due to missing DMAR units
Jan Kiszka [Tue, 3 Jun 2014 15:38:20 +0000 (17:38 +0200)]
x86: Avoid crashes under QEMU due to missing DMAR units

Make sure we do not crash in the hypervisor when adding or removing
cells with PCI devices under QEMU. These hacks will be removed once
emulated VT-d is available.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
10 years agox86: Improve reporting of EPT violations
Jan Kiszka [Wed, 14 May 2014 09:40:10 +0000 (11:40 +0200)]
x86: Improve reporting of EPT violations

Report details about the EPT violation also when the MMIO parser fails.
At this chance, remove the term "EPT" from the print-out. This is an
invalid MMIO or RAM access.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
10 years agox86: Fix assembly constraints of write_gdtr/idtr
Jan Kiszka [Wed, 14 May 2014 09:14:04 +0000 (11:14 +0200)]
x86: Fix assembly constraints of write_gdtr/idtr

Copy & paste mistake: write_gdtr and write_idtr do not return anything
in descriptor table structure, they read from it. This broke the
hypervisor setup with certain optimizing compilers, noticed in
particular with old gcc 4.4.

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