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 6F63CC4332F for ; Wed, 21 Dec 2022 17:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tvTbgpcNrTKZ5OWn/PG+s0X+mz2mTUTB/Nu7Wz3amBc=; b=ic2nvcTH+KubIu 7QSn7hboFH6dEJRzXiZsHLLLgOPnrviBrIZ9E2Wrmh7J516ZKfhA6LXvDXS9aiR9TBPaXX01tQDe+ GKOMK8tzXeedgV90AgG1NygdyVJP2Wlih013lXGnaQ6lOzF3OCXRaNMni9XC8WevP0hQKNRr5o9Ok zH+0rFWIhCnBbygUIqniXU+jatx1Bzhyn/xhksY88kYraiNLnfaP8P2/U1h5lqbThulPTcnpavBBm jKjq59uCjHiSqqdaa3ga3u+PPXLHiJUU11Nu2ot5nSH7QVaTnXJkPfrTIpnymurLPf4rsuWvCe1Yp Uzj6O8cUwlrFg2UpkxGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p83IJ-000A2D-Fc; Wed, 21 Dec 2022 17:54:19 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p83I4-0009ig-7E for linux-arm-kernel@lists.infradead.org; Wed, 21 Dec 2022 17:54:06 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 87BDAB81BEC; Wed, 21 Dec 2022 17:54:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30AEDC433EF; Wed, 21 Dec 2022 17:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671645241; bh=7LRl7Za1xJWk+DAkT1K7niH/xhQTNQuhVESv5AviT0Q=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=MwcYMmy0zWFWpAtAluvPnPFo8TnCkeieBXd6A2rvAkrB+3oz764XK7wH8x6tQLkfA bqlk63bzyNJbb9HqEr5o3MV5C8brm3/L4hakACfnJhjiHw+vxoeRkj7yUyYBUNymi0 rvLZn1kvb10ovCLU+8p0LPxcWSMnGJ/iTezD7Z5uM/Ci0HJg06RKMNU3f49k1NCDm6 1AhpDpNqy/AcbCCcAhjzKewk+wy5+yKHnEBjeO/sCLrgyFZz1n1TivKmZ/jWpi7O8u 7LE/dzcHHjAp82elLTpCdMSSyUeQgviJMv8nsEjsH3AGtxIEtczGdASqdQ4xSIxvkD edbO2ZlXSgNSQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1p83Hy-00ECiH-OR; Wed, 21 Dec 2022 17:53:58 +0000 Date: Wed, 21 Dec 2022 17:53:58 +0000 Message-ID: <86k02kbq2x.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.cs.columbia.edu, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Alexandru Elisei , Ard Biesheuvel , Will Deacon , Quentin Perret , stable@vger.kernel.org Subject: Re: [PATCH 1/3] KVM: arm64: Fix S1PTW handling on RO memslots In-Reply-To: References: <20221220200923.1532710-1-maz@kernel.org> <20221220200923.1532710-2-maz@kernel.org> <86pmcdaylx.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.cs.columbia.edu, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, ardb@kernel.org, will@kernel.org, qperret@google.com, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221221_095404_611687_5CFF387A X-CRM114-Status: GOOD ( 39.33 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 21 Dec 2022 16:50:30 +0000, Oliver Upton wrote: > > On Wed, Dec 21, 2022 at 09:35:06AM +0000, Marc Zyngier wrote: > > [...] > > > > > + if (kvm_vcpu_abt_iss1tw(vcpu)) { > > > > + /* > > > > + * Only a permission fault on a S1PTW should be > > > > + * considered as a write. Otherwise, page tables baked > > > > + * in a read-only memslot will result in an exception > > > > + * being delivered in the guest. > > > > > > Somewhat of a tangent, but: > > > > > > Aren't we somewhat unaligned with the KVM UAPI by injecting an > > > exception in this case? I know we've been doing it for a while, but it > > > flies in the face of the rules outlined in the > > > KVM_SET_USER_MEMORY_REGION documentation. > > > > That's an interesting point, and I certainly haven't considered that > > for faults introduced by page table walks. > > > > I'm not sure what userspace can do with that though. The problem is > > that this is a write for which we don't have useful data: although we > > know it is a page-table walker access, we don't know what it was about > > to write. The instruction that caused the write is meaningless (it > > could either be a load, a store, or an instruction fetch). How do you > > populate the data[] field then? > > > > If anything, this is closer to KVM_EXIT_ARM_NISV, for which we give > > userspace the full ESR and ask it to sort it out. I doubt it will be > > able to, but hey, maybe it is worth a shot. This would need to be a > > different exit reason though, as NISV is explicitly for non-memslot > > stuff. > > > > In any case, the documentation for KVM_SET_USER_MEMORY_REGION needs to > > reflect the fact that KVM_EXIT_MMIO cannot represent a fault due to a > > S1 PTW. > > Oh I completely agree with you here. I probably should have said before, > I think the exit would be useless anyway. Getting the documentation in > line with the intended behavior seems to be the best fix. Right. How about something like this? diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 226b40baffb8..72abd018a618 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -1381,6 +1381,14 @@ It is recommended to use this API instead of the KVM_SET_MEMORY_REGION ioctl. The KVM_SET_MEMORY_REGION does not allow fine grained control over memory allocation and is deprecated. +Note: On arm64, a write generated by the page-table walker (to update +the Access and Dirty flags, for example) never results in a +KVM_EXIT_MMIO exit when the slot has the KVM_MEM_READONLY flag. This +is because KVM cannot provide the data that would be written by the +page-table walker, making it impossible to emulate the access. +Instead, an abort (data abort if the cause of the page-table update +was a load or a store, instruction abort if it was an instruction +fetch) is injected in the guest. 4.36 KVM_SET_TSS_ADDR --------------------- Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel