All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: dmukhin@ford.com
Cc: xen-devel@lists.xenproject.org, andrew.cooper3@citrix.com,
	 anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org,
	 michal.orzel@amd.com, roger.pau@citrix.com,
	sstabellini@kernel.org
Subject: Re: [PATCH v8 5/7] xen/console: use memcpy() in conring_puts()
Date: Mon, 10 Aug 2026 13:24:59 -0700 (PDT)	[thread overview]
Message-ID: <8b114d89-e026-686c-167c-6ebe1006be4c@kernel.org> (raw)
In-Reply-To: <20260728065049.1318143-6-dmukhin@ford.com>

On Mon, 27 Jul 2026, dmukhin@ford.com wrote:
> From: Denis Mukhin <dmukhin@ford.com> 
> 
> Make conring_puts() more efficient by using memcpy()'s, rather than
> copying the ring a byte at a time.
> 
> No functional change intended.
> 
> Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> ---
> Changes since v7:
> - hardended len check in conring_puts()
> ---
>  xen/drivers/char/console.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
> index 09282a7a4f8e..a1b8e5f5b507 100644
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -361,12 +361,24 @@ static DECLARE_SOFTIRQ_TASKLET(conring_tasklet, conring_notify, NULL);
>  /* NB: Do not send conring VIRQs during panic. */
>  static bool conring_no_notify;
>  
> -static void conring_puts(const char *str, size_t len)
> +static void conring_puts(const char *str, unsigned int len)
>  {
> +    unsigned int src = len;
> +
> +    /* There are no callers with strings longer than PAGE_SIZE. */
> +    BUG_ON(len > PAGE_SIZE);

Should be an ASSERT


>      ASSERT(rspin_is_locked(&console_lock));
>  
> -    while ( len-- )
> -        conring[CONRING_IDX_MASK(conringp++)] = *str++;
> +    while ( src < len )

src is initialized to len, so this is a problem?


> +    {
> +        unsigned int dst = CONRING_IDX_MASK(conringp + src);
> +        unsigned int n = min(conring_size - dst, len - src);
> +
> +        memcpy(&conring[dst], &str[src], n);
> +        src += n;
> +    }
> +
> +    conringp += len;
>  
>      if ( conringp - conringc > conring_size )
>          conringc = conringp - conring_size;
> -- 
> 2.54.0
> 


  reply	other threads:[~2026-08-10 20:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  6:50 [PATCH v8 0/7] xen/console: some cleanups and configurable conring size dmukhin
2026-07-28  6:50 ` [PATCH v8 1/7] xen/console: do not use XENCONS_RING_IDX in console_init_ring() dmukhin
2026-08-10 20:03   ` Stefano Stabellini
2026-07-28  6:50 ` [PATCH v8 2/7] xen/console: use 'unsigned int' in contring_{flush,puts}() dmukhin
2026-08-10 20:05   ` Stefano Stabellini
2026-07-28  6:50 ` [PATCH v8 3/7] xen/console: switch conring runtime allocation to xvmalloc dmukhin
2026-08-10 20:19   ` Stefano Stabellini
2026-07-28  6:50 ` [PATCH v8 4/7] xen/serial: switch txbuf " dmukhin
2026-08-10 20:22   ` Stefano Stabellini
2026-07-28  6:50 ` [PATCH v8 5/7] xen/console: use memcpy() in conring_puts() dmukhin
2026-08-10 20:24   ` Stefano Stabellini [this message]
2026-08-10 21:36   ` Stefano Stabellini
2026-08-10 21:37   ` Andrew Cooper
2026-07-28  6:50 ` [PATCH v8 6/7] xen/serial: harden serial_tx_buffer checks dmukhin
2026-08-10 20:32   ` Stefano Stabellini
2026-07-28  6:50 ` [PATCH v8 7/7] xen/console: make console buffer size configurable dmukhin
2026-08-10 20:42   ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8b114d89-e026-686c-167c-6ebe1006be4c@kernel.org \
    --to=sstabellini@kernel.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=dmukhin@ford.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.