From patchwork Thu Dec 1 08:03:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiamei Xie X-Patchwork-Id: 13061037 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 905B0C47088 for ; Thu, 1 Dec 2022 08:05:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.450231.707485 (Exim 4.92) (envelope-from ) id 1p0eZD-0007rJ-4y; Thu, 01 Dec 2022 08:05:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 450231.707485; Thu, 01 Dec 2022 08:05:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p0eZD-0007rC-2B; Thu, 01 Dec 2022 08:05:11 +0000 Received: by outflank-mailman (input) for mailman id 450231; Thu, 01 Dec 2022 08:05: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 1p0eZB-0007Zr-Ng for xen-devel@lists.xenproject.org; Thu, 01 Dec 2022 08:05:09 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id d5dc77b0-714e-11ed-8fd2-01056ac49cbb; Thu, 01 Dec 2022 09:04:53 +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 C355FD6E; Thu, 1 Dec 2022 00:05:14 -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 CF5AD3F67D; Thu, 1 Dec 2022 00:05:05 -0800 (PST) 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: d5dc77b0-714e-11ed-8fd2-01056ac49cbb 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 v4 1/2] xen/arm: vpl011: emulate non-SBSA registers as WI/RAZ Date: Thu, 1 Dec 2022 16:03:59 +0800 Message-Id: <20221201080400.1842558-2-jiamei.xie@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221201080400.1842558-1-jiamei.xie@arm.com> References: <20221201080400.1842558-1-jiamei.xie@arm.com> MIME-Version: 1.0 When the guest kernel enables DMA engine with "CONFIG_DMA_ENGINE=y", 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 = 0x96000000 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x00: ttbr address size fault Data abort info: ISV = 0, ISS = 0x00000000 CM = 0, WnR = 0 swapper pgtable: 4k pages, 39-bit VAs, pgdp=0000000020e2e000 [ffffffc00944d048] pgd=100000003ffff803, p4d=100000003ffff803, pud=100000003ffff803, pmd=100000003fffa803, pte=006800009c090f13 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) ---[ 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=en [2] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2211161552420.4020@ubuntu-linux-20-04-desktop/ Signed-off-by: Jiamei Xie Reviewed-by: Michal Orzel --- 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; } return 1; +read_as_zero: + *r = 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; } write_ignore: From patchwork Thu Dec 1 08:04:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiamei Xie X-Patchwork-Id: 13061036 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 8BF76C43217 for ; Thu, 1 Dec 2022 08:05:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.450233.707496 (Exim 4.92) (envelope-from ) id 1p0eZJ-0008CI-Cd; Thu, 01 Dec 2022 08:05:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 450233.707496; Thu, 01 Dec 2022 08:05: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 1p0eZJ-0008C6-9m; Thu, 01 Dec 2022 08:05:17 +0000 Received: by outflank-mailman (input) for mailman id 450233; Thu, 01 Dec 2022 08:05:15 +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 1p0eZH-00089d-S6 for xen-devel@lists.xenproject.org; Thu, 01 Dec 2022 08:05:15 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id e22707bf-714e-11ed-91b6-6bf2151ebd3b; Thu, 01 Dec 2022 09:05:14 +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 A16A5D6E; Thu, 1 Dec 2022 00:05:19 -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 A59263F67D; Thu, 1 Dec 2022 00:05:10 -0800 (PST) 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: e22707bf-714e-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 v4 2/2] xen/arm: vpl011: drop extra return in vpl011_mmio_read Date: Thu, 1 Dec 2022 16:04:00 +0800 Message-Id: <20221201080400.1842558-3-jiamei.xie@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221201080400.1842558-1-jiamei.xie@arm.com> References: <20221201080400.1842558-1-jiamei.xie@arm.com> MIME-Version: 1.0 In vpl011_mmio_read switch block, all cases have a return. So the outside one can be removed. Signed-off-by: Jiamei Xie --- v3 -> v4 - Don't consolidate check registers access - Don't remove label read_as_zero --- xen/arch/arm/vpl011.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index f4a5621fab..35de50760c 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -417,8 +417,6 @@ static int vpl011_mmio_read(struct vcpu *v, goto read_as_zero; } - return 1; - read_as_zero: *r = 0; return 1;