From patchwork Wed Oct 18 10:38:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Bouyer X-Patchwork-Id: 13426837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8232ECDB47E for ; Wed, 18 Oct 2023 10:39:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.618483.962161 (Exim 4.92) (envelope-from ) id 1qt3x9-0001IM-80; Wed, 18 Oct 2023 10:39:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 618483.962161; Wed, 18 Oct 2023 10:39:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qt3x9-0001IF-5S; Wed, 18 Oct 2023 10:39:03 +0000 Received: by outflank-mailman (input) for mailman id 618483; Wed, 18 Oct 2023 10:39:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qt3x7-0001I9-V0 for xen-devel@lists.xenproject.org; Wed, 18 Oct 2023 10:39:01 +0000 Received: from isis.lip6.fr (isis.lip6.fr [2001:660:3302:283c::2]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8bddff4b-6da2-11ee-98d4-6d05b1d4d9a1; Wed, 18 Oct 2023 12:39:00 +0200 (CEST) Received: from asim.lip6.fr (asim.lip6.fr [132.227.86.2]) by isis.lip6.fr (8.16.1/8.15.2) with ESMTPS id 39IAcwbl000294 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Wed, 18 Oct 2023 12:38:58 +0200 (CEST) Received: from armandeche.soc.lip6.fr (armandeche [132.227.63.133]) by asim.lip6.fr (8.15.2/8.15.2) with ESMTP id 39IAcwoJ022746 for ; Wed, 18 Oct 2023 12:38:58 +0200 (MEST) Received: by armandeche.soc.lip6.fr (Postfix, from userid 20331) id D3B1577C1; Wed, 18 Oct 2023 12:38:57 +0200 (MEST) 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" X-Inumbo-ID: 8bddff4b-6da2-11ee-98d4-6d05b1d4d9a1 Date: Wed, 18 Oct 2023 12:38:57 +0200 From: Manuel Bouyer To: xen-devel@lists.xenproject.org Subject: Xen 4.18 pvshim console issue (with patch) Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.4 (isis.lip6.fr [132.227.60.2]); Wed, 18 Oct 2023 12:38:58 +0200 (CEST) X-Scanned-By: MIMEDefang 3.3 on 132.227.60.2 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. --- drivers/char/console.c.orig 2023-10-18 12:24:57.221891748 +0200 +++ drivers/char/console.c 2023-10-18 12:30:26.072844802 +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,7 +508,11 @@ 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);