]> rtime.felk.cvut.cz Git - jailhouse.git/log
jailhouse.git
9 years agotools: config-create: drop line numbers in parse_iomem_tree()
Benjamin Block [Fri, 7 Nov 2014 17:57:10 +0000 (18:57 +0100)]
tools: config-create: drop line numbers in parse_iomem_tree()

Previously we defined the children of a MemRegion-Tree as set. This
caused the order of the children to be undefined as soon as they got
added to this structure. But the using function of parse_iomem_tree()
wanted the list of regions returned to be sorted like in the file, so we
had to maintain a separate list of line numbers.

By changing the set to a list, the order is always maintained and
because parse_iomem_tree() only adds to his private regions-list and
never inserts or reorders, this private structure will also always have
the same order as in the file. With this we can remove the
line numbers list. This structure was never use for anything else, so it
will make the code more readable.

Signed-off-by: Benjamin Block <bebl@mageta.org>
Reviewed-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoTODO: add an item for potential inter-cell information leaking
Henning Schild [Fri, 7 Nov 2014 14:06:07 +0000 (15:06 +0100)]
TODO: add an item for potential inter-cell information leaking

as discussed on the list
http://article.gmane.org/gmane.linux.jailhouse/1922

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoREADME: Trivial adjustment to new hypervisor binary file names
Jan Kiszka [Fri, 7 Nov 2014 14:03:43 +0000 (15:03 +0100)]
README: Trivial adjustment to new hypervisor binary file names

There is now jailhouse.bin, jailhouse-intel.bin and jailhouse-amd.bin...

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: pci: include feature check in capability lookup
Henning Schild [Fri, 7 Nov 2014 13:46:02 +0000 (14:46 +0100)]
inmates: pci: include feature check in capability lookup

Do not look for pci capabilites in devices that do not support them.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Explicit %rax for SVM instructions
Valentine Sinitsyn [Thu, 6 Nov 2014 11:54:05 +0000 (16:54 +0500)]
x86: Explicit %rax for SVM instructions

vmload, vmsave and vmrun use %rax implicitly, but to make Clang happy,
it needs to be part of the mnemonic.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Eliminate dead code in vcpu_activate_vmm()
Valentine Sinitsyn [Thu, 6 Nov 2014 11:54:04 +0000 (16:54 +0500)]
x86: Eliminate dead code in vcpu_activate_vmm()

There is no point in clearing host-side MSRs in vcpu_activate_vmm()
(svm.c version), as they get restored as soon as vmload is executed
few lines below.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates/x86: Initialize jailhouse_use_vmcall
Valentine Sinitsyn [Thu, 6 Nov 2014 11:54:03 +0000 (16:54 +0500)]
inmates/x86: Initialize jailhouse_use_vmcall

Jailhouse relies on the caller to define and initialize jailhouse_use_vmcall
global variable for hypercalls to work properly. As no inmates currently use
hypercalls, the code was stripped from the original patch.

This patch re-introduces jailhouse_use_vmcall initialization, this time with
hypercall_init() function, which should be called during inmate initialization
the same way other *_init() function are called. This way, inmates that don't
need hypercalls (or timers) can skip initializing them.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Adjust some indentions after vcpu/iommu refactorings
Jan Kiszka [Thu, 6 Nov 2014 20:13:43 +0000 (21:13 +0100)]
x86: Adjust some indentions after vcpu/iommu refactorings

No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Factor out config_commit
Jan Kiszka [Sat, 11 Oct 2014 07:14:58 +0000 (09:14 +0200)]
core: Factor out config_commit

Factor out the generic part of x86's arch_config_commit into
config_commit so that we don't need to replicate it into other archs.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Remove cpu_data parameter from vmx_set_cell_config
Jan Kiszka [Wed, 5 Nov 2014 08:27:33 +0000 (09:27 +0100)]
x86: Remove cpu_data parameter from vmx_set_cell_config

As a consequence, this allows to remove it also from vmx_vcpu_reset. All
functions always work against the invoking CPU.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Privatize names of static vendor-specific functions
Jan Kiszka [Wed, 5 Nov 2014 08:18:29 +0000 (09:18 +0100)]
x86: Privatize names of static vendor-specific functions

vcpu_set_cell_config, vcpu_reset, vcpu_vendor_get_io_intercept and
vcpu_vendor_get_pf_intercept - they share the same parameters across the
vendor-specific implementations, but they are invoked only locally. So
rename them to something which is prefixed by vmx and svm, respectively,
so that they can be locally refactored as desired with risking confusion
that they might have to usable in a cross-vendor fashion.

CC: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Remove cpu_data parameter from interrupt handling path
Jan Kiszka [Sat, 23 Aug 2014 14:04:20 +0000 (16:04 +0200)]
x86: Remove cpu_data parameter from interrupt handling path

We can obtain a reference on demand now.

CC: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Remove debug output from SVM NMI handler
Jan Kiszka [Wed, 5 Nov 2014 08:05:46 +0000 (09:05 +0100)]
x86: Remove debug output from SVM NMI handler

This message no longer provides valuable information as the related code
path is stable now.

CC: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Remove unused cpu_data argument from vmx_entry_failure
Jan Kiszka [Sat, 23 Aug 2014 13:51:52 +0000 (15:51 +0200)]
x86: Remove unused cpu_data argument from vmx_entry_failure

panic_stop no longer requires it, so it became useless.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Rename vcpu_entry_failure back to vmx_entry_failure
Jan Kiszka [Wed, 5 Nov 2014 07:51:57 +0000 (08:51 +0100)]
x86: Rename vcpu_entry_failure back to vmx_entry_failure

This function is only used for VMX, so move it to the proper namespace.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Move mmio_parse and struct mmio_instruction into arch header
Jan Kiszka [Wed, 1 Oct 2014 15:51:57 +0000 (17:51 +0200)]
core: Move mmio_parse and struct mmio_instruction into arch header

There will be no need for and implementation of this service outside of
x86 in the foreseeable future. So make it arch-private until we have
more users.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Refactor struct mmio_access to mmio_instruction
Jan Kiszka [Wed, 1 Oct 2014 15:33:49 +0000 (17:33 +0200)]
core: Refactor struct mmio_access to mmio_instruction

The current mmio_access rather contains information about the accessing
instruction. ARM's mmio_access will hold data about the actual access.
To clarify the meaning and free the namespace, rework the preexisting
struct to mmio_instruction.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Move cpu_suspended setting into arch_panic_stop
Jan Kiszka [Mon, 29 Sep 2014 12:00:31 +0000 (14:00 +0200)]
core: Move cpu_suspended setting into arch_panic_stop

cpu_suspended is an x86-specific control, nothing every arch needs to
provide. Leave it up to the arch how to set the CPU's state on panic.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: vtd: Drop bogus checks in iommu_get_remapped_root_int
Jan Kiszka [Thu, 6 Nov 2014 19:32:23 +0000 (20:32 +0100)]
x86: vtd: Drop bogus checks in iommu_get_remapped_root_int

These checks make no sense: At this stage, we actually don't care if
there is a corresponding entry in the hypervisor remapping table for the
device. And the check of the vector number is actually comparing apples
(hypervisor-side base_index) to onions (guest-side irt_entries).
Finally, the tuple of device_id and vector stored in this function will
be validated by iommu_map_interrupt before use in case it gets forwarded
to it.

So drop this code. This will also make the function directly usable for
virtual devices that have no corresponding entry in the hypervisor's
interrupt remapping table.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Clarify usage constraints of strcmp
Jan Kiszka [Thu, 6 Nov 2014 16:25:27 +0000 (17:25 +0100)]
core: Clarify usage constraints of strcmp

Using strcmp quickly attracts the attention of reviews: Is this really
safe regarding buffer overflows? It is, but that's not obvious. So
document what enables the safe usage of strcmp in this case.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore/tools: Protect result of ARRAY_SIZE
Jan Kiszka [Thu, 6 Nov 2014 16:00:10 +0000 (17:00 +0100)]
core/tools: Protect result of ARRAY_SIZE

Prevent any operator prioritization issues when embedding ARRAY_SIZE
into an expression by protecting the result with braces. This is a
defensive measure, no current user was affected by it.

Do not convert all the generated or copy&pasted ARRAY_SIZE defines in
the config files as long as they are not affected by the issue.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoscripts: Fix types include in header_check
Jan Kiszka [Sat, 1 Nov 2014 18:59:32 +0000 (19:59 +0100)]
scripts: Fix types include in header_check

Since 0006f1a3be, it is necessary to include jailhouse/types.h instead
of the asm header.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoDocumentation: Update README and other resources
Valentine Sinitsyn [Sun, 28 Sep 2014 08:02:41 +0000 (14:02 +0600)]
Documentation: Update README and other resources

Outline Jailhouse AMD-V system requirements and nested SVM setup instructions
in the qemu-vm.cell config and README file. As Linux 3.17 is already released,
reflect this in aforementioned files as well.

Also remove "AMD-V support" item from the TODO list and add AMD IOMMU to it.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
[Jan: raise host-kernel requirement to 3.18 for AMD]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Add Gigabyte GA-F2A88XM-HD3 board config
Valentine Sinitsyn [Tue, 23 Sep 2014 16:18:18 +0000 (22:18 +0600)]
configs: Add Gigabyte GA-F2A88XM-HD3 board config

Add a config file for another AMD-based board which can be used
to test Jailhouse AMD-V port.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Add IMB-A180 G-Series board
Valentine Sinitsyn [Wed, 3 Sep 2014 13:55:25 +0000 (19:55 +0600)]
configs: Add IMB-A180 G-Series board

Add a configuration for AMD-based ASRock IMB-A180 G-series board.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Map ACPI PM1a_* to ioapic-demo cell
Valentine Sinitsyn [Wed, 3 Sep 2014 13:43:32 +0000 (19:43 +0600)]
configs: Map ACPI PM1a_* to ioapic-demo cell

Extend the range of I/O ports mapped to ioapic-demo cell,
as it may be referenced on some AMD-based G-Series boards.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Rudimentary guest MTRR emulation support
Valentine Sinitsyn [Tue, 23 Sep 2014 16:09:18 +0000 (22:09 +0600)]
x86: Rudimentary guest MTRR emulation support

