Re: [PATCH v3 3/8] gdbserver/linux-aarch64: Factor out function to get aarch64_features

Luis Machado via Gdb-patches
2023-02-01T09:00:25Z

On 1/30/23 04:45, Thiago Jung Bauermann wrote:
> It will be used in a subsequent commit. There's no functional change.
>
> Reviewed-by: Luis Machado <luis.machado@arm.com>
> Approved-By: Simon Marchi <simon.marchi@efficios.com>
> ---
> gdbserver/linux-aarch64-low.cc | 36 ++++++++++++++++++++++------------
> 1 file changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
> index 2ed6e95562c5..92c621e5548c 100644
> --- a/gdbserver/linux-aarch64-low.cc
> +++ b/gdbserver/linux-aarch64-low.cc
> @@ -675,6 +675,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)
> +
> +/* Obtain the architectural features available in the given THREAD. */
> +
> +static struct aarch64_features
> +aarch64_get_arch_features (const thread_info *thread)
> +{
> + struct aarch64_features features;
> + int pid = thread->id.pid ();
> + int tid = thread->id.lwp ();
> +
> + features.vq = aarch64_sve_get_vq (tid);
> + /* A-profile PAC is 64-bit only. */
> + features.pauth = linux_get_hwcap (pid, 8) & AARCH64_HWCAP_PACA;
> + /* A-profile MTE is 64-bit only. */
> + features.mte = linux_get_hwcap2 (pid, 8) & HWCAP2_MTE;
> + features.tls = aarch64_tls_register_count (tid);
> +
> + return features;
> +}
> +
> void
> aarch64_target::low_new_thread (lwp_info *lwp)
> {
> @@ -827,9 +849,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
> @@ -845,15 +864,8 @@ aarch64_target::low_arch_setup ()
>
> if (is_elf64)
> {
> - struct aarch64_features features;
> - int pid = current_thread->id.pid ();
> -
> - features.vq = aarch64_sve_get_vq (tid);
> - /* A-profile PAC is 64-bit only. */
> - features.pauth = linux_get_hwcap (pid, 8) & AARCH64_HWCAP_PACA;
> - /* A-profile MTE is 64-bit only. */
> - features.mte = linux_get_hwcap2 (pid, 8) & HWCAP2_MTE;
> - features.tls = aarch64_tls_register_count (tid);
> + struct aarch64_features features
> + = aarch64_get_arch_features (current_thread);
>
> current_process ()->tdesc = aarch64_linux_read_description (features);
>

Still LGTM.