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

[XEN][PATCH] console/consoleio: account for xen serial input focus during write


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Thu, 4 Dec 2025 23:32:12 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=mMRJAKsb9K9uB+kPMBEqMhvInS5859NUvvO6Dcxef/k=; b=qGePmDnNrT1aYih0otTRaIyGpIFppMdOX3a4U+VwehINOWU4akkflMjKGqvdh87QtIq4DCOjeH7XS5YTUSUChfW5nyntUy5sP9igCHF6jXJnB7g09HZmb64x8jExSbtOpxSx/mNB6u8JaJxULQx9CRgvljDklo0j5IZpY+2FN5bY/IbdD9A9Cwxi0nKM8nrv/ZCzJXUwUiKlzCka0q9EQT+VPhCqoQYn0w+6tPzEm7aRvybooicKzArl0Xqi7S/yBx4EJ4f5luAfJd4YXZxyi+/ZLHluzhvylmJRhxQcTovEPONlQqYw55AzkIATPdouC4zAJapp1mXCaqECq4awwQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PhOsl1krlkS1p6dpVDkX78Zfk4WcyugGgW+4VK6ogOFaXGJzgYClZrZrKF1BxRfKjOi1L1lInbF/u85jwZhdmFnRsg34XzCo7Fuy+1GczD6N1fjEDw9Kal35o+PoCXij6uB6u4Giw6bgYTbLardnoLo7X5vZ+PXgXhUq3JbMrGOE5+mqWrSabUFR0aywDxlELqvetcy0x6QaxgQAo7MVFNgAsjuuCoVojbV3pufUInf5uRh/VhzTXY1MW0AucDwEzN0On/5hgf+X1Gk0lRk2JAvVRmGtWN9CbhI9ZeTIct5QIKrdgXVCJEpaBq/vDlhpIeCDQYMnaFXXKDUOjbcnSg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Grygorii Strashko <grygorii_strashko@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Victor Lira <victorm.lira@xxxxxxx>
  • Delivery-date: Thu, 04 Dec 2025 23:32:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcZXY3Nl349El2IUi++g6UhbChUA==
  • Thread-topic: [XEN][PATCH] console/consoleio: account for xen serial input focus during write

From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

When 2 or more domains are created and:
- one is hwdom with "hvc0" (console_io) console
- other DomUs with vpl011 or "hvc0" (console_io) console
console output from hwdom may mix with output from other domains.

Example:
[    2.288816] Key type id_legacy registered
[    2.291894] n(XEN) DOM1: [    1.016950] DMA: preallocated 128 KiB 
GFP_KERNEL|GFP_DMA32 pool for atomic allocations
fs4filelayout_init: NFSv4 File Layout Driver Registering...
(XEN) DOM1: [    1.018846] audit: initializing netlink subsys (disabled)

This happens because for hwdom the console output is produced by domain and
handled by Xen as stream of chars, which can be interrupted when hwdom is
scheduled out and so, cause console output mix.
The Xen consoleio code trying to mimic serial HW behavior for hwdom
unconditionally by sending available data to serial HW on arrival.
Xen consoleio code does not account for Xen console input focus, comparing
to emulated serial hw, like vpl011, which does the same for domain with
active Xen console input focus only.

Switching console input focus to Xen improves situation, but not enough.

This patch changes consoleio code to account for domain with active Xen
console input focus - console output will be sent directly to serial HW
only if domain has active Xen console input focus. For other domains -
console output will be buffered and sync on per-line basis.

Example output:
(d2) [    4.263417] Key type id_legacy registered
(XEN) DOM1: [    4.658080] Advanced Linux Sound Architecture Driver Initialized.
(d2) [    4.277824] nfs4filelayout_init: NFSv4 File Layout Driver Registering...

Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
---
This causes random multi-domain tests failures due to inter-domain console
mixing which breaks console parsing checks.

 xen/drivers/char/console.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index a99605103552..391cefc1a7c6 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -733,6 +733,8 @@ static long 
guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,
 
     while ( count > 0 )
     {
+        struct domain *input;
+
         if ( kcount && hypercall_preempt_check() )
             return hypercall_create_continuation(
                 __HYPERVISOR_console_io, "iih",
@@ -742,7 +744,9 @@ static long 
guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,
         if ( copy_from_guest(kbuf, buffer, kcount) )
             return -EFAULT;
 
-        if ( is_hardware_domain(cd) )
+        input = console_get_domain();
+
+        if ( cd == input )
         {
             /* Use direct console output as it could be interactive */
             nrspin_lock_irq(&console_lock);
@@ -783,6 +787,8 @@ static long 
guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,
             spin_unlock(&cons->lock);
         }
 
+        console_put_domain(input);
+
         guest_handle_add_offset(buffer, kcount);
         count -= kcount;
     }
-- 
2.34.1



 


Rackspace

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