Implemented rough MTRR Enable bit (MTRR defType) emulation. This is
required for Linux CPU bootstrapping code to work properly, and fixes
a CPU lockup bug that occurs when destroying a cell on some AMD boards.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Make use of VMCB clean bits
Valentine Sinitsyn [Tue, 5 Aug 2014 18:51:01 +0000 (00:51 +0600)]
x86: Make use of VMCB clean bits

After a cell is created, Jailhouse doesn't change its VMCB much.
This means VMCB Clean Bits (APMv2, Sect. 15.15.1) have a good
potential to reduce a world switch time.

This commit introduces VMCB Clean Bits support in Jailhouse. On each
VM exit, VMCB is marked as clean (unmodified), and each function that
changes guest state in VMCB is responsible for clearing the bit.

This is an optional feature, however it is cheap and harmless even
on CPUs that don't support it. So we use it unconditionally: CPUs
that do not support VMCB State Caching will simply ignore this.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Implement vcpu_park() for AMD-V CPUs
Valentine Sinitsyn [Sun, 22 Jun 2014 09:08:40 +0000 (15:08 +0600)]
x86: Implement vcpu_park() for AMD-V CPUs

When a CPU is parked, it is halted in guest mode with interrupts off. This way,
only NMI sent from the hypervisor can "unpark" the CPU to run another cell.

AMD-V provides no VMX guest activity states equivalent, thus there is no easy way
to halt a CPU in guest mode waiting for NMI. To overcome this, when a CPU is parked,
its memory is temporarily switched to shared "parked mode NPT" which contains
"parking code" (cli; hlt) mapped at the Jailhouse custom reset vector (0xffff0).
The guest is directed to continue at this address. When NMI occurs, vcpu_reset()
restores original NPTs.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Implement vcpu_[de]activate_vmm() for AMD-V
Valentine Sinitsyn [Wed, 4 Jun 2014 18:31:12 +0000 (00:31 +0600)]
x86: Implement vcpu_[de]activate_vmm() for AMD-V

Compared to VMX, vcpu_activate_vmm() and vcpu_deativate_vmm() for AMD-V
systems have several notable differences.

First, additional MSRs (part of VMCB but not VMCS) need to be set and
restored. Then, host state area is opaque in AMD-V, so vcpu_activate_vmm()
remembers host stack pointer and essentially begins a VMRUN/#VMEXIT loop
implemented in svm-vmexit.S. Third, as RAX register is part of VMCB, it is
copied to guest_regs on each VM exit and written back before VM entry.

As Jailhouse runs with GIF set, it needs to be cleared on VMM deactivation.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Intercept guest XSETBV instruction in AMD-V
Valentine Sinitsyn [Sun, 28 Sep 2014 12:35:46 +0000 (18:35 +0600)]
x86: Intercept guest XSETBV instruction in AMD-V

This adds XSETBV instruction emulation. The code is almost the same as in
VMX, and is barely tested as the instruction is rarely used in real-world
scenarios.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add AMD-V handler for guests CR0 access
Valentine Sinitsyn [Sun, 28 Sep 2014 12:34:20 +0000 (18:34 +0600)]
x86: Add AMD-V handler for guests CR0 access

Guest CR0 writes are intercepted if they change bits other than CR0.TS
or CR0.MP. The main purpose for this is to activate Long mode for
Jailhouse cells. As Decode Assists are optional in Jailhouse, if they
are not present the instruction is decoded manually. All current Jailhouse
inmates are first changing CR0 while they are in real mode, so having
real mode support in vcpu_get_guest_paging_structs() is essential.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Implement AMD-V NMI handler and CPU reset
Valentine Sinitsyn [Sun, 28 Sep 2014 12:33:08 +0000 (18:33 +0600)]
x86: Implement AMD-V NMI handler and CPU reset

NMIs originate from the hypervisor which uses them to manage cells. As a part
of this management task, the CPU can be reset. This is performed in vcpu_reset().

Jailhouse runs with GIF set, and it needs to be cleared shortly to let the CPU
to consume pending interrupt and allow further NMIs trigger VM exits. Otherwise,
current NMI would be delivered to the guest on the next VM entry.

NMI can trigger in host mode only if Jailhouse explicitly clears the GIF to
consume the pending interrupt. There is nothing to handle in this case, so
vcpu_nmi_handler() simply prints a message that the NMI was consumed.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add AMD-V port-based I/O VM exit handler
Valentine Sinitsyn [Sun, 28 Sep 2014 12:30:40 +0000 (18:30 +0600)]
x86: Add AMD-V port-based I/O VM exit handler

This is just the same as NPF handler: all real work is done in
vcpu_handle_io_access().

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add generic NPF handler for AMD-V code
Valentine Sinitsyn [Sun, 28 Sep 2014 12:29:09 +0000 (18:29 +0600)]
x86: Add generic NPF handler for AMD-V code

This completes Nested Page Fault handler introduced in the previous commit
with generic NPF handling route. The actual handling code is shared between
VMX and SVM, so we simply need to call vcpu_handle_pt_violation() and
implement the appropriate data wrapper.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Trap xAPIC register writes under AMD-V
Valentine Sinitsyn [Sun, 28 Sep 2014 12:13:12 +0000 (18:13 +0600)]
x86: Trap xAPIC register writes under AMD-V

