From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id A2C8A3858D39 for ; Tue, 7 Mar 2023 13:02:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2C8A3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1678194149; bh=MMCqlAyt6vUSbAZZZWNxJOf44vu3tjPhxZCeyfCmnFY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=GKfHiFNGhQ3LaoeqY/IDBelCjokKzunOrr9MIPLr9BE8HQswAegebGpRYEZSJCsbf rnxNVSzgl/aMWeWLFkYRdB8Xw8MqyN4Vaye2v+W3IX9B/7odQPOXV+CGxr5BWJnfv6 Mlmc9f6bdgjtEC8wgNk2YrQbQJqzSfwlMA3rif5k= Received: from [IPv6:240e:457:1130:24c0:882b:64fc:f6e9:11b3] (unknown [IPv6:240e:457:1130:24c0:882b:64fc:f6e9:11b3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 2B07F65B9A; Tue, 7 Mar 2023 08:02:25 -0500 (EST) Message-ID: Subject: Re: [PATCH] x86: Fix bug about glibc.cpu.hwcaps. From: Xi Ruoyao To: caiyinyu , "H.J. Lu" Cc: libc-alpha@sourceware.org, goldstein.w.n@gmail.com Date: Tue, 07 Mar 2023 21:02:18 +0800 In-Reply-To: References: <20230302023349.3194099-1-caiyinyu@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 MIME-Version: 1.0 X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,LIKELY_SPAM_FROM,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: On Tue, 2023-03-07 at 20:45 +0800, caiyinyu wrote: >=20 > =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]: > > >=20 > > > 1. export GLIBC_TUNABLES=3Dglibc.cpu.hwcaps=3D-AVX512 > > > 2. Add=C2=A0 _dl_printf("p -- %s\n", p); just before switch(nl) in > > > =C2=A0=C2=A0=C2=A0 sysdeps/x86/cpu-tunables.c > > > 3. compiled and run ./testrun.sh /usr/bin/ls > > > you will get: > > >=20 > > > p -- -AVX512 > > > p -- LC_ADDRESS=3Den_US.UTF-8 > > > p -- LC_NUMERIC=3DC > > > ... > > >=20 > > > The function, TUNABLE_CALLBACK (set_hwcaps) > > > (tunable_val_t *valp), checks far more than it should and it > > > should stop at end of "-AVX512". > > > --- > > > =C2=A0 sysdeps/x86/cpu-tunables.c | 6 +++--- > > > =C2=A0 1 file changed, 3 insertions(+), 3 deletions(-) > > >=20 > > > 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) > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NOTE: the IFUNC selection may ch= ange over time.=C2=A0 Please > > > check all > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 multiarch implementations when e= xperimenting.=C2=A0 */ > > >=20 > > > -=C2=A0 const char *p =3D valp->strval; > > > +=C2=A0 const char *p =3D valp->strval, *c; > > > =C2=A0=C2=A0=C2=A0 struct cpu_features *cpu_features =3D > > > &GLRO(dl_x86_cpu_features); > > > =C2=A0=C2=A0=C2=A0 size_t len; > > >=20 > > > =C2=A0=C2=A0=C2=A0 do > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { > > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const char *c, *n; > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const char *n; > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bool disable; > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size_t nl; > > >=20 > > > @@ -283,7 +283,7 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t > > > *valp) > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 p +=3D len + 1; > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > > > -=C2=A0 while (*p !=3D '\0'); > > > +=C2=A0 while (*c !=3D '\0'); > > > =C2=A0 } > > >=20 > > > =C2=A0 # if CET_ENABLED > > > -- > > > 2.31.1 > > >=20 > > OK. > >=20 > > Thanks. >=20 > 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). --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University