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

[PATCH] console: make input work again for pv-shim


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 18 Oct 2023 16:58:25 +0200
  • 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=JtdLStHJ6wPskxUHsn22Jm6tejXGHXKWQEDe753mGTI=; b=Coa08xWIQjOwomobi8OdZtU52gWpjExT0azZlCX/jKrbK4cGY5nmt7ZcsW7uqOL0PreUVRhissLkK3sKJDtKhhwfmvoINH5vQgqPUZ4oCofwbMyFQNwGnlZGfOyup6B69MMAoILLT0Q0n4DpGfQHsEyg6Bwfsm/HbZvg/CXIUW0P1+0ll2RdTesaUZ9AnoIGNhSjoZiKsJWkIkPn8Zqu4XpvMCsFha+sTCgzr22rl/F0MmSbRdWNzzCZcDfL88tzjJqLJCqrFQMZGvw3k2pKoAi8hA7jfVvcZ/PUiR/6dGwci8EFm8PBSNCoBJxAptnCWjoSCWulfhss2QHPGzzd5Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AdoUY/SnoMF98PVpgrX7XDY3gFOEg+1Ig8W+Qn97g8XGfgFpg1dvbdtzSBQuJH/ftycM9NuwCiK/VX7GktGTXYMswrLVrGkuCeeGlgNIPqzFa6PnnM2QAHEZ374TLv8M2rCxykNqgBhTwzL18yDnVVem/0Znjhyp9ztZQYMCDPQsfPfG2m7ZDlscOgFi3dKdtJsB58KSPlqxm8atJbuSU3v6mSO0V9lnAj883hVqrMp91yBKULCCs9L6Aqwb41rMS4ryfReCwyqWy4FQNrAB2B6U0yc5In1iGTKkXqP6p8wsxDkT6xf1eVGzdqblq4dJOOH3QEjPvtJGQLy5xS9d8Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Manuel Bouyer <bouyer@xxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 18 Oct 2023 14:58:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Manuel Bouyer <bouyer@xxxxxxxxxxxxxxx>

The use of rcu_lock_domain_by_id() right in switch_serial_input() makes
assumptions about domain IDs which don't hold when in shim mode: The
sole (initial) domain there has a non-zero ID. Obtain the real domain ID
in that case (generalized as get_initial_domain_id() returns zero when
not in shim mode).

Note that console_input_domain() isn't altered, for not being used when
in shim mode (or more generally on x86).

Fixes: c2581c58bec9 ("xen/console: skip switching serial input to non existing 
domains")
Signed-off-by: Manuel Bouyer <bouyer@xxxxxxxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -468,7 +468,7 @@ static void cf_check dump_console_ring_k
 #define switch_code (opt_conswitch[0]-'a'+1)
 /*
  * console_rx=0 => input to xen
- * console_rx=1 => input to dom0
+ * console_rx=1 => input to dom0 (or the sole shim domain)
  * console_rx=N => input to dom(N-1)
  */
 static unsigned int __read_mostly console_rx = 0;
@@ -493,6 +493,7 @@ static void switch_serial_input(void)
      */
     for ( ; ; )
     {
+        domid_t domid;
         struct domain *d;
 
         if ( next_rx++ >= max_console_rx )
@@ -502,12 +503,18 @@ static void switch_serial_input(void)
             break;
         }
 
-        d = rcu_lock_domain_by_id(next_rx - 1);
+#ifdef CONFIG_PV_SHIM
+        if ( next_rx == 1 )
+            domid = get_initial_domain_id();
+        else
+#endif
+            domid = next_rx - 1;
+        d = rcu_lock_domain_by_id(domid);
         if ( d )
         {
             rcu_unlock_domain(d);
             console_rx = next_rx;
-            printk("*** Serial input to DOM%u", next_rx - 1);
+            printk("*** Serial input to DOM%u", domid);
             break;
         }
     }



 


Rackspace

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