On Wed, Oct 18, 2023 at 12:38:57PM +0200, Manuel Bouyer wrote:
> Hello,
> With Xen 4.18, a PV domain running under pvshim doesn't get console input.
> This is because the domain id in pvshim isn't 0 (and on x86 max_init_domid is
> hardwired to 0), so console_input_domain() will never select that domain
> as input.
> 
> The attached patch fixes it by translating 0 to the real domain id for
> pvshim, but there may be a better way to do this.

Small improvement, print the real domain ID instead of DOM0

-- 
Manuel Bouyer <bou...@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--
--- drivers/char/console.c.orig 2023-10-18 12:24:57.221891748 +0200
+++ drivers/char/console.c      2023-10-18 12:41:10.513003560 +0200
@@ -478,14 +478,20 @@
 /* Make sure to rcu_unlock_domain after use */
 struct domain *console_input_domain(void)
 {
+    domid_t domid;
     if ( console_rx == 0 )
             return NULL;
-    return rcu_lock_domain_by_id(console_rx - 1);
+    if (console_rx == 1 && pv_shim)
+        domid = get_initial_domain_id();
+    else
+       domid = console_rx - 1;
+    return rcu_lock_domain_by_id(domid);
 }
 
 static void switch_serial_input(void)
 {
     unsigned int next_rx = console_rx;
+    domid_t domid;
 
     /*
      * Rotate among Xen, dom0 and boot-time created domUs while skipping
@@ -502,12 +508,16 @@
             break;
         }
 
-        d = rcu_lock_domain_by_id(next_rx - 1);
+       if (next_rx == 1 && pv_shim)
+           domid = get_initial_domain_id();
+       else
+           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;
         } else {
                printk("next_rx %d not domain", next_rx);

Reply via email to