diff options
author | Luis Machado <luis.machado@linaro.org> | 2020-06-19 17:33:13 -0300 |
---|---|---|
committer | Luis Machado <luis.machado@linaro.org> | 2021-03-24 14:53:56 -0300 |
commit | 4601818e8c06bb8a5bf4b63fa527c69d3f81c6f0 (patch) | |
tree | a8650e0d1beb52fdf709a0198be63a61d29f4b49 /gdb/arch/aarch64-mte-linux.c | |
parent | 3f3bd8b8c14d844533b70b25c7f1a8cbdbac2639 (diff) | |
download | gdb-4601818e8c06bb8a5bf4b63fa527c69d3f81c6f0.zip gdb-4601818e8c06bb8a5bf4b63fa527c69d3f81c6f0.tar.gz gdb-4601818e8c06bb8a5bf4b63fa527c69d3f81c6f0.tar.bz2 |
AArch64: Implement memory tagging target methods for AArch64
The patch implements the memory tagging target hooks for AArch64, so we
can handle MTE.
gdb/ChangeLog:
2021-03-24 Luis Machado <luis.machado@linaro.org>
* Makefile.in (ALL_64_TARGET_OBS): Add arch/aarch64-mte-linux.o.
(HFILES_NO_SRCDIR): Add arch/aarch64-mte-linux.h and
nat/aarch64-mte-linux-ptrace.h.
* aarch64-linux-nat.c: Include nat/aarch64-mte-linux-ptrace.h.
(aarch64_linux_nat_target) <supports_memory_tagging>: New method
override.
<fetch_memtags>: New method override.
<store_memtags>: New method override.
(aarch64_linux_nat_target::supports_memory_tagging): New method.
(aarch64_linux_nat_target::fetch_memtags): New method.
(aarch64_linux_nat_target::store_memtags): New method.
* arch/aarch64-mte-linux.c: New file.
* arch/aarch64-mte-linux.h: Include gdbsupport/common-defs.h.
(AARCH64_MTE_GRANULE_SIZE): Define.
(aarch64_memtag_type): New enum.
(aarch64_mte_get_tag_granules): New prototype.
* configure.nat (NATDEPFILES): Add nat/aarch64-mte-linux-ptrace.o.
* configure.tgt (aarch64*-*-linux*): Add arch/aarch64-mte-linux.o.
* nat/aarch64-mte-linux-ptrace.c: New file.
* nat/aarch64-mte-linux-ptrace.h: New file.
Diffstat (limited to 'gdb/arch/aarch64-mte-linux.c')
-rw-r--r-- | gdb/arch/aarch64-mte-linux.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gdb/arch/aarch64-mte-linux.c b/gdb/arch/aarch64-mte-linux.c new file mode 100644 index 0000000..3d72b8d --- /dev/null +++ b/gdb/arch/aarch64-mte-linux.c @@ -0,0 +1,38 @@ +/* Common Linux target-dependent functionality for AArch64 MTE + + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "arch/aarch64-mte-linux.h" + +/* See arch/aarch64-mte-linux.h */ + +size_t +aarch64_mte_get_tag_granules (CORE_ADDR addr, size_t len, size_t granule_size) +{ + /* An empty range has 0 tag granules. */ + if (len == 0) + return 0; + + /* Start address */ + CORE_ADDR s_addr = align_down (addr, granule_size); + /* End address */ + CORE_ADDR e_addr = align_down (addr + len, granule_size); + + /* We always have at least 1 granule. */ + return 1 + (e_addr - s_addr) / granule_size; +} |