This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: SVC SPSR overwritten in Arm HAL
>>>>> Pierre Habraken writes:
> Mark Salter wrote:
>> [...]
>> The bne has more of an impact (due to the pipeline) than a simple
>> instruction. I think the code should look like this:
>>
>> // return to supervisor mode is simple
>> and r1,r0,#CPSR_MODE_BITS
>> cmp r1,#CPSR_SUPERVISOR_MODE
>> msreq cpsr, r0
>> ldmeqfd sp, {r0-r14, pc}
>> msr spsr, r0
>> ...
>>
>> Cancelling two insns because of condition codes is generally cheaper
>> than branching around them. This adds extra overhead to the return to
>> SVC mode case and only one insn in the other (much less likely) case.
> You are right, but, in case we return to svc mode, the code above makes
> the cpsr and its condition code flags being restored to their
> pre-exception value ; thus the execution of the ldmeqfd instruction will
> be based on an erroneous condition....
Ahh, right. So, it looks like the branch will have to stay.
--Mark