From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id C6DFE3858D33 for ; Thu, 2 Mar 2023 02:38:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C6DFE3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.20.4.187]) by gateway (Coremail) with SMTP id _____8AxbdoRDABkwhkHAA--.7836S3; Thu, 02 Mar 2023 10:38:09 +0800 (CST) Received: from [10.20.4.187] (unknown [10.20.4.187]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxWL3MCwBkU4dFAA--.57537S3; Thu, 02 Mar 2023 10:37:11 +0800 (CST) Subject: Re: [PATCH] x86: Fix bug about glibc.cpu.hwcaps. To: Noah Goldstein Cc: libc-alpha@sourceware.org, adhemerval.zanella@linaro.org, hjl.tools@gmail.com, carlos@redhat.com References: <20230301032238.566874-1-caiyinyu@loongson.cn> From: caiyinyu Message-ID: Date: Thu, 2 Mar 2023 10:37:00 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:AQAAf8CxWL3MCwBkU4dFAA--.57537S3 X-CM-SenderInfo: 5fdl5xhq1xqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoW7tF4UZr4kXFWDtw18JF18Krg_yoW8ur4Upr yxAa1jkrs8XrW5KwnFgw4Yg3WYqrW8KF18Zrs8C3WkZr1qqryfGa1IyF45ua13Ar1fWr1I vF4FgFya9F1UZrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bI8YFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4xG64xvF2 IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4U McvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwCYjI0SjxkI62AI1cAE67vIY487Mx AIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_ Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwI xGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8 JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcV C2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxU70PfDUUUU X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_PASS,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: 在 2023/3/2 上午12:42, Noah Goldstein 写道: > On Wed, Mar 1, 2023 at 3:11 AM caiyinyu wrote: >> >> 在 2023/3/1 下午12:19, Noah Goldstein 写道: >>> On Tue, Feb 28, 2023 at 9:22 PM caiyinyu wrote: >>>> 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". >>>> --- >>>> 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 >>>> -- >>>> 2.31.1 >>>> >>> Can you make a bugzilla for this? >> bugzilla: >> >> https://sourceware.org/bugzilla/show_bug.cgi?id=30183 >> >> > Can you append '[BZ #30183]' to the commit message. > Otherwise looks good. OK. https://sourceware.org/pipermail/libc-alpha/2023-March/145996.html