From patchwork Wed Oct 18 14:58:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13427210 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 47F3ACDB482 for ; Wed, 18 Oct 2023 14:58:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.618664.962601 (Exim 4.92) (envelope-from ) id 1qt80G-0004uJ-Cc; Wed, 18 Oct 2023 14:58:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 618664.962601; Wed, 18 Oct 2023 14:58:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qt80G-0004uC-9p; Wed, 18 Oct 2023 14:58:32 +0000 Received: by outflank-mailman (input) for mailman id 618664; Wed, 18 Oct 2023 14:58:31 +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 1qt80F-0004u4-36 for xen-devel@lists.xenproject.org; Wed, 18 Oct 2023 14:58:31 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20610.outbound.protection.outlook.com [2a01:111:f400:7e1a::610]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cc863a86-6dc6-11ee-98d4-6d05b1d4d9a1; Wed, 18 Oct 2023 16:58:30 +0200 (CEST) Received: from DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) by PAXPR04MB9218.eurprd04.prod.outlook.com (2603:10a6:102:221::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 14:58:28 +0000 Received: from DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::d9c0:d907:4d2d:15b3]) by DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::d9c0:d907:4d2d:15b3%7]) with mapi id 15.20.6907.022; Wed, 18 Oct 2023 14:58:28 +0000 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: cc863a86-6dc6-11ee-98d4-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AdoUY/SnoMF98PVpgrX7XDY3gFOEg+1Ig8W+Qn97g8XGfgFpg1dvbdtzSBQuJH/ftycM9NuwCiK/VX7GktGTXYMswrLVrGkuCeeGlgNIPqzFa6PnnM2QAHEZ374TLv8M2rCxykNqgBhTwzL18yDnVVem/0Znjhyp9ztZQYMCDPQsfPfG2m7ZDlscOgFi3dKdtJsB58KSPlqxm8atJbuSU3v6mSO0V9lnAj883hVqrMp91yBKULCCs9L6Aqwb41rMS4ryfReCwyqWy4FQNrAB2B6U0yc5In1iGTKkXqP6p8wsxDkT6xf1eVGzdqblq4dJOOH3QEjPvtJGQLy5xS9d8Q== 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-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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JtdLStHJ6wPskxUHsn22Jm6tejXGHXKWQEDe753mGTI=; b=STp7LLMB0QlOLgd18yQC2tUh5jlgK7RQOwwwQm3YJFvdObHkMM7oGVfJaBkSLCM8smPesEJ3C8S5THWUfVqSM6iFfminWHzXzlf/iXSgd44EjuI5YhW7MXoFZ4XOVg3Dc5CBAQ/6yYNUNLc+9W4AbO61rA13umPPWlily+/JFSuETv2/xyuR3kw4P+onj7606zrllxkHf9rto8nXIXpKQcXfYLwPdsLLWsqgMMokp6I4pP2gAb4eV7YyiiUQVYXSH5STx3Zi3oZZ5n9SIvlX1vnmsFUpGmw2GkrxlZWwBZnDN/Wh0EshT/qrh7Whu/rGqlUFPPAPTjoj+XopOfpuOw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Wed, 18 Oct 2023 16:58:25 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu , Henry Wang , Michal Orzel , Manuel Bouyer From: Jan Beulich Subject: [PATCH] console: make input work again for pv-shim X-ClientProxiedBy: FR4P281CA0198.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e5::13) To DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8790:EE_|PAXPR04MB9218:EE_ X-MS-Office365-Filtering-Correlation-Id: 5987cc22-a158-4056-a621-08dbcfeaafb3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4S8cIsmSTs/wZhooeJWNgmqyL4bj9y4PC1cx781PTB2SZdiojEjssImRzB7TR8OQFJPaHUUqMXh/Jr1DkdeLadoDi2Mmt6Y3IMkjucANKXRy4CtZm0QmwaieOjDQzd94OUt53tvO0stKiHLGpsnKfXQhcoIbo9CwP2Ud9K1ye69uaBJCxULoQaxzGtb7Tt1b9Q5CVPcAoBeM5JWeqXt4eOQBbcK5Cb1hWm67ji2UZJByipPHfB540uKLYCpOpVXZzeogtw+aakzY4EE+zafxZr2DdXuXfSote1LmNEKfgwMxk9ZsaC8x2gIRnN9CA9LmVkVxbCK4fBUj2ydw3hYl5BrXYOu6Hhm2l4lKt4J5fIkhKUCjCWc+dSbeuACZm95T0OnGYQ/HmK06TmrvYuUjlBPvzp1PpRuwWAahEkbhyK1tQMfUZjnyp7bziqpV0OQrqtBJTYMBdSO/QCA8F0LHRuGNEF9rCKi8vOnBdeX8BpvY479sHYW/lW2tjaT0DkQCvr3r26fxdDvzhSzOC7Dh51+UQtKjqLyEQ6m5TseNReN1VZ5SjUZTVTQkQgq4EtL8vE+ddHOO0svtgRi+GQ8yKBSf3/luwHvHRxIcPGsAnM1eh8dRKQ69IvCc32rX1c4C1pczRJ5MzzrjihuyPeLJKQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8790.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(396003)(376002)(346002)(366004)(136003)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(26005)(41300700001)(36756003)(83380400001)(2616005)(6512007)(86362001)(38100700002)(31686004)(2906002)(6506007)(31696002)(6666004)(6916009)(5660300002)(66476007)(316002)(66946007)(54906003)(66556008)(8936002)(6486002)(478600001)(8676002)(4326008)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?CRnuAHsyqnqPJkIJoTbo+Ui8wkO9?= =?utf-8?q?/UY5ohVJ1ybEsNzBLnhd4opYlAnk0/VQC2jyZFgBWviDw7xdCz/WcQIedRp/BOvx1?= =?utf-8?q?MfJX4gu9knTJBWX1CszV8gdnUEpk+65GWr8orjjL051cY/rAH21A8HdBT/t6EuuDI?= =?utf-8?q?/gCk+DckQUDnyXgtqLT8ZVZuGT194Yf6uUiyn1974ZECHOSeuYIYiqSwCxz8cKBKH?= =?utf-8?q?GSMgE8QGbCTNnXTURH52tmzNNoVFq6C8mTmRMNaqrm0MGbb9x24vZUUs7yiNjbmc0?= =?utf-8?q?/5QpPB85NQ/42n/EQFIIst3LENdTdmk/0Lt2YxcEoHNlK0lxra9KwjN+yzAsFsziN?= =?utf-8?q?O9lCwDNQNher2M+e1DoiHHmucy9DQsgNKiGSYT3QGhCQB/3fpB0PPkC3HikpGMVL5?= =?utf-8?q?Hn81/Q03ktYjL1wpClX9/qLHhZacv3uPfPiK2f5sq8cHy+fMdrx5WRX1pfFd+FY+/?= =?utf-8?q?M4IJe8HAECA+QM19KrG8K/otAUcfavOovsyHLUAkGFo6YsoC6+UWK4Y7rohnBKMiW?= =?utf-8?q?wDMOicN4gxrz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hrF8/DlsDJkJ05NHMRzK0bM0WulAEfBUsaHEPBtF2?= =?utf-8?q?+/upCV5DowuzEZRKNDh7O/0aIxxDkYt6ELVP0gmJKNj3j0U04GIpPEAr634tsJJd9?= =?utf-8?q?BIA3xoNh03CM?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5987cc22-a158-4056-a621-08dbcfeaafb3 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8790.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 14:58:28.1030 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wuNRB/SqWWjpB9fzgZTDaOkH66EiDu2lAYYJ8ZofMsyxRajsTc2rAtH2KSwOWOpPFzBeO2QdXLit8JUs+LfsOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9218 From: Manuel Bouyer 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 Signed-off-by: Jan Beulich Reviewed-by: Julien Grall --- 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; } }