Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm64/SMP: Fix FPU and exception handling for ARM64 #13695

Merged
merged 4 commits into from
Oct 2, 2024

Conversation

pussuw
Copy link
Contributor

@pussuw pussuw commented Sep 27, 2024

Summary

Fix FPU and exception handling for ARM64 by:

  • Saving and restoring FPU state on every exception / interrupt
  • Switching to the interrupt stack, when executing the exception handler / interrupt service routine

This is a continuation of: #13520
@GUIDINGLI and @lipengfei28 Did the initial patches, which are adapted for CONFIG_BUILD_KERNEL / CONFIG_LIB_SYSCALL, which were implemented by me. The goal is to merge this work without breaking either one.

Impact

Impact is on ARM64 platform only. The impacted parts are the exception and ISR handling.

Testing

qemu-armv8a:nsh
qemu-armv8a:nsh_smp
qemu-armv8a:knsh

@pussuw pussuw marked this pull request as draft September 27, 2024 14:03
@github-actions github-actions bot added Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: L The size of the change in this PR is large labels Sep 27, 2024
@pussuw
Copy link
Contributor Author

pussuw commented Sep 27, 2024

@GUIDINGLI the adaptation with #13520 is almost done. Flat mode nsh and nsh_smp both work, knsh doesn't work yet due to how SP_EL0 handling was changed.

Can you please take a look that the SMP issue you mentioned is OK with these changes? I'll fix the kernel mode issue on Monday.

GUIDINGLI and others added 4 commits October 1, 2024 13:11
As the handling of sp_el0 was moved from the context switch routine
to exception entry/exit, we must set sp_el0 explicitly when the user
process is first started.
@pussuw pussuw marked this pull request as ready for review October 1, 2024 10:52
@pussuw
Copy link
Contributor Author

pussuw commented Oct 1, 2024

SP_EL0 handling is now also fixed. Tested with:
qemu-armv8a:nsh
qemu-armv8a:nsh_smp
qemu-armv8a:knsh
Downstream imx9 with both with flat and kernel mode, with ~50 processes + threads running

sizeof(struct arm64_cpu_fpu_context));
g_cpu_fpu_ctx[cpu].idle_thread = tcb;

tcb->xcp.fpu_regs = (uint64_t *)&g_idle_thread_fpu[cpu];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

  • tcb->xcp.fpu_regs
  • tcb->xcp.fpu_saved_regs

what should we do with those ?

@xiaoxiang781216 xiaoxiang781216 merged commit 24c931c into apache:master Oct 2, 2024
29 checks passed
@pussuw pussuw deleted the arm64_smp_irqstack_fix branch October 2, 2024 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: L The size of the change in this PR is large
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants