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

Re: [XEN v3 3/9] xen/drivers: ns16550: Use paddr_t for io_base/io_size


  • To: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 8 Feb 2023 14:52: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=okrVck6BRG6qGz81zprf1OrFP5YupAGMWlqt7WKoUmU=; b=Lt92cU1EYiNF2TBWZGUsLn4HlYDUxgDXnFgqDRBVpqtMBx8ulwkhbiNJH9Lmk97qF3UEzGV4E0ZCGfsQ1U8KtHKRbheDOztKNKHgEhOsi8q6LLxO5ZAK2lEhEXg5toUni9wDQZBgndpKJStVD5DUhE3KhIskFpS8awGoolUozKyT4HWhae2LM7ss2DyZSNSI2Bs1Tq0m16lNsNQ15GAwOiLeCpntwmh0iuaFIB8fgWk2/KvI3960po21m3nDiQqgVQdcrf7f5TX6b6AJvs2l39r73CZ6NXBIG071o3ZXyDzKawV7LcyqwXIIaeZjAAUiNM+bJl3qQha9RW1AryeOJg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ho81jvmYQ2kSn4W9OKux8FDfKGMJLbDQLdSMIxnP/N9yl1K5rVoNo3nqB5FM8JeY+1VajRMdW7ixgkV/QUbXSGYA5NEpMMxkYR67hQilavZhs9HGIyCyRmRVsK1H1An6XqiR6F230h2n7PgaCGoOCk4hN7qO0rIxvJ8YHRMA5NlbVeX60JSSDLntAKUsbszw/26OluiQrdX0WfGwHDAo+/GO9xmSgKSTAYScb2OpOJZyAmtdH7k7b/IXwAI9v/5a8b23YpF4vvizYex0PNQu0tQzfcGmSsu39G3xz/iRZol0zhW2O9JVk9MFE6ufp4VJZ+bSanragJ68qvaIk5+kWQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: sstabellini@xxxxxxxxxx, stefano.stabellini@xxxxxxx, julien@xxxxxxx, Volodymyr_Babchuk@xxxxxxxx, bertrand.marquis@xxxxxxx, andrew.cooper3@xxxxxxxxxx, george.dunlap@xxxxxxxxxx, wl@xxxxxxx, rahul.singh@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 08 Feb 2023 13:53:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 08.02.2023 13:05, Ayan Kumar Halder wrote:
> @@ -1166,8 +1166,9 @@ static const struct ns16550_config __initconst 
> uart_config[] =
>  static int __init
>  pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx)
>  {
> -    u64 orig_base = uart->io_base;
> +    paddr_t orig_base = uart->io_base;
>      unsigned int b, d, f, nextf, i;
> +    u64 pci_uart_io_base;

uint64_t please (also elsewhere as needed), assuming the variable
actually needs to survive. And if it needs to, please move it into
a more narrow scope (and perhaps shorten its name).

> @@ -1259,8 +1260,13 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, 
> unsigned int idx)
>                      else
>                          size = len & PCI_BASE_ADDRESS_MEM_MASK;
>  
> -                    uart->io_base = ((u64)bar_64 << 32) |
> -                                    (bar & PCI_BASE_ADDRESS_MEM_MASK);
> +                    pci_uart_io_base = ((u64)bar_64 << 32) |
> +                                        (bar & PCI_BASE_ADDRESS_MEM_MASK);
> +
> +                    /* Truncation detected while converting to paddr_t */
> +                    BUG_ON((pci_uart_io_base >> (PADDR_SHIFT - 1)) > 1);

Why would we want to crash during early boot at all? And then even at a
point where it'll be hard to figure out what's going on, as we're only
in the process of configuring the serial console?

> @@ -1532,7 +1539,12 @@ static bool __init parse_positional(struct ns16550 
> *uart, char **str)
>          else
>  #endif
>          {
> -            uart->io_base = simple_strtoull(conf, &conf, 0);
> +            uart_io_base = simple_strtoull(conf, &conf, 0);
> +
> +            /* Truncation detected while converting to paddr_t */
> +            BUG_ON((uart_io_base >> (PADDR_SHIFT - 1)) > 1);

All the same here.

Jan



 


Rackspace

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