From patchwork Tue Nov 26 23:21:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886396 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 5F320D66B9D for ; Tue, 26 Nov 2024 23:23:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844045.1259593 (Exim 4.92) (envelope-from ) id 1tG4tl-0000MH-Sm; Tue, 26 Nov 2024 23:23:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844045.1259593; Tue, 26 Nov 2024 23:23:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tl-0000MA-OX; Tue, 26 Nov 2024 23:23:13 +0000 Received: by outflank-mailman (input) for mailman id 844045; Tue, 26 Nov 2024 23:22:01 +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 1tG4sb-0000Ao-91 for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:01 +0000 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3a6e18f8-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:21:57 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id AC7B8A401D8; Tue, 26 Nov 2024 23:20:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 3A719C4CED3; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D6EAD66B88; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) 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: 3a6e18f8-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjE0Ny43NS4xOTMuOTEiLCJoZWxvIjoibnljLnNvdXJjZS5rZXJuZWwub3JnIn0= X-Custom-Transaction: eyJpZCI6IjNhNmUxOGY4LWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzE3LjQyMjY3LCJzZW5kZXIiOiJkZXZudWxsK2RtdWtoaW4uZm9yZC5jb21Aa2VybmVsLm9yZyIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663315; bh=Yb0mvdyBQS1c7dAPhUGgIsRh+rcogZBJTDsqTjxJ3hs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=G379LioZzb3INaF2u6erQbpZ0mHNJM6NtXCtFwfgkkuivFbiPCwplSphDrw9rXnEK j7OIGwcs2UrkkOTWmrjtJMblVivSnLXVA9bV7WRupIUWNdooiGLxvQ3kQzffCypdm8 y20BYGp2Fl1E1CXAYVnsNhEjcmYMbPJLdGVKSuULPehJgzwyvVqwroEnrCqRT77a07 ZlreXPxqEpm7c0zJCzeowVKqQuzHZHuqAzRDIXcRwRlCazW5ORj/NANrNsfjzQZtGG kUoEi4+2yhntsQCttMPLAXqhUHpq/Kx5CI8j31llSMCXR3I2Vc8hkwEDdiOE+MoZB9 2GYYk8Z3fXYEA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:21:51 -0800 Subject: [PATCH 01/36] x86/setup: fix typo in acpi=off description MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-1-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=913; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=7yTBjRl8lmc1tg+ZFlXhUwzuZwMkcPhVqwc9gw3xsIQ=; b=fGhLeTafOQHdmZPBdD9bIVheTVXsfAPHD70yBmhJl2mjqDLgSZD+W7NfTS1UpjOjg5WWyO82s 3nLC9cTHbFbD0Zur6mUCtIfo/TkKIfkB94RsV1dDD42fBf/p2X0hkh9 X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Signed-off-by: Denis Mukhin --- xen/arch/x86/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d8661d7ca699c96f38229c75ad0a8626c6f675d4..0a748e2c14122d6c5d692bc5691e8cbe13a32c81 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -83,7 +83,7 @@ int8_t __initdata opt_probe_port_aliases = -1; boolean_param("probe-port-aliases", opt_probe_port_aliases); /* **** Linux config option: propagated to domain0. */ -/* "acpi=off": Sisables both ACPI table parsing and interpreter. */ +/* "acpi=off": Disables both ACPI table parsing and interpreter. */ /* "acpi=force": Override the disable blacklist. */ /* "acpi=ht": Limit ACPI just to boot-time to enable HT. */ /* "acpi=noirq": Disables ACPI interrupt routing. */ From patchwork Tue Nov 26 23:21:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886403 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 0CE8AD66B86 for ; Tue, 26 Nov 2024 23:23:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844047.1259602 (Exim 4.92) (envelope-from ) id 1tG4tm-0000S5-Dm; Tue, 26 Nov 2024 23:23:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844047.1259602; Tue, 26 Nov 2024 23:23:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tm-0000Qp-7M; Tue, 26 Nov 2024 23:23:14 +0000 Received: by outflank-mailman (input) for mailman id 844047; Tue, 26 Nov 2024 23:22:02 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sc-0000At-3S for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:02 +0000 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3abaf4ed-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:21:57 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id BD963A41660; Tue, 26 Nov 2024 23:20:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 47EA8C4CED2; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37680D66B8A; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) 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: 3abaf4ed-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjE0Ny43NS4xOTMuOTEiLCJoZWxvIjoibnljLnNvdXJjZS5rZXJuZWwub3JnIn0= X-Custom-Transaction: eyJpZCI6IjNhYmFmNGVkLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzE3Ljg5NTQ0NCwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663315; bh=cKINO/Hsop/bfc6jLIz0xl2D+OXz60jGYySFfpDcAlU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=q5St0jFa5oFUvjtCcRCeWJmo6nYrhlIHDG52k32aN6SMTRRJ/SPvVvpVGXpn7yJ5C dFdQRzjsTwehBpnCGgLBzkzeOgmKwSRK+TR5NwnZQ0BMxFyUgzADvvckX31MpRHKE4 xz48heyE1k5iquEGcUE51LjUw36xlXsaXHEh+UtYPHV2wf7aoXXnb2NxifKhG00N49 A55dQF8MPu9VzDAG6cUnEhbKBYRk+AsxkynSiPxMMIK96hvppfssOfNycH3etAiLZi 5VvucsQ+xGcrQqXUqotLn1vvutpDF8Z2cpyXJsRMztpKmQa0o6SYDLgYtOWjKokVWW ARdgoCOj25yuQ== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:21:52 -0800 Subject: [PATCH 02/36] xsm/flask: missing breaks, MISRA rule 16.4 MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-2-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=1534; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=Om6cdnbe5fxG+CPjXPUOumzF0XPQ191PKf8s/8GFQ90=; b=w8ahloFDu924cxnDNLZ4R1wwM6DWcNf1t2DrnlPft9LzkIetQCU1BI/6U654/5ljvXy08gkyR 0sUOpQD/agmCgTz6kCaQ8aW0762sTvVUZlawmKG9f0feuH2wHd5/HYB X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin While working on console forwarding for virtual NS8250 I stepped into flask_domain_alloc_security() where break statement was missing in default case which violates MISRA rule 16.4. Fixed everywhere in hooks.c. Signed-off-by: Denis Mukhin --- xen/xsm/flask/hooks.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index dfa23738cd8a9fd91eda23d9c328c3cc55d31418..a79474ffe43af19f602a6c067eab6b40dba0d946 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -198,6 +198,7 @@ static int cf_check flask_domain_alloc_security(struct domain *d) else if ( pv_shim ) dsec->sid = SECINITSID_DOMU; } + break; } dsec->self_sid = dsec->sid; @@ -342,6 +343,7 @@ static int cf_check flask_evtchn_send(struct domain *d, struct evtchn *chn) break; default: rc = avc_unknown_permission("event channel state", chn->state); + break; } return rc; @@ -1310,6 +1312,7 @@ static int cf_check flask_hvm_param(struct domain *d, unsigned long op) break; default: perm = HVM__HVMCTL; + break; } return current_has_perm(d, SECCLASS_HVM, perm); @@ -2013,6 +2016,7 @@ const struct xsm_ops *__init flask_init( case FLASK_BOOTPARAM_INVALID: default: panic("Flask: Invalid value for flask= boot parameter.\n"); + break; } avc_init(); From patchwork Tue Nov 26 23:21:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886406 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 11DD1D66BA7 for ; Tue, 26 Nov 2024 23:23:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844052.1259624 (Exim 4.92) (envelope-from ) id 1tG4tn-0000nZ-Cz; Tue, 26 Nov 2024 23:23:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844052.1259624; Tue, 26 Nov 2024 23:23:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tn-0000mE-4r; Tue, 26 Nov 2024 23:23:15 +0000 Received: by outflank-mailman (input) for mailman id 844052; Tue, 26 Nov 2024 23:22:04 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4se-0000At-CO for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:04 +0000 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3ae27bca-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:21:57 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id E9453A41665; Tue, 26 Nov 2024 23:20:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 56E98C4CED7; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A42ED66B84; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) 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: 3ae27bca-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjE0Ny43NS4xOTMuOTEiLCJoZWxvIjoibnljLnNvdXJjZS5rZXJuZWwub3JnIn0= X-Custom-Transaction: eyJpZCI6IjNhZTI3YmNhLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzE3Ljk3MDI5MSwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663315; bh=hhpepZyC6+B98tKRYu7FEASFfIF/3/TSsCfLQMcZ32A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qnzUmTBBnyPw/PBcHJlWArvKyI3BqwPBho6sr0Ljp4rDl716NfDn4W/kR5sa24HeN LfQqL14pYIaW5oKjKa+2wWEQQqLcYQJUaxaX8lFThkeZ4wfrVxqa8riVBoZ+pmXa6G e5DZ+xsajgVkEYhLPPHs2zODp10ZEE9ocsKEsGSx6CBmZRBLJ21xSFiBVJotMKDIci GjXijXXt4ITNwNyav8sKH8kwvnJ4lMB8dPxNL0+/muqV+4hLhgFyb840SKGcF4PKV6 WL+APewHdNypUEBBSXUA/yv5fEa67mtK4tUfX8LirE2kXWxb5ury8wvshCHtOYW/jy SbzrPLNILgJtQ== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:21:53 -0800 Subject: [PATCH 03/36] xen: introduce resource.h MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-3-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=4665; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=Q8GpN19knhkzccfTAV4prViqD1gvBrGqV7AxMvPxGlg=; b=R204wyNJVDFwtxunVQ6uTri4iQAm0/nHG/UG64/jv9N7oGTk83gB3DKrDKESdQQu1IVN9xlm7 3k8U0eTtjb9DPHLtDbGKT5MQ/HAPZ4KbuEtGVkcnzKJn04P8qSywJYz X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Move resource definitions to a new architecture-agnostic shared header file. It will be used in follow on NS8250 emulator code to describe legacy PC COM resources. Signed-off-by: Denis Mukhin --- xen/common/device-tree/device-tree.c | 21 +------------------ xen/drivers/passthrough/arm/smmu.c | 15 +------------- xen/include/xen/resource.h | 40 ++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 34 deletions(-) diff --git a/xen/common/device-tree/device-tree.c b/xen/common/device-tree/device-tree.c index d0528c5825651f7cc9ebca0c949229c9083063c6..e8f810b2fe10890c033ed3a9d4ca627010ad019b 100644 --- a/xen/common/device-tree/device-tree.c +++ b/xen/common/device-tree/device-tree.c @@ -24,6 +24,7 @@ #include #include #include +#include const void *device_tree_flattened; dt_irq_xlate_func dt_irq_xlate; @@ -535,26 +536,6 @@ int dt_child_n_size_cells(const struct dt_device_node *parent) return __dt_n_size_cells(parent, true); } -/* - * These are defined in Linux where much of this code comes from, but - * are currently unused outside this file in the context of Xen. - */ -#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ - -#define IORESOURCE_TYPE_BITS 0x00001f00 /* Resource type */ -#define IORESOURCE_IO 0x00000100 /* PCI/ISA I/O ports */ -#define IORESOURCE_MEM 0x00000200 -#define IORESOURCE_REG 0x00000300 /* Register offsets */ -#define IORESOURCE_IRQ 0x00000400 -#define IORESOURCE_DMA 0x00000800 -#define IORESOURCE_BUS 0x00001000 - -#define IORESOURCE_PREFETCH 0x00002000 /* No side effects */ -#define IORESOURCE_READONLY 0x00004000 -#define IORESOURCE_CACHEABLE 0x00008000 -#define IORESOURCE_RANGELENGTH 0x00010000 -#define IORESOURCE_SHADOWABLE 0x00020000 - /* * Default translator (generic bus) */ diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index 03d22bce1e497e41834c273f9048b98dcbd48a54..aa6a968b574dce7cc753e8070fad3a6e585cd9e7 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -70,22 +71,8 @@ #define of_property_read_u32(np, pname, out) (!dt_property_read_u32(np, pname, out)) #define of_property_read_bool dt_property_read_bool #define of_parse_phandle_with_args dt_parse_phandle_with_args - -/* Xen: Helpers to get device MMIO and IRQs */ -struct resource -{ - paddr_t addr; - paddr_t size; - unsigned int type; -}; - -#define resource_size(res) (res)->size; - #define platform_device dt_device_node -#define IORESOURCE_MEM 0 -#define IORESOURCE_IRQ 1 - static struct resource *platform_get_resource(struct platform_device *pdev, unsigned int type, unsigned int num) diff --git a/xen/include/xen/resource.h b/xen/include/xen/resource.h new file mode 100644 index 0000000000000000000000000000000000000000..4962e17da8387b7f324317482b19cc9fe71433fc --- /dev/null +++ b/xen/include/xen/resource.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * System resource description. + * + * Reference: + * include/linux/ioport.h + */ +#if !defined(XEN__RESOURCE_H) +#define XEN__RESOURCE_H + +#define IORESOURCE_BITS 0x000000FFU /* Bus-specific bits */ + +#define IORESOURCE_TYPE_BITS 0x00001F00U /* Resource type */ +#define IORESOURCE_IO 0x00000100U /* PCI/ISA I/O ports */ +#define IORESOURCE_MEM 0x00000200U +#define IORESOURCE_REG 0x00000300U /* Register offsets */ +#define IORESOURCE_IRQ 0x00000400U +#define IORESOURCE_DMA 0x00000800U +#define IORESOURCE_BUS 0x00001000U + +#define IORESOURCE_PREFETCH 0x00002000U /* No side effects */ +#define IORESOURCE_READONLY 0x00004000U +#define IORESOURCE_CACHEABLE 0x00008000U +#define IORESOURCE_RANGELENGTH 0x00010000U +#define IORESOURCE_SHADOWABLE 0x00020000U + +#define IORESOURCE_UNKNOWN (~0U) + +struct resource { + paddr_t addr; + paddr_t size; + unsigned int type; +}; + +#define resource_size(res) (res)->size; + +#define foreach_resource(res) \ + for (; res && res->type != IORESOURCE_UNKNOWN; res++) + +#endif /* #if !defined(XEN__RESOURCE_H) */ From patchwork Tue Nov 26 23:21:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886400 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 51ED3D66BA4 for ; Tue, 26 Nov 2024 23:23:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844048.1259606 (Exim 4.92) (envelope-from ) id 1tG4tm-0000XD-Lc; Tue, 26 Nov 2024 23:23:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844048.1259606; Tue, 26 Nov 2024 23:23:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tm-0000V3-Gc; Tue, 26 Nov 2024 23:23:14 +0000 Received: by outflank-mailman (input) for mailman id 844048; Tue, 26 Nov 2024 23:22:02 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sc-0000At-CM for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:02 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3aa2fa8b-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:21:57 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 78BB95C5BEA; Tue, 26 Nov 2024 23:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 6B1C8C4CEDB; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 596E7D66B88; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) 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: 3aa2fa8b-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNhYTJmYThiLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzE3Ljg5MTk3MSwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663315; bh=jP7Qo7rqdlhdDtQjECWtHV/Nhjgbh2HMa37UuR2ELXI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fa5bqt+h1xnsBmKLWN7RhsQfcSmOrhJvxsFWm7LcFlX4ah/uxa/fA2KRGR0PdI8Vf DdppIqEwozhki1m1+mmysleQ1sjqM/oCYx15QRdFQZdp0BhMBqtU3XIGMsdnkgf9Nl a6lgFHE4Nm9KAnpb4WvEji9B8K5Kx/nFjYu9iaEdkUmCNvid3n2rs/Hx3a4U1Hl9BA e6qxS7fc11oYzkOTDo+DJjbKJU+H8v45MObr+DkF8HTuCzNknL8r+rtKNK0QSLZInB 3NzaBj0qmfyv5wZMl73GWH4fIiBML8YQgHe2Zqz8z9XuvUpVN5EVJUPtzcbg7bxp/f jEw+zh0UEunPg== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:21:54 -0800 Subject: [PATCH 04/36] xen/irq: introduce NO_IRQ MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-4-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=616; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=dP3fe+TbEoRyzDIKnwZpy2zc7XNhJoHUDN0gqSrT6Sc=; b=ZK/Egrhd1ftyBDG8fHCbgj99AZ9DcnZ5TxuavepL4iKCTofpCdmvmPQJY/yN3M2p29rTI4mg6 v8M76j0gxtADkBiXTcySpLMh1uQQabkcw/KIGK4vj4s7sXp5Zfzx7iQ X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Introduce definition for IRQ resource checks. Signed-off-by: Denis Mukhin --- xen/include/xen/irq.h | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h index 95034c0d6bb5f0aa7d5bb572aca59872508a438a..aee878293ecc0de6a938bcfea1140d36b4de745a 100644 --- a/xen/include/xen/irq.h +++ b/xen/include/xen/irq.h @@ -53,6 +53,7 @@ struct irqaction { #define AUTO_ASSIGN_IRQ (-1) #define NEVER_ASSIGN_IRQ (-2) #define FREE_TO_ASSIGN_IRQ (-3) +#define NO_IRQ (-4) struct irq_desc; From patchwork Tue Nov 26 23:21:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886407 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 2480ED66BAB for ; Tue, 26 Nov 2024 23:23:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844046.1259596 (Exim 4.92) (envelope-from ) id 1tG4tm-0000OO-40; Tue, 26 Nov 2024 23:23:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844046.1259596; Tue, 26 Nov 2024 23:23:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tl-0000Ni-VH; Tue, 26 Nov 2024 23:23:13 +0000 Received: by outflank-mailman (input) for mailman id 844046; Tue, 26 Nov 2024 23:22:01 +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 1tG4sb-0000Ao-I9 for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:01 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3aa60ca8-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:21:57 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8DBEA5C5C0D; Tue, 26 Nov 2024 23:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 79CDAC4CEDD; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BC62D66B89; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) 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: 3aa60ca8-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNhYTYwY2E4LWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzE4LjA5Nzk5Miwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663315; bh=xRl/VI33XtcNQyJ8toSM7CxORY63SAcLHHhJDp/5VHE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RdupsLJVIRafQLWxJMPEhpP/XHYk4ho+6qgZbdxC8XWaZKfDeIdNdkxnFyp5JmVMD bymk/6NP2NGllgK/rnULmAZNoSi9ArJupKYHrs8c7J4eOO87gCwDmpd+kP8TW7chPq GPtg76P4sN/1vs8Wc3mg82ZjzroFo8mLGeCEzAjgM0OZ65hkvaaL8cKSGU9BT2t9tB T8Q92HbKVu7M9XePQndcz3RfJ1J21soYc9KCRwMHiSmGY0C1Uc07qblTocMmoburKs 9Yy6Y9xAmpK+dwHCcX9WGZJZjUQUWe8kSEhqaBf9S/XeHwEfsdCpl/P9JTwfUGi8Aq HFQgAR3Tfy4HA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:21:55 -0800 Subject: [PATCH 05/36] xen/xmalloc: add kmalloc() and kfree() aliases MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-5-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=2077; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=izvZS5PqvGBio87RDretaNG85fhbAWhHk9N0az9Fz9c=; b=DxooxiraEmxSjKMVEBBQD4C5YYEkrJbAOK1wZaShOd6buUxM3dQFSSYYVIfElWUereMJvfwLg Wj8gFWn4yIjB0TL6qPikxL3D5RpBO5Qg26QYelUQogHdovGoR4kWouc X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Move existing aliases to a common header so those could be used in the new code. The code looks simpler w/ kmalloc(): type specification of the object being allocated is not required, e.g.: ... struct my_obj_s *obj; obj = kmalloc(sizeof(*obj), 0); ... Signed-off-by: Denis Mukhin --- xen/drivers/passthrough/arm/smmu.c | 4 ---- xen/include/xen/xmalloc.h | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index aa6a968b574dce7cc753e8070fad3a6e585cd9e7..b343dbc32282136ccb95654ae2756eaa8a51149f 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -136,11 +136,7 @@ typedef enum irqreturn irqreturn_t; #define dev_name(dev) dt_node_full_name(dev_to_dt(dev)) /* Alias to Xen allocation helpers */ -#define kfree xfree -#define kmalloc(size, flags) _xmalloc(size, sizeof(void *)) -#define kzalloc(size, flags) _xzalloc(size, sizeof(void *)) #define devm_kzalloc(dev, size, flags) _xzalloc(size, sizeof(void *)) -#define kmalloc_array(size, n, flags) _xmalloc_array(size, sizeof(void *), n) #define devm_kcalloc(dev, n, size, flags) \ _xzalloc_array(size, sizeof(void *), n) diff --git a/xen/include/xen/xmalloc.h b/xen/include/xen/xmalloc.h index b903fa2e26e198fc80fc6010c3165cc50b1197c7..eea8cced51d9fe784b558201a68648e1672d624f 100644 --- a/xen/include/xen/xmalloc.h +++ b/xen/include/xen/xmalloc.h @@ -16,6 +16,11 @@ #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type))) #define xzalloc(_type) ((_type *)_xzalloc(sizeof(_type), __alignof__(_type))) +#define kfree xfree +#define kmalloc(size, flags) _xmalloc(size, sizeof(void *)) +#define kzalloc(size, flags) _xzalloc(size, sizeof(void *)) +#define kmalloc_array(size, n, flags) _xmalloc_array(size, sizeof(void *), n) + /* * Allocate space for a typed object and copy an existing instance. * From patchwork Tue Nov 26 23:21:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886408 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 0D0F7D66BA9 for ; Tue, 26 Nov 2024 23:23:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844059.1259657 (Exim 4.92) (envelope-from ) id 1tG4tp-0001Wy-Do; Tue, 26 Nov 2024 23:23:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844059.1259657; Tue, 26 Nov 2024 23:23:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tp-0001UA-15; Tue, 26 Nov 2024 23:23:17 +0000 Received: by outflank-mailman (input) for mailman id 844059; Tue, 26 Nov 2024 23:22:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sg-0000At-D7 for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:06 +0000 Received: from nyc.source.kernel.org (nyc.source.kernel.org [2604:1380:45d1:ec00::3]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3b0f43ea-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:21:58 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 2BCF5A4166A; Tue, 26 Nov 2024 23:20:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 8A7ACC4CEE0; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82931D66B8A; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) 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: 3b0f43ea-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjI2MDQ6MTM4MDo0NWQxOmVjMDA6OjMiLCJoZWxvIjoibnljLnNvdXJjZS5rZXJuZWwub3JnIn0= X-Custom-Transaction: eyJpZCI6IjNiMGY0M2VhLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzE4LjQxOTIzNiwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663315; bh=Mz0LfCOOHYiw5/C9m9hW2cPDEp/vC7dK7lem4N02Sxg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=aIjU402cJH+SGngOO0S0c6Rj4bK3IJx5aoYni+Vmv0ttkiuk7zUgf5Ov6pmVlYuTq lYMq+ThcZiAhepv24l0dj4PvMButU0KqFWFq3a5QvoK8JIHalQlmstew7fjhEIWmNC hN/pAhCFchm71EpQV5lRA24sS+L9fwb609cOp4AGwbU3te+K+36l0k/X3Git4mCC99 VJYRZoUpuk36qiiXIWUYASWa/I09wo9NDWljCaO5a8wHutCFHL1aglM4QfNJUh8v/f i0pulpTWshGNcmhixEmmpgdAJJilIR5OA1kcpyHHnlRVd/GlTj0Es8mPc/frREm3tW LGaXIdaUo+r5Q== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:21:56 -0800 Subject: [PATCH 06/36] xen/ctype: introduce isconsole() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-6-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=2961; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=AiWQqLZufYvPF2BvW1MH1/m06BTcFm+ZjCUWxGGdDOM=; b=Nk3hSzmyiSciOxuFiqeHNmLM17vLHl4dm7GK5e+zTLBVctllzH40H0KiGU9Ltvtt8mndY72w/ tHnwxiHyr2dCyF6c8DfKcqBWQiThwRjNDVBdSjU+V1SPC00i/smcg7U X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin There are several console drivers which have same checks w.r.t. printable characters. The check is moved to new isconsole() macro and re-used in the console drivers. Signed-off-by: Denis Mukhin --- xen/arch/arm/vuart.c | 3 +-- xen/arch/x86/hvm/hvm.c | 3 +-- xen/drivers/char/console.c | 2 +- xen/include/xen/ctype.h | 3 +++ 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c index d5ba483f1e63245e545346ad5045098152b8c152..ac76e2327bb84f05ea5716c6f5550f94812d2827 100644 --- a/xen/arch/arm/vuart.c +++ b/xen/arch/arm/vuart.c @@ -79,8 +79,7 @@ static void vuart_print_char(struct vcpu *v, char c) struct domain *d = v->domain; struct vuart *uart = &d->arch.vuart; - /* Accept only printable characters, newline, and horizontal tab. */ - if ( !isprint(c) && (c != '\n') && (c != '\t') ) + if ( !isconsole(c) ) return ; spin_lock(&uart->lock); diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 74e58c653e6f697e7e563fd076bbbafaf257137d..493b699c708949b2109c26573a107565543f5d45 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -561,8 +561,7 @@ static int cf_check hvm_print_line( if ( dir != IOREQ_WRITE ) return X86EMUL_UNHANDLEABLE; - /* Accept only printable characters, newline, and horizontal tab. */ - if ( !isprint(c) && (c != '\n') && (c != '\t') ) + if ( !isconsole(c) ) return X86EMUL_OKAY; spin_lock(&cd->pbuf_lock); diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 7da8c5296f3b62c6c45131c58fe5cf0e393e9ef3..bb56953bab681a13da8d41431aba4632f1919df9 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -674,7 +674,7 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, c = *kin++; if ( c == '\n' ) break; - if ( isprint(c) || c == '\t' ) + if ( isconsole(c) ) *kout++ = c; } while ( --kcount > 0 ); diff --git a/xen/include/xen/ctype.h b/xen/include/xen/ctype.h index 773ac27aa44ac65e76e87cdec960450804310249..741bea8ff7ae431e27b05e2b62402f64b3a9cacf 100644 --- a/xen/include/xen/ctype.h +++ b/xen/include/xen/ctype.h @@ -4,6 +4,8 @@ /* * NOTE! This ctype does not handle EOF like the standard C * library is required to. + * + * See Rule 21.13 in docs/misra/rules.rst. */ #define _U 0x01 /* upper */ @@ -30,6 +32,7 @@ extern const unsigned char _ctype[]; #define isspace(c) ((__ismask(c)&(_S)) != 0) #define isupper(c) ((__ismask(c)&(_U)) != 0) #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) +#define isconsole(c) (isprint(c) || c == '\n' || c == '\t') #define isascii(c) (((unsigned char)(c))<=0x7f) #define toascii(c) (((unsigned char)(c))&0x7f) From patchwork Tue Nov 26 23:21:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886409 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 0166FD66BAC for ; Tue, 26 Nov 2024 23:23:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844068.1259696 (Exim 4.92) (envelope-from ) id 1tG4ts-0002Xb-Cj; Tue, 26 Nov 2024 23:23:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844068.1259696; Tue, 26 Nov 2024 23:23:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4ts-0002TT-3j; Tue, 26 Nov 2024 23:23:20 +0000 Received: by outflank-mailman (input) for mailman id 844068; Tue, 26 Nov 2024 23:22:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4si-0000At-DM for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:08 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3aeb9b32-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:21:58 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A67CF5C5C12; Tue, 26 Nov 2024 23:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 9C951C4CEE1; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91754D66B8E; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) 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: 3aeb9b32-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjI2MDQ6MTM4MDo0NjQxOmM1MDA6OjEiLCJoZWxvIjoiZGZ3LnNvdXJjZS5rZXJuZWwub3JnIn0= X-Custom-Transaction: eyJpZCI6IjNhZWI5YjMyLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzE4LjcxNjY0OSwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663315; bh=8N48N7tGzPRpnph3uUKQy0qYgM/g5Ojg1QgMgxF7sN8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=dQiHVyRBD3LqER6trrKd4fXaZH8LcYXwkYaUFmwAtsRvWkUpfzaFPNcbGuWwY3qtQ KIsoAI7ZpG7hFxf4VVZYEzhnKLDc94M6d5MWJaGYY6Az3Zmy5qknWXM1Pfc/ofXujB 5RlFU/FCcQ8FGcp/draW5YzykDszNR3OtbUJXAhL3gaWwx+dnnitntd5kjnVork2S+ 6+GWfxNpFIUQbhpl1GTRowa4SSO7qGVRFLCb8VFyep5knS7OwsWP3SldGvoZ/xTX7j T9UA5CppELRY1zoph6nxxN+pf99VedH5EZyN+F4wg2ua8y/9czMsjMd4GSzY+bUsJl AXlTrmRxvg01w== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:21:57 -0800 Subject: [PATCH 07/36] arm/vuart: use guest_printk() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-7-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=1513; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=6dwRL08Xk+9xlKPfi6ImA8lNmAhhTdKU8a+CgXv8hC0=; b=qZPve2qjLwadK8wGOIbj7Nd8nbym1+viKPOUXFNAuXOLAB6VxWO9OyEzQ4wvq/o0cAjeApBl8 nHNN9lxCnELAb4T5ICI1vgTq6DKGkT2jX3/kAZwDT0rQ5syNYVP7mm8 X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Use guest_printk() in all current in-hypervisor UART emulators. That slightly improves the logging as guest_printk() already prints the domain ID. Signed-off-by: Denis Mukhin --- xen/arch/arm/vpl011.c | 2 +- xen/arch/arm/vuart.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 1fc3114cce9ddb48cf199834c8e9abe8cfba92b5..8ade6f2588b8bbcc58fb0f9edc324502a1992ce7 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -107,7 +107,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data) if ( data != '\n' ) intf->out[intf->out_prod++] = '\n'; intf->out[intf->out_prod++] = '\0'; - printk("DOM%u: %s", d->domain_id, intf->out); + guest_printk(d, "%s", intf->out); intf->out_prod = 0; } } diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c index ac76e2327bb84f05ea5716c6f5550f94812d2827..38ce8cc14fac4132578059b696be952b29fab809 100644 --- a/xen/arch/arm/vuart.c +++ b/xen/arch/arm/vuart.c @@ -89,7 +89,7 @@ static void vuart_print_char(struct vcpu *v, char c) if ( c != '\n' ) uart->buf[uart->idx++] = '\n'; uart->buf[uart->idx] = '\0'; - printk(XENLOG_G_DEBUG "DOM%u: %s", d->domain_id, uart->buf); + guest_printk(d, "%s", uart->buf); uart->idx = 0; } spin_unlock(&uart->lock); From patchwork Tue Nov 26 23:21:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886410 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 E4041D66BA6 for ; Tue, 26 Nov 2024 23:23:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844065.1259690 (Exim 4.92) (envelope-from ) id 1tG4tr-0002LY-SW; Tue, 26 Nov 2024 23:23:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844065.1259690; Tue, 26 Nov 2024 23:23:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tr-0002JQ-Av; Tue, 26 Nov 2024 23:23:19 +0000 Received: by outflank-mailman (input) for mailman id 844065; Tue, 26 Nov 2024 23:22:07 +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 1tG4sh-0000Ao-Ls for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:07 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3cfb709a-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:01 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CDAA85C5CA2; Tue, 26 Nov 2024 23:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id AEE08C4CED0; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A59D2D66B84; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) 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: 3cfb709a-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNjZmI3MDlhLWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzIxLjk4NjgzMiwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663315; bh=xzKcNYqy712oJFpscHzBooZVYYhlKxtUkfpZjPeQnx4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=nvCSIBHitSEZyYIWJzK4MBz0C/agcVAdwnWHiJ08BO23WAHIavaY+XN4eJLmGaZJc vXsmwi7yJZWJavILa2JrDa2sAk1GMLM2BaoUgXQdcoFwkaJsZP+La9VR3tt9M9vbyM cvOfLMohcc6rfQv0ttXNAZVsCmB17yTzxCTtlTwztiWcNt0RAxkm/jm1kEKNeVnJC3 yOt239YHElcdcyI2LWnk9QjS+bwr5LO8GEajYMFhZZGEUU0U9C5WWS4B7I7RPJcpDc YsfJf55EsTCqFeSpfrtKUjywQFM82Jh6FplxBpZEKFvYUXSUd8k/kcufx8YG3VGQ6q N5egw6Aa1qDag== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:21:58 -0800 Subject: [PATCH 08/36] arm/vuart: make domain_has_vuart() public MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-8-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=2314; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=uCztJF40iiw3Im/nqwTMa7qbljN2JkGzlchQ98JzHsE=; b=isneJVgwidpN8rhG/OkAiaRbJdUdO7yE2BwELU9Bp6jwr+k8o9BX8cUFkDWfx0RMKc2FRLugJ BGjQU6KqQiuBLLooUpXjSIHbWfvIAg5+S+qgjK4tEdnPv1tizdzO1OC X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Move domain_has_vuart() to arch namespace as preparation code change for architecture-agnostic way of forwarding physical console to the guest OS w/ in-hypervisor UART emulator. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/domain.h | 9 +++++++++ xen/arch/arm/vpl011.c | 2 ++ xen/arch/arm/vuart.c | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h index f1d72c6e48dfeba347b4cd091ca33603c368b7c0..2bbd3f472176bdcfbc0f95f9d8809343d11965c8 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -119,8 +119,17 @@ struct arch_domain void *tee; #endif + /* Emulated devices enabled bitmap. */ + uint32_t emulation_flags; + } __cacheline_aligned; +enum { + ARM_EMU_VUART = BIT(0, U), +}; + +#define domain_has_vuart(d) (!!((d)->arch.emulation_flags & ARM_EMU_VUART)) + struct arch_vcpu { struct { diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 8ade6f2588b8bbcc58fb0f9edc324502a1992ce7..140dca48e0a3901cba289dbc6eb117358134d917 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -730,6 +730,8 @@ int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info) register_mmio_handler(d, &vpl011_mmio_handler, vpl011->base_addr, GUEST_PL011_SIZE, NULL); + d->arch.emulation_flags |= ARM_EMU_VUART; + return 0; out1: diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c index 38ce8cc14fac4132578059b696be952b29fab809..8ca8ae5523a7924846df4324f9e0a81f225756ad 100644 --- a/xen/arch/arm/vuart.c +++ b/xen/arch/arm/vuart.c @@ -31,8 +31,6 @@ #include "vuart.h" -#define domain_has_vuart(d) ((d)->arch.vuart.info != NULL) - static int vuart_mmio_read(struct vcpu *v, mmio_info_t *info, register_t *r, void *priv); static int vuart_mmio_write(struct vcpu *v, mmio_info_t *info, @@ -63,6 +61,8 @@ int domain_vuart_init(struct domain *d) d->arch.vuart.info->size, NULL); + d->arch.emulation_flags |= ARM_EMU_VUART; + return 0; } From patchwork Tue Nov 26 23:21:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886397 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 1F461D66B9A for ; Tue, 26 Nov 2024 23:23:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844064.1259675 (Exim 4.92) (envelope-from ) id 1tG4tq-0001zY-Or; Tue, 26 Nov 2024 23:23:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844064.1259675; Tue, 26 Nov 2024 23:23:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tq-0001vr-BJ; Tue, 26 Nov 2024 23:23:18 +0000 Received: by outflank-mailman (input) for mailman id 844064; Tue, 26 Nov 2024 23:22:07 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sh-0000At-DJ for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:07 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3b4c2a0c-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:21:58 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D661C5C5CAF; Tue, 26 Nov 2024 23:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id C21D2C4CEE2; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA0CBD66B91; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) 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: 3b4c2a0c-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNiNGMyYTBjLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzE4Ljk1OTI3NCwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663315; bh=JpvOelHa4b8SSlnyQ1G57JyTx7oZcL2ofFdr2MblKyY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YwCJJpa3gtvCn9Qm4iP4NOkC+7XhwtWQDOZWYAA6YMle8/6n+LE81uOUvvvJpTyp6 0IBg461zR4gjtHFTMFrbkD+PJEv3ajXrMu2MG+Suzg5q0AoqrEFV1+5xXmtSozQqye 2CS307sIfEJ0YF5DV3K46kDexwD5Fa8OhbASvVdjzKD0Dploy+iPY53wjfdDzt3rqf 0cZeku7tSyKpj9V+sskg7yQLekpV1th2TjLmj0Cm0SpLp2be6L4RpMFwCXj2mNX3CB uZQvJcebdHLdGawbA2l3kHr1DOZvUWpHZuWjLbmYxU7csWdizWNmKPgovbzABQzA+Z 4F3HVY8IByytA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:21:59 -0800 Subject: [PATCH 09/36] riscv/domain: introduce domain_has_vuart() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-9-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=677; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=Fxckvj4Rq3ciLOXnJC51fJ7legC3d6vrDts1ke6yfmU=; b=TSM/n3jP/hKn1R5R46t8lGXKgXQW9Tyfrrj8oA8KSn8tY69MNLUbX+Yv33RoFU6wp81P1amtR +jBKzcZRr28AL3WaamkV1l7PcFmGc64Z5+C8v2tVYQqRalGfZwHKDNg X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Introduce domain_has_vuart() for RISC-V port to be used in the console driver. Signed-off-by: Denis Mukhin --- xen/arch/riscv/include/asm/domain.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/riscv/include/asm/domain.h b/xen/arch/riscv/include/asm/domain.h index c3d965a559b6ce3661bf17166d0c51853ff295a2..efbc4f1ea2619a187fe30ede17d96de01e599220 100644 --- a/xen/arch/riscv/include/asm/domain.h +++ b/xen/arch/riscv/include/asm/domain.h @@ -10,6 +10,8 @@ struct hvm_domain uint64_t params[HVM_NR_PARAMS]; }; +#define domain_has_vuart(d) false + struct arch_vcpu_io { }; From patchwork Tue Nov 26 23:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886402 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 797A9D66BA3 for ; Tue, 26 Nov 2024 23:23:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844056.1259644 (Exim 4.92) (envelope-from ) id 1tG4to-0001Ey-Gd; Tue, 26 Nov 2024 23:23:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844056.1259644; Tue, 26 Nov 2024 23:23:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4to-00019f-1g; Tue, 26 Nov 2024 23:23:16 +0000 Received: by outflank-mailman (input) for mailman id 844056; Tue, 26 Nov 2024 23:22:05 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sf-0000At-Ch for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:05 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3b1d5cd9-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:21:58 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BE78C5C5C99; Tue, 26 Nov 2024 23:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id EC458C4CEDA; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4272D66B8E; Tue, 26 Nov 2024 23:21:55 +0000 (UTC) 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: 3b1d5cd9-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNiMWQ1Y2Q5LWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzE4LjY1OTU0MSwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=W3lsM6sLlkNO6zjU1lHZ+u6ONjEFm+ba+WSVSjVypa4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=DWG5xl3PA9EWYt6A1foAYmpaGYGMDxUuqrePoRwb34UBxkzHa5bijAvMJaKswoYGE mGxMhoSwcGciCHgvN7fPLDgFcdZltrZ9IrstLF6xp0Q7Lh4VGnuFKQTjTJ9JxOy2sv kgNn3LK4TBCfKcYlUS482xV5IlxiuafjKkZz9vEBPqAp3xsbXvN537pzwk9xWdkJKC L0qrNyy38R/bxl8vWq4c0OjN29o73zGBrd88pM/A1T9p7MVzirlRw5TAY4NHCzjbkj mzzc6d876TccV6N2sJVcgikRV1N7dapXeam0YqCjLLLER6S8Qk6+TQoIqCE2WDHeig 4/ZGBjHRZKwjA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:00 -0800 Subject: [PATCH 10/36] ppc/domain: introduce domain_has_vuart() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-10-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=728; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=t3QJZEOM8PRrx5tFAM37Q5lrsCWx/ouiwIRJrERCogM=; b=f8wXFvd3jIkFIxNMBQ/Axu1bbqXBT0SUKFv83mK3ibYkFiQYPB/1CIit84amN75UuJ8kKxZhP qoa3sZDsWsYBHULljtv9I1Vynu51trtpjkriYMTMTyEbSz/qdAX7tC/ X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Introduce domain_has_vuart() for PPC port to be used in the console driver. Signed-off-by: Denis Mukhin --- xen/arch/ppc/include/asm/domain.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/ppc/include/asm/domain.h b/xen/arch/ppc/include/asm/domain.h index 3a447272c6f28586bf0d610929adbf228579e13f..764978e6a61b9d7220ec10fe0763e3424d07d27a 100644 --- a/xen/arch/ppc/include/asm/domain.h +++ b/xen/arch/ppc/include/asm/domain.h @@ -10,6 +10,8 @@ struct hvm_domain uint64_t params[HVM_NR_PARAMS]; }; +#define domain_has_vuart(d) false + /* TODO: Implement */ #define guest_mode(r) ({ (void)(r); BUG_ON("unimplemented"); 0; }) From patchwork Tue Nov 26 23:22:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886404 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 60A71D66BA8 for ; Tue, 26 Nov 2024 23:23:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844073.1259715 (Exim 4.92) (envelope-from ) id 1tG4tu-000339-FV; Tue, 26 Nov 2024 23:23:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844073.1259715; Tue, 26 Nov 2024 23:23:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tt-0002ym-SD; Tue, 26 Nov 2024 23:23:21 +0000 Received: by outflank-mailman (input) for mailman id 844073; Tue, 26 Nov 2024 23:22:09 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sj-0000At-DP for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:09 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3cffca5d-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:01 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D57035C5CAB; Tue, 26 Nov 2024 23:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 105EDC4CEDB; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0622ED66B94; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 3cffca5d-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNjZmZjYTVkLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzIxLjgwNDA1LCJzZW5kZXIiOiJkZXZudWxsK2RtdWtoaW4uZm9yZC5jb21Aa2VybmVsLm9yZyIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=uX6eDC7J8gnEJzkAK+vFayV4YOh384qGm0SB3/a+eoo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=BsEhuq5RfoZD+6Kjkcdh+1UmQjETVdTMJ1Y9U2a0BhxSmGuQt3As7TUinDnmaYyM0 a/EDKlaWVcGHIPALZNARRp16k+Bpka1H7eVoensrfFmkSbJIRpw8n820Azr+rO/XX8 f1ZBp0/a8/OrQ3jlqhuaLMdZXZ0RH9JIpGl18X1stfMdpeAx1JCVRGBS35IG+vMprV jfaF++CEmnMSeRgydRq/zIyjkeCac/v19J4Mmar06ksRwNPiCvMJk46mMQGOmHNS76 nQi637/zapqi1Gr/BJstnf0UoyCJYBGv2wEzz1ItMaIB61TnS9z+PbBHSqigwVYi7t vwn9B3n1hM2rA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:01 -0800 Subject: [PATCH 11/36] x86/domain: introduce domain_has_vuart() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-11-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=889; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=d8+eK1EX7G4dAD9MTJCuZscRKOX31WZGg59AsNpMxsU=; b=uKI8dZysavD1G91oDNk8dSTzasbyQi26nDseOFCosloHlC7ztmtSLUYzwhVsG90ns5k9SkWZh VllqUfZyW8DC8F6KDfz9apA7MC8TS7TbnCzh9IG3aeseGrwOtJPD6PM X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Introduce domain_has_vuart() for x86 port to be used in the console driver. Signed-off-by: Denis Mukhin --- xen/arch/x86/include/asm/domain.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index b79d6badd71c4d96279555df62fad75fe817a2b6..c1d0d1f47324e8cc678a4c76c43f86820a89e7b3 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -506,6 +506,9 @@ struct arch_domain #define has_pirq(d) (!!((d)->arch.emulation_flags & X86_EMU_USE_PIRQ)) #define has_vpci(d) (!!((d)->arch.emulation_flags & X86_EMU_VPCI)) +/* NB: same symbol as in Arm port */ +#define domain_has_vuart(d) false + #define gdt_ldt_pt_idx(v) \ ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT)) #define pv_gdt_ptes(v) \ From patchwork Tue Nov 26 23:22:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886399 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 6D389D66BA1 for ; Tue, 26 Nov 2024 23:23:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844055.1259633 (Exim 4.92) (envelope-from ) id 1tG4tn-000115-S7; Tue, 26 Nov 2024 23:23:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844055.1259633; Tue, 26 Nov 2024 23:23:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tn-0000za-Ft; Tue, 26 Nov 2024 23:23:15 +0000 Received: by outflank-mailman (input) for mailman id 844055; Tue, 26 Nov 2024 23:22:04 +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 1tG4se-0000Ao-LM for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:04 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3d68389e-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:02 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EB2D95C5CB9; Tue, 26 Nov 2024 23:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 24EECC4CED7; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19CF7D66B93; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 3d68389e-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNkNjgzODllLWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzIyLjY5OTU3NCwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=2WgWqZsNDflVD6JmnKTRAOPbRC5jJUlqppnLV6LXXy4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=HZNZNKqgwaqz1KQn2n9Opxrj6816OOMoiXpti9Bn7hSOYnvixMKkCUmFKaBaEhzph Sz4VMsj81Hzs/PfkGBnwl+f6KCl5xiQLGLDzNWqr8ekYWoNKoRBzyJ19KXkwGRV06T SVNWyam3s87wCS4a5DrxYg/BcE+CSbW1svyvCFr+BJc+j4gRVp5K3vmm2m6UZBqzer wAj9QvBnHSCX1Jd4Ykhaegh7WQW7FHSjcsXPWEIrdhe0ICveHsM8mu0T26TwWCNvdN AF/WG6mmmxKyYjwQJZ/ouij7VbTQLjifFUNfgm639nZYsmAb/BWxxzS+N+0kXpA7Ez NszparVX9JDtA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:02 -0800 Subject: [PATCH 12/36] x86/domain: print emulation_flags MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-12-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=1263; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=732gIMLcaCgGTFTHv9vAjNIT6ES/ZZttjeIUCT3F6PI=; b=2D1GntxceEk8CMvCOGVcGx8ZV/nfrqT6w+jxAmtSvt6YKGse6dADcw0/VXr3voTosV5dqLTi0 bWeqzqNK8CfARQ2L2mPeU6iFTzP8vSKt5Jjr+TxraPvuDidph2v/E57 X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Print d->arch.emulation_flags on the console for better traceability while debugging in-hypervisor hardware emulators. Signed-off-by: Denis Mukhin --- xen/arch/x86/domain.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 78a13e6812c9120901d0a70fb3bc1bd6a8b6917d..c88d422a64544531c1e1058fa484364bb4277d1e 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -818,11 +818,15 @@ int arch_domain_create(struct domain *d, if ( !emulation_flags_ok(d, emflags) ) { - printk(XENLOG_G_ERR "d%d: Xen does not allow %s domain creation " + printk(XENLOG_G_ERR "d%d: Xen does not allow %s %sdomain creation " "with the current selection of emulators: %#x\n", - d->domain_id, is_hvm_domain(d) ? "HVM" : "PV", emflags); + d->domain_id, + is_hvm_domain(d) ? "HVM" : "PV", + is_hardware_domain(d) ? "(hardware) " : "", + emflags); return -EOPNOTSUPP; } + printk(XENLOG_G_INFO "d%d: emulation_flags %#x\n", d->domain_id, emflags); d->arch.emulation_flags = emflags; #ifdef CONFIG_PV32 From patchwork Tue Nov 26 23:22:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886398 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 69D53D66BA2 for ; Tue, 26 Nov 2024 23:23:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844058.1259648 (Exim 4.92) (envelope-from ) id 1tG4to-0001ND-Sb; Tue, 26 Nov 2024 23:23:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844058.1259648; Tue, 26 Nov 2024 23:23:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4to-0001Jx-FM; Tue, 26 Nov 2024 23:23:16 +0000 Received: by outflank-mailman (input) for mailman id 844058; Tue, 26 Nov 2024 23:22:05 +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 1tG4sf-0000Ao-LX for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:05 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3d69a0fb-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:02 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 09A3E5C5CC2; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 334C8C4CED3; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B769D66B8E; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 3d69a0fb-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNkNjlhMGZiLWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzIyLjY3NjYxLCJzZW5kZXIiOiJkZXZudWxsK2RtdWtoaW4uZm9yZC5jb21Aa2VybmVsLm9yZyIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=tVwGh2fI891yEmph9JS9g2v7QV1qSjDfL8jnuUT3Tb8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YyxtdXZwF5HGKtsKRUm1zirJZMLpJ6oxFzpfDPEYVhiGKIP1H7T25EZjFyX3niXwb dczYRBuH00BGZSQb8psXy3zx+EFN0ehYWA1ZO1fl3xcPeZ7Yw2cqNo3ArJw3ntTkrZ shAqcUXhpXBXDXgi08wJabThKsPPMHH4SMtfKjM4NKAgQ16ga8N9KfqK93Fs2onGTQ i2/kiNBE1eLo5OEolMA86YWULbyEsHEaqVhcbsYRhqlw51KlpdRYGmZT8SWeZmmLIU bfQ6KgLknzBvLRBJD/6AVXbZCYVCgNrGafJSs8ek2U+CUvo60QlUEOdw0AApTeIr60 KIGAKZl1h3uxQ== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:03 -0800 Subject: [PATCH 13/36] xen/domain: add get_initial_domain_id() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-13-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=3214; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=e/LNB+9Wk5d4Vu+ImwNmQARBXeefJiOOq9L8JfHstNA=; b=p4c6qAznAvJRnp/3HVjjynj1T4WRFFM62MWF06rptmAfMPUraD8W5+8g56LcbD6mMjTtn9dyK 3ID6rRQiP1UCksYsjKunjlrT8zbD94uIl0NQoksdMflBSXs+VQ4OJ2s X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Move get_initial_domain_id() to a public API and enable for all architectures. That is pre-requisite change for console focus switch logic cleanup. Signed-off-by: Denis Mukhin --- xen/arch/x86/include/asm/pv/shim.h | 4 ++-- xen/arch/x86/pv/shim.c | 4 ++-- xen/common/domain.c | 10 ++++++++++ xen/include/xen/domain.h | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/include/asm/pv/shim.h b/xen/arch/x86/include/asm/pv/shim.h index 6153e27005986881ad87e9db0b555b30edc59fc0..1515ad1b0680aa11ab91a152a1944fc1bb477a79 100644 --- a/xen/arch/x86/include/asm/pv/shim.h +++ b/xen/arch/x86/include/asm/pv/shim.h @@ -31,7 +31,7 @@ long cf_check pv_shim_cpu_up(void *data); long cf_check pv_shim_cpu_down(void *data); void pv_shim_online_memory(unsigned int nr, unsigned int order); void pv_shim_offline_memory(unsigned int nr, unsigned int order); -domid_t get_initial_domain_id(void); +domid_t pv_shim_initial_domain_id(void); uint64_t pv_shim_mem(uint64_t avail); void pv_shim_fixup_e820(void); const struct platform_bad_page *pv_shim_reserved_pages(unsigned int *size); @@ -76,7 +76,7 @@ static inline void pv_shim_offline_memory(unsigned int nr, unsigned int order) { ASSERT_UNREACHABLE(); } -static inline domid_t get_initial_domain_id(void) +static inline domid_t pv_shim_initial_domain_id(void) { return 0; } diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index 81e4a0516d18b359561f471f1d96e38977661ca7..17cb30620290c76cf42251f70cfa4199c0e165d1 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -328,7 +328,7 @@ int pv_shim_shutdown(uint8_t reason) } /* Update domain id. */ - d->domain_id = get_initial_domain_id(); + d->domain_id = pv_shim_initial_domain_id(); /* Clean the iomem range. */ BUG_ON(iomem_deny_access(d, 0, ~0UL)); @@ -1016,7 +1016,7 @@ void pv_shim_offline_memory(unsigned int nr, unsigned int order) } } -domid_t get_initial_domain_id(void) +domid_t pv_shim_initial_domain_id(void) { uint32_t eax, ebx, ecx, edx; diff --git a/xen/common/domain.c b/xen/common/domain.c index 92263a4fbdc57159b4a32d9d4ee038f9f37804ed..2f67aa06ed50e69c27cedc8d7f6eb0b469fe81cd 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -45,6 +45,7 @@ #ifdef CONFIG_X86 #include +#include #endif /* Linux config option: propageted to domain0 */ @@ -2229,6 +2230,15 @@ int continue_hypercall_on_cpu( return 0; } +domid_t get_initial_domain_id(void) +{ +#ifdef CONFIG_X86 + return pv_shim_initial_domain_id(); +#else + return 0; +#endif +} + /* * Local variables: * mode: C diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 3de56352911347a54cce310f0211bcc213d8a08d..601ef431cf621af44c867400499b73b845eb137a 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -171,4 +171,6 @@ extern bool vmtrace_available; extern bool vpmu_is_available; +domid_t get_initial_domain_id(void); + #endif /* __XEN_DOMAIN_H__ */ From patchwork Tue Nov 26 23:22:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886411 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 C1924D66B9D for ; Tue, 26 Nov 2024 23:23:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844077.1259739 (Exim 4.92) (envelope-from ) id 1tG4tx-0003r1-NA; Tue, 26 Nov 2024 23:23:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844077.1259739; Tue, 26 Nov 2024 23:23:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tw-0003lM-Qg; Tue, 26 Nov 2024 23:23:24 +0000 Received: by outflank-mailman (input) for mailman id 844077; Tue, 26 Nov 2024 23:22:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sk-0000At-Da for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:10 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3d8be5df-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:02 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1A4B55C5CCD; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 49047C4CED8; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F95AD66B93; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 3d8be5df-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNkOGJlNWRmLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzIyLjg1NzUyNCwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=F18Rd37Hu8IJR5rLsatEBXLaN+jWgrMYc3ZMm20WI7M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=VYE4ELADIfnpwnRDMGAqRaJfyYr3r+HoxxnkvSN2mCVpFju8wLpHLSaV9O6emyBBx VkqUCDyfZbbqQYFFccxn+7MlD9XvChzMtN79qkZBjcjdkT33JTcClrUiR0yXTaL358 1p09hnteFQm2OL/6ZPrMte/mEGkwZeQYGBtdeanb8ceLpVhBNtRCjzWPCoe1NnqP/7 dx4ae8mMUODiMtI6BD1bV3MCnrvjQ/1gslKJIrrRiw+8ojaUHEvHVREHAMT2UjB7Lt 1pfls+9h8jrZtux4d/nQK+VYDTn1oLD2mj1r+q8d8+lqkHnvvUR25A0kAwejjCLtI2 blN5PoPFexw3g== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:04 -0800 Subject: [PATCH 14/36] xen/domain: enable max_init_domid for all architectures MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-14-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=3782; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=yaQRDGz2W+Ijh9JWeI+JahaekRUAILaRwxdJICvftvE=; b=Cpw86+mRzAjuPvdWy+ql0J5AE4/wZWwSFWswO+Khyo0kNcLmJbm4nSQUK7OJQrG7/wywrPs6V +/6vEBR8fRWDpnQsSDMChi/Z7902+RqQjGkmF0v0XR7oR3vrJFrG73O X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Move max_init_domid to a public API and enable for all architectures. That is pre-requisite change for console focus switch logic cleanup. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/setup.h | 2 -- xen/arch/arm/setup.c | 2 -- xen/arch/ppc/include/asm/setup.h | 2 -- xen/arch/riscv/include/asm/setup.h | 2 -- xen/arch/x86/include/asm/setup.h | 2 -- xen/common/domain.c | 3 +++ xen/include/xen/domain.h | 2 ++ 7 files changed, 5 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h index 64c227d171fc7b92e5b62d9fd42e5662871bd12b..d4e1670cd69cdd4475b2a5eb316d2c0601090ed7 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -19,8 +19,6 @@ struct map_range_data struct rangeset *irq_ranges; }; -extern domid_t max_init_domid; - void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len); size_t estimate_efi_size(unsigned int mem_nr_banks); diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 71ebaa77ca94ab6f5878135406dd3b6d79a59754..b4855ede8876b365101a2d6a146384a39a503382 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -58,8 +58,6 @@ struct cpuinfo_arm __read_mostly system_cpuinfo; bool __read_mostly acpi_disabled; #endif -domid_t __read_mostly max_init_domid; - static __used void init_done(void) { int rc; diff --git a/xen/arch/ppc/include/asm/setup.h b/xen/arch/ppc/include/asm/setup.h index e4f64879b68ca5aac24bd9544255143e6ef693f3..956fa6985adb23375bd41d3e5d34d9d5f0712bd5 100644 --- a/xen/arch/ppc/include/asm/setup.h +++ b/xen/arch/ppc/include/asm/setup.h @@ -1,6 +1,4 @@ #ifndef __ASM_PPC_SETUP_H__ #define __ASM_PPC_SETUP_H__ -#define max_init_domid (0) - #endif /* __ASM_PPC_SETUP_H__ */ diff --git a/xen/arch/riscv/include/asm/setup.h b/xen/arch/riscv/include/asm/setup.h index c0214a9bf295f516572af87841e40ff6aaf79b28..0bbb8ab37cf9af89206a09c0f11767b090814ea9 100644 --- a/xen/arch/riscv/include/asm/setup.h +++ b/xen/arch/riscv/include/asm/setup.h @@ -3,8 +3,6 @@ #ifndef ASM__RISCV__SETUP_H #define ASM__RISCV__SETUP_H -#define max_init_domid (0) - #endif /* ASM__RISCV__SETUP_H */ /* diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 5c2391a8684b66efdf4b092409ed33935db6b40c..296348655b9d146c73acc305cc9edd5fd46f7d47 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -69,6 +69,4 @@ extern bool opt_dom0_verbose; extern bool opt_dom0_cpuid_faulting; extern bool opt_dom0_msr_relaxed; -#define max_init_domid (0) - #endif diff --git a/xen/common/domain.c b/xen/common/domain.c index 2f67aa06ed50e69c27cedc8d7f6eb0b469fe81cd..d8f6829db50dabba7464004b39eea39f6970f800 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -65,6 +65,9 @@ DEFINE_RCU_READ_LOCK(domlist_read_lock); static struct domain *domain_hash[DOMAIN_HASH_SIZE]; struct domain *domain_list; +/* Last known non-system domain ID. */ +domid_t __read_mostly max_init_domid; + /* * Insert a domain into the domlist/hash. This allows the domain to be looked * up by domid, and therefore to be the subject of hypercalls/etc. diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 601ef431cf621af44c867400499b73b845eb137a..6102826a929ff7aad58a4bc40974815071a97446 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -171,6 +171,8 @@ extern bool vmtrace_available; extern bool vpmu_is_available; +extern domid_t max_init_domid; + domid_t get_initial_domain_id(void); #endif /* __XEN_DOMAIN_H__ */ From patchwork Tue Nov 26 23:22:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886431 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 480ECD66B8E for ; Tue, 26 Nov 2024 23:39:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844374.1259951 (Exim 4.92) (envelope-from ) id 1tG59F-0005Fm-4L; Tue, 26 Nov 2024 23:39:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844374.1259951; Tue, 26 Nov 2024 23:39:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG59F-0005Ff-0w; Tue, 26 Nov 2024 23:39:13 +0000 Received: by outflank-mailman (input) for mailman id 844374; Tue, 26 Nov 2024 23:39:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4su-0000At-Eb for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:20 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 406a0290-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:06 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2E3E45C5CD9; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 5C63EC4CEDA; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 519D6D66B94; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 406a0290-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjQwNmEwMjkwLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzI2Ljg4Mjk3Nywic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=5YTuUDaV5EVnrers6QrjQT6r8NErcJtABTvZxKp9ABI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=OMUL/Ri32IOYBUiHifEGwvULrRHLBD3Ipk2Js5lMmkEv2Oa8ighcsJzz0tK4l8P/K RoCI9/VXPg0SJ4e4pGvrPQ/ak0+BOV3LelpEkhklE3O9YQvPr3Se5uX1VW0JzgGYhm lnUmkHu8Yx65dFVR7lanOYhoplKCQIdf/9eA+E91KCN18r3wL4kP6bJ2cABNbBkNaf /gqkyrFnAtdWlqXLvTxU/bO+hrENISGN1bHyiwMhOtpA4Rv0HBtpQxq6bzAeCi2AXv rRw3h9rFzL9Y+vm4HQmojIiZ8MN/Z0Jv02HFKYny/zLCxeMe+xGqkS41qkUnZcMyWM TEcTQmvrWznEw== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:05 -0800 Subject: [PATCH 15/36] xen/console: move vpl011-related code to vpl011 emulator MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-15-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=3543; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=eSoRo4IQpqEF5DX3/57J0/HMwWVyveMZrxkTrUrQksc=; b=Ssyod9J853vaDvi8IVQuIiYqz+IJjFLP8x8AMQfyU0pyk/+zh3NLrbs1goiBjJDowTSWQc80I ughd7gBeOHeAkJxyo2dIQH83kva3uuUwVA3y9DNqEgntr4GNv0lVs5L X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Xen console driver has vpl011-related logic which shall belong vpl011 emulator code. Move vpl011-related to vpl011.c. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/vpl011.h | 2 +- xen/arch/arm/vpl011.c | 15 ++++++++++++--- xen/drivers/char/console.c | 4 +--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/include/asm/vpl011.h b/xen/arch/arm/include/asm/vpl011.h index c09abcd7a9b3356d0809743517934adae00087f5..cc838682815c0d049ba33d3bf9966a64b2e527dd 100644 --- a/xen/arch/arm/include/asm/vpl011.h +++ b/xen/arch/arm/include/asm/vpl011.h @@ -69,7 +69,7 @@ struct vpl011_init_info { int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info); void domain_vpl011_deinit(struct domain *d); -void vpl011_rx_char_xen(struct domain *d, char c); +int vpl011_rx_char_xen(struct domain *d, char c); #else static inline int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 140dca48e0a3901cba289dbc6eb117358134d917..3e1487b101053891c9c0fb7fb50af1c547d4cbf3 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -569,14 +569,21 @@ static void vpl011_data_avail(struct domain *d, * vpl011_rx_char_xen adds a char to a domain's vpl011 receive buffer. * It is only used when the vpl011 backend is in Xen. */ -void vpl011_rx_char_xen(struct domain *d, char c) +int vpl011_rx_char_xen(struct domain *d, char c) { unsigned long flags; struct vpl011 *vpl011 = &d->arch.vpl011; struct vpl011_xen_backend *intf = vpl011->backend.xen; XENCONS_RING_IDX in_cons, in_prod, in_fifo_level; - ASSERT(!vpl011->backend_in_domain); + /* + * If we have a properly initialized vpl011 console for the + * domain, without a full PV ring to Dom0 (in that case input + * comes from the PV ring), then send the character to it. + */ + if ( vpl011->backend_in_domain || intf == NULL ) + return -ENODEV; + VPL011_LOCK(d, flags); in_cons = intf->in_cons; @@ -584,7 +591,7 @@ void vpl011_rx_char_xen(struct domain *d, char c) if ( xencons_queued(in_prod, in_cons, sizeof(intf->in)) == sizeof(intf->in) ) { VPL011_UNLOCK(d, flags); - return; + return -ENOSPC; } intf->in[xencons_mask(in_prod, sizeof(intf->in))] = c; @@ -596,6 +603,8 @@ void vpl011_rx_char_xen(struct domain *d, char c) vpl011_data_avail(d, in_fifo_level, sizeof(intf->in), 0, SBSA_UART_FIFO_SIZE); VPL011_UNLOCK(d, flags); + + return 0; } static void vpl011_notification(struct vcpu *v, unsigned int port) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index bb56953bab681a13da8d41431aba4632f1919df9..0af4b551801356f242f1770b3826608136d65653 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -559,9 +559,7 @@ static void __serial_rx(char c) * domain, without a full PV ring to Dom0 (in that case input * comes from the PV ring), then send the character to it. */ - if ( d != NULL && - !d->arch.vpl011.backend_in_domain && - d->arch.vpl011.backend.xen != NULL ) + if ( d != NULL ) vpl011_rx_char_xen(d, c); else printk("Cannot send chars to Dom%d: no UART available\n", From patchwork Tue Nov 26 23:22:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886415 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 65216D66B9A for ; Tue, 26 Nov 2024 23:31:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844207.1259801 (Exim 4.92) (envelope-from ) id 1tG51j-0004Rh-Oq; Tue, 26 Nov 2024 23:31:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844207.1259801; Tue, 26 Nov 2024 23:31:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG51j-0004Ra-Lu; Tue, 26 Nov 2024 23:31:27 +0000 Received: by outflank-mailman (input) for mailman id 844207; Tue, 26 Nov 2024 23:31:26 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4ss-0000At-EW for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:18 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4052cc30-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:06 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 424AC5C5CDF; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 720A2C4CED0; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68E9ED66B97; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 4052cc30-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjQwNTJjYzMwLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzI2Ljc2MzYwMywic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=Bn46VxfAkAcMhv6DUkrTdMnTNfB+okMDoUD+Om5BMyY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=m6JM8GCJGhtrmxVQvqrmhKB9kFFTklfeOAlWO5/+UU2fq0kgrPSgUXV6ImmQXliNa TfqmqY4ZmR/6s4p2kAyF3HNG0ut8Z0gsysqmZWF470Wo/ILXdRF3ezJCHsPdh2Mvuw Tk6zBz9+FTdtUMwHsSZgOMn8BREHv9vNoS0fZSD8f6/pg2pf5QRxkbeGBjOeq3BTjD sF7MdJ9TbqgNWk92LP7fd8QPrv/eIJ6QRXFDlpXs1zGpBEdaL1F8GwrjFE0dVR9Y/U x0zD9U98I/Es1TkqFRukmmZtmfM0Eg2O9WikFnfJm8sNmqKEg1LIx8966xPMTllta0 I9bwC9b578QoQ== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:06 -0800 Subject: [PATCH 16/36] xen/console: rename console_input_domain MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-16-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=2162; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=//8B6RWBIW7SNgnF2T6+HEA2/O3wgsD0ciOR+76PaLM=; b=F6KU38cCC+uW7VC+/FDMuTylh4u51qK5IZuAVjuLIRIwoAHjJEwX1ZcwPeWYsBp7Jcz2UZs+H m3VQ/gQTRhgDEAbVrKlIKpMw6P5C7JIWDqUAjxReSCvMICF7iavKNUM X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin console_input_domain() takes an RCU lock to protect domain structure. That implies call to rcu_unlock_domain() after use. Rename console_input_domain() to rcu_lock_domain_console_owner() to highlight the need of calling rcu_unlock_domain(). Signed-off-by: Denis Mukhin --- xen/arch/arm/vpl011.c | 2 +- xen/drivers/char/console.c | 2 +- xen/include/xen/console.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 3e1487b101053891c9c0fb7fb50af1c547d4cbf3..07ef872d72b7881a70f4a938dcd6bea4c30198d9 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -78,7 +78,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data) unsigned long flags; struct vpl011 *vpl011 = &d->arch.vpl011; struct vpl011_xen_backend *intf = vpl011->backend.xen; - struct domain *input = console_input_domain(); + struct domain *input = rcu_lock_domain_console_owner(); VPL011_LOCK(d, flags); diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 0af4b551801356f242f1770b3826608136d65653..01fcbd5581d11f8f4f2b23592255b5c744430a3e 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -477,7 +477,7 @@ static unsigned int __read_mostly console_rx = 0; #ifdef CONFIG_SBSA_VUART_CONSOLE /* Make sure to rcu_unlock_domain after use */ -struct domain *console_input_domain(void) +struct domain *rcu_lock_domain_console_owner(void) { if ( console_rx == 0 ) return NULL; diff --git a/xen/include/xen/console.h b/xen/include/xen/console.h index 6dfbade3ece36352c74f1124305da945b210f2a7..0e211e44d9703c804e18f52c9743916f8d2a9d4e 100644 --- a/xen/include/xen/console.h +++ b/xen/include/xen/console.h @@ -31,7 +31,7 @@ void console_end_sync(void); void console_start_log_everything(void); void console_end_log_everything(void); -struct domain *console_input_domain(void); +struct domain *rcu_lock_domain_console_owner(void); /* * Steal output from the console. Returns +ve identifier, else -ve error. From patchwork Tue Nov 26 23:22:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886401 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 D95D1D66B8E for ; Tue, 26 Nov 2024 23:23:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844060.1259668 (Exim 4.92) (envelope-from ) id 1tG4tq-0001jU-9W; Tue, 26 Nov 2024 23:23:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844060.1259668; Tue, 26 Nov 2024 23:23:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tp-0001hF-KO; Tue, 26 Nov 2024 23:23:17 +0000 Received: by outflank-mailman (input) for mailman id 844060; Tue, 26 Nov 2024 23:22:06 +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 1tG4sg-0000Ao-Lb for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:06 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3d87a499-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:02 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 550B45C5CF1; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 83748C4CEDD; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C9CCD66B8E; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 3d87a499-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjI2MDQ6MTM4MDo0NjQxOmM1MDA6OjEiLCJoZWxvIjoiZGZ3LnNvdXJjZS5rZXJuZWwub3JnIn0= X-Custom-Transaction: eyJpZCI6IjNkODdhNDk5LWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzIyLjg5ODM2Miwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=Cap5cSdXQnJhIWZIJycGmw66XTO7q8HjNlh67Jy7JB4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Roi4bnO89HuQscE/mllmZ4di8KrGNkAEgaFCrZwspwH1JCGP7EeSelMhqJp3FtN2p 1vmqcBEY6PtxBqWJW1VUHMpW/bPH5B+YC80zhJx30UowTy+ZgCQQnJEd0hnAn1Hlkt XcGKUReaRSPFHSjEvr5WInFgGkBvQkKepHz1F2TNg2MZxcNVm5HUfJxwzd27u0Wdt2 DjdOJziJugSXgtF7Jn3f6bo30Ln6l01S2E8qR9nY0G4TFpac36FqwR/86tOFX/ts/x nKhPwQFQosdNK6Bir87YPHUpd+Dfu25EOC3kfrmlu72LVexy+/k0LtMpla4qGDvOj8 CoRT7AHq/AL0A== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:07 -0800 Subject: [PATCH 17/36] xen/console: rename switch_serial_input() to console_find_owner() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-17-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=1478; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=kkv+AJB+iT69SEANPtdQ4jOx6o8Fe+p28DiGHObsMCE=; b=34yyRPfAwR5Xa4Xuz4/BOFOrcATMDRQQnnZ5y9UsR0hdVr18qx/Zq/l4GCrf/HFvgLYIzpxwv YVD7bNrxNZHCYCzTZGhZp5eE+8zkM7+FIcjsbE+IX79uUTZFrdW6EHP X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Updated the name to highlight the logic of selection the physical console owner: existing code does not switch only serial console, it also switches video console and debugging console (debug I/O port and console hypercall). Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 01fcbd5581d11f8f4f2b23592255b5c744430a3e..f8a7db385c9525cabc69ceb1a84d73f57863aa45 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -485,7 +485,7 @@ struct domain *rcu_lock_domain_console_owner(void) } #endif -static void switch_serial_input(void) +static void console_find_owner(void) { unsigned int next_rx = console_rx; @@ -588,7 +588,7 @@ static void cf_check serial_rx(char c) /* We eat CTRL- in groups of 3 to switch console input. */ if ( ++switch_code_count == 3 ) { - switch_serial_input(); + console_find_owner(); switch_code_count = 0; } return; @@ -1128,7 +1128,7 @@ void __init console_endboot(void) "toggle host/guest log level adjustment", 0); /* Serial input is directed to DOM0 by default. */ - switch_serial_input(); + console_find_owner(); } int __init console_has(const char *device) From patchwork Tue Nov 26 23:22:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886419 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 B7A8DD66B8E for ; Tue, 26 Nov 2024 23:32:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844236.1259842 (Exim 4.92) (envelope-from ) id 1tG52D-0006JF-TU; Tue, 26 Nov 2024 23:31:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844236.1259842; Tue, 26 Nov 2024 23:31:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG52D-0006J2-Od; Tue, 26 Nov 2024 23:31:57 +0000 Received: by outflank-mailman (input) for mailman id 844236; Tue, 26 Nov 2024 23:31:56 +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 1tG4sr-0000Ao-NS for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:17 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 404f6775-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:06 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6AF2F5C5D0C; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 98D78C4CED3; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F6D5D66B98; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 404f6775-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjQwNGY2Nzc1LWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzI2Ljc1MjY5LCJzZW5kZXIiOiJkZXZudWxsK2RtdWtoaW4uZm9yZC5jb21Aa2VybmVsLm9yZyIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=owjhPqMN/sfHwDFdAwELQ23W67gacGzY3DCmgAbUG18=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=NrMOAdLWUjxpQz3jaTxfnIXSc3yKGQn5VCrM887lJG30+7SRR1m+YUy5YlEcFkp0M OJsvdRn8FAPajpezUSl0Sf87pH2Ogh5aRLuTT9gqp+iK8hccTVgGERmlYTDxgoArhl hv4l1Q/H7aAZZKPUcms8C6n6fhp38uP5oNP5O/6B1Mof6km8+A6KVfrL9JcsmRQkX/ FxWeUwazxd3RdPZ71lg3iYfUstVBycrMbCtoMUXZwUEmHlJmiHBnAOxF2o5kv3u4EI BSRVjDxvivfiSX6me7SV92jQNHVDQSsC9Ocmxhl7FXM/u/rPsnMkWaA4jZQ6d9qdMJ C5AQExxiB710g== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:08 -0800 Subject: [PATCH 18/36] xen/console: rename console_rx to console_owner MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-18-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=3503; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=adx3ttDq9DGxs5v/iNqFG/t0SkuLKBWjA23PcHLO1+c=; b=IGxjWhFAg7XglUWziOn324G97nMmVYuDMsHVRirzfW0FLmtntUSWMQ0+UUZF6Y5jWsWkcWmKg K0SKJ9oAAGaAf7mlgCU66d5Ocl+sy3UFeBq8D1SW6JucgTfyS4RY07A X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Preparation for the follow on change to switch console_owner to domid_t address space. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index f8a7db385c9525cabc69ceb1a84d73f57863aa45..86bf899ada8f8221ffc77bcffb1f58777a22198e 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -467,11 +467,11 @@ static void cf_check dump_console_ring_key(unsigned char key) */ #define switch_code (opt_conswitch[0]-'a'+1) /* - * console_rx=0 => input to xen - * console_rx=1 => input to dom0 (or the sole shim domain) - * console_rx=N => input to dom(N-1) + * console_owner=0 => input to xen + * console_owner=1 => input to dom0 (or the sole shim domain) + * console_owner=N => input to dom(N-1) */ -static unsigned int __read_mostly console_rx = 0; +static unsigned int __read_mostly console_owner = 0; #define max_console_rx (max_init_domid + 1) @@ -479,15 +479,15 @@ static unsigned int __read_mostly console_rx = 0; /* Make sure to rcu_unlock_domain after use */ struct domain *rcu_lock_domain_console_owner(void) { - if ( console_rx == 0 ) + if ( console_owner == 0 ) return NULL; - return rcu_lock_domain_by_id(console_rx - 1); + return rcu_lock_domain_by_id(console_owner - 1); } #endif static void console_find_owner(void) { - unsigned int next_rx = console_rx; + unsigned int next_rx = console_owner; /* * Rotate among Xen, dom0 and boot-time created domUs while skipping @@ -500,7 +500,7 @@ static void console_find_owner(void) if ( next_rx++ >= max_console_rx ) { - console_rx = 0; + console_owner = 0; printk("*** Serial input to Xen"); break; } @@ -515,7 +515,7 @@ static void console_find_owner(void) if ( d ) { rcu_unlock_domain(d); - console_rx = next_rx; + console_owner = next_rx; printk("*** Serial input to DOM%u", domid); break; } @@ -529,7 +529,7 @@ static void console_find_owner(void) static void __serial_rx(char c) { - switch ( console_rx ) + switch ( console_owner ) { case 0: return handle_keypress(c, false); @@ -552,7 +552,7 @@ static void __serial_rx(char c) #ifdef CONFIG_SBSA_VUART_CONSOLE default: { - struct domain *d = rcu_lock_domain_by_id(console_rx - 1); + struct domain *d = rcu_lock_domain_by_id(console_owner - 1); /* * If we have a properly initialized vpl011 console for the @@ -563,7 +563,7 @@ static void __serial_rx(char c) vpl011_rx_char_xen(d, c); else printk("Cannot send chars to Dom%d: no UART available\n", - console_rx - 1); + console_owner - 1); if ( d != NULL ) rcu_unlock_domain(d); @@ -1116,7 +1116,7 @@ void __init console_endboot(void) * a useful 'how to switch' message. */ if ( opt_conswitch[1] == 'x' ) - console_rx = max_console_rx; + console_owner = max_console_rx; register_keyhandler('w', dump_console_ring_key, "synchronously dump console ring buffer (dmesg)", 0); From patchwork Tue Nov 26 23:22:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886424 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 F0066D66B8E for ; Tue, 26 Nov 2024 23:35:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844299.1259881 (Exim 4.92) (envelope-from ) id 1tG55p-00013n-1a; Tue, 26 Nov 2024 23:35:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844299.1259881; Tue, 26 Nov 2024 23:35:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG55o-00013g-VB; Tue, 26 Nov 2024 23:35:40 +0000 Received: by outflank-mailman (input) for mailman id 844299; Tue, 26 Nov 2024 23:35:39 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sq-0000At-EH for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:16 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 402dbdde-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:07 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7DC285C5D1E; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id AC684C4CED2; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2F71D66B94; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 402dbdde-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjQwMmRiZGRlLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzI3LjMxNjU4Nywic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=EehkYBiOP/PXKJY+PdWeOgafO7LhWK+IAcas/cU+rxo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=brD5/9fb2xAuUirBhFjGTHQOyaRnbK6H/SN3nlnc6TLnkymQMAVupzp+jdzWRxx4u ozETwS51ugRZcEeZVAmEQIrcACKEt9AD1g8IOxVtmNczRcwSFDpqiCkvikBAPttGpi LwxUKCvhsbBxF913fbsCaZ+qiS98SfMOs5i4fhdxfvn4C14Hq7z40b5LO4aYS97ItQ x4ax8U+EfQGHnOzEhLXzOaO8qvHjO7mYzD8MMCv2Qtj+XQ2Lzx3WMmU3puNv3+5OgW GlsOZnMeAtpQqTWtVgxJvTMUf5woCC4OmtO7B4ImYvj9FZ3FOinjGMU709Itsc7mHU 4X9yxORAq8oew== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:09 -0800 Subject: [PATCH 19/36] xen/console: introduce printk_common() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-19-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=1598; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=ZaoWKGFunF1v2fJrLgskSFgg/fFHSsN+iDoAE6XfT9Q=; b=qf1Tso16MB8AZmrXNCz9umrGZGM1ODTNxpZz1C5AlhIFFZtIt51Zk7hm0IXDTzpOaQ21aT1Xy Bnsh8vhnpDLD2g2jthBGW9Vj4jFyK4LFbJhtEQZuruPSO9haplPlZcM X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Introduce new printk() variant for convenient printouts which skip '(XEN)' prefix on xen console. This is needed for the case when physical console is owned by a domain w/ in-hypervisor UART emulation enabled. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 8 ++++++++ xen/include/xen/lib.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 86bf899ada8f8221ffc77bcffb1f58777a22198e..f034ce5aab3f3bf59b0df9fa583ee9ce32dbf665 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -968,6 +968,14 @@ void printk(const char *fmt, ...) va_end(args); } +void printk_common(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vprintk_common("", fmt, args); + va_end(args); +} + void guest_printk(const struct domain *d, const char *fmt, ...) { va_list args; diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 81b722ea3e801e9089aaf8758249feb3a758c4f7..8a7ff2e8af9089796ff28ef8d01c00e9845782ca 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -61,6 +61,9 @@ debugtrace_printk(const char *fmt, ...) {} extern void printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2), cold)); +extern void printk_common(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + #define printk_once(fmt, args...) \ ({ \ static bool __read_mostly once_; \ From patchwork Tue Nov 26 23:22:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886416 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 3662CD66B9A for ; Tue, 26 Nov 2024 23:31:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844209.1259807 (Exim 4.92) (envelope-from ) id 1tG51k-0004UY-23; Tue, 26 Nov 2024 23:31:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844209.1259807; Tue, 26 Nov 2024 23:31:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG51j-0004Ti-Sc; Tue, 26 Nov 2024 23:31:27 +0000 Received: by outflank-mailman (input) for mailman id 844209; Tue, 26 Nov 2024 23:31:26 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sr-0000At-EN for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:17 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4019797e-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:06 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 950025C5D22; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id C34ACC4CED7; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4ACDD66B8E; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 4019797e-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjQwMTk3OTdlLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzI2LjM1NjQ2OCwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=50fKjc2QOVuxtHeCWL67mp4YIYRrVBdHtpZLvHIma5E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=BBoTyplhMIAPEAOnJhFln241XCN141CxblrzJCf0bRaf3R6yqKmOnrTKzlU0yhCaJ L6+hYvAMtPk6+Nv2Ss611hnJD51ZQUDtgCo5B4LvRPpieEBOrdGl6+LBZ9T2XaBrBU UKqv/PKH2bKvM1+Du0mEFXUp0eXEgqDM8TwOxn1b6w7OWODGqHLCCzOlnZ5uVQldgQ xoSmncVBRkZ2ld06R5RYwAszQNZaL7ZL/b7V5lFcb7rXXbsCo22I/e4BsjcnLBxd++ awpFMdzAAym2D0wjAK8isiYRERxu94xr6vRbLkamxim8KEK4+AJzVsL9cjSPu1jwI2 s06zjdIbGWvyA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:10 -0800 Subject: [PATCH 20/36] xen/console: introduce consoled_is_enabled() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-20-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=4384; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=dmfspZvPgoI4EGX+YrlzVMe2EpWEao1fcT911zaxlEE=; b=b8yT+vorsOT/zpMXLcXELRcjbP8A5xks6ATDBkx57XKFIDY+aHn3Ylyvhm4Z3AH3+ZRx1C8qL Jwel3yfp81XClJATR0JRkeqv+Ek2LpNbnP2Vh/Z/EibO0x25KL5xBeT X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin There are few places which check pv_shim console under CONFIG_PV_SHIM in xen console driver. Instead of #ifdef-ing, use new consoled_is_enabled() to customize the logic. Header file now can be included w/o CONFIG_X86. Signature of consoled_guest_{rx,tx} has changed to account for follow-on console switch logic cleanup. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 10 +++------- xen/drivers/char/consoled.c | 18 ++++++++++++++---- xen/include/xen/consoled.h | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index f034ce5aab3f3bf59b0df9fa583ee9ce32dbf665..60c055396b697869b04b9132b0dcfa832fabe932 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -33,9 +33,9 @@ #include #include #include +#include #ifdef CONFIG_X86 -#include #include #endif #ifdef CONFIG_SBSA_VUART_CONSOLE @@ -505,11 +505,9 @@ static void console_find_owner(void) break; } -#ifdef CONFIG_PV_SHIM - if ( next_rx == 1 ) + if ( consoled_is_enabled() && next_rx == 1 ) domid = get_initial_domain_id(); else -#endif domid = next_rx - 1; d = rcu_lock_domain_by_id(domid); if ( d ) @@ -573,10 +571,8 @@ static void __serial_rx(char c) #endif } -#ifdef CONFIG_X86 - if ( pv_shim && pv_console ) + if ( consoled_is_enabled() ) consoled_guest_tx(c); -#endif } static void cf_check serial_rx(char c) diff --git a/xen/drivers/char/consoled.c b/xen/drivers/char/consoled.c index b415b632cecc0a80e161b701d7b70ba4f3cc5fb8..d6624e7697f56e1a1959b0efa5dca104f34af002 100644 --- a/xen/drivers/char/consoled.c +++ b/xen/drivers/char/consoled.c @@ -43,13 +43,13 @@ struct xencons_interface *consoled_get_ring_addr(void) static char buf[BUF_SZ + 1]; /* Receives characters from a domain's PV console */ -void consoled_guest_rx(void) +int consoled_guest_rx(void) { size_t idx = 0; XENCONS_RING_IDX cons, prod; if ( !cons_ring ) - return; + return 0; spin_lock(&rx_lock); @@ -91,15 +91,17 @@ void consoled_guest_rx(void) out: spin_unlock(&rx_lock); + + return 0; } /* Sends a character into a domain's PV console */ -void consoled_guest_tx(char c) +int consoled_guest_tx(char c) { XENCONS_RING_IDX cons, prod; if ( !cons_ring ) - return; + return 0; cons = ACCESS_ONCE(cons_ring->in_cons); prod = cons_ring->in_prod; @@ -118,6 +120,7 @@ void consoled_guest_tx(char c) cons_ring->in[MASK_XENCONS_IDX(prod++, cons_ring->in)] = c; + /* Write to the ring before updating the pointer */ smp_wmb(); ACCESS_ONCE(cons_ring->in_prod) = prod; @@ -125,6 +128,13 @@ void consoled_guest_tx(char c) notify: /* Always notify the guest: prevents receive path from getting stuck. */ pv_shim_inject_evtchn(pv_console_evtchn()); + + return 0; +} + +bool consoled_is_enabled(void) +{ + return pv_shim && pv_console; } /* diff --git a/xen/include/xen/consoled.h b/xen/include/xen/consoled.h index bd7ab6329ee8a7c466484021247241ded8ed03c7..b88e3025fde84a52d7027b785b0a51ada8493832 100644 --- a/xen/include/xen/consoled.h +++ b/xen/include/xen/consoled.h @@ -3,10 +3,41 @@ #include +#if defined(CONFIG_PV_SHIM) + void consoled_set_ring_addr(struct xencons_interface *ring); struct xencons_interface *consoled_get_ring_addr(void); -void consoled_guest_rx(void); -void consoled_guest_tx(char c); +int consoled_guest_rx(void); +int consoled_guest_tx(char c); +bool consoled_is_enabled(void); + +#else + +void consoled_set_ring_addr(struct xencons_interface *ring) +{ +} + +struct xencons_interface *consoled_get_ring_addr(void) +{ + return NULL; +} + +int consoled_guest_rx(void) +{ + return 0; +} + +int consoled_guest_tx(char c) +{ + return 0; +} + +bool consoled_is_enabled(void) +{ + return false; +} + +#endif /* #if defined(CONFIG_PV_SHIM) */ #endif /* __XEN_CONSOLED_H__ */ /* From patchwork Tue Nov 26 23:22:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886425 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 12418D66B8E for ; Tue, 26 Nov 2024 23:37:38 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844321.1259891 (Exim 4.92) (envelope-from ) id 1tG57b-00026b-CM; Tue, 26 Nov 2024 23:37:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844321.1259891; Tue, 26 Nov 2024 23:37:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG57b-00026U-9u; Tue, 26 Nov 2024 23:37:31 +0000 Received: by outflank-mailman (input) for mailman id 844321; Tue, 26 Nov 2024 23:37:30 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sl-0000At-De for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:11 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3dbb8ddd-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:02 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A3A9D5C5D31; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id D1560C4CED0; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7F4DD66B97; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 3dbb8ddd-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNkYmI4ZGRkLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzIzLjE1Mzg0NCwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663316; bh=3B9kDEeHN3CLeIVggukm2mQ91O/Gp2h/G9Z0+jViCMU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cr5zAvq4k8x3uKM38Jz4HtBTKbGja2wbZmF6XG0K8nudD9IEhghKJJwsatgsvTfgE tOj1Rfjh9QoJCdPcOmeDhUm2Wd0De/OFwNguK0cBTTtaavf2k/w66IycgdSxSjdIjV NO+9OHhmcAd+IDzpqJ1Kv8XPf5fqQvTctp7+O2/aJanmDxonEMsyd7f58t0PAknLUC ZnelYJkaDQjj8W6DdjL7doWjMfxXXMAAtHNBelEcAAGeAuyl6MVK4KMViBu4MG3fAJ k+rRYAp88hHzxdNSB0SDgn7Z1pMxblpYPfs9a8W3ZhVB7yVrGiZMtWfJrq4EdljZGl 5his4NKZAjZ2A== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:11 -0800 Subject: [PATCH 21/36] xen/console: introduce use of 'is_console' flag MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-21-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=3376; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=ly2NKmV1rm1k90TAwD4huxu/gpF7eMHcF04jNDfnH2A=; b=Adf9/uDabysbO97VQCxegMuFHWIbw+k/X5FX4Vsxz0Y+j/VcL+5URcPHM/jpc4NJZyL8kTyY4 yGmxTV2nxksDqRPybSI7d7nPcT9HN8BKUfsx8LBkoVWN5+6Gsr2vfOd X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin The code now inspects d->is_console flag to decide whether the console focus should move to the domain w/ console after administrator presses . To do that max_init_domid is updated in domain_create(). Console owner domain switch logic updated accordingly. Signed-off-by: Denis Mukhin --- xen/arch/x86/pv/shim.c | 2 ++ xen/common/domain.c | 14 ++++++++++++++ xen/drivers/char/console.c | 14 ++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index 17cb30620290c76cf42251f70cfa4199c0e165d1..a55c1d2a1e616f8979677a198eb9caabc3afc6bf 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -238,6 +238,8 @@ void __init pv_shim_setup_dom(struct domain *d, l4_pgentry_t *l4start, * guest from depleting the shim memory pool. */ d->max_pages = domain_tot_pages(d); + + d->is_console = true; } static void write_start_info(struct domain *d) diff --git a/xen/common/domain.c b/xen/common/domain.c index d8f6829db50dabba7464004b39eea39f6970f800..56f5d3b2031c52d567bfcf839740600320d952e9 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -682,6 +682,8 @@ struct domain *domain_create(domid_t domid, old_hwdom = hardware_domain; hardware_domain = d; + + d->is_console = true; } TRACE_TIME(TRC_DOM0_DOM_ADD, d->domain_id); @@ -818,6 +820,18 @@ struct domain *domain_create(domid_t domid, memcpy(d->handle, config->handle, sizeof(d->handle)); + /* + * Housekeeping for physical console forwarding to the domain. + */ + if ( !is_system_domain(d) && max_init_domid < domid ) + max_init_domid = domid; + + /* + * NB: flag is already set for PV shim and hardware domain, check whether + * virtual UART is present. + */ + d->is_console |= domain_has_vuart(d); + return d; fail: diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 60c055396b697869b04b9132b0dcfa832fabe932..8cbac54c66044ae8581e486a782102b75c8bfaa9 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -1,8 +1,8 @@ /****************************************************************************** * console.c - * + * * Emergency console I/O for Xen and the domain-0 guest OS. - * + * * Copyright (c) 2002-2004, K A Fraser. * * Added printf_ratelimit @@ -509,14 +509,20 @@ static void console_find_owner(void) domid = get_initial_domain_id(); else domid = next_rx - 1; + d = rcu_lock_domain_by_id(domid); - if ( d ) + if ( d == NULL ) + continue; + + if ( d->is_console ) { rcu_unlock_domain(d); console_owner = next_rx; printk("*** Serial input to DOM%u", domid); break; } + + rcu_unlock_domain(d); } if ( switch_code ) @@ -814,7 +820,7 @@ static int printk_prefix_check(char *p, char **pp) return ((atomic_read(&print_everything) != 0) || (loglvl < lower_thresh) || ((loglvl < upper_thresh) && printk_ratelimit())); -} +} static int cf_check parse_console_timestamps(const char *s) { From patchwork Tue Nov 26 23:22:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886428 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 53F36D66B9A for ; Tue, 26 Nov 2024 23:38:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844355.1259921 (Exim 4.92) (envelope-from ) id 1tG58X-0003qG-7b; Tue, 26 Nov 2024 23:38:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844355.1259921; Tue, 26 Nov 2024 23:38:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG58X-0003q9-4H; Tue, 26 Nov 2024 23:38:29 +0000 Received: by outflank-mailman (input) for mailman id 844355; Tue, 26 Nov 2024 23:38:27 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sn-0000At-E0 for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:13 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3dbddc90-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:02 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BDF735C5D37; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id E73D3C4CED3; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB2FED66B94; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 3dbddc90-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNkYmRkYzkwLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzIzLjE4OTI5Niwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=Msd9ALOQsKWgqYjqZp3vEbU4YxKp+IL/6j5doF/TX4s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=EjGuXXXvARbSkfc9IeVFfmDHBQewfsHXB2SXcmmGhSEvXVTaV5iWWdnXzabgyJMwH +B5r5Dapx/vEoY/eyz5JhORRlBsB0xnQ2a8FoW5puADacIjjtYIyGkiLIhNX0HjDVC FGkTol8ab/a+6vKnUS41q9cGlMb7mjKysuc2cBgm3N4lzTYJX30pRJko+rhXJfcGYt Jj4SZkbqShKLlqH01xPdfnHWxkxZmXo8hYKCjcawD/AMa7gR9MxMJ7XEfM0gASX3E7 dNFMElmgkVxhKRPxT/vr/jXLwNXBsQBhZsjfCtbRCdQY63rpKkATQiAhj3RupE5tkt rldH3hv+7xf/Q== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:12 -0800 Subject: [PATCH 22/36] xen/console: introduce console_set_owner() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-22-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=6105; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=LaoLtTtPVB803Wx66ywoNWCuGefL+9P7BcXWkOi4Ttw=; b=4lK/8BHVyfy3woSRpKh5PM02ENnqP+ItqkfEgYigMPj6lRFJWcPJsSQvqyG1yASQpUrz6O30O flL6r/RmuUgA0bIlRawQx23oGAn7Yvbn6WD6FIZY6jvjVBKaIN+E4lv X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin console_set_owner() is introduced for setting the new console owner. Switches console owner to domain ID vs range of integer numbers mapped to domain IDs. This a public API to console driver, will be used in the follow on code change. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 122 ++++++++++++++++++++++++++------------------- xen/include/xen/console.h | 1 + 2 files changed, 71 insertions(+), 52 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 8cbac54c66044ae8581e486a782102b75c8bfaa9..52cf64dbf6fd18d599cb88835d03501a23b3e3c4 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -463,82 +463,100 @@ static void cf_check dump_console_ring_key(unsigned char key) /* * CTRL- changes input direction, rotating among Xen, Dom0, - * and the DomUs started from Xen at boot. + * and the DomUs. */ #define switch_code (opt_conswitch[0]-'a'+1) + /* - * console_owner=0 => input to xen - * console_owner=1 => input to dom0 (or the sole shim domain) - * console_owner=N => input to dom(N-1) + * Current console owner domain ID: either Xen or domain w/ d->is_console == + * true. + * + * Initialized in console_endboot(). */ -static unsigned int __read_mostly console_owner = 0; +static domid_t __read_mostly console_owner; -#define max_console_rx (max_init_domid + 1) +static struct domain *rcu_lock_domain_console_by_id(domid_t domid) +{ + struct domain *d; + + d = rcu_lock_domain_by_id(domid); + + if ( d == NULL ) + return NULL; + + if ( d->is_console ) + return d; + + rcu_unlock_domain(d); + + return NULL; +} -#ifdef CONFIG_SBSA_VUART_CONSOLE /* Make sure to rcu_unlock_domain after use */ struct domain *rcu_lock_domain_console_owner(void) { - if ( console_owner == 0 ) - return NULL; - return rcu_lock_domain_by_id(console_owner - 1); + return rcu_lock_domain_console_by_id(console_owner); } -#endif -static void console_find_owner(void) +static bool console_owner_possible(domid_t domid) { - unsigned int next_rx = console_owner; - - /* - * Rotate among Xen, dom0 and boot-time created domUs while skipping - * switching serial input to non existing domains. - */ - for ( ; ; ) - { - domid_t domid; - struct domain *d; - - if ( next_rx++ >= max_console_rx ) - { - console_owner = 0; - printk("*** Serial input to Xen"); - break; - } - - if ( consoled_is_enabled() && next_rx == 1 ) - domid = get_initial_domain_id(); - else - domid = next_rx - 1; - - d = rcu_lock_domain_by_id(domid); - if ( d == NULL ) - continue; - - if ( d->is_console ) - { - rcu_unlock_domain(d); - console_owner = next_rx; - printk("*** Serial input to DOM%u", domid); - break; - } + struct domain *d; + d = rcu_lock_domain_console_by_id(domid); + if ( d != NULL ) rcu_unlock_domain(d); - } + + return d != NULL; +} + +int console_set_owner(domid_t domid) +{ + if ( domid == DOMID_XEN ) + printk("*** Serial input to Xen"); + else if ( console_owner_possible(domid) ) + printk("*** Serial input to DOM%u", domid); + else + return -ENOENT; + + console_owner = domid; if ( switch_code ) printk(" (type 'CTRL-%c' three times to switch input)", opt_conswitch[0]); printk("\n"); + + return 0; +} + +/* + * Switch console input focus. + * Rotates input focus among Xen, dom0 and boot-time created domUs while + * skipping switching serial input to non existing domains. + */ +static void console_find_owner(void) +{ + domid_t i, n = max_init_domid + 1; + + if ( console_owner == DOMID_XEN ) + i = get_initial_domain_id(); + else + i = console_owner + 1; + + for ( ; i < n; i++ ) + if ( !console_set_owner(i) ) + break; + if ( i == n ) + console_set_owner(DOMID_XEN); } static void __serial_rx(char c) { switch ( console_owner ) { - case 0: + case DOMID_XEN: return handle_keypress(c, false); - case 1: + case 0: /* * Deliver input to the hardware domain buffer, unless it is * already full. @@ -556,7 +574,7 @@ static void __serial_rx(char c) #ifdef CONFIG_SBSA_VUART_CONSOLE default: { - struct domain *d = rcu_lock_domain_by_id(console_owner - 1); + struct domain *d = rcu_lock_domain_by_id(console_owner); /* * If we have a properly initialized vpl011 console for the @@ -567,7 +585,7 @@ static void __serial_rx(char c) vpl011_rx_char_xen(d, c); else printk("Cannot send chars to Dom%d: no UART available\n", - console_owner - 1); + console_owner); if ( d != NULL ) rcu_unlock_domain(d); @@ -1126,7 +1144,7 @@ void __init console_endboot(void) * a useful 'how to switch' message. */ if ( opt_conswitch[1] == 'x' ) - console_owner = max_console_rx; + console_owner = DOMID_XEN; register_keyhandler('w', dump_console_ring_key, "synchronously dump console ring buffer (dmesg)", 0); diff --git a/xen/include/xen/console.h b/xen/include/xen/console.h index 0e211e44d9703c804e18f52c9743916f8d2a9d4e..57c482cfbf2da15b011e64841ea086e779f4588d 100644 --- a/xen/include/xen/console.h +++ b/xen/include/xen/console.h @@ -32,6 +32,7 @@ void console_start_log_everything(void); void console_end_log_everything(void); struct domain *rcu_lock_domain_console_owner(void); +int console_set_owner(domid_t); /* * Steal output from the console. Returns +ve identifier, else -ve error. From patchwork Tue Nov 26 23:22:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886422 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 E1F6FD66B8E for ; Tue, 26 Nov 2024 23:33:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844281.1259871 (Exim 4.92) (envelope-from ) id 1tG53L-0000GG-MC; Tue, 26 Nov 2024 23:33:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844281.1259871; Tue, 26 Nov 2024 23:33:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG53L-0000G9-JU; Tue, 26 Nov 2024 23:33:07 +0000 Received: by outflank-mailman (input) for mailman id 844281; Tue, 26 Nov 2024 23:33:05 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sm-0000At-Dq for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:12 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3dc3ccbf-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:02 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D25375C5D3C; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 08ACFC4CED2; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3EF3D66B9A; Tue, 26 Nov 2024 23:21:56 +0000 (UTC) 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: 3dc3ccbf-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNkYzNjY2JmLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzIzLjI1NDg4OSwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=70k9tJWzxtakueDep8Z1r6BQFS566Fm/qs8rAVna/Is=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jJCZv7my8H/3lS+3bdlfiB83uaPSOwCH3+jJeeXZZTOAPn2xwqA6s9B26wCFmxouc dJAeEomRCDXxgvwx+zpUOevdODJ/mohAivCKU9vxU+QiTLq9ppACjw6n8z/UA+dpfK gRYAK4fFaGGlqQs9+31gxr2xaXplzaQQGIgEkP6ZawoZJH0sR3/dUTJBXUGxep1S6t 1MCs8hCEeBSIhCMHpzrqZlMl2lf+gFok8tyChn/d/baw4rzCZXeWHndR0BiaFdBOKL lQ1o5TU/hdA3uyoDv9FIgouVQTn8whv/LlRl9i+ukJfUpia2TmnrF89dT8EOzJyPga eRmRO2+OXDyHg== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:13 -0800 Subject: [PATCH 23/36] xen/console: introduce console_owner_domid() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-23-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=1498; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=B93paIiJy8o1DGD2n2g3KcZoYn4UUAYMMgdZEki+Vh4=; b=a1KLhgIP/wkGHh4LRPTxOwbLhltFvdmll2s4Flx4yZG+kptxLNfIi4RPcJXe1hUfAR75LCSDK CPqJbPQrUXiBdavoxzNDPIXzGTnXA1tR5jPRZbungeACqaHpREZ+6Ui X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin console_owner_domid() is introduced to obtain the "console owner" domain ID. The call is used in NS8250 emulator to identify the case when physical xen console focus is owned by the domain w/ NS8250 emulator, in which case, messages from guest OS are formatted w/o '(XEN)' prefix. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 5 +++++ xen/include/xen/console.h | 1 + 2 files changed, 6 insertions(+) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 52cf64dbf6fd18d599cb88835d03501a23b3e3c4..a8ab5c2bcb98e4cadf9ad2c9ad28d297977d0557 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -498,6 +498,11 @@ struct domain *rcu_lock_domain_console_owner(void) return rcu_lock_domain_console_by_id(console_owner); } +domid_t console_owner_domid(void) +{ + return console_owner; +} + static bool console_owner_possible(domid_t domid) { struct domain *d; diff --git a/xen/include/xen/console.h b/xen/include/xen/console.h index 57c482cfbf2da15b011e64841ea086e779f4588d..83be5794aff6630beaad46f910fcc0fc6d833808 100644 --- a/xen/include/xen/console.h +++ b/xen/include/xen/console.h @@ -33,6 +33,7 @@ void console_end_log_everything(void); struct domain *rcu_lock_domain_console_owner(void); int console_set_owner(domid_t); +domid_t console_owner_domid(void); /* * Steal output from the console. Returns +ve identifier, else -ve error. From patchwork Tue Nov 26 23:22:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886394 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 9FAD6D66B8E for ; Tue, 26 Nov 2024 23:23:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844069.1259703 (Exim 4.92) (envelope-from ) id 1tG4tt-0002nj-EV; Tue, 26 Nov 2024 23:23:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844069.1259703; Tue, 26 Nov 2024 23:23:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4ts-0002kw-U1; Tue, 26 Nov 2024 23:23:20 +0000 Received: by outflank-mailman (input) for mailman id 844069; Tue, 26 Nov 2024 23:22:08 +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 1tG4si-0000Ao-MC for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:08 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3dbf5b85-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:02 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E47905C5D70; Tue, 26 Nov 2024 23:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 1DBFDC4CED7; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11E83D66B94; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3dbf5b85-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNkYmY1Yjg1LWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzIzLjI1ODE0NSwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=xN3Qk4AnkavJDz1+2oRzOsxhatlUANXuldhRbnVqaL0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ItYXHoJ/mJNsPDSZ9pf4Ui726UpgFmylp5LAsOGmc2yZqvNzSjIAKc+fMV+PdsJnC RxLCIck1Wfcv7eF+HknLfAxJO3jiVLxxpII/Kl6TpWtC4ct7bFEvLWhMjp+d9vAmHP P3iuRXB3dQJQtffNjDd8pjaYCsMO1maYRtTENwECy0JhRRkr39RkuNR454sLuDH503 /egBzxIdcif4Zqt16DnAkRv5CWX5Ye9QkvhYwsm7O42u/G+sGk0WKSUlEAYMnCCCZn sJR8lW7x5wSmgrdL7nhCuJPqJFMoB5Bd1flhz7j4z2RcMg/GJoXQh12ijlgRx/5dmO GYQ8r9hIxUlDg== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:14 -0800 Subject: [PATCH 24/36] xen/console: introduce console_init_owner() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-24-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=1949; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=9IHMF1BdeViUoT1r1xwy88EM2J39hJxCdMpf6FUj+oc=; b=iU++HT4kXEU4fCx3MfdSPop0eCxgapVBalO1zTfRHftl7NMTURPkAWlnTI41PiCDlyw5pkYq5 YJOq/CZ6Y6lD6glLNem8Mfog6GMWKqhpPKh/ks4hfwiAJ0sIF3uEIrW X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin console_init_owner() is introduced for selecting the boot-time console owner. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index a8ab5c2bcb98e4cadf9ad2c9ad28d297977d0557..6261bdb5a2ac1075bc89fa408c0fd6cfef380ae6 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -554,6 +554,22 @@ static void console_find_owner(void) console_set_owner(DOMID_XEN); } +static void console_init_owner(void) +{ + domid_t domid; + + /* + * If user specifies so, we fool the switch routine to redirect input + * straight back to Xen. + */ + if ( opt_conswitch[1] == 'x' ) + domid = DOMID_XEN; + else + domid = get_initial_domain_id(); + + console_set_owner(domid); +} + static void __serial_rx(char c) { switch ( console_owner ) @@ -1143,14 +1159,6 @@ void __init console_endboot(void) video_endboot(); - /* - * If user specifies so, we fool the switch routine to redirect input - * straight back to Xen. I use this convoluted method so we still print - * a useful 'how to switch' message. - */ - if ( opt_conswitch[1] == 'x' ) - console_owner = DOMID_XEN; - register_keyhandler('w', dump_console_ring_key, "synchronously dump console ring buffer (dmesg)", 0); register_irq_keyhandler('+', &do_inc_thresh, @@ -1160,8 +1168,7 @@ void __init console_endboot(void) register_irq_keyhandler('G', &do_toggle_guest, "toggle host/guest log level adjustment", 0); - /* Serial input is directed to DOM0 by default. */ - console_find_owner(); + console_init_owner(); } int __init console_has(const char *device) From patchwork Tue Nov 26 23:22:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886414 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 A036CD66B8E for ; Tue, 26 Nov 2024 23:30:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844188.1259792 (Exim 4.92) (envelope-from ) id 1tG512-0003hl-Hb; Tue, 26 Nov 2024 23:30:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844188.1259792; Tue, 26 Nov 2024 23:30:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG512-0003he-ET; Tue, 26 Nov 2024 23:30:44 +0000 Received: by outflank-mailman (input) for mailman id 844188; Tue, 26 Nov 2024 23:30:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4st-0000At-EW for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:19 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3fde0617-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:06 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 023A95C5D75; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 2EA58C4CED8; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26DF0D66B9A; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3fde0617-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjI2MDQ6MTM4MDo0NjQxOmM1MDA6OjEiLCJoZWxvIjoiZGZ3LnNvdXJjZS5rZXJuZWwub3JnIn0= X-Custom-Transaction: eyJpZCI6IjNmZGUwNjE3LWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzI2Ljc1MjkwMywic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=Fe2836fVTLNAm3WsnALDDlo7tZdWGBnob9UKBanM8xI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=J468pXVt8bOqy5i6t8qfP65xQmcXe+5MRsCF3WbpQP8490hVNvowZ0irJcnakiJKy xqfQHD5GExSMWUtTvk6CjkvYWGd+f1kB/GCid2DX34E/uMtZz2Sqiw3ncPsnKKe+Aw lCqD9pEu0lsqRMXKYR5R4ZIUFjriLbV2shx5VyiRtqo3TB2w2bxS9QUUHpVM2eTTFh POHQcMAIFaDN3qSFzrd41r+QRK0u+B/4k7oVMOWA5MVuOJKSGAgAQjlFhHrf77wNsx c3pbqB4KCwhUK8FaY/ivZNcWcpV7MHMAZMBtTPB1LZujkwzNMx9vnVguBWqzOl5EJs JOdfysywjGVjQ== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:15 -0800 Subject: [PATCH 25/36] xen/console: introduce handle_keypress_in_domain() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-25-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=4030; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=WFmMQGLVJ0pT89tmxZ0ESYKHXHYqZV3StRB9Oqc56Go=; b=GoTkJnk83G9LUzBwpX7Aka4GbqCU17s/CyNsDUtmb57uNiKM4uuDJ+oKcwJiPDwset63x3jYN YB7yk8Qun2gBof4pKaDDjOz1+GkUp1ER7gJzYPIEFEAEe0lcgNWckUO X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin With introduction of NS8250 emulator for x86, the logic of switching console focus gets more convoluted: HVM domain w/ NS8205 must be able to receive the physical console input for guest VM debugging. Also, existing code does not honor `hardware_dom=` xen command line parameter (hardware domain ID does _not_ necessarily starts from 0). Introduce handle_keypress_in_domain() to account for all scenarios of console input forwarding. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 102 ++++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 6261bdb5a2ac1075bc89fa408c0fd6cfef380ae6..4439e00763631969767719053cdc81e67c2cda2c 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -570,54 +570,70 @@ static void console_init_owner(void) console_set_owner(domid); } -static void __serial_rx(char c) +static void handle_keypress_in_domain(struct domain *d, char c) { - switch ( console_owner ) + int rc = 0; + + /* + * Deliver input to the emulated UART. + */ + if ( domain_has_vuart(d) ) { - case DOMID_XEN: - return handle_keypress(c, false); - - case 0: - /* - * Deliver input to the hardware domain buffer, unless it is - * already full. - */ - if ( (serial_rx_prod - serial_rx_cons) != SERIAL_RX_SIZE ) - serial_rx_ring[SERIAL_RX_MASK(serial_rx_prod++)] = c; - - /* - * Always notify the hardware domain: prevents receive path from - * getting stuck. - */ - send_global_virq(VIRQ_CONSOLE); - break; - -#ifdef CONFIG_SBSA_VUART_CONSOLE - default: - { - struct domain *d = rcu_lock_domain_by_id(console_owner); - - /* - * If we have a properly initialized vpl011 console for the - * domain, without a full PV ring to Dom0 (in that case input - * comes from the PV ring), then send the character to it. - */ - if ( d != NULL ) - vpl011_rx_char_xen(d, c); - else - printk("Cannot send chars to Dom%d: no UART available\n", - console_owner); - - if ( d != NULL ) - rcu_unlock_domain(d); - - break; - } +#if defined(CONFIG_SBSA_VUART_CONSOLE) + rc = vpl011_rx_char_xen(d, c); #endif } + /* + * Deliver input to the hardware domain buffer. + */ + else if ( d == hardware_domain ) + { + /* + * Deliver input to the PV shim console. + */ + if ( consoled_is_enabled() ) + rc = consoled_guest_tx(c); + else + { + /* + * Deliver input to the hardware domain buffer, unless it is + * already full. + */ + if ( (serial_rx_prod - serial_rx_cons) != SERIAL_RX_SIZE ) + serial_rx_ring[SERIAL_RX_MASK(serial_rx_prod++)] = c; - if ( consoled_is_enabled() ) - consoled_guest_tx(c); + /* + * Always notify the hardware domain: prevents receive path from + * getting stuck. + */ + send_global_virq(VIRQ_CONSOLE); + rc = 0; + } + } + /* + * Deliver input to the PV shim console. + */ + else if ( consoled_is_enabled() ) + rc = consoled_guest_tx(c); + + if ( rc ) + printk(KERN_WARNING "console input domain %d: not ready: %d\n", + d->domain_id, rc); + +} + +static void __serial_rx(char c) +{ + struct domain *d; + + d = rcu_lock_domain_console_owner(); + if ( d != NULL ) + { + handle_keypress_in_domain(d, c); + rcu_unlock_domain(d); + } + else + handle_keypress(c, false); } static void cf_check serial_rx(char c) From patchwork Tue Nov 26 23:22:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886426 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 9A554D66B9A for ; Tue, 26 Nov 2024 23:37:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844323.1259902 (Exim 4.92) (envelope-from ) id 1tG57f-0002Nq-Kg; Tue, 26 Nov 2024 23:37:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844323.1259902; Tue, 26 Nov 2024 23:37:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG57f-0002Nj-H2; Tue, 26 Nov 2024 23:37:35 +0000 Received: by outflank-mailman (input) for mailman id 844323; Tue, 26 Nov 2024 23:37:34 +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 1tG4sn-0000Ao-NE for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:13 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3fc4fba5-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:05 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1F59F5C5D77; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 45451C4CED0; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B882D66B8E; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3fc4fba5-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNmYzRmYmE1LWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzI1LjgxMDY0OCwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=5p7FQirypDNvXa/ADc/A3qm2m9f35PQKXZmP0f/F4yM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=vPwWjyWIjN/ljcfhd3K4w3gyn1iFmZMe/TRHxFN8DZvVAIz/5prMPhINBiaGqzQZz 9uEe5ei3yODyUP9cJ2uVHO6ISEktdurzgm7RNtBS4mULVAWdTDQmBp1WyCpeyQ0XoE QfgnSdSQzQeebIYM4HUrqztxN3OIzzNl1Y7eabDWYKyfNG8SSMbHjZiIDARIilMOCt ahAKkPlpuCK5srsQ0IvgjOyI/mLPDUJT86iwSDM+ZVtsYNQ5lhj1GNZERmjScV8MXV Ke1BRLvORdIaANR5/Wf8mOIniodkcTgkgvU2VMGtnMrvsHkXG4usxTxKLrq1RQex+/ Pt9f8eaqqaz4w== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:16 -0800 Subject: [PATCH 26/36] xen/console: introduce console_write() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-26-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=4283; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=mC1dfr4+26P41BllPMG6MZbu9F46btGiiA2X1kH3gME=; b=hb4ZH7CsrUUdK9/NkrG9FYu22AqGi/bZMiyvvI9e3EZYIzNKn/vse7pJTCknstGu43n9nc68n zegv/33ak9sCf0BS87RJVnZ4f1YoDras7AKDidQNrQtdz43jVQn137A X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin PV Linux kernel uses HYPERVISOR_console_io hypercall for early console which ends up being handled by Xen's console driver's guest_console_write(). guest_console_write() duplicates the code from __putstr(), elimitate code duplication. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 94 ++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 44 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 4439e00763631969767719053cdc81e67c2cda2c..3d8d3c852e69d8fddd1d978fdd8932eb75551f25 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -665,6 +665,19 @@ static void cf_check notify_dom0_con_ring(void *unused) static DECLARE_SOFTIRQ_TASKLET(notify_dom0_con_ring_tasklet, notify_dom0_con_ring, NULL); +static bool console_locks_busted; + +static void conring_write(const char *str, size_t len) +{ + if ( opt_console_to_ring ) + { + conring_puts(str, len); + + if ( !console_locks_busted ) + tasklet_schedule(¬ify_dom0_con_ring_tasklet); + } +} + #ifdef CONFIG_X86 static inline void xen_console_write_debug_port(const char *buf, size_t len) { @@ -673,8 +686,43 @@ static inline void xen_console_write_debug_port(const char *buf, size_t len) : "=&S" (tmp), "=&c" (tmp) : "0" (buf), "1" (len), "d" (XEN_HVM_DEBUGCONS_IOPORT) ); } + +static void xen_console_write(const char *str, size_t len) +{ + if ( opt_console_xen ) + { + if ( xen_guest ) + xen_hypercall_console_write(str, len); + else + xen_console_write_debug_port(str, len); + } +} +#else +static void xen_console_write(const char *str, size_t len) +{ +} #endif +/* + * Write characters to console. + * + * That will handle all possible scenarios working w/ console + * - serial console; + * - video output; + * - __HYPERVISOR_console_io hypercall (x86 only); + * - debug I/O port (x86 only); + * - forward to Xen event channel. + */ +static void console_write(const char *str, size_t len) +{ + ASSERT(rspin_is_locked(&console_lock)); + + console_serial_puts(str, len); + video_puts(str, len); + xen_console_write(str, len); + conring_write(str, len); +} + static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, unsigned int count) { @@ -695,28 +743,8 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, if ( is_hardware_domain(cd) ) { - /* Use direct console output as it could be interactive */ nrspin_lock_irq(&console_lock); - - console_serial_puts(kbuf, kcount); - video_puts(kbuf, kcount); - -#ifdef CONFIG_X86 - if ( opt_console_xen ) - { - if ( xen_guest ) - xen_hypercall_console_write(kbuf, kcount); - else - xen_console_write_debug_port(kbuf, kcount); - } -#endif - - if ( opt_console_to_ring ) - { - conring_puts(kbuf, kcount); - tasklet_schedule(¬ify_dom0_con_ring_tasklet); - } - + console_write(kbuf, kcount); nrspin_unlock_irq(&console_lock); } else @@ -817,31 +845,9 @@ long do_console_io( * ***************************************************** */ -static bool console_locks_busted; - static void __putstr(const char *str) { - size_t len = strlen(str); - - ASSERT(rspin_is_locked(&console_lock)); - - console_serial_puts(str, len); - video_puts(str, len); - -#ifdef CONFIG_X86 - if ( opt_console_xen ) - { - if ( xen_guest ) - xen_hypercall_console_write(str, len); - else - xen_console_write_debug_port(str, len); - } -#endif - - conring_puts(str, len); - - if ( !console_locks_busted ) - tasklet_schedule(¬ify_dom0_con_ring_tasklet); + console_write(str, strlen(str)); } static int printk_prefix_check(char *p, char **pp) From patchwork Tue Nov 26 23:22:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886418 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 4E8F4D66B8E for ; Tue, 26 Nov 2024 23:31:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844226.1259832 (Exim 4.92) (envelope-from ) id 1tG521-0005Y1-LV; Tue, 26 Nov 2024 23:31:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844226.1259832; Tue, 26 Nov 2024 23:31:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG521-0005XM-H1; Tue, 26 Nov 2024 23:31:45 +0000 Received: by outflank-mailman (input) for mailman id 844226; Tue, 26 Nov 2024 23:31:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sv-0000At-Ei for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:21 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3fd053c2-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:06 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2D1395C5D81; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 5507EC4CED9; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D7EAD66B9D; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3fd053c2-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNmZDA1M2MyLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzI2LjY3MzkzNCwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=MgApai2X2eHnbK37BwNB8ShofCKeQUT/r7C8T0eMz1I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Kr4Oa3t4K4Lqehvz16FW6oidxWBNJJCWVcBIING4CPQQMH9bCF60D3lqRB5iZww1s l28HhYztl0EArICqaJohxeYIfob6EHHJVjrgmI+45/CUb+QjdaOQ0BRPiqEAj8EEE7 QR3qfxv6Cvi3ETN/EOvruf1iuysj0PGLoPkjKgoSWfuQ3DZmisdxp2K2qieHdyIoMF 30P5pX8+TA7oXj+ayjDnuO0aBnAcH/5Dek/9FmSc4Ges+vIoSQTpkvVWosLaHbNArM kwVAA/VwcjQzuLpSB9BGbnm8BeboZTxjip26X+tTrY+5WpL3f9AAHGQnzuLeLgWDBb CMwLNSTQkyy+A== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:17 -0800 Subject: [PATCH 27/36] xen/console: introduce hwdom_crashconsole= MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-27-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=3869; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=JESGJHjMxTvWh9SGyt0+xymQaxEqPkPKVM3b9HUELmI=; b=mY7Ag7UTh6FVmqmRN1Vz6+VT0ef9bxlfj+zIyWvTuiQ7Kzug6VSn9jEO79q8KDBzcMJb0BbLg SBhaZjR2X43Bt0VtujV+uNAm8/kuyShsWwnARo7ewwDgMfGgasQJAyr X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin The new command line switch `hwdom_crashconsole=BOOL` allows to switch serial console input focus to xen for machine state inspection using keyhandler mechanism after the hardware domain crashes. The new command line switch is aliased via `dom0=...,crashconsole` knob. Such functionality can be useful while debugging dom0 bringup. Signed-off-by: Denis Mukhin --- docs/misc/xen-command-line.pandoc | 5 +++++ xen/arch/x86/dom0_build.c | 2 ++ xen/arch/x86/include/asm/setup.h | 1 + xen/common/domain.c | 14 +++++++++++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 293dbc1a957ba6e668fd4d55d58e84f643822126..fb77d7dca1ea517f79d6713aa6909422f31e7724 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -806,6 +806,7 @@ Specify the bit width of the DMA heap. ### dom0 = List of [ pv | pvh, shadow=, verbose=, + crashconsole=, cpuid-faulting=, msr-relaxed= ] (x86) = List of [ sve= ] (Arm64) @@ -839,6 +840,10 @@ Controls for how dom0 is constructed on x86 systems. information during the dom0 build. It defaults to the compile time choice of `CONFIG_VERBOSE_DEBUG`. +* The `crashconsole` boolean instructs Xen to drop into emergency console + in case of dom0 crash. May be useful for dom0 bringup on a custom + hardware. + * The `cpuid-faulting` boolean is an interim option, is only applicable to PV dom0, and defaults to true. diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index e8f5bf5447bc47a6daa3d95787106a4c11e80d31..706aeec0ecbb565a415edbfb33ca2fd72967c560 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -286,6 +286,8 @@ int __init parse_arch_dom0_param(const char *s, const char *e) opt_dom0_cpuid_faulting = val; else if ( (val = parse_boolean("msr-relaxed", s, e)) >= 0 ) opt_dom0_msr_relaxed = val; + else if ( (val = parse_boolean("crashconsole", s, e)) >= 0 ) + opt_hwdom_crashconsole = !!val; else return -EINVAL; diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 296348655b9d146c73acc305cc9edd5fd46f7d47..5edae2d15cc0a1ad74eb1637a48dd3a74e0c37ee 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -68,5 +68,6 @@ extern bool opt_dom0_pvh; extern bool opt_dom0_verbose; extern bool opt_dom0_cpuid_faulting; extern bool opt_dom0_msr_relaxed; +extern bool opt_hwdom_crashconsole; #endif diff --git a/xen/common/domain.c b/xen/common/domain.c index 56f5d3b2031c52d567bfcf839740600320d952e9..68112ca6de09d58f3df10b8545fec55583d2bf74 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -56,6 +56,13 @@ unsigned int xen_processor_pmbits = XEN_PROCESSOR_PM_PX; bool opt_dom0_vcpus_pin; boolean_param("dom0_vcpus_pin", opt_dom0_vcpus_pin); +/* + * Hardware domain crash handler: if true, do not halt machine, but switch to + * Xen console for debugging. + */ +bool opt_hwdom_crashconsole; +boolean_param("hwdom_crashconsole", opt_hwdom_crashconsole); + /* Protect updates/reads (resp.) of domain_list and domain_hash. */ DEFINE_SPINLOCK(domlist_update_lock); DEFINE_RCU_READ_LOCK(domlist_read_lock); @@ -1144,7 +1151,12 @@ int domain_shutdown(struct domain *d, u8 reason) reason = d->shutdown_code; if ( is_hardware_domain(d) ) - hwdom_shutdown(reason); + { + if ( opt_hwdom_crashconsole ) + console_set_owner(DOMID_XEN); + else + hwdom_shutdown(reason); + } if ( d->is_shutting_down ) { From patchwork Tue Nov 26 23:22:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886417 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 09AC1D66B9A for ; Tue, 26 Nov 2024 23:31:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844222.1259822 (Exim 4.92) (envelope-from ) id 1tG51u-00057E-CF; Tue, 26 Nov 2024 23:31:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844222.1259822; Tue, 26 Nov 2024 23:31:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG51u-000575-90; Tue, 26 Nov 2024 23:31:38 +0000 Received: by outflank-mailman (input) for mailman id 844222; Tue, 26 Nov 2024 23:31:36 +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 1tG4sm-0000Ao-Mu for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:12 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3fb763ee-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:05 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3D79C5C5D84; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 65829C4CED7; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BC36D66B9A; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3fb763ee-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNmYjc2M2VlLWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzI1LjU5MzM4Nywic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=P4X+dnER+7JoqwwmELmRNzsru3TR+rJuCDE5NVa75n8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=LTOb+oAyp07JKXq2KJLVV+d+MoHMeglaDQDpfdyCKHfYf7hokgtzJvzzayeEwnusL xHKXsVFkKdUWVziDvBhvsgLEE6VCg6BVZgJwbo3dSLP4THmQTvfCwtYpm6MtR9vEu6 8Zs1a5pzDa3Zwa1yAafV6H1ovtNzVr1OwPRlydFehttigbeFLTNM4XGW8VncIlEjrM aeg0NzHColTIN1EiqOM0a0KvmsToLU1Dz23F7cwgrdyJvEYDzRn2bIirirIbDJcf7P 2Ssf20fmV2hDlhO7E69JzPLNLozLDgYy/+FuuBT7BRABn4wGqD5pKuKJwnJb7LcBdH saDtyLBreVxDg== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:18 -0800 Subject: [PATCH 28/36] xen/console: simplify console owner switch hint MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-28-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=881; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=IPN7McCx2GMasxWXQvc4fWV7JKmlK0HvFSHLV2y3YOg=; b=oN+IviwIRCqEG8bugGFvwedgL4OLnk6vPm6uROZKAImjHwOcHtL8C/RatenQWqO7uSxuLu4gJ ZT0mRsqa0qjA91V6VY/0iAfAWAnoxW6FR+klTt83UV5rUFCDfvYqK8S X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Update the hint w/ the combination of keys to press to switch physical console to the next owner. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 3d8d3c852e69d8fddd1d978fdd8932eb75551f25..9f67ecb26f5ab1183d17c83631a17b45cfefd5ab 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -526,8 +526,8 @@ int console_set_owner(domid_t domid) console_owner = domid; if ( switch_code ) - printk(" (type 'CTRL-%c' three times to switch input)", - opt_conswitch[0]); + printk(" (type 'CTRL-%c%c%c' to switch input)", + opt_conswitch[0], opt_conswitch[0], opt_conswitch[0]); printk("\n"); return 0; From patchwork Tue Nov 26 23:22:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886429 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 11509D66B9A for ; Tue, 26 Nov 2024 23:39:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844364.1259931 (Exim 4.92) (envelope-from ) id 1tG593-0004bW-Fy; Tue, 26 Nov 2024 23:39:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844364.1259931; Tue, 26 Nov 2024 23:39:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG593-0004bP-DV; Tue, 26 Nov 2024 23:39:01 +0000 Received: by outflank-mailman (input) for mailman id 844364; Tue, 26 Nov 2024 23:38:59 +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 1tG4so-0000Ao-NJ for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:14 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3f92f938-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:06 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4F80A5C5D8A; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 778B7C4CEDB; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B238D66B94; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3f92f938-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNmOTJmOTM4LWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzI2LjMyOTA4MSwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=lj/mfdQca1gsUrIVD1+Z6uLYfT5KncbYzGoRr8znGg8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=lTwL1lLxHQLzdkVdjZUQ3xsKci5v5odyqqMyYMPKv3tGFO3xyeaHNrTYTvvtLdsdK Kvynjxx6BZtaBegtDmSZtYTY23fGx7Dt5weqMf6lE74dy6l2w+E91Ebvl5TFhS3Kbx zusPn0uPxT+H1hzK6yPJdbOlyQI9y3tNoRHN3lwCd+cFp3qftklpB8Zvp98Y0kNlhe puSPncppxvOf7Dv0QwqjN88qOQ3W0KeYfaxfyZKqzlsQ1SONSpcu38a5jctu0NTTVZ 39nl21KByRFDIWOh4Eh6lZcueLdEpYChXKnnTzrXr8tBtztdD2igoy0gZLPNDH1riC S05WRt+GoBeKw== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:19 -0800 Subject: [PATCH 29/36] xen/console: make console buffer size configurable MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-29-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=2270; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=AKwyQAvwjj+wQmu1WwmpWDVO3KxHtjslwmqsRTzrAD0=; b=2HaC4h5V7Nqz/P9NOv91yjhDKAIlxkFFwtZ/HQqHYBGIHO0FUCz24w2vidaasH3dA1AmaxlAe FHROVQWFA36AM3r9ufqu45LJzuW/14PyrFrvxk30PhdkkGk/KDETzzI X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Add new CONRING_LOG_SHIFT Kconfig parameter to specify the boot console buffer size as a power of 2. Bump default size to 32 KiB. Link: https://gitlab.com/xen-project/xen/-/issues/185 Signed-off-by: Denis Mukhin --- xen/drivers/char/Kconfig | 23 +++++++++++++++++++++++ xen/drivers/char/console.c | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig index e175d07c022b051c5af4e689061adba72f9b54a0..2c754545cf05e740bd3d59d88de464f3653fb68e 100644 --- a/xen/drivers/char/Kconfig +++ b/xen/drivers/char/Kconfig @@ -93,6 +93,29 @@ config SERIAL_TX_BUFSIZE Default value is 32768 (32KiB). +config CONRING_LOG_SHIFT + int "Console buffer size" + range 14 25 + default 15 + help + Select the boot console buffer size as a power of 2. + Run-time console buffer size is the same as the boot console size, + unless enforced via 'conring_size=' boot parameter. + + Examples: + 25 => 32 MiB + 24 => 16 MiB + 23 => 8 MiB + 22 => 4 MiB + 21 => 2 MiB + 20 => 1 MiB + 19 => 512 KiB + 18 => 256 KiB + 17 => 128 KiB + 16 => 64 KiB + 15 => 32 KiB + 14 => 16 KiB + config XHCI bool "XHCI DbC UART driver" depends on X86 diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 9f67ecb26f5ab1183d17c83631a17b45cfefd5ab..24a8263045b0e5ecf901d08e627f34a80edd297d 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -102,11 +102,11 @@ static int cf_check parse_console_timestamps(const char *s); custom_runtime_param("console_timestamps", parse_console_timestamps, con_timestamp_mode_upd); -/* conring_size: allows a large console ring than default (16kB). */ +/* conring_size: allows a large console ring than default (32 KiB). */ static uint32_t __initdata opt_conring_size; size_param("conring_size", opt_conring_size); -#define _CONRING_SIZE 16384 +#define _CONRING_SIZE (1U << CONFIG_CONRING_LOG_SHIFT) #define CONRING_IDX_MASK(i) ((i)&(conring_size-1)) static char __initdata _conring[_CONRING_SIZE]; static char *__read_mostly conring = _conring; From patchwork Tue Nov 26 23:22:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886412 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 73FFBD66BAA for ; Tue, 26 Nov 2024 23:23:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844081.1259758 (Exim 4.92) (envelope-from ) id 1tG4u0-0004Rt-UG; Tue, 26 Nov 2024 23:23:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844081.1259758; Tue, 26 Nov 2024 23:23:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tz-0004Ku-FA; Tue, 26 Nov 2024 23:23:27 +0000 Received: by outflank-mailman (input) for mailman id 844081; Tue, 26 Nov 2024 23:22:11 +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 1tG4sl-0000Ao-Mn for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:11 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3f7e5ad1-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:05 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5A14E5C5D97; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 8904BC4CED3; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80BA4D66B8E; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3f7e5ad1-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjI2MDQ6MTM4MDo0NjQxOmM1MDA6OjEiLCJoZWxvIjoiZGZ3LnNvdXJjZS5rZXJuZWwub3JnIn0= X-Custom-Transaction: eyJpZCI6IjNmN2U1YWQxLWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzI1LjM1MDAwMywic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=XhlyTKT6Hlfb0qF61veOPFsm+lhyRH3KNfs5+i2StaA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=gTcMOlTcS220ZM2r3z/DMYmj2iowjMt3qadytRFodvrayrx+QnwWiMg91clSJiJj+ cFJ9n1Ia714FZLG8xgMviWPsttV/UzwdV8NBFJB4mjpO2uDUiQNTUyQy5xHaD7YMpa X9dlVpa8vrb1Usnn89466SRbjYHEZF20hf2ryG9UbH8sDKual57tXsH0eDEzBJLjbM uPCp30t6v+1gI7tXUgvoWcUvmVKobFtQ6hFXWwfsqC2lJAasw7eT7Z6q4MiyYt9Lw4 P50S+94VXQgnowVD+aZ89YSKtm1BrODQz7iVNuLVz1TtCfHl6aBZN09AzNyqGt96si yc1pRzOUoiNmg== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:20 -0800 Subject: [PATCH 30/36] xen/8250-uart: add missing definitions MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-30-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=7186; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=oejdv1gxnsCTTpK0zev/wdrMthybKBcbIC8U8s3WUPs=; b=/MaDwKP9awtaJDnFOE38qqIxCqUh/XIedVanwgDnvHPxhEduc2YVmEpIhzLVWa/T0f6THEh4s nu/8XGQN8rGCDv5+owOfQdvcFbtjw+36ayeQrOU70Rz12/xHWMGYE64 X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Added missing definitions needed for NS8250 UART emulator. Signed-off-by: Denis Mukhin --- xen/include/xen/8250-uart.h | 82 +++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 21 deletions(-) diff --git a/xen/include/xen/8250-uart.h b/xen/include/xen/8250-uart.h index d13352940c13c50bac17d4cdf2f3bf584380776a..51c9b8c5fc3b8d9fa4b93f7722acb963fdf52a3d 100644 --- a/xen/include/xen/8250-uart.h +++ b/xen/include/xen/8250-uart.h @@ -32,16 +32,22 @@ #define UART_MCR 0x04 /* Modem control */ #define UART_LSR 0x05 /* line status */ #define UART_MSR 0x06 /* Modem status */ +#define UART_SCR 0x07 /* Scratch pad */ #define UART_USR 0x1f /* Status register (DW) */ #define UART_DLL 0x00 /* divisor latch (ls) (DLAB=1) */ #define UART_DLM 0x01 /* divisor latch (ms) (DLAB=1) */ #define UART_XR_EFR 0x09 /* Enhanced function register (Exar) */ +/* ns8250 emulator: range of emulated registers [0..UART_MAX-1] */ +#define UART_MAX (UART_SCR + 1) + /* Interrupt Enable Register */ #define UART_IER_ERDAI 0x01 /* rx data recv'd */ #define UART_IER_ETHREI 0x02 /* tx reg. empty */ #define UART_IER_ELSI 0x04 /* rx line status */ #define UART_IER_EMSI 0x08 /* MODEM status */ +#define UART_IER_MASK \ + (UART_IER_ERDAI | UART_IER_ETHREI | UART_IER_ELSI | UART_IER_EMSI) /* Interrupt Identification Register */ #define UART_IIR_NOINT 0x01 /* no interrupt pending */ @@ -51,12 +57,21 @@ #define UART_IIR_THR 0x02 /* - tx reg. empty */ #define UART_IIR_MSI 0x00 /* - MODEM status */ #define UART_IIR_BSY 0x07 /* - busy detect (DW) */ +#define UART_IIR_FE0 BIT(6, U) /* FIFO enable #0 */ +#define UART_IIR_FE1 BIT(7, U) /* FIFO enable #1 */ +#define UART_IIR_FE_MASK (UART_IIR_FE0 | UART_IIR_FE1) /* FIFO Control Register */ -#define UART_FCR_ENABLE 0x01 /* enable FIFO */ -#define UART_FCR_CLRX 0x02 /* clear Rx FIFO */ -#define UART_FCR_CLTX 0x04 /* clear Tx FIFO */ -#define UART_FCR_DMA 0x10 /* enter DMA mode */ +#define UART_FCR_ENABLE BIT(0, U) /* enable FIFO */ +#define UART_FCR_CLRX BIT(1, U) /* clear Rx FIFO */ +#define UART_FCR_CLTX BIT(2, U) /* clear Tx FIFO */ +#define UART_FCR_DMA BIT(3, U) /* enter DMA mode */ +#define UART_FCR_RESERVED0 BIT(4, U) /* reserved; always 0 */ +#define UART_FCR_RESERVED1 BIT(5, U) /* reserved; always 0 */ +#define UART_FCR_RTB0 BIT(6, U) /* receiver trigger bit #0 */ +#define UART_FCR_RTB1 BIT(7, U) /* receiver trigger bit #1 */ +#define UART_FCR_TRG_MASK (UART_FCR_RTB0 | UART_FCR_RTB1) + #define UART_FCR_TRG1 0x00 /* Rx FIFO trig lev 1 */ #define UART_FCR_TRG4 0x40 /* Rx FIFO trig lev 4 */ #define UART_FCR_TRG8 0x80 /* Rx FIFO trig lev 8 */ @@ -64,17 +79,17 @@ /* * Note: The FIFO trigger levels are chip specific: - * RX:76 = 00 01 10 11 TX:54 = 00 01 10 11 - * PC16550D: 1 4 8 14 xx xx xx xx - * TI16C550A: 1 4 8 14 xx xx xx xx - * TI16C550C: 1 4 8 14 xx xx xx xx - * ST16C550: 1 4 8 14 xx xx xx xx - * ST16C650: 8 16 24 28 16 8 24 30 PORT_16650V2 - * NS16C552: 1 4 8 14 xx xx xx xx - * ST16C654: 8 16 56 60 8 16 32 56 PORT_16654 - * TI16C750: 1 16 32 56 xx xx xx xx PORT_16750 - * TI16C752: 8 16 56 60 8 16 32 56 - * Tegra: 1 4 8 14 16 8 4 1 PORT_TEGRA + * RX:76 = 00 01 10 11 TX:54 = 00 01 10 11 + * PC16550D: 1 4 8 14 xx xx xx xx + * TI16C550A: 1 4 8 14 xx xx xx xx + * TI16C550C: 1 4 8 14 xx xx xx xx + * ST16C550: 1 4 8 14 xx xx xx xx + * ST16C650: 8 16 24 28 16 8 24 30 PORT_16650V2 + * NS16C552: 1 4 8 14 xx xx xx xx + * ST16C654: 8 16 56 60 8 16 32 56 PORT_16654 + * TI16C750: 1 16 32 56 xx xx xx xx PORT_16750 + * TI16C752: 8 16 56 60 8 16 32 56 + * Tegra: 1 4 8 14 16 8 4 1 PORT_TEGRA */ #define UART_FCR_R_TRIG_00 0x00 #define UART_FCR_R_TRIG_01 0x40 @@ -96,11 +111,32 @@ #define UART_LCR_CONF_MODE_B 0xBF /* Configuration mode B */ /* Modem Control Register */ -#define UART_MCR_DTR 0x01 /* Data Terminal Ready */ -#define UART_MCR_RTS 0x02 /* Request to Send */ -#define UART_MCR_OUT2 0x08 /* OUT2: interrupt mask */ -#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */ -#define UART_MCR_TCRTLR 0x40 /* Access TCR/TLR (TI16C752, EFR[4]=1) */ +#define UART_MCR_DTR BIT(0, U) /* Data Terminal Ready */ +#define UART_MCR_RTS BIT(1, U) /* Request to Send */ +#define UART_MCR_OUT1 BIT(2, U) /* OUT1: interrupt mask */ +#define UART_MCR_OUT2 BIT(3, U) /* OUT2: interrupt mask */ +#define UART_MCR_LOOP BIT(4, U) /* Enable loopback test mode */ +#define UART_MCR_RESERVED0 BIT(5, U) /* Reserved #0 */ +#define UART_MCR_RESERVED1 BIT(6, U) /* Reserved #1 */ +#define UART_MCR_TCRTLR BIT(6, U) /* Access TCR/TLR (TI16C752, EFR[4]=1) */ +#define UART_MCR_RESERVED2 BIT(7, U) /* Reserved #2 */ +#define UART_MCR_MASK \ + (UART_MCR_DTR | UART_MCR_RTS | \ + UART_MCR_OUT1 | UART_MCR_OUT2 | \ + UART_MCR_LOOP) + +/* Modem Status Register */ +#define UART_MSR_DCTS BIT(0, U) /* Change in CTS */ +#define UART_MSR_DDSR BIT(1, U) /* Change in DSR */ +#define UART_MSR_TERI BIT(2, U) /* Change in RI */ +#define UART_MSR_DDCD BIT(3, U) /* Change in CTS */ +#define UART_MSR_CTS BIT(4, U) +#define UART_MSR_DSR BIT(5, U) +#define UART_MSR_RI BIT(6, U) +#define UART_MSR_DCD BIT(7, U) +#define UART_MSR_SHIFT 4 +#define UART_MSR_DELTA \ + (UART_MSR_DCTS | UART_MSR_DDSR | UART_MSR_TERI | UART_MSR_DDCD) /* Line Status Register */ #define UART_LSR_DR 0x01 /* Data ready */ @@ -111,6 +147,7 @@ #define UART_LSR_THRE 0x20 /* Xmit hold reg empty */ #define UART_LSR_TEMT 0x40 /* Xmitter empty */ #define UART_LSR_ERR 0x80 /* Error */ +#define UART_LSR_MASK (UART_LSR_OE | UART_LSR_BI) /* These parity settings can be ORed directly into the LCR. */ #define UART_PARITY_NONE (0<<3) @@ -119,7 +156,10 @@ #define UART_PARITY_MARK (5<<3) #define UART_PARITY_SPACE (7<<3) -/* Frequency of external clock source. This definition assumes PC platform. */ +/* + * Frequency of external UART clock source. + * Same as IBM PC master input clock frequency. + */ #define UART_CLOCK_HZ 1843200 /* Bits in Exar specific UART_XR_EFR register */ From patchwork Tue Nov 26 23:22:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886421 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 53EB8D66B9D for ; Tue, 26 Nov 2024 23:32:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844262.1259862 (Exim 4.92) (envelope-from ) id 1tG52l-0007ds-AM; Tue, 26 Nov 2024 23:32:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844262.1259862; Tue, 26 Nov 2024 23:32:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG52l-0007dl-7I; Tue, 26 Nov 2024 23:32:31 +0000 Received: by outflank-mailman (input) for mailman id 844262; Tue, 26 Nov 2024 23:32:30 +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 1tG4sp-0000Ao-NJ for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:15 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3f8d82d9-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:05 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 77C2A5C5D98; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id A456AC4CEDC; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99391D66B94; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3f8d82d9-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNmOGQ4MmQ5LWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzI2LjI2NzQzMSwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=3rV9SQVk/30C/uR+xCoEerXgtGQ+GY3Qffyqy2vy1lU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=SGwS+nVz3R6LTSZsbbawwgPSwG4FaUqt9ctb2YeNyoXD85n0MiuI42uEE5b5dVvSf k14PHNnarznICc31SNfnu1/ana8c+YOCI3ioBTsoOn7EQ2PMwUTqE5ofrq3KAflVK+ ltoaNe9+TZth6HkLEnL7A9aMsz69Cp6/UJgIMJc4ugya+bnQssgYtNA9vHg69fdKU1 pXxzMWSAq8XhUw6nivMr5iJYAFZoF5DnPvgYqrex4jZsanPoBzBCmSulixr3U+9DTo qfQkjPs8HxlTaDGSUtvD3OoyVQw45FCwx1pl6hLlmOne6RZfaPJiayazr5ZCYihI54 ZGcrL2wHwi+3Q== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:21 -0800 Subject: [PATCH 31/36] x86/hvm: add HVM-specific Kconfig MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-31-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=5119; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=xth/C4RssnpHF5d1BFSmQSRG1c+DKNwkoUPEyi1j9F4=; b=SOUETyT5mODqIQZsTEddy3lHiDVCjngDNDkNnn32sXy/ZccYCCpVCwy+fm7nrRFJ0PM9nFBaT yp2ZeAxEGFSCAl6mI+CVbAxa55bdaoZsW+pk5yz0S5PBRuTMQtP31rr X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Add separate menu for configuring HVM build-time settings. That will help organizing HVM-specific options under a separate menu. Signed-off-by: Denis Mukhin --- xen/arch/x86/Kconfig | 66 +++--------------------------------------------- xen/arch/x86/hvm/Kconfig | 63 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 63 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 9cdd04721afa1916c7edd8fdf7d606858c73ce88..5afee9a9f9bafa3c760b06b8601fad4cad3b7191 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -107,42 +107,9 @@ config PV_LINEAR_PT If unsure, say Y. -config HVM - bool "HVM support" - depends on !PV_SHIM_EXCLUSIVE - default !PV_SHIM - select COMPAT - select IOREQ_SERVER - select MEM_ACCESS_ALWAYS_ON - help - Interfaces to support HVM domains. HVM domains require hardware - virtualisation extensions (e.g. Intel VT-x, AMD SVM), but can boot - guests which have no specific Xen knowledge. - - This option is needed if you want to run HVM or PVH domains. - - If unsure, say Y. - -config AMD_SVM - bool "AMD-V" if EXPERT - depends on HVM - default y - help - Enables virtual machine extensions on platforms that implement the - AMD Virtualization Technology (AMD-V). - If your system includes a processor with AMD-V support, say Y. - If in doubt, say Y. - -config INTEL_VMX - bool "Intel VT-x" if EXPERT - depends on HVM - default y - select ARCH_VCPU_IOREQ_COMPLETION - help - Enables virtual machine extensions on platforms that implement the - Intel Virtualization Technology (Intel VT-x). - If your system includes a processor with Intel VT-x support, say Y. - If in doubt, say Y. +menu "HVM Support" +source "arch/x86/hvm/Kconfig" +endmenu config XEN_SHSTK bool "Supervisor Shadow Stacks" @@ -201,25 +168,6 @@ config BIGMEM If unsure, say N. -config HVM_FEP - bool "HVM Forced Emulation Prefix support (UNSUPPORTED)" if UNSUPPORTED - default DEBUG - depends on HVM - help - - Compiles in a feature that allows HVM guest to arbitrarily - exercise the instruction emulator. - - This feature can only be enabled during boot time with - appropriate hypervisor command line option. Please read - hypervisor command line documentation before trying to use - this feature. - - This is strictly for testing purposes, and not appropriate - for use in production. - - If unsure, say N. - config TBOOT bool "Xen tboot support (UNSUPPORTED)" depends on INTEL && UNSUPPORTED @@ -348,14 +296,6 @@ config HYPERV_GUEST endif -config MEM_PAGING - bool "Xen memory paging support (UNSUPPORTED)" if UNSUPPORTED - depends on HVM - -config MEM_SHARING - bool "Xen memory sharing support (UNSUPPORTED)" if UNSUPPORTED - depends on HVM - config REQUIRE_NX bool "Require NX (No eXecute) support" help diff --git a/xen/arch/x86/hvm/Kconfig b/xen/arch/x86/hvm/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..361bb6572e633f3cf0fc972a3b391e8341c33361 --- /dev/null +++ b/xen/arch/x86/hvm/Kconfig @@ -0,0 +1,63 @@ +config HVM + bool "HVM support" + depends on !PV_SHIM_EXCLUSIVE + default !PV_SHIM + select COMPAT + select IOREQ_SERVER + select MEM_ACCESS_ALWAYS_ON + help + Interfaces to support HVM domains. HVM domains require hardware + virtualisation extensions (e.g. Intel VT-x, AMD SVM), but can boot + guests which have no specific Xen knowledge. + + This option is needed if you want to run HVM or PVH domains. + + If unsure, say Y. + +config AMD_SVM + bool "AMD-V" if EXPERT + depends on HVM + default y + help + Enables virtual machine extensions on platforms that implement the + AMD Virtualization Technology (AMD-V). + If your system includes a processor with AMD-V support, say Y. + If in doubt, say Y. + +config INTEL_VMX + bool "Intel VT-x" if EXPERT + depends on HVM + default y + select ARCH_VCPU_IOREQ_COMPLETION + help + Enables virtual machine extensions on platforms that implement the + Intel Virtualization Technology (Intel VT-x). + If your system includes a processor with Intel VT-x support, say Y. + If in doubt, say Y. + +config MEM_PAGING + bool "Xen memory paging support (UNSUPPORTED)" if UNSUPPORTED + depends on HVM + +config MEM_SHARING + bool "Xen memory sharing support (UNSUPPORTED)" if UNSUPPORTED + depends on HVM + +config HVM_FEP + bool "HVM Forced Emulation Prefix support (UNSUPPORTED)" if UNSUPPORTED + default DEBUG + depends on HVM + help + + Compiles in a feature that allows HVM guest to arbitrarily + exercise the instruction emulator. + + This feature can only be enabled during boot time with + appropriate hypervisor command line option. Please read + hypervisor command line documentation before trying to use + this feature. + + This is strictly for testing purposes, and not appropriate + for use in production. + + If unsure, say N. From patchwork Tue Nov 26 23:22:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886420 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 113E9D66B8E for ; Tue, 26 Nov 2024 23:32:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844257.1259851 (Exim 4.92) (envelope-from ) id 1tG52h-0007Lh-40; Tue, 26 Nov 2024 23:32:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844257.1259851; Tue, 26 Nov 2024 23:32:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG52h-0007La-15; Tue, 26 Nov 2024 23:32:27 +0000 Received: by outflank-mailman (input) for mailman id 844257; Tue, 26 Nov 2024 23:32:25 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sp-0000At-EC for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:15 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3f7da23a-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:05 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 874FF5C5BF6; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id B79D1C4CED0; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB5C4D66B9D; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3f7da23a-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNmN2RhMjNhLWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzI1LjM2NDIxLCJzZW5kZXIiOiJkZXZudWxsK2RtdWtoaW4uZm9yZC5jb21Aa2VybmVsLm9yZyIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=WDr/PwUo7NPVqK8vVCu/sN3ApYHaNVXqHBFVutTjEsg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=bkBhss7xSShP7C40xt01FhoPGq5cQEMVzQF4f2cY3ApbZPrWn7RayCwmhkqJRhEhj d6yKiwYR+jFN1eG47mBUGxoEWMABee3dAqxyeK0yi/0MD+1Km5Ebt9i3+JdaS5RJu3 aw2qgl3uxapuufS+U+6DSi0HA2ElrQecaX47KVibJZSY+TAx0NohANkA9ZxMHdM7z6 jRCwe5WFfl6Ug2eaHwfbVtOur+sA67kkVw//QOvpq7ZQSqCdIM9EWMr3HLEuZuVjlq XiZqAPJ26GgjnQ1c1Qyzc/jfAXYECd8GAN/u5bpwh465T4X/OnTnjuNlD67+T6SoGv d16BKhnKRlEpg== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:22 -0800 Subject: [PATCH 32/36] x86/hvm: add helpers for raising guest IRQs MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-32-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=1876; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=7BbjWtYddozrVOKtAkZI0QGQoqm6ofyyNdgxey+37YU=; b=ThSK3I1nGSONSUOI8mLhfE3bYgxEWNIeTGmqKGF4Wt0hASsaBfM9mvC9LGsCTP8xT/H1gbzAI 1Ak2zfg3dNeDPlENUq8QeW8vsLJWhYmLYPD53ex/4VN5v6wLCj5aagQ X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Added convenience wrappers for asserting/de-asserting interrupts in the hardware emulation code. That will be used for PCI-based NS8250 emulator. Signed-off-by: Denis Mukhin --- xen/arch/x86/hvm/irq.c | 24 ++++++++++++++++++++++++ xen/arch/x86/include/asm/hvm/irq.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c index 1eab44defca4c82ec35769617c66c380cc07d1b6..9e3a50d21dcf281c1015116094e47795c51ed5d0 100644 --- a/xen/arch/x86/hvm/irq.c +++ b/xen/arch/x86/hvm/irq.c @@ -242,6 +242,30 @@ void hvm_isa_irq_deassert( spin_unlock(&d->arch.hvm.irq_lock); } +void hvm_irq_raise(struct domain *d, unsigned int irq) +{ + if ( irq < NR_ISAIRQS ) + { + hvm_isa_irq_assert(d, irq, NULL); + } + else + { + hvm_gsi_assert(d, irq); + } +} + +void hvm_irq_lower(struct domain *d, unsigned int irq) +{ + if ( irq < NR_ISAIRQS ) + { + hvm_isa_irq_deassert(d, irq); + } + else + { + hvm_gsi_deassert(d, irq); + } +} + static void hvm_set_callback_irq_level(struct vcpu *v) { struct domain *d = v->domain; diff --git a/xen/arch/x86/include/asm/hvm/irq.h b/xen/arch/x86/include/asm/hvm/irq.h index 87e89993a44f48f366fa84e851688f383cb562d4..27bb9f64171c1b8aac2cf119699e60c91e727177 100644 --- a/xen/arch/x86/include/asm/hvm/irq.h +++ b/xen/arch/x86/include/asm/hvm/irq.h @@ -210,6 +210,9 @@ void hvm_maybe_deassert_evtchn_irq(void); void hvm_assert_evtchn_irq(struct vcpu *v); void hvm_set_callback_via(struct domain *d, uint64_t via); +void hvm_irq_raise(struct domain *d, unsigned int irq); +void hvm_irq_lower(struct domain *d, unsigned int irq); + struct pirq; bool hvm_domain_use_pirq(const struct domain *d, const struct pirq *pirq); From patchwork Tue Nov 26 23:22:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886430 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 01845D66B8E for ; Tue, 26 Nov 2024 23:39:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844368.1259942 (Exim 4.92) (envelope-from ) id 1tG599-0004uU-OH; Tue, 26 Nov 2024 23:39:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844368.1259942; Tue, 26 Nov 2024 23:39:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG599-0004uL-LH; Tue, 26 Nov 2024 23:39:07 +0000 Received: by outflank-mailman (input) for mailman id 844368; Tue, 26 Nov 2024 23:39:06 +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 1tG4sq-0000Ao-NR for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:16 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3f67f983-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:04 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A5F395C5C0F; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id D40ABC4CED9; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C85A3D66B8E; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3f67f983-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNmNjdmOTgzLWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzI1LjIwODEzNywic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663317; bh=/g2cVTZs4029JT6EU7g6V/nqyM2bmw6nhq5P6qlv7vQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Xj9/fqjVvD4Y9quSyk6lRCUKC2P3WFyqLi03uL/hekoIcEl17OSB4+21lmWmdeG+a VKB1gDlG8OaYZohhjLAkg7gVwkFXUHEVqEePm5XN6Mf1TfyVd2EWgp1zQKZiKWmEGa FU/pvTqro68ot6DZESlIRIGld1lC6Ae3twN7VUD5vNQqMI+dG2/hcHggJGoSAMgZpD NwZHT7Hg3RWB/dx9hVswU8IFYxiFwzZjL2gjbdBocryZvuV1FFXcguK6lRai7YPrvM hVZXyiYBhPbzR8fIdq3RzGwDOGenVSCdq3dEv7fYv6u9jdvkpPnu+0FSAfxDFcQ0t7 PWdwkUqt7/Wew== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:23 -0800 Subject: [PATCH 33/36] x86/hvm: introduce NS8250 UART emulator MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-33-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=33587; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=2mX8SbJHihzdfjvm3RXQXDQVhou/2iajvHj4uEds9xA=; b=gWhbfCPeAzsX9QeqHQr0sm6S0gDzWQDK+7IsDJLXHvr6Y6vWGGdoDUiCHJkFLmLXfwJcfAEtZ xXRIKBEVaV+BlPlJW1XpSYhxb/LvV860J78+QOI9wzt7FQIPCuxJmK1 X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Add initial in-hypervisor emulator for NS8250/NS16x50-compatible UARTs under CONFIG_HAS_VUART_NS8250. In parallel domain creation scenario (hyperlaunch), NS8520 emulator helps early guest OS bringup debugging, because it eliminates dependency on the external emulator being operational by the time domains are created. Also, there's no early console facility similar to vpl011 to support x86 guest OS bring up. By default, CONFIG_HAS_VUART_NS8250 enables emulatio of NS8250 at I/O port 0x3f8, IRQ#4 in guest OS. Limitations: - Only x86; - Only Linux guest tested so far; - Only legacy COM{1,2,3,4} resources, no customization; - Only Xen console as a backend, no inter-domain communication (similar to vpl011 on Arm); - Only 8-bit characters; - Baud rate is not emulated; - FIFO-less mode is not emulated properly; - RX FIFO interrupt moderation (FCR) is not emulated properly, TL16C750 has special FCR handling; - No integration w/ VM snapshotting (HVM_REGISTER_SAVE_RESTORE() and friends); - Assumes no ISA-device IRQ sharing; - MMIO-based UART is not supported. Signed-off-by: Denis Mukhin --- xen/arch/x86/hvm/Kconfig | 14 + xen/arch/x86/hvm/Makefile | 1 + xen/arch/x86/hvm/hvm.c | 7 + xen/arch/x86/hvm/vuart_ns8250.c | 1012 +++++++++++++++++++++++++++ xen/arch/x86/include/asm/hvm/domain.h | 5 + xen/arch/x86/include/asm/hvm/vuart_ns8250.h | 75 ++ 6 files changed, 1114 insertions(+) diff --git a/xen/arch/x86/hvm/Kconfig b/xen/arch/x86/hvm/Kconfig index 361bb6572e633f3cf0fc972a3b391e8341c33361..af6e698b8be0d82af94b00c0cfdaf9a2bc24b154 100644 --- a/xen/arch/x86/hvm/Kconfig +++ b/xen/arch/x86/hvm/Kconfig @@ -61,3 +61,17 @@ config HVM_FEP for use in production. If unsure, say N. + +config HAS_VUART_NS8250 + bool "NS8250-compatible UART Emulation" + depends on HVM && HAS_IOPORTS + default n + help + In-hypervisor NS8250/NS16x50 UART emulation. + + Only legacy PC I/O ports are emulated. + + This is strictly for testing purposes (early HVM guest console), and not + appropriate for use in production. + + If unsure, say N. diff --git a/xen/arch/x86/hvm/Makefile b/xen/arch/x86/hvm/Makefile index 4c1fa5c6c2bf75d336b39f343241bfced5b91b09..14761435e0694109f815da63289666c0f1cbf0ce 100644 --- a/xen/arch/x86/hvm/Makefile +++ b/xen/arch/x86/hvm/Makefile @@ -29,3 +29,4 @@ obj-y += vm_event.o obj-y += vmsi.o obj-y += vpic.o obj-y += vpt.o +obj-$(CONFIG_HAS_VUART_NS8250) += vuart_ns8250.o diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 493b699c708949b2109c26573a107565543f5d45..9449b5005e49c456069fdb256b0d0a8e168fc97f 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -679,6 +680,10 @@ int hvm_domain_initialise(struct domain *d, if ( rc != 0 ) goto fail1; + rc = domain_vuart_init(d); + if ( rc != 0 && rc != -ENODEV ) + goto out_vioapic_deinit; + stdvga_init(d); rtc_init(d); @@ -699,6 +704,8 @@ int hvm_domain_initialise(struct domain *d, return 0; fail2: + domain_vuart_free(d); + out_vioapic_deinit: vioapic_deinit(d); fail1: if ( is_hardware_domain(d) ) diff --git a/xen/arch/x86/hvm/vuart_ns8250.c b/xen/arch/x86/hvm/vuart_ns8250.c new file mode 100644 index 0000000000000000000000000000000000000000..ecf89ce7159d273597b652ab27f8a1c27ac41af0 --- /dev/null +++ b/xen/arch/x86/hvm/vuart_ns8250.c @@ -0,0 +1,1012 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * NS8250-compatible UART Emulator. + * + * Limitations: + * - Only x86; + * - Only Linux guest tested so far; + * - Only legacy COM{1,2,3,4} resources, no customization; + * - Only Xen console as a backend, no inter-domain communication (similar to + * vpl011 on Arm); + * - Only 8-bit characters; + * - Baud rate is not emulated; + * - FIFO-less mode is not emulated properly; + * - RX FIFO interrupt moderation (FCR) is not emulated properly, TL16C750 + * has special FCR handling; + * - No integration w/ VM snapshotting (HVM_REGISTER_SAVE_RESTORE() and + * friends); + * - Assumes no ISA-device IRQ sharing; + * - MMIO-based UART is not supported; + * - PCI UART is not supported. + * + * See: + * - Serial and UART Tutorial: + * https://download.freebsd.org/doc/en/articles/serial-uart/serial-uart_en.pdf + * - UART w/ 16 byte FIFO: + * https://www.ti.com/lit/ds/symlink/tl16c550c.pdf + * - UART w/ 64 byte FIFO: + * https://www.ti.com/lit/ds/symlink/tl16c750.pdf + */ + +#define pr_fmt(fmt) "ns8250: " fmt +#define pr_log_level hvm_ns8250_log_level + +/* Development debugging */ +#define NS8250_LOG_LEVEL 0 +#undef NS8250_DEBUG + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(NS8250_DEBUG) +#include +#endif +#include /* console_input_domid() */ +#include /* max_init_domid */ +#include +#include +#include +#include + +#if !defined(pr_fmt) +#define pr_fmt(fmt) fmt +#endif + +#if !defined(pr_log_level) +#define pr_log_level 0 +#endif + +#define pr_err(fmt, args...) \ + gprintk(KERN_ERR, pr_fmt(fmt), ## args) +#define pr_warn(fmt, args...) \ + if (pr_log_level) gprintk(KERN_WARNING, pr_fmt(fmt), ## args) +#define pr_info(fmt, args...) \ + if (pr_log_level) gprintk(KERN_INFO, pr_fmt(fmt), ## args) +#define pr_debug(fmt, args...) \ + if (pr_log_level) gprintk(KERN_DEBUG, pr_fmt(fmt), ## args) + +/* + * NS8250 emulator state machine logging (development only) + * FIXME: use similar to parse_guest_loglvl() + */ +static unsigned int __read_mostly hvm_ns8250_log_level = NS8250_LOG_LEVEL; +integer_param("hvm.ns8250.log_level", hvm_ns8250_log_level); + +/* + * Default emulated NS8250 resources. + * If not specified, COM1 (I/O port 0x3f8, IRQ#4) is emulated. + * FIXME: follow Linux'es console= syntax or re-use + * ns16550_parse_port_config(). + */ +static char __read_mostly hvm_ns8250_console[64]; +string_param("hvm.ns8250.console", hvm_ns8250_console); + +/* I/O access mask */ +static const uint32_t iosize_mask[] = { + [0] = 0X00000000ULL, + [1] = 0X000000FFULL, + [2] = 0X0000FFFFULL, + [4] = 0XFFFFFFFFULL, +}; + +/* + * Legacy IBM PC NS8250 resources. + * There are only 4 I/O port ranges, hardcoding all of them here. + */ +static const struct { + const char *name; + const struct resource *res; +} ns8250_x86_legacy_uarts[4] = { + [0] = { + .name = "com1", + .res = (const struct resource[]){ + { .type = IORESOURCE_IO, .addr = 0x3F8, .size = UART_MAX }, + { .type = IORESOURCE_IRQ, .addr = 4, .size = 1 }, + { .type = IORESOURCE_UNKNOWN }, + }, + }, + [1] = { + .name = "com2", + .res = (const struct resource[]){ + { .type = IORESOURCE_IO, .addr = 0x2F8, .size = UART_MAX }, + { .type = IORESOURCE_IRQ, .addr = 3, .size = 1 }, + { .type = IORESOURCE_UNKNOWN }, + }, + }, + [2] = { + .name = "com3", + .res = (const struct resource[]){ + { .type = IORESOURCE_IO, .addr = 0x3E8, .size = UART_MAX }, + { .type = IORESOURCE_IRQ, .addr = 4, .size = 1 }, + { .type = IORESOURCE_UNKNOWN }, + }, + }, + [3] = { + .name = "com4", + .res = (const struct resource[]){ + { .type = IORESOURCE_IO, .addr = 0x2E8, .size = UART_MAX }, + { .type = IORESOURCE_IRQ, .addr = 3, .size = 1 }, + { .type = IORESOURCE_UNKNOWN }, + }, + }, +}; + +static bool ns8250_fifo_rx_empty(struct vuart_ns8250 *vdev) +{ + struct xencons_interface *cons = vdev->cons; + + return cons->in_prod == cons->in_cons; +} + +static bool ns8250_fifo_rx_full(struct vuart_ns8250 *vdev) +{ + struct xencons_interface *cons = vdev->cons; + + return cons->in_prod - cons->in_cons == sizeof(cons->in); +} + +static void ns8250_fifo_rx_reset(struct vuart_ns8250 *vdev) +{ + struct xencons_interface *cons = vdev->cons; + + cons->in_cons = cons->in_prod; +} + +static int ns8250_fifo_rx_getchar(struct vuart_ns8250 *vdev) +{ + struct xencons_interface *cons = vdev->cons; + int rc = -1; + + if ( !ns8250_fifo_rx_empty(vdev) ) + { + rc = cons->in[MASK_XENCONS_IDX(cons->in_cons, cons->in)]; + cons->in_cons++; + } + + return rc; +} + +static int ns8250_fifo_rx_putchar(struct vuart_ns8250 *vdev, char c) +{ + struct xencons_interface *cons = vdev->cons; + int rc = 0; + + /* + * FIFO-less 8250/16450 UARTs: newly arrived word overwrites the contents + * of the THR. + */ + if ( ns8250_fifo_rx_full(vdev) ) + { + ns8250_fifo_rx_reset(vdev); + rc = -ENOSPC; + } + + cons->in[MASK_XENCONS_IDX(cons->in_prod, cons->in)] = c; + cons->in_prod++; + + return rc; +} + +/* + * Flush cached output to Xen console. + * Can be called from ns8250_exit(). + */ +static void ns8250_fifo_tx_reset(struct vuart_ns8250 *vdev) +{ + struct xencons_interface *cons = vdev->cons; + + if ( cons->out_prod == 0 ) + return; + + cons->out[cons->out_prod++] = '\0'; + + /* + * NB: do not show domain ID if the domain owning the virtual UART also + * owns Xen input console. + */ + if ( vdev->owner->domain_id == console_owner_domid() ) + printk_common("%s", cons->out); + else + guest_printk(vdev->owner, "%s", cons->out); + + cons->out_prod = 0; +} + +/* + * Send a character to Xen console. + */ +static void ns8250_fifo_tx_putchar(struct vuart_ns8250 *vdev, char ch) +{ + struct xencons_interface *cons = vdev->cons; + + if ( !isconsole(ch) ) + return; + + cons->out[cons->out_prod] = ch; + cons->out_prod++; + + if ( cons->out_prod == ARRAY_SIZE(cons->out) - 1 + || ch == '\n' || ch == '\0' ) + ns8250_fifo_tx_reset(vdev); +} + +static bool ns8250_iir_check_lsi(struct vuart_ns8250 *vdev) +{ + return !!( vdev->regs[UART_LSR] & UART_LSR_MASK ); +} + +static bool ns8250_iir_check_rda(struct vuart_ns8250 *vdev) +{ + return !ns8250_fifo_rx_empty(vdev); +} + +static bool ns8250_iir_check_thr(struct vuart_ns8250 *vdev) +{ + return !!( vdev->flags & NS8250_IRQ_THRE_PENDING ); +} + +static bool ns8250_iir_check_msi(struct vuart_ns8250 *vdev) +{ + return !!( vdev->regs[UART_MSR] & UART_MSR_DELTA ); +} + +/* + * Interrupt identity reasons by priority. + * NB: highest priority are at lower indexes. + */ +static const struct { + uint8_t ier_mask; + uint8_t iir_mask; + bool (*iir_check)(struct vuart_ns8250 *vdev); +} iir_by_prio[] = { + [0] = { UART_IER_ELSI, UART_IIR_LSI, ns8250_iir_check_lsi }, + [1] = { UART_IER_ERDAI, UART_IIR_RDA, ns8250_iir_check_rda }, + [2] = { UART_IER_ETHREI, UART_IIR_THR, ns8250_iir_check_thr }, + [3] = { UART_IER_EMSI, UART_IIR_MSI, ns8250_iir_check_msi }, +}; + +/* + * Define the interrupt identity reason. + * NB: NS8250 always reports high priority events first. + */ +static uint8_t ns8250_irq_reason(struct vuart_ns8250 *vdev) +{ + int i; + + ASSERT( spin_is_locked(&vdev->lock) ); + for ( i = 0; i < ARRAY_SIZE(iir_by_prio); i++ ) + { + if ( (vdev->regs[UART_IER] & iir_by_prio[i].ier_mask) + && iir_by_prio[i].iir_check(vdev) ) + return iir_by_prio[i].iir_mask; + } + + return UART_IIR_NOINT; +} + +/* + * Assert virtual NS8250 interrupt line. + */ +static void ns8250_irq_assert(struct vuart_ns8250 *vdev) +{ + uint8_t iir; + + iir = ns8250_irq_reason(vdev); + if (iir & UART_IIR_NOINT) + hvm_irq_lower(vdev->owner, vdev->irq); + else + hvm_irq_raise(vdev->owner, vdev->irq); + + pr_debug("IRQ#%d %x %s\n", vdev->irq, iir, + !!(iir & UART_IIR_NOINT) ? "lower" : "raise"); +} + +/* + * Emulate 8-bit write access to NS8250 register. + */ +static int ns8250_io_write8( + struct vuart_ns8250 *vdev, uint32_t reg, uint8_t *data) +{ + uint8_t msr_delta; + uint8_t msr; + uint8_t val; + int rc = 0; + + val = *data; + + switch ( reg ) + { + /* DLAB=0 */ + case UART_THR: + if ( vdev->regs[UART_MCR] & UART_MCR_LOOP ) + { + ns8250_fifo_rx_putchar(vdev, val); + vdev->regs[UART_LSR] |= UART_LSR_OE; + } + else + ns8250_fifo_tx_putchar(vdev, val); + + vdev->flags |= NS8250_IRQ_THRE_PENDING; + + break; + + case UART_IER: + if ( val & vdev->regs[UART_IER] & UART_IER_ETHREI ) + vdev->flags |= NS8250_IRQ_THRE_PENDING; + + vdev->regs[UART_IER] = val & UART_IER_MASK; + + break; + + case UART_FCR: /* WO */ + if ( val & UART_FCR_CLRX ) + ns8250_fifo_rx_reset(vdev); + + if ( val & UART_FCR_CLTX ) + ns8250_fifo_tx_reset(vdev); + + if ( !(val & UART_FCR_ENABLE) ) + val = 0; + + vdev->regs[UART_FCR] = val & (UART_FCR_ENABLE | + UART_FCR_DMA | + UART_FCR_TRG_MASK); + + break; + + case UART_LCR: + vdev->regs[UART_LCR] = val; + break; + + case UART_MCR: + msr = 0; + + if ( val & UART_MCR_LOOP ) + { + if ( val & UART_MCR_DTR ) + msr |= UART_MSR_DSR; + if ( val & UART_MCR_RTS ) + msr |= UART_MSR_CTS; + if ( val & UART_MCR_OUT1 ) + msr |= UART_MSR_RI; + if ( val & UART_MCR_OUT2 ) + msr |= UART_MSR_DCD; + } + else + msr |= UART_MSR_DCD | UART_MSR_DSR | UART_MSR_CTS; + + msr_delta = ((msr ^ vdev->regs[UART_MSR]) >> UART_MSR_SHIFT) + & (UART_MSR_DCTS | UART_MSR_DDSR | UART_MSR_DDCD); + if ( msr & vdev->regs[UART_MSR] & UART_MSR_RI ) + msr_delta |= UART_MSR_TERI; + + vdev->regs[UART_MCR] = val & UART_MCR_MASK; + vdev->regs[UART_MSR] = msr | msr_delta; + + break; + + case UART_LSR: /* RO */ + case UART_MSR: /* RO */ + rc = -EINVAL; + break; + + /* + * NB: Firmware like OVMF rely on SCR presence to initialize the ns8250 + * driver. + */ + case UART_SCR: + vdev->regs[UART_SCR] = val; + break; + + /* DLAB=1 */ + case UART_MAX + UART_DLL: + vdev->dl = (vdev->dl & 0xFF00U) | val; + break; + + case UART_MAX + UART_DLM: + vdev->dl = (val << 8) | (vdev->dl & 0x00FFU); + break; + + default: + rc = -EINVAL; + break; + } + + return rc; +} + +/* + * Emulate 16-bit write access to NS8250 register. + * NB: some guest OSes use outw() to access UART_DLL. + */ +static int ns8250_io_write16( + struct vuart_ns8250 *vdev, uint32_t reg, uint16_t *data) +{ + int rc; + + switch ( reg ) + { + case UART_MAX + UART_DLL: + vdev->dl = *data; + rc = 0; + break; + + default: + rc = -EINVAL; + break; + } + + return rc; +} + +/* + * Emulate write access to NS8250 register. + */ +static int ns8250_io_write( + struct vuart_ns8250 *vdev, uint8_t reg, uint32_t size, uint32_t *data) +{ + int rc = -EINVAL; + + switch ( size ) + { + case 1: + rc = ns8250_io_write8(vdev, reg, (uint8_t *)data); + break; + + case 2: + rc = ns8250_io_write16(vdev, reg, (uint16_t *)data); + break; + + default: + break; + } + + ns8250_irq_assert(vdev); + + return rc; +} + +/* + * Emulate 8-bit read access to NS8250 register. + */ +static int ns8250_io_read8( + struct vuart_ns8250 *vdev, uint32_t reg, uint8_t *data) +{ + int rc = 0; + uint8_t val; + + switch ( reg ) + { + /* DLAB=0 */ + case UART_RBR: + val = (uint8_t)ns8250_fifo_rx_getchar(vdev); + /* NB: do not forget to clear overrun condition */ + vdev->regs[UART_LSR] &= ~UART_LSR_OE; + break; + + case UART_IER: /* RO */ + val = vdev->regs[UART_IER]; + break; + + case UART_IIR: + val = ns8250_irq_reason(vdev); + if ( val & UART_IIR_THR ) + vdev->flags &= ~NS8250_IRQ_THRE_PENDING; + + if ( vdev->regs[UART_FCR] & UART_FCR_ENABLE ) + val |= UART_IIR_FE_MASK; + + break; + + case UART_LCR: + val = vdev->regs[UART_LCR]; + break; + + case UART_MCR: + val = vdev->regs[UART_MCR]; + break; + + case UART_LSR: + val = vdev->regs[UART_LSR] | UART_LSR_THRE | UART_LSR_TEMT; + if ( ns8250_fifo_rx_empty(vdev) ) + val &= ~UART_LSR_DR; + else + val |= UART_LSR_DR; + + vdev->regs[UART_LSR] = val & ~UART_LSR_MASK; + + break; + + case UART_MSR: + val = vdev->regs[UART_MSR]; + vdev->regs[UART_MSR] &= ~UART_MSR_DELTA; + break; + + case UART_SCR: + val = vdev->regs[UART_SCR]; + break; + + /* DLAB=1 */ + case UART_MAX + UART_DLL: + val = vdev->dl & 0xFFU; + break; + + case UART_MAX + UART_DLM: + val = vdev->dl >> 8; + break; + + default: + val = (uint8_t)iosize_mask[1]; + rc = -EINVAL; + break; + } + + *data = val; + + return rc; +} + +/* + * Emulate 16-bit read access to NS8250 register. + */ +static int ns8250_io_read16( + struct vuart_ns8250 *vdev, uint32_t reg, uint16_t *data) +{ + uint16_t val; + int rc; + + switch ( reg ) + { + case UART_MAX + UART_DLL: + val = vdev->dl; + rc = 0; + break; + + default: + val = (uint16_t)iosize_mask[2]; + rc = -EINVAL; + break; + } + + *data = val; + + return rc; +} + +/* + * Emulate read access to NS8250 register. + */ +static int ns8250_io_read( + struct vuart_ns8250 *vdev, uint8_t reg, uint32_t size, uint32_t *data) +{ + int rc; + + switch ( size ) + { + case 1: + rc = ns8250_io_read8(vdev, reg, (uint8_t *)data); + break; + + case 2: + rc = ns8250_io_read16(vdev, reg, (uint16_t *)data); + break; + + default: + *data = iosize_mask[size]; + rc = -EINVAL; + break; + } + + ns8250_irq_assert(vdev); + + return rc; +} + +static const char *ns8250_regname( + const struct vuart_ns8250 *vdev, uint32_t reg, int dir) +{ + static const char *reg_names[UART_MAX + 2][2] = { + /* register W R */ + [UART_RBR] = { "THR", "RBR" }, + [UART_IER] = { "IER", "IER" }, + [UART_IIR] = { "FCR", "IIR" }, + [UART_LCR] = { "LCR", "LCR" }, + [UART_MCR] = { "MCR", "MCR" }, + [UART_LSR] = { "LSR", "LSR" }, + [UART_MSR] = { "MSR", "MSR" }, + [UART_SCR] = { "SCR", "SCR" }, + [UART_MAX + UART_DLL] = { "DLL", "DLL" }, + [UART_MAX + UART_DLM] = { "DLM", "DLM" }, + }; + + return reg_names[reg][dir]; +} + +static void ns8250_dump(struct vuart_ns8250 *vdev) +{ +#if defined(NS8250_DEBUG) + uint8_t val; + + printk("I/O port %02"PRIx64" IRQ %d flags %"PRIx32" owner %d\n", + vdev->io_addr, vdev->irq, + vdev->flags, vdev->owner->domain_id); + + printk("RX size %ld in_prod %d in_cons %d used %d\n", + sizeof(vdev->cons->in), + vdev->cons->in_prod, vdev->cons->in_cons, + vdev->cons->in_prod - vdev->cons->in_cons); + + printk("TX size %ld out_prod %d out_cons %d used %d\n", + sizeof(vdev->cons->out), + vdev->cons->out_prod, vdev->cons->out_cons, + vdev->cons->out_prod - vdev->cons->out_cons); + + printk("%02x RBR [ %c ] THR [ %c ] DLL %02x DLM %02x\n", + UART_RBR, + vdev->cons->in[MASK_XENCONS_IDX(vdev->cons->in_prod, vdev->cons)], + vdev->cons->out[MASK_XENCONS_IDX(vdev->cons->out_prod, vdev->cons)], + vdev->dl & 0xFFU, vdev->dl >> 8); + + printk("%02"PRIx8" IER %02"PRIx8"\n", UART_IER, vdev->regs[UART_IER]); + + val = (vdev->regs[UART_FCR] & UART_FCR_ENABLE) ? UART_IIR_FE_MASK : 0; + val |= ns8250_irq_reason(vdev); + printk("%02"PRIx8" FCR %02"PRIx8" IIR %02"PRIx8"\n", + UART_FCR, vdev->regs[UART_FCR], val); + + printk("%02"PRIx8" LCR %02"PRIx8"\n", UART_LCR, vdev->regs[UART_LCR]); + printk("%02"PRIx8" MCR %02"PRIx8"\n", UART_MCR, vdev->regs[UART_MCR]); + printk("%02"PRIx8" LSR %02"PRIx8"\n", UART_LSR, vdev->regs[UART_LSR]); + printk("%02"PRIx8" MSR %02"PRIx8"\n", UART_MSR, vdev->regs[UART_MSR]); +#endif +} + +/* + * Emulate I/O access to NS8250 register. + */ +static int cf_check ns8250_io_handle( + int dir, unsigned int addr, unsigned int size, uint32_t *data) +{ +#define op(dir) (((dir) == IOREQ_WRITE) ? 'W' : 'R') + struct domain *d = rcu_lock_current_domain(); + struct vuart_ns8250 *vdev = &d->arch.hvm.vuart; + uint32_t offset, reg; + int rc; + + spin_lock(&vdev->lock); + + BUG_ON( vdev->owner != d ); + + if ( !(vdev->flags & NS8250_READY) ) + { + pr_err("%c io 0x%04x %d 0x%08"PRIx32": propagate to external I/O emulator\n", + op(dir), addr, size, *data); + rc = X86EMUL_UNHANDLEABLE; + goto out; + } + + reg = addr - vdev->io_addr; + BUG_ON( reg >= UART_MAX ); + /* NB: all NS8250 registers are naturally aligned */ + if ( reg % size != 0 ) + { + pr_err("%c 0x%04x %d 0x%08"PRIx32": unaligned access\n", + op(dir), addr, size, *data & iosize_mask[size]); + rc = X86EMUL_OKAY; + goto out; + } + + /* Redirect access to divisor latch registers */ + if ( !!(vdev->regs[UART_LCR] & UART_LCR_DLAB) + && (reg == UART_DLL || reg == UART_DLM) ) + offset = UART_MAX + reg; + else + offset = reg; + + if ( dir == IOREQ_WRITE ) + { + pr_debug("%c 0x%04x %d 0x%08"PRIx32" %s[0x%02"PRIx32"]\n", + op(dir), addr, size, + *data & iosize_mask[size], + ns8250_regname(vdev, offset, dir), reg); + rc = ns8250_io_write(vdev, offset, size, data); + } + else + { + rc = ns8250_io_read(vdev, offset, size, data); + pr_debug("%c 0x%04x %d 0x%08"PRIx32" %s[0x%02"PRIx32"]\n", + op(dir), addr, size, + *data & iosize_mask[size], + ns8250_regname(vdev, offset, dir), reg); + } + if ( rc ) + pr_err("%c 0x%04x %d 0x%08"PRIx32": unsupported access\n", + op(dir), addr, size, *data & iosize_mask[size]); + rc = X86EMUL_OKAY; + +out: + ns8250_dump(vdev); + spin_unlock(&vdev->lock); + + return rc; +#undef op +} + +/* + * Parse virtual NS8250 configuration. + * hvm.ns8250.console=[com1|com2|com3|com4] + */ +static const struct resource *ns8250_parse(void) +{ + int i; + + for ( i = 0; i < ARRAY_SIZE(ns8250_x86_legacy_uarts); i++ ) + if ( !strcasecmp(hvm_ns8250_console, ns8250_x86_legacy_uarts[i].name) ) + return ns8250_x86_legacy_uarts[i].res; + + return ns8250_x86_legacy_uarts[0].res; +} + +/* + * Claim virtual NS8250 resources to domain. + */ +static int ns8250_claim( + struct vuart_ns8250 *vdev, const struct resource *r, struct domain *d) +{ + unsigned long size; + unsigned long start; + unsigned long end; + + vdev->irq = NO_IRQ; + vdev->io_addr = IORESOURCE_UNKNOWN; + vdev->io_size = IORESOURCE_UNKNOWN; + + foreach_resource(r) + { + if ( r->type & IORESOURCE_IO ) + { + size = r->size; + start = r->addr; + end = r->addr + r->size - 1; + + if ( !ioports_access_permitted(d, start, end) ) + ioports_permit_access(d, start, end); + + register_portio_handler(d, start, size, ns8250_io_handle); + + /* Used to assert I/O port handler */ + vdev->io_addr = start; + vdev->io_size = size; + } + else if ( r->type & IORESOURCE_IRQ ) + /* "Claim" virtual IRQ; assumes no ISA-device IRQ sharing */ + vdev->irq = r->addr; + else + return -EINVAL; + } + + if ( vdev->irq == NO_IRQ + || vdev->io_addr == IORESOURCE_UNKNOWN + || vdev->io_size == IORESOURCE_UNKNOWN ) + return -ENODEV; + + return 0; +} + +/* + * Unclaim virtual NS8250 resources. + */ +static void ns8250_unclaim(struct vuart_ns8250 *vdev, struct domain *d) +{ + unsigned long size = vdev->io_size; + unsigned long start = vdev->io_addr; + unsigned long end = start + size - 1; + + if ( ioports_access_permitted(d, start, end) ) + ioports_deny_access(d, start, size); +} + +#if defined(NS8250_DEBUG) +static struct domain *rcu_find_first_domain_with_vuart(void) +{ + struct domain *d = NULL; + domid_t domid; + + for ( domid = 0; domid < max_init_domid + 1; domid++ ) + { + d = rcu_lock_domain_by_id(domid); + if ( d == NULL ) + continue; + + if ( domain_has_vuart(d) ) + break; + + rcu_unlock_domain(d); + } + + return d; +} + +static void cf_check ns8250_keyhandler_show(unsigned char key) +{ + struct vuart_ns8250 *vdev; + struct domain *d; + + d = rcu_find_first_domain_with_vuart(); + if ( d == NULL ) + return; + + printk("'%c' pressed -> dumping virtual NS8250 state (d%d)\n", + key, d->domain_id); + + vdev = &d->arch.hvm.vuart; + spin_lock(&vdev->lock); + ns8250_dump(vdev); + spin_unlock(&vdev->lock); + + rcu_unlock_domain(d); +} + +static void cf_check ns8250_keyhandler_irq(unsigned char key) +{ + struct vuart_ns8250 *vdev; + struct domain *d; + + d = rcu_find_first_domain_with_vuart(); + if ( d == NULL ) + return; + + printk("'%c' pressed -> triggering IRQ on virtual NS8250 (d%d)\n", + key, d->domain_id); + + vdev = &d->arch.hvm.vuart; + spin_lock(&vdev->lock); + ns8250_irq_assert(vdev); + spin_unlock(&vdev->lock); + + rcu_unlock_domain(d); +} +#endif /* #if defined(NS8250_DEBUG) */ + +static int ns8250_init(struct domain *d) +{ + struct vuart_ns8250 *vdev = &d->arch.hvm.vuart; + struct xencons_interface *cons; + const struct resource *r; + int rc; + + memset(vdev, 0, sizeof(*vdev)); + + r = ns8250_parse(); + if ( r == NULL ) + return -ENODEV; + + cons = kzalloc(sizeof(*vdev->cons), 0); + if ( cons == NULL ) + { + rc = -ENOMEM; + goto out; + } + + spin_lock_init(&vdev->lock); + + rc = ns8250_claim(vdev, r, d); + if ( rc ) + goto out; + + /* Report 115200 baud rate */ + vdev->dl = (UART_CLOCK_HZ / 115200) >> 4; + + vdev->owner = d; + vdev->cons = cons; + vdev->flags = NS8250_READY | NS8250_IRQ_THRE_PENDING; + + hvm_irq_lower(d, vdev->irq); + +#if defined(NS8250_DEBUG) + register_keyhandler('1', ns8250_keyhandler_show, + "dump virtual NS8250 state", 0); + register_keyhandler('2', ns8250_keyhandler_irq, + "trigger IRQ from virtual NS8250", 0); +#endif /* #if defined(NS8250_DEBUG) */ + + return 0; + +out: + kfree(cons); + + return rc; +} + +static void ns8250_exit(struct domain *d) +{ + struct vuart_ns8250 *vdev = &d->arch.hvm.vuart; + + if ( !(vdev->flags & NS8250_READY) ) + return; + + spin_lock(&vdev->lock); + + ns8250_unclaim(vdev, d); + + ns8250_fifo_tx_reset(vdev); + kfree(vdev->cons); + + vdev->owner = NULL; + vdev->cons = NULL; + vdev->flags = 0; + + spin_unlock(&vdev->lock); +} + +int vuart_putchar(struct vuart_ns8250 *vdev, char ch) +{ + int rc; + + spin_lock(&vdev->lock); + + if ( !(vdev->flags & NS8250_READY) ) + { + rc = -ENODEV; + goto out; + } + + /* Echo the user input on the console */ + printk("%c", ch); + + /* + * Device is in loopback mode; do nothing. + */ + if ( vdev->regs[UART_MCR] & UART_MCR_LOOP ) + { + rc = -EBUSY; + goto out; + } + + rc = ns8250_fifo_rx_putchar(vdev, ch); + if ( rc == -ENOSPC ) + vdev->regs[UART_LSR] |= UART_LSR_OE | UART_LSR_DR; + else + /* NB: UART_LSR_DR is also set when UART_LSR is accessed. */ + vdev->regs[UART_LSR] |= UART_LSR_DR; + + /* FIXME: check FCR when to fire an interrupt */ + ns8250_irq_assert(vdev); + +out: + ns8250_dump(vdev); + spin_unlock(&vdev->lock); + + return rc; +} + +int domain_vuart_init(struct domain *d) +{ + int rc = -ENODEV; + + if ( domain_has_vuart(d) ) + rc = ns8250_init(d); + + return rc; +} + +void domain_vuart_free(struct domain *d) +{ + if ( domain_has_vuart(d) ) + ns8250_exit(d); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/include/asm/hvm/domain.h b/xen/arch/x86/include/asm/hvm/domain.h index 333501d5f2ac01676646b9b277b551f06d43c3a5..d4ce25896259fc9763477e88d56bacbe4f78af5b 100644 --- a/xen/arch/x86/include/asm/hvm/domain.h +++ b/xen/arch/x86/include/asm/hvm/domain.h @@ -16,6 +16,7 @@ #include #include #include +#include #ifdef CONFIG_MEM_SHARING struct mem_sharing_domain @@ -73,6 +74,10 @@ struct hvm_domain { struct hvm_vioapic **vioapic; unsigned int nr_vioapics; +#if defined(CONFIG_HAS_VUART_NS8250) + struct vuart_ns8250 vuart; +#endif + /* * hvm_hw_pmtimer is a publicly-visible name. We will defer renaming * it to the more appropriate hvm_hw_acpi until the expected diff --git a/xen/arch/x86/include/asm/hvm/vuart_ns8250.h b/xen/arch/x86/include/asm/hvm/vuart_ns8250.h new file mode 100644 index 0000000000000000000000000000000000000000..27d9458c24dfb4c5decea51fefcb73650cc863c6 --- /dev/null +++ b/xen/arch/x86/include/asm/hvm/vuart_ns8250.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * NS8250-compatible UART Emulator. + */ +#if !defined(HVM__VUART_NS8250_H) +#define HVM__VUART_NS8250_H + +#include +#include +#include /* xencons_interface */ + +/* + * NS8250 emulator operational flags. + */ +enum { + /* Emulator is ready */ + NS8250_READY = BIT(0, U), + /* Trigger re-delivery of THRE interrupt */ + NS8250_IRQ_THRE_PENDING = BIT(1, U), +}; + +/* + * Virtual NS8250 device state. + */ +struct vuart_ns8250 { + uint16_t dl; /* Divisor Latch */ + uint8_t regs[UART_MAX]; /* Registers */ + uint32_t flags; /* Virtual device flags */ + uint64_t io_addr; /* Guest I/O region base address */ + uint64_t io_size; /* Guest I/O region size */ + int irq; /* Guest IRQ# */ + struct xencons_interface *cons; /* Emulated RX/TX FIFOs */ + struct domain *owner; /* Owner domain */ + spinlock_t lock; /* Protection */ +}; + +#if defined(CONFIG_HAS_VUART_NS8250) + +int vuart_putchar(struct vuart_ns8250 *vdev, char ch); + +/* + * Match the names w/ arch/arm/vuart.h + * FIXME: move to common vuart.h + */ +int domain_vuart_init(struct domain *d); +void domain_vuart_free(struct domain *d); + +#else + +static inline int vuart_putchar(struct vuart_ns8250 *vdev, char ch) +{ + return -1; +} + +static inline int domain_vuart_init(struct domain *d) +{ + return 0; +} + +static inline void domain_vuart_free(struct domain *d) +{ +} + +#endif /* #if defined(CONFIG_HAS_VUART_NS8250) */ + +#endif /* #if !defined(HVM__VUART_NS8250_H) */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ From patchwork Tue Nov 26 23:22:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886395 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 CC188D66B86 for ; Tue, 26 Nov 2024 23:23:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844074.1259729 (Exim 4.92) (envelope-from ) id 1tG4tv-0003Rx-Uw; Tue, 26 Nov 2024 23:23:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844074.1259729; Tue, 26 Nov 2024 23:23:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tv-0003P1-3y; Tue, 26 Nov 2024 23:23:23 +0000 Received: by outflank-mailman (input) for mailman id 844074; Tue, 26 Nov 2024 23:22:09 +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 1tG4sj-0000Ao-MS for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:09 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3f7c2e3a-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:05 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BF25A5C5DA0; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id EE3DBC4CED7; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E276FD66B94; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) 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: 3f7c2e3a-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjI2MDQ6MTM4MDo0NjQxOmM1MDA6OjEiLCJoZWxvIjoiZGZ3LnNvdXJjZS5rZXJuZWwub3JnIn0= X-Custom-Transaction: eyJpZCI6IjNmN2MyZTNhLWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzI2LjEzODY4OCwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663318; bh=YfYCHh0nVVhyUMXcW2poOpCSgAUn/qfDmEJPr0RM4oY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YTyhPPJYnhy04bo8F7f8koIfZXZgjBfIB05ZmxEwq9aFZ7xlvRaphAT9vt3DANNzx ZQYH1TIFSRdNWl1Nb6i8Iie7rF7zqHQnWnCecWY/crT26czdMnE4zcWsl74guEwAcc ZxVqp0v3u8x38Jt3QCfYCEDjL8gp5rqYK39ujPilLoK42nz9zpvgeA1g1Q6vFJy0mD oUCQCL3czhCJNZBX+CQJs0U5du34E7pDX8CBkXo+/UR76HCQ603mi8YuYS/tZ+6pB0 j7lGnUyR49OEM1jSik6LQZpLPhi4vESjyNpZlPjeoWP4OCz1LsnjuHfe+WvfSX7Oeo lu9/mbfi+bjyA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:24 -0800 Subject: [PATCH 34/36] x86/domain: implement domain_has_vuart() MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-34-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=7401; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=tfiJLSOur1vSXiemSyjr8enIFIEF26fIRGrdEEwbY18=; b=/N/5CYqKcD6seLR4F2jKfzySETrT8B+vZVURCXKxLPT1koQC+NDS1ls5JLia0xD7s5pm/MeaL subrLZMun+cCOrcoQyaLAF7u6vvZSXh4d8Ja0x+Pt9dNifh/cn4ke3C X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Add new emulation flag for virtual UART on x86 and plumb it through the stack. This change enables NS8250 emulator initialization. Signed-off-by: Denis Mukhin --- tools/libs/light/libxl_x86.c | 6 +++++- tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + tools/python/xen/lowlevel/xc/xc.c | 4 +--- xen/arch/x86/domain.c | 8 +++++--- xen/arch/x86/include/asm/domain.h | 7 ++++--- xen/include/public/arch-x86/xen.h | 14 +++++++++++++- 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c index a3164a3077fec7e1b81a34074894dc646954a49a..de5f05e18cb0671bb031b101b9a7159eb0fe0178 100644 --- a/tools/libs/light/libxl_x86.c +++ b/tools/libs/light/libxl_x86.c @@ -8,7 +8,11 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, { switch(d_config->c_info.type) { case LIBXL_DOMAIN_TYPE_HVM: - config->arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI); + config->arch.emulation_flags = XEN_X86_EMU_ALL; + config->arch.emulation_flags &= ~XEN_X86_EMU_VPCI; + /* Virtual UART is selected at Xen build time */ + config->arch.emulation_flags &= ~XEN_X86_EMU_VUART; + if (!libxl_defbool_val(d_config->b_info.u.hvm.pirq)) config->arch.emulation_flags &= ~XEN_X86_EMU_USE_PIRQ; break; diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index 2690f9a92316b812ad3d3ff0e1c36823070adb4a..647239b3e55e88b00eb8e9773a5267894cbbae54 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -47,6 +47,7 @@ type x86_arch_emulation_flags = | X86_EMU_PIT | X86_EMU_USE_PIRQ | X86_EMU_VPCI + | X86_EMU_VUART type x86_arch_misc_flags = | X86_MSR_RELAXED diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli index febbe1f6ae3f10c5abe45eaa3c06a8a67d9ba268..4f5f64c786e83e8a0c3dd3cdb0460f7095de4a62 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -41,6 +41,7 @@ type x86_arch_emulation_flags = | X86_EMU_PIT | X86_EMU_USE_PIRQ | X86_EMU_VPCI + | X86_EMU_VUART type x86_arch_misc_flags = | X86_MSR_RELAXED diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 9feb12ae2b16e48cb5d0c3c45044ae226f152f2d..e54308956efc7061d58d2166ec9a95bc1dcd1781 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -159,9 +159,7 @@ static PyObject *pyxc_domain_create(XcObject *self, #if defined (__i386) || defined(__x86_64__) if ( config.flags & XEN_DOMCTL_CDF_hvm ) - config.arch.emulation_flags = XEN_X86_EMU_ALL & - ~(XEN_X86_EMU_VPCI | - XEN_X86_EMU_USE_PIRQ); + config.arch.emulation_flags = XEN_X86_EMU_HVM_ALLOWABLE; #elif defined (__arm__) || defined(__aarch64__) config.arch.gic_version = XEN_DOMCTL_CONFIG_GIC_NATIVE; #else diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index c88d422a64544531c1e1058fa484364bb4277d1e..439da7adc92a3a8eb481075bf834da5f9670dd54 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -752,10 +752,10 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) if ( is_hardware_domain(d) && emflags != (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC) ) return false; + + emflags &= ~X86_EMU_VUART; if ( !is_hardware_domain(d) && - /* HVM PIRQ feature is user-selectable. */ - (emflags & ~X86_EMU_USE_PIRQ) != - (X86_EMU_ALL & ~(X86_EMU_VPCI | X86_EMU_USE_PIRQ)) && + xen_emflags_allowable(emflags) != XEN_X86_EMU_HVM_ALLOWABLE && emflags != X86_EMU_LAPIC ) return false; } @@ -806,6 +806,8 @@ int arch_domain_create(struct domain *d, emflags = config->arch.emulation_flags; + if ( IS_ENABLED(CONFIG_HAS_VUART_NS8250) && is_hvm_domain(d) ) + emflags |= XEN_X86_EMU_VUART; if ( is_hardware_domain(d) && is_pv_domain(d) ) emflags |= XEN_X86_EMU_PIT; diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index c1d0d1f47324e8cc678a4c76c43f86820a89e7b3..dacea6e1aad46e9f8710b2202bb81203c5e92807 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -484,7 +484,8 @@ struct arch_domain #define X86_EMU_VPCI 0 #endif -#define X86_EMU_PIT XEN_X86_EMU_PIT +#define X86_EMU_PIT XEN_X86_EMU_PIT +#define X86_EMU_VUART XEN_X86_EMU_VUART /* This must match XEN_X86_EMU_ALL in xen.h */ #define X86_EMU_ALL (X86_EMU_LAPIC | X86_EMU_HPET | \ @@ -492,7 +493,7 @@ struct arch_domain X86_EMU_IOAPIC | X86_EMU_PIC | \ X86_EMU_VGA | X86_EMU_IOMMU | \ X86_EMU_PIT | X86_EMU_USE_PIRQ | \ - X86_EMU_VPCI) + X86_EMU_VPCI | X86_EMU_VUART) #define has_vlapic(d) (!!((d)->arch.emulation_flags & X86_EMU_LAPIC)) #define has_vhpet(d) (!!((d)->arch.emulation_flags & X86_EMU_HPET)) @@ -507,7 +508,7 @@ struct arch_domain #define has_vpci(d) (!!((d)->arch.emulation_flags & X86_EMU_VPCI)) /* NB: same symbol as in Arm port */ -#define domain_has_vuart(d) false +#define domain_has_vuart(d) (!!((d)->arch.emulation_flags & X86_EMU_VUART)) #define gdt_ldt_pt_idx(v) \ ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT)) diff --git a/xen/include/public/arch-x86/xen.h b/xen/include/public/arch-x86/xen.h index fc2487986642a7694578ab9d2f5f16d09761bff8..e7922e3f9ddc1742a464d228807279839df31e52 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -283,13 +283,25 @@ struct xen_arch_domainconfig { #define XEN_X86_EMU_USE_PIRQ (1U<<_XEN_X86_EMU_USE_PIRQ) #define _XEN_X86_EMU_VPCI 10 #define XEN_X86_EMU_VPCI (1U<<_XEN_X86_EMU_VPCI) +#define _XEN_X86_EMU_VUART 11 +#define XEN_X86_EMU_VUART (1U<<_XEN_X86_EMU_VUART) #define XEN_X86_EMU_ALL (XEN_X86_EMU_LAPIC | XEN_X86_EMU_HPET | \ XEN_X86_EMU_PM | XEN_X86_EMU_RTC | \ XEN_X86_EMU_IOAPIC | XEN_X86_EMU_PIC | \ XEN_X86_EMU_VGA | XEN_X86_EMU_IOMMU | \ XEN_X86_EMU_PIT | XEN_X86_EMU_USE_PIRQ |\ - XEN_X86_EMU_VPCI) + XEN_X86_EMU_VPCI | XEN_X86_EMU_VUART) + +/* HVM PIRQ feature is user-selectable (libxl). */ +#define XEN_X86_EMU_HVM_SELECTABLE (XEN_X86_EMU_VPCI | \ + XEN_X86_EMU_USE_PIRQ | \ + XEN_X86_EMU_VUART) + +#define xen_emflags_allowable(x) ((x) & ~XEN_X86_EMU_HVM_SELECTABLE) + +#define XEN_X86_EMU_HVM_ALLOWABLE xen_emflags_allowable(XEN_X86_EMU_ALL) + uint32_t emulation_flags; /* From patchwork Tue Nov 26 23:22:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886427 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 78381D66B8E for ; Tue, 26 Nov 2024 23:38:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844341.1259913 (Exim 4.92) (envelope-from ) id 1tG589-0003Bb-TP; Tue, 26 Nov 2024 23:38:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844341.1259913; Tue, 26 Nov 2024 23:38:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG589-0003BU-PF; Tue, 26 Nov 2024 23:38:05 +0000 Received: by outflank-mailman (input) for mailman id 844341; Tue, 26 Nov 2024 23:38:04 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4so-0000At-E6 for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:14 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3f621fc5-ac4d-11ef-99a3-01e77a169b0f; Wed, 27 Nov 2024 00:22:05 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DD2565C5DA1; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 12E37C4CED8; Tue, 26 Nov 2024 23:21:58 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08948D66B9A; Tue, 26 Nov 2024 23:21:58 +0000 (UTC) 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: 3f621fc5-ac4d-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNmNjIxZmM1LWFjNGQtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyNjYzMzI1Ljk4NTY5OSwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663318; bh=rm9Rfw2X1emp+k6O3Rfqq3jQzpQZEqHAsm70LmgQdN8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fC+fp3S/a4J15BEcEE3UUNrNN0fMF1o8trNXlcTxvSUnRdG91DwKePim4+MCu9ttd bq3sOodnYYTxRoQCAhcykn2MCu6u3qY1mAyTpcrVohK/sqAN47y3KWvsCmuI9B4iAM gZZlV9oUKQuvQj7ZRse5ZBumkeMZzb5v6+6aAoy/JRnIocJz/ivk5Z2H3D728H1q7u dMPDZ94fw2HQ+Pyqg4Vrh60Gpv2mx6mMFMkJo1l+bthtPbqq98iqLI/lQptrCMbemk WXxPVc5Pzj2vkD+WOzvRVrik7VP6AWfOoWgHO9YBRDiKxdBh1snqsYCzLkyp8S4Z2x isEkFAvIINWBw== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:25 -0800 Subject: [PATCH 35/36] xen/console: enable console owners w/ emulated NS8250 MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-35-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=1133; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=WQSeR36nIyjmpuQo8H1p9/NbRUrGXqQm6ZbcYesml3s=; b=CpDYEchPnsqpvivWMdQylePfQPuJSv0/SjOEWfua7YW9lLt1hgiNJ6VsfmU5JHvY35yc3Ople waiIIpFcbLcC2C5el3B47d6MtywojYP1vjZQlm+z48MSNaddZKt8lgp X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Enable console focus for domains w/ virtual NS8250. Code change allows to capture the output from the guest OS now and send it to the physical console device. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 24a8263045b0e5ecf901d08e627f34a80edd297d..54595b486b9761d0a17831b95481f2fa9bdcfcc7 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -41,6 +41,9 @@ #ifdef CONFIG_SBSA_VUART_CONSOLE #include #endif +#if defined(CONFIG_HAS_VUART_NS8250) +#include +#endif /* console: comma-separated list of console outputs. */ static char __initdata opt_console[30] = OPT_CONSOLE_STR; @@ -581,6 +584,8 @@ static void handle_keypress_in_domain(struct domain *d, char c) { #if defined(CONFIG_SBSA_VUART_CONSOLE) rc = vpl011_rx_char_xen(d, c); +#elif defined(CONFIG_HAS_VUART_NS8250) + rc = vuart_putchar(&d->arch.hvm.vuart, c); #endif } /* From patchwork Tue Nov 26 23:22:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin via B4 Relay X-Patchwork-Id: 13886413 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 9DFE0D66B9A for ; Tue, 26 Nov 2024 23:23:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.844078.1259745 (Exim 4.92) (envelope-from ) id 1tG4ty-00041x-Pg; Tue, 26 Nov 2024 23:23:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 844078.1259745; Tue, 26 Nov 2024 23:23:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tx-0003yO-NI; Tue, 26 Nov 2024 23:23:25 +0000 Received: by outflank-mailman (input) for mailman id 844078; Tue, 26 Nov 2024 23:22:10 +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 1tG4sk-0000Ao-MS for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:10 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3f492bb9-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:04 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0054A5C5DA4; Tue, 26 Nov 2024 23:21:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 2A80AC4CEDB; Tue, 26 Nov 2024 23:21:58 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21B5FD66B9D; Tue, 26 Nov 2024 23:21:58 +0000 (UTC) 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: 3f492bb9-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzOS4xNzguODQuMjE3IiwiaGVsbyI6ImRmdy5zb3VyY2Uua2VybmVsLm9yZyJ9 X-Custom-Transaction: eyJpZCI6IjNmNDkyYmI5LWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzI1LjAwMzU0LCJzZW5kZXIiOiJkZXZudWxsK2RtdWtoaW4uZm9yZC5jb21Aa2VybmVsLm9yZyIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663318; bh=YBcSY6jiH0oljNDw524ilFoQbBSFGheVZRh8mWFvphc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=MoYlYSuIPCnu4b1HHhuKXukwkOccdSQUeZFE42H1bU6Wt2EZ6uyaQv+nIwJzW3pE6 Bg1CIxMkJ0kVWBwSk35mcZL70XCPj0xIgbWG8W0rWSiO4VQuTGH/c4fn5XFyphjxk1 3yD5e4/vVXdjMzA/Qq/uFAOIt1Id6EhdbdO/prkOBLlXgkSv5i0RUc0y3B6MxFDcl9 C7ZMyMeFT94Ij8KXqfiqHOA5Xh0h2+TvVj30nuDi3f6qUSuCXLgQBBJOEXKbO3cv3D TU0nzE7hODveOO6yKOeMTiwolRk222khkUESkmRxDElOHVWwYQzzk+zc6rEoq2U3b6 Z3ApgaxGuiMOA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:26 -0800 Subject: [PATCH 36/36] docs/misc: update console documentation MIME-Version: 1.0 Message-Id: <20241126-vuart-ns8250-v1-v1-36-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=5611; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=O/e2TuAbfREf6sK5Rox2Z4H+zlo5Q3N8ksFZglsK7sE=; b=XavKhjZA3mfK4h09UVfAzuoD+nqYtkqc4418biMqkmSexlVgea/EgM0/sVOixRT0rGc6Is/Ke gmcR6+YgzKOD7ftpuWh53AGZUZYrdt+D/f3ZpAPz7y6T7Ams0JNWAsX X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com From: Denis Mukhin Minor update related to virtual UART support. Also: s/pv/PV/g s/hvm/HVM/g Signed-off-by: Denis Mukhin --- docs/misc/console.txt | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/docs/misc/console.txt b/docs/misc/console.txt index 4e180f88ba1312d8fcc47d27622ec347d387ce12..b5411b4d74b6d3d920a4fbb2ce6033a239ec5832 100644 --- a/docs/misc/console.txt +++ b/docs/misc/console.txt @@ -4,11 +4,11 @@ Xen PV Console notes stefano.stabellini@eu.citrix.com -Xen traditionally provided a single pv console to pv guests, storing the +Xen traditionally provided a single PV console to PV guests, storing the relevant information in xenstore under /local/domain/$DOMID/console. -Now many years after the introduction of the pv console we have -multiple pv consoles support for pv and hvm guests; multiple pv +Now many years after the introduction of the PV console we have +multiple PV consoles support for PV and HVM guests; multiple PV console backends (qemu and xenconsoled, see limitations below) and emulated serial cards too. @@ -103,48 +103,50 @@ The supported values are only xenconsoled or ioemu; xenconsoled has several limitations: it can only be used for the first PV or virtual UART console and it can only connect to a pty. -Emulated serials are provided by qemu-dm only to hvm guests; the number -of emulated serials depends on how many "-serial" command line options -are given to qemu. The output of a serial is specified as argument to -the -serial command line option to qemu. Qemu writes the tty name to -xenstore in the following path: +Emulated serials are provided to HVM guests by qemu-dm or in-hypervisor UART +emulator (Xen needs to be re-compiled). + +In qemu-dm case, the number of emulated serials depends on how many "-serial" +command line options are given to qemu. The output of a serial is specified as +argument to the -serial command line option to qemu. Qemu writes the tty name +to xenstore in the following path: /local/domain/$DOMID/serial/$SERIAL_NUM/tty xenconsole is the tool to connect to a PV or virtual UART console or an emulated serial that has a pty as output. Xenconsole takes a domid as -parameter plus an optional console type (pv for PV consoles, vuart for +parameter plus an optional console type (PV for PV consoles, vuart for virtual UART or serial for emulated serials) and console number. Depending on the type and console number, xenconsole will look for the tty node in different xenstore paths, as described above. If the user doesn't -specify the console type xenconsole will try to guess: if the guest is a pv -guest it defaults to PV console, if the guest is an hvm guest it defaults to +specify the console type xenconsole will try to guess: if the guest is a PV +guest it defaults to PV console, if the guest is an HVM guest it defaults to emulated serial. -By default xl creates a pv console for hvm guests, plus an emulated +By default xl creates a PV console for HVM guests, plus an emulated serial if the user specified 'serial = "pty"' in the VM config file. -Considering that xenconsole defaults to emulated serials for hvm guests, +Considering that xenconsole defaults to emulated serials for HVM guests, executing xl create -c "domain" causes xenconsole to attach to the emulated serial tty. This is most probably what the user wanted because -currently no bootloaders support xen pv consoles so the only way to +currently no bootloaders support xen PV consoles so the only way to interact with a bootloader like grub over a console is to use the emulated serial. -However the pv console is still easy to use with Linux PV on HVM guests: +However the PV console is still easy to use with Linux PV on HVM guests: the user just need to pass "console=hvc0" to the kernel command line and then execute "xl console -t pv " to connect to it. When using stubdoms the serial cards are still emulated by qemu (this time running in the stubdom), the number of serial cards and where the output goes is still specified using qemu command line options. -The difference is that for each emulated serial card there must be a pv +The difference is that for each emulated serial card there must be a PV console connection between the stubdom and dom0 to export the serial -output from the stubdom to dom0. The pv console backend for stubdom's pv -consoles is always ioemu because multiple pv consoles support is a -requirement in this case, considering that minios has its own pv console -too. In order to simplify the setup when using stubdoms the hvm guest -can only have one pv console with xenstored as backend (the stubdom -could provide pv console backends to the hvm guest but then it would -need another pv console connection for each console backend to export +output from the stubdom to dom0. The PV console backend for stubdom's PV +consoles is always ioemu because multiple PV consoles support is a +requirement in this case, considering that minios has its own PV console +too. In order to simplify the setup when using stubdoms the HVM guest +can only have one PV console with xenstored as backend (the stubdom +could provide PV console backends to the HVM guest but then it would +need another PV console connection for each console backend to export the pty to dom0). The xenconsole program supports a very simple protocol to notify parent about