From nobody Mon Nov 23 22:45:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1791577592; cv=none; d=zohomail.com; s=zohoarc; b=O+vS6krMjQWA48TjuY+HId0PVCP4C8waQqUp0NZiwAX84LeK2WEosUtcfQ1tGbdeZM/KEtk9jWqkFSpykZAmXLv9//TBcXAB32cnCMVnt/z732uhv39R7nr0PzU3JTELPz870/TG0dCZ3w5D8PjfClRiwbafZryXWCR7qFcLjqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791577592; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=viiD07VAm0wzPwhi7WCLojzjM3p/uz3mpHV0GNtwMuE=; b=Z8QKo70hD+gEkmOguPcuQtM4NAbzJbjNdXBNFLj9nXmr0+DGMnuOoMYgPQlJhPDMuHfgWQLJjf9YVGk9k7NbFPOoOSKrPgH4K/MXkaDErkGGZV0Us4RtFryhdCS6lhZfQTRln83Ioy84XTqlN5wXE8qoC11h2uuUguPGYzLEQnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1791577592500161.04926824320785; Fri, 9 Oct 2026 13:26:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1444696.1661390 (Exim 4.92) (envelope-from ) id 1xFHAG-0000W5-U6; Fri, 09 Oct 2026 20:26:00 +0000 Received: by outflank-mailman (output) from mailman id 1444696.1661390; Fri, 09 Oct 2026 20:26:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xFHAG-0000Vx-QL; Fri, 09 Oct 2026 20:26:00 +0000 Received: by outflank-mailman (input) for mailman id 1444696; Fri, 09 Oct 2026 20:26:00 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xFHAF-0000Vo-PG for xen-devel@lists.xenproject.org; Fri, 09 Oct 2026 20:26:00 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xFHAF-009hdL-6B for xen-devel@lists.xenproject.org; Fri, 09 Oct 2026 22:25:59 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ac94dc0-8faa-0a2a0a5109dd-0a2a4506df62-14 for ; Fri, 09 Oct 2026 22:25:59 +0200 Received: from [209.85.128.175] (helo=mail-yw1-f175.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ac94dd6-195a-0a2a45060019-d15580afa8f7-3 for ; Fri, 09 Oct 2026 22:25:59 +0200 Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-8aca54b75d4so16860147b3.0 for ; Fri, 09 Oct 2026 13:25:58 -0700 (PDT) Received: from StolidWingnut.localdomain ([174.80.170.224]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b07f1eab6csm11469547b3.20.2026.10.09.13.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2026 13:25:56 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=edera.io header.i="@edera.io" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=edera.io; s=google; t=1791577557; x=1792182357; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=viiD07VAm0wzPwhi7WCLojzjM3p/uz3mpHV0GNtwMuE=; b=NLpS+QGJPwlc+gxi4SrepdIdDcZm8znZBNYWKPAvAcoisdZKnqHVhv1zRggl1i4TnZ BSO5DqrY4Eh3m/PAfbuWeeEfVsN8Tin4WRDny1vjkNxQ7qfgHs5nhkTpzNdt86K5uRoE 02o/2fhjtQzfbRibuijeMEg7lbwcZjuyxKyL8wE0M8RMGuIo32Nzl30zo6TxcDUEhARO kKuKEZaWC9MIhT+nszOnGjdhx2VLD0MYBCablb0B35/OC6uTp9/P5bTUJmsmjF8sqnr4 VDnBW2+A9BK0nuoPjB444EnKTGgQjkUyo8A0Q8T48i30Xo1sZXh6SyUpR5B/OgPbb0P5 nj9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791577557; x=1792182357; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=viiD07VAm0wzPwhi7WCLojzjM3p/uz3mpHV0GNtwMuE=; b=OtYBFhvZEBNHUTg9PW2S7jrRy9RHkIcB1n5M8bEZopCGvLmU1NZD2xSqa7E1WT7qPO BdQtxSiILxlNQE0S2P3W8M9PNzzulqFCTXoDDSnB+dDQxw6V8T+xeTTxBV095ngeGbq5 4WPFOey8DaJei//mupEDnBh6MkB4t2DE6xNQ4oLMm41jJJpMCcNJ/vrkOC1QxLX6vSso nPpeIdO6Za/AVMfbvbEnr5I7VCjX8nY0dkV9ml4Waq35tPe0BX5EOfikhmwvyabrrxnp U7ZWmlNbowyWoQj2VRFoFu00HAkNf/GG6b9EXVcxLQbKtZ5YYgCeAJ8uMaxcneuZC/Cw f3ZA== X-Gm-Message-State: AFq9FYKllLiKh0SxTu5QuoFyNrJvdTKCMzcrNkvR9XvW4uBPr9od+ZfV 0730NAUT+e4TYHl78SHhPjKJDr86zCKXGyCVgy3mDRQiTIPtUhZjD6+jf6/d9Mzawt6H6yurjk/ UthslKQUBJg== X-Gm-Gg: AYBFou3THsk7YmeAhc9S4mKjdBVI6TBB54raBFtxVdIcaWmi7HMhKR4fIdZP+f58sVb /L30M+bcV7Ozs/HQYaUTbv0qPDAUtwlSRJuZCwifAVYkICarSWqLDkQflDSU2oHJKWh6GJbJCkx 7tYnOcahgj1w84WtJlKMIQk1cwhIvN64v4WhmC7ippkUw/QliEynfGg1PJzc9zR820LDwhIRhVh pylrPOvgE9UrU9ow8uiGwZF19aXO9j7eBih3bXy0nXNHj6wHqlAV7exKiDYH5AS8k2dqwaLaPXi onyUGRLEAz0sKPaYaXM3459KxTOuXFHQRrFPr0MHHGViUSkxmS+h0itaSh6vhm/VXVefFmmjxBX bktLbJ5LLQ1oMtvWbNZWW5A5O5XNl5ZI+GoKtDVSj4MLnefZOOnY2Uy5n1A9j30TNtk2sRPQiIb TK6nB0kOL0CDGTZCnfd9IRY5bxWo45f74jofhE7tAdf05dCqCwb4U0GkgZwLalh3IQuVJAfV9zH Y4toS9hPJh/Bjc9E9Q8QpZHLdGHGCjySf7BzRp5n0E+z2lZLYK8m//AO9VdNyVXSwZ0FAc= X-Received: by 2002:a05:690c:c50d:b0:890:f416:7a27 with SMTP id 00721157ae682-8b07ed91534mr9377927b3.19.1791577557288; Fri, 09 Oct 2026 13:25:57 -0700 (PDT) From: Benjamin Leggett To: xen-devel@lists.xenproject.org Cc: Benjamin Leggett , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH] ns16550: add "auto" to scan PCI only when the default base has no UART Date: Fri, 9 Oct 2026 16:24:47 -0400 Message-ID: <20261009202447.852414-1-benjamin@edera.io> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260922184316.324817-1-benjamin@edera.io> References: <20260922184316.324817-1-benjamin@edera.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1791577559-F6C7777B-A7031A45/0/0 X-purgate-type: clean X-purgate-size: 5461 X-ZohoMail-DKIM: pass (identity @edera.io) X-ZM-MESSAGEID: 1791577594031158500 Content-Type: text/plain; charset="utf-8" On some systems the console UART is at the legacy I/O port, and on others, such as Amazon EC2 bare metal instances, the only UART is on PCI. "com1=3D...,pci" finds the PCI UART, but it prefers any PCI serial device to the legacy port, so it is not correct on a system that has both. No option today says "use the legacy port, and scan PCI only if it has no UART". A deployment that boots one command line on many kinds of machine needs exactly that. Add "auto" as a value in the position. With it, Xen probes the default base as usual. Only if check_existence() fails there does it scan PCI, as "pci" does. Without "auto", nothing changes. The scan runs only when the command line asks for it, at the same point in boot as "pci" and "amt". There is no console yet, but the scan is not silent: it logs the device that it picked, and PARSE_ERR() logs a failure. Both messages go to the console ring, and console_init_preirq() replays the ring to each console that comes up, VGA included. Only a hang or a crash inside the scan goes unreported, as with "pci" and "amt" today. To limit what an unexpected scan can touch, "auto" only considers devices that are in uart_config[]. A serial-class device without built-in parameters is skipped before its BARs are sized, so a firmware that misreports the legacy port cannot move com1 to an arbitrary plug-in card. When the scan finds nothing, pci_uart_config() puts back the original base, and check_existence() does not test MMIO addresses. Thus ps_bdf_enable, not check_existence(), tells whether a device was found. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Benjamin Leggett --- docs/misc/xen-command-line.pandoc | 5 ++++- xen/drivers/char/ns16550.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index ea0e3368b1..58ef53a5b2 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -357,7 +357,7 @@ ACPI indicating none to be there. =20 ### com1 (x86) ### com2 (x86) -> `=3D [/][,[DPS][,[|pci|amt][,[|msi][,[][,[]]]]]]` +> `=3D [/][,[DPS][,[|pci|amt|auto][,[|msi][= ,[][,[]]]]]]` =20 Both option `com1` and `com2` follow the same format. =20 @@ -387,6 +387,9 @@ Both option `com1` and `com2` follow the same format. avoiding Intel AMT devices. * `amt` indicated that Xen should scan the PCI bus for the UART, including Intel AMT devices if present. +* `auto` indicates that Xen should use the default I/O base if a UART + responds there, and otherwise scan the PCI bus for the UART as `pci` + does, but only for devices with built-in parameters in Xen. =20 A typical setup for most situations might be `com1=3D115200,8n1` =20 diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index cdda28879e..ab55e2ba45 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -66,6 +66,7 @@ static struct ns16550 { bool dw_usr_bsy; #ifdef NS16550_PCI /* PCI card parameters. */ + bool pci_fallback; /* if =3D1, scan PCI if io_base has no UART */ bool pb_bdf_enable; /* if =3D1, pb-bdf effective, port behind brid= ge */ bool ps_bdf_enable; /* if =3D1, ps_bdf effective, port on pci card= */ pci_sbdf_t pci_bridge; @@ -1321,6 +1322,10 @@ pci_uart_config(struct ns16550 *uart, bool skip_amt,= unsigned int idx) } } =20 + /* Keep "auto" off unknown devices, including their BARs. = */ + if ( uart->pci_fallback && i =3D=3D ARRAY_SIZE(uart_config= ) ) + continue; + if ( port_idx >=3D param->max_ports ) { idx -=3D param->max_ports; @@ -1628,6 +1633,11 @@ static bool __init parse_positional(struct ns16550 *= uart, char **str) return true; conf +=3D 3; } + else if ( strncmp(conf, "auto", 4) =3D=3D 0 ) + { + uart->pci_fallback =3D true; + conf +=3D 4; + } else #endif { @@ -1819,7 +1829,26 @@ static void __init ns16550_parse_port_config( if ( uart->io_base =3D=3D 0 ) PARSE_ERR("I/O base address must be specified."); if ( !check_existence(uart) ) - PARSE_ERR("16550-compatible serial UART not present"); + { +#ifdef CONFIG_HAS_PCI + if ( uart->pci_fallback ) + { + pci_uart_config(uart, 1 /* skip AMT */, uart - ns16550_com); + if ( uart->ps_bdf_enable ) + printk("ns16550: com%u: no UART at default base, using %pp= \n", + (unsigned int)(uart - ns16550_com) + 1, + &uart->pci_device); + } + + /* + * A failed scan puts back the rejected base, and check_existence() + * passes MMIO addresses untested, so only ps_bdf_enable says that + * a device was found. + */ + if ( !uart->ps_bdf_enable || !check_existence(uart) ) +#endif + PARSE_ERR("16550-compatible serial UART not present"); + } =20 /* Register with generic serial driver. */ serial_register_uart(uart - ns16550_com, &ns16550_driver, uart); --=20 2.55.0