We're backing hypervisor pages with an empty page for the root cell. This commit excludes the console page and allows RO access to it, but only if the debug console of system configuration has the flag JAILHOUSE_CON2_TYPE_ROOTPAGE set.
This flag is not activated by default and has to be set manually. In this way, the Linux driver may easily read out the console without any interactions with the hypervisor. Signed-off-by: Ralf Ramsauer <[email protected]> --- hypervisor/include/jailhouse/printk.h | 1 + hypervisor/printk.c | 1 + hypervisor/setup.c | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/hypervisor/include/jailhouse/printk.h b/hypervisor/include/jailhouse/printk.h index f2bed6e292..e775e97564 100644 --- a/hypervisor/include/jailhouse/printk.h +++ b/hypervisor/include/jailhouse/printk.h @@ -28,4 +28,5 @@ void __attribute__((format(printf, 1, 2))) panic_printk(const char *fmt, ...); void arch_dbg_write_init(void); extern void (*arch_dbg_write)(const char *msg); +extern bool virtual_console; extern volatile struct jailhouse_console console; diff --git a/hypervisor/printk.c b/hypervisor/printk.c index ca54b60dce..117fe74c96 100644 --- a/hypervisor/printk.c +++ b/hypervisor/printk.c @@ -18,6 +18,7 @@ #include <asm/bitops.h> #include <asm/spinlock.h> +bool virtual_console = false; volatile struct jailhouse_console console __attribute__((section(".console"))); static DEFINE_SPINLOCK(printk_lock); diff --git a/hypervisor/setup.c b/hypervisor/setup.c index 8cfa455510..9b1c0c1df7 100644 --- a/hypervisor/setup.c +++ b/hypervisor/setup.c @@ -41,6 +41,10 @@ static void init_early(unsigned int cpu_id) system_config = (struct jailhouse_system *) (JAILHOUSE_BASE + core_and_percpu_size); + if (CON2_TYPE(system_config->debug_console.flags) == + JAILHOUSE_CON2_TYPE_ROOTPAGE) + virtual_console = true; + arch_dbg_write_init(); printk("\nInitializing Jailhouse hypervisor %s on CPU %d\n", @@ -65,6 +69,9 @@ static void init_early(unsigned int cpu_id) * Back the region of the hypervisor core and per-CPU page with empty * pages for Linux. This allows to fault-in the hypervisor region into * Linux' page table before shutdown without triggering violations. + * + * Allow read access to the console page, if the hypervisor has the + * debug console flag JAILHOUSE_CON2_TYPE_ROOTPAGE set. */ hyp_phys_start = system_config->hypervisor_memory.phys_start; hyp_phys_end = hyp_phys_start + system_config->hypervisor_memory.size; @@ -74,6 +81,11 @@ static void init_early(unsigned int cpu_id) hv_page.size = PAGE_SIZE; hv_page.flags = JAILHOUSE_MEM_READ; while (hv_page.virt_start < hyp_phys_end) { + if (virtual_console && + hv_page.virt_start == paging_hvirt2phys(&console)) + hv_page.phys_start = paging_hvirt2phys(&console); + else + hv_page.phys_start = paging_hvirt2phys(empty_page); error = arch_map_memory_region(&root_cell, &hv_page); if (error) return; -- 2.11.0 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
