From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GMKKIjWf7F/qCgAAWB0awg (envelope-from ) for ; Wed, 30 Dec 2020 10:39:33 -0500 Received: by simark.ca (Postfix, from userid 112) id 85D211F0B7; Wed, 30 Dec 2020 10:39:33 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D4BAD1E965 for ; Wed, 30 Dec 2020 10:39:30 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 673C73850425; Wed, 30 Dec 2020 15:39:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 673C73850425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609342770; bh=jjk7lYvxMvz1fjwKWVMBPn6TM+GEihTxW2EFUGaDvTc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=m+WLCYr6YwbGB56hHxZRrpsSXyBi4s9By7ynnNOkbeVUAcK1Y6MJMaMV7GX8X7PGd E47oxvexp6M0OTGXwyZwoI6VUs2gBOLulBBh1gYPFsPRVAECipOpdIl7gT1C18+OQr o9QILaTWoLA8nUYyFuv/2DMgmkZOa410roqCIPwg= Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 20EE43850425 for ; Wed, 30 Dec 2020 15:39:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 20EE43850425 Received: by mail-qk1-x729.google.com with SMTP id 22so14148669qkf.9 for ; Wed, 30 Dec 2020 07:39:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jjk7lYvxMvz1fjwKWVMBPn6TM+GEihTxW2EFUGaDvTc=; b=q9TPtu0fco4BY7zDf2FMpiGCWeZclZwER9rknPWI2CEexTWywxcMuq5spZ2s3p/Nxq M9QH8hHDbxWl8YBTvggyvKJW0U2bUfEjFtoCJoyaedvhHfZ2XQbi4nLQlBdvXjl6wq5P dYi3ehBSr2MUPN9DF6J5RF9NT9TsnIM4C4Cp/LM4jp3Ui64x554rCIuVlJ/3zqqbPZ7k ySqxsuR8D7Q/RQrtKdTeGBf4NzQ9S6VkHdw9x9iF4Y7smXaNB2WxAoYjo5R01Be4umk+ 7rv0wIV9bgqZcd6jIT7S5a/MJC7dccGby8UMCcTm7ZHtJxJwqnh8gENTEAahhzQYlBv8 bLNw== X-Gm-Message-State: AOAM5329T6nxYYzJT0y2s3M//4jZnCqZyB/g4is/w8T9x+g0u9SyRgLH kcl8XFEyUu3r+bSdgDLGGkOs3oPPsvu7zA== X-Google-Smtp-Source: ABdhPJyWTwjyXFZ+E5PRsiNm6gX7oANVfRNnkJ4IFNaqo8IL9Guac0nkuDe+P3hPlvAOgOdxEdC66w== X-Received: by 2002:a37:640a:: with SMTP id y10mr54441210qkb.272.1609342766311; Wed, 30 Dec 2020 07:39:26 -0800 (PST) Received: from localhost.localdomain ([2804:7f0:8284:370e:c9ba:c4ec:737b:57da]) by smtp.gmail.com with ESMTPSA id f6sm28589336qkh.2.2020.12.30.07.39.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Dec 2020 07:39:25 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PATCH v4 02/25] New gdbarch memory tagging hooks Date: Wed, 30 Dec 2020 12:38:53 -0300 Message-Id: <20201230153916.1586725-3-luis.machado@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201230153916.1586725-1-luis.machado@linaro.org> References: <20201230153916.1586725-1-luis.machado@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Cc: david.spickett@linaro.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Updates on v4: - Updated return type of gdbarch_set_memtags to bool. - Renamed gdbarch_memtag_mismatch_p to gdbarch_memtag_matches_p. - Renamed gdbarch_granule_size to gdbarch_memtag_granule_size. -- We need some new gdbarch hooks to help us manipulate memory tags without having to have GDB call the target methods directly. This patch adds the following hooks: gdbarch_memtag_to_string -- Returns a printable string corresponding to the tag. gdbarch_tagged_address_p -- Checks if a particular address is protected with memory tagging. gdbarch_memtag_matches_p -- Checks if the logical tag of a pointer and the allocation tag from the address the pointer points to matches. gdbarch_set_memtags: -- Sets either the allocation tag or the logical tag for a particular value. gdbarch_get_memtag: -- Gets either the allocation tag or the logical tag for a particular value. gdbarch_memtag_granule_size -- Sets the memory tag granule size, which represents the number of bytes a particular allocation tag covers. For example, this is 16 bytes for AArch64's MTE. I've used struct value as opposed to straight CORE_ADDR so other architectures can use the infrastructure without having to rely on a particular type for addresses/pointers. Some architecture may use pointers of 16 bytes that don't fit in a CORE_ADDR, for example. gdb/ChangeLog: YYYY-MM-DD Luis Machado * arch-utils.c (default_memtag_to_string, default_tagged_address_p) (default_memtag_matches_p, default_set_memtags) (default_get_memtag): New functions. * arch-utils.h (default_memtag_to_string, default_tagged_address_p) (default_memtag_matches_p, default_set_memtags) (default_get_memtag): New prototypes. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (memtag_to_string, tagged_address_p, memtag_matches_p) (set_memtags, get_memtag, memtag_granule_size): New gdbarch hooks. (enum memtag_type): New enum. --- gdb/arch-utils.c | 50 +++++++++++++++++ gdb/arch-utils.h | 23 ++++++++ gdb/gdbarch.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++ gdb/gdbarch.h | 53 ++++++++++++++++++ gdb/gdbarch.sh | 36 +++++++++++++ 5 files changed, 299 insertions(+) diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 2786544d22..efb041d927 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -77,6 +77,56 @@ legacy_register_sim_regno (struct gdbarch *gdbarch, int regnum) return LEGACY_SIM_REGNO_IGNORE; } + +/* See arch-utils.h */ + +std::string +default_memtag_to_string (struct gdbarch *gdbarch, struct value *address, + enum memtag_type tag_type) +{ + /* By default, assume the address is untagged. */ + return ""; +} + +/* See arch-utils.h */ + +bool +default_tagged_address_p (struct gdbarch *gdbarch, struct value *address) +{ + /* By default, assume the address is untagged. */ + return false; +} + +/* See arch-utils.h */ + +bool +default_memtag_matches_p (struct gdbarch *gdbarch, struct value *address) +{ + /* By default, assume the tags match. */ + return true; +} + +/* See arch-utils.h */ + +bool +default_set_memtags (struct gdbarch *gdbarch, struct value *address, + size_t length, const gdb::byte_vector &tags, + enum memtag_type tag_type) +{ + /* By default, return true (successful); */ + return true; +} + +/* See arch-utils.h */ + +struct value * +default_get_memtag (struct gdbarch *gdbarch, struct value *address, + enum memtag_type tag_type) +{ + /* By default, return no tag. */ + return NULL; +} + CORE_ADDR generic_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) { diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index c9589e1f3a..b2e5cdbfec 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -132,6 +132,29 @@ extern const struct floatformat ** default_floatformat_for_type (struct gdbarch *gdbarch, const char *name, int len); +/* Default implementation of gdbarch_tagged_address_p. */ +extern std::string default_memtag_to_string (struct gdbarch *gdbarch, + struct value *address, + enum memtag_type tag_type); + +/* Default implementation of gdbarch_tagged_address_p. */ +bool default_tagged_address_p (struct gdbarch *gdbarch, struct value *address); + +/* Default implementation of gdbarch_memtag_matches_p. */ +extern bool default_memtag_matches_p (struct gdbarch *gdbarch, + struct value *address); + +/* Default implementation of gdbarch_set_memtags. */ +bool default_set_memtags (struct gdbarch *gdbarch, + struct value *address, size_t length, + const gdb::byte_vector &tags, + enum memtag_type tag_type); + +/* Default implementation of gdbarch_get_memtag. */ +struct value *default_get_memtag (struct gdbarch *gdbarch, + struct value *address, + enum memtag_type tag_type); + extern CORE_ADDR generic_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index bf8d8bc211..39c41b7162 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -253,6 +253,12 @@ struct gdbarch gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr; gdbarch_addr_bits_remove_ftype *addr_bits_remove; int significant_addr_bit; + gdbarch_memtag_to_string_ftype *memtag_to_string; + gdbarch_tagged_address_p_ftype *tagged_address_p; + gdbarch_memtag_matches_p_ftype *memtag_matches_p; + gdbarch_set_memtags_ftype *set_memtags; + gdbarch_get_memtag_ftype *get_memtag; + CORE_ADDR memtag_granule_size; gdbarch_software_single_step_ftype *software_single_step; gdbarch_single_step_through_delay_ftype *single_step_through_delay; gdbarch_print_insn_ftype *print_insn; @@ -433,6 +439,11 @@ gdbarch_alloc (const struct gdbarch_info *info, gdbarch->stabs_argument_has_addr = default_stabs_argument_has_addr; gdbarch->convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity; gdbarch->addr_bits_remove = core_addr_identity; + gdbarch->memtag_to_string = default_memtag_to_string; + gdbarch->tagged_address_p = default_tagged_address_p; + gdbarch->memtag_matches_p = default_memtag_matches_p; + gdbarch->set_memtags = default_set_memtags; + gdbarch->get_memtag = default_get_memtag; gdbarch->print_insn = default_print_insn; gdbarch->skip_trampoline_code = generic_skip_trampoline_code; gdbarch->skip_solib_resolver = generic_skip_solib_resolver; @@ -626,6 +637,12 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of convert_from_func_ptr_addr, invalid_p == 0 */ /* Skip verify of addr_bits_remove, invalid_p == 0 */ /* Skip verify of significant_addr_bit, invalid_p == 0 */ + /* Skip verify of memtag_to_string, invalid_p == 0 */ + /* Skip verify of tagged_address_p, invalid_p == 0 */ + /* Skip verify of memtag_matches_p, invalid_p == 0 */ + /* Skip verify of set_memtags, invalid_p == 0 */ + /* Skip verify of get_memtag, invalid_p == 0 */ + /* Skip verify of memtag_granule_size, invalid_p == 0 */ /* Skip verify of software_single_step, has predicate. */ /* Skip verify of single_step_through_delay, has predicate. */ /* Skip verify of print_insn, invalid_p == 0 */ @@ -1088,6 +1105,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: get_longjmp_target = <%s>\n", host_address_to_string (gdbarch->get_longjmp_target)); + fprintf_unfiltered (file, + "gdbarch_dump: get_memtag = <%s>\n", + host_address_to_string (gdbarch->get_memtag)); fprintf_unfiltered (file, "gdbarch_dump: get_pc_address_flags = <%s>\n", host_address_to_string (gdbarch->get_pc_address_flags)); @@ -1217,6 +1237,15 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: memory_remove_breakpoint = <%s>\n", host_address_to_string (gdbarch->memory_remove_breakpoint)); + fprintf_unfiltered (file, + "gdbarch_dump: memtag_granule_size = %s\n", + core_addr_to_string_nz (gdbarch->memtag_granule_size)); + fprintf_unfiltered (file, + "gdbarch_dump: memtag_matches_p = <%s>\n", + host_address_to_string (gdbarch->memtag_matches_p)); + fprintf_unfiltered (file, + "gdbarch_dump: memtag_to_string = <%s>\n", + host_address_to_string (gdbarch->memtag_to_string)); fprintf_unfiltered (file, "gdbarch_dump: num_pseudo_regs = %s\n", plongest (gdbarch->num_pseudo_regs)); @@ -1370,6 +1399,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: sdb_reg_to_regnum = <%s>\n", host_address_to_string (gdbarch->sdb_reg_to_regnum)); + fprintf_unfiltered (file, + "gdbarch_dump: set_memtags = <%s>\n", + host_address_to_string (gdbarch->set_memtags)); fprintf_unfiltered (file, "gdbarch_dump: short_bit = %s\n", plongest (gdbarch->short_bit)); @@ -1478,6 +1510,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: syscalls_info = %s\n", host_address_to_string (gdbarch->syscalls_info)); + fprintf_unfiltered (file, + "gdbarch_dump: tagged_address_p = <%s>\n", + host_address_to_string (gdbarch->tagged_address_p)); fprintf_unfiltered (file, "gdbarch_dump: target_desc = %s\n", host_address_to_string (gdbarch->target_desc)); @@ -3283,6 +3318,108 @@ set_gdbarch_significant_addr_bit (struct gdbarch *gdbarch, gdbarch->significant_addr_bit = significant_addr_bit; } +std::string +gdbarch_memtag_to_string (struct gdbarch *gdbarch, struct value *address, enum memtag_type tag_type) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->memtag_to_string != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_memtag_to_string called\n"); + return gdbarch->memtag_to_string (gdbarch, address, tag_type); +} + +void +set_gdbarch_memtag_to_string (struct gdbarch *gdbarch, + gdbarch_memtag_to_string_ftype memtag_to_string) +{ + gdbarch->memtag_to_string = memtag_to_string; +} + +bool +gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->tagged_address_p != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_tagged_address_p called\n"); + return gdbarch->tagged_address_p (gdbarch, address); +} + +void +set_gdbarch_tagged_address_p (struct gdbarch *gdbarch, + gdbarch_tagged_address_p_ftype tagged_address_p) +{ + gdbarch->tagged_address_p = tagged_address_p; +} + +bool +gdbarch_memtag_matches_p (struct gdbarch *gdbarch, struct value *address) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->memtag_matches_p != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_memtag_matches_p called\n"); + return gdbarch->memtag_matches_p (gdbarch, address); +} + +void +set_gdbarch_memtag_matches_p (struct gdbarch *gdbarch, + gdbarch_memtag_matches_p_ftype memtag_matches_p) +{ + gdbarch->memtag_matches_p = memtag_matches_p; +} + +bool +gdbarch_set_memtags (struct gdbarch *gdbarch, struct value *address, size_t length, const gdb::byte_vector &tags, enum memtag_type tag_type) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->set_memtags != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_set_memtags called\n"); + return gdbarch->set_memtags (gdbarch, address, length, tags, tag_type); +} + +void +set_gdbarch_set_memtags (struct gdbarch *gdbarch, + gdbarch_set_memtags_ftype set_memtags) +{ + gdbarch->set_memtags = set_memtags; +} + +struct value * +gdbarch_get_memtag (struct gdbarch *gdbarch, struct value *address, enum memtag_type tag_type) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->get_memtag != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_get_memtag called\n"); + return gdbarch->get_memtag (gdbarch, address, tag_type); +} + +void +set_gdbarch_get_memtag (struct gdbarch *gdbarch, + gdbarch_get_memtag_ftype get_memtag) +{ + gdbarch->get_memtag = get_memtag; +} + +CORE_ADDR +gdbarch_memtag_granule_size (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + /* Skip verify of memtag_granule_size, invalid_p == 0 */ + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_memtag_granule_size called\n"); + return gdbarch->memtag_granule_size; +} + +void +set_gdbarch_memtag_granule_size (struct gdbarch *gdbarch, + CORE_ADDR memtag_granule_size) +{ + gdbarch->memtag_granule_size = memtag_granule_size; +} + bool gdbarch_software_single_step_p (struct gdbarch *gdbarch) { diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 002628d898..d3c5a84827 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -117,6 +117,18 @@ enum function_call_return_method return_method_struct, }; +enum memtag_type +{ + /* Logical tag, the tag that is stored in unused bits of a pointer to a + virtual address. */ + tag_logical = 0, + + /* Allocation tag, the tag that is associated with every granule of memory in + the physical address space. Allocation tags are used to validate memory + accesses via pointers containing logical tags. */ + tag_allocation, +}; + /* The following are pre-initialized by GDBARCH. */ @@ -712,6 +724,47 @@ extern void set_gdbarch_addr_bits_remove (struct gdbarch *gdbarch, gdbarch_addr_ extern int gdbarch_significant_addr_bit (struct gdbarch *gdbarch); extern void set_gdbarch_significant_addr_bit (struct gdbarch *gdbarch, int significant_addr_bit); +/* Return a string representation of the memory tag TYPE of ADDRESS. + If no tag is associated with such an address, return the empty string. */ + +typedef std::string (gdbarch_memtag_to_string_ftype) (struct gdbarch *gdbarch, struct value *address, enum memtag_type tag_type); +extern std::string gdbarch_memtag_to_string (struct gdbarch *gdbarch, struct value *address, enum memtag_type tag_type); +extern void set_gdbarch_memtag_to_string (struct gdbarch *gdbarch, gdbarch_memtag_to_string_ftype *memtag_to_string); + +/* Return true if ADDRESS contains a tag and false otherwise. */ + +typedef bool (gdbarch_tagged_address_p_ftype) (struct gdbarch *gdbarch, struct value *address); +extern bool gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address); +extern void set_gdbarch_tagged_address_p (struct gdbarch *gdbarch, gdbarch_tagged_address_p_ftype *tagged_address_p); + +/* Return true if the tag from ADDRESS matches the memory tag for that + particular address. Return false otherwise. */ + +typedef bool (gdbarch_memtag_matches_p_ftype) (struct gdbarch *gdbarch, struct value *address); +extern bool gdbarch_memtag_matches_p (struct gdbarch *gdbarch, struct value *address); +extern void set_gdbarch_memtag_matches_p (struct gdbarch *gdbarch, gdbarch_memtag_matches_p_ftype *memtag_matches_p); + +/* Set the tags for the address range [ADDRESS, ADDRESS + LENGTH) to TAGS + Return true if successful and false otherwise. */ + +typedef bool (gdbarch_set_memtags_ftype) (struct gdbarch *gdbarch, struct value *address, size_t length, const gdb::byte_vector &tags, enum memtag_type tag_type); +extern bool gdbarch_set_memtags (struct gdbarch *gdbarch, struct value *address, size_t length, const gdb::byte_vector &tags, enum memtag_type tag_type); +extern void set_gdbarch_set_memtags (struct gdbarch *gdbarch, gdbarch_set_memtags_ftype *set_memtags); + +/* Return the tag portion of ADDRESS, assuming ADDRESS is tagged. */ + +typedef struct value * (gdbarch_get_memtag_ftype) (struct gdbarch *gdbarch, struct value *address, enum memtag_type tag_type); +extern struct value * gdbarch_get_memtag (struct gdbarch *gdbarch, struct value *address, enum memtag_type tag_type); +extern void set_gdbarch_get_memtag (struct gdbarch *gdbarch, gdbarch_get_memtag_ftype *get_memtag); + +/* memtag_granule_size is the size of the allocation tag granule, for + architectures that support memory tagging. + This is 0 for architectures that do not support memory tagging. + For a non-zero value, this represents the number of bytes of memory per tag. */ + +extern CORE_ADDR gdbarch_memtag_granule_size (struct gdbarch *gdbarch); +extern void set_gdbarch_memtag_granule_size (struct gdbarch *gdbarch, CORE_ADDR memtag_granule_size); + /* FIXME/cagney/2001-01-18: This should be split in two. A target method that indicates if the target needs software single step. An ISA method to implement it. diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index e90654dc5c..a111f67a2b 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -605,6 +605,30 @@ m;CORE_ADDR;addr_bits_remove;CORE_ADDR addr;addr;;core_addr_identity;;0 # additional data associated with the address. v;int;significant_addr_bit;;;;;;0 +# Return a string representation of the memory tag TYPE of ADDRESS. +# If no tag is associated with such an address, return the empty string. +m;std::string;memtag_to_string;struct value *address, enum memtag_type tag_type;address, tag_type;;default_memtag_to_string;;0 + +# Return true if ADDRESS contains a tag and false otherwise. +m;bool;tagged_address_p;struct value *address;address;;default_tagged_address_p;;0 + +# Return true if the tag from ADDRESS matches the memory tag for that +# particular address. Return false otherwise. +m;bool;memtag_matches_p;struct value *address;address;;default_memtag_matches_p;;0 + +# Set the tags for the address range [ADDRESS, ADDRESS + LENGTH) to TAGS +# Return true if successful and false otherwise. +m;bool;set_memtags;struct value *address, size_t length, const gdb::byte_vector \&tags, enum memtag_type tag_type;address, length, tags, tag_type;;default_set_memtags;;0 + +# Return the tag portion of ADDRESS, assuming ADDRESS is tagged. +m;struct value *;get_memtag;struct value *address, enum memtag_type tag_type;address, tag_type;;default_get_memtag;;0 + +# memtag_granule_size is the size of the allocation tag granule, for +# architectures that support memory tagging. +# This is 0 for architectures that do not support memory tagging. +# For a non-zero value, this represents the number of bytes of memory per tag. +v;CORE_ADDR;memtag_granule_size;;;;;;0 + # FIXME/cagney/2001-01-18: This should be split in two. A target method that # indicates if the target needs software single step. An ISA method to # implement it. @@ -1362,6 +1386,18 @@ enum function_call_return_method return_method_struct, }; +enum memtag_type +{ + /* Logical tag, the tag that is stored in unused bits of a pointer to a + virtual address. */ + tag_logical = 0, + + /* Allocation tag, the tag that is associated with every granule of memory in + the physical address space. Allocation tags are used to validate memory + accesses via pointers containing logical tags. */ + tag_allocation, +}; + EOF # function typedef's -- 2.25.1