From 3ea1b2a84cf1866b0c421c6e45ebb4eaaf76b667 Mon Sep 17 00:00:00 2001 From: "Edgar E. Iglesias" Date: Mon, 19 Feb 2018 01:21:56 -0500 Subject: [PATCH] target-arm: Implement the S2 MMU inputsize > pamax check Implement the inputsize > pamax check for Stage 2 translations. This is CONSTRAINED UNPREDICTABLE and we choose to fault. Backports commit 3526423e867765568ad95b8094ae8b4042cac215 from qemu --- qemu/target-arm/helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qemu/target-arm/helper.c b/qemu/target-arm/helper.c index 37b37fe1..ea972f2a 100644 --- a/qemu/target-arm/helper.c +++ b/qemu/target-arm/helper.c @@ -6137,6 +6137,7 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, } if (is_aa64) { + CPUARMState *env = &cpu->env; unsigned int pamax = arm_pamax(cpu); switch (stride) { @@ -6158,6 +6159,13 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, default: g_assert_not_reached(); } + + /* Inputsize checks. */ + if (inputsize > pamax && + (arm_el_is_aa64(env, 1) || inputsize > 40)) { + /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. */ + return false; + } } else { /* AArch32 only supports 4KB pages. Assert on that. */ assert(stride == 9);