|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v3 24/24] xen/console: unify printout behavior for UART emulators
From: Denis Mukhin <dmukhin@xxxxxxxx>
If virtual UART prints on the physical console, the behavior is updated to:
- no prefix for Dom0 output;
- DOM$NUM for DomUs when not in focus, otherwise no prefix.
Introduce printk_noprefix() for convenient printouts which skip '(XEN)'
prefix on the physical console. This is needed for the case when physical
console is owned by a domain with in-hypervisor UART emulation enabled.
Add printk_noprefix() to exception into ECLAIR deviations list for
rule MC3A2.R17.1.
Use guest_printk() in all current in-hypervisor UART emulators. That aligns
behavior with debug I/O port 0xe9 handler in x86 port and slightly improves the
logging since guest_printk() already prints the domain ID.
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
automation/eclair_analysis/ECLAIR/deviations.ecl | 1 +
xen/arch/arm/vpl011.c | 6 +++---
xen/arch/arm/vuart.c | 8 +++++++-
xen/arch/x86/hvm/vuart-ns16550.c | 7 +++++--
xen/drivers/char/console.c | 8 ++++++++
xen/include/xen/lib.h | 3 +++
6 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index
ae25eeb76ac938588d16c9b4f9f116ddcaf97956..d94a8bc59d0b562cc285bb236dbac41a151042ac
100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -523,6 +523,7 @@ safe."
-config=MC3A2.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(panic)&&kind(function))))"}
-config=MC3A2.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(elf_call_log_callback)&&kind(function))))"}
-config=MC3A2.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(vprintk_common)&&kind(function))))"}
+-config=MC3A2.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(printk_noprefix)&&kind(function))))"}
-config=MC3A2.R17.1,macros+={hide , "^va_(arg|start|copy|end)$"}
-doc_end
diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c
index
efe77c13007716d0e0d70ab5ccf5f94268d5b693..ab85893174e76c5ec4350931a030760c9e0331b0
100644
--- a/xen/arch/arm/vpl011.c
+++ b/xen/arch/arm/vpl011.c
@@ -89,7 +89,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t
data)
{
if ( intf->out_prod == 1 )
{
- printk("%c", data);
+ printk_noprefix("%c", data);
intf->out_prod = 0;
}
else
@@ -97,7 +97,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t
data)
if ( data != '\n' )
intf->out[intf->out_prod++] = '\n';
intf->out[intf->out_prod++] = '\0';
- printk("%s", intf->out);
+ printk_noprefix("%s", intf->out);
intf->out_prod = 0;
}
}
@@ -109,7 +109,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t
data)
if ( data != '\n' )
intf->out[intf->out_prod++] = '\n';
intf->out[intf->out_prod++] = '\0';
- printk("DOM%u: %s", d->domain_id, intf->out);
+ guest_printk(d, "%s", intf->out);
intf->out_prod = 0;
}
}
diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c
index
03366da17a604502f6e0afb45e8824c9d7cfa3dd..0e0fba344b68760463e894dc43133121bccbd960
100644
--- a/xen/arch/arm/vuart.c
+++ b/xen/arch/arm/vuart.c
@@ -31,6 +31,7 @@
#include <xen/serial.h>
#include <asm/mmio.h>
#include <xen/perfc.h>
+#include <xen/console.h>
#include "vuart.h"
@@ -87,7 +88,12 @@ static void hwdom_vuart_print_char(struct vcpu *v, char c)
if ( c != '\n' )
uart->buf[uart->idx++] = '\n';
uart->buf[uart->idx] = '\0';
- printk(XENLOG_G_DEBUG "DOM%u: %s", d->domain_id, uart->buf);
+
+ if ( d->domain_id == console_get_owner() )
+ printk_noprefix("%s", uart->buf);
+ else
+ guest_printk(d, "%s", uart->buf);
+
uart->idx = 0;
}
spin_unlock(&uart->lock);
diff --git a/xen/arch/x86/hvm/vuart-ns16550.c b/xen/arch/x86/hvm/vuart-ns16550.c
index
d0c19f53399bd8241f54d2fe2716e62046b8e59d..67cc7e9acc396a2f4346aebeef85d4b96c0d0e3f
100644
--- a/xen/arch/x86/hvm/vuart-ns16550.c
+++ b/xen/arch/x86/hvm/vuart-ns16550.c
@@ -35,6 +35,7 @@
#include <asm/setup.h> /* max_init_domid */
#include <public/io/console.h>
#include <xen/8250-uart.h>
+#include <xen/console.h>
#include <xen/ctype.h>
#include <xen/ioreq.h>
#include <xen/resource.h>
@@ -899,10 +900,12 @@ static int cf_check ns16550_putchar(struct domain *d,
char ch)
regs[UART_LSR] |= UART_LSR_DR | val;
/*
- * Echo the user input on Xen console.
+ * Echo the user input on Xen console iff Xen console input is owned
+ * by NS16550 domain.
* NB: use 'console_timestamps=none' to disable Xen timestamps.
*/
- printk("%c", ch);
+ if ( d->domain_id == console_get_owner() )
+ printk_noprefix("%c", ch);
/* FIXME: check FCR when to fire an interrupt */
ns16550_irq_check(vdev);
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index
96375067164980a138b1a93161712c0758f4f7fe..64abde479305910d1a962e68d5c1f0c25000cb3d
100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -1026,6 +1026,14 @@ void printk(const char *fmt, ...)
va_end(args);
}
+void printk_noprefix(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintk_common("", fmt, args);
+ va_end(args);
+}
+
void guest_printk(const struct domain *d, const char *fmt, ...)
{
va_list args;
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index
81b722ea3e801e9089aaf8758249feb3a758c4f7..e55b8fac8d4d121262a56948638d83f1146e5a06
100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -61,6 +61,9 @@ debugtrace_printk(const char *fmt, ...) {}
extern void printk(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2), cold));
+extern void printk_noprefix(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2), cold));
+
#define printk_once(fmt, args...) \
({ \
static bool __read_mostly once_; \
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |