* Jailhouse, a Linux-based partitioning hypervisor
*
* Copyright (c) Siemens AG, 2013
+ * Copyright (c) Valentine Sinitsyn, 2014
*
* Authors:
* Jan Kiszka <jan.kiszka@siemens.com>
+ * Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
/** Cell-related states. */
/* TODO: factor out arch-independent bits, define struct arch_cell */
struct cell {
- struct {
- /** PIO access bitmap. */
- /* should be first as it requires page alignment */
- u8 __attribute__((aligned(PAGE_SIZE))) io_bitmap[2*PAGE_SIZE];
- /** Paging structures used for cell CPUs. */
- struct paging_structures ept_structs;
- } vmx; /**< Intel VMX-specific fields. */
+ union {
+ struct {
+ /** PIO access bitmap. */
+ u8 *io_bitmap;
+ /** Paging structures used for cell CPUs. */
+ struct paging_structures ept_structs;
+ } vmx; /**< Intel VMX-specific fields. */
+ };
- struct {
- /** Paging structures used for DMA requests. */
- struct paging_structures pg_structs;
- /** True if interrupt remapping support is emulated for this
- * cell. */
- bool ir_emulation;
- } vtd; /**< Inte VT-d specific fields. */
+ union {
+ struct {
+ /** Paging structures used for DMA requests. */
+ struct paging_structures pg_structs;
+ /** True if interrupt remapping support is emulated for this
+ * cell. */
+ bool ir_emulation;
+ } vtd; /**< Intel VT-d specific fields. */
+ };
/** ID of the cell. */
unsigned int id;
* Jailhouse, a Linux-based partitioning hypervisor
*
* Copyright (c) Siemens AG, 2013
+ * Copyright (c) Valentine Sinitsyn, 2014
*
* Authors:
* Jan Kiszka <jan.kiszka@siemens.com>
+ * Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
/** @} */
/** True when CPU is initialized by hypervisor. */
bool initialized;
- /** VMX initialization state. */
- enum vmx_state vmx_state;
+ union {
+ /** VMX initialization state */
+ enum vmx_state vmx_state;
+ };
/**
* Lock protecting CPU state changes done for control tasks.
/** Number of iterations to clear pending APIC IRQs. */
unsigned int num_clear_apic_irqs;
- /** VMXON region, required by VMX. */
- struct vmcs vmxon_region __attribute__((aligned(PAGE_SIZE)));
- /** VMCS of this CPU, required by VMX. */
- struct vmcs vmcs __attribute__((aligned(PAGE_SIZE)));
+ union {
+ struct {
+ /** VMXON region, required by VMX. */
+ struct vmcs vmxon_region
+ __attribute__((aligned(PAGE_SIZE)));
+ /** VMCS of this CPU, required by VMX. */
+ struct vmcs vmcs
+ __attribute__((aligned(PAGE_SIZE)));
+ };
+ };
} __attribute__((aligned(PAGE_SIZE)));
/**
int vcpu_vendor_cell_init(struct cell *cell)
{
+ /* allocate io_bitmap */
+ cell->vmx.io_bitmap = page_alloc(&mem_pool, 2);
+ if (!cell->vmx.io_bitmap)
+ return -ENOMEM;
+
/* build root EPT of cell */
cell->vmx.ept_structs.root_paging = ept_paging;
cell->vmx.ept_structs.root_table = page_alloc(&mem_pool, 1);