@@ -1169,6 +1169,8 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Translate *ptw,
uint32_t dacr;
bool ns;
int user_prot;
+ int wxn = arm_wxn_enabled(env, mmu_idx);
+ int uwxn = arm_uwxn_enabled(env, mmu_idx);
/* Pagetable walk. */
/* Lookup l1 descriptor. */
@@ -1288,6 +1290,15 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Translate *ptw,
if (result->f.prot && !xn) {
result->f.prot |= PAGE_EXEC;
}
+
+ if (result->f.prot & PAGE_WRITE) {
+ /* WXN works for PL1&0, while UWXN only for PL0. */
+ if (wxn)
+ result->f.prot &= ~PAGE_EXEC;
+ if (uwxn && regime_is_user(env, mmu_idx))
+ result->f.prot &= ~PAGE_EXEC;
+ }
+
if (!(result->f.prot & (1 << access_type))) {
/* Access permission fault. */
fi->type = ARMFault_Permission;
get_phys_addr_v6() is used for decoding armv7's short descriptor format. Based on ARM ARM AArch32.S1SDHasPermissionsFault(), WXN should be respected in !LPAE mode as well. Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> --- target/arm/ptw.c | 11 +++++++++++ 1 file changed, 11 insertions(+)