aarch64-mte-linux.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Common Linux target-dependent definitions for AArch64 MTE
  2. Copyright (C) 2021-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef ARCH_AARCH64_LINUX_H
  15. #define ARCH_AARCH64_LINUX_H
  16. #include "gdbsupport/common-defs.h"
  17. /* Feature check for Memory Tagging Extension. */
  18. #ifndef HWCAP2_MTE
  19. #define HWCAP2_MTE (1 << 18)
  20. #endif
  21. /* The MTE regset consists of a single 64-bit register. */
  22. #define AARCH64_LINUX_SIZEOF_MTE 8
  23. /* We have one tag per 16 bytes of memory. */
  24. #define AARCH64_MTE_GRANULE_SIZE 16
  25. #define AARCH64_MTE_LOGICAL_TAG_START_BIT 56
  26. #define AARCH64_MTE_LOGICAL_MAX_VALUE 0xf
  27. /* Memory tagging definitions. */
  28. #ifndef SEGV_MTEAERR
  29. # define SEGV_MTEAERR 8
  30. # define SEGV_MTESERR 9
  31. #endif
  32. /* Memory tag types for AArch64. */
  33. enum class aarch64_memtag_type
  34. {
  35. /* MTE logical tag contained in pointers. */
  36. mte_logical = 0,
  37. /* MTE allocation tag stored in memory tag granules. */
  38. mte_allocation
  39. };
  40. /* Return the number of tag granules in the memory range
  41. [ADDR, ADDR + LEN) given GRANULE_SIZE. */
  42. extern size_t aarch64_mte_get_tag_granules (CORE_ADDR addr, size_t len,
  43. size_t granule_size);
  44. /* Return the 4-bit tag made from VALUE. */
  45. extern CORE_ADDR aarch64_mte_make_ltag_bits (CORE_ADDR value);
  46. /* Return the 4-bit tag that can be OR-ed to an address. */
  47. extern CORE_ADDR aarch64_mte_make_ltag (CORE_ADDR value);
  48. /* Helper to set the logical TAG for a 64-bit ADDRESS.
  49. It is always possible to set the logical tag. */
  50. extern CORE_ADDR aarch64_mte_set_ltag (CORE_ADDR address, CORE_ADDR tag);
  51. /* Helper to get the logical tag from a 64-bit ADDRESS.
  52. It is always possible to get the logical tag. */
  53. extern CORE_ADDR aarch64_mte_get_ltag (CORE_ADDR address);
  54. #endif /* ARCH_AARCH64_LINUX_H */