From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 67FB53858D33 for ; Wed, 8 Mar 2023 16:56:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 67FB53858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x533.google.com with SMTP id i34so68352781eda.7 for ; Wed, 08 Mar 2023 08:56:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678294584; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=uOfiyET+lFrEENlHso9ncqh5BSMFdUOmXGvdtSk/UPY=; b=O72RmuiNKmxaswl7h4YPVSut9ucCurpe97uY58Igl+d1eBvZ2b0xCegHuux8tT1YXl y3sKIAJ57uqh8EENKjkBL01f0y+aJprdnqEZM7D3ql0+Rs7xBdkMUmNLjrugWHikQ3V+ 7qUoHmBM7tsu5uhHZp81kb0wo5qUuzdMnOOFB2D5Lh24psh3Sw2nROpOItfgB0EZoWF4 LG9Cjo3SVFaf2xYGRH2690GjT/l6Urg3Q2qXpg+1cXh1403kvrZyXCfAvnzmvEV6nlKR N0hpV71ap1ICtRrmuQ+p82BlRhziWZNAwAM0U3YZybOL6a3BJq2uB8AiOi+0v1UFWywh Dumw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678294584; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uOfiyET+lFrEENlHso9ncqh5BSMFdUOmXGvdtSk/UPY=; b=Y4G5p5NaXbX6OFEEVnQ8/aZnYKVJ+C77KgzqJ6yGXpD3e7dGidEhA3sZZAyi1SIn6w UjiXUzZ41LQMq+RKOOSpb6R198/uZIItRRqPT38wGcBUDMAS6KiwjT7Lhj0ECiHgl7ft qN75saOxmq3ccHLNrupZftvRqOdfcmtbOGH61o1izXgmcOqaoQbzFaSx0Bs/1IknIstx 1DTVfSz7QG4NZEkGEDOgHN2yw5jqUqOy+7XRPQ9kTEzDqYy+2RV2LOeq3FnPpEmOzrPs qfqVfFTyu77uqJBT66zECXp+bz4stpoeZkXw48Mod0HQa51Eis623Txj1u3W8WmlbiQd 6mnA== X-Gm-Message-State: AO0yUKVwIkh+gBhzZ0qgRyN4tYyWDekxP3bj66Gwul9z48HECOJmcn71 u9vQUcY0hMfX/7ChqarDch3mDFFYayUbLu13rzI= X-Google-Smtp-Source: AK7set/avAeW5PhZk9rAy4bm3fnSOJQHv5TDBzDOVcgU3brdNg+O+RdmlWtSiGvDDWu6J/uiB8Ycorl4xT/mjbYUEoM= X-Received: by 2002:a17:906:398a:b0:877:747e:f076 with SMTP id h10-20020a170906398a00b00877747ef076mr8834359eje.0.1678294583844; Wed, 08 Mar 2023 08:56:23 -0800 (PST) MIME-Version: 1.0 References: <20230302023349.3194099-1-caiyinyu@loongson.cn> <092a02df-58c3-633d-e44f-56d32535f775@loongson.cn> <3398ea16-1e36-8c08-0041-f7a4a2193907@loongson.cn> In-Reply-To: <3398ea16-1e36-8c08-0041-f7a4a2193907@loongson.cn> From: Noah Goldstein Date: Wed, 8 Mar 2023 10:56:10 -0600 Message-ID: Subject: Re: [PATCH] x86: Fix bug about glibc.cpu.hwcaps. To: caiyinyu Cc: Xi Ruoyao , "H.J. Lu" , libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,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 Wed, Mar 8, 2023 at 1:16=E2=80=AFAM caiyinyu wrot= e: > > > =E5=9C=A8 2023/3/8 =E4=B8=8A=E5=8D=881:23, Noah Goldstein =E5=86=99=E9=81= =93: > > On Tue, Mar 7, 2023 at 7:18=E2=80=AFAM caiyinyu = wrote: > >> > >> =E5=9C=A8 2023/3/7 =E4=B8=8B=E5=8D=889:02, Xi Ruoyao =E5=86=99=E9=81= =93: > >>> On Tue, 2023-03-07 at 20:45 +0800, caiyinyu wrote: > >>>> =E5=9C=A8 2023/3/2 =E4=B8=8B=E5=8D=8812:22, H.J. Lu =E5=86=99=E9=81= =93: > >>>>> On Wed, Mar 1, 2023 at 6:36=E2=80=AFPM caiyinyu > >>>>> wrote: > >>>>>> Recorded in [BZ #30183]: > >>>>>> > >>>>>> 1. export GLIBC_TUNABLES=3Dglibc.cpu.hwcaps=3D-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=3Den_US.UTF-8 > >>>>>> p -- LC_NUMERIC=3DC > >>>>>> ... > >>>>>> > >>>>>> 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 =3D valp->strval; > >>>>>> + const char *p =3D valp->strval, *c; > >>>>>> struct cpu_features *cpu_features =3D > >>>>>> &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 +=3D len + 1; > >>>>>> } > >>>>>> - while (*p !=3D '\0'); > >>>>>> + while (*c !=3D '\0'); > >>>>>> } > >>>>>> > >>>>>> # if CET_ENABLED > >>>>>> -- > >>>>>> 2.31.1 > >>>>>> > >>>>> OK. > >>>>> > >>>>> Thanks. > >>>> Could you help to push this patch? > >>> I guess you can push it yourself. A port maintainer has write access= to > >>> the entire Git repository, just use it carefully (i. e. always get a > >>> permission before changing other subsystems). > >>> > >> OK, thanks. > > did you add the tests HJ asked for? > > Not yet. It also doesn't have the BZ number in the commit message. In the future ple= ase wait for approval before pushing. > >