mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
target/arm: Provide accessor functions for HCR_EL2.{IMO, FMO, AMO}
The IMO, FMO and AMO bits in HCR_EL2 are defined to "behave as 1 for all purposes other than direct reads" if HCR_EL2.TGE is set and HCR_EL2.E2H is 0, and to "behave as 0 for all purposes other than direct reads" if HCR_EL2.TGE is set and HRC_EL2.E2H is 1. To avoid having to check E2H and TGE everywhere where we test IMO and FMO, provide accessors arm_hcr_el2_imo(), arm_hcr_el2_fmo()and arm_hcr_el2_amo(). We don't implement ARMv8.1-VHE yet, so the E2H case will never be true, but we include the logic to save effort when we eventually do get to that. (Note that in several of these callsites the change doesn't actually make a difference as either the callsite is handling TGE specially anyway, or the CPU can't get into that situation with TGE set; we change everywhere for consistency.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20180724115950.17316-5-peter.maydell@linaro.org
This commit is contained in:
parent
7556edfb4d
commit
ac656b166b
3 changed files with 71 additions and 18 deletions
|
@ -85,7 +85,10 @@ static bool icv_access(CPUARMState *env, int hcr_flags)
|
|||
* * access if NS EL1 and either IMO or FMO == 1:
|
||||
* CTLR, DIR, PMR, RPR
|
||||
*/
|
||||
return (env->cp15.hcr_el2 & hcr_flags) && arm_current_el(env) == 1
|
||||
bool flagmatch = ((hcr_flags & HCR_IMO) && arm_hcr_el2_imo(env)) ||
|
||||
((hcr_flags & HCR_FMO) && arm_hcr_el2_fmo(env));
|
||||
|
||||
return flagmatch && arm_current_el(env) == 1
|
||||
&& !arm_is_secure_below_el3(env);
|
||||
}
|
||||
|
||||
|
@ -1549,8 +1552,8 @@ static void icc_dir_write(CPUARMState *env, const ARMCPRegInfo *ri,
|
|||
/* No need to include !IsSecure in route_*_to_el2 as it's only
|
||||
* tested in cases where we know !IsSecure is true.
|
||||
*/
|
||||
route_fiq_to_el2 = env->cp15.hcr_el2 & HCR_FMO;
|
||||
route_irq_to_el2 = env->cp15.hcr_el2 & HCR_IMO;
|
||||
route_fiq_to_el2 = arm_hcr_el2_fmo(env);
|
||||
route_irq_to_el2 = arm_hcr_el2_imo(env);
|
||||
|
||||
switch (arm_current_el(env)) {
|
||||
case 3:
|
||||
|
@ -1893,7 +1896,7 @@ static CPAccessResult gicv3_irqfiq_access(CPUARMState *env,
|
|||
switch (el) {
|
||||
case 1:
|
||||
if (arm_is_secure_below_el3(env) ||
|
||||
((env->cp15.hcr_el2 & (HCR_IMO | HCR_FMO)) == 0)) {
|
||||
(arm_hcr_el2_imo(env) == 0 && arm_hcr_el2_fmo(env) == 0)) {
|
||||
r = CP_ACCESS_TRAP_EL3;
|
||||
}
|
||||
break;
|
||||
|
@ -1933,7 +1936,7 @@ static CPAccessResult gicv3_dir_access(CPUARMState *env,
|
|||
static CPAccessResult gicv3_sgi_access(CPUARMState *env,
|
||||
const ARMCPRegInfo *ri, bool isread)
|
||||
{
|
||||
if ((env->cp15.hcr_el2 & (HCR_IMO | HCR_FMO)) &&
|
||||
if ((arm_hcr_el2_imo(env) || arm_hcr_el2_fmo(env)) &&
|
||||
arm_current_el(env) == 1 && !arm_is_secure_below_el3(env)) {
|
||||
/* Takes priority over a possible EL3 trap */
|
||||
return CP_ACCESS_TRAP_EL2;
|
||||
|
@ -1958,8 +1961,7 @@ static CPAccessResult gicv3_fiq_access(CPUARMState *env,
|
|||
if (env->cp15.scr_el3 & SCR_FIQ) {
|
||||
switch (el) {
|
||||
case 1:
|
||||
if (arm_is_secure_below_el3(env) ||
|
||||
((env->cp15.hcr_el2 & HCR_FMO) == 0)) {
|
||||
if (arm_is_secure_below_el3(env) || !arm_hcr_el2_fmo(env)) {
|
||||
r = CP_ACCESS_TRAP_EL3;
|
||||
}
|
||||
break;
|
||||
|
@ -1998,8 +2000,7 @@ static CPAccessResult gicv3_irq_access(CPUARMState *env,
|
|||
if (env->cp15.scr_el3 & SCR_IRQ) {
|
||||
switch (el) {
|
||||
case 1:
|
||||
if (arm_is_secure_below_el3(env) ||
|
||||
((env->cp15.hcr_el2 & HCR_IMO) == 0)) {
|
||||
if (arm_is_secure_below_el3(env) || !arm_hcr_el2_imo(env)) {
|
||||
r = CP_ACCESS_TRAP_EL3;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue