]> rtime.felk.cvut.cz Git - jailhouse.git/log
jailhouse.git
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>
9 years agotooling: Silence recursive make calls
Jan Kiszka [Sun, 21 Sep 2014 06:40:44 +0000 (08:40 +0200)]
tooling: Silence recursive make calls

Generalize install.mk to include.mk so that it can host the Q tag
definition. Apply this tag on the recursive make call of the top-level
makefile.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoUpdate TODO regarding ARM
Jan Kiszka [Sat, 20 Sep 2014 11:30:25 +0000 (13:30 +0200)]
Update TODO regarding ARM

Specifically leave a note that big endian support is not yet there.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore/driver: Rework obtaining of maximum number of CPUs
Jan Kiszka [Sat, 20 Sep 2014 11:21:39 +0000 (13:21 +0200)]
core/driver: Rework obtaining of maximum number of CPUs

num_possible_cpus() actually counts the possible CPUs and does not
necessarily return the maximum CPU ID + 1, the value Jailhouse needs.
Fix this by deriving that value from the root cell's CPU set. Rename
the header field correspondingly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agodriver: Rename hv_core_percpu_size to hv_core_and_percpu_size
Jan Kiszka [Sat, 20 Sep 2014 11:15:17 +0000 (13:15 +0200)]
driver: Rename hv_core_percpu_size to hv_core_and_percpu_size

This size is the sum of the core and the per-CPU data region.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Validate CPU ID before using it
Jan Kiszka [Fri, 19 Sep 2014 05:53:06 +0000 (07:53 +0200)]
core: Validate CPU ID before using it

Currently, Linux ensures that we have enough room in the per-CPU data
area when calling the entry function with a specific CPU ID. That will
change as we will allocate only as much as required for a given system
configuration. To avoid that we would then dereference some out of
bounds CPU data because of an invalid CPU ID, always perform the ID
check before using the data structure.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Calculate core and per-CPU data region size differently
Jan Kiszka [Fri, 19 Sep 2014 07:17:29 +0000 (09:17 +0200)]
core: Calculate core and per-CPU data region size differently

Use pointer arithmetic to obtain the size of the region that contains
the hypervisor core and the per-CPU data structures. system_config tells
us where it ends.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Clarify local variable meaning in init_early
Jan Kiszka [Fri, 19 Sep 2014 06:17:47 +0000 (08:17 +0200)]
core: Clarify local variable meaning in init_early

This size is the sum of the core and the per-CPU data area.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore: Compact local variable list in paging_init
Jan Kiszka [Fri, 19 Sep 2014 06:15:56 +0000 (08:15 +0200)]
core: Compact local variable list in paging_init

No functional change.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoREADME: Update after recent build system changes
Jan Kiszka [Wed, 17 Sep 2014 18:28:17 +0000 (20:28 +0200)]
README: Update after recent build system changes

This reflects the changes on KDIR (e2cc88642d) as well as the tool build
and installation (932db6709b).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: qemu: put floppy IO ports into config
Henning Schild [Mon, 15 Sep 2014 14:40:43 +0000 (16:40 +0200)]
configs: qemu: put floppy IO ports into config

The qemu VM will have a floppy drive and we can not tell Qemu to not
emulate one. Now if the guest kernel has a driver for a floppy drive we
can get violations on "jailhouse enable". Of the shelf distro kernels
will have floppy support so we need to whitelist the floppy ports in the
qemu root cell config.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: x86: Add E1000-based PCI DMA demonstration
Jan Kiszka [Thu, 11 Sep 2014 20:21:52 +0000 (22:21 +0200)]
inmates: x86: Add E1000-based PCI DMA demonstration

This adds a simple Ethernet ping-ping via Intel E1000-based NICs. Run
two instances in the same network, and the first will become the test
controller while the second instance to show up will be the target.
Round trip times will be measured and dumped by the controller. This can
surely be further improved, and there are still some stability issues
(measurement stops on lost packet). It's a start.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Add NULL definition
Jan Kiszka [Sun, 14 Sep 2014 09:21:48 +0000 (11:21 +0200)]
inmates: Add NULL definition

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoinmates: Add memcpy prototype
Jan Kiszka [Sat, 13 Sep 2014 10:54:00 +0000 (12:54 +0200)]
inmates: Add memcpy prototype

Only supports built-in version so far.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: Install jailhouse binary under sbin
Jan Kiszka [Mon, 8 Sep 2014 12:20:39 +0000 (14:20 +0200)]
tooling: Install jailhouse binary under sbin

