All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Henry Wang <Henry.Wang@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	Manuel Bouyer <bouyer@antioche.eu.org>
Subject: [PATCH] console: make input work again for pv-shim
Date: Wed, 18 Oct 2023 16:58:25 +0200	[thread overview]
Message-ID: <ed275abf-351f-5237-7e19-a3856f6d4272@suse.com> (raw)

From: Manuel Bouyer <bouyer@antioche.eu.org>

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@antioche.eu.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- 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;
         }
     }


             reply	other threads:[~2023-10-18 14:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18 14:58 Jan Beulich [this message]
2023-10-18 18:00 ` [PATCH] console: make input work again for pv-shim Julien Grall
2023-10-19  0:29   ` Henry Wang
2023-10-19  6:35   ` Jan Beulich
2023-10-19  6:50     ` Henry Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ed275abf-351f-5237-7e19-a3856f6d4272@suse.com \
    --to=jbeulich@suse.com \
    --cc=Henry.Wang@arm.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bouyer@antioche.eu.org \
    --cc=george.dunlap@citrix.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.