target/arm: add canonical tag check helper
Add a helper that checks whether mtx is active from MTEDESC. Refactored an existing function to use it. Signed-off-by: Gabriel Brookman <brookmangabriel@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20260529-feat-mte4-v7-7-ccbd3c14eb3c@gmail.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Gabriel Brookman committed
May 29, 2026 at 12:52 UTC
5df644c8d955bcef685b82d98c7975e3b13d0992
1 file changed
+7
-1
target/arm/internals.h
+7
-1
@@ -1665,6 +1665,12 @@ static inline bool tbi_or_mtx_check(uint32_t desc, int bit55)
1665
return desc & (mask << bit55);
1666
}
1667
1668
+/* Return whether or not the second nibble of a VA matches bit 55. */
1669
+static inline bool tag_is_canonical(int ptr_tag, int bit55)
1670
+{
1671
+ return ((ptr_tag + bit55) & 0xf) == 0;
1672
+}
1673
+
1674
/* Return true if tcma bits mean that the access is unchecked. */
1675
static inline bool tcma_check(uint32_t desc, int bit55, int ptr_tag)
1676
{
@@ -1672,7 +1678,7 @@ static inline bool tcma_check(uint32_t desc, int bit55, int ptr_tag)
1678
* We had extracted bit55 and ptr_tag for other reasons, so fold
1679
* (ptr<59:55> == 00000 || ptr<59:55> == 11111) into a single test.
1680
*/
1675
- bool match = ((ptr_tag + bit55) & 0xf) == 0;
1681
+ bool match = tag_is_canonical(ptr_tag, bit55);
1682
bool tcma = (desc >> (R_MTEDESC_TCMA_SHIFT + bit55)) & 1;
1683
return tcma && match;
1684
}