From: Jan Kiszka Date: Sun, 6 Jul 2014 09:06:07 +0000 (+0200) Subject: x86: Provide PM timer access to all cells X-Git-Url: https://rtime.felk.cvut.cz/gitweb/jailhouse.git/commitdiff_plain/cebf6a2cd83da41bc7a245bfb09de207660db026 x86: Provide PM timer access to all cells 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 --- diff --git a/Documentation/hypervisor-interfaces.txt b/Documentation/hypervisor-interfaces.txt index 82cd6b5..6726e45 100644 --- a/Documentation/hypervisor-interfaces.txt +++ b/Documentation/hypervisor-interfaces.txt @@ -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 ---------- diff --git a/hypervisor/arch/arm/include/asm/jailhouse_hypercall.h b/hypervisor/arch/arm/include/asm/jailhouse_hypercall.h index 7a07f27..1967138 100644 --- a/hypervisor/arch/arm/include/asm/jailhouse_hypercall.h +++ b/hypervisor/arch/arm/include/asm/jailhouse_hypercall.h @@ -27,6 +27,10 @@ #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; diff --git a/hypervisor/arch/x86/control.c b/hypervisor/arch/x86/control.c index d4efa1a..5d3468d 100644 --- a/hypervisor/arch/x86/control.c +++ b/hypervisor/arch/x86/control.c @@ -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; } diff --git a/hypervisor/arch/x86/include/asm/jailhouse_hypercall.h b/hypervisor/arch/x86/include/asm/jailhouse_hypercall.h index 9145e6e..54cd228 100644 --- a/hypervisor/arch/x86/include/asm/jailhouse_hypercall.h +++ b/hypervisor/arch/x86/include/asm/jailhouse_hypercall.h @@ -33,6 +33,12 @@ #ifndef __ASSEMBLY__ +struct jailhouse_comm_region { + COMM_REGION_GENERIC_HEADER; + + __u16 pm_timer_address; +}; + static inline __u32 jailhouse_call(__u32 num) { __u32 result; diff --git a/hypervisor/arch/x86/vmx.c b/hypervisor/arch/x86/vmx.c index d6172e6..e6b97a7 100644 --- a/hypervisor/arch/x86/vmx.c +++ b/hypervisor/arch/x86/vmx.c @@ -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; } diff --git a/hypervisor/include/jailhouse/hypercall.h b/hypervisor/include/jailhouse/hypercall.h index 9cbc807..072874d 100644 --- a/hypervisor/include/jailhouse/hypercall.h +++ b/hypervisor/include/jailhouse/hypercall.h @@ -62,18 +62,11 @@ #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