From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DD1819CCF4; Thu, 25 Jul 2024 15:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721921600; cv=none; b=eVOQJyTuLr+lWFmVw3scXePFqxI1Zxms4Rwl7/YPrQ/Og5Yrd2fME2UtrbAGCKX/uf3zKNDXKM066ZqKBRpCcoFzPn6dg8VIHnUy0ue5jnFQOe4DKsF9fKgQnB4PgHxcJ/5AZX5poAoLrq9tzupHMozeJMdHdWmHPnApbINytQ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721921600; c=relaxed/simple; bh=MDq1Q4saoPwdhXmKqgMKL/Ay+WsV+Wk+4g7Y7dWlJZc=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=qwsjAtT6z1f2jLjacuV/0GhQyI1CnlsykpobIrjL0vL27yisWXQQbmx3gTMNPt+GPBM2oN3u4XZbINMhJ+YHZS+O4M7llFCLJhMokO6dCB48u/50T/4t4vRmSVGLNCLxxY5DnukJqRfriWbAqw5rVW74z5NWEh5ofHe0vc7lTHU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NcEJB0v9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NcEJB0v9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C524BC116B1; Thu, 25 Jul 2024 15:33:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721921599; bh=MDq1Q4saoPwdhXmKqgMKL/Ay+WsV+Wk+4g7Y7dWlJZc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NcEJB0v9/lQuR42qN7+wQgACD3DChNNImNTi9QOMAKcYLAkCDTNSR0rM/vyyy5ZMA OoMpnkNxnttzVYIzr6vnlu5oh6MhN7Rm9U0xh0gN9kPiXfyXyXGF24jd6p0LI5l+ue EAMEcOKi0T2R9sZRKNy24uWBXKOxTqy2sOuJZTArcLVKdZbkRzZrG15+P7VSS/afxW rhkHlGilpkmSH5eKdl1TDnvWOHX5f+jU51ANkRld1GuKqiVteb/FVMEt3xfwzqNT1t 77QWXyUS8aRC4KxMp/iypALlnODZx8RE5pr71w2+Tmx/01/dWvYO8r9SGt6AYtAM+K lYjvPv/RjTj6w== 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 1sX0Sz-00FLAl-Qa; Thu, 25 Jul 2024 16:33:17 +0100 Date: Thu, 25 Jul 2024 16:33:17 +0100 Message-ID: <8634nx32rm.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> <864j8d35p3.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/29.3 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 On Thu, 25 Jul 2024 16:13:25 +0100, Alexandru Elisei wrote: > > Hi, > > On Thu, Jul 25, 2024 at 03:30:00PM +0100, Marc Zyngier wrote: > > On Thu, 25 Jul 2024 15:16:12 +0100, > > Alexandru Elisei wrote: > > > > > > Hi Marc, > > > > > > On Mon, Jul 08, 2024 at 05:57:58PM +0100, Marc Zyngier wrote: > > > > + if (perm_fail) { > > > > + struct s1_walk_result tmp; > > > > > > I was wondering if you would consider initializing 'tmp' to the empty struct > > > here. That makes it consistent with the initialization of 'wr' in the !perm_fail > > > case and I think it will make the code more robust wrt to changes to > > > compute_par_s1() and what fields it accesses. > > > > I think there is a slightly better way, with something like this: > > > > diff --git a/arch/arm64/kvm/at.c b/arch/arm64/kvm/at.c > > index b02d8dbffd209..36fa2801ab4ef 100644 > > --- a/arch/arm64/kvm/at.c > > +++ b/arch/arm64/kvm/at.c > > @@ -803,12 +803,12 @@ static u64 handle_at_slow(struct kvm_vcpu *vcpu, u32 op, u64 vaddr) > > } > > > > if (perm_fail) { > > - struct s1_walk_result tmp; > > - > > - tmp.failed = true; > > - tmp.fst = ESR_ELx_FSC_PERM | wr.level; > > - tmp.s2 = false; > > - tmp.ptw = false; > > + struct s1_walk_result tmp = (struct s1_walk_result){ > > + .failed = true, > > + .fst = ESR_ELx_FSC_PERM | wr.level, > > + .s2 = false, > > + .ptw = false, > > + }; > > > > wr = tmp; > > } > > > > Thoughts? > > How about (diff against your kvm-arm64/nv-at-pan-WIP branch, in case something > looks off): > > diff --git a/arch/arm64/kvm/at.c b/arch/arm64/kvm/at.c > index b02d8dbffd20..74ebe3223a13 100644 > --- a/arch/arm64/kvm/at.c > +++ b/arch/arm64/kvm/at.c > @@ -802,16 +802,8 @@ static u64 handle_at_slow(struct kvm_vcpu *vcpu, u32 op, u64 vaddr) > BUG(); > } > > - if (perm_fail) { > - struct s1_walk_result tmp; > - > - tmp.failed = true; > - tmp.fst = ESR_ELx_FSC_PERM | wr.level; > - tmp.s2 = false; > - tmp.ptw = false; > - > - wr = tmp; > - } > + if (perm_fail) > + fail_s1_walk(&wr, ESR_ELx_FSC_PERM | wr.level, false, false); > > compute_par: > return compute_par_s1(vcpu, &wr); > Ah, much nicer indeed! Thanks, M. -- Without deviation from the norm, progress is not possible.