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 EBD98C3DA60 for ; Thu, 18 Jul 2024 11:38:28 +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-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID: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=nFg9frX2Y2TGCQi7YKu9/iHJMteUPZdJ22CxDnaKDOE=; b=t2rja1Gi9vOpjyMN65/exmjIQ6 +7OYl9nqSjafzNiD1U5kEtNuQFumJdG7ClTYn6EEki9DU6pLn4CxhprRcvg0zwiUxuTfVfWA3/8PY dkijDr+/4bifVrLjGwZlm3UB9xzVg7AHTNKOo/5Bt7AN18vOhYGZMRSDyBEg3Wkyx6aIzyCiWflLS 1AMmgy0nND8wQl6m97BezD4OcDWnwdKVUdBeDTliCed134+32PNrjzDYAIfTw9R0o7IqPiEQ0ym75 JyyDC8Fx/OHe0lh9VW1YVLLXm+0nyh9gjmQAs7E+zGWeHYYNUW6jS6ZoUHQ2E3OJCrFHsl0erg1sr e9i5pqvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUPSg-0000000GrpM-2xwG; Thu, 18 Jul 2024 11:38:14 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUPSL-0000000GrmN-0Wst for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 11:37:54 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 454F161A8E; Thu, 18 Jul 2024 11:37:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAE5FC116B1; Thu, 18 Jul 2024 11:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721302671; bh=JTdVhHa8K8Oj9vWfltL+Kcl+giEACbBSmFqRmJsRqik=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AMFa9J87Gi8RHYPHz8GZpa+zIVfUwtnGKw4QWBgJ7eRG5RKdN3XIbqEgB3dAA69xL zAv51c3H8tRE1RfsQ7dwymm89G7WduNX+zh8T+Neh+mwwP9FMaWUgswa5CfQwP+X1E jRmvn9zURoLeatMiMgUOoieJpdql7x83Qpx/P4CVQgOa2KAeEIILNBG2u0frCQYn+h z0Q8RbeqT/Z4aNxOBlIuGE7WW37vXehPRJJCyY9x1O8Vp5ny3F+63WHjM1ZtP01UnF /o9Fpv7OubkkzA5sCyApkELgrYVAxQdTnv9/l8vFdgrBxUUhSpGy8HuBd5IkVKQSBl 66HXHp4bcUkhA== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.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 1sUPSH-00DQvm-Gy; Thu, 18 Jul 2024 12:37:49 +0100 Date: Thu, 18 Jul 2024 12:37:49 +0100 Message-ID: <87a5if53si.wl-maz@kernel.org> From: Marc Zyngier To: Alexandru Elisei Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Joey Gouly Subject: Re: [PATCH 10/12] KVM: arm64: nv: Add SW walker for AT S1 emulation In-Reply-To: References: <20240625133508.259829-1-maz@kernel.org> <20240708165800.1220065-1-maz@kernel.org> <874j8wp1hx.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 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: alexandru.elisei@arm.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, joey.gouly@arm.com 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-20240718_043753_321467_C59F6A31 X-CRM114-Status: GOOD ( 21.11 ) 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 Alex, On Mon, 15 Jul 2024 16:30:19 +0100, Alexandru Elisei wrote: > > In this patch, if I'm reading the code right (and I'm starting to doubt myself) > if PAR_EL1.F is set and PAR_EL1 doesn't indicate a permissions fault, then KVM > falls back to walking the S1 tables: > > if (par & SYS_PAR_EL1_F) { > u8 fst = FIELD_GET(SYS_PAR_EL1_FST, par); > > /* > * If we get something other than a permission fault, we > * need to retry, as we're likely to have missed in the PTs. > */ > if ((fst & ESR_ELx_FSC_TYPE) != ESR_ELx_FSC_PERM) > retry_slow = true; > } > > I suppose that's because KVM cannot distinguish between two very different > reasons for AT failing: 1, because of something being wrong with the stage 1 > tables when the AT S1E0* instruction was executed and 2, because of missing > entries at stage 2, as per the comment. Is that correct? Exactly. It doesn't help that I'm using 3 AT instructions to implement a single one, and that makes the window of opportunity for things to go wrong rather large. Now, I've been thinking about this some more, and I came to the conclusion that we can actually implement the FEAT_PAN2 instructions using the PAN2 instructions themselves, which would greatly simplify the code. We just need to switch PSTATE.PAN so that it reflects the guest's state around the AT instruction. With that scheme, the process becomes slightly clearer (and applies to all AT instructions except for FEAT_ATS1A): - either we have a successful translation and all is good - or we have a failure for permission fault: all is good as well, as this is simply a "normal" failure - or we have a failure for any other reason, and we must fall back to a SW walk to work things out properly. I'll try to capture this reasoning as a comment in the next version. Thanks, M. -- Without deviation from the norm, progress is not possible.