Skip to contentSkip to conversation

target/arm: Fix validation of 32-bit address spaces for aa32

PATCH Applied Richard Henderson 2 participants 2 messages Jan 25, 2019 – Jan 28, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Fix validation of 32-bit address spaces for aa32

When tsz == 0, aarch32 selects the address space via exclusion, and there are no "top_bits" remaining that require validation.

---
 target/arm/helper.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
target/arm/helper.c +13 -6
index 92666e5208..e24689f767 100644
@@ -10447,7 +10447,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
     uint64_t ttbr;
     hwaddr descaddr, indexmask, indexmask_grainsize;
     uint32_t tableattrs;
-    target_ulong page_size, top_bits;
+    target_ulong page_size;
     uint32_t attrs;
     int32_t stride;
     int addrsize, inputsize;
@@ -10487,12 +10487,19 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
      * We determined the region when collecting the parameters, but we
      * have not yet validated that the address is valid for the region.
      * Extract the top bits and verify that they all match select.
+     *
+     * For aa32, if inputsize == addrsize, then we have selected the
+     * region by exclusion in aa32_va_parameters and there is no more
+     * validation to do here.
      */
-    top_bits = sextract64(address, inputsize, addrsize - inputsize);
-    if (-top_bits != param.select || (param.select && !ttbr1_valid)) {
-        /* In the gap between the two regions, this is a Translation fault */
-        fault_type = ARMFault_Translation;
-        goto do_fault;
+    if (inputsize < addrsize) {
+        target_ulong top_bits = sextract64(address, inputsize,
+                                           addrsize - inputsize);
+        if (-top_bits != param.select || (param.select && !ttbr1_valid)) {
+            /* The gap between the two regions is a Translation fault */
+            fault_type = ARMFault_Translation;
+            goto do_fault;
+        }
     }
 
     if (param.using64k) {
Signature · 1 line
2.17.1
#1 lore raw
Quoted 10 lines · Richard Henderson

When tsz == 0, aarch32 selects the address space via exclusion, and there are no "top_bits" remaining that require validation.

---
 target/arm/helper.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

Applied to target-arm.next, thanks.

-- PMM