From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by sourceware.org (Postfix) with ESMTPS id BC5B5385803E for ; Thu, 8 Sep 2022 06:43:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BC5B5385803E Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-1278624b7c4so23694558fac.5 for ; Wed, 07 Sep 2022 23:43:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=8Od6aXXbCESiuBc1r03ToIZFLd8pQm9MqQoxgCIz7jQ=; b=iGYqIDEZfohPOTdetNCKAUvGQTDBDjCHxnrzqSBadjoYplvR9UI2WDDSiDAjGGM9g6 /tDAIk/AmKVIbPqleXZgWk8oHiw3G1RLEv7GechvWIx+eXm5Vt66nc5MwqovZcQLwzUM Q6PiD7rk/K6hGZoKuXZ3dvG+PykbF4tlvQmzUZvEN2iF/BaCClcXS/fsJZo/8vruCpjL 72zwDBRliNbpG1TBnVesYp7MwJC82FlfD7pDpMVkUsYgN63Be1GllYm03O2Srleagac2 mSSElG9vw0p+RRJ1URyf4LnMOw6RG1so0h2IM9fhVYzqTOcenxiNDPDhdnJp0aO1DE6W KYKA== X-Gm-Message-State: ACgBeo1Mm8i2wcoNdfGoTYctSvpDyk0py0zAvxJ+5FnGDrtI7WdgfA2w fGTtgHJOczA4oLwW2r63/x4xOznO22oGkQ== X-Google-Smtp-Source: AA6agR6n8H3xZsTRwSTSF6NHU432Iv3Q5u/ZsW3ApVt/5yEHKWyr11iARulZYlpLSEtDJLfl3v/1Hw== X-Received: by 2002:a05:6808:15a4:b0:343:4205:1a1c with SMTP id t36-20020a05680815a400b0034342051a1cmr821370oiw.182.1662619380042; Wed, 07 Sep 2022 23:43:00 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:8eab:4efc:ca3b:b046]) by smtp.gmail.com with ESMTPSA id r11-20020acaf30b000000b00345cce8083dsm7187692oih.33.2022.09.07.23.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 23:42:59 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Thiago Jung Bauermann Subject: [PATCH 4/8] gdbserver/linux-aarch64: Factor out function to get aarch64_features Date: Thu, 8 Sep 2022 06:41:47 +0000 Message-Id: <20220908064151.3959930-5-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220908064151.3959930-1-thiago.bauermann@linaro.org> References: <20220908064151.3959930-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 08 Sep 2022 06:43:02 -0000 It will be used in a subsequent commit. There's no functional change. --- gdbserver/linux-aarch64-low.cc | 45 ++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 576925838f49..9b57be73818e 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -652,6 +652,28 @@ aarch64_target::low_delete_process (arch_process_info *info) xfree (info); } +/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */ +#define AARCH64_HWCAP_PACA (1 << 30) + +static gdb::optional +aarch64_get_arch_features (const thread_info *thread) +{ + struct aarch64_features features; + int vq = aarch64_sve_get_vq (thread->id.lwp ()); + + if (vq < 0) + return {}; + + features.vq = vq; + /* A-profile PAC is 64-bit only. */ + features.pauth = linux_get_hwcap (thread, 8) & AARCH64_HWCAP_PACA; + /* A-profile MTE is 64-bit only. */ + features.mte = linux_get_hwcap2 (thread, 8) & HWCAP2_MTE; + features.tls = true; + + return features; +} + void aarch64_target::low_new_thread (lwp_info *lwp) { @@ -804,9 +826,6 @@ aarch64_adjust_register_sets (const struct aarch64_features &features) } } -/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */ -#define AARCH64_HWCAP_PACA (1 << 30) - /* Implementation of linux target ops method "low_arch_setup". */ void @@ -822,24 +841,18 @@ aarch64_target::low_arch_setup () if (is_elf64) { - struct aarch64_features features; - int vq = aarch64_sve_get_vq (tid); + gdb::optional features + = aarch64_get_arch_features (current_thread); - /* If ptrace fails we can't determine vq, but the low_arch_setup method - always succeeds so all we can do here is assert that vq is valid. */ - gdb_assert (vq >= 0); - features.vq = vq; - /* A-profile PAC is 64-bit only. */ - features.pauth = linux_get_hwcap (current_thread, 8) & AARCH64_HWCAP_PACA; - /* A-profile MTE is 64-bit only. */ - features.mte = linux_get_hwcap2 (current_thread, 8) & HWCAP2_MTE; - features.tls = true; + /* If ptrace fails we can't determine vq, but low_arch_setup always + succeeds so all we can do here is assert that features is valid. */ + gdb_assert (features.has_value ()); - current_process ()->tdesc = aarch64_linux_read_description (features); + current_process ()->tdesc = aarch64_linux_read_description (*features); /* Adjust the register sets we should use for this particular set of features. */ - aarch64_adjust_register_sets (features); + aarch64_adjust_register_sets (*features); } else current_process ()->tdesc = aarch32_linux_read_description ();