Jailhouse maps APIC MMIO page to cells read-only, so it only needs to handle
register writes, which are translated to Nested Page Faults. The real work is
delegated to generic apic_mmio_access(), which requires guest page tables to
work. These are obtained with vcpu_get_guest_paging_structs(), which supports
real mode cells as well.

As there is no AVIC support for any known AMD hardware, AVIC-related VM exits
are nor intercepted neither handled in Jailhouse.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Trap MSR access for AMD-V cells
Valentine Sinitsyn [Sun, 28 Sep 2014 09:00:00 +0000 (15:00 +0600)]
x86: Trap MSR access for AMD-V cells

Jailhouse traps read and write MSR access for two main purposes:

 * Emulating x2APIC on xAPIC-only hardware (all real-world AMD CPUs)
 * Preventing cells from clearing EFER.SVME bit

In the latter case, TLB also needs to be flushed.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add AMD-V hypercall handler
Valentine Sinitsyn [Sun, 28 Sep 2014 08:44:47 +0000 (14:44 +0600)]
x86: Add AMD-V hypercall handler

Provide a way for guests to call into Jailhouse on AMD-V systems. Real work
is delegated to generic vcpu_handle_hypercall() handler.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Implement vcpu_get_guest_bytes() for AMD-V
Valentine Sinitsyn [Sun, 28 Sep 2014 12:15:41 +0000 (18:15 +0600)]
x86: Implement vcpu_get_guest_bytes() for AMD-V

mmio_parse() can use accelerated guest memory access function, if the one
is provided in vendor-specific code. If Decode Assists are available on a
given CPU, we can avoid a costly page table walk and read guest instruction
directly from VMCB. However, since Decode Assists are optional as they may
not be advertised in nested SVM setup, a fallback route is provided as well.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add vcpu_skip_emulated_instruction() for AMD-V
Valentine Sinitsyn [Sun, 28 Sep 2014 08:54:18 +0000 (14:54 +0600)]
x86: Add vcpu_skip_emulated_instruction() for AMD-V

Many VM exit handlers need a way to skip the instruction they emulated.
Add vcpu_skip_emulated_instruction() that does this for AMD-V guests.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add vcpu_handle_exit() function for AMD-V
Valentine Sinitsyn [Sun, 28 Sep 2014 08:19:53 +0000 (14:19 +0600)]
x86: Add vcpu_handle_exit() function for AMD-V

Add the infrastructure required to handle VM exits. It is mostly boilerplate
code in its current state, and any VM exit will cause a CPU to dump registers
and halt.

Appropriate handlers are added in subsequent commits.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add AMD-V cell initialization/exit code
Valentine Sinitsyn [Tue, 27 May 2014 18:21:30 +0000 (00:21 +0600)]
x86: Add AMD-V cell initialization/exit code

AMD-V vendor-specific parts of vcpu_cell_init() and vcpu_cell_exit() are
implemented.

On startup, if AVIC is not available (which is usually the case) APIC is
mapped to cells read-only so only register writes are trapped and emulated.

On cell exits, the mapping is destroyed.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add AMD-V memory management functions
Valentine Sinitsyn [Fri, 26 Sep 2014 16:35:12 +0000 (22:35 +0600)]
x86: Add AMD-V memory management functions

Implemented functions to map and unmap memory regions in NPT, get guest page
tables (including "fake" identity mappings if the guest runs in real mode), and
also to translate guest physical to host physical address. For TLB flush, only
mappings for the guest and not Jailhouse itself are cleaned, if possible.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add AMD-V initialization routines
Valentine Sinitsyn [Fri, 26 Sep 2014 14:53:35 +0000 (20:53 +0600)]
x86: Add AMD-V initialization routines

Implemented functions responsible for checking AMD-V features present and
enabling/disabling SVM mode. Nested Page Tables (NPT) support is required,
and Decode Assists can optionally be used if available. For AVIC, only a
backing page is allocated.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Setup VMCB for Linux CPUs
Valentine Sinitsyn [Tue, 27 May 2014 18:30:14 +0000 (00:30 +0600)]
x86: Setup VMCB for Linux CPUs

Configure VMCB so that Linux can continue run safely on the Jailhouse-managed
CPU. This is done mostly the same way as for VMX (except CPUID is not intercepted
and only CR0 writes that change paging state are trapped). AMD-V guests can also
use ASID to tag TLB entries; as Jailhouse cells run on the same CPUs during all
their lifespan, it is assigned a static value (1).

AVIC is not present in any known AMD chip, so it is not configured yet.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
[Jan: adjust overlapping entries in msrpm, add comment about x2APIC]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Add AMD-V definitions and data structures
Valentine Sinitsyn [Sun, 3 Aug 2014 17:41:07 +0000 (23:41 +0600)]
x86: Add AMD-V definitions and data structures

AMD-V data structures (VMCB, exit codes, flags etc) were adapted
from the Xvisor code. See http://xhypervisor.org for details.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Enable Extended Interrupt LVT
Valentine Sinitsyn [Wed, 17 Sep 2014 16:57:26 +0000 (22:57 +0600)]
x86: Enable Extended Interrupt LVT

