From: Andrew Cooper Date: Thu, 23 Nov 2017 10:59:59 +0000 (+0000) Subject: xen/console: Introduce console=xen X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d7e47e0b75960a28b04bea4d06a9931cda27238c;p=people%2Fiwj%2Fxen.git xen/console: Introduce console=xen Signed-off-by: Andrew Cooper --- diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 19d0e74f17..5882b04cf0 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -30,6 +30,7 @@ #include /* for do_console_io */ #include #include +#include /* console: comma-separated list of console outputs. */ static char __initdata opt_console[30] = OPT_CONSOLE_STR; @@ -83,6 +84,8 @@ static uint32_t conringc, conringp; static int __read_mostly sercon_handle = -1; +static bool __read_mostly opt_console_xen; /* console=xen */ + static DEFINE_SPINLOCK(console_lock); /* @@ -458,6 +461,19 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, int count) sercon_puts(kbuf); video_puts(kbuf); + if ( opt_console_xen ) + { + unsigned long tmp; + size_t len = strlen(kbuf); + + if ( xen_guest ) + xen_hypercall_console_write(kbuf, len); + else + asm volatile ( "rep outsb;" + : "=&S" (tmp), "=&c" (tmp) + : "0" (kbuf), "1" (len), "d" (0xe9) ); + } + if ( opt_console_to_ring ) { conring_puts(kbuf); @@ -567,6 +583,19 @@ static void __putstr(const char *str) sercon_puts(str); video_puts(str); + if ( opt_console_xen ) + { + unsigned long tmp; + size_t len = strlen(str); + + if ( xen_guest ) + xen_hypercall_console_write(str, len); + else + asm volatile ( "rep outsb;" + : "=&S" (tmp), "=&c" (tmp) + : "0" (str), "1" (len), "d" (0xe9) ); + } + conring_puts(str); if ( !console_locks_busted ) @@ -762,6 +791,8 @@ void __init console_init_preirq(void) p++; if ( !strncmp(p, "vga", 3) ) video_init(); + else if ( !strncmp(p, "xen", 3) ) + opt_console_xen = true; else if ( !strncmp(p, "none", 4) ) continue; else if ( (sh = serial_parse_handle(p)) >= 0 ) diff --git a/xen/include/asm-x86/guest/hypercall.h b/xen/include/asm-x86/guest/hypercall.h index 4bb749f240..d5fe535c03 100644 --- a/xen/include/asm-x86/guest/hypercall.h +++ b/xen/include/asm-x86/guest/hypercall.h @@ -99,6 +99,13 @@ static inline long xen_hypercall_memory_op(unsigned int cmd, void *arg) /* * Higher level hypercall helpers */ +static inline void xen_hypercall_console_write( + const char *buf, unsigned int count) +{ + (void)_hypercall64_3(long, __HYPERVISOR_console_io, + CONSOLEIO_write, count, buf); +} + static inline long xen_hypercall_shutdown(unsigned int reason) { return xen_hypercall_sched_op(SCHEDOP_shutdown, &reason); @@ -106,6 +113,12 @@ static inline long xen_hypercall_shutdown(unsigned int reason) #else /* CONFIG_XEN_GUEST */ +static inline void xen_hypercall_console_write( + const char *buf, unsigned int count) +{ + ASSERT_UNREACHABLE(); +} + static inline long xen_hypercall_shutdown(unsigned int reason) { ASSERT_UNREACHABLE();