I'm doing some testing on Exynos5422 SoC which implements big.LITTLE architecture (A7 + A15), I'm running bare metal application which starts in HYP mode. I haven't returned from HYP mode by accident and then software delay which I implemented by simple for loop was significantly (about 40 times) longer than in SVC mode. Compiler settings are same in both cases. And only difference is in boot code. This is code for loop:
void delay_some_time(){ for (int i = 0; i < 100000000; i++) { __asm("nop");}
void delay_some_time()
{
for (int i = 0; i < 100000000; i++)
__asm("nop");
}
This is boot code:
mrs r0, apsr and r1, r0, #0x1f @ Get processor mode teq r1, #0x1a @ Check for hypervisor mode a: bne x @ Escape if not in hypervisor mode bic r0, r0, #0x1f @ clear all mode bits orr r0, r0, #0x13 @ set SVC mode ldr r1, =x msr elr_hyp, r1 msr spsr_hyp, r0 eret
mrs r0, apsr
and r1, r0, #0x1f @ Get processor mode
teq r1, #0x1a @ Check for hypervisor mode
a: bne x @ Escape if not in hypervisor mode
bic r0, r0, #0x1f @ clear all mode bits
orr r0, r0, #0x13 @ set SVC mode
ldr r1, =x
msr elr_hyp, r1
msr spsr_hyp, r0
eret
x: [BOOT PROCESS CONTINUES]
On label "a" in case where I run in HYP mode is BEQ instead of BNE. This is the only difference.
I have feeling that this is somehow connected to bootloaders prior to uboot, but still it is strange. What this could be?