On 21 March 2016 at 17:53, Cohen, Eugene <[email protected]> wrote:
> Alexei and Ard,
>
>> The suggested code for EL1_OR_EL2 macro:
>>
>> mrs SAFE_XREG, CurrentEL ;\
>> cmp SAFE_XREG, #0x8 ;\
>> b.eq 2f ;\
>> tbnz SAFE_XREG, #2, 1f ;\
>> b . ;// We should never get here
>>
>> will successfully branch to 1f label in case of EL3 with SAFE_XREG = 0xC
>> because bit #2 will be set.
>
> Agreed. If you assume that EL1_OR_EL2 can never be invoked at EL3 then
> obviously this wouldn't be a concern. But since there's already a case for
> handling neither EL1 nor EL2 (b .) then it would make sense to correct this
> so if it was accidentally used in EL3 it would hit the default case which is
> better for debugability. The last tbnz needs to be reverted to the previous
> cmp/b.ne construct or equivalent.
>
Thanks for spotting that. I committed it as follows:
// CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1
// This only selects between EL1 and EL2, else we die.
// Provide the Macro with a safe temp xreg to use.
#define EL1_OR_EL2(SAFE_XREG) \
mrs SAFE_XREG, CurrentEL ;\
cmp SAFE_XREG, #0x8 ;\
b.gt . ;\
b.eq 2f ;\
cbnz SAFE_XREG, 1f ;\
b . ;// We should never get here
// CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1
// This only selects between EL1 and EL2 and EL3, else we die.
// Provide the Macro with a safe temp xreg to use.
#define EL1_OR_EL2_OR_EL3(SAFE_XREG) \
mrs SAFE_XREG, CurrentEL ;\
cmp SAFE_XREG, #0x8 ;\
b.gt 3f ;\
b.eq 2f ;\
cbnz SAFE_XREG, 1f ;\
b . ;// We should never get here
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel