[PATCH v8 2/2] xen: enable dom0less guests to use console_io hypercalls

Stefano Stabellini posted 2 patches 1 week, 3 days ago
There is a newer version of this series
[PATCH v8 2/2] xen: enable dom0less guests to use console_io hypercalls
Posted by Stefano Stabellini 1 week, 3 days ago
Enable dom0less guests on ARM to use console_io hypercalls:
- set input_allow = true for dom0less domains
- update the in-code comment in console.c
- prioritize the VUART check to retain the same behavior as today

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
---
Changes in v8:
- move in-code comment update to previous patch
- add in-code comment about is_focus_domain() check
---
 xen/common/device-tree/dom0less-build.c |  2 ++
 xen/drivers/char/console.c              | 16 ++++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tree/dom0less-build.c
index 840d14419d..cb7026fa7e 100644
--- a/xen/common/device-tree/dom0less-build.c
+++ b/xen/common/device-tree/dom0less-build.c
@@ -829,6 +829,8 @@ static int __init construct_domU(struct kernel_info *kinfo,
 
     rangeset_destroy(kinfo->xen_reg_assigned);
 
+    d->console->input_allowed = true;
+
     return rc;
 }
 
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index ed8f1ad8f2..418d194cef 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -613,11 +613,20 @@ static void __serial_rx(char c)
     if ( console_rx == 0 )
         return handle_keypress(c, false);
 
+    /* Includes an is_focus_domain() check. */
     d = console_get_domain();
     if ( !d )
         return;
 
-    if ( is_hardware_domain(d) )
+#ifdef CONFIG_SBSA_VUART_CONSOLE
+    /* Prioritize vpl011 if enabled for this domain */
+    if ( d->arch.vpl011.base_addr )
+    {
+        /* Deliver input to the emulated UART. */
+        rc = vpl011_rx_char_xen(d, c);
+    }
+    else
+#endif
     {
         unsigned long flags;
 
@@ -636,11 +645,6 @@ static void __serial_rx(char c)
          */
         send_global_virq(VIRQ_CONSOLE);
     }
-#ifdef CONFIG_SBSA_VUART_CONSOLE
-    else
-        /* Deliver input to the emulated UART. */
-        rc = vpl011_rx_char_xen(d, c);
-#endif
 
     if ( consoled_is_enabled() )
         /* Deliver input to the PV shim console. */
-- 
2.25.1
Re: [PATCH v8 2/2] xen: enable dom0less guests to use console_io hypercalls
Posted by Jason Andryuk 1 week, 3 days ago
On 2026-01-29 17:08, Stefano Stabellini wrote:
> Enable dom0less guests on ARM to use console_io hypercalls:
> - set input_allow = true for dom0less domains
> - update the in-code comment in console.c
> - prioritize the VUART check to retain the same behavior as today
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> ---
> Changes in v8:
> - move in-code comment update to previous patch
> - add in-code comment about is_focus_domain() check
> ---
>   xen/common/device-tree/dom0less-build.c |  2 ++
>   xen/drivers/char/console.c              | 16 ++++++++++------
>   2 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tree/dom0less-build.c
> index 840d14419d..cb7026fa7e 100644
> --- a/xen/common/device-tree/dom0less-build.c
> +++ b/xen/common/device-tree/dom0less-build.c
> @@ -829,6 +829,8 @@ static int __init construct_domU(struct kernel_info *kinfo,
>   
>       rangeset_destroy(kinfo->xen_reg_assigned);
>   
> +    d->console->input_allowed = true;
> +
>       return rc;
>   }
>   
> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
> index ed8f1ad8f2..418d194cef 100644
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -613,11 +613,20 @@ static void __serial_rx(char c)
>       if ( console_rx == 0 )
>           return handle_keypress(c, false);
>   
> +    /* Includes an is_focus_domain() check. */
>       d = console_get_domain();
>       if ( !d )
>           return;
>   
> -    if ( is_hardware_domain(d) )
> +#ifdef CONFIG_SBSA_VUART_CONSOLE
> +    /* Prioritize vpl011 if enabled for this domain */
> +    if ( d->arch.vpl011.base_addr )
> +    {
> +        /* Deliver input to the emulated UART. */
> +        rc = vpl011_rx_char_xen(d, c);
> +    }
> +    else
> +#endif
>       {
>           unsigned long flags;
>   
> @@ -636,11 +645,6 @@ static void __serial_rx(char c)
>            */
>           send_global_virq(VIRQ_CONSOLE);

I think we need an additional patch, or included in one of these two, to 
change VIRQ_CONSOLE to a VIRQ_DOMAIN.  Otherwise only hwdom could bind 
to the virq, I think?  It would be the two changes below:

Regards,
Jason

diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index 67700b050a..dab123f20d 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -138,6 +138,7 @@ static enum virq_type get_virq_type(unsigned int virq)
          return VIRQ_VCPU;

      case VIRQ_ARGO:
+    case VIRQ_CONSOLE:
          return VIRQ_DOMAIN;

      case VIRQ_ARCH_0 ... VIRQ_ARCH_7:
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 903ad912cc..138eeaa14d 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -611,7 +611,7 @@ static void __serial_rx(char c)
           * Always notify the hardware domain: prevents receive path from
           * getting stuck.
           */
-        send_global_virq(VIRQ_CONSOLE);
+        send_guest_domain_virq(d, VIRQ_CONSOLE);
      }
  #ifdef CONFIG_SBSA_VUART_CONSOLE
      else
Re: [PATCH v8 2/2] xen: enable dom0less guests to use console_io hypercalls
Posted by Stefano Stabellini 6 days, 21 hours ago
On Thu, 29 Jan 2026, Jason Andryuk wrote:
> On 2026-01-29 17:08, Stefano Stabellini wrote:
> > Enable dom0less guests on ARM to use console_io hypercalls:
> > - set input_allow = true for dom0less domains
> > - update the in-code comment in console.c
> > - prioritize the VUART check to retain the same behavior as today
> > 
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> > ---
> > Changes in v8:
> > - move in-code comment update to previous patch
> > - add in-code comment about is_focus_domain() check
> > ---
> >   xen/common/device-tree/dom0less-build.c |  2 ++
> >   xen/drivers/char/console.c              | 16 ++++++++++------
> >   2 files changed, 12 insertions(+), 6 deletions(-)
> > 
> > diff --git a/xen/common/device-tree/dom0less-build.c
> > b/xen/common/device-tree/dom0less-build.c
> > index 840d14419d..cb7026fa7e 100644
> > --- a/xen/common/device-tree/dom0less-build.c
> > +++ b/xen/common/device-tree/dom0less-build.c
> > @@ -829,6 +829,8 @@ static int __init construct_domU(struct kernel_info
> > *kinfo,
> >         rangeset_destroy(kinfo->xen_reg_assigned);
> >   +    d->console->input_allowed = true;
> > +
> >       return rc;
> >   }
> >   diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
> > index ed8f1ad8f2..418d194cef 100644
> > --- a/xen/drivers/char/console.c
> > +++ b/xen/drivers/char/console.c
> > @@ -613,11 +613,20 @@ static void __serial_rx(char c)
> >       if ( console_rx == 0 )
> >           return handle_keypress(c, false);
> >   +    /* Includes an is_focus_domain() check. */
> >       d = console_get_domain();
> >       if ( !d )
> >           return;
> >   -    if ( is_hardware_domain(d) )
> > +#ifdef CONFIG_SBSA_VUART_CONSOLE
> > +    /* Prioritize vpl011 if enabled for this domain */
> > +    if ( d->arch.vpl011.base_addr )
> > +    {
> > +        /* Deliver input to the emulated UART. */
> > +        rc = vpl011_rx_char_xen(d, c);
> > +    }
> > +    else
> > +#endif
> >       {
> >           unsigned long flags;
> >   @@ -636,11 +645,6 @@ static void __serial_rx(char c)
> >            */
> >           send_global_virq(VIRQ_CONSOLE);
> 
> I think we need an additional patch, or included in one of these two, to
> change VIRQ_CONSOLE to a VIRQ_DOMAIN.  Otherwise only hwdom could bind to the
> virq, I think?  It would be the two changes below:

Thank you Jason. I didn't notice this problem because Linux is able to
silently fallback to polling which works surprisingly well. I didn't
notice the difference.

I confirm that the error you highlighted is real and that with the patch
below the error goes away.

My preference is to submit it as a separate patch, it can still be part
of this series. Especially as the other two patches have already been
reviewed and tested independently a few times. But I am happy either
way.

Jan, what do you think?

 
> diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
> index 67700b050a..dab123f20d 100644
> --- a/xen/common/event_channel.c
> +++ b/xen/common/event_channel.c
> @@ -138,6 +138,7 @@ static enum virq_type get_virq_type(unsigned int virq)
>          return VIRQ_VCPU;
> 
>      case VIRQ_ARGO:
> +    case VIRQ_CONSOLE:
>          return VIRQ_DOMAIN;
> 
>      case VIRQ_ARCH_0 ... VIRQ_ARCH_7:
> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
> index 903ad912cc..138eeaa14d 100644
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -611,7 +611,7 @@ static void __serial_rx(char c)
>           * Always notify the hardware domain: prevents receive path from
>           * getting stuck.
>           */
> -        send_global_virq(VIRQ_CONSOLE);
> +        send_guest_domain_virq(d, VIRQ_CONSOLE);
>      }
>  #ifdef CONFIG_SBSA_VUART_CONSOLE
>      else
>
Re: [PATCH v8 2/2] xen: enable dom0less guests to use console_io hypercalls
Posted by Jan Beulich 6 days, 14 hours ago
On 03.02.2026 01:11, Stefano Stabellini wrote:
> On Thu, 29 Jan 2026, Jason Andryuk wrote:
>> On 2026-01-29 17:08, Stefano Stabellini wrote:
>>> --- a/xen/drivers/char/console.c
>>> +++ b/xen/drivers/char/console.c
>>> @@ -613,11 +613,20 @@ static void __serial_rx(char c)
>>>       if ( console_rx == 0 )
>>>           return handle_keypress(c, false);
>>>   +    /* Includes an is_focus_domain() check. */
>>>       d = console_get_domain();
>>>       if ( !d )
>>>           return;
>>>   -    if ( is_hardware_domain(d) )
>>> +#ifdef CONFIG_SBSA_VUART_CONSOLE
>>> +    /* Prioritize vpl011 if enabled for this domain */
>>> +    if ( d->arch.vpl011.base_addr )
>>> +    {
>>> +        /* Deliver input to the emulated UART. */
>>> +        rc = vpl011_rx_char_xen(d, c);
>>> +    }
>>> +    else
>>> +#endif
>>>       {
>>>           unsigned long flags;
>>>   @@ -636,11 +645,6 @@ static void __serial_rx(char c)
>>>            */
>>>           send_global_virq(VIRQ_CONSOLE);
>>
>> I think we need an additional patch, or included in one of these two, to
>> change VIRQ_CONSOLE to a VIRQ_DOMAIN.  Otherwise only hwdom could bind to the
>> virq, I think?  It would be the two changes below:
> 
> Thank you Jason. I didn't notice this problem because Linux is able to
> silently fallback to polling which works surprisingly well. I didn't
> notice the difference.
> 
> I confirm that the error you highlighted is real and that with the patch
> below the error goes away.
> 
> My preference is to submit it as a separate patch, it can still be part
> of this series. Especially as the other two patches have already been
> reviewed and tested independently a few times. But I am happy either
> way.
> 
> Jan, what do you think?

Imo this wants to be a separate change, yes. Likely a prereq one.

Jan