* FAILED: patch "[PATCH] arm64/ptrace: Don't enable SVE when setting streaming SVE" failed to apply to 6.1-stable tree
@ 2023-08-07 7:07 gregkh
2023-08-07 19:56 ` [PATCH 6.1.y] arm64/ptrace: Don't enable SVE when setting streaming SVE Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2023-08-07 7:07 UTC (permalink / raw)
To: broonie, catalin.marinas; +Cc: stable
The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 045aecdfcb2e060db142d83a0f4082380c465d2c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023080713-schedule-tuition-b3a5@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
045aecdfcb2e ("arm64/ptrace: Don't enable SVE when setting streaming SVE")
baa8515281b3 ("arm64/fpsimd: Track the saved FPSIMD state type separately to TIF_SVE")
93ae6b01bafe ("KVM: arm64: Discard any SVE state when entering KVM guests")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 045aecdfcb2e060db142d83a0f4082380c465d2c Mon Sep 17 00:00:00 2001
From: Mark Brown <broonie@kernel.org>
Date: Thu, 3 Aug 2023 19:33:21 +0100
Subject: [PATCH] arm64/ptrace: Don't enable SVE when setting streaming SVE
Systems which implement SME without also implementing SVE are
architecturally valid but were not initially supported by the kernel,
unfortunately we missed one issue in the ptrace code.
The SVE register setting code is shared between SVE and streaming mode
SVE. When we set full SVE register state we currently enable TIF_SVE
unconditionally, in the case where streaming SVE is being configured on a
system that supports vanilla SVE this is not an issue since we always
initialise enough state for both vector lengths but on a system which only
support SME it will result in us attempting to restore the SVE vector
length after having set streaming SVE registers.
Fix this by making the enabling of SVE conditional on setting SVE vector
state. If we set streaming SVE state and SVE was not already enabled this
will result in a SVE access trap on next use of normal SVE, this will cause
us to flush our register state but this is fine since the only way to
trigger a SVE access trap would be to exit streaming mode which will cause
the in register state to be flushed anyway.
Fixes: e12310a0d30f ("arm64/sme: Implement ptrace support for streaming mode SVE registers")
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230803-arm64-fix-ptrace-ssve-no-sve-v1-1-49df214bfb3e@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 740e81e9db04..5b9b4305248b 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -932,11 +932,13 @@ static int sve_set_common(struct task_struct *target,
/*
* Ensure target->thread.sve_state is up to date with target's
* FPSIMD regs, so that a short copyin leaves trailing
- * registers unmodified. Always enable SVE even if going into
- * streaming mode.
+ * registers unmodified. Only enable SVE if we are
+ * configuring normal SVE, a system with streaming SVE may not
+ * have normal SVE.
*/
fpsimd_sync_to_sve(target);
- set_tsk_thread_flag(target, TIF_SVE);
+ if (type == ARM64_VEC_SVE)
+ set_tsk_thread_flag(target, TIF_SVE);
target->thread.fp_type = FP_STATE_SVE;
BUILD_BUG_ON(SVE_PT_SVE_OFFSET != sizeof(header));
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6.1.y] arm64/ptrace: Don't enable SVE when setting streaming SVE
2023-08-07 7:07 FAILED: patch "[PATCH] arm64/ptrace: Don't enable SVE when setting streaming SVE" failed to apply to 6.1-stable tree gregkh
@ 2023-08-07 19:56 ` Mark Brown
2023-08-09 9:07 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2023-08-07 19:56 UTC (permalink / raw)
To: stable; +Cc: Mark Brown, Catalin Marinas
Systems which implement SME without also implementing SVE are
architecturally valid but were not initially supported by the kernel,
unfortunately we missed one issue in the ptrace code.
The SVE register setting code is shared between SVE and streaming mode
SVE. When we set full SVE register state we currently enable TIF_SVE
unconditionally, in the case where streaming SVE is being configured on a
system that supports vanilla SVE this is not an issue since we always
initialise enough state for both vector lengths but on a system which only
support SME it will result in us attempting to restore the SVE vector
length after having set streaming SVE registers.
Fix this by making the enabling of SVE conditional on setting SVE vector
state. If we set streaming SVE state and SVE was not already enabled this
will result in a SVE access trap on next use of normal SVE, this will cause
us to flush our register state but this is fine since the only way to
trigger a SVE access trap would be to exit streaming mode which will cause
the in register state to be flushed anyway.
Fixes: e12310a0d30f ("arm64/sme: Implement ptrace support for streaming mode SVE registers")
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230803-arm64-fix-ptrace-ssve-no-sve-v1-1-49df214bfb3e@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
(cherry picked from commit 045aecdfcb2e060db142d83a0f4082380c465d2c)
[Fix up backport -- broonie]
Signed-off-by: Mark Brown <broonie@kernel.org>
---
arch/arm64/kernel/ptrace.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 92bc9a2d702c..f19f020ccff9 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -937,11 +937,13 @@ static int sve_set_common(struct task_struct *target,
/*
* Ensure target->thread.sve_state is up to date with target's
* FPSIMD regs, so that a short copyin leaves trailing
- * registers unmodified. Always enable SVE even if going into
- * streaming mode.
+ * registers unmodified. Only enable SVE if we are
+ * configuring normal SVE, a system with streaming SVE may not
+ * have normal SVE.
*/
fpsimd_sync_to_sve(target);
- set_tsk_thread_flag(target, TIF_SVE);
+ if (type == ARM64_VEC_SVE)
+ set_tsk_thread_flag(target, TIF_SVE);
BUILD_BUG_ON(SVE_PT_SVE_OFFSET != sizeof(header));
start = SVE_PT_SVE_OFFSET;
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 6.1.y] arm64/ptrace: Don't enable SVE when setting streaming SVE
2023-08-07 19:56 ` [PATCH 6.1.y] arm64/ptrace: Don't enable SVE when setting streaming SVE Mark Brown
@ 2023-08-09 9:07 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2023-08-09 9:07 UTC (permalink / raw)
To: Mark Brown; +Cc: stable, Catalin Marinas
On Mon, Aug 07, 2023 at 08:56:33PM +0100, Mark Brown wrote:
> Systems which implement SME without also implementing SVE are
> architecturally valid but were not initially supported by the kernel,
> unfortunately we missed one issue in the ptrace code.
>
> The SVE register setting code is shared between SVE and streaming mode
> SVE. When we set full SVE register state we currently enable TIF_SVE
> unconditionally, in the case where streaming SVE is being configured on a
> system that supports vanilla SVE this is not an issue since we always
> initialise enough state for both vector lengths but on a system which only
> support SME it will result in us attempting to restore the SVE vector
> length after having set streaming SVE registers.
>
> Fix this by making the enabling of SVE conditional on setting SVE vector
> state. If we set streaming SVE state and SVE was not already enabled this
> will result in a SVE access trap on next use of normal SVE, this will cause
> us to flush our register state but this is fine since the only way to
> trigger a SVE access trap would be to exit streaming mode which will cause
> the in register state to be flushed anyway.
>
> Fixes: e12310a0d30f ("arm64/sme: Implement ptrace support for streaming mode SVE registers")
> Signed-off-by: Mark Brown <broonie@kernel.org>
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/r/20230803-arm64-fix-ptrace-ssve-no-sve-v1-1-49df214bfb3e@kernel.org
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> (cherry picked from commit 045aecdfcb2e060db142d83a0f4082380c465d2c)
> [Fix up backport -- broonie]
> Signed-off-by: Mark Brown <broonie@kernel.org>
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-09 9:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-07 7:07 FAILED: patch "[PATCH] arm64/ptrace: Don't enable SVE when setting streaming SVE" failed to apply to 6.1-stable tree gregkh
2023-08-07 19:56 ` [PATCH 6.1.y] arm64/ptrace: Don't enable SVE when setting streaming SVE Mark Brown
2023-08-09 9:07 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox