From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 5.15 v2 06/10] KVM: arm64: Unconditionally save+flush host FPSIMD/SVE/SME state
Date: Thu, 3 Apr 2025 11:39:26 -0400 [thread overview]
Message-ID: <20250403105408-8e55d56c8c27f17c@stable.kernel.org> (raw)
In-Reply-To: <20250403-stable-sve-5-15-v2-6-30a36a78a20a@kernel.org>
[ Sasha's backport helper bot ]
Hi,
✅ All tests passed successfully. No issues detected.
No action required from the submitter.
The upstream commit SHA1 provided is correct: fbc7e61195e23f744814e78524b73b59faa54ab4
WARNING: Author mismatch between patch and upstream commit:
Backport author: Mark Brown<broonie@kernel.org>
Commit author: Mark Rutland<mark.rutland@arm.com>
Status in newer kernel trees:
6.13.y | Present (different SHA1: 314eed0b3ec1)
6.12.y | Present (different SHA1: f42151c41cd6)
6.6.y | Present (different SHA1: 7db8ea02c171)
6.1.y | Not found
Note: The patch differs from the upstream commit:
---
1: fbc7e61195e23 ! 1: 7138b0dfa0d0b KVM: arm64: Unconditionally save+flush host FPSIMD/SVE/SME state
@@ Metadata
## Commit message ##
KVM: arm64: Unconditionally save+flush host FPSIMD/SVE/SME state
+ [ Upstream commit fbc7e61195e23f744814e78524b73b59faa54ab4 ]
+
There are several problems with the way hyp code lazily saves the host's
FPSIMD/SVE state, including:
@@ Commit message
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20250210195226.1215254-2-mark.rutland@arm.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
+ [ Mark: Handle vcpu/host flag conflict, remove host_data_ptr() ]
+ Signed-off-by: Mark Rutland <mark.rutland@arm.com>
+ Signed-off-by: Mark Brown <broonie@kernel.org>
## arch/arm64/kernel/fpsimd.c ##
@@ arch/arm64/kernel/fpsimd.c: void fpsimd_signal_preserve_current_state(void)
@@ arch/arm64/kernel/fpsimd.c: void fpsimd_signal_preserve_current_state(void)
## arch/arm64/kvm/fpsimd.c ##
@@ arch/arm64/kvm/fpsimd.c: void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu)
- if (!system_supports_fpsimd())
- return;
+ vcpu->arch.flags &= ~KVM_ARM64_FP_ENABLED;
+ vcpu->arch.flags |= KVM_ARM64_FP_HOST;
- fpsimd_kvm_prepare();
-
- /*
-- * We will check TIF_FOREIGN_FPSTATE just before entering the
-- * guest in kvm_arch_vcpu_ctxflush_fp() and override this to
-- * FP_STATE_FREE if the flag set.
+- vcpu->arch.flags &= ~KVM_ARM64_HOST_SVE_ENABLED;
++ /*
+ * Ensure that any host FPSIMD/SVE/SME state is saved and unbound such
+ * that the host kernel is responsible for restoring this state upon
+ * return to userspace, and the hyp code doesn't need to save anything.
+ *
+ * When the host may use SME, fpsimd_save_and_flush_cpu_state() ensures
+ * that PSTATE.{SM,ZA} == {0,0}.
- */
-- *host_data_ptr(fp_owner) = FP_STATE_HOST_OWNED;
-- *host_data_ptr(fpsimd_state) = kern_hyp_va(¤t->thread.uw.fpsimd_state);
-- *host_data_ptr(fpmr_ptr) = kern_hyp_va(¤t->thread.uw.fpmr);
++ */
+ fpsimd_save_and_flush_cpu_state();
-+ *host_data_ptr(fp_owner) = FP_STATE_FREE;
-+ *host_data_ptr(fpsimd_state) = NULL;
-+ *host_data_ptr(fpmr_ptr) = NULL;
++ vcpu->arch.flags &= ~KVM_ARM64_FP_HOST;
- host_data_clear_flag(HOST_SVE_ENABLED);
if (read_sysreg(cpacr_el1) & CPACR_EL1_ZEN_EL0EN)
-@@ arch/arm64/kvm/fpsimd.c: void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu)
- host_data_clear_flag(HOST_SME_ENABLED);
- if (read_sysreg(cpacr_el1) & CPACR_EL1_SMEN_EL0EN)
- host_data_set_flag(HOST_SME_ENABLED);
--
-- /*
-- * If PSTATE.SM is enabled then save any pending FP
-- * state and disable PSTATE.SM. If we leave PSTATE.SM
-- * enabled and the guest does not enable SME via
-- * CPACR_EL1.SMEN then operations that should be valid
-- * may generate SME traps from EL1 to EL1 which we
-- * can't intercept and which would confuse the guest.
-- *
-- * Do the same for PSTATE.ZA in the case where there
-- * is state in the registers which has not already
-- * been saved, this is very unlikely to happen.
-- */
-- if (read_sysreg_s(SYS_SVCR) & (SVCR_SM_MASK | SVCR_ZA_MASK)) {
-- *host_data_ptr(fp_owner) = FP_STATE_FREE;
-- fpsimd_save_and_flush_cpu_state();
-- }
- }
-
- /*
+ vcpu->arch.flags |= KVM_ARM64_HOST_SVE_ENABLED;
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.1.y | Success | Success |
next prev parent reply other threads:[~2025-04-03 15:39 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-02 23:20 [PATCH 5.15 v2 00/10] KVM: arm64: Backport of SVE fixes to v5.15 Mark Brown
2025-04-02 23:20 ` [PATCH 5.15 v2 01/10] KVM: arm64: Get rid of host SVE tracking/saving Mark Brown
2025-04-03 15:38 ` Sasha Levin
2025-04-03 16:04 ` Mark Brown
2025-04-03 16:10 ` Mark Brown
2025-04-02 23:20 ` [PATCH 5.15 v2 02/10] KVM: arm64: Discard any SVE state when entering KVM guests Mark Brown
2025-04-03 15:39 ` Sasha Levin
2025-04-03 16:27 ` Mark Brown
2025-04-02 23:20 ` [PATCH 5.15 v2 03/10] arm64/fpsimd: Track the saved FPSIMD state type separately to TIF_SVE Mark Brown
2025-04-03 15:38 ` Sasha Levin
2025-04-02 23:20 ` [PATCH 5.15 v2 04/10] arm64/fpsimd: Have KVM explicitly say which FP registers to save Mark Brown
2025-04-03 15:39 ` Sasha Levin
2025-04-02 23:20 ` [PATCH 5.15 v2 05/10] arm64/fpsimd: Stop using TIF_SVE to manage register saving in KVM Mark Brown
2025-04-03 15:38 ` Sasha Levin
2025-04-02 23:20 ` [PATCH 5.15 v2 06/10] KVM: arm64: Unconditionally save+flush host FPSIMD/SVE/SME state Mark Brown
2025-04-03 15:39 ` Sasha Levin [this message]
2025-04-02 23:20 ` [PATCH 5.15 v2 07/10] KVM: arm64: Remove host FPSIMD saving for non-protected KVM Mark Brown
2025-04-03 15:39 ` Sasha Levin
2025-04-02 23:20 ` [PATCH 5.15 v2 08/10] KVM: arm64: Remove VHE host restore of CPACR_EL1.ZEN Mark Brown
2025-04-03 15:38 ` Sasha Levin
2025-04-02 23:20 ` [PATCH 5.15 v2 09/10] KVM: arm64: Calculate cptr_el2 traps on activating traps Mark Brown
2025-04-03 15:38 ` Sasha Levin
2025-04-02 23:20 ` [PATCH 5.15 v2 10/10] KVM: arm64: Eagerly switch ZCR_EL{1,2} Mark Brown
2025-04-03 15:39 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250403105408-8e55d56c8c27f17c@stable.kernel.org \
--to=sashal@kernel.org \
--cc=broonie@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox