]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
x86: Provide PM timer access to all cells
authorJan Kiszka <jan.kiszka@siemens.com>
Sun, 6 Jul 2014 09:06:07 +0000 (11:06 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Sun, 6 Jul 2014 09:54:39 +0000 (11:54 +0200)
Export the PM timer address via the Communication Region to non-root
cells and allow access to that port for all cells. This is safe as the
PM timer hardware is specified to be read-only.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Documentation/hypervisor-interfaces.txt
hypervisor/arch/arm/include/asm/jailhouse_hypercall.h
hypervisor/arch/x86/control.c
hypervisor/arch/x86/include/asm/jailhouse_hypercall.h
hypervisor/arch/x86/vmx.c
hypervisor/include/jailhouse/hypercall.h

index 82cd6b59939ad57935406443469891eb249d6239..6726e451ed76e7d1fbe2a8eac8a2ab82a0440780 100644 (file)
@@ -228,9 +228,16 @@ Communication region layout
         |  Message from Cell (32 bit)  |
         +------------------------------+
         |     Cell State (32 bit)      |
+        +------------------------------+
+        |      Reserved (32 bit)       |
+        +------------------------------+
+        :     Platform Information     :
         +------------------------------+ - higher address
 
-All fields use the native endianness of the system.
+All fields use the native endianness of the system. The format is of the
+Platform Information part is architecture-specific. Its content is filled by
+the hypervisor during cell creation and shall be considered read-only until
+cell destruction.
 
 
 Logical Channel "Message"
@@ -307,6 +314,16 @@ to destroy or restart that cell. On restart, it will also reset the state field
 to "Running".
 
 
+Platform Information for x86
+- - - - - - - - - - - - - - -
+
+        +------------------------------+ - begin of communication region
+        :   generic part, see above    :   (lower address)
+        +------------------------------+
+        |   PM Timer Address (16 bit)  |
+        +------------------------------+ - higher address
+
+
 References
 ----------
 
index 7a07f2749f6a9ff9c953e0591bd4978b7331511d..196713893e98bff7cd6b0142376bd2b02099a43b 100644 (file)
 
 #ifndef __ASSEMBLY__
 
+struct jailhouse_comm_region {
+       COMM_REGION_GENERIC_HEADER;
+};
+
 static inline __u32 jailhouse_call(__u32 num)
 {
        register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
index d4efa1a58d1ef7e1d0a95d950b9dc547fa3a4a8a..5d3468df35e096ccc060ca85380e4095d7d861ba 100644 (file)
@@ -44,6 +44,9 @@ int arch_cell_create(struct per_cpu *cpu_data, struct cell *cell)
        ioapic_cell_init(cell);
        ioapic_root_cell_shrink(cell->config);
 
+       cell->comm_page.comm_region.pm_timer_address =
+               system_config->platform_info.x86.pm_timer_address;
+
        return 0;
 }
 
index 9145e6e778da68c42a6801c0fff6dc558cc7fe02..54cd22873e787f51cf16eb9710c00ae83c39ab7f 100644 (file)
 
 #ifndef __ASSEMBLY__
 
+struct jailhouse_comm_region {
+       COMM_REGION_GENERIC_HEADER;
+
+       __u16 pm_timer_address;
+};
+
 static inline __u32 jailhouse_call(__u32 num)
 {
        __u32 result;
index d6172e6e4cd8b6e4d88aaa3a13965115b519a30e..e6b97a76d9c2b38e392fc8503b466e39be09fbbe 100644 (file)
@@ -259,10 +259,15 @@ int vmx_cell_init(struct cell *cell)
 {
        const u8 *pio_bitmap = jailhouse_cell_pio_bitmap(cell->config);
        u32 pio_bitmap_size = cell->config->pio_bitmap_size;
-       int n, err;
+       unsigned int n, pm_timer_addr;
        u32 size;
+       int err;
        u8 *b;
 
+       /* PM timer has to be provided */
+       if (system_config->platform_info.x86.pm_timer_address == 0)
+               return -EINVAL;
+
        /* build root EPT of cell */
        cell->vmx.ept_structs.root_paging = ept_paging;
        cell->vmx.ept_structs.root_table = page_alloc(&mem_pool, 1);
@@ -301,6 +306,13 @@ int vmx_cell_init(struct cell *cell)
                        *b |= ~*pio_bitmap;
        }
 
+       /* permit access to the PM timer */
+       pm_timer_addr = system_config->platform_info.x86.pm_timer_address;
+       for (n = 0; n < 4; n++, pm_timer_addr++) {
+               b = cell->vmx.io_bitmap;
+               b[pm_timer_addr / 8] &= ~(1 << (pm_timer_addr % 8));
+       }
+
        return 0;
 }
 
index 9cbc807b1f296c507ff7ee218b659ffbab80caf3..072874d081c740f922aba97485c5817ef17ad526 100644 (file)
 #define JAILHOUSE_CELL_SHUT_DOWN               2 /* terminal state */
 #define JAILHOUSE_CELL_FAILED                  3 /* terminal state */
 
-#ifndef __ASSEMBLY__
-
-struct jailhouse_comm_region {
-       volatile __u32 msg_to_cell;
-       volatile __u32 reply_from_cell;
-
-       volatile __u32 cell_state;
-
-       /* errors etc. */
-};
-
-#endif /* !__ASSEMBLY__ */
+#define COMM_REGION_GENERIC_HEADER             \
+       volatile __u32 msg_to_cell;             \
+       volatile __u32 reply_from_cell;         \
+       volatile __u32 cell_state;              \
+       volatile __u32 padding
 
 #include <asm/jailhouse_hypercall.h>