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 irq1 #13520

Merged
merged 5 commits into from
Sep 23, 2024
Merged

Arm64 irq1 #13520

merged 5 commits into from
Sep 23, 2024

Conversation

lipengfei28
Copy link
Contributor

Summary

arm64: simply the vectors

Impact

Testing

@lipengfei28
Copy link
Contributor Author

1. save FPU regs enter exception and retore exit exception every time
2. simp the vectors
3. save sp_el0 enter exception and restore sp_el0 exit exception every time

@lipengfei28 lipengfei28 force-pushed the arm64_irq1 branch 4 times, most recently from 1e1c326 to 2b07421 Compare September 18, 2024 07:04
arch/arm64/src/common/arm64_syscall.c Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_syscall.c Outdated Show resolved Hide resolved
@lipengfei28 lipengfei28 force-pushed the arm64_irq1 branch 3 times, most recently from 2539ba1 to 5d4b00a Compare September 20, 2024 02:03
@github-actions github-actions bot added the Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. label Sep 20, 2024
@lipengfei28 lipengfei28 force-pushed the arm64_irq1 branch 4 times, most recently from 8f7fb07 to 851d7ff Compare September 23, 2024 02:23
@github-actions github-actions bot added the Arch: arm64 Issues related to ARM64 (64-bit) architecture label Sep 23, 2024
qinwei2004 and others added 2 commits September 23, 2024 16:07
Summary
  The original implement for exception handler is very simple and
haven't framework for breakpoint/watchpoint routine or brk instruction.
  I refine the fatal handler and add framework for debug handler to
register or unregister. this is a prepare for watchpoint/breakpoint
implement

Signed-off-by: qinwei1 <[email protected]>
Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@xiaoxiang781216 xiaoxiang781216 merged commit 52a4fb6 into apache:master Sep 23, 2024
29 checks passed

bne exc_handle

#ifdef CONFIG_LIB_SYSCALL
Copy link
Contributor

@pussuw pussuw Sep 23, 2024

Choose a reason for hiding this comment

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

Why exactly was this part changed??? Now you destroy the incoming system call parameter registers x0-x6, and then re-read them from the context wasting massive amounts of CPU time??

WHY WAS THIS CHANGED? I spent days making this optimized system call path to work, please restore this functionality as it was.

* cannot yet handle nested system calls.
*/

regs[REG_X0] = dispatch_syscall(regs[REG_X0], regs[REG_X1],
Copy link
Contributor

@pussuw pussuw Sep 23, 2024

Choose a reason for hiding this comment

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

This is completely unnecessary, the registers x0-x6 are already correct when coming from userspace. There is NO REASON TO READ THEM FROM THE CONTEXT AREA. What I had done is much more optimized than what this does.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another thing this change does; the system call now runs with interrupts disabled, affecting interrupt service latency.

Copy link
Contributor

Choose a reason for hiding this comment

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

@lipengfei28 please take a look.

@jlaitine
Copy link
Contributor

After this PR got merged, nuttx is not compiling any more. I am getting this:

common/arm64_fatal.c:84:30: error: initialized field overwritten [-Werror=override-init]
84 | [ESR_ELX_EC_UNKNOWN] = "Unknown/Uncategorized",
| ^~~~~~~~~~~~~~~~~~~~~~~
common/arm64_fatal.c:84:30: note: (near initialization for 'g_esr_class_str[0]')
common/arm64_fatal.c:85:30: error: initialized field overwritten [-Werror=override-init]
85 | [ESR_ELX_EC_WFX] = "WFI/WFE",
| ^~~~~~~~~
common/arm64_fatal.c:85:30: note: (near initialization for 'g_esr_class_str[1]')
common/arm64_fatal.c:86:30: error: initialized field overwritten [-Werror=override-init]
86 | [ESR_ELX_EC_CP15_32] = "CP15 MCR/MRC",
| ^~~~~~~~~~~~~~
common/arm64_fatal.c:86:30: note: (near initialization for 'g_esr_class_str[3]')
common/arm64_fatal.c:87:30: error: initialized field overwritten [-Werror=override-init]
87 | [ESR_ELX_EC_CP15_64] = "CP15 MCRR/MRRC",
| ^~~~~~~~~~~~~~~~
common/arm64_fatal.c:87:30: note: (near initialization for 'g_esr_class_str[4]')
common/arm64_fatal.c:88:30: error: initialized field overwritten [-Werror=override-init]
88 | [ESR_ELX_EC_CP14_MR] = "CP14 MCR/MRC",
| ^~~~~~~~~~~~~~
common/arm64_fatal.c:88:30: note: (near initialization for 'g_esr_class_str[5]')
common/arm64_fatal.c:89:30: error: initialized field overwritten [-Werror=override-init]
89 | [ESR_ELX_EC_CP14_LS] = "CP14 LDC/STC",
| ^~~~~~~~~~~~~~
common/arm64_fatal.c:89:30: note: (near initialization for 'g_esr_class_str[6]')
common/arm64_fatal.c:90:30: error: initialized field overwritten [-Werror=override-init]
90 | [ESR_ELX_EC_FP_ASIMD] = "ASIMD",

@lipengfei28
Copy link
Contributor Author

commit 8288fe4 (HEAD -> master, apache/master)
Author: chao an [email protected]
Date: Mon Sep 23 08:59:15 2024 +0800

Revert "toolchain/ghs: Fix CONFIG_SCHED_CRITMONITOR_MAXTIME_XXX "zero used for undefined preprocessing identifier" warnings"

move private define to public

This reverts commit 236678d730220138416724d2cab25d6e1bd2ce9d.

Signed-off-by: chao an <[email protected]>

commit a5b85fc
Author: wangjianyu3 [email protected]
Date: Mon Sep 23 18:44:17 2024 +0800

misc/rpmsgdev: Fix invalid pointer error when there are more than one remotes

Test: (see tests/testcases/rpmsgdev for details)
  # 1. Register dummy device
  testdev -d 0 -r "/dev/ttyGNSS0"
  # 2. Call rpmsgdev_export() to export the device to remote
  testdev -d 2 -c "droid" -l "/dev/ttyGNSS0"

Log:
  [ap] arm_busfault: PANIC!!! Bus Fault:
  [ap] arm_busfault:        IRQ: 5 regs: 0x3c434e44
  [ap] arm_busfault:        BASEPRI: 00000000 PRIMASK: 00000000 IPSR: 00000005 CONTROL: 00000004
  [ap] arm_busfault:        CFSR: 00008200 HFSR: 00000000 DFSR: 00000000 BFAR: 00000000 AFSR: 00040000
  [ap] arm_busfault: Bus Fault Reason:
  [ap] arm_busfault:        Precise data bus error
  [ap] dump_assert_info: Current Version: NuttX ****** ***** *** 12.3.0 ********** Sep 23 2024 18:35:50 arm
  [ap] dump_assert_info: Assertion failed panic: at file: armv8-m/arm_busfault.c:113 task: testdev process: testdev 0x2c86ca75

This commit build is ok

@jlaitine
Copy link
Contributor

This PR seems problematic also for the performance; what is the reason for example for saving the FPU registers every time? Before this PR we had well working and performant arm64 in both flat and kernel builds (and extensively using FPU as well).

Or why to execute system calls with interrupts disabled? That is clearly wrong.

Can you please explain what is the problem this PR is trying to solve? Just to break everything for fun?

Sorry to be negative, but I don't see any benefits in breaking things like this, please explain!

@jlaitine
Copy link
Contributor

FYI: I managed to get things running in our own branches again by reverting everything in this PR except for e38f2b2

@xiaoxiang781216
Copy link
Contributor

let's revert this patch first and refine the change later.

@jlaitine
Copy link
Contributor

The idea in "arm64: refine the fatal handler" is good; I'd suggest making a separate PR of that one, on top of the existing implementation.

@xiaoxiang781216
Copy link
Contributor

@GUIDINGLI will resend the patch again.

@GUIDINGLI
Copy link
Contributor

@jlaitine @pussuw
#13652

@pussuw
Copy link
Contributor

pussuw commented Sep 26, 2024

@jlaitine @pussuw #13652

I'll take a look tomorrow, thanks

#if CONFIG_ARCH_ARM64_EXCEPTION_LEVEL == 3
mrs x0, esr_el3
/* Switch to IRQ stack and save current sp on it. */
#ifdef CONFIG_SMP
Copy link
Contributor

Choose a reason for hiding this comment

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

@GUIDINGLI I assume this is the code that SMP needs ? I can adapt this part so that kernel mode works like before. I'll try to provide a patch tomorrow, or on Monday.

Copy link
Contributor

Choose a reason for hiding this comment

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

good

@@ -299,6 +299,9 @@ struct regs_context
uint64_t spsr;
uint64_t sp_el0;
uint64_t exe_depth;
#ifdef CONFIG_ARCH_FPU
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the content of this patch needed by SMP too ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The removable of FPU trap reason:

  1. The FPU trap logic is not stable in some SMP situation (HERE haven't the detail analysis)
  2. Make the logic Complex and different to read.
  3. The most important reason: it has almost no benefit for the performance, because the compiler will optimize the code with float/double instructions when use the option -O3 (always be). Even the printf/syslog will use use the FPU, so the FPU is used too often and almost each context switch.
    Or, you must use -mgeneral-regs-only to limit the FPU registers usage, that will harmful for the speed.
  4. How about use the FPU registers in the IRQ/SVC ISR, maybe there are hidden bugs ?

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: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants