All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: dmukhin@xen.org
Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech,
	julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com,
	sstabellini@kernel.org, dmukhin@ford.com,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v5 4/6] xen/console: use memcpy() in console_init_ring()
Date: Mon, 9 Feb 2026 17:56:38 +0100	[thread overview]
Message-ID: <7e8669d4-d1b6-47c7-ad08-da14f14fb4a4@suse.com> (raw)
In-Reply-To: <20260205013606.3384798-5-dmukhin@ford.com>

On 05.02.2026 02:36, dmukhin@xen.org wrote:
> @@ -479,11 +479,23 @@ void __init console_init_ring(void)
>      opt_conring_size = PAGE_SIZE << order;
>  
>      nrspin_lock_irqsave(&console_lock, flags);
> -    for ( i = conringc ; i != conringp; i++ )
> -        ring[i & (opt_conring_size - 1)] = conring[i & (conring_size - 1)];
> +
> +    start = conringc & (conring_size - 1);
> +    size = min(conringp - conringc, conring_size);

Is this correct when the ring size actually shrinks? In such a case you want
to copy the tail of the ring if not all of the original contents fits in the
new one. But ...

> +    chunk = min(size, conring_size - start);
> +
> +    memcpy(&ring[0], &conring[start], chunk);

... you start at its head.

> +    if ( size > chunk )
> +        memcpy(&ring[chunk], &conring[0], size - chunk);
> +
> +    /* Data is moved to [0..size), re-position conring pointers. */
> +    conringc = 0;
> +    conringp = size;

Why this unrelated change, which the description also doesn't mention? Since
this is in an __init function, there's no race with read_console_ring(), but
a static analysis tool may still (validly) spot one. Yet then there's also
conring_flush(), which doesn't look to be using any locking either. Have you
excluded that this function can run in a racing manner?

Jan


  reply	other threads:[~2026-02-09 16:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05  1:36 [PATCH v5 0/6] xen/console: configurable conring size dmukhin
2026-02-05  1:36 ` [PATCH v5 1/6] xen/console: group conring code together dmukhin
2026-02-09 16:38   ` Jan Beulich
2026-02-11 19:47     ` dmukhin
2026-02-05  1:36 ` [PATCH v5 2/6] xen/console: make console buffer size configurable dmukhin
2026-02-05  8:43   ` Jan Beulich
2026-02-06  1:52     ` dmukhin
2026-02-05  1:36 ` [PATCH v5 3/6] xen/console: promote conring{,_size} to __ro_after_init dmukhin
2026-02-09 16:40   ` Jan Beulich
2026-02-11 19:47     ` dmukhin
2026-02-05  1:36 ` [PATCH v5 4/6] xen/console: use memcpy() in console_init_ring() dmukhin
2026-02-09 16:56   ` Jan Beulich [this message]
2026-02-05  1:36 ` [PATCH v5 5/6] xen/console: update conring memory allocation dmukhin
2026-02-09 17:02   ` Jan Beulich
2026-05-08 21:45     ` dmukhin
2026-02-10 15:08   ` Jan Beulich
2026-02-05  1:36 ` [PATCH v5 6/6] xen/console: add conring buffer size alignment setting dmukhin
2026-02-10 15:10   ` Jan Beulich
2026-05-08 21:46     ` dmukhin

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=7e8669d4-d1b6-47c7-ad08-da14f14fb4a4@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=dmukhin@ford.com \
    --cc=dmukhin@xen.org \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --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.