From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7891) id 647033858D3C; Tue, 7 Mar 2023 13:42:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 647033858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678196575; bh=sQPKx8WkpYbHk82zSg3KLQ9ys8wK2yBjBHG9nHvkQm0=; h=From:To:Subject:Date:From; b=MmGCYKt2IKBel2xVUC3MT+nkY4CPf3NI3m80koiyYsVxjUE7P3Q/M5YBwlc8eMUJQ 6KpmyIPg5Fgefo8qgPRahbLjsppPgIzHG18oRoyjxKLyRh7WdpVLyEUHuijgfdfcut C8OExqD6PvMLq+3hjq3hNMan73yVFW1I7E3s5KC8= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Yinyu Cai To: glibc-cvs@sourceware.org Subject: [glibc] x86: Fix bug about glibc.cpu.hwcaps. X-Act-Checkin: glibc X-Git-Author: caiyinyu X-Git-Refname: refs/heads/master X-Git-Oldrev: 436a604b7dc741fc76b5a6704c6cd8bb178518e7 X-Git-Newrev: 4c721f24fc190d1dc935eb0bab283de7cf13182e Message-Id: <20230307134255.647033858D3C@sourceware.org> Date: Tue, 7 Mar 2023 13:42:55 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4c721f24fc190d1dc935eb0bab283de7cf13182e commit 4c721f24fc190d1dc935eb0bab283de7cf13182e Author: caiyinyu Date: Tue Feb 28 16:21:41 2023 +0800 x86: Fix bug about glibc.cpu.hwcaps. Recorded in [BZ #30183]: 1. export GLIBC_TUNABLES=glibc.cpu.hwcaps=-AVX512 2. Add _dl_printf("p -- %s\n", p); just before switch(nl) in sysdeps/x86/cpu-tunables.c 3. compiled and run ./testrun.sh /usr/bin/ls you will get: p -- -AVX512 p -- LC_ADDRESS=en_US.UTF-8 p -- LC_NUMERIC=C ... The function, TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp), checks far more than it should and it should stop at end of "-AVX512". Diff: --- sysdeps/x86/cpu-tunables.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysdeps/x86/cpu-tunables.c b/sysdeps/x86/cpu-tunables.c index d3e1367bda..772fb0c4c2 100644 --- a/sysdeps/x86/cpu-tunables.c +++ b/sysdeps/x86/cpu-tunables.c @@ -107,13 +107,13 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) NOTE: the IFUNC selection may change over time. Please check all multiarch implementations when experimenting. */ - const char *p = valp->strval; + const char *p = valp->strval, *c; struct cpu_features *cpu_features = &GLRO(dl_x86_cpu_features); size_t len; do { - const char *c, *n; + const char *n; bool disable; size_t nl; @@ -283,7 +283,7 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) } p += len + 1; } - while (*p != '\0'); + while (*c != '\0'); } # if CET_ENABLED