On Thu, 5 Nov 2026 at 09:44, Manos Pitsidianakis <[email protected]> wrote: > > For the ARM_FEATURE_V6 case, it seems like we retrieve AP and XN bits in > get_phys_addr_v6() but we don't check the XN bit in get_S1prot(). > > Change the `if (arm_feature(env, ARM_FEATURE_V7))` check in get_S1prot() > to `if (arm_feature(env, ARM_FEATURE_V6))` since v7 implies v6. > > Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4367 > Signed-off-by: Manos Pitsidianakis <[email protected]>
I think this is worth backporting, so: Cc: [email protected] Fixes: d8e052b3876356 ("target-arm: get_phys_addr_lpae: more xn control") > --- > target/arm/ptw.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/target/arm/ptw.c b/target/arm/ptw.c > index > 2e67d02493bd463cfd2d31ecf1316272ac3f1d99..b8b22b014e0574340a85abe73f3d9611d2360219 > 100644 > --- a/target/arm/ptw.c > +++ b/target/arm/ptw.c > @@ -1595,7 +1595,7 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx > mmu_idx, bool is_aa64, > if (regime_has_2_ranges(mmu_idx) && !is_user) { > xn = pxn || (user_rw & PAGE_WRITE); > } > - } else if (arm_feature(env, ARM_FEATURE_V7)) { > + } else if (arm_feature(env, ARM_FEATURE_V6)) { > switch (regime_el(mmu_idx)) { > case 1: > case 3: Digging into the various versions of the Arm ARM and looking at QEMU's code, I think that "allow this for v6" is correct, but I think that ARM_FEATURE_V6 will always be true here so we don't need to explicitly check it. The two callers of get_S1prot() are get_phys_addr_v6() and get_phys_addr_lpae(). If the CPU isn't v6 then it doesn't get those page table formats. (get_phys_addr_v5() is simpler and just figures out its prot bits directly rather than calling this.) So I think we can make this a plain "else", and delete the existing "else" clause that sets xn and wxn to 0. (Strictly speaking it is possible to get here without V6, because we don't enforce that a guest on a v5 CPU can't write to the SCTLR.XP bit which should be RAZ there, and we don't ignore it in get_phys_addr_nogpc(). But if the guest does do that then they're in UNPREDICTABLE territory and whether we give them v6 VMSA with XP or v6 VMSA without XP doesn't matter.) thanks -- PMM