It is, in fact, a privileged program, at least now and in the
foreseeable future. So move it to sbin.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: Respect DESTDIR for module installation
Jan Kiszka [Mon, 8 Sep 2014 12:04:56 +0000 (14:04 +0200)]
tooling: Respect DESTDIR for module installation

If unset, derive INSTALL_MOD_PATH from DESTDIR and export it so that the
module installation will use it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: Remove explicit depmod invocation
Jan Kiszka [Mon, 8 Sep 2014 11:59:10 +0000 (13:59 +0200)]
tooling: Remove explicit depmod invocation

Modern kernels do this for us.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: extracts common install-definitions into a central include
Benjamin Block [Wed, 3 Sep 2014 12:53:17 +0000 (14:53 +0200)]
tooling: extracts common install-definitions into a central include

After adding install-rules to the tools- and root-Makefile we have some
redundancies in some variables and definitions (e.g.: $(INSTALL)). To fix
this, extract all duplications and general definitions concerning the
install-process into one central Makefile-include `install.mk`.

This also unifies the way directories are created for
installation-rules. Previously we would just create them every time
without checking if that is needed. Now we add them as prerequisite to
the install-rule and generate a rule for each of them in `install.mk`.
This way `make` will figure out if the need to be created. This also
lowers the verboseness of the Makefile.

Signed-off-by: Benjamin Block <bebl@mageta.org>
[Jan: moved install.mk to scripts folder]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: add recursive tools-build and proper install-rules to the root Makefile
Benjamin Block [Wed, 3 Sep 2014 12:53:16 +0000 (14:53 +0200)]
tooling: add recursive tools-build and proper install-rules to the root Makefile

To build the jailhouse-tools, one has to make separate make-calls in
each their directory. This is fixed by adding simple recursive rules to
the root-Makefile. This also makes sure, that we always build both and
don't get incompatible versions during development.

This patch also adds proper install-rules to the root-Makefile. We added
them to our tools-Makefile, so we should also add them here. This only
concerns the hypervisor-image-file at the moment.

Signed-off-by: Benjamin Block <bebl@mageta.org>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotooling: split Kbuild-related rules from the main Makefile
Benjamin Block [Wed, 3 Sep 2014 12:53:15 +0000 (14:53 +0200)]
tooling: split Kbuild-related rules from the main Makefile

Split all parts of the main Makefile, that are only related to the
kernel build-system, into their own file (Kbuild). When invokes, this
file will be search first for additional rules by the kernel
build-system.

The remaining rules in our own root-Makefile will not be seen by the
kernel build-system anymore and thus are easier to extend.

Also, change some variable-names to fit those suggested by the
kernel-documentation (Documentation/kbuild/modules.txt).

Signed-off-by: Benjamin Block <bebl@mageta.org>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agodriver: Fix signedness in stats_show()
Valentine Sinitsyn [Thu, 4 Sep 2014 07:58:17 +0000 (13:58 +0600)]
driver: Fix signedness in stats_show()

A variable that store hypercall result in stats_show() function
was incorrectly declared as unsigned, hence the error check always
succeeded.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: Add VERSION file to jailhouse tool dependencies
Jan Kiszka [Tue, 2 Sep 2014 14:14:16 +0000 (16:14 +0200)]
tools: Add VERSION file to jailhouse tool dependencies

If the version changes, we want this information in the tool (via
CFLAGS).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoscripts: deal with shell incompatibilities
Henning Schild [Mon, 1 Sep 2014 12:20:20 +0000 (14:20 +0200)]
scripts: deal with shell incompatibilities

In dash echo is a builtin that does not support -e as a result we did
generate broken header files on Ubuntu and newer Debian systems.
For make_relaese just enforce bash as the shell of our choice.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoBump version number
Jan Kiszka [Fri, 29 Aug 2014 12:31:29 +0000 (14:31 +0200)]
Bump version number

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoREADME: Describe installation process
Jan Kiszka [Fri, 29 Aug 2014 07:37:05 +0000 (09:37 +0200)]
README: Describe installation process

make install is now consistently available.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoscripts: Add release-maker script
Jan Kiszka [Thu, 28 Aug 2014 15:53:57 +0000 (17:53 +0200)]
scripts: Add release-maker script

To document the steps in a productive way. The final git push is not
included, intentionally.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: Add Version information to command line tool
Jan Kiszka [Thu, 28 Aug 2014 11:32:35 +0000 (13:32 +0200)]
tools: Add Version information to command line tool

