On 2017-01-16 17:07, Ralf Ramsauer wrote:
> 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 68596e84..4c8e5224 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 console_print;
Should probably be called something like "virtual_console", to
differentiate from the UARTs.
> extern struct jailhouse_console console;
> diff --git a/hypervisor/printk.c b/hypervisor/printk.c
> index 994a0432..aad6dadc 100644
> --- a/hypervisor/printk.c
> +++ b/hypervisor/printk.c
> @@ -18,6 +18,7 @@
> #include <asm/bitops.h>
> #include <asm/spinlock.h>
>
> +bool console_print = false;
> struct jailhouse_console console __attribute__((section(".console")));
>
> static DEFINE_SPINLOCK(printk_lock);
> diff --git a/hypervisor/setup.c b/hypervisor/setup.c
> index 8cfa4555..12e563ba 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)
> + console_print = 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 (console_print &&
> + 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;
>
Jan
--
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
--
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.