On 05.02.2026 00:37, Stefano Stabellini wrote:
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -541,6 +541,12 @@ void console_put_domain(struct domain *d)
>          rcu_unlock_domain(d);
>  }
>  
> +static bool is_focus_domain(const struct domain *d)
> +{
> +    ASSERT(rspin_is_locked(&console_lock));
> +    return d != NULL && d->domain_id == console_rx - 1;
> +}

Just as a remark: You using only nrspin_*() further down and in patch 3,
using rspin_is_locked() here is slightly irritating. It looks to be
technically correct, but maybe a comment is warranted nevertheless?

> @@ -559,6 +565,7 @@ static void console_switch_input(void)
>          {
>              nrspin_lock_irqsave(&console_lock, flags);
>              ACCESS_ONCE(console_rx) = 0;
> +            serial_rx_cons = serial_rx_prod;

I think you want to have the same comment here as you put ...

> @@ -581,6 +588,8 @@ static void console_switch_input(void)
>  
>              nrspin_lock_irqsave(&console_lock, flags);
>              ACCESS_ONCE(console_rx) = next_rx;
> +            /* Don't let the next dom read the previous dom's unread data. */
> +            serial_rx_cons = serial_rx_prod;

... here.

> @@ -610,7 +619,7 @@ static void __serial_rx(char c)
>          unsigned long flags;
>  
>          /*
> -         * Deliver input to the hardware domain buffer, unless it is
> +         * Deliver input to the focus domain buffer, unless it is
>           * already full.
>           */
>          nrspin_lock_irqsave(&console_lock, flags);

The conditional ahead of this comment isn't changed here yet, so changing the
comment is premature. (I'm pretty sure I said so before.)

Jan

Reply via email to