mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
LoongArch: Ensure FP/SIMD registers in the core dump file is up to date
[ Upstream commit656f9aec07
] This is a port of commit379eb01c21
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
ccdfcb9119
commit
95c5d3fbd3
2 changed files with 20 additions and 4 deletions
|
@ -117,16 +117,30 @@ static inline void restore_fp(struct task_struct *tsk)
|
||||||
_restore_fp(&tsk->thread.fpu);
|
_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) {
|
if (tsk == current) {
|
||||||
preempt_disable();
|
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);
|
_save_fp(¤t->thread.fpu);
|
||||||
|
|
||||||
preempt_enable();
|
preempt_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
return tsk->thread.fpu.fpr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _ASM_FPU_H */
|
#endif /* _ASM_FPU_H */
|
||||||
|
|
|
@ -147,6 +147,8 @@ static int fpr_get(struct task_struct *target,
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
save_fpu_regs(target);
|
||||||
|
|
||||||
if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t))
|
if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t))
|
||||||
r = gfpr_get(target, &to);
|
r = gfpr_get(target, &to);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue