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 A32C5168B7 for ; Mon, 20 May 2024 08:05:40 +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=1716192340; cv=none; b=UoTWDO392wvDEOlb9p9+6Otr+7Qms0A6+KdoxY8R+7ZVTkDPQeaznJWcQ5IDAfyA5uQS305LZIFEai0TlqBGEq1fDXdYJJ7rB7OkflSBHGRh1acxhcnD9o3wXvdcOJ/UV+BCtxP7E5mVyV4W+kmDCvYWhltpJvRoH8+Yw9EFuWk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716192340; c=relaxed/simple; bh=PF+AMv/2xBV4WMySoaRryg6Bp6r6gGNO2fyOTSeycMo=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=oXkgZ5PLAg9JC0fXw5UM7cYQ4lxgqtVbdvGUfUD4Nzuqudjpvp7HyPghV1BSfM6rC+E/f/q57W2QEfF4PePch8pYWoZJBJLc5tlRycAGoKUePNOABULk9CG9JK8nWRBnT/Em/wRQvnkvHR487i/NZZmmclOReue3SfjhKsmTaMs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=phfRsKa9; 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="phfRsKa9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 194ABC2BD10; Mon, 20 May 2024 08:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716192340; bh=PF+AMv/2xBV4WMySoaRryg6Bp6r6gGNO2fyOTSeycMo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=phfRsKa9/eIDZ5c69/LJM9FT+cuv600ic9jAdcY/+KNOETtYkXGeiLj9qs1I9gumv aDchuBrdBn409Yhm2tBQ2L0dy3OcYFv9jr1BgljQhMPhrMfnbMzDLvcvVk3hpvv9mO 4ePox3jNMGP2PD8afOPgvDPeauNe4IPgR1ZgW9YhPC3bIvot646Lkw7XAW+oJMNg6T n1NH5W6R0sOFYG4TT+OnjXmyoakZHlelu2E4R/pWE+3BnpxZ2+KoqZ/yTjhH4msdUB 6G0knBqfcbU/lvaXsPHBi+l9zsM17Ik1NTS7b+8BGtSuk6hu/FOkjWENlTHDfHt7uf m1kMrdykivVWw== Received: from [185.143.37.16] (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 1s8y1Z-00EQAG-In; Mon, 20 May 2024 09:05:37 +0100 Date: Mon, 20 May 2024 09:05:34 +0100 Message-ID: <87r0dw3o35.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: Oliver Upton , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, will@kernel.org, qperret@google.com, seanjc@google.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, philmd@linaro.org, james.morse@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, broonie@kernel.org, joey.gouly@arm.com, rananta@google.com, yuzenghui@huawei.com Subject: Re: [PATCH v1 6/7] KVM: arm64: Eagerly restore host fpsimd/sve state in pKVM In-Reply-To: References: <20240517131814.719933-1-tabba@google.com> <20240517131814.719933-7-tabba@google.com> 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) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.143.37.16 X-SA-Exim-Rcpt-To: tabba@google.com, oliver.upton@linux.dev, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, will@kernel.org, qperret@google.com, seanjc@google.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, philmd@linaro.org, james.morse@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, broonie@kernel.org, joey.gouly@arm.com, rananta@google.com, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 20 May 2024 08:37:22 +0100, Fuad Tabba wrote: >=20 > Hi Oliver, >=20 > On Fri, May 17, 2024 at 6:09=E2=80=AFPM Oliver Upton wrote: > > > > Hi Fuad, > > > > On Fri, May 17, 2024 at 02:18:13PM +0100, Fuad Tabba wrote: > > > static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu) > > > { > > > - __fpsimd_save_state(*host_data_ptr(fpsimd_state)); > > > + /* > > > + * Non-protected kvm relies on the host restoring its sve state. > > > + * Protected kvm restores the host's sve state as not to reveal= that > > > + * fpsimd was used by a guest nor leak upper sve bits. > > > + */ > > > + if (unlikely(is_protected_kvm_enabled() && system_supports_sve(= ))) { > > > + __hyp_sve_save_host(); > > > + > > > + /* Re-enable SVE traps for guests that do not support i= t. */ > > > + if (!vcpu_has_sve(vcpu)) > > > + sysreg_clear_set(cptr_el2, 0, CPTR_EL2_TZ); > > > > This doesn't account for hVHE. I wonder we'd be better off abstracting > > CPTR_EL2 behind a helper wherever it gets used in nVHE and translate > > into the VHE-format behind the scenes: >=20 > Right! Too many modes to keep track of :) >=20 > Abstracting cptr_el2 would make things clearer and less error-prone. > I'll do that on the respin. If we're going with the conversion game, then I'd suggest you use the VHE format as the reference, and convert it to nVHE on the flight. That's for a few reasons: - like it or not, nVHE is going the way of the dodo. I love my v8.0 hardware to bits, but it sucks, and nVHE is now optional anyway. - Keeping everything in the VHE format helps drawing a parallel with what is happening in the kernel (you grep for the same symbols). - One day, I hope to be able to rip any form of SVE/SME support out of nVHE and only keep it for hVHE, because there is no ARMv8.0 implementations with these extensions (apart from SW models). One day... Thanks, M. --=20 Without deviation from the norm, progress is not possible.