From patchwork Wed Feb 26 19:00:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 868540 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f56:0:b0:38f:210b:807b with SMTP id cm22csp959163wrb; Wed, 26 Feb 2025 11:04:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWj2qZG/s3iWnqCJf3LN4Fne7PEs7P7sY8j8WYSyrMVMFUoRpsuhw6pubpHiwdlD+jYftmgrQ==@linaro.org X-Google-Smtp-Source: AGHT+IFZPzjHxDaBvRKOrofiLbq6UiAZ6L0W/WxNsNhoFqUl3QEneo7GEtRSPUrZSdbvItGC6qMD X-Received: by 2002:a05:6808:3c8f:b0:3f4:18d1:69b5 with SMTP id 5614622812f47-3f540ec6921mr5176981b6e.16.1740596653896; Wed, 26 Feb 2025 11:04:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1740596653; cv=pass; d=google.com; s=arc-20240605; b=XLvlANiYTZkfQfZ43yUKy76M1YF7vRwkaBCU8qeD1yNEyjsKEu7jkB49Wm20Fa9WOQ gWG6xXsXuauJrilobishJna885Ym6AqfbwN/AV7t1fj5hU1NJ+DVnX0C0BfsdMpXioYP jBxfRYc+Wi0TjpxQ14Jzgsw4EQeD1xytuBkow00aolkntcxRk9HIBVzhwT2GMPTlfWeG rs0T90DOAqduc2Zv2JELD/eE9w88i7YYvWZjZNOFv2GCBSDQvgA2kCD+oRlTBP9vaqBB bjM3qVM7ojl2ahPdINRJ7EMbMlwhFqwihbm2iYJh7NJr8TXCbyl6ZCepd6wKPr3bzQAc ZFjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:dkim-filter:arc-filter:dmarc-filter:delivered-to :dkim-filter; bh=VjjasWyBrTVpUQPRvfAF8Iy97ov9bYENB/9SKdWsEkQ=; fh=LwDEXkF2BCfvt5pKmeQEzNeZtO/ktrc/ajkpXRdekFs=; b=jpbJWhM4ddY15sO4dt8ZY3wf9XLJH5oXXDYvZ/x6EugRUCofZbPbO6J+aoEc6gJ73/ h/YuzwefBzu7f5y6ht5Po3SGnG2aEiiVe0Z2IYcfi+dR054VhvMhWyQcMuZc8k62ROgp eEmkWQim+VJvYXDjcmhlcUNHjrWQ827Ht8AaoRsfyK/+3sGp3nh8rtxmrggqHmhJUxaf WCq1ofxvuBQ5tyaLq7wPln6JK75CNqnkFcRexJfozxUbc3L8y2oH0u3RJybeL1M6ZQM5 mLpslM7mYEIqV/BTFjqH48OrlE2JO/KLOE2qqNLMDxXQkO1dljCXyh23l14l7hQkaZ+x Nh+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mtdchKA2; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 5614622812f47-3f541c4569dsi3186959b6e.227.2025.02.26.11.04.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2025 11:04:13 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mtdchKA2; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AAEE73858CD9 for ; Wed, 26 Feb 2025 19:04:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AAEE73858CD9 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=mtdchKA2 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 2B0F23858D34 for ; Wed, 26 Feb 2025 19:03:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B0F23858D34 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 2B0F23858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740596600; cv=none; b=ZMjsNzCnNMhCCxATE2zjRbW1eQGMbALijZCQ5zII3+Pbiep6z//z52HfNgkqKFd8inuzivM1xdKdleQGIdGRZo9b4p2hviKg0iEEP8A+zjwLuwocKC1lUSsOedF0+eHhNVf7vTksERTb6geFq7ooC8TyHnse92joaG6jIAzA/NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740596600; c=relaxed/simple; bh=V8/ymzUs8hdhoNcuNvW9amThOhGwaPd90SEh5Y6BltA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=P3sMpfi0nQ1BDVON2AMxBg8j7dRmSNYc7PqgVRz7OSFW6TBXpJZLOFIUPZSAmSZDW2vKvVcYesmB8g0e+GWyAOnhUWbY4xQPHyugV75UM7teKKEoSKFOaPzbfzAXvawkmAgb8RvlQQPs5AiMfmVoXV4F0Av4sMWlRNNT+CimN8M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B0F23858D34 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-220f4dd756eso1650315ad.3 for ; Wed, 26 Feb 2025 11:03:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1740596599; x=1741201399; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=VjjasWyBrTVpUQPRvfAF8Iy97ov9bYENB/9SKdWsEkQ=; b=mtdchKA2zbxHKzF7Jkps0DoPQ1ZhyHkmv3UMOm59Ucg+ooDvQKeuftq/gt5XYqKdVV N8eM2HpR4PKF6B61mnh9LjHI5Ke0S6vSx+nYpWDBZ/FtLNTgjTbyMwBuR0UhzyB33sOr n0znmNWNV1lpiQ/XR79uXDhOPNcLF49m3369GHuQieVzF6QI7r1U7UAunpCr/ti4jiM6 Nyc5PqwSI7G3ZVo3x75BOW41p9Ajxo1coHHYDsgKlqJlEdJkO/Wg2/Jm0IFxNiOacOk+ qzy61mlPqmbd2uPvs0HRabP3yIDAWHWKvn2rxghnwNAcMg5IiZr9tPySAQeIvETsTbu4 Qqvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740596599; x=1741201399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VjjasWyBrTVpUQPRvfAF8Iy97ov9bYENB/9SKdWsEkQ=; b=auep6Cggke8KxrPnPcv6wB1lvhcaiKVUPjf8pMYlZ0K83mebyOnjQmSSixjJmPDrnf +j7erLjHgaykg+aThKTXFku8MHwbvZ2HJfA04ljhQR9gN2F+5NlmFhvigmqX/A6bE12E jWJN9bgnl95rB57peztGE9Tr4PcND64UJhxYbhnvh3YbHYnpn09gSmH6EXAZEVmqDgmh pBVLDOPFvn2NoglBTP/5x8DGfseCQ+sMDka5lSnfyrUg/cJAjdXmkC9bWXPyF5gxKjr2 ziijeB/Ag7eJjTk8vbcjy7oi5ZdsLuljOntx8kMTAQZcOFkzFAh2+tr2JR+LrB9UVSkM W/mA== X-Gm-Message-State: AOJu0YxVkkoxBPaPn5GFlPyr/b7km3gg0Gu0oxI+z9hdO5Oe2QztsxUI mCXJ/hkniWV1UOpesI/3bRpu+JPmzYk5eV/N3uffjvfgMplPkqSD+M5ctIs/8Cnuq5ajMq9sEAB b X-Gm-Gg: ASbGncvf7InkxeC3fy+U5v/5Wu4x/HatiTWtRi790ntHBEVLnZ8NLxgQDvoq6/dvB4E NM+SyV8t5m9TPFNYhiesk8YaF9/mrX0pijv12J0t7GUnfq5mRRp3chAppWgDFbRHdvyF5I5t5EJ lEnPMp8OJivTC7jOY6M4jUjv37YRMhDwq1E496qjLHnOToXHG1q+BZeiblyKWpRRvr2ZZp2NG+y ScAzcKjtoSy5gFgoQ0eKHYLOUamT4S34YMfCqkP09IegSzHd62OmdccaJ+cHCw+rYNi5CQ1fGeB xh1Kut95VUR/+CnsLhtTzolzQFezhfNt2JF9k68= X-Received: by 2002:a17:902:dacd:b0:215:e685:fa25 with SMTP id d9443c01a7336-22307b5302bmr117447145ad.20.1740596598631; Wed, 26 Feb 2025 11:03:18 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c3:f704:a0c6:9418:957f:d5bf]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22344c837e2sm6946185ad.139.2025.02.26.11.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2025 11:03:18 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Stefan Liebler , Peter Bergner , Wilco Dijkstra Subject: [PATCH 2/6] powerpc: Move AT_HWCAP descriptions to ld diagnostics Date: Wed, 26 Feb 2025 16:00:18 -0300 Message-ID: <20250226190308.2163908-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250226190308.2163908-1-adhemerval.zanella@linaro.org> References: <20250226190308.2163908-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org The ld.so diagnostics already prints AT_HWCAP values, but only in hexadecimal. To avoid duplicating the strings, consolidate the hwcap_names from cpu-features.h on a new file, dl-hwcap-info.h (and it also improves the hwcap string description with more values). For future AT_HWCAP3/AT_HWCAP4 extensions, it is just a matter to add them on dl-hwcap-info.c so both ld diagnostics and tunable filtering will parse the new values. Checked on powerpc64le-linux-gnu. --- sysdeps/powerpc/dl-diagnostics-cpu.c | 48 +++++++ sysdeps/powerpc/dl-procinfo.c | 31 ----- sysdeps/powerpc/dl-procinfo.h | 62 ---------- sysdeps/unix/sysv/linux/powerpc/Makefile | 4 + .../unix/sysv/linux/powerpc/cpu-features.c | 46 ++++--- .../unix/sysv/linux/powerpc/cpu-features.h | 99 --------------- .../unix/sysv/linux/powerpc/dl-hwcap-info.c | 117 ++++++++++++++++++ .../unix/sysv/linux/powerpc/dl-hwcap-info.h | 34 +++++ 8 files changed, 230 insertions(+), 211 deletions(-) create mode 100644 sysdeps/powerpc/dl-diagnostics-cpu.c create mode 100644 sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.c create mode 100644 sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.h diff --git a/sysdeps/powerpc/dl-diagnostics-cpu.c b/sysdeps/powerpc/dl-diagnostics-cpu.c new file mode 100644 index 0000000000..db8d19c7ec --- /dev/null +++ b/sysdeps/powerpc/dl-diagnostics-cpu.c @@ -0,0 +1,48 @@ +/* Print CPU diagnostics data in ld.so. PowerPC version. + Copyright (C) 2025 Free Software Foundation, Inc. + 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 + +static void +print_hwcap_value (const char *label, int hwcap, unsigned long int value) +{ + _dl_printf ("powerpc.cpu_features.%s=\"", label); + size_t offset = 0; + for (int i = 0; i < __dl_hwcap_info_size; ++i) + { + const char *hwcap_name = __dl_hwcap_names + offset; + size_t hwcap_name_len = strlen (hwcap_name); + if (hwcap == __dl_hwcap_info[i].hwcap + && value & __dl_hwcap_info[i].value) + _dl_printf ("%s ", hwcap_name); + offset += hwcap_name_len + 1; + } + _dl_printf ("\"\n"); +} + +void +_dl_diagnostics_cpu (void) +{ + print_hwcap_value ("hwcap", AT_HWCAP, GLRO(dl_hwcap)); + print_hwcap_value ("hwcap2", AT_HWCAP2, GLRO(dl_hwcap2)); + print_hwcap_value ("hwcap3", AT_HWCAP3, GLRO(dl_hwcap3)); + print_hwcap_value ("hwcap4", AT_HWCAP4, GLRO(dl_hwcap4)); +} diff --git a/sysdeps/powerpc/dl-procinfo.c b/sysdeps/powerpc/dl-procinfo.c index 1df247ac07..0db1e65112 100644 --- a/sysdeps/powerpc/dl-procinfo.c +++ b/sysdeps/powerpc/dl-procinfo.c @@ -62,37 +62,6 @@ PROCINFO_CLASS struct cpu_features _dl_powerpc_cpu_features # endif #endif -#if !defined PROCINFO_DECL && defined SHARED - ._dl_powerpc_cap_flags -#else -PROCINFO_CLASS const char _dl_powerpc_cap_flags[_DL_HWCAP_COUNT][15] -#endif -#ifndef PROCINFO_DECL -= { - "ppcle", "true_le", "", "", - "", "", "archpmu", "vsx", - "arch_2_06", "power6x", "dfp", "pa6t", - "arch_2_05", "ic_snoop", "smt", "booke", - "cellbe", "power5+", "power5", "power4", - "notb", "efpdouble", "efpsingle", "spe", - "ucache", "4xxmac", "mmu", "fpu", - "altivec", "ppc601", "ppc64", "ppc32", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "mma", "arch_3_1", "htm-no-suspend", - "scv", "darn", "ieee128", "arch_3_00", - "htm-nosc", "vcrypto", "tar", "isel", - "ebb", "dscr", "htm", "arch_2_07", - } -#endif -#if !defined SHARED || defined PROCINFO_DECL -; -#else -, -#endif - #if !IS_IN (ldconfig) # if !defined PROCINFO_DECL && defined SHARED ._dl_cache_line_size diff --git a/sysdeps/powerpc/dl-procinfo.h b/sysdeps/powerpc/dl-procinfo.h index 585ce41226..04bbe7ba1c 100644 --- a/sysdeps/powerpc/dl-procinfo.h +++ b/sysdeps/powerpc/dl-procinfo.h @@ -20,20 +20,6 @@ #define _DL_PROCINFO_H 1 #include -#include /* This defines the PPC_FEATURE[2]_* macros. */ - -/* Feature masks are all 32-bits in size. */ -#define _DL_HWCAP_SIZE 32 - -/* AT_HWCAP2 feature strings follow the AT_HWCAP feature strings. */ -#define _DL_HWCAP2_OFFSET _DL_HWCAP_SIZE - -/* AT_HWCAP3 feature strings follow the AT_HWCAP2 feature strings. */ -#define _DL_HWCAP3_OFFSET (_DL_HWCAP2_OFFSET + _DL_HWCAP_SIZE) - -/* AT_HWCAP4 feature strings follow the AT_HWCAP3 feature strings. */ -#define _DL_HWCAP4_OFFSET (_DL_HWCAP3_OFFSET + _DL_HWCAP_SIZE) - #define _DL_FIRST_PLATFORM 32 @@ -56,13 +42,6 @@ #define PPC_PLATFORM_POWER10 15 #define PPC_PLATFORM_POWER11 16 -static inline const char * -__attribute__ ((unused)) -_dl_hwcap_string (int idx) -{ - return GLRO(dl_powerpc_cap_flags)[idx]; -} - static inline int __attribute__ ((unused, always_inline)) _dl_string_platform (const char *str) @@ -183,47 +162,6 @@ _dl_procinfo (unsigned int type, unsigned long int word) { switch(type) { - case AT_HWCAP: - _dl_printf ("AT_HWCAP: "); - - for (int i = 0; i < _DL_HWCAP_SIZE; ++i) - if (word & (1 << i)) - _dl_printf (" %s", _dl_hwcap_string (i)); - break; - case AT_HWCAP2: - { - - _dl_printf ("AT_HWCAP2: "); - - /* We have to go through them all because the kernel added the - AT_HWCAP2 features starting with the high bits. */ - for (int i = 0; i < _DL_HWCAP_SIZE; ++i) - if (word & (1 << i)) - _dl_printf (" %s", _dl_hwcap_string (_DL_HWCAP2_OFFSET + i)); - break; - } - case AT_HWCAP3: - { - _dl_printf ("AT_HWCAP3: "); - - /* We have to go through them all because the kernel added the - AT_HWCAP3 features starting with the high bits. */ - for (int i = 0; i < _DL_HWCAP_SIZE; ++i) - if (word & (1 << i)) - _dl_printf (" %s", _dl_hwcap_string (_DL_HWCAP3_OFFSET + i)); - break; - } - case AT_HWCAP4: - { - _dl_printf ("AT_HWCAP4: "); - - /* We have to go through them all because the kernel added the - AT_HWCAP4 features starting with the high bits. */ - for (int i = 0; i <= _DL_HWCAP_SIZE; ++i) - if (word & (1 << i)) - _dl_printf (" %s", _dl_hwcap_string (_DL_HWCAP4_OFFSET + i)); - break; - } case AT_L1I_CACHEGEOMETRY: { cache_geometry ("AT_L1I_CACHEGEOMETRY: ", word); diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile index 24827efe79..cddb624bf2 100644 --- a/sysdeps/unix/sysv/linux/powerpc/Makefile +++ b/sysdeps/unix/sysv/linux/powerpc/Makefile @@ -13,6 +13,10 @@ gen-as-const-headers += ucontext_i.sym endif ifeq ($(subdir),elf) +dl-routines += \ + dl-hwcap-info \ + # dl-routines + # Otherwise tst-tls-dlinfo fails due to tst-tlsmod2.so using static tls. ifeq ($(have-tls-get-addr-optimize),yes) LDFLAGS-tst-tlsmod2.so += -Wl,--no-tls-get-addr-optimize diff --git a/sysdeps/unix/sysv/linux/powerpc/cpu-features.c b/sysdeps/unix/sysv/linux/powerpc/cpu-features.c index bcce635763..f0fabac0e0 100644 --- a/sysdeps/unix/sysv/linux/powerpc/cpu-features.c +++ b/sysdeps/unix/sysv/linux/powerpc/cpu-features.c @@ -21,9 +21,22 @@ #include #include #include +#include #include #include +#define ENABLE_BIT(__hwcap, __v) __hwcap &= (__v) +#define DISABLE_BIT(__hwcap, __h, __v) __hwcap |= (__h) & (__v) + +static void set_hwcap_bit (unsigned long int *hwcap, bool disable, + unsigned long int tcb_value, unsigned int value) +{ + if (disable) + *hwcap &= ~value; + else + *hwcap |= tcb_value & value; +} + static void TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) { @@ -55,32 +68,27 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) continue; size_t offset = 0; - for (int i = 0; i < array_length (hwcap_tunables); ++i) + for (int i = 0; i < __dl_hwcap_info_size; ++i) { - const char *hwcap_name = hwcap_names + offset; + const char *hwcap_name = __dl_hwcap_names + offset; size_t hwcap_name_len = strlen (hwcap_name); /* Check the tunable name on the supported list. */ if (tunable_str_comma_strcmp (&t, hwcap_name, hwcap_name_len)) { - /* Update the hwcap and hwcap2 bits. */ - if (t.disable) + switch (__dl_hwcap_info[i].hwcap) { - /* Id is 1 for hwcap2 tunable. */ - if (hwcap_tunables[i].id) - cpu_features->hwcap2 &= ~(hwcap_tunables[i].mask); - else - cpu_features->hwcap &= ~(hwcap_tunables[i].mask); - } - else - { - /* Enable the features and also check that no unsupported - features were enabled by user. */ - if (hwcap_tunables[i].id) - cpu_features->hwcap2 |= (tcbv_hwcap2 & hwcap_tunables[i].mask); - else - cpu_features->hwcap |= (tcbv_hwcap & hwcap_tunables[i].mask); + case AT_HWCAP: + set_hwcap_bit (&cpu_features->hwcap, t.disable, tcbv_hwcap, + __dl_hwcap_info[i].value); + break; + + case AT_HWCAP2: + set_hwcap_bit (&cpu_features->hwcap2, t.disable, tcbv_hwcap2, + __dl_hwcap_info[i].value); + break; + + /* Ignore unknown values. */ } - break; } offset += hwcap_name_len + 1; } diff --git a/sysdeps/unix/sysv/linux/powerpc/cpu-features.h b/sysdeps/unix/sysv/linux/powerpc/cpu-features.h index 3c5cc6e84d..f15a80374c 100644 --- a/sysdeps/unix/sysv/linux/powerpc/cpu-features.h +++ b/sysdeps/unix/sysv/linux/powerpc/cpu-features.h @@ -30,103 +30,4 @@ struct cpu_features unsigned long int hwcap4; }; -static const char hwcap_names[] = { - "4xxmac\0" - "altivec\0" - "arch_2_05\0" - "arch_2_06\0" - "archpmu\0" - "booke\0" - "cellbe\0" - "dfp\0" - "efpdouble\0" - "efpsingle\0" - "fpu\0" - "ic_snoop\0" - "mmu\0" - "notb\0" - "pa6t\0" - "power4\0" - "power5\0" - "power5+\0" - "power6x\0" - "ppc32\0" - "ppc601\0" - "ppc64\0" - "ppcle\0" - "smt\0" - "spe\0" - "true_le\0" - "ucache\0" - "vsx\0" - "arch_2_07\0" - "dscr\0" - "ebb\0" - "htm\0" - "htm-nosc\0" - "htm-no-suspend\0" - "isel\0" - "tar\0" - "vcrypto\0" - "arch_3_00\0" - "ieee128\0" - "darn\0" - "scv\0" - "arch_3_1\0" - "mma\0" -}; - -static const struct -{ - unsigned int mask; - bool id; -} hwcap_tunables[] = { - /* AT_HWCAP tunable masks. */ - { PPC_FEATURE_HAS_4xxMAC, 0 }, - { PPC_FEATURE_HAS_ALTIVEC, 0 }, - { PPC_FEATURE_ARCH_2_05, 0 }, - { PPC_FEATURE_ARCH_2_06, 0 }, - { PPC_FEATURE_PSERIES_PERFMON_COMPAT, 0 }, - { PPC_FEATURE_BOOKE, 0 }, - { PPC_FEATURE_CELL_BE, 0 }, - { PPC_FEATURE_HAS_DFP, 0 }, - { PPC_FEATURE_HAS_EFP_DOUBLE, 0 }, - { PPC_FEATURE_HAS_EFP_SINGLE, 0 }, - { PPC_FEATURE_HAS_FPU, 0 }, - { PPC_FEATURE_ICACHE_SNOOP, 0 }, - { PPC_FEATURE_HAS_MMU, 0 }, - { PPC_FEATURE_NO_TB, 0 }, - { PPC_FEATURE_PA6T, 0 }, - { PPC_FEATURE_POWER4, 0 }, - { PPC_FEATURE_POWER5, 0 }, - { PPC_FEATURE_POWER5_PLUS, 0 }, - { PPC_FEATURE_POWER6_EXT, 0 }, - { PPC_FEATURE_32, 0 }, - { PPC_FEATURE_601_INSTR, 0 }, - { PPC_FEATURE_64, 0 }, - { PPC_FEATURE_PPC_LE, 0 }, - { PPC_FEATURE_SMT, 0 }, - { PPC_FEATURE_HAS_SPE, 0 }, - { PPC_FEATURE_TRUE_LE, 0 }, - { PPC_FEATURE_UNIFIED_CACHE, 0 }, - { PPC_FEATURE_HAS_VSX, 0 }, - - /* AT_HWCAP2 tunable masks. */ - { PPC_FEATURE2_ARCH_2_07, 1 }, - { PPC_FEATURE2_HAS_DSCR, 1 }, - { PPC_FEATURE2_HAS_EBB, 1 }, - { PPC_FEATURE2_HAS_HTM, 1 }, - { PPC_FEATURE2_HTM_NOSC, 1 }, - { PPC_FEATURE2_HTM_NO_SUSPEND, 1 }, - { PPC_FEATURE2_HAS_ISEL, 1 }, - { PPC_FEATURE2_HAS_TAR, 1 }, - { PPC_FEATURE2_HAS_VEC_CRYPTO, 1 }, - { PPC_FEATURE2_ARCH_3_00, 1 }, - { PPC_FEATURE2_HAS_IEEE128, 1 }, - { PPC_FEATURE2_DARN, 1 }, - { PPC_FEATURE2_SCV, 1 }, - { PPC_FEATURE2_ARCH_3_1, 1 }, - { PPC_FEATURE2_MMA, 1 }, -}; - #endif /* __CPU_FEATURES_H */ diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.c b/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.c new file mode 100644 index 0000000000..1178828744 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.c @@ -0,0 +1,117 @@ +/* HWCAP string information. PowerPC version. + Copyright (C) 2017-2025 Free Software Foundation, Inc. + + 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 + +const char __dl_hwcap_names[] = { + "4xxmac\0" + "altivec\0" + "arch_2_05\0" + "arch_2_06\0" + "archpmu\0" + "booke\0" + "cellbe\0" + "dfp\0" + "efpdouble\0" + "efpsingle\0" + "fpu\0" + "ic_snoop\0" + "mmu\0" + "notb\0" + "pa6t\0" + "power4\0" + "power5\0" + "power5+\0" + "power6x\0" + "ppc32\0" + "ppc601\0" + "ppc64\0" + "ppcle\0" + "smt\0" + "spe\0" + "true_le\0" + "ucache\0" + "vsx\0" + "arch_2_07\0" + "dscr\0" + "ebb\0" + "htm\0" + "htm-nosc\0" + "htm-no-suspend\0" + "isel\0" + "tar\0" + "vcrypto\0" + "arch_3_00\0" + "ieee128\0" + "darn\0" + "scv\0" + "arch_3_1\0" + "mma\0" +}; + +const struct hwcap_info_t __dl_hwcap_info[] = +{ + /* AT_HWCAP tunable masks. */ + { PPC_FEATURE_HAS_4xxMAC, AT_HWCAP }, + { PPC_FEATURE_HAS_ALTIVEC, AT_HWCAP }, + { PPC_FEATURE_ARCH_2_05, AT_HWCAP }, + { PPC_FEATURE_ARCH_2_06, AT_HWCAP }, + { PPC_FEATURE_PSERIES_PERFMON_COMPAT, AT_HWCAP }, + { PPC_FEATURE_BOOKE, AT_HWCAP }, + { PPC_FEATURE_CELL_BE, AT_HWCAP }, + { PPC_FEATURE_HAS_DFP, AT_HWCAP }, + { PPC_FEATURE_HAS_EFP_DOUBLE, AT_HWCAP }, + { PPC_FEATURE_HAS_EFP_SINGLE, AT_HWCAP }, + { PPC_FEATURE_HAS_FPU, AT_HWCAP }, + { PPC_FEATURE_ICACHE_SNOOP, AT_HWCAP }, + { PPC_FEATURE_HAS_MMU, AT_HWCAP }, + { PPC_FEATURE_NO_TB, AT_HWCAP }, + { PPC_FEATURE_PA6T, AT_HWCAP }, + { PPC_FEATURE_POWER4, AT_HWCAP }, + { PPC_FEATURE_POWER5, AT_HWCAP }, + { PPC_FEATURE_POWER5_PLUS, AT_HWCAP }, + { PPC_FEATURE_POWER6_EXT, AT_HWCAP }, + { PPC_FEATURE_32, AT_HWCAP }, + { PPC_FEATURE_601_INSTR, AT_HWCAP }, + { PPC_FEATURE_64, AT_HWCAP }, + { PPC_FEATURE_PPC_LE, AT_HWCAP }, + { PPC_FEATURE_SMT, AT_HWCAP }, + { PPC_FEATURE_HAS_SPE, AT_HWCAP }, + { PPC_FEATURE_TRUE_LE, AT_HWCAP }, + { PPC_FEATURE_UNIFIED_CACHE, AT_HWCAP }, + { PPC_FEATURE_HAS_VSX, AT_HWCAP }, + + /* AT_HWCAP2 tunable masks. */ + { PPC_FEATURE2_ARCH_2_07, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_DSCR, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_EBB, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_HTM, AT_HWCAP2 }, + { PPC_FEATURE2_HTM_NOSC, AT_HWCAP2 }, + { PPC_FEATURE2_HTM_NO_SUSPEND, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_ISEL, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_TAR, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_VEC_CRYPTO, AT_HWCAP2 }, + { PPC_FEATURE2_ARCH_3_00, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_IEEE128, AT_HWCAP2 }, + { PPC_FEATURE2_DARN, AT_HWCAP2 }, + { PPC_FEATURE2_SCV, AT_HWCAP2 }, + { PPC_FEATURE2_ARCH_3_1, AT_HWCAP2 }, + { PPC_FEATURE2_MMA, AT_HWCAP2 }, +}; + +size_t __dl_hwcap_info_size = array_length (__dl_hwcap_info); diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.h b/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.h new file mode 100644 index 0000000000..194f40ce4d --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.h @@ -0,0 +1,34 @@ +/* HWCAP string information. PowerPC version. + Copyright (C) 2017-2025 Free Software Foundation, Inc. + + 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 + . */ + +#ifndef _DL_HWCAP_INFO_H +#define _DL_HWCAP_INFO_H + +#include +#include + +extern const char __dl_hwcap_names[] attribute_hidden; + +struct hwcap_info_t +{ + unsigned int value; + int hwcap; +}; +extern const struct hwcap_info_t __dl_hwcap_info[] attribute_hidden; +extern size_t __dl_hwcap_info_size attribute_hidden; + +#endif