[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] xen/console: Skip switching serial input to non existing domains


  • To: Michal Orzel <michal.orzel@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 16 Mar 2023 12:11:19 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fCmINk3ZLz2jxe0JLs3TMpzTb4OO+6HOpzF2TJ//fQw=; b=OJTUBlpJagl8VC3Xi7KIGZad2ufpeZaKn/0ODxQmrnnGqWATjw4ad7Jm8X2MtxoHcTbv7YH0nbkc1O/StD4gtvkgg9fyMJmes5KMCW1JIQ/pUBbXOAon/ZTQJu23rFJuib/3D6HJaBGcNAkRLaVhoPL21pGKKLbeQzpw3sHULFsOxEl88v3eaLVamBv/jEctYWpznC/+eaU5yZNC1WnUYE05hHYnPNDIUAq0jQDTkO4XasLEt7roWxonNXrEZGk1Rlw43ptYCJokj+BEPVnN+8BSXTFEXa/Lm2FvxHGj2CF699oTpnAEkKlZKM2Atn9aZOoNCJM61/6Jy+hbdcrBjw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=El/h0801GbGfaVpyl51bwkdrZsJQp5EEgHLefjvOueNnsvcjTFQxKZ46ExU+OleI9TA2tFjjb2FeK4QYjhW2T1zyQaqRBfy5gw7en8FcPNQ2u6Y6DKldqC5PYghUh89pO4ib2a44G4O5NZqSRrl3B4iMUH5Z3W14kFZCidixdCmEIXAWM13YzBqN51Rqj/84w2kQ04kd7PwoisJnLfPU97Um3zIvs/Lxw3sfbBhW5MXs+nob3L4qdtDq33YpQaL4+uqWwzd8zd+GgeEFoE8BRuHx4MJYdGBKvKLYiI2bCGc5pWW1Or5VZe7mFgCHFtLzCG40J0ptNSkqOy3ZLy5emw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 16 Mar 2023 11:11:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.