From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C0DA5CF8857 for ; Fri, 4 Oct 2024 19:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Yoy0QBaXuWq9zQCN1DnTsTcGojJx4kkJvXqAeEBHiB4=; b=Fz7VccfT0kA1PjSesnAXBPdrvt lqoru1oV9NStg9/snm0GzTEA4rU1bRs+ySODIqN0wEHRkO/DDHHhDXYsi8MozBXTujj3uZfx9zc4z PJ15Lk+fvVh3VpwLvuSUAXOmmc57gJ8pukkSHVBMpGMSRH/IyckzowfIEkfQgyAPYL0bIWZb2+b88 y4kOau+8PtOuxa6W3/TwbWGnkNg9mgErbT68MbFq0tKHMmJ+/Q5UOom0yBvS7eXUBLH2udqsRZssz bM/D7kjoAXt1y9ixhWVudVhCKZ1M1ycKJjhdXgw/okJFW1eU8sHX+p9WqGCKP588BsL4piHtFKQtP 6El04TPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swoL8-0000000DziV-2hXF; Fri, 04 Oct 2024 19:51:50 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swoJq-0000000DzLu-0Mdy for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2024 19:50:32 +0000 Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1swoJg-0001qQ-83; Fri, 04 Oct 2024 21:50:20 +0200 Message-ID: <4d559b9e-c208-46f3-851a-68086dc8a50f@pengutronix.de> Date: Fri, 4 Oct 2024 21:50:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [BUG] ARM64 KVM: Data abort executing post-indexed LDR on MMIO address To: Peter Maydell Cc: qemu-arm@nongnu.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, Pengutronix Kernel Team , "linux-arm-kernel@lists.infradead.org" , Enrico Joerns References: <89f184d6-5b61-4c77-9f3b-c0a8f6a75d60@pengutronix.de> Content-Language: en-US From: Ahmad Fatoum In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241004_125030_161656_13333BCC X-CRM114-Status: GOOD ( 13.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On 04.10.24 14:10, Peter Maydell wrote: > On Fri, 4 Oct 2024 at 12:51, Ahmad Fatoum wrote: >> On 04.10.24 12:40, Peter Maydell wrote: >>> Don't do this -- KVM doesn't support it. For access to MMIO, >>> stick to instructions which will set the ISV bit in ESR_EL1. >>> >>> That is: >>> >>> * AArch64 loads and stores of a single general-purpose register >>> (including the register specified with 0b11111, including those >>> with Acquire/Release semantics, but excluding Load Exclusive >>> or Store Exclusive and excluding those with writeback). >>> * AArch32 instructions where the instruction: >>> - Is an LDR, LDA, LDRT, LDRSH, LDRSHT, LDRH, LDAH, LDRHT, >>> LDRSB, LDRSBT, LDRB, LDAB, LDRBT, STR, STL, STRT, STRH, >>> STLH, STRHT, STRB, STLB, or STRBT instruction. >>> - Is not performing register writeback. >>> - Is not using R15 as a source or destination register. >>> >>> Your instruction is doing writeback. Do the address update >>> as a separate instruction. With readl/writel implemented in assembly, I get beyond that point, but now I get a data abort running an DC IVAC instruction on address 0x1000, where the cfi-flash is located. This instruction is part of a routine to remap the cfi-flash to start a page later, so the zero page can be mapped faulting. Simple reproducer: start: ldr x0, =0x1000 ldr x1, =0x1040 bl v8_inv_dcache_range mov w10, '!' bl putch ret v8_inv_dcache_range: mrs x3, ctr_el0 lsr x3, x3, #16 and x3, x3, #0xf mov x2, #0x4 lsl x2, x2, x3 sub x3, x2, #0x1 bic x0, x0, x3 1: dc ivac, x0 add x0, x0, x2 cmp x0, x1 b.cc 1b dsb sy ret This prints ! without KVM, but triggers a data abort before that with -enable-kvm: DABT (current EL) exception (ESR 0x96000010) at 0x0000000000001000 elr: 000000007fbe0550 lr : 000000007fbe01ac [snip] Call trace: [<7fbe0550>] (v8_inv_dcache_range+0x1c/0x34) from [<7fbe0218>] (arch_remap_range+0x64/0x70) [<7fbe0218>] (arch_remap_range+0x64/0x70) from [<7fb8795c>] (of_platform_device_create+0x1e8/0x22c) [<7fb8795c>] (of_platform_device_create+0x1e8/0x22c) from [<7fb87a04>] (of_platform_bus_create+0x64/0xbc) [snip] Any idea what this is about? Thanks, Ahmad -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |