2 * Jailhouse, a Linux-based partitioning hypervisor
4 * Copyright (c) Siemens AG, 2014, 2015
7 * Jan Kiszka <jan.kiszka@siemens.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
12 * Alternatively, you can use or redistribute this file under the following
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
36 * THE POSSIBILITY OF SUCH DAMAGE.
39 #ifndef _JAILHOUSE_CELL_CONFIG_H
40 #define _JAILHOUSE_CELL_CONFIG_H
42 #define JAILHOUSE_CELL_NAME_MAXLEN 31
44 #define JAILHOUSE_CELL_PASSIVE_COMMREG 0x00000001
46 #define JAILHOUSE_CELL_DESC_SIGNATURE "JAILCELL"
48 struct jailhouse_cell_desc {
50 char name[JAILHOUSE_CELL_NAME_MAXLEN+1];
54 __u32 num_memory_regions;
56 __u32 pio_bitmap_size;
57 __u32 num_pci_devices;
59 } __attribute__((packed));
61 #define JAILHOUSE_MEM_READ 0x0001
62 #define JAILHOUSE_MEM_WRITE 0x0002
63 #define JAILHOUSE_MEM_EXECUTE 0x0004
64 #define JAILHOUSE_MEM_DMA 0x0008
65 #define JAILHOUSE_MEM_IO 0x0010
66 #define JAILHOUSE_MEM_COMM_REGION 0x0020
67 #define JAILHOUSE_MEM_LOADABLE 0x0040
68 #define JAILHOUSE_MEM_ROOTSHARED 0x0080
70 #define JAILHOUSE_MEM_VALID_FLAGS (JAILHOUSE_MEM_READ | \
71 JAILHOUSE_MEM_WRITE | \
72 JAILHOUSE_MEM_EXECUTE | \
75 JAILHOUSE_MEM_COMM_REGION | \
76 JAILHOUSE_MEM_LOADABLE | \
77 JAILHOUSE_MEM_ROOTSHARED)
79 struct jailhouse_memory {
84 } __attribute__((packed));
86 struct jailhouse_irqchip {
90 } __attribute__((packed));
92 #define JAILHOUSE_PCI_TYPE_DEVICE 0x01
93 #define JAILHOUSE_PCI_TYPE_BRIDGE 0x02
94 #define JAILHOUSE_PCI_TYPE_IVSHMEM 0x03
96 struct jailhouse_pci_device {
104 __u8 num_msi_vectors;
106 __u16 num_msix_vectors;
107 __u16 msix_region_size;
109 /** used to refer to memory in virtual PCI devices */
111 } __attribute__((packed));
113 #define JAILHOUSE_PCICAPS_WRITE 0x0001
115 struct jailhouse_pci_capability {
120 } __attribute__((packed));
122 #define JAILHOUSE_MAX_IOMMU_UNITS 8
124 #define JAILHOUSE_SYSTEM_SIGNATURE "JAILSYST"
126 struct jailhouse_system {
128 struct jailhouse_memory hypervisor_memory;
129 struct jailhouse_memory debug_uart;
133 __u8 mmconfig_end_bus;
135 __u16 pm_timer_address;
136 __u64 iommu_base[JAILHOUSE_MAX_IOMMU_UNITS];
137 } __attribute__((packed)) x86;
138 } __attribute__((packed)) platform_info;
140 __u32 interrupt_limit;
141 struct jailhouse_cell_desc root_cell;
142 } __attribute__((packed));
145 jailhouse_cell_config_size(struct jailhouse_cell_desc *cell)
147 return sizeof(struct jailhouse_cell_desc) +
149 cell->num_memory_regions * sizeof(struct jailhouse_memory) +
150 cell->num_irqchips * sizeof(struct jailhouse_irqchip) +
151 cell->pio_bitmap_size +
152 cell->num_pci_devices * sizeof(struct jailhouse_pci_device) +
153 cell->num_pci_caps * sizeof(struct jailhouse_pci_capability);
157 jailhouse_system_config_size(struct jailhouse_system *system)
159 return sizeof(*system) - sizeof(system->root_cell) +
160 jailhouse_cell_config_size(&system->root_cell);
163 static inline const unsigned long *
164 jailhouse_cell_cpu_set(const struct jailhouse_cell_desc *cell)
166 return (const unsigned long *)((const void *)cell +
167 sizeof(struct jailhouse_cell_desc));
170 static inline const struct jailhouse_memory *
171 jailhouse_cell_mem_regions(const struct jailhouse_cell_desc *cell)
173 return (const struct jailhouse_memory *)
174 ((void *)jailhouse_cell_cpu_set(cell) + cell->cpu_set_size);
177 static inline const struct jailhouse_irqchip *
178 jailhouse_cell_irqchips(const struct jailhouse_cell_desc *cell)
180 return (const struct jailhouse_irqchip *)
181 ((void *)jailhouse_cell_mem_regions(cell) +
182 cell->num_memory_regions * sizeof(struct jailhouse_memory));
185 static inline const __u8 *
186 jailhouse_cell_pio_bitmap(const struct jailhouse_cell_desc *cell)
188 return (const __u8 *)((void *)jailhouse_cell_irqchips(cell) +
189 cell->num_irqchips * sizeof(struct jailhouse_irqchip));
192 static inline const struct jailhouse_pci_device *
193 jailhouse_cell_pci_devices(const struct jailhouse_cell_desc *cell)
195 return (const struct jailhouse_pci_device *)
196 ((void *)jailhouse_cell_pio_bitmap(cell) +
197 cell->pio_bitmap_size);
200 static inline const struct jailhouse_pci_capability *
201 jailhouse_cell_pci_caps(const struct jailhouse_cell_desc *cell)
203 return (const struct jailhouse_pci_capability *)
204 ((void *)jailhouse_cell_pci_devices(cell) +
205 cell->num_pci_devices * sizeof(struct jailhouse_pci_device));
208 #endif /* !_JAILHOUSE_CELL_CONFIG_H */