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 3B1CCCF8840 for ; Fri, 4 Oct 2024 17:12:37 +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=zlM8m7v/qswLm5RCIdVV6zcxY4xUPPYPHOAIW5U70Sc=; b=uDtJUzABlWzOXVvmO/MMAzdMYU X/LJt4dfJz+VBrVdoddrqg8P3U9PrMDw49lvmQHF7cEWjh1SJXyJ36HceWwx4CTWTp+2lfLmQVdAt nG5R8lTqWnRw/s7pcOy+vQoZfZ1Pz7PfSlYShcs3osLVAvQ7SBAvKZwvgCX8q6+omA/hPfxD5nvOP 2rkMSW+b9NJmFqUauGUmr/VkZ8TWsGu77wZJKKCKYo4ppR3A9C4bKa0FaPF3DoasmsfioyA25QHuJ sH2iVR0QyOI4lCMT0K4F025+7/AepmCU3vnj/Tg+cqByPfquh3fyWN9wc/i5O1REfomM7utpJMPQC zJef+imA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swlqq-0000000DSWY-3qAH; Fri, 04 Oct 2024 17:12:24 +0000 Received: from out-186.mta0.migadu.com ([91.218.175.186]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swl3g-0000000DEHm-0sEi for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2024 16:21:37 +0000 Date: Fri, 4 Oct 2024 09:21:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1728058889; 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=zlM8m7v/qswLm5RCIdVV6zcxY4xUPPYPHOAIW5U70Sc=; b=lSOjAaTqUpZvTU6T8QVVY02TEP5Ti3WOAE+d2atngJNuLQ7fVaEjcYA1WT0s1/E46OuU6Y kpwXZjwQFFbbscrh2qD/IkA4IIGc9l/n74Kqtt+OLdJJSAgr0eLB0uWY1ypqHw9OUyxFH5 03sVn0dZ65TN/TUObvZxxJ07yvWSEqU= 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_092136_425691_4497E194 X-CRM114-Status: GOOD ( 25.73 ) 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 04:57:56PM +0100, Peter Maydell wrote: > On Fri, 4 Oct 2024 at 16:53, Oliver Upton wrote: > > > > 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. > > Do we actually care about that, though? Judging from the fact that our existing MMIO flows have a similar "bug", I'd say no. I was just being pedantic about how annoying it'd be to do this faithfully, including the VA -> IPA translation. > If the guest does > that isn't it equivalent to a hardware CPU happening to > fetch the insn just-after a remapping rather than just-before? > If you decode the insn and it's not a store you could just > restart the guest... Definitely, you'd need to restart any time the instruction doesn't line up with the ESR. The pedantic thing I was thinking about was if the instruction bytes remain the same but marked as non-executable: T1 T2 == == readl(addr); < MMIO data abort > insn = fetch(readl); set_nx(readl); tlbi(readl); dsb(ish); emulate(insn); -- Thanks, Oliver