Dump the static version tag from the management tool when invoked with
"--version". We don't need precise git-based tracking here as interfaces
are fairly decoupled now.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agocore/driver: Add version information
Jan Kiszka [Wed, 27 Aug 2014 22:25:36 +0000 (00:25 +0200)]
core/driver: Add version information

Create a version string in the format

    vX.Y (<commits-since-vX.Y>-<git-hash>[-dirty])

and embed it into the hypervisor core as well as the driver module.
Helps to identify what is actually executed.

The management tool is more decoupled from those two and will get a
simpler version tag.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: Remove dependency of jailhouse tool on cell-config.h
Jan Kiszka [Thu, 28 Aug 2014 11:36:18 +0000 (13:36 +0200)]
tools: Remove dependency of jailhouse tool on cell-config.h

Two things caused jailhouse.h and, thus, tools/jailhouse.c to depend on
the cell configuration header: the definition of the JAILHOUSE_ENABLE
IOCTL and the maximum cell name length in config files.

The first dependency is not only unneeded (the command line tool passed
the an uninterpreted blob via JAILHOUSE_ENABLE), it also made the driver
ABI change each time we updated the config format. So replace the
reference to struct jailhouse_system in JAILHOUSE_ENABLE with a symbolic
"void *".

The second dependency is also unneeded: While the name length used in
configs and, thus, also inside the driver to reference cells should be
identical to the lengths we use in struct jailhouse_cell_id, there is no
hard dependency. In the worst case (different lengths), we would fail to
address cells by name. However, these lengths are unlikely to change. So
simply define our own name length for that struct and test for
deviations during the driver build.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: Add installation rules
Jan Kiszka [Wed, 27 Aug 2014 18:35:15 +0000 (20:35 +0200)]
tools: Add installation rules

This installs the jailhouse tool, its helper scripts and the template
files to standard, configurable directories. We patch the config
generator on installation so that the target version is aware of the
chosen data directory.

Note that installing the bash completion is left up to the user. There
is apparently no distro-independent way to achieve this.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: Hide some secondary build commands
Jan Kiszka [Wed, 27 Aug 2014 18:33:21 +0000 (20:33 +0200)]
tools: Hide some secondary build commands

By default, hide commands that are not essential for following the build
(or installation) process. Those can still be revealed by specifying
V=1. chmod is a first candidate.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: config-create: Add support for using a data directory
Jan Kiszka [Wed, 27 Aug 2014 18:28:33 +0000 (20:28 +0200)]
tools: config-create: Add support for using a data directory

Once installed, the jailhouse-config-create has to be able to use a data
directory for finding its templates. That dir will typically be
different from the one where the script is located. Prepare for this by
providing a datadir variable assignment that can be patched during
installation.

When running from the source tree, we continue to use that directory as
default template dir.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agoconfigs: Avoid spaces in QEMU config name
Jan Kiszka [Wed, 27 Aug 2014 18:45:01 +0000 (20:45 +0200)]
configs: Avoid spaces in QEMU config name

Specifically bash completion is more fun without them.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: jailhouse: Use a libexec subdir for extension scripts
Jan Kiszka [Wed, 27 Aug 2014 19:03:14 +0000 (21:03 +0200)]
tools: jailhouse: Use a libexec subdir for extension scripts

We want our extension scripts to be under a standard directory, namely
$libexecdir/<package>. As libexecdir may be overwritten during
installation, accept it from the Makefile via a define.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9 years agotools: add bash-completion for the jailhouse-tool
Benjamin Block [Wed, 27 Aug 2014 17:40:52 +0000 (19:40 +0200)]
tools: add bash-completion for the jailhouse-tool

Because `jailhouse` is the main user-interface to the VM and some
command-chains are quite verbose (create, enable, cell create, cell
load, ...) it is very convenient to have a working bash-completion for
it.

This completes all current uses, although it is very static in some
places (as is the jh-tool) - some argument are only expected at certain
positions, etc.

For it to work, you need to have the `jailhouse`-tool in your
PATH-variable (obviously for the tool itself to work, you will likely
also need all other tools in PATH). Then just run

> . tools/jailhouse_bashcompletion

and it should work. You also need the bash-completion package installed
on your distribution and activated in your bash, otherwise the
source-operation will do nothing. For more details please read the
header of the file.

Known Bug: cell-namens as argument for the cell-subcommands can't contain
           spaces

Signed-off-by: Benjamin Block <bebl@mageta.org>
[Jan: removed restriction to .bin files]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>