From nobody Sat May 4 11:53:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1670225284001731.6078175091445; Sun, 4 Dec 2022 23:28:04 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.453197.710870 (Exim 4.92) (envelope-from ) id 1p25t6-0002mj-Cg; Mon, 05 Dec 2022 07:27:40 +0000 Received: by outflank-mailman (output) from mailman id 453197.710870; Mon, 05 Dec 2022 07:27:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p25t6-0002mc-9x; Mon, 05 Dec 2022 07:27:40 +0000 Received: by outflank-mailman (input) for mailman id 453197; Mon, 05 Dec 2022 07:27:38 +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 1p25t4-0002UH-IX for xen-devel@lists.xenproject.org; Mon, 05 Dec 2022 07:27:38 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 4b044921-746e-11ed-91b6-6bf2151ebd3b; Mon, 05 Dec 2022 08:27:37 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9502523A; Sun, 4 Dec 2022 23:27:43 -0800 (PST) Received: from a015971.shanghai.arm.com (unknown [10.169.188.104]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8E3C83F73D; Sun, 4 Dec 2022 23:27:34 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 4b044921-746e-11ed-91b6-6bf2151ebd3b From: Jiamei Xie To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, jiamei.xie@arm.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH v5 1/2] xen/arm: vpl011: emulate non-SBSA registers as WI/RAZ Date: Mon, 5 Dec 2022 15:26:39 +0800 Message-Id: <20221205072640.2092473-2-jiamei.xie@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205072640.2092473-1-jiamei.xie@arm.com> References: <20221205072640.2092473-1-jiamei.xie@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1670225284966100002 Content-Type: text/plain; charset="utf-8" When the guest kernel enables DMA engine with "CONFIG_DMA_ENGINE=3Dy", Linux SBSA PL011 driver will access PL011 DMACR register in some functions. As chapter "B Generic UART" in "ARM Server Base System Architecture"[1] documentation describes, SBSA UART doesn't support DMA. In current code, when the kernel tries to access DMACR register, Xen will inject a data abort: Unhandled fault at 0xffffffc00944d048 Mem abort info: ESR =3D 0x96000000 EC =3D 0x25: DABT (current EL), IL =3D 32 bits SET =3D 0, FnV =3D 0 EA =3D 0, S1PTW =3D 0 FSC =3D 0x00: ttbr address size fault Data abort info: ISV =3D 0, ISS =3D 0x00000000 CM =3D 0, WnR =3D 0 swapper pgtable: 4k pages, 39-bit VAs, pgdp=3D0000000020e2e000 [ffffffc00944d048] pgd=3D100000003ffff803, p4d=3D100000003ffff803, pud=3D10= 0000003ffff803, pmd=3D100000003fffa803, pte=3D006800009c090f13 Internal error: ttbr address size fault: 96000000 [#1] PREEMPT SMP ... Call trace: pl011_stop_rx+0x70/0x80 tty_port_shutdown+0x7c/0xb4 tty_port_close+0x60/0xcc uart_close+0x34/0x8c tty_release+0x144/0x4c0 __fput+0x78/0x220 ____fput+0x1c/0x30 task_work_run+0x88/0xc0 do_notify_resume+0x8d0/0x123c el0_svc+0xa8/0xc0 el0t_64_sync_handler+0xa4/0x130 el0t_64_sync+0x1a0/0x1a4 Code: b9000083 b901f001 794038a0 8b000042 (b9000041) Acked-by: Julien Grall Reviewed-by: Michal Orzel ---[ end trace 83dd93df15c3216f ]--- note: bootlogd[132] exited with preempt_count 1 /etc/rcS.d/S07bootlogd: line 47: 132 Segmentation fault start-stop-daemon As discussed in [2], this commit makes the access to non-SBSA registers RAZ/WI as an improvement. [1] https://developer.arm.com/documentation/den0094/c/?lang=3Den [2] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2211161552420.402= 0@ubuntu-linux-20-04-desktop/ Signed-off-by: Jiamei Xie --- v4 -> v5 - no change v3 -> v4 - remove the size check for unknown registers in the SBSA UART - remove lock in read_as_zero v2 -> v3 - emulate non-SBSA registers as WI/RAZ in default case - update commit message v1 -> v2 - print a message using XENLOG_G_DEBUG when it's write-ignore --- xen/arch/arm/vpl011.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 43522d48fd..f4a5621fab 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -414,11 +414,15 @@ static int vpl011_mmio_read(struct vcpu *v, default: gprintk(XENLOG_ERR, "vpl011: unhandled read r%d offset %#08x\n", dabt.reg, vpl011_reg); - return 0; + goto read_as_zero; } =20 return 1; =20 +read_as_zero: + *r =3D 0; + return 1; + bad_width: gprintk(XENLOG_ERR, "vpl011: bad read width %d r%d offset %#08x\n", dabt.size, dabt.reg, vpl011_reg); @@ -486,7 +490,7 @@ static int vpl011_mmio_write(struct vcpu *v, default: gprintk(XENLOG_ERR, "vpl011: unhandled write r%d offset %#08x\n", dabt.reg, vpl011_reg); - return 0; + goto write_ignore; } =20 write_ignore: --=20 2.25.1 From nobody Sat May 4 11:53:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1670225288579390.40453679580025; Sun, 4 Dec 2022 23:28:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.453200.710881 (Exim 4.92) (envelope-from ) id 1p25tH-0003Dk-Pp; Mon, 05 Dec 2022 07:27:51 +0000 Received: by outflank-mailman (output) from mailman id 453200.710881; Mon, 05 Dec 2022 07:27:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p25tH-0003DY-Mr; Mon, 05 Dec 2022 07:27:51 +0000 Received: by outflank-mailman (input) for mailman id 453200; Mon, 05 Dec 2022 07:27:51 +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 1p25tH-0002UH-1M for xen-devel@lists.xenproject.org; Mon, 05 Dec 2022 07:27:51 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 52ab5f3b-746e-11ed-91b6-6bf2151ebd3b; Mon, 05 Dec 2022 08:27:50 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6665B23A; Sun, 4 Dec 2022 23:27:56 -0800 (PST) Received: from a015971.shanghai.arm.com (unknown [10.169.188.104]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5659C3F73D; Sun, 4 Dec 2022 23:27:47 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 52ab5f3b-746e-11ed-91b6-6bf2151ebd3b From: Jiamei Xie To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, jiamei.xie@arm.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH v5 2/2] xen/arm: vpl011: add ASSERT_UNREACHABLE in vpl011_mmio_read Date: Mon, 5 Dec 2022 15:26:40 +0800 Message-Id: <20221205072640.2092473-3-jiamei.xie@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205072640.2092473-1-jiamei.xie@arm.com> References: <20221205072640.2092473-1-jiamei.xie@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1670225290813100001 Content-Type: text/plain; charset="utf-8" In vpl011_mmio_read switch block, all cases should have a return. Add ASSERT_UNREACHABLE to catch case where the return is not added. Signed-off-by: Jiamei Xie Acked-by: Julien Grall --- v4 -> v5 - don't remove "return 1" and add ASSERT_UNREACHABLE v3 -> v4 - Don't consolidate check registers access - Don't remove label read_as_zero --- xen/arch/arm/vpl011.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index f4a5621fab..c7f9dae76c 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -417,6 +417,7 @@ static int vpl011_mmio_read(struct vcpu *v, goto read_as_zero; } =20 + ASSERT_UNREACHABLE(); return 1; =20 read_as_zero: --=20 2.25.1