From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oDzFEkOf7F/qCgAAWB0awg (envelope-from ) for ; Wed, 30 Dec 2020 10:39:47 -0500 Received: by simark.ca (Postfix, from userid 112) id 24FC11F0B7; Wed, 30 Dec 2020 10:39:46 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [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 F20EC1E965 for ; Wed, 30 Dec 2020 10:39:45 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5EC49388C033; Wed, 30 Dec 2020 15:39:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5EC49388C033 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609342785; bh=sT98I8Jqy9zG8eVwViEXYXPx5WnQG1xzNyYqqcH408g=; 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=wKeH0Bw2QCmeVzO94xfEb6fjRoHaCWTDx5O964v30cc4EqLwb6UgWRPjxxE6GmE+h Klf/qk+qeD9Q1jC34fKwlbXRVIpVX9xoQ7YJueQR5y7I6Y4GwbzuainnJ0rnas7tvV Vci1t3x5n1Hs8PozOJ4KCvBa/yQdcp5R7OsSAdrw= Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by sourceware.org (Postfix) with ESMTPS id C1234388C02E for ; Wed, 30 Dec 2020 15:39:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C1234388C02E Received: by mail-qk1-x734.google.com with SMTP id 22so14149268qkf.9 for ; Wed, 30 Dec 2020 07:39:41 -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=sT98I8Jqy9zG8eVwViEXYXPx5WnQG1xzNyYqqcH408g=; b=fbE7axqrzJN3xGQ2lVKxu/1MsGotwZ7+EH/w9b1MZGUbFqih0JopmEoCVCAKaayVPm pPGwckSaB1lt6/TBX4pK3kD3D2W5GMmM/VLJA+5qRtgwY+bDDCoNPjfUStYcBrY3nqfA uBgKFuEZ3wIb0OPL3u52E4DcZEXP8Mm5lZ+WYfCR8X58RWoWFRzufbxyiefF3Gxm6e8Z M+u1sAhYWIj2GF2qlhkQHk7iufb1npQun2NinB6xXPB8AST31KmtyZYqeEC7I3JaCwHb 4z1p9t/rLdfOe/zH4OwyS6FwduaP8LfVcyXt89kNuILklfz20qj0Nlaq1O2SmR0CtK6T E6Bw== X-Gm-Message-State: AOAM532NyVLCuGvfuzEKIRI0xJ3vwsiNwuLHQUuCcf+bjKEifriCYr+6 Q5HInYWuNox66YuFTxKc3005hjDtYWbV+A== X-Google-Smtp-Source: ABdhPJwQOS5+E+yhMIe9pQv4lekRP6rOrgLyP+7SWClJQoVdr+ULxP7TtHDEzQOwsaO1iYIEg5BLTg== X-Received: by 2002:a37:9d96:: with SMTP id g144mr51600319qke.441.1609342780855; Wed, 30 Dec 2020 07:39:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Dec 2020 07:39:40 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PATCH v4 09/25] AArch64: Add target description/feature for MTE registers Date: Wed, 30 Dec 2020 12:39:00 -0300 Message-Id: <20201230153916.1586725-10-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" This patch adds a target description and feature "mte" for aarch64. It includes one new register, tag_ctl, that can be used to configure the tag generation rules and sync/async modes. It is 64-bit in size. The patch also adjusts the code that creates the target descriptions at runtime based on CPU feature checks. gdb/ChangeLog: YYYY-MM-DD Luis Machado * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description): Take MTE flag into account. Slight refactor to hwcap flag checking. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Likewise. * aarch64-tdep.c (tdesc_aarch64_list): Add one more dimension for MTE. (aarch64_read_description): Add mte_p parameter and update to use it. Update the documentation. (aarch64_gdbarch_init): Update call to aarch64_read_description. * aarch64-tdep.h (aarch64_read_description): Add mte_p parameter. * arch/aarch64.c: Include ../features/aarch64-mte.c. (aarch64_create_target_description): Add mte_p parameter and update the code to use it. * arch/aarch64.h (aarch64_create_target_description): Add mte_p parameter. * features/Makefile (FEATURE_XMLFILES): Add aarch64-mte.xml. * features/aarch64-mte.c: New file, generated. * features/aarch64-mte.xml: New file. gdbserver/ChangeLog: YYYY-MM-DD Luis Machado * linux-aarch64-ipa.cc (get_ipa_tdesc): Update call to aarch64_linux_read_description. (initialize_low_tracepoint): Likewise. * linux-aarch64-low.cc (aarch64_target::low_arch_setup): Take MTE flag into account. * linux-aarch64-tdesc.cc (tdesc_aarch64_list): Add one more dimension for MTE. (aarch64_linux_read_description): Add mte_p parameter and update to use it. * linux-aarch64-tdesc.h (aarch64_linux_read_description): Add mte_p parameter. --- gdb/aarch64-linux-nat.c | 7 +++++-- gdb/aarch64-linux-tdep.c | 5 ++++- gdb/aarch64-tdep.c | 16 +++++++++------- gdb/aarch64-tdep.h | 3 ++- gdb/arch/aarch64.c | 7 ++++++- gdb/arch/aarch64.h | 7 +++++-- gdb/features/Makefile | 1 + gdb/features/aarch64-mte.c | 14 ++++++++++++++ gdb/features/aarch64-mte.xml | 11 +++++++++++ gdbserver/linux-aarch64-ipa.cc | 8 ++++---- gdbserver/linux-aarch64-low.cc | 6 +++++- gdbserver/linux-aarch64-tdesc.cc | 10 +++++----- gdbserver/linux-aarch64-tdesc.h | 3 ++- 13 files changed, 73 insertions(+), 25 deletions(-) create mode 100644 gdb/features/aarch64-mte.c create mode 100644 gdb/features/aarch64-mte.xml diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index eeff80654b..77a16f239a 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -653,9 +653,12 @@ aarch64_linux_nat_target::read_description () return aarch32_read_description (); CORE_ADDR hwcap = linux_get_hwcap (this); + CORE_ADDR hwcap2 = linux_get_hwcap2 (this); - return aarch64_read_description (aarch64_sve_get_vq (tid), - hwcap & AARCH64_HWCAP_PACA); + bool pauth_p = hwcap & AARCH64_HWCAP_PACA; + bool mte_p = hwcap2 & HWCAP2_MTE; + + return aarch64_read_description (aarch64_sve_get_vq (tid), pauth_p, mte_p); } /* Convert a native/host siginfo object, into/from the siginfo in the diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 8866298c2f..83c470fd14 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -730,9 +730,12 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { CORE_ADDR hwcap = linux_get_hwcap (target); + CORE_ADDR hwcap2 = linux_get_hwcap2 (target); + bool pauth_p = hwcap & AARCH64_HWCAP_PACA; + bool mte_p = hwcap2 & HWCAP2_MTE; return aarch64_read_description (aarch64_linux_core_read_vq (gdbarch, abfd), - hwcap & AARCH64_HWCAP_PACA); + pauth_p, mte_p); } /* Implementation of `gdbarch_stap_is_single_operand', as defined in diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 5858b64970..e799d6b165 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -58,7 +58,7 @@ #define HA_MAX_NUM_FLDS 4 /* All possible aarch64 target descriptors. */ -struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/]; +struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/][2 /* mte */]; /* The standard register names, and all the valid aliases for them. */ static const struct @@ -3264,21 +3264,23 @@ aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch) /* Get the correct target description for the given VQ value. If VQ is zero then it is assumed SVE is not supported. - (It is not possible to set VQ to zero on an SVE system). */ + (It is not possible to set VQ to zero on an SVE system). + + MTE_P indicates the presence of the Memory Tagging Extension feature. */ const target_desc * -aarch64_read_description (uint64_t vq, bool pauth_p) +aarch64_read_description (uint64_t vq, bool pauth_p, bool mte_p) { if (vq > AARCH64_MAX_SVE_VQ) error (_("VQ is %" PRIu64 ", maximum supported value is %d"), vq, AARCH64_MAX_SVE_VQ); - struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p]; + struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p][mte_p]; if (tdesc == NULL) { - tdesc = aarch64_create_target_description (vq, pauth_p); - tdesc_aarch64_list[vq][pauth_p] = tdesc; + tdesc = aarch64_create_target_description (vq, pauth_p, mte_p); + tdesc_aarch64_list[vq][pauth_p][mte_p] = tdesc; } return tdesc; @@ -3378,7 +3380,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) value. */ const struct target_desc *tdesc = info.target_desc; if (!tdesc_has_registers (tdesc) || vq != aarch64_get_tdesc_vq (tdesc)) - tdesc = aarch64_read_description (vq, false); + tdesc = aarch64_read_description (vq, false, false); gdb_assert (tdesc); feature_core = tdesc_find_feature (tdesc,"org.gnu.gdb.aarch64.core"); diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h index 7d035c1aec..609e4f460c 100644 --- a/gdb/aarch64-tdep.h +++ b/gdb/aarch64-tdep.h @@ -102,7 +102,8 @@ struct gdbarch_tdep } }; -const target_desc *aarch64_read_description (uint64_t vq, bool pauth_p); +const target_desc *aarch64_read_description (uint64_t vq, bool pauth_p, + bool mte_p); extern int aarch64_process_record (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr); diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c index f89d5e014d..6c90bb36e4 100644 --- a/gdb/arch/aarch64.c +++ b/gdb/arch/aarch64.c @@ -23,11 +23,12 @@ #include "../features/aarch64-fpu.c" #include "../features/aarch64-sve.c" #include "../features/aarch64-pauth.c" +#include "../features/aarch64-mte.c" /* See arch/aarch64.h. */ target_desc * -aarch64_create_target_description (uint64_t vq, bool pauth_p) +aarch64_create_target_description (uint64_t vq, bool pauth_p, bool mte_p) { target_desc_up tdesc = allocate_target_description (); @@ -47,5 +48,9 @@ aarch64_create_target_description (uint64_t vq, bool pauth_p) if (pauth_p) regnum = create_feature_aarch64_pauth (tdesc.get (), regnum); + /* Memory tagging extension registers. */ + if (mte_p) + regnum = create_feature_aarch64_mte (tdesc.get (), regnum); + return tdesc.release (); } diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h index b75352461a..e337ff7d34 100644 --- a/gdb/arch/aarch64.h +++ b/gdb/arch/aarch64.h @@ -25,9 +25,12 @@ /* Create the aarch64 target description. A non zero VQ value indicates both the presence of SVE and the Vector Quotient - the number of 128bit chunks in an SVE Z register. HAS_PAUTH_P indicates the presence of the PAUTH - feature. */ + feature. -target_desc *aarch64_create_target_description (uint64_t vq, bool has_pauth_p); + MTE_P indicates the presence of the Memory Tagging Extension feature. */ + +target_desc *aarch64_create_target_description (uint64_t vq, bool has_pauth_p, + bool mte_p); /* Register numbers of various important registers. Note that on SVE, the Z registers reuse the V register numbers and the V diff --git a/gdb/features/Makefile b/gdb/features/Makefile index 61a4fe783f..d2e68c9f32 100644 --- a/gdb/features/Makefile +++ b/gdb/features/Makefile @@ -202,6 +202,7 @@ $(outdir)/%.dat: %.xml number-regs.xsl sort-regs.xsl gdbserver-regs.xsl FEATURE_XMLFILES = aarch64-core.xml \ aarch64-fpu.xml \ aarch64-pauth.xml \ + aarch64-mte.xml \ arc/v1-core.xml \ arc/v1-aux.xml \ arc/v2-core.xml \ diff --git a/gdb/features/aarch64-mte.c b/gdb/features/aarch64-mte.c new file mode 100644 index 0000000000..883b19cd15 --- /dev/null +++ b/gdb/features/aarch64-mte.c @@ -0,0 +1,14 @@ +/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: + Original: aarch64-mte.xml */ + +#include "gdbsupport/tdesc.h" + +static int +create_feature_aarch64_mte (struct target_desc *result, long regnum) +{ + struct tdesc_feature *feature; + + feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.mte"); + tdesc_create_reg (feature, "tag_ctl", regnum++, 0, "system", 64, "uint64"); + return regnum; +} diff --git a/gdb/features/aarch64-mte.xml b/gdb/features/aarch64-mte.xml new file mode 100644 index 0000000000..85455b13b2 --- /dev/null +++ b/gdb/features/aarch64-mte.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/gdbserver/linux-aarch64-ipa.cc b/gdbserver/linux-aarch64-ipa.cc index 694dfd77df..1a47bf95d7 100644 --- a/gdbserver/linux-aarch64-ipa.cc +++ b/gdbserver/linux-aarch64-ipa.cc @@ -147,12 +147,12 @@ get_raw_reg (const unsigned char *raw_regs, int regnum) /* Return target_desc to use for IPA, given the tdesc index passed by gdbserver. Index is ignored, since we have only one tdesc - at the moment. SVE and pauth not yet supported. */ + at the moment. SVE, pauth and MTE not yet supported. */ const struct target_desc * get_ipa_tdesc (int idx) { - return aarch64_linux_read_description (0, false); + return aarch64_linux_read_description (0, false, false); } /* Allocate buffer for the jump pads. The branch instruction has a reach @@ -204,6 +204,6 @@ alloc_jump_pad_buffer (size_t size) void initialize_low_tracepoint (void) { - /* SVE and pauth not yet supported. */ - aarch64_linux_read_description (0, false); + /* SVE, pauth and MTE not yet supported. */ + aarch64_linux_read_description (0, false, false); } diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 941acfb920..eabe3f0aa0 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -664,9 +664,13 @@ aarch64_target::low_arch_setup () { uint64_t vq = aarch64_sve_get_vq (tid); unsigned long hwcap = linux_get_hwcap (8); + unsigned long hwcap2 = linux_get_hwcap2 (8); bool pauth_p = hwcap & AARCH64_HWCAP_PACA; + /* MTE is AArch64-only. */ + bool mte_p = hwcap2 & HWCAP2_MTE; - current_process ()->tdesc = aarch64_linux_read_description (vq, pauth_p); + current_process ()->tdesc + = aarch64_linux_read_description (vq, pauth_p, mte_p); } else current_process ()->tdesc = aarch32_linux_read_description (); diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbserver/linux-aarch64-tdesc.cc index 897fbb43bd..3c5233d1fb 100644 --- a/gdbserver/linux-aarch64-tdesc.cc +++ b/gdbserver/linux-aarch64-tdesc.cc @@ -27,22 +27,22 @@ #include /* All possible aarch64 target descriptors. */ -struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/]; +struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/][2 /* mte */]; /* Create the aarch64 target description. */ const target_desc * -aarch64_linux_read_description (uint64_t vq, bool pauth_p) +aarch64_linux_read_description (uint64_t vq, bool pauth_p, bool mte_p) { if (vq > AARCH64_MAX_SVE_VQ) error (_("VQ is %" PRIu64 ", maximum supported value is %d"), vq, AARCH64_MAX_SVE_VQ); - struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p]; + struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p][mte_p]; if (tdesc == NULL) { - tdesc = aarch64_create_target_description (vq, pauth_p); + tdesc = aarch64_create_target_description (vq, pauth_p, mte_p); static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL }; static const char *expedite_regs_aarch64_sve[] = { "x29", "sp", "pc", @@ -53,7 +53,7 @@ aarch64_linux_read_description (uint64_t vq, bool pauth_p) else init_target_desc (tdesc, expedite_regs_aarch64_sve); - tdesc_aarch64_list[vq][pauth_p] = tdesc; + tdesc_aarch64_list[vq][pauth_p][mte_p] = tdesc; } return tdesc; diff --git a/gdbserver/linux-aarch64-tdesc.h b/gdbserver/linux-aarch64-tdesc.h index 0165e633d4..09d42970a9 100644 --- a/gdbserver/linux-aarch64-tdesc.h +++ b/gdbserver/linux-aarch64-tdesc.h @@ -20,6 +20,7 @@ #ifndef GDBSERVER_LINUX_AARCH64_TDESC_H #define GDBSERVER_LINUX_AARCH64_TDESC_H -const target_desc * aarch64_linux_read_description (uint64_t vq, bool pauth_p); +const target_desc * aarch64_linux_read_description (uint64_t vq, bool pauth_p, + bool mte_p); #endif /* GDBSERVER_LINUX_AARCH64_TDESC_H */ -- 2.25.1