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

Re: [PATCH 1/2] ns16550: reject IRQ above nr_irqs


  • To: Julien Grall <julien@xxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 11 Mar 2022 16:04:11 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=lgI5z3POU1knKetqPNIAXGK84/wxhJZ8VBSD/E8/dX4=; b=ad757i/0+WHSN/iEvXCTsftYQXQcF+MlVit6E2bCdxHIngD9anqRJqETEtN6Z5Pc/e1JBvgntz7XDrTtjpMDirmAmP47zY8H5JKKWXVz/z9c/K/nrUroQPPcAHpwly3VINc0X/OdF+1fx1gaQ9YkDWTArwuQbGXnh8zTe55JMOoqk6KauXJ6ZIGtty/XVG5cMGUO4wW9LH3z7XxM8fKbA1iqRMKsaO9MX3uqf0SSh+/vptl9qG37M5F12kYNzyQsGZsj5+eE6t6yGZXpjm0KconoRSRSGmd6wkwLyD9Q1SVrPID9mkoO334CWnXrrV6ccSUo52Cr/rImhqIJMfVl1A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oYS3WGciAvhCHTqoQpYuCps3XKEs/VcWQWEzUPstTl57hMt3Xgw4q4A0bR7CLN0PWIr4LiD2k3S6b9R811L5jIyufZmULyF7KPZ6stVfmhgMbKuPP0lLVg9SDHcXH4kgijF+AyFq738KHL4lwwEl5nJOppQ+PDuG2dKCqS9lLlpOrgXNPBbHN/F78Z+X10p+m8FNAvCoDAd6/RUjRWAtzCgr4in8NY06F1TF/lyNtDnynLCkwh9kgIW4M/piufX5ZEZQEO10PEn+HRbxbU3Pm9RoiXlqjFNh2bmGpvs7spNvRCszJQsG8ntwYzh0wtAmL2UVvhxmg6QbCQLLhyd5xA==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 11 Mar 2022 15:04:30 +0000
  • Ironport-data: A9a23:e+AfNKxBakqmsFDhQs16t+fvxirEfRIJ4+MujC+fZmUNrF6WrkVTn 2UfD2rSaKuJM2r3fth/atu2ph9VvcCHn9BqTlBkpCAxQypGp/SeCIXCJC8cHc8zwu4v7q5Dx 59DAjUVBJlsFhcwnj/0bv656yMUOZigHtIQMsadUsxKbVIiGX9JZS5LwbZj2NYz2IHhWWthh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0FnRnDRx6lAe2e0s9VfrzFonoR5fMeaFGH/bSe gr25OrRElU1XfsaIojNfr7TKiXmS1NJVOSEoiI+t6OK2nCuqsGuu0qS2TV1hUp/0l20c95NJ NpliL6NYyQRYIT2uscBU1oDExAkFoJl0eqSSZS/mZT7I0zudnLtx7NlDV0sPJ1e8eFyaY1M3 aVGcnZXNEnF3r/ohuLgIgVvrp1LwM3DJoQQt2sm1TjEJf0nXYrCU+PB4towMDIY2J0STK2FO JdxhTxHQi/Jc0UWE1ArT5c8292Ri2jbLiQFgQfAzUYwyzeKl1EguFT3C/LOYcCDT8hRmkeep 0rF8n7/DxVcM8aQoRKa9lq8i+mJmjn0MKoCGbv9+vN0jVm7wm0IFAZQRVa9ueO+iEO1R5RYM UN80igzqak/8mS7Q9+7WAe3yFaBtwQZUsBdEMU77h+M0ave5wuFBmkCQSVFYdZgv8gzLRQo3 FKUm9LiBRR0raaYD3ma89+pQSiaYHZPazVYPGldEFVDs4KLTJwPYgznc/ReOo2N0PTPOxLsw 3PRrBlkrJowpJtev0mkxmzvjzWpr5nPawc64ATLQ26ohj9EiJ6Zi5+AsgaCs6sZRGqNZhzY5 SVfxZDChAwbJczVzESwrPMx8KZFDhpvGBnVmhZREpYo7FxBEFbzLNkLsFmSyKqEW/vomAMFg meP6Gu9B7cJZRNGiJObharoWqzGKoC6SbzYugj8NIYmX3SIXFbvENtSTUCRxXvxt0MnjLsyP 5yWGe71UypEWP84k2ruH75DuVPO+szY7TqCLXwc5076uYdymVbPEetVWLdwRrxRAFy4TPX9r I8EapriJ+R3W+zieCjHmbP/3nhRRUXX8ave8pQNHsbae1IOMDh4V5f5nONwE6Q4zv89vrqZo RmAtrpwlQOXaYvvcl7RNBiOqdrHAP5CkJ7MFXd1bAjyhCR7P9rHAWV2X8JfQITLPddLlJZcZ /IEZ9+BErJITDHG8C4adp7zsMppcxHDuO5EF3P4CNTjV/aMnzD0x+I=
  • Ironport-hdrordr: A9a23:flejZ6j508n3vwU1Ku2YnyXt8HBQXuQji2hC6mlwRA09TyX+rb HIoB17726RtN9/YgBDpTntAsm9qBDnlKKdg7NhW4tKNTOO0AHEQL2KhbGSugEIcBeOk9K1u5 0QEJSWIeeAdWST0q3BizVQaexP/DAsytHSuQ6k9RhQcT0=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Mar 11, 2022 at 11:15:13AM +0000, Julien Grall wrote:
> Hi,
> 
> On 11/03/2022 10:52, Marek Marczykowski-Górecki wrote:
> > On Fri, Mar 11, 2022 at 10:23:03AM +0000, Julien Grall wrote:
> > > Hi Marek,
> > > 
> > > On 10/03/2022 16:37, Marek Marczykowski-Górecki wrote:
> > > > On Thu, Mar 10, 2022 at 04:21:50PM +0000, Julien Grall wrote:
> > > > > Hi,
> > > > > 
> > > > > On 10/03/2022 16:12, Roger Pau Monné wrote:
> > > > > > On Thu, Mar 10, 2022 at 05:08:07PM +0100, Jan Beulich wrote:
> > > > > > > On 10.03.2022 16:47, Roger Pau Monné wrote:
> > > > > > > > On Thu, Mar 10, 2022 at 04:23:00PM +0100, Jan Beulich wrote:
> > > > > > > > > On 10.03.2022 15:34, Marek Marczykowski-Górecki wrote:
> > > > > > > > > > --- a/xen/drivers/char/ns16550.c
> > > > > > > > > > +++ b/xen/drivers/char/ns16550.c
> > > > > > > > > > @@ -1221,6 +1221,9 @@ pci_uart_config(struct ns16550 *uart, 
> > > > > > > > > > bool_t skip_amt, unsigned int idx)
> > > > > > > > > >                                 pci_conf_read8(PCI_SBDF(0, 
> > > > > > > > > > b, d, f),
> > > > > > > > > >                                                
> > > > > > > > > > PCI_INTERRUPT_LINE) : 0;
> > > > > > > > > > +                if (uart->irq >= nr_irqs)
> > > > > > > > > > +                    uart->irq = 0;
> > > > > > > > > 
> > > > > > > > > Don't you mean nr_irqs_gsi here? Also (nit) please add the 
> > > > > > > > > missing blanks
> > > > > > > > > immediately inside the parentheses.
> > > > > > > > 
> > > > > > > > If we use nr_irqs_gsi we will need to make the check x86 only 
> > > > > > > > AFAICT.
> > > > > > > 
> > > > > > > Down the road (when Arm wants to select HAS_PCI) - yes. Not 
> > > > > > > necessarily
> > > > > > > right away. After all Arm wants to have an equivalent check here 
> > > > > > > then,
> > > > > > > not merely checking against nr_irqs instead. So putting a 
> > > > > > > conditional
> > > > > > > here right away would hide the need for putting in place an 
> > > > > > > Arm-specific
> > > > > > > alternative.
> > > > > > 
> > > > > > Oh, I always forget Arm doesn't have CONFIG_HAS_PCI enabled just 
> > > > > > yet.
> > > > > The PCI code in ns16550.c is gated by CONFIG_HAS_PCI and CONFIG_X86. 
> > > > > I am
> > > > > not sure we will ever see a support for PCI UART card in Xen on Arm.
> > > > > 
> > > > > However, if it evers happens then neither nr_irqs or nr_irqs_gsi 
> > > > > would help
> > > > > here because from the interrupt controller PoV 0xff may be a valid 
> > > > > (GICv2
> > > > > supports up to 1024 interrupts).
> > > > > 
> > > > > Is there any reason we can't explicitely check 0xff?
> > > > 
> > > > That's what my v0.1 did, but Roger suggested nr_irqs. And I agree,
> > > > because the value is later used (on x86) to access irq_desc array (via
> > > > irq_to_desc), which has nr_irqs size.
> > > 
> > > I think it would be better if that check is closer to who access the
> > > irq_desc. This would be helpful for other users (I am sure this is not the
> > > only potential place where the IRQ may be wrong). So how about moving it 
> > > in
> > > setup_irq()?
> > 
> > I don't like it, it's rather fragile approach (at least in the current
> > code base, without some refactor). There are a bunch of places using
> > uart->irq (even if just checking if its -1 or 0) before setup_irq()
> > call. This includes smp_intr_init(), which is what was the first thing
> > crashing with 0xff set there.
> 
> Even if the code is gated with !CONFIG_X86, it sounds wrong to me to have
> such check in an UART driver. It only prevents us to do an out-of-bound
> access. There are no guarantee the interrupt will be usable (on Arm 256 is a
> valid interrupt).

It's a sanity check of a value we get from the hardware, I don't think
it's that strange. It's mostly similar to doing sanity checks of input
values we get from users.

Could you add an error message to note that an incorrect irq to use
was reported by hardware?

Thanks, Roger.



 


Rackspace

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