The console page is implemented as ring buffer, and will _not_ contain a trailing \0 for string termination.
Signed-off-by: Ralf Ramsauer <[email protected]> --- hypervisor/hypervisor.lds.S | 6 ++++++ hypervisor/include/jailhouse/cell-config.h | 6 ++++++ hypervisor/include/jailhouse/header.h | 8 ++++++++ hypervisor/include/jailhouse/printk.h | 2 ++ hypervisor/printk.c | 2 ++ 5 files changed, 24 insertions(+) diff --git a/hypervisor/hypervisor.lds.S b/hypervisor/hypervisor.lds.S index 09b1a0b2e3..f81782820d 100644 --- a/hypervisor/hypervisor.lds.S +++ b/hypervisor/hypervisor.lds.S @@ -35,6 +35,12 @@ SECTIONS . = ALIGN(16); .bss : { *(.bss) } + /* The console section shall only contain the hypervisor console. This + * section and the next section must be aligned to PAGE_SIZE, as we + * want the console section to reserve a whole page */ + . = ALIGN(PAGE_SIZE); + .console : { *(.console) } + . = ALIGN(PAGE_SIZE); __page_pool = .; diff --git a/hypervisor/include/jailhouse/cell-config.h b/hypervisor/include/jailhouse/cell-config.h index 80fa5a78b4..67b3319eca 100644 --- a/hypervisor/include/jailhouse/cell-config.h +++ b/hypervisor/include/jailhouse/cell-config.h @@ -192,6 +192,12 @@ struct jailhouse_iommu { #define CON1_IS_MMIO(flags) ((flags) & JAILHOUSE_CON1_FLAG_MMIO) +/* Bits 16..19 are used to select the second console driver */ +#define JAILHOUSE_CON2_TYPE_ROOTPAGE 0x0100 +#define JAILHOUSE_CON2_TYPE_MASK 0x0f00 + +#define CON2_TYPE(flags) ((flags) & JAILHOUSE_CON2_TYPE_MASK) + struct jailhouse_debug_console { __u64 address; __u32 size; diff --git a/hypervisor/include/jailhouse/header.h b/hypervisor/include/jailhouse/header.h index 4fe159c621..ccb9684243 100644 --- a/hypervisor/include/jailhouse/header.h +++ b/hypervisor/include/jailhouse/header.h @@ -24,6 +24,14 @@ */ typedef int (*jailhouse_entry)(unsigned int); +struct jailhouse_console { + unsigned int lock; + unsigned int tail; + /* current implementation requires the size of the content to be a + * power of two */ + char content[2048]; +}; + /** * Hypervisor description. * Located at the beginning of the hypervisor binary image and loaded by diff --git a/hypervisor/include/jailhouse/printk.h b/hypervisor/include/jailhouse/printk.h index a506c0fddf..f2bed6e292 100644 --- a/hypervisor/include/jailhouse/printk.h +++ b/hypervisor/include/jailhouse/printk.h @@ -27,3 +27,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 volatile struct jailhouse_console console; diff --git a/hypervisor/printk.c b/hypervisor/printk.c index e8f5ffe289..ca54b60dce 100644 --- a/hypervisor/printk.c +++ b/hypervisor/printk.c @@ -18,6 +18,8 @@ #include <asm/bitops.h> #include <asm/spinlock.h> +volatile struct jailhouse_console console __attribute__((section(".console"))); + static DEFINE_SPINLOCK(printk_lock); #define console_write(msg) arch_dbg_write(msg) -- 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.
