-
Notifications
You must be signed in to change notification settings - Fork 1.5k
arch: armv7-a: Fix memory corruption in SMP mode #3265
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
Conversation
|
armv7-a/arm_vectors.S: Assembler messages: armv7-a/arm_vectors.S: Line 108, This marco "cpuindex" don't used when enable CONFIG_SMP |
|
Which configuration are you using? |
In our own project, it used A7 SMP. and apply this patch, the compile is broken. |
Perhaps, your project does not set CONFIG_ARCH_INTERRUPTSTACK. |
Yes, we set CONFIG_ARCH_INTERRUPTSTACK=0, and CONFIG_SMP=y, and this cpuindex don't find. |
OK, I've just fixed for imx6 case. |
Yes, i try it. Thank you. |
jerpelea
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
arch/arm/src/armv7-a/arm_cpustart.c
Outdated
|
|
||
| /* Set IRQ mode stack for this CPU */ | ||
|
|
||
| set_irqstack((uintptr_t)&g_irqtmp + (8 * this_cpu())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not move to arm_vectors.S?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's difficult to write the same thing in assembler at the beginning of arm_vectorirq().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will study the code tonight to find wether can fix the bug in assemble code, will give the feedback tomorrow.
|
@masayuki2009 I enable ARM_THUMB, complie break: {standard input}: Assembler messages: |
arch/arm/src/armv7-a/arm_vectors.S
Outdated
| ldr r0, .Lirqtmp /* Points to temp storage */ | ||
|
|
||
| #ifdef CONFIG_SMP | ||
| cpuindex r1 /* r1 = cpuindex */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible directly get cpuindex?
mrc CP15_MPIDR(r1) /* Get R1=MPIDR /
and r1, r1, #MPIDR_CPUID_MASK
mov r1, r1, lsl #MPIDR_CPUID_SHIFT / r1 = cpuindex */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want not to use the macro?
|
Converted to Draft, waiting until @xiaoxiang781216 verify if it can be fixed in assembly code |
|
Hmmm, Lint failed... error pulling image configuration: received unexpected HTTP status: 503 No healthy IP available for the backend |
|
Hmm, Download action repository 'actions/download-artifact@v1' |
|
@xiaoxiang781216 @Donny9 is it working now? May we merge it? |
|
I am working on this, and will provide a update tonight or tomorrow morning. |
|
I rebased the branch and fixed conflicts. |
|
Refactor the inline assembly code in the set_irqstack() |
|
@masayuki2009 , I will take a look tonight. |
|
|
||
| .globl g_irqtmp | ||
|
|
||
| g_irqtmp: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid use the temporary storage? so SMP get resolved automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I also tried to remove the temporary storage but I was not able to find how to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have an idea that:
- Switch to SVC mode directly in the entry point
- Save some registers to stack
- Switch back IRQ/FIQ/ABT/UND mode
- Read LR/SPRS register
- Switch to SVC mode again
Step 4 should has enough free registers saved at step 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will try this afternoon. We hit the same issue on dual Cortex-A7 SoC.
Summary: - During the stress test with sabre-6quad:smp (QEMU), I noticed that sometimes prefetch abort happens. - Finally, I found that g_irqtmp is corrupted. - This commit fixes this issue with the following changes - Allocate g_irqtmp for all CPUs - Load g_irqtmp only once in arm_vectorirq() - In SMP mode, the IRQ mode stack is set in arm_start_handler() - Also, access to the g_irqtmp is adjusted in arm_vectorirq() - Apply the same logic to FIQ/ABORT/UNDEF stacks Impact: - IRQ/FIQ/ABORT/UNDEF handling for armv7-a Testing: - Tested with the following configs - sabre-6quad:smp (QEMU, dev board) - sabre-6quad:netnsh (QEMU) Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
…ACK=0 Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
|
@masayuki2009 could you try this patch #3451? |
|
#3451 resolved this issue. |
Summary
that sometimes prefetch abort happens.
Impact
Testing