]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/arm: Don't skip MTE checks for LDRT/STRT at EL0
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 12 Sep 2023 14:04:23 +0000 (15:04 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Mon, 25 Sep 2023 20:43:49 +0000 (23:43 +0300)
commitc8d2fc2177cfa020bc37937e46fbfe8d0bc6043f
tree926659ad72629be258fec189503727f7e6e71e5c
parent79f113448a08e72acbcca60e8ee3e909dc690bbb
target/arm: Don't skip MTE checks for LDRT/STRT at EL0

The LDRT/STRT "unprivileged load/store" instructions behave like
normal ones if executed at EL0. We handle this correctly for
the load/store semantics, but get the MTE checking wrong.

We always look at s->mte_active[is_unpriv] to see whether we should
be doing MTE checks, but in hflags.c when we set the TB flags that
will be used to fill the mte_active[] array we only set the
MTE0_ACTIVE bit if UNPRIV is true (i.e.  we are not at EL0).

This means that a LDRT at EL0 will see s->mte_active[1] as 0,
and will not do MTE checks even when MTE is enabled.

To avoid the translate-time code having to do an explicit check on
s->unpriv to see if it is OK to index into the mte_active[] array,
duplicate MTE_ACTIVE into MTE0_ACTIVE when UNPRIV is false.

(This isn't a very serious bug because generally nobody executes
LDRT/STRT at EL0, because they have no use there.)

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20230912140434.1333369-2-peter.maydell@linaro.org
(cherry picked from commit 903dbefc2b6918c10d12d9aafa0168cee8d287c7)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: before v7.2.0-1636-g671efad16a this code was in target/arm/helper.c)
target/arm/helper.c