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 A2C50CF8840 for ; Fri, 4 Oct 2024 17:11:17 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ivG9THqCQQnFANZXsktsXbgeggmF80l3fARD79rk4OU=; b=v/qBEhGY+XQJN6QzAwlhmziFfR 8Nb9wHz0Dq6ICfq/yhlanuOR2NeRAEVPZBs8YK8F8xNyyeV5uXVTnV+L4Y8EfGBvyw/NS8lBf++u0 CY4YHPbilqLtOlszaaGh1CnmD27f3C8kvlWOcEGAcJMWqUJLWBT1Hpral8lvraD+wEs4O/5J/Ztbf 8pPUiq5Zq6z35MSDofAFdnmczq3wpkPsDCLAeoi3BC4l9TU3RcswdaGmSd06+V3IlXebW5iomr22P aaNC9NuCxABfEI00C3dGBOjYw81QDxA++DBZrVwM/WRkdE/V3Lf0rGZdvZeg+it5IrBtgOPi/gfkJ fLSaU/dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swlpW-0000000DRCa-0nZ3; Fri, 04 Oct 2024 17:11:02 +0000 Received: from out-188.mta1.migadu.com ([2001:41d0:203:375::bc]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swkc8-0000000D6zn-3YfJ for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2024 15:53:10 +0000 Date: Fri, 4 Oct 2024 08:52:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1728057185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ivG9THqCQQnFANZXsktsXbgeggmF80l3fARD79rk4OU=; b=VBEdW6TdJq+I0Nni5DzNlmiLE4pE738CbB+0OTgiHbZpgUoJi/Je1pnPd+L3nCltngGK6V xKB4MNhUyy6gW7Y2Vp3j9rX5aK/0N45w1qn2+EmYweF+nBjIzxWopsR+3Lw9DCb0FB0nKd dzkQ+bGU/2kC6D0PzBHZVzRUWj1GLfY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Peter Maydell Cc: Ahmad Fatoum , qemu-arm@nongnu.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, Pengutronix Kernel Team , "linux-arm-kernel@lists.infradead.org" , Enrico Joerns Subject: Re: [BUG] ARM64 KVM: Data abort executing post-indexed LDR on MMIO address Message-ID: References: <89f184d6-5b61-4c77-9f3b-c0a8f6a75d60@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241004_085309_606501_F88A1C0D X-CRM114-Status: GOOD ( 23.32 ) 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 On Fri, Oct 04, 2024 at 01:10:48PM +0100, Peter Maydell wrote: > On Fri, 4 Oct 2024 at 12:51, Ahmad Fatoum wrote: > > > Strictly speaking this is a missing feature in KVM (in an > > > ideal world it would let you do MMIO with any instruction > > > that you could use on real hardware). > > > > I assume that's because KVM doesn't want to handle interruptions > > in the middle of such "composite" instructions? > > It's because with the ISV=1 information in the ESR_EL2, > KVM has everything it needs to emulate the load/store: > it has the affected register number, the data width, etc. When > ISV is 0, simulating the load/store would require KVM > to load the actual instruction word, decode it to figure > out what kind of load/store it was, and then emulate > its behaviour. The instruction decode would be complicated > and if done in the kernel would increase the attack surface > exposed to the guest. On top of that, the only way to 'safely' fetch the instruction would be to pause all vCPUs in the VM to prevent the guest from remapping the address space behind either KVM or the VMM's back. > > static inline u32 __raw_readl(const volatile void __iomem *addr) > > { > > return *(const volatile u32 __force *)addr; > > } > > > > I wouldn't necessarily characterize this as strange, we just erroneously > > assumed that with strongly ordered memory for MMIO regions and volatile > > accesses we had our bases covered and indeed we did until the bases > > shifted to include hardware-assisted virtualization. :-) This has nothing to do with ordering and everything to do with the instruction set && what your compiler decided to emit. > I'm not a fan of doing MMIO access via 'volatile' in C code, > personally -- I think the compiler has a tendency to do more > clever recombination than you might actually want, because > it doesn't know that the thing you're accessing isn't RAM-like. +1 -- Thanks, Oliver