xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Jan Beulich <jbeulich@suse.com>
Cc: Michal Orzel <michal.orzel@amd.com>,
	 Andrew Cooper <andrew.cooper3@citrix.com>,
	 George Dunlap <george.dunlap@citrix.com>,
	Julien Grall <julien@xen.org>,
	 Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wl@xen.org>,
	 xen-devel@lists.xenproject.org
Subject: Re: [PATCH v2] xen/console: Skip switching serial input to non existing domains
Date: Thu, 16 Mar 2023 15:59:31 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2303161559250.3359@ubuntu-linux-20-04-desktop> (raw)
In-Reply-To: <d9654392-ce4b-07b6-9be0-7a6d4230c287@suse.com>

On Thu, 16 Mar 2023, Jan Beulich wrote:
> On 16.03.2023 11:26, Michal Orzel wrote:
> > --- a/xen/drivers/char/console.c
> > +++ b/xen/drivers/char/console.c
> > @@ -490,7 +490,24 @@ static void switch_serial_input(void)
> >      }
> >      else
> >      {
> > -        console_rx++;
> > +        unsigned int next_rx = console_rx + 1;
> > +
> > +        /* Skip switching serial input to non existing domains */
> > +        while ( next_rx < max_init_domid + 1 )
> > +        {
> > +            struct domain *d = rcu_lock_domain_by_id(next_rx - 1);
> > +
> > +            if ( d )
> > +            {
> > +                rcu_unlock_domain(d);
> > +                break;
> > +            }
> > +
> > +            next_rx++;
> > +        }
> > +
> > +        console_rx = next_rx;
> > +
> >          printk("*** Serial input to DOM%d", console_rx - 1);
> >      }
> 
> While at the first glance (when you sent it in reply to v1) it looked okay,
> I'm afraid it really isn't: Please consider what happens when the last of
> the DomU-s doesn't exist anymore. (You don't really check whether it still
> exists, because the range check comes ahead of the existence one.) In that
> case you want to move from second-to-last to Xen. I expect the entire
> if/else construct wants to be inside the loop.

I don't think we need another loop, just a check if we found a domain or
not. E.g.:


    unsigned int next_rx = console_rx + 1;

    /* Skip switching serial input to non existing domains */
    while ( next_rx < max_init_domid + 1 )
    {
        struct domain *d = rcu_lock_domain_by_id(next_rx - 1);

        if ( d )
        {
            rcu_unlock_domain(d);
            console_rx = next_rx;
            printk("*** Serial input to DOM%d", console_rx - 1);
            break;
        }

        next_rx++;
    }

    /* no domain found */
    console_rx = 0;
    printk("*** Serial input to Xen");


  parent reply	other threads:[~2023-03-16 22:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 10:26 [PATCH v2] xen/console: Skip switching serial input to non existing domains Michal Orzel
2023-03-16 11:11 ` Jan Beulich
2023-03-16 14:15   ` Michal Orzel
2023-03-16 14:22     ` George Dunlap
2023-03-16 16:02     ` Jan Beulich
2023-03-16 22:59   ` Stefano Stabellini [this message]
2023-03-17  8:36     ` Jan Beulich
2023-03-17  9:32       ` Michal Orzel
2023-03-17 14:55         ` Jan Beulich

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=alpine.DEB.2.22.394.2303161559250.3359@ubuntu-linux-20-04-desktop \
    --to=sstabellini@kernel.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=wl@xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).