summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2026-06-03 14:06:14 +0300
committerWill Deacon <will@kernel.org>2026-06-03 18:50:47 +0300
commitdc233762588051bfd28f03e848aa2015c9b1dbd2 (patch)
tree4cfc7bf38f94c24d7522a2b6efb24e5a85585887
parent79e66bb7e8b48f953c97022998b25734a5d09651 (diff)
downloadlinux-dc233762588051bfd28f03e848aa2015c9b1dbd2.tar.xz
KVM: arm64: Don't override FFR save/restore argument
The __sve_save_state() and __sve_restore_state() functions take a parameter describing whether to save/restore the FFR, but both functions silently override this with '1'. This has always been benign (and callers have all passed 'true' since the parameter was introduced), but clearly this is not intentional. Historically, the functions always saved/restored the FFR, and there was no parameter to control this. In v5.16, the sve_save and sve_load assembly macros used by __sve_save_state() and __sve_restore_state() were changed to make saving/restoring FFR optional. The implementations of __sve_save_state() and __sve_restore_state() were changed to pass '1' to their respective macros, and the prototypes of __sve_save_state() and __sve_restore_state() were unchanged. See commit: 9f5848665788 ("arm64/sve: Make access to FFR optional") In v6.10, the prototypes of __sve_save_state() and __sve_restore_state() were changed to add 'save_ffr' and 'restore_ffr' parameters respectively, but the implementations were not changed to stop passing 1 to their respective macros. All callers were changed to pass 'true' to __sve_save_state() and __sve_restore_state(). See commit: 45f4ea9bcfe9 ("KVM: arm64: Fix prototype for __sve_save_state/__sve_restore_state") This is all benign, but clearly unintentional, and it gets in the way of cleaning up the FPSIMD/SVE/SME code. Remove the unnecessary overriding. The 'save_ffr' and 'restore_ffr' parameters are 32-bit ints, and per the AAPCS64 parameter passing rules, the upper 32 bits of the register holding these arguments might contain arbitrary values. Thus it is necessary to pass 'w2' rather than 'x2' to the sve_load and save_save macros, such that the upper 32 bits are ignored when deciding whether to save/restore the FFR. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Mark Brown <broonie@kernel.org> Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Fuad Tabba <tabba@google.com> Cc: James Morse <james.morse@arm.com> Cc: Marc Zyngier <maz@kernel.org> Cc: Oliver Upton <oupton@kernel.org> Cc: Will Deacon <will@kernel.org> Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--arch/arm64/kvm/hyp/fpsimd.S6
1 files changed, 2 insertions, 4 deletions
diff --git a/arch/arm64/kvm/hyp/fpsimd.S b/arch/arm64/kvm/hyp/fpsimd.S
index e950875e31ce..30507c50942e 100644
--- a/arch/arm64/kvm/hyp/fpsimd.S
+++ b/arch/arm64/kvm/hyp/fpsimd.S
@@ -21,13 +21,11 @@ SYM_FUNC_START(__fpsimd_restore_state)
SYM_FUNC_END(__fpsimd_restore_state)
SYM_FUNC_START(__sve_restore_state)
- mov x2, #1
- sve_load 0, x1, x2, 3
+ sve_load 0, x1, w2, 3
ret
SYM_FUNC_END(__sve_restore_state)
SYM_FUNC_START(__sve_save_state)
- mov x2, #1
- sve_save 0, x1, x2, 3
+ sve_save 0, x1, w2, 3
ret
SYM_FUNC_END(__sve_save_state)