Skip to contentSkip to conversation

target/arm: fix stage 2 page-walks in 32-bit emulation

PATCH In review Rémi Denis-Courmont 3 participants 3 messages Nov 18, 2020 – Nov 20, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: fix stage 2 page-walks in 32-bit emulation

From: Rémi Denis-Courmont <[email protected]>

Using a target unsigned long would limit the Input Address to a LPAE page-walk to 32 bits on AArch32 and 64 bits on AArch64. This is okay for stage 1 or on AArch64, but it is insufficient for stage 2 on AArch32. In that later case, the Input Address can have up to 40 bits.

---
 target/arm/helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/arm/helper.c +2 -2
index 11b0803df7..38cd35c049 100644
@@ -40,7 +40,7 @@
 
 #ifndef CONFIG_USER_ONLY
 
-static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
+static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
                                MMUAccessType access_type, ARMMMUIdx mmu_idx,
                                bool s1_is_el0,
                                hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
@@ -10988,7 +10988,7 @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va,
  * @fi: set to fault info if the translation fails
  * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
  */
-static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
+static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
                                MMUAccessType access_type, ARMMMUIdx mmu_idx,
                                bool s1_is_el0,
                                hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Rémi Denis-Courmont

From: Rémi Denis-Courmont <[email protected]>

Using a target unsigned long would limit the Input Address to a LPAE page-walk to 32 bits on AArch32 and 64 bits on AArch64. This is okay for stage 1 or on AArch64, but it is insufficient for stage 2 on AArch32. In that later case, the Input Address can have up to 40 bits.

---
 target/arm/helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Peter, bug fix for 5.2 or postpone?

r~

#2 lore raw
Quoted 9 lines · Richard Henderson
Quoted 7 lines · Rémi Denis-Courmont

From: Rémi Denis-Courmont <[email protected]>

Using a target unsigned long would limit the Input Address to a LPAE page-walk to 32 bits on AArch32 and 64 bits on AArch64. This is okay for stage 1 or on AArch64, but it is insufficient for stage 2 on AArch32. In that later case, the Input Address can have up to 40 bits.

Quoted 8 lines
Quoted 4 lines
---
 target/arm/helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Peter, bug fix for 5.2 or postpone?

Looks pretty safe so it seems reasonable to have in 5.2. Interesting that it's taken so long for anybody to notice...

-- PMM