From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id AF3B23858415 for ; Fri, 5 Apr 2024 13:42:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF3B23858415 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AF3B23858415 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::635 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712324553; cv=none; b=iKPVIsg9IQmPLqt34WBsZwKLquhdfSOmkaVyiDAzIYGd6nJsSLRS+L5op0XDLC6TTBNWxDh8l3DwB2ZWmYjgNLk1l1AO3pbuOJv9OVUZv8qE8c0G4PFS+jg43eNr323WJCWyIvOp1z8wSidssowQCdNpGtUFxUGbYE1hbYFu9jA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712324553; c=relaxed/simple; bh=Rw0RhiMVjxcNSShusaL9GkfPCCGmXZiRt7GESYFYO28=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=hQKMkCFaVXxN2b+c1VDx0wCUjufQPPHcuPIPpsCdIE/1kblWFmMQEAOvQ1S97W3MHN0S5O5F8qmuVKaGZY3XijEVHLH3OJq/ZaOvbrEZYDUzUO2UKnxTfuhc4uzbeebrOiKBeH5qz6V52kvvyXW7mo52vLN8I47RaOUDcxBI37c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1dff837d674so18977285ad.3 for ; Fri, 05 Apr 2024 06:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712324549; x=1712929349; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=D2NvRWPuzIcraiIebb6fEtEXjrKeUhuoYIfMM/IMm3M=; b=F9d0U+hPSLhJyHgk1Geva3o1JLFD9w7iS4ESxqcbQBg4oPfu5E40cxek4bCnX772pn YEEi/cRzYb57DiyvqSOhrz1FyFKs5l5bq25MxNYXJ3/Ryy2mcYgIFj6bGIErF9NMw+ep W73wiVr/B5Lb29PV/WcusTDynN31eI5LqGrL+TNOC9l3dTqnN0jPtndBXK4Ri/C93RRO XNpXnPq+vPRu3JbE+L2yGjLNHM7q6WMKhqfzR/4s5czUwHgUGsInZD4LOaJv7biA/W7/ JegVQ37JBKA+t/aOitSGytokdU61roHRCaFzm36RFbdHfSFXUQJEpnXGI57K9ztoRajJ DXSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712324549; x=1712929349; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D2NvRWPuzIcraiIebb6fEtEXjrKeUhuoYIfMM/IMm3M=; b=PB/xYacH9GQ2zjg6ozCoRhadeBEuFdqRWhkXu1BpCyyM0CV2gxnD3HC6R/tu4b3YL0 WQ9omgurwpiDYTjXb3Vyf8MjWkKqKR4TgjvOXcpv2LFQDprpTe33N7qkXNLj7KDnzxVz bav2AHOrQuqCw/lMj6Ht9Rlk+JYwxip4nPH3icoG+u1dtUqiM2iT4hcqnofgFVStYpED /IDkH5YxNdERpjRC6ZDFo5eAY/IOeXbWuSDySuvU2pVqmDV7xABx7JpcRUDW6tf+HNzV aFPk/r+J/TbM2yiTwO5A6tTFNSLF9NPR845ZYsTPAplCWXp7REsFAkYpA3rS77ei+RTT YbUA== X-Forwarded-Encrypted: i=1; AJvYcCVOjKBwID4N2hnBR6vyHDvd6yGBJHrdn85qMoV3sk/xZeZF2wyjrfKV194i1tiUR03SRbjH3JqfOXdLkwQfYAWURHjoYDimqMJD X-Gm-Message-State: AOJu0YzCTfGHLvUoYt7c6+NIFYiulVceVHOHLPWApt9iC+kTGCnsvaxD tYu6hkWZMbF2NFb/Yfm47W9jfH51kVG17927NWNeyRSsDfKp8ebBLKUywbGlS32ObrTGbqOy13I 6 X-Google-Smtp-Source: AGHT+IGgeFOWKVHschwmZcODbwGxJ/c1WUX7m+J6lTPpG2O2P2I+FAJsEbmEfCviMfZlfL/b8Ce8UA== X-Received: by 2002:a17:902:c403:b0:1e2:bf94:487 with SMTP id k3-20020a170902c40300b001e2bf940487mr1575003plk.57.1712324549621; Fri, 05 Apr 2024 06:42:29 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:3e7e:1da:fede:338:8975? ([2804:1b3:a7c0:3e7e:1da:fede:338:8975]) by smtp.gmail.com with ESMTPSA id f6-20020a170902ce8600b001e28eea8a72sm1551167plg.185.2024.04.05.06.42.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Apr 2024 06:42:29 -0700 (PDT) Message-ID: <946cbc29-07ea-4c2f-a65e-c67d4a0448c2@linaro.org> Date: Fri, 5 Apr 2024 10:42:26 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/3] aarch64: Enhanced CPU diagnostics for ld.so To: Florian Weimer , libc-alpha@sourceware.org References: Content-Language: en-US From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 05/04/24 07:16, Florian Weimer wrote: > This prints some information from struct cpu_features, and the midr_el1 > and dczid_el0 system register contents on every CPU. > --- > manual/dynlink.texi | 34 +++++++++++ > sysdeps/aarch64/dl-diagnostics-cpu.c | 84 ++++++++++++++++++++++++++++ > 2 files changed, 118 insertions(+) > create mode 100644 sysdeps/aarch64/dl-diagnostics-cpu.c > > diff --git a/manual/dynlink.texi b/manual/dynlink.texi > index f2f2341818..6f4acf321d 100644 > --- a/manual/dynlink.texi > +++ b/manual/dynlink.texi > @@ -224,6 +224,40 @@ reflect adjustment by @theglibc{}. > These Linux-specific items show the values of @code{struct utsname}, as > reported by the @code{uname} function. @xref{Platform Type}. > > +@item aarch64.cpu_features.@dots{} > +These items are specific to the AArch64 architectures. They report data > +that is used by @theglibc{} to select alternative function > +implementations. Maybe also add some options are security related and not really tied to ifunc support (mte, bti). > + > +@item aarch64.processor[@var{index}].@dots{} > +These are additional items for the AArch64 architecture and are > +described below. > + > +@item aarch64.processor[@var{index}].requested=@var{kernel-cpu} > +The kernel is told to run the subsequent probing on the CPU numbered > +@var{kernel-cpu}. The values @var{kernel-cpu} and @var{index} can be > +distinct if there are gaps in the process CPU affinity mask. This line > +is not included if CPU affinity mask information is not available. > + > +@item aarch64.processor[@var{index}].observed=@var{kernel-cpu} > +This line reports the kernel CPU number @var{kernel-cpu} on which the > +probing code initially ran. If the CPU number cannot be obtained, > +this line is not printed. > + > +@item aarch64.processor[@var{index}].observed_node=@var{node} > +This reports the observed NUMA node number, as reported by the > +@code{getcpu} system call. If this information cannot be obtained, this > +line is not printed. > + > +@item aarch64.processor[@var{index}].midr_el1=@var{value} > +The value of the @code{midr_el1} system register on the processor > +@var{index}. This line is only printed if the kernel indicates that > +this system register is supported. > + > +@item aarch64.processor[@var{index}].dczid_el0=@var{value} > +The value of the @code{dczid_el0} system register on the processor > +@var{index}. > + > @cindex CPUID (diagnostics) > @item x86.cpu_features.@dots{} > These items are specific to the i386 and x86-64 architectures. They > diff --git a/sysdeps/aarch64/dl-diagnostics-cpu.c b/sysdeps/aarch64/dl-diagnostics-cpu.c > new file mode 100644 > index 0000000000..e037e6ea8c > --- /dev/null > +++ b/sysdeps/aarch64/dl-diagnostics-cpu.c > @@ -0,0 +1,84 @@ > +/* Print CPU diagnostics data in ld.so. AArch64 version. > + Copyright (C) 2021-2024 Free Software Foundation, Inc. Maybe just 2024 here. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library 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 > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include > + > +#include > +#include > +#include > +#include > + > +static void > +print_cpu_features_value (const char *label, uint64_t value) > +{ > + _dl_printf ("aarch64.cpu_features."); > + _dl_diagnostics_print_labeled_value (label, value); > +} > + > +static void > +print_per_cpu_value (const struct dl_iterate_cpu *dic, > + const char *label, uint64_t value) > +{ > + _dl_printf ("aarch64.processor[0x%x].", dic->processor_index); > + _dl_diagnostics_print_labeled_value (label, value); > +} > + > +void > +_dl_diagnostics_cpu (void) > +{ > + print_cpu_features_value ("bti", GLRO (dl_aarch64_cpu_features).bti); > + print_cpu_features_value ("midr_el1", > + GLRO (dl_aarch64_cpu_features).midr_el1); > + print_cpu_features_value ("mops", GLRO (dl_aarch64_cpu_features).mops); > + print_cpu_features_value ("mte_state", > + GLRO (dl_aarch64_cpu_features).mte_state); > + print_cpu_features_value ("prefer_sve_ifuncs", > + GLRO (dl_aarch64_cpu_features).prefer_sve_ifuncs); > + print_cpu_features_value ("sve", GLRO (dl_aarch64_cpu_features).sve); > + print_cpu_features_value ("zva_size", > + GLRO (dl_aarch64_cpu_features).zva_size); > + > + struct dl_iterate_cpu dic; > + _dl_iterate_cpu_init (&dic); > + > + while (_dl_iterate_cpu_next (&dic)) > + { > + if (dic.requested_cpu >= 0) > + _dl_printf ("aarch64.processor[0x%x].requested=0x%x\n", > + dic.processor_index, dic.requested_cpu); > + if (dic.actual_cpu >= 0) > + _dl_printf ("aarch64.processor[0x%x].observed=0x%x\n", > + dic.processor_index, dic.actual_cpu); > + if (dic.actual_node >= 0) > + _dl_printf ("aarch64.processor[0x%x].observed_node=0x%x\n", > + dic.processor_index, dic.actual_node); > + > + if (GLRO (dl_hwcap) & HWCAP_CPUID) > + { > + uint64_t midr_el1; > + asm ("mrs %0, midr_el1" : "=r" (midr_el1)); > + print_per_cpu_value (&dic, "midr_el1", midr_el1); > + } > + > + { > + uint64_t dczid_el0; > + asm ("mrs %0, dczid_el0" : "=r" (dczid_el0)); > + print_per_cpu_value (&dic, "dczid_el0", dczid_el0); > + } > + } > +} The rest looks ok.