Skip to contentSkip to conversation

Bug in tlbi_aa64_vae2is_write: tlbbits_for_regime called with swapped ARMMMUIdx_ values?

DISCUSSION Rebecca Cran 3 participants 3 messages Mar 16, 2021 – Mar 22, 2021

lore
Share & tools
lore
#0 lore raw

I noticed the following in tlbi_aa64_vae2is_write: it appears that when calling tlbbits_for_regime the ARMMMUIdx values are swapped?

static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,

                                   uint64_t value)
{
    CPUState *cs = env_cpu(env);
    uint64_t pageaddr = sextract64(value << 12, 0, 56);
    bool secure = arm_is_secure_below_el3(env);
    int mask = secure ? ARMMMUIdxBit_SE2 : ARMMMUIdxBit_E2;
    int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : 

ARMMMUIdx_SE2,
pageaddr);

tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask,
bits);
}

Signature · 1 line
Rebecca Cran
#1 lore raw
Quoted 10 lines · Rebecca Cran

I noticed the following in tlbi_aa64_vae2is_write: it appears that when calling tlbbits_for_regime the ARMMMUIdx values are swapped?

static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
                                   uint64_t value)
{
    CPUState *cs = env_cpu(env);
    uint64_t pageaddr = sextract64(value << 12, 0, 56);
    bool secure = arm_is_secure_below_el3(env);
    int mask = secure ? ARMMMUIdxBit_SE2 : ARMMMUIdxBit_E2;
    int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,

Yep, good catch.

r~

Quoted 5 lines

                                  pageaddr);

    tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask, bits);
}

#2 lore raw
Quoted 14 lines · Richard Henderson
Quoted 11 lines · Rebecca Cran

I noticed the following in tlbi_aa64_vae2is_write: it appears that when calling tlbbits_for_regime the ARMMMUIdx values are swapped?

static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,

                                    uint64_t value)
{
     CPUState *cs = env_cpu(env);
     uint64_t pageaddr = sextract64(value << 12, 0, 56);
     bool secure = arm_is_secure_below_el3(env);
     int mask = secure ? ARMMMUIdxBit_SE2 : ARMMMUIdxBit_E2;
     int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
Quoted 1 line

Yep, good catch.

Would somebody like to write a patch with the fix ?

thanks
-- PMM