Extended Interrupt LVTs are vendor-specific APIC registers (0x50-0x53),
defined by AMD (see APMv2, Sect. 16.3.2). Jailhouse lists this MMIO
range as reserved, as it is not used on Intel systems. On AMD systems,
Extended Interrupt LVT is no more "privileged" than other LVT registers,
so we enable them in corresponding vcpu_init() much the same way it is
currently done for xAPIC mode. Note this also required to make
apic_reserved_bits[] non-static.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Choose a hypercall instruction in run-time
Valentine Sinitsyn [Mon, 1 Sep 2014 16:54:48 +0000 (22:54 +0600)]
x86: Choose a hypercall instruction in run-time

VMX and SVM use different instructions to make a hypercall (vmcall and
vmmcall, respectively). Jailhouse abstracts hypercall instructions with
inlined functions in jailhouse_hypercall.h, and these need to be able to
differentiate between VMX and SVM. For this reason, jailhouse_use_vmcall
global variable was introduced that is stored and filled by the driver.
Inmates will require similar initialization. This is left out as inmates
do not make use of hypercalls at this point.

As jailhouse_call_*() functions are never called on a CPU without VM
extensions (the driver checks if Jailhouse is enabled before issuing a
hypercall, and inmates do not run outside cells), it is safe to assume
that the CPU without VMX support is an SVM one.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
[Jan: dropped inmate initialization,
      switched to bool for jailhouse_use_vmcall,
      refactored init_use_vmcall_flag to init_hypercall]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agodriver: Support "variants" in firmware name
Valentine Sinitsyn [Sun, 28 Sep 2014 16:42:36 +0000 (22:42 +0600)]
driver: Support "variants" in firmware name

