Skip to contentSkip to conversation

riscv: Ensure the value of FP registers in the core dump file is up to date

PATCH Superseded Vincent Chen 1 participant 1 message Aug 3, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Ensure the value of FP registers in the core dump file is up to date

The value of FP registers in the core dump file comes from the thread.fstate. However, kernel saves the FP registers to the thread.fstate only before scheduling out the process. If no process switch happens during the exception handling process, kernel will not have a chance to save the latest value of FP registers to thread.fstate. It will cause the value of FP registers in the core dump file may be incorrect. To solve this problem, this patch force lets kernel save the FP register into the thread.fstate if the target task_struct equals the current.

---
 arch/riscv/kernel/ptrace.c | 3 +++
 1 file changed, 3 insertions(+)
arch/riscv/kernel/ptrace.c +3 -0
index c54cafb569b2..1a0dffc61f9f 100644
@@ -60,6 +60,9 @@ static int riscv_fpr_get(struct task_struct *target,
 {
 	struct __riscv_d_ext_state *fstate = &target->thread.fstate;
 
+	if (target == current)
+		fstate_save(current, task_pt_regs(current));
+
 	membuf_write(&to, fstate, offsetof(struct __riscv_d_ext_state, fcsr));
 	membuf_store(&to, fstate->fcsr);
 	return membuf_zero(&to, 4);	// explicitly pad
Signature · 7 lines
2.32.0


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv