]> rtime.felk.cvut.cz Git - jailhouse.git/log
jailhouse.git
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>
9 years agocore: Document control subsystem
Jan Kiszka [Wed, 24 Sep 2014 08:01:53 +0000 (10:01 +0200)]
core: Document control subsystem

This adds doxygen-style documentation for public parts of the control
subsystem.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Rename [arch_]panic_halt to [arch_]panic_park
Jan Kiszka [Wed, 24 Sep 2014 16:06:15 +0000 (18:06 +0200)]
core: Rename [arch_]panic_halt to [arch_]panic_park

This makes naming consistent with other parts of the code.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Remove cpu_data from arch_config_commit
Jan Kiszka [Wed, 24 Sep 2014 15:40:39 +0000 (17:40 +0200)]
core: Remove cpu_data from arch_config_commit

We can obtain a reference inside arch_config_commit. This also allows to
drop cpu_data from late_init.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Remove unused cpu_data from arch_cell_create/destroy
Jan Kiszka [Wed, 24 Sep 2014 15:29:05 +0000 (17:29 +0200)]
core: Remove unused cpu_data from arch_cell_create/destroy

Became obsolete with 77b0e690ec.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Remove cpu_data parameter from hypercall functions
Jan Kiszka [Sat, 23 Aug 2014 14:23:06 +0000 (16:23 +0200)]
core: Remove cpu_data parameter from hypercall functions

We can obtain a reference on demand now.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Factor out generic jailhouse/types.h
Jan Kiszka [Wed, 24 Sep 2014 08:11:57 +0000 (10:11 +0200)]
core: Factor out generic jailhouse/types.h

Some types in the architecture-specific header are in fact generic. Move
them into a separate header and include this one directly from now on.
Document cpu_set at this chance according to doxygen style.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Document page management subsystem interfaces
Jan Kiszka [Wed, 24 Sep 2014 05:38:08 +0000 (07:38 +0200)]
core: Document page management subsystem interfaces

This adds doxygen-style documentation for public parts of the page
management subsystem. Again we place documentation of architecture-
provided entities in the generic header.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Rename arch-specific cache and TLB flush functions
Jan Kiszka [Wed, 24 Sep 2014 07:00:46 +0000 (09:00 +0200)]
core: Rename arch-specific cache and TLB flush functions

Consistently add "arch_" and the subsystem prefix und use clearer names
for cache and TLB flushing services.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Rename *MAX_PAGE_DIR_LEVELS to *MAX_PAGE_TABLE_LEVELS
Jan Kiszka [Wed, 24 Sep 2014 05:42:30 +0000 (07:42 +0200)]
core: Rename *MAX_PAGE_DIR_LEVELS to *MAX_PAGE_TABLE_LEVELS

To be consistent with terms used throughout the hypervisor.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Rename page_map_* -> paging_*
Jan Kiszka [Sat, 23 Aug 2014 12:50:16 +0000 (14:50 +0200)]
core: Rename page_map_* -> paging_*

The module is already called "paging", so lets call its functions like
this as well. No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Document PCI subsystem interfaces
Jan Kiszka [Tue, 23 Sep 2014 16:33:25 +0000 (18:33 +0200)]
core: Document PCI subsystem interfaces

Convert existing kernel-doc comments to doxygen style and add missing
functions and structure descriptions for public interfaces. Architecture
specific functions are documented in the headers to avoid duplications
at the implementation site.

No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Prefix arch-specific PCI functions properly
Jan Kiszka [Tue, 23 Sep 2014 16:30:39 +0000 (18:30 +0200)]
core: Prefix arch-specific PCI functions properly

Add the "arch_"-prefix to pci_suppress_msi, pci_update_msi and
pci_update_msix_vector. This clearly signals that those functions have
to be implemented by the architecture support.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoDocumentation: Add Doxygen infrastructure
Jan Kiszka [Tue, 23 Sep 2014 13:06:40 +0000 (15:06 +0200)]
Documentation: Add Doxygen infrastructure

We diverge from Linux kernel style and use Doxygen as our code
documentation generator, see [1] for the reasoning. This adds the
required build infrastructure. Run "make docs" to trigger it (not
automatically done via other targets).

[1] http://thread.gmane.org/gmane.linux.jailhouse/1281

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: Do not print directory names during build
Jan Kiszka [Thu, 25 Sep 2014 07:56:31 +0000 (09:56 +0200)]
tooling: Do not print directory names during build

Just to reduce verbosity.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: Fix parallel kbuild
Jan Kiszka [Thu, 25 Sep 2014 07:54:43 +0000 (09:54 +0200)]
tooling: Fix parallel kbuild

The define decouples the calling make from the recursively called one.
Fix it by prefixing the latter with "+".

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: pci: add msix support to inmate lib
Henning Schild [Fri, 19 Sep 2014 14:35:25 +0000 (16:35 +0200)]
inmates: pci: add msix support to inmate lib

Add basic MSI-X support to inmate PCI library.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: pci: allow pci_find_device to discover multiple devices
Henning Schild [Fri, 19 Sep 2014 14:35:26 +0000 (16:35 +0200)]
inmates: pci: allow pci_find_device to discover multiple devices

Systems can have more than one PCI device with the same vendor/device
id pair. Change the discovery helper to allow searching for more than
just the first bdf.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoRevert "core: make the jailhouse-header arch-independent"
Jan Kiszka [Thu, 25 Sep 2014 13:37:18 +0000 (15:37 +0200)]
Revert "core: make the jailhouse-header arch-independent"

This reverts commit 17f8453876f8b143022278e6438c8ebb157d1821.

It turned out to break 32-bit architectures: At least core_size and
entry must be of the size the hypervisor uses for pointer, otherwise
link-time initialization of those fields fail.

We will need a more sophisticated solution if including the header in
i386 mode is really necessary.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: Fix gen_version_h to query git support for the correct repository
Jan Kiszka [Tue, 23 Sep 2014 16:24:10 +0000 (18:24 +0200)]
tooling: Fix gen_version_h to query git support for the correct repository

The initial git availability check ran in the kernel directory instead
of the Jailhouse source tree. Fix it by moving the cd before it. Also
quote the input path properly at this chance.

Reported-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: Remove debugging left-over in gen_version_h
Jan Kiszka [Tue, 23 Sep 2014 12:57:29 +0000 (14:57 +0200)]
tooling: Remove debugging left-over in gen_version_h

Stop polluting the source directory with this useless diff.log that was
once added during development.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: make the jailhouse-header arch-independent
Benjamin Block [Mon, 22 Sep 2014 13:08:27 +0000 (15:08 +0200)]
core: make the jailhouse-header arch-independent

The header of jailhouse is defined with arch-dependent types such as
`unsigned long` which on linux varies in size. Because this header can
be considered the "communication"-relay with the environment, it should
be type-safe on any arch. Thus change all types into fixed-size-types.

Signed-off-by: Benjamin Block <bebl@mageta.org>
[Jan: adjusted jailhouse_entry to keep unsigned int]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agox86: make the x86 types-definitions work on either x86-32 and x86-64
Benjamin Block [Mon, 22 Sep 2014 13:08:26 +0000 (15:08 +0200)]
x86: make the x86 types-definitions work on either x86-32 and x86-64

For Intel TXT we will need to work in 32bit mode for a limited amount of
time. To make sure we can use certain headers and definitions safely in
both modes, change the definition of `u64` to use `long long` instead of
`long` (which changes its length depending on the arch).

Furthermore, the x86-header defines a macro BITS_PER_LONG, currently we
define this always as `64`. To make this usable for the TXT-stub, hide
this behind an `ifndef`. The current hypervisor-code won't be affected
by this change and we can define this for the TXT-stub with our tooling,
thus make the header usable in both modes.

Signed-off-by: Benjamin Block <bebl@mageta.org>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: config create: change the way input files are handled
Henning Schild [Mon, 22 Sep 2014 13:13:32 +0000 (15:13 +0200)]
tools: config create: change the way input files are handled

Switch from automatically generated lists of input files to
hand-maintained ones. Generating the lists turned out to make the code
less readable. All the parse-functions would have to be called just to
collect theire opens.
Now we still use the input_open wrapper to prefix the opens with the
root_dir and we make sure that the file one is trying to open is listed
as an input file and will therefore be collected by the collector.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: config-create: cosmetic changes for pep8 compliance
Henning Schild [Mon, 22 Sep 2014 12:17:55 +0000 (14:17 +0200)]
tools: config-create: cosmetic changes for pep8 compliance

Fix syntax according to pep8 and remove stale function return.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: Add copyright header to make_release
Jan Kiszka [Mon, 22 Sep 2014 08:51:02 +0000 (10:51 +0200)]
tooling: Add copyright header to make_release

Top-level license already applied, but let's make it also formally
clear.

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