Jailhouse loader was also updated to locate and load a correct firmware
binary depending on a type of the system hypervisor executes on.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
[Jan: adjusted #endif to keep MODULE_VERSION unconditional]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agomakefiles: Build jailhouse-{amd,intel} together
Valentine Sinitsyn [Tue, 23 Sep 2014 17:10:27 +0000 (23:10 +0600)]
makefiles: Build jailhouse-{amd,intel} together

This build system update brings an ability to build "jailhouse.bin"
firmware for different architecture "variants" (currently, AMD and
Intel on x86_64) simultaneously. Corresponding firmware files are
called 'jailhouse-$variant.bin'. Variants are introduced in
$(BUILD_VARIANTS) in hypervisor/Makefile and also in corresponding
arch Makefiles. Having per-variant compilation options inside one
architecture is not supported.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Introduce AMD-V code skeleton
Valentine Sinitsyn [Sun, 28 Sep 2014 16:38:56 +0000 (22:38 +0600)]
x86: Introduce AMD-V code skeleton

Introduce a set of vendor-specific headers and sources that contain stubs for
functions required to support AMD-V (SVM) in Jailhouse. As AMD IOMMU support
is not planned for now, iommu_init() does nothing more than print a warning.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Prepare for AMD-V data structures
Valentine Sinitsyn [Wed, 29 Oct 2014 10:10:10 +0000 (15:10 +0500)]
x86: Prepare for AMD-V data structures

VMX-specific data members in struct cell and struct per_cpu were "unionized"
to avoid #ifdefs later, when AMD-V members will be introduced. As a part of these
changes, I/O bitmap became heap-allocated to make this field equally-sized for
both VMX and SVM.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: x86: align code after 32-bit page table
Jan Kiszka [Sat, 1 Nov 2014 08:07:46 +0000 (09:07 +0100)]
inmates: x86: align code after 32-bit page table

Analogous to 906e53b246, fix also the 32-bit header.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agogitignore: add another vim temp file extension
Henning Schild [Wed, 22 Oct 2014 14:38:12 +0000 (16:38 +0200)]
gitignore: add another vim temp file extension

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: x86: Refactor lgdt instruction expression
Jan Kiszka [Fri, 31 Oct 2014 12:44:44 +0000 (13:44 +0100)]
inmates: x86: Refactor lgdt instruction expression

This expresses the intention to load from gdt_ptr using CS clearer than
via the cs prefix, and it is more portable to other assemblers (namely
that of clang).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: x86: Use .code16 instead of .code16gcc
Jan Kiszka [Fri, 31 Oct 2014 12:43:42 +0000 (13:43 +0100)]
inmates: x86: Use .code16 instead of .code16gcc

This removes support for binutils < 2.16 but makes us more portable.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Fix assembly constraints in per_cpu()
Jan Kiszka [Fri, 31 Oct 2014 08:27:25 +0000 (09:27 +0100)]
x86: Fix assembly constraints in per_cpu()

lea's second operand can only be a register. Adjust the constraints
accordingly. LLVM/clang stumbled over this.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agodriver: Express build dependency on version.h
Jan Kiszka [Thu, 30 Oct 2014 18:53:24 +0000 (19:53 +0100)]
driver: Express build dependency on version.h

This fixes the issue that the driver module is not rebuilt properly when
the version header changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: x86: align code after last level of page tables
Henning Schild [Thu, 30 Oct 2014 16:29:54 +0000 (17:29 +0100)]
inmates: x86: align code after last level of page tables

The header contains the page tables but the last level (pd) contained the
code right after the first entry. Calls to map_range would actually
overwrite the inmates code.
This patch makes sure the code will start on the next page.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoDocumentation: Introduce coding style
Valentine Sinitsyn [Sun, 26 Oct 2014 13:07:26 +0000 (18:07 +0500)]
Documentation: Introduce coding style

As the number of external contributions to Jailhouse grows, the need
for some formal coding style to ease review process and integration
arise. This is the first attempt to summarize what's have been discussed
on jailhouse-dev@googlegroups.com mailing list so far.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
[Jan: clarify include block separation]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: config-create: rename parse_cmdline to parse_kernel_cmdline
Benjamin Block [Fri, 12 Sep 2014 17:05:31 +0000 (19:05 +0200)]
tools: config-create: rename parse_cmdline to parse_kernel_cmdline

`parse_cmdline` is quite missleading in the context of a script with
command-line parameters. Thus better name it for what it does, parse the
kernel command line.

Signed-off-by: Benjamin Block <bebl@mageta.org>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: fix pci MSI-X support code bug
Henning Schild [Wed, 22 Oct 2014 12:07:05 +0000 (14:07 +0200)]
inmates: fix pci MSI-X support code bug

The "Message Control" field of a MSI-X capability structure starts two
bytes after the capabilty id, not just one.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agodocs: x86 apic: add x86 apic doxygen submodule
Henning Schild [Mon, 20 Oct 2014 13:09:05 +0000 (15:09 +0200)]
docs: x86 apic: add x86 apic doxygen submodule

Add a new doxygen submodule and convert existing documentation to
doxygen style.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
[Jan: renamed module to "APIC"]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agodocs: add x86 doxygen module
Henning Schild [Mon, 20 Oct 2014 13:09:04 +0000 (15:09 +0200)]
docs: add x86 doxygen module

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agomake: introduce make target docs_clean
Henning Schild [Mon, 20 Oct 2014 11:22:08 +0000 (13:22 +0200)]
make: introduce make target docs_clean

Introduce a make target to remove generated documentation.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agopci: fix msix device list remove-code
Henning Schild [Fri, 17 Oct 2014 17:19:29 +0000 (19:19 +0200)]
pci: fix msix device list remove-code

In pci_remove_device we want to remove only one device from the list.
The current code truncates our device list and drops the tail, fix that
by just unchaining one element.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86/tools/inmates: Account for 32-bit PM timers
Valentine Sinitsyn [Thu, 9 Oct 2014 17:00:36 +0000 (23:00 +0600)]
x86/tools/inmates: Account for 32-bit PM timers

Some systems may use 32-bit PM timer (as defined by TMR_VAL_EXT feature
flag in FADT), however pm_timer_read() assumes it is always 24-bit. Where
this assumption is wrong, return value becomes incorrect, and the error
grows over time leading to obscure bugs, including lockups in the hypervisor.

To fix this, TMR_VAL_EXT is made part of platform config and is passed to
inmates in the communication region. Config generator was also adapted
to parse FADT to get TMR_VAL_EXT value for target system. pm_timer_init()
function was also introduced to the inmates framework to the overflow value.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
[Jan: mark jailhouse_comm_region as packed]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: control: use arch_flush_cell_vcpu_caches in arch_config_commit
Henning Schild [Fri, 10 Oct 2014 13:25:44 +0000 (15:25 +0200)]
x86: control: use arch_flush_cell_vcpu_caches in arch_config_commit

Use the new function also in arch_config_commit to get that function
more compact.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocontrol: add a control function to flush vcpu caches of a whole cell
Henning Schild [Fri, 10 Oct 2014 13:25:43 +0000 (15:25 +0200)]
control: add a control function to flush vcpu caches of a whole cell

When having to unmap memory while a cell is running we need a way to
flush its tlbs. Adding a function to do just that.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: rename per_cpu variable flush_virt_caches to flush_vcpu_caches
Henning Schild [Fri, 10 Oct 2014 13:25:42 +0000 (15:25 +0200)]
core: rename per_cpu variable flush_virt_caches to flush_vcpu_caches

Also changed the comment to hopefully better reflect what the variable
is used for.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Keep IOAPIC entries consistent when unmasked
Valentine Sinitsyn [Thu, 9 Oct 2014 15:38:19 +0000 (21:38 +0600)]
x86: Keep IOAPIC entries consistent when unmasked

When an IOAPIC redirection entry is masked, only lower half of the register
is written. This causes the upper half to contain stale data when the entry
is unmasked. On systems that don't do interrupt remapping (currently, QEMU
and AMD) this may result in interrupts being lost or delivered to the wrong
destination.

Fix this by unconditionally writing the upper half of the register when
it is unmasked.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Make vcpu_handle_pt_violation() generic
Valentine Sinitsyn [Sat, 16 Aug 2014 19:46:44 +0000 (01:46 +0600)]
x86: Make vcpu_handle_pt_violation() generic

Finally, page fault handling in guests was generalized and can now
be called for any vendor. To communicate page fault details between
vendor-specific and generic code, struct vcpu_pf_intercept was introduced,
and vcpu_get_guest_paging_structures() was made public (i.e. non-static).

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Make vcpu_handle_io_access() generic
Valentine Sinitsyn [Sat, 16 Aug 2014 19:00:14 +0000 (01:00 +0600)]
x86: Make vcpu_handle_io_access() generic

I/O VM exit handling code can now be used for any vendor.
This implies introducing struct vcpu_io_intercept to communicate
intercepted instruction properties like the port number and access
size between vendor-specific and generic code.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Make vcpu_handle_hypercall() generic
Valentine Sinitsyn [Fri, 15 Aug 2014 19:07:55 +0000 (01:07 +0600)]
x86: Make vcpu_handle_hypercall() generic

Hypercall handling code can now be used for any vendor.
This implies implementing accessor to EFER, RFLAGS, CS and RIP,
(commonly referred to as "execution state") and also making
vcpu_deactivate_vmm() non-static.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Refactor generic bits of vcpu_cell_{init,exit}
Valentine Sinitsyn [Fri, 15 Aug 2014 17:55:02 +0000 (23:55 +0600)]
x86: Refactor generic bits of vcpu_cell_{init,exit}

vcpu_cell_init() and vcpu_cell_exit() functions contain some code that is
the same regardless virtualization technology used. So they were moved to
the newly-introduced vcpu.c, calling vcpu_vendor_cell_init() and
vcpu_vendor_cell_exit() for vendor-specific actions.

This also implies introducing the first data abstraction structure, and the
first vendor-specific data wrapper function: vcpu_vendor_get_cell_io_bitmap().
More to follow.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Make vcpu_get_guest_paging_structs() public
Valentine Sinitsyn [Fri, 3 Oct 2014 08:17:45 +0000 (14:17 +0600)]
x86: Make vcpu_get_guest_paging_structs() public

Similarly, vmx_get_guest_paging_structs() was renamed to
vcpu_get_guest_paging_structs() and made non-static.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Make vcpu_skip_emulated_instruction() public
Valentine Sinitsyn [Fri, 3 Oct 2014 08:10:52 +0000 (14:10 +0600)]
x86: Make vcpu_skip_emulated_instruction() public

In preparation for vmx.c refactoring, vmx_skip_emulated_instruction() was
renamed to vcpu_skip_emulated_instruction() and made non-static.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Switchable guest code access for mmio_parse()
Valentine Sinitsyn [Sat, 9 Aug 2014 18:21:55 +0000 (00:21 +0600)]
x86: Switchable guest code access for mmio_parse()

mmio_parse() and related infrastructure use link-time resolved (rather
than hardcoded) static function to access guest memory. This way,
vendor-specific code can provide an accelerated implementation if available.

map_code_page() helper routine is now superseded by vcpu_get_inst_bytes() with
different call semantics. The function returns a pointer to the first byte
available and accepts the number of bytes to map (or otherwise make available)
to the hypervisor. It can adjust this value (it is now done to save an
unnecessary page table walk) as described inside the commit.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Introduce iommu_cell_emulates_ir()
Valentine Sinitsyn [Tue, 7 Oct 2014 06:21:10 +0000 (12:21 +0600)]
x86: Introduce iommu_cell_emulates_ir()

As ir_emulation flag is defined in VTD-specific part of struct cell,
a wrapper function was added to access it in the uniform manner.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Untie APIC code from VMX implementation
Valentine Sinitsyn [Wed, 24 Sep 2014 12:31:22 +0000 (18:31 +0600)]
x86: Untie APIC code from VMX implementation

Removed direct references to VMX functions from the APIC code,
which is generic by its design. NMI handlers are now defined in
corresponding vendor-specific code (presently, only vmx.c), and
resolved at the link time.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Move vmx_vmexit to vmx-vmexit.S
Valentine Sinitsyn [Tue, 7 Oct 2014 06:29:12 +0000 (12:29 +0600)]
x86: Move vmx_vmexit to vmx-vmexit.S

entry.S was split between vendor-neutral code (arch_entry, interrupt handlers),
and vendor-specific code for handling VM exists. This helps to avoid #ifdefs later,
when SVM entry point will be introduced.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Rename VMX/VTD public functions
Valentine Sinitsyn [Sat, 17 May 2014 18:12:45 +0000 (00:12 +0600)]
x86: Rename VMX/VTD public functions

In preparation to support different vendor-specific implementations for
virtualization features, public functions for VMX/VTD were renamed.
"vmx_" and "vtd_" prefixes are now superseded with "vcpu_" and "iommu_",
and new header files were introduced to hold the declarations.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Introduce realmode_paging structures
Valentine Sinitsyn [Thu, 7 Aug 2014 18:39:16 +0000 (00:39 +0600)]
x86: Introduce realmode_paging structures

Real mode certainly has no paging, but having these structures in place make
guest memory access more uniform. Future AMD code will need to read guest
instructions for cells running in real mode.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Do not hardcode RIP position on Linux stack
Valentine Sinitsyn [Sun, 22 Jun 2014 06:13:07 +0000 (12:13 +0600)]
x86: Do not hardcode RIP position on Linux stack

On guest mode entry, linux_ip is always NUM_ENTRY_REGS * 8 bytes from linux_sp,
not 6 bytes.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Make CS segment switching more generic
Valentine Sinitsyn [Mon, 9 Jun 2014 15:53:05 +0000 (21:53 +0600)]
x86: Make CS segment switching more generic

Original set_cs() implementation relied on rex64/ljmp instruction. However,
AMD64 doesn't support 64-bit offsets in far jump (there is no rex-prefixed
version), and the offset used by Jailhouse is more than 32-bit long.

An alternative method that relies on lretq is used to switch CS now. It is
known to work both on Intel and AMD.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Adjust QEMU config to changes in AHCI model
Jan Kiszka [Sun, 5 Oct 2014 08:51:40 +0000 (10:51 +0200)]
configs: Adjust QEMU config to changes in AHCI model

The cap location was adjusted to comply with the spec.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: Add include dependency checker for header files
Jan Kiszka [Thu, 9 Oct 2014 06:05:04 +0000 (08:05 +0200)]
tooling: Add include dependency checker for header files

This script checks is all dependencies of a header file are fulfilled so
that the header can be included stand-alone.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: config.h is expected in the $(obj), not $(src)
Jan Kiszka [Mon, 29 Sep 2014 06:59:15 +0000 (08:59 +0200)]
core: config.h is expected in the $(obj), not $(src)

Cosmetic change, both are identical in practice (no out-of-tree build
possible for out-of-tree modules right now).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agodriver: Use hypervisor's version.h
Jan Kiszka [Mon, 29 Sep 2014 06:55:24 +0000 (08:55 +0200)]
driver: Use hypervisor's version.h

Let the driver module depend on the hypervisor subdir. This allows us to
reuse the version.h generated by the hypervisor build also for the
driver. They were identical.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: Fix CPU listing in "cell list"
Jan Kiszka [Mon, 29 Sep 2014 10:54:15 +0000 (12:54 +0200)]
tools: Fix CPU listing in "cell list"

This fixes the output of patterns like "0,3", i.e. individual CPUs with
a gap in between them.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: Fix make problems with run-kbuild macro
Jan Kiszka [Mon, 6 Oct 2014 15:57:14 +0000 (17:57 +0200)]
tooling: Fix make problems with run-kbuild macro

Switch to a more robust pattern for invoking kbuild. The indirection via
the macro caused too many issues, up to no execution at all.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Tested-by: Santosh Shukla <santosh.shukla@linaro.org>
9 years agocore: Document I/O access subsystem
Jan Kiszka [Thu, 25 Sep 2014 11:54:09 +0000 (13:54 +0200)]
core: Document I/O access subsystem

This adds doxygen-style documentation for I/O access subsystem which
covers MMIO as well as PIO.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Document per-CPU data subsystem
Jan Kiszka [Wed, 24 Sep 2014 21:59:39 +0000 (23:59 +0200)]
x86: Document per-CPU data subsystem

Document the x86-specific per-CPU data structure and accessors. This is
a temporary solution until we factored out generic bits.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Rename DECLARE_PER_CPU_ACCESSOR to DEFINE_PER_CPU_ACCESSOR
Jan Kiszka [Thu, 25 Sep 2014 11:57:54 +0000 (13:57 +0200)]
core: Rename DECLARE_PER_CPU_ACCESSOR to DEFINE_PER_CPU_ACCESSOR

This declaration is a definition, in fact. Adjust the name.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Rename CPU suspension state variables
Jan Kiszka [Thu, 25 Sep 2014 05:56:29 +0000 (07:56 +0200)]
core: Rename CPU suspension state variables

Rename stop_cpu and cpu_stopped to suspend_cpu and cpu_suspended. This
is more consistent with the function names that manipulate the CPU
state.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Disentangle circular dependency of percpu.h and vmx.h
Jan Kiszka [Wed, 24 Sep 2014 20:28:46 +0000 (22:28 +0200)]
x86: Disentangle circular dependency of percpu.h and vmx.h

Move the struct vmcs to where it really belongs: vmx.h. This requires
including of the latter file from percpu.h. Enable this via a forward-
declaration of struct per_cpu in vmx.h. And now that we split things up,
we can move the vmx_state enum as well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore Assign root_cell to control subsystem
Jan Kiszka [Wed, 24 Sep 2014 19:26:46 +0000 (21:26 +0200)]
core Assign root_cell to control subsystem

Move the global root_cell structure to the control subsystem, both
code- and documentation-wise.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Document cell structure
Jan Kiszka [Wed, 24 Sep 2014 19:13:54 +0000 (21:13 +0200)]
x86: Document cell structure

Document the x86-specific cell structure. This is a temporary solution
until we factored out generic bits.

The cell structure is cross-subsystem, so leave it unassigned to
group.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Document setup subsystem
Jan Kiszka [Wed, 24 Sep 2014 17:47:51 +0000 (19:47 +0200)]
core: Document setup subsystem

This adds doxygen-style documentation for public parts of the setup
subsystem, including the hypervisor header.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: Rename vm_exit to vmx_vmexit
Jan Kiszka [Wed, 24 Sep 2014 20:16:42 +0000 (22:16 +0200)]
x86: Rename vm_exit to vmx_vmexit

Clarify that this is in fact a VMX-specific entry point. Consequently,
move the misplaced prototype to the VMX header.

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