[PATCH v2] xen/console: introduce domain_console struct

dmkhn@proton.me posted 1 patch 4 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20250617012713.57074-1-dmukhin@ford.com
There is a newer version of this series
xen/arch/arm/vpl011.c      |  2 +-
xen/arch/x86/hvm/hvm.c     | 26 ++++++++++++++++----------
xen/arch/x86/pv/shim.c     |  2 +-
xen/common/domain.c        | 18 ++++++++++--------
xen/drivers/char/console.c | 24 ++++++++++++++----------
xen/include/xen/sched.h    | 27 +++++++++++++++++----------
6 files changed, 59 insertions(+), 40 deletions(-)
[PATCH v2] xen/console: introduce domain_console struct
Posted by dmkhn@proton.me 4 months, 2 weeks ago
From: Denis Mukhin <dmukhin@ford.com>

Introduce domain_console for grouping data structures used for integrating
domain's diagnostic console with Xen's console driver.

Group all pbuf-related data structures under domain_console. Rename the moved
fields to plain .buf, .idx and .lock names, since all uses of the fields are
touched.

Bump the domain console buffer size to the closest power of 2 (256) and
rename the symbol to DOMAIN_CONSOLE_BUF_SIZE.

Move d->console->buf management under CONFIG_VERBOSE_DEBUG when the
HYPERCALL_console_io handler is enabled.

Finally, update the domain_console allocation code.

No functional change.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
Changes since v1:
- added new struct domain_console
- updated allocation code for domain's console data structure
- bumped the size of the domain's output buffer to 256
- put domain's console buffer treatment under CONFIG_VERBOSE_DEBUG

I addressed most of the v1 feedback here, since all fields of the domain's
console data structures are touched.

Domain's console input buffer question is not addressed because it looks like a
separate (big) patch.

Link to v1: https://lore.kernel.org/xen-devel/20250606194937.2412579-1-dmukhin@ford.com/
Link to CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/1870179848
---
 xen/arch/arm/vpl011.c      |  2 +-
 xen/arch/x86/hvm/hvm.c     | 26 ++++++++++++++++----------
 xen/arch/x86/pv/shim.c     |  2 +-
 xen/common/domain.c        | 18 ++++++++++--------
 xen/drivers/char/console.c | 24 ++++++++++++++----------
 xen/include/xen/sched.h    | 27 +++++++++++++++++----------
 6 files changed, 59 insertions(+), 40 deletions(-)

diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c
index 2b6f2a09bca6..f4a840da10c5 100644
--- a/xen/arch/arm/vpl011.c
+++ b/xen/arch/arm/vpl011.c
@@ -713,7 +713,7 @@ int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info)
     }
     else
     {
-        d->console.input_allowed = true;
+        d->console->input_allowed = true;
         vpl011->backend_in_domain = false;
 
         vpl011->backend.xen = xzalloc(struct vpl011_xen_backend);
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 056360d5fe50..4295d98ddeb1 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -559,7 +559,6 @@ void hvm_do_resume(struct vcpu *v)
 static int cf_check hvm_print_line(
     int dir, unsigned int port, unsigned int bytes, uint32_t *val)
 {
-    struct domain *cd = current->domain;
     char c = *val;
 
     ASSERT(bytes == 1 && port == XEN_HVM_DEBUGCONS_IOPORT);
@@ -570,17 +569,24 @@ static int cf_check hvm_print_line(
 
     if ( !is_console_printable(c) )
         return X86EMUL_OKAY;
-
-    spin_lock(&cd->pbuf_lock);
-    if ( c != '\n' )
-        cd->pbuf[cd->pbuf_idx++] = c;
-    if ( (cd->pbuf_idx == (DOMAIN_PBUF_SIZE - 1)) || (c == '\n') )
+#ifdef CONFIG_VERBOSE_DEBUG
+    else
     {
-        cd->pbuf[cd->pbuf_idx] = '\0';
-        guest_printk(cd, XENLOG_G_DEBUG "%s\n", cd->pbuf);
-        cd->pbuf_idx = 0;
+        struct domain *cd = current->domain;
+        struct domain_console *cons = cd->console;
+
+        spin_lock(&cons->lock);
+        if ( c != '\n' )
+            cons->buf[cons->idx++] = c;
+        if ( (cons->idx == (DOMAIN_CONSOLE_BUF_SIZE - 1)) || (c == '\n') )
+        {
+            cons->buf[cons->idx] = '\0';
+            guest_printk(cd, XENLOG_G_DEBUG "%s\n", cons->buf);
+            cons->idx = 0;
+        }
+        spin_unlock(&cons->lock);
     }
-    spin_unlock(&cd->pbuf_lock);
+#endif
 
     return X86EMUL_OKAY;
 }
diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c
index bc2a7dd5fae5..bd29c53a2d34 100644
--- a/xen/arch/x86/pv/shim.c
+++ b/xen/arch/x86/pv/shim.c
@@ -239,7 +239,7 @@ void __init pv_shim_setup_dom(struct domain *d, l4_pgentry_t *l4start,
      */
     d->max_pages = domain_tot_pages(d);
 
-    d->console.input_allowed = true;
+    d->console->input_allowed = true;
 }
 
 static void write_start_info(struct domain *d)
diff --git a/xen/common/domain.c b/xen/common/domain.c
index e566a1874795..578eb587e27e 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -669,7 +669,7 @@ static void _domain_destroy(struct domain *d)
     BUG_ON(!d->is_dying);
     BUG_ON(atomic_read(&d->refcnt) != DOMAIN_DESTROYED);
 
-    xfree(d->pbuf);
+    xfree(d->console);
 
     argo_destroy(d);
 
@@ -800,6 +800,11 @@ struct domain *domain_create(domid_t domid,
     if ( (d = alloc_domain_struct()) == NULL )
         return ERR_PTR(-ENOMEM);
 
+    err = -ENOMEM;
+    d->console = xvzalloc(typeof(*d->console));
+    if ( !d->console )
+        goto fail;
+
     /* Sort out our idea of is_system_domain(). */
     d->domain_id = domid;
     d->unique_id = get_unique_id();
@@ -832,7 +837,7 @@ struct domain *domain_create(domid_t domid,
         if ( old_hwdom )
             old_hwdom->cdf &= ~CDF_hardware;
 
-        d->console.input_allowed = true;
+        d->console->input_allowed = true;
     }
 
     /* Holding CDF_* internal flags. */
@@ -862,7 +867,9 @@ struct domain *domain_create(domid_t domid,
     spin_lock_init(&d->shutdown_lock);
     d->shutdown_code = SHUTDOWN_CODE_INVALID;
 
-    spin_lock_init(&d->pbuf_lock);
+#ifdef CONFIG_VERBOSE_DEBUG
+    spin_lock_init(&d->console->lock);
+#endif
 
     rwlock_init(&d->vnuma_rwlock);
 
@@ -955,11 +962,6 @@ struct domain *domain_create(domid_t domid,
     if ( (err = argo_init(d)) != 0 )
         goto fail;
 
-    err = -ENOMEM;
-    d->pbuf = xzalloc_array(char, DOMAIN_PBUF_SIZE);
-    if ( !d->pbuf )
-        goto fail;
-
     if ( (err = sched_init_domain(d, config->cpupool_id)) != 0 )
         goto fail;
 
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 616f4968b004..61a804c09a50 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -524,7 +524,7 @@ struct domain *console_get_domain(void)
     if ( !d )
         return NULL;
 
-    if ( d->console.input_allowed )
+    if ( d->console->input_allowed )
         return d;
 
     rcu_unlock_domain(d);
@@ -567,7 +567,7 @@ static void console_switch_input(void)
         {
             rcu_unlock_domain(d);
 
-            if ( !d->console.input_allowed )
+            if ( !d->console->input_allowed )
                 continue;
 
             console_rx = next_rx;
@@ -754,9 +754,11 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,
             console_send(kbuf, kcount, flags);
             nrspin_unlock_irq(&console_lock);
         }
+#ifdef CONFIG_VERBOSE_DEBUG
         else
         {
             char *kin = kbuf, *kout = kbuf, c;
+            struct domain_console *cons = cd->console;
 
             /* Strip non-printable characters */
             do
@@ -769,23 +771,25 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,
             } while ( --kcount > 0 );
 
             *kout = '\0';
-            spin_lock(&cd->pbuf_lock);
+            spin_lock(&cons->lock);
             kcount = kin - kbuf;
             if ( c != '\n' &&
-                 (cd->pbuf_idx + (kout - kbuf) < (DOMAIN_PBUF_SIZE - 1)) )
+                 cons->idx + kout - kbuf < DOMAIN_CONSOLE_BUF_SIZE - 1 )
             {
                 /* buffer the output until a newline */
-                memcpy(cd->pbuf + cd->pbuf_idx, kbuf, kout - kbuf);
-                cd->pbuf_idx += (kout - kbuf);
+                memcpy(cons->buf + cons->idx, kbuf, kout - kbuf);
+                cons->idx += (kout - kbuf);
             }
             else
             {
-                cd->pbuf[cd->pbuf_idx] = '\0';
-                guest_printk(cd, XENLOG_G_DEBUG "%s%s\n", cd->pbuf, kbuf);
-                cd->pbuf_idx = 0;
+                cons->buf[cons->idx] = '\0';
+                guest_printk(cd,
+                             XENLOG_G_DEBUG "%s%s\n", cons->buf, kbuf);
+                cons->idx = 0;
             }
-            spin_unlock(&cd->pbuf_lock);
+            spin_unlock(&cons->lock);
         }
+#endif
 
         guest_handle_add_offset(buffer, kcount);
         count -= kcount;
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index fe53d4fab7ba..388ba70a41a9 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -371,6 +371,22 @@ struct evtchn_port_ops;
 
 #define MAX_NR_IOREQ_SERVERS 8
 
+/* Arbitrary value; must be a multiple of the cacheline size. */
+#define DOMAIN_CONSOLE_BUF_SIZE 256
+
+/* Domain console settings. */
+struct domain_console {
+#ifdef CONFIG_VERBOSE_DEBUG
+    /* hvm_print_line() and guest_console_write() logging. */
+    char *buf;
+    unsigned int idx;
+    spinlock_t lock;
+#endif /* CONFIG_VERBOSE_DEBUG */
+
+    /* Permission to take ownership of the physical console input. */
+    bool input_allowed;
+};
+
 struct domain
 {
     domid_t          domain_id;
@@ -562,12 +578,6 @@ struct domain
     /* Control-plane tools handle for this domain. */
     xen_domain_handle_t handle;
 
-    /* hvm_print_line() and guest_console_write() logging. */
-#define DOMAIN_PBUF_SIZE 200
-    char       *pbuf;
-    unsigned int pbuf_idx;
-    spinlock_t  pbuf_lock;
-
     /* OProfile support. */
     struct xenoprof *xenoprof;
 
@@ -653,10 +663,7 @@ struct domain
 #endif
 
     /* Console settings. */
-    struct {
-        /* Permission to take ownership of the physical console input. */
-        bool input_allowed;
-    } console;
+    struct domain_console *console;
 } __aligned(PAGE_SIZE);
 
 static inline struct page_list_head *page_to_list(
-- 
2.34.1
Re: [PATCH v2] xen/console: introduce domain_console struct
Posted by Jan Beulich 4 months, 2 weeks ago
On 17.06.2025 03:27, dmkhn@proton.me wrote:
> From: Denis Mukhin <dmukhin@ford.com>
> 
> Introduce domain_console for grouping data structures used for integrating
> domain's diagnostic console with Xen's console driver.
> 
> Group all pbuf-related data structures under domain_console. Rename the moved
> fields to plain .buf, .idx and .lock names, since all uses of the fields are
> touched.
> 
> Bump the domain console buffer size to the closest power of 2 (256) and
> rename the symbol to DOMAIN_CONSOLE_BUF_SIZE.
> 
> Move d->console->buf management under CONFIG_VERBOSE_DEBUG when the
> HYPERCALL_console_io handler is enabled.

This, if at all, needs to be a separate change (with its own justification).
I for one don't think VERBOSE_DEBUG is intended to control any kind of guest
output.

> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -559,7 +559,6 @@ void hvm_do_resume(struct vcpu *v)
>  static int cf_check hvm_print_line(
>      int dir, unsigned int port, unsigned int bytes, uint32_t *val)
>  {
> -    struct domain *cd = current->domain;
>      char c = *val;
>  
>      ASSERT(bytes == 1 && port == XEN_HVM_DEBUGCONS_IOPORT);
> @@ -570,17 +569,24 @@ static int cf_check hvm_print_line(
>  
>      if ( !is_console_printable(c) )
>          return X86EMUL_OKAY;

After this "return" ...

> -
> -    spin_lock(&cd->pbuf_lock);
> -    if ( c != '\n' )
> -        cd->pbuf[cd->pbuf_idx++] = c;
> -    if ( (cd->pbuf_idx == (DOMAIN_PBUF_SIZE - 1)) || (c == '\n') )
> +#ifdef CONFIG_VERBOSE_DEBUG
> +    else

... there's no point to have "else" here.

>      {
> -        cd->pbuf[cd->pbuf_idx] = '\0';
> -        guest_printk(cd, XENLOG_G_DEBUG "%s\n", cd->pbuf);
> -        cd->pbuf_idx = 0;
> +        struct domain *cd = current->domain;

We normally name such a variable d. It also looks as if this could be pointer-
to-const.

> +        struct domain_console *cons = cd->console;
> +
> +        spin_lock(&cons->lock);
> +        if ( c != '\n' )
> +            cons->buf[cons->idx++] = c;
> +        if ( (cons->idx == (DOMAIN_CONSOLE_BUF_SIZE - 1)) || (c == '\n') )
> +        {
> +            cons->buf[cons->idx] = '\0';
> +            guest_printk(cd, XENLOG_G_DEBUG "%s\n", cons->buf);
> +            cons->idx = 0;
> +        }
> +        spin_unlock(&cons->lock);
>      }
> -    spin_unlock(&cd->pbuf_lock);
> +#endif

None of the re-indentation is really warranted here (and will likely go away
anyway once the #ifdef is dropped).

> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -669,7 +669,7 @@ static void _domain_destroy(struct domain *d)
>      BUG_ON(!d->is_dying);
>      BUG_ON(atomic_read(&d->refcnt) != DOMAIN_DESTROYED);
>  
> -    xfree(d->pbuf);
> +    xfree(d->console);
>  
>      argo_destroy(d);
>  
> @@ -800,6 +800,11 @@ struct domain *domain_create(domid_t domid,
>      if ( (d = alloc_domain_struct()) == NULL )
>          return ERR_PTR(-ENOMEM);
>  
> +    err = -ENOMEM;
> +    d->console = xvzalloc(typeof(*d->console));
> +    if ( !d->console )
> +        goto fail;

This definitely need to move down some, at least ...

>      /* Sort out our idea of is_system_domain(). */
>      d->domain_id = domid;
>      d->unique_id = get_unique_id();

... past here. There absolutely must not be struct domain instances be
passed around (see e.g. the call to sched_destroy_domain()) without the
domain ID set. It's hard to see ...

> @@ -862,7 +867,9 @@ struct domain *domain_create(domid_t domid,
>      spin_lock_init(&d->shutdown_lock);
>      d->shutdown_code = SHUTDOWN_CODE_INVALID;
>  
> -    spin_lock_init(&d->pbuf_lock);
> +#ifdef CONFIG_VERBOSE_DEBUG
> +    spin_lock_init(&d->console->lock);
> +#endif

.. why here or ...

> @@ -955,11 +962,6 @@ struct domain *domain_create(domid_t domid,
>      if ( (err = argo_init(d)) != 0 )
>          goto fail;
>  
> -    err = -ENOMEM;
> -    d->pbuf = xzalloc_array(char, DOMAIN_PBUF_SIZE);
> -    if ( !d->pbuf )
> -        goto fail;

... even here wouldn't be early enough anyway.

And btw - where did this buffer allocation move? I don't see anywhere
that d->console->buf would now be initialized. (However, see below.)

> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -371,6 +371,22 @@ struct evtchn_port_ops;
>  
>  #define MAX_NR_IOREQ_SERVERS 8
>  
> +/* Arbitrary value; must be a multiple of the cacheline size. */
> +#define DOMAIN_CONSOLE_BUF_SIZE 256

Where does the relationship with cache line size come from? What if
Xen was to run on hardware (whichever arch) with 512-byte cache lines?

> +/* Domain console settings. */
> +struct domain_console {
> +#ifdef CONFIG_VERBOSE_DEBUG
> +    /* hvm_print_line() and guest_console_write() logging. */
> +    char *buf;

To avoid the need to do yet another separate allocation, how about ...

> +    unsigned int idx;
> +    spinlock_t lock;
> +#endif /* CONFIG_VERBOSE_DEBUG */
> +
> +    /* Permission to take ownership of the physical console input. */
> +    bool input_allowed;

    char buf[DOMAIN_CONSOLE_BUF_SIZE];

Ultimately this would allow the buffer size to be e.g. command line
controlled (if so desired), by then simply converting to a flexible
array member.

Jan
Re: [PATCH v2] xen/console: introduce domain_console struct
Posted by dmkhn@proton.me 4 months, 2 weeks ago
On Tue, Jun 17, 2025 at 11:48:10AM +0200, Jan Beulich wrote:
> On 17.06.2025 03:27, dmkhn@proton.me wrote:
> > From: Denis Mukhin <dmukhin@ford.com>
> >
> > Introduce domain_console for grouping data structures used for integrating
> > domain's diagnostic console with Xen's console driver.
> >
> > Group all pbuf-related data structures under domain_console. Rename the moved
> > fields to plain .buf, .idx and .lock names, since all uses of the fields are
> > touched.
> >
> > Bump the domain console buffer size to the closest power of 2 (256) and
> > rename the symbol to DOMAIN_CONSOLE_BUF_SIZE.
> >
> > Move d->console->buf management under CONFIG_VERBOSE_DEBUG when the
> > HYPERCALL_console_io handler is enabled.
> 
> This, if at all, needs to be a separate change (with its own justification).
> I for one don't think VERBOSE_DEBUG is intended to control any kind of guest
> output.
> 
> > --- a/xen/arch/x86/hvm/hvm.c
> > +++ b/xen/arch/x86/hvm/hvm.c
> > @@ -559,7 +559,6 @@ void hvm_do_resume(struct vcpu *v)
> >  static int cf_check hvm_print_line(
> >      int dir, unsigned int port, unsigned int bytes, uint32_t *val)
> >  {
> > -    struct domain *cd = current->domain;
> >      char c = *val;
> >
> >      ASSERT(bytes == 1 && port == XEN_HVM_DEBUGCONS_IOPORT);
> > @@ -570,17 +569,24 @@ static int cf_check hvm_print_line(
> >
> >      if ( !is_console_printable(c) )
> >          return X86EMUL_OKAY;
> 
> After this "return" ...
> 
> > -
> > -    spin_lock(&cd->pbuf_lock);
> > -    if ( c != '\n' )
> > -        cd->pbuf[cd->pbuf_idx++] = c;
> > -    if ( (cd->pbuf_idx == (DOMAIN_PBUF_SIZE - 1)) || (c == '\n') )
> > +#ifdef CONFIG_VERBOSE_DEBUG
> > +    else
> 
> ... there's no point to have "else" here.
> 
> >      {
> > -        cd->pbuf[cd->pbuf_idx] = '\0';
> > -        guest_printk(cd, XENLOG_G_DEBUG "%s\n", cd->pbuf);
> > -        cd->pbuf_idx = 0;
> > +        struct domain *cd = current->domain;
> 
> We normally name such a variable d. It also looks as if this could be pointer-
> to-const.
> 
> > +        struct domain_console *cons = cd->console;
> > +
> > +        spin_lock(&cons->lock);
> > +        if ( c != '\n' )
> > +            cons->buf[cons->idx++] = c;
> > +        if ( (cons->idx == (DOMAIN_CONSOLE_BUF_SIZE - 1)) || (c == '\n') )
> > +        {
> > +            cons->buf[cons->idx] = '\0';
> > +            guest_printk(cd, XENLOG_G_DEBUG "%s\n", cons->buf);
> > +            cons->idx = 0;
> > +        }
> > +        spin_unlock(&cons->lock);
> >      }
> > -    spin_unlock(&cd->pbuf_lock);
> > +#endif
> 
> None of the re-indentation is really warranted here (and will likely go away
> anyway once the #ifdef is dropped).
> 
> > --- a/xen/common/domain.c
> > +++ b/xen/common/domain.c
> > @@ -669,7 +669,7 @@ static void _domain_destroy(struct domain *d)
> >      BUG_ON(!d->is_dying);
> >      BUG_ON(atomic_read(&d->refcnt) != DOMAIN_DESTROYED);
> >
> > -    xfree(d->pbuf);
> > +    xfree(d->console);
> >
> >      argo_destroy(d);
> >
> > @@ -800,6 +800,11 @@ struct domain *domain_create(domid_t domid,
> >      if ( (d = alloc_domain_struct()) == NULL )
> >          return ERR_PTR(-ENOMEM);
> >
> > +    err = -ENOMEM;
> > +    d->console = xvzalloc(typeof(*d->console));
> > +    if ( !d->console )
> > +        goto fail;
> 
> This definitely need to move down some, at least ...
> 
> >      /* Sort out our idea of is_system_domain(). */
> >      d->domain_id = domid;
> >      d->unique_id = get_unique_id();
> 
> ... past here. There absolutely must not be struct domain instances be
> passed around (see e.g. the call to sched_destroy_domain()) without the
> domain ID set. It's hard to see ...
> 
> > @@ -862,7 +867,9 @@ struct domain *domain_create(domid_t domid,
> >      spin_lock_init(&d->shutdown_lock);
> >      d->shutdown_code = SHUTDOWN_CODE_INVALID;
> >
> > -    spin_lock_init(&d->pbuf_lock);
> > +#ifdef CONFIG_VERBOSE_DEBUG
> > +    spin_lock_init(&d->console->lock);
> > +#endif
> 
> .. why here or ...
> 
> > @@ -955,11 +962,6 @@ struct domain *domain_create(domid_t domid,
> >      if ( (err = argo_init(d)) != 0 )
> >          goto fail;
> >
> > -    err = -ENOMEM;
> > -    d->pbuf = xzalloc_array(char, DOMAIN_PBUF_SIZE);
> > -    if ( !d->pbuf )
> > -        goto fail;
> 
> ... even here wouldn't be early enough anyway.
> 
> And btw - where did this buffer allocation move? I don't see anywhere
> that d->console->buf would now be initialized. (However, see below.)
> 
> > --- a/xen/include/xen/sched.h
> > +++ b/xen/include/xen/sched.h
> > @@ -371,6 +371,22 @@ struct evtchn_port_ops;
> >
> >  #define MAX_NR_IOREQ_SERVERS 8
> >
> > +/* Arbitrary value; must be a multiple of the cacheline size. */
> > +#define DOMAIN_CONSOLE_BUF_SIZE 256
> 
> Where does the relationship with cache line size come from? What if
> Xen was to run on hardware (whichever arch) with 512-byte cache lines?
> 
> > +/* Domain console settings. */
> > +struct domain_console {
> > +#ifdef CONFIG_VERBOSE_DEBUG
> > +    /* hvm_print_line() and guest_console_write() logging. */
> > +    char *buf;
> 
> To avoid the need to do yet another separate allocation, how about ...
> 
> > +    unsigned int idx;
> > +    spinlock_t lock;
> > +#endif /* CONFIG_VERBOSE_DEBUG */
> > +
> > +    /* Permission to take ownership of the physical console input. */
> > +    bool input_allowed;
> 
>     char buf[DOMAIN_CONSOLE_BUF_SIZE];
> 
> Ultimately this would allow the buffer size to be e.g. command line
> controlled (if so desired), by then simply converting to a flexible
> array member.

Whoops, apologies for the bogus change.
Looks like I posted from the wrong branch.

> 
> Jan
Re: [PATCH v2] xen/console: introduce domain_console struct
Posted by Jan Beulich 4 months, 2 weeks ago
On 17.06.2025 11:48, Jan Beulich wrote:
> On 17.06.2025 03:27, dmkhn@proton.me wrote:
>> From: Denis Mukhin <dmukhin@ford.com>
>>
>> Introduce domain_console for grouping data structures used for integrating
>> domain's diagnostic console with Xen's console driver.
>>
>> Group all pbuf-related data structures under domain_console. Rename the moved
>> fields to plain .buf, .idx and .lock names, since all uses of the fields are
>> touched.
>>
>> Bump the domain console buffer size to the closest power of 2 (256) and
>> rename the symbol to DOMAIN_CONSOLE_BUF_SIZE.
>>
>> Move d->console->buf management under CONFIG_VERBOSE_DEBUG when the
>> HYPERCALL_console_io handler is enabled.
> 
> This, if at all, needs to be a separate change (with its own justification).
> I for one don't think VERBOSE_DEBUG is intended to control any kind of guest
> output.

Hmm, the option's help text indeed says it mixes two unrelated things. Maybe
this wants untangling. With a behavioral change like the one you suggest, that
help text would need updating in any event, though.

Jan