[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: Jan Beulich <jbeulich@xxxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Wed, 8 Feb 2023 17:07:54 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.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=wF+jvPzW/t75K67ZlUkLDlWTJo3FWF0QTAZfcrA4DdE=; b=BbCZAE8v+83MHD64G1+kdQRE0yBXZOUMXb2bVWaMZPFCh4duGi3ao6bZayHde9I9cLCkJ6F1XpPSvqBIpPsQLinmvDZLKsWAeY+g1ybARsevKAn/kDHNDAfo5tGW+cRVUW++iWfTwL6Y03Q/axFFfopEu1Tb04Vl5dMN7d6gzrzAkpgqsLt6OhxgkNMEB1ykXrrN6XNmm9HFKDQHg8VHaWXSL+ryJIv6pQLQq7c6WlL18WD09/YBq0vuYKKTVv00W3OhFzmszQ2x8JcbU2AAEnPgPH+mu33/ghrqochGhPp2bpTPzD6wqu+VYuF+AC0vGZB9jpJJwvdVzjw7N3puLA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VeQxvr6HkLAvdis2BzIOxWv+xNsCGmhNWX+ppvVRrB4Eoi6kjLsEaxBX/SgI6z5/5OqeHsKptT7F71ED9Av2DwwyyrrYJe8qEGGsZ+2PD76TJ4sNU+12PfSJDrEDo6q+N7GX/u+H3eyV+4KtOrwSLpYydv6/Dboz91GTca4alH0MxV4DUpXiAqLGcgoo9iS8Wq4pzPZO6FbT8OQCLc+4vzv8GHK/JG3ypGWmdMcKkYklgr8/4Ta0MEwzPxOtuWbKaZFQxq2+Lmh1kaQWoxm+Z8jZssS8R+2h+cymzq8qDrnFuJGtmp4BPSSj+0kaqAN38sxPMTR8HDLwSZFFbmMrEA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.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 17:08:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Jan,

On 08/02/2023 13:52, Jan Beulich wrote:
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).
Ack.

@@ -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?

I do not understand the best way to return an error from pci_uart_config().

Out of the 4 invocations of pci_uart_config(), the return value is checked in two invocations only like this.

if ( pci_uart_config(uart, 0, uart - ns16550_com) )
                return true;

pci_uart_config() returns 0 in case of success and -1 in case of error. But the caller seems to be checking the opposite.

I could not use domain_crash() as I understand that pci_uart_config() is invoked before domain is created.


@@ -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.

I can return false from here and let ns16550_parse_port_config() return.

I think that might be the correct thing to do here.

- Ayan


Jan



 


Rackspace

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