]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
x86: Prepare for AMD-V data structures
authorValentine Sinitsyn <valentine.sinitsyn@gmail.com>
Wed, 29 Oct 2014 10:10:10 +0000 (15:10 +0500)
committerJan Kiszka <jan.kiszka@siemens.com>
Sat, 1 Nov 2014 08:09:09 +0000 (09:09 +0100)
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>
hypervisor/arch/x86/include/asm/cell.h
hypervisor/arch/x86/include/asm/percpu.h
hypervisor/arch/x86/vmx.c

index 07651880acc080ae583fe8070b57d4c7b54041f1..1671ef7607deb2216d9c9d606e9597b076c00cab 100644 (file)
@@ -2,9 +2,11 @@
  * 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.
@@ -23,21 +25,24 @@ struct pci_device;
 /** 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;
index a0b6bac883aefc2bde699210eeddb6322430af48..fd3d87cfe60038382cf320e0d353a2cbe10bc8d4 100644 (file)
@@ -2,9 +2,11 @@
  * 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.
@@ -79,8 +81,10 @@ struct per_cpu {
        /** @} */
        /** 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.
@@ -124,10 +128,16 @@ struct per_cpu {
        /** 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)));
 
 /**
index 4b08e1ce6f556dbcd72a96051588b756745b784f..e146aa251281d42324a26cf7edf361c242664ed0 100644 (file)
@@ -262,6 +262,11 @@ unsigned long arch_paging_gphys2phys(struct per_cpu *cpu_data,
 
 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);