SMP Problem on i386
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Aug 5 10:05:21 UTC 2013
Hello,
I found the problem. The startup code for secondary processor uses this
(smp-imps.c):
static int
boot_cpu(imps_processor *proc)
{
[...]
reset[1] = (uint32_t)secondary_cpu_initialize;
reset[2] = (uint32_t)_Per_CPU_Get_by_index(apicid)->interrupt_stack_high;
[...]
Thus the startup code uses the interrupt stack of the processor.
In _CPU_Context_switch we have:
SYM (_CPU_Context_switch):
movl RUNCONTEXT_ARG(esp),eax /* eax = running threads context */
pushf /* push eflags */
popl REG_EFLAGS(eax) /* save eflags */
movl esp,REG_ESP(eax) /* save stack pointer */
movl ebp,REG_EBP(eax) /* save base pointer */
movl ebx,REG_EBX(eax) /* save ebx */
movl esi,REG_ESI(eax) /* save source register */
movl edi,REG_EDI(eax) /* save destination register */
movl HEIRCONTEXT_ARG(esp),eax /* eax = heir threads context */
restore:
pushl REG_EFLAGS(eax) /* push eflags */
popf /* restore eflags */
movl REG_ESP(eax),esp /* restore stack pointer */
movl REG_EBP(eax),ebp /* restore base pointer */
movl REG_EBX(eax),ebx /* restore ebx */
movl REG_ESI(eax),esi /* restore source register */
movl REG_EDI(eax),edi /* restore destination register */
ret
The eflags are restored before the stack pointer restore. Thus in case an
interrupt is pending this interrupt will store the thread context on the stack
which it will use later destroying this context!
On 2013-07-30 17:51, Sebastian Huber wrote:
> Hello,
>
> if I apply the following patch
>
> diff --git a/cpukit/score/include/rtems/bspsmp.h
> b/cpukit/score/include/rtems/bspsmp.h
> index ec8be9f..69cbff4 100644
> --- a/cpukit/score/include/rtems/bspsmp.h
> +++ b/cpukit/score/include/rtems/bspsmp.h
> @@ -104,8 +104,7 @@ void bsp_smp_broadcast_interrupt(void);
> * This function must not be called by the main processor. This function does
> * not return to the caller.
> */
> -void rtems_smp_secondary_cpu_initialize( void )
> - RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
> +void rtems_smp_secondary_cpu_initialize( void );
>
> /**
> * @brief Process the incoming interprocessor request.
>
> then the i386 SMP test cases fail on Qemu. I get a General Protection Fault
> after the "iret" in _ISR_Handler.
>
> What could be the reason for this?
>
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the devel
mailing list