1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-12-24 17:51:17 +03:00

powerpc: Move AT_HWCAP descriptions to ld diagnostics

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.

Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
This commit is contained in:
Adhemerval Zanella
2025-02-26 12:54:17 -03:00
parent 3a9fb97caf
commit 8a995670a8
8 changed files with 227 additions and 211 deletions

View File

@@ -21,9 +21,19 @@
#include <cpu-features.h>
#include <elf/dl-tunables.h>
#include <dl-tunables-parse.h>
#include <dl-hwcap-info.h>
#include <unistd.h>
#include <string.h>
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 +65,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);
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. */
}
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);
}
break;
}
offset += hwcap_name_len + 1;
}