@@ -985,7 +985,6 @@ void __init create_domUs(void)
panic("Error initializing LLC coloring for domain %s (rc = %d)\n",
dt_node_name(node), rc);
- d->is_console = true;
dt_device_set_used_by(node, d->domain_id);
rc = construct_domU(d, node);
@@ -238,6 +238,8 @@ void __init pv_shim_setup_dom(struct domain *d, l4_pgentry_t *l4start,
* guest from depleting the shim memory pool.
*/
d->max_pages = domain_tot_pages(d);
+
+ d->is_console = true;
}
static void write_start_info(struct domain *d)
@@ -706,6 +706,8 @@ struct domain *domain_create(domid_t domid,
old_hwdom = hardware_domain;
hardware_domain = d;
+
+ d->is_console = true;
}
TRACE_TIME(TRC_DOM0_DOM_ADD, d->domain_id);
@@ -1,8 +1,8 @@
/******************************************************************************
* console.c
- *
+ *
* Emergency console I/O for Xen and the domain-0 guest OS.
- *
+ *
* Copyright (c) 2002-2004, K A Fraser.
*
* Added printf_ratelimit
@@ -473,11 +473,26 @@ static unsigned int __read_mostly console_owner = 0;
#define max_console_rx (max_init_domid + 1)
+static struct domain *console_get_domain_by_id(domid_t domid)
+{
+ struct domain *d = rcu_lock_domain_by_id(domid);
+
+ if ( !d )
+ return NULL;
+
+ if ( d->is_console )
+ return d;
+
+ rcu_unlock_domain(d);
+
+ return NULL;
+}
+
struct domain *console_get_domain(void)
{
if ( console_owner == 0 )
return NULL;
- return rcu_lock_domain_by_id(console_owner - 1);
+ return console_get_domain_by_id(console_owner - 1);
}
void console_put_domain(struct domain *d)
@@ -486,6 +501,15 @@ void console_put_domain(struct domain *d)
rcu_unlock_domain(d);
}
+static bool console_owner_possible(domid_t domid)
+{
+ struct domain *d = console_get_domain_by_id(domid);
+
+ console_put_domain(d);
+
+ return !!d;
+}
+
static void console_switch_input(void)
{
unsigned int next_rx = console_owner;
@@ -497,7 +521,6 @@ static void console_switch_input(void)
for ( ; ; )
{
domid_t domid;
- struct domain *d;
if ( next_rx++ >= max_console_rx )
{
@@ -510,10 +533,9 @@ static void console_switch_input(void)
domid = get_initial_domain_id();
else
domid = next_rx - 1;
- d = rcu_lock_domain_by_id(domid);
- if ( d )
+
+ if ( console_owner_possible(domid) )
{
- rcu_unlock_domain(d);
console_owner = next_rx;
printk("*** Serial input to DOM%u", domid);
break;
@@ -562,8 +584,19 @@ static void __serial_rx(char c)
/* Deliver input to the PV shim console. */
rc = consoled_guest_tx(c);
- if ( rc )
- printk(KERN_ERR "d%pd: failed to process console input: %d\n", d, rc);
+ switch ( rc )
+ {
+ case 0:
+ break;
+ case -EBUSY: /* Loopback mode */
+ case -ENOSPC: /* FIFO is full */
+ printk(KERN_WARNING "d%pd: failed to process console input: %d\n", d, rc);
+ break;
+ default:
+ d->is_console = false;
+ printk(KERN_ERR "d%pd: disabled console forwarding: %d\n", d, rc);
+ break;
+ }
console_put_domain(d);
}
@@ -807,7 +840,7 @@ static int printk_prefix_check(char *p, char **pp)
return ((atomic_read(&print_everything) != 0) ||
(loglvl < lower_thresh) ||
((loglvl < upper_thresh) && printk_ratelimit()));
-}
+}
static int cf_check parse_console_timestamps(const char *s)
{
@@ -20,6 +20,7 @@ int virtdev_uart_init(struct domain *d, struct virtdev_uart_params *params)
#if !defined(__i386__) && !defined(__x86_64__)
d->arch.emulation_flags |= VIRTDEV_UART;
#endif
+ d->is_console = true;
return 0;
}
@@ -33,6 +34,7 @@ void virtdev_uart_exit(struct domain *d)
#if !defined(__i386__) && !defined(__x86_64__)
d->arch.emulation_flags &= ~VIRTDEV_UART;
#endif
+ d->is_console = false;
}
int virtdev_uart_putchar(struct domain *d, char c)