target-arm: Forbid mode switch to Mon from Secure EL1

In v8 trying to switch mode to Mon from Secure EL1 is an
illegal mode switch. (In v7 this is impossible as all secure
modes except User are at EL3.) We can handle this case by
making a switch to Mon valid only if the current EL is 3,
which then gives the correct answer whether EL3 is AArch32
or AArch64.

Backports commit 58ae2d1f037fae1d90eed4522053a85d79edfbec from qemu
This commit is contained in:
Peter Maydell 2018-02-20 22:21:08 -05:00 committed by Lioncash
parent 4919c7287c
commit 2296fb5915
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -4525,7 +4525,7 @@ static int bad_mode_switch(CPUARMState *env, int mode)
return !arm_feature(env, ARM_FEATURE_EL2)
|| arm_current_el(env) < 2 || arm_is_secure(env);
case ARM_CPU_MODE_MON:
return !arm_is_secure(env);
return arm_current_el(env) < 3;
default:
return 1;
}