* FAILED: patch "[PATCH] LoongArch: Ensure FP/SIMD registers in the core dump file is" failed to apply to 6.4-stable tree
@ 2023-08-27 6:45 gregkh
2023-08-27 8:23 ` Huacai Chen
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2023-08-27 6:45 UTC (permalink / raw)
To: chenhuacai, chenhuacai; +Cc: stable
The patch below does not apply to the 6.4-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.4.y
git checkout FETCH_HEAD
git cherry-pick -x 656f9aec07dba7c61d469727494a5d1b18d0bef4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023082705-predator-enjoyable-15fb@gregkh' --subject-prefix 'PATCH 6.4.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 656f9aec07dba7c61d469727494a5d1b18d0bef4 Mon Sep 17 00:00:00 2001
From: Huacai Chen <chenhuacai@kernel.org>
Date: Sat, 26 Aug 2023 22:21:57 +0800
Subject: [PATCH] LoongArch: Ensure FP/SIMD registers in the core dump file is
up to date
This is a port of commit 379eb01c21795edb4c ("riscv: Ensure the value
of FP registers in the core dump file is up to date").
The values of FP/SIMD registers in the core dump file come from the
thread.fpu. However, kernel saves the FP/SIMD registers only before
scheduling out the process. If no process switch happens during the
exception handling, kernel will not have a chance to save the latest
values of FP/SIMD registers. So it may cause their values in the core
dump file incorrect. To solve this problem, force fpr_get()/simd_get()
to save the FP/SIMD registers into the thread.fpu if the target task
equals the current task.
Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h
index b541f6248837..c2d8962fda00 100644
--- a/arch/loongarch/include/asm/fpu.h
+++ b/arch/loongarch/include/asm/fpu.h
@@ -173,16 +173,30 @@ static inline void restore_fp(struct task_struct *tsk)
_restore_fp(&tsk->thread.fpu);
}
-static inline union fpureg *get_fpu_regs(struct task_struct *tsk)
+static inline void save_fpu_regs(struct task_struct *tsk)
{
+ unsigned int euen;
+
if (tsk == current) {
preempt_disable();
- if (is_fpu_owner())
+
+ euen = csr_read32(LOONGARCH_CSR_EUEN);
+
+#ifdef CONFIG_CPU_HAS_LASX
+ if (euen & CSR_EUEN_LASXEN)
+ _save_lasx(¤t->thread.fpu);
+ else
+#endif
+#ifdef CONFIG_CPU_HAS_LSX
+ if (euen & CSR_EUEN_LSXEN)
+ _save_lsx(¤t->thread.fpu);
+ else
+#endif
+ if (euen & CSR_EUEN_FPEN)
_save_fp(¤t->thread.fpu);
+
preempt_enable();
}
-
- return tsk->thread.fpu.fpr;
}
static inline int is_simd_owner(void)
diff --git a/arch/loongarch/kernel/ptrace.c b/arch/loongarch/kernel/ptrace.c
index a0767c3a0f0a..f72adbf530c6 100644
--- a/arch/loongarch/kernel/ptrace.c
+++ b/arch/loongarch/kernel/ptrace.c
@@ -147,6 +147,8 @@ static int fpr_get(struct task_struct *target,
{
int r;
+ save_fpu_regs(target);
+
if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t))
r = gfpr_get(target, &to);
else
@@ -278,6 +280,8 @@ static int simd_get(struct task_struct *target,
{
const unsigned int wr_size = NUM_FPU_REGS * regset->size;
+ save_fpu_regs(target);
+
if (!tsk_used_math(target)) {
/* The task hasn't used FP or LSX, fill with 0xff */
copy_pad_fprs(target, regset, &to, 0);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] LoongArch: Ensure FP/SIMD registers in the core dump file is" failed to apply to 6.4-stable tree
2023-08-27 6:45 FAILED: patch "[PATCH] LoongArch: Ensure FP/SIMD registers in the core dump file is" failed to apply to 6.4-stable tree gregkh
@ 2023-08-27 8:23 ` Huacai Chen
2023-08-27 8:37 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Huacai Chen @ 2023-08-27 8:23 UTC (permalink / raw)
To: gregkh; +Cc: chenhuacai, stable
On Sun, Aug 27, 2023 at 2:45 PM <gregkh@linuxfoundation.org> wrote:
>
>
> The patch below does not apply to the 6.4-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.4.y
> git checkout FETCH_HEAD
> git cherry-pick -x 656f9aec07dba7c61d469727494a5d1b18d0bef4
> # <resolve conflicts, build, test, etc.>
> git commit -s
> git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023082705-predator-enjoyable-15fb@gregkh' --subject-prefix 'PATCH 6.4.y' HEAD^..
>
> Possible dependencies:
I'm sorry, this is my mistake. 6.4 also need to cut the simd_get()
part, because simd is only supported since 6.5
Huacai
>
>
>
> thanks,
>
> greg k-h
>
> ------------------ original commit in Linus's tree ------------------
>
> From 656f9aec07dba7c61d469727494a5d1b18d0bef4 Mon Sep 17 00:00:00 2001
> From: Huacai Chen <chenhuacai@kernel.org>
> Date: Sat, 26 Aug 2023 22:21:57 +0800
> Subject: [PATCH] LoongArch: Ensure FP/SIMD registers in the core dump file is
> up to date
>
> This is a port of commit 379eb01c21795edb4c ("riscv: Ensure the value
> of FP registers in the core dump file is up to date").
>
> The values of FP/SIMD registers in the core dump file come from the
> thread.fpu. However, kernel saves the FP/SIMD registers only before
> scheduling out the process. If no process switch happens during the
> exception handling, kernel will not have a chance to save the latest
> values of FP/SIMD registers. So it may cause their values in the core
> dump file incorrect. To solve this problem, force fpr_get()/simd_get()
> to save the FP/SIMD registers into the thread.fpu if the target task
> equals the current task.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
>
> diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h
> index b541f6248837..c2d8962fda00 100644
> --- a/arch/loongarch/include/asm/fpu.h
> +++ b/arch/loongarch/include/asm/fpu.h
> @@ -173,16 +173,30 @@ static inline void restore_fp(struct task_struct *tsk)
> _restore_fp(&tsk->thread.fpu);
> }
>
> -static inline union fpureg *get_fpu_regs(struct task_struct *tsk)
> +static inline void save_fpu_regs(struct task_struct *tsk)
> {
> + unsigned int euen;
> +
> if (tsk == current) {
> preempt_disable();
> - if (is_fpu_owner())
> +
> + euen = csr_read32(LOONGARCH_CSR_EUEN);
> +
> +#ifdef CONFIG_CPU_HAS_LASX
> + if (euen & CSR_EUEN_LASXEN)
> + _save_lasx(¤t->thread.fpu);
> + else
> +#endif
> +#ifdef CONFIG_CPU_HAS_LSX
> + if (euen & CSR_EUEN_LSXEN)
> + _save_lsx(¤t->thread.fpu);
> + else
> +#endif
> + if (euen & CSR_EUEN_FPEN)
> _save_fp(¤t->thread.fpu);
> +
> preempt_enable();
> }
> -
> - return tsk->thread.fpu.fpr;
> }
>
> static inline int is_simd_owner(void)
> diff --git a/arch/loongarch/kernel/ptrace.c b/arch/loongarch/kernel/ptrace.c
> index a0767c3a0f0a..f72adbf530c6 100644
> --- a/arch/loongarch/kernel/ptrace.c
> +++ b/arch/loongarch/kernel/ptrace.c
> @@ -147,6 +147,8 @@ static int fpr_get(struct task_struct *target,
> {
> int r;
>
> + save_fpu_regs(target);
> +
> if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t))
> r = gfpr_get(target, &to);
> else
> @@ -278,6 +280,8 @@ static int simd_get(struct task_struct *target,
> {
> const unsigned int wr_size = NUM_FPU_REGS * regset->size;
>
> + save_fpu_regs(target);
> +
> if (!tsk_used_math(target)) {
> /* The task hasn't used FP or LSX, fill with 0xff */
> copy_pad_fprs(target, regset, &to, 0);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] LoongArch: Ensure FP/SIMD registers in the core dump file is" failed to apply to 6.4-stable tree
2023-08-27 8:23 ` Huacai Chen
@ 2023-08-27 8:37 ` Greg KH
2023-08-27 8:45 ` Huacai Chen
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2023-08-27 8:37 UTC (permalink / raw)
To: Huacai Chen; +Cc: chenhuacai, stable
On Sun, Aug 27, 2023 at 04:23:35PM +0800, Huacai Chen wrote:
> On Sun, Aug 27, 2023 at 2:45 PM <gregkh@linuxfoundation.org> wrote:
> >
> >
> > The patch below does not apply to the 6.4-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.4.y
> > git checkout FETCH_HEAD
> > git cherry-pick -x 656f9aec07dba7c61d469727494a5d1b18d0bef4
> > # <resolve conflicts, build, test, etc.>
> > git commit -s
> > git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023082705-predator-enjoyable-15fb@gregkh' --subject-prefix 'PATCH 6.4.y' HEAD^..
> >
> > Possible dependencies:
> I'm sorry, this is my mistake. 6.4 also need to cut the simd_get()
> part, because simd is only supported since 6.5
I do not understand, sorry. Is this relevant for 6.4.y? If so, can you
provide a working backport?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] LoongArch: Ensure FP/SIMD registers in the core dump file is" failed to apply to 6.4-stable tree
2023-08-27 8:37 ` Greg KH
@ 2023-08-27 8:45 ` Huacai Chen
0 siblings, 0 replies; 4+ messages in thread
From: Huacai Chen @ 2023-08-27 8:45 UTC (permalink / raw)
To: Greg KH; +Cc: chenhuacai, stable
On Sun, Aug 27, 2023 at 4:38 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Sun, Aug 27, 2023 at 04:23:35PM +0800, Huacai Chen wrote:
> > On Sun, Aug 27, 2023 at 2:45 PM <gregkh@linuxfoundation.org> wrote:
> > >
> > >
> > > The patch below does not apply to the 6.4-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.4.y
> > > git checkout FETCH_HEAD
> > > git cherry-pick -x 656f9aec07dba7c61d469727494a5d1b18d0bef4
> > > # <resolve conflicts, build, test, etc.>
> > > git commit -s
> > > git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023082705-predator-enjoyable-15fb@gregkh' --subject-prefix 'PATCH 6.4.y' HEAD^..
> > >
> > > Possible dependencies:
> > I'm sorry, this is my mistake. 6.4 also need to cut the simd_get()
> > part, because simd is only supported since 6.5
>
> I do not understand, sorry. Is this relevant for 6.4.y? If so, can you
> provide a working backport?
Sorry to bother you. Please give up backporting this patch, I found
that there are some dependencies but they shouldn't be backported to
stable branches.
Sorry for that again.
Huacai
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-27 8:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-27 6:45 FAILED: patch "[PATCH] LoongArch: Ensure FP/SIMD registers in the core dump file is" failed to apply to 6.4-stable tree gregkh
2023-08-27 8:23 ` Huacai Chen
2023-08-27 8:37 ` Greg KH
2023-08-27 8:45 ` Huacai Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox