From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by sourceware.org (Postfix) with ESMTPS id F20DA385559E for ; Wed, 1 Mar 2023 17:33:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F20DA385559E 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-yw1-x112f.google.com with SMTP id 00721157ae682-536cd8f6034so377154667b3.10 for ; Wed, 01 Mar 2023 09:33:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=gfEV8qjgcexUu0AAmV6blrakGpa/qOcXafudBox3zcM=; b=l2VRLoVILGZ5a7xrOmJ1X3E6ObXY6psuQgd8WiPdP5NFJbHZaRscH19KUsV6s9+/Uj n2f7o9SN/9RDSCpxcWHau6RoDUdJJV5TnivdpWfISmWs3Pc+xcEaQ/POGY+3RCfU2Kjz bi2IngoH3N3tVQDMLO3KlkNMrhbYnVljQr0LtHi6HY7M86qR3K6jkVFL4x88Ptvf1ihx qCQb5pS3xmri/d9hRhm2dYL761QpthEyl/KtyabPB/d0X8ALn0aiYHH1Tw6EldVqmg66 5/wZrsyh6GmswgCoZ1guk4VNxJeiKvf0jNmN3gAvOaPech8oSBV5AD4JAcuXtm253cv3 bSew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=gfEV8qjgcexUu0AAmV6blrakGpa/qOcXafudBox3zcM=; b=1qjSCTS5OOAED4SSswJDXa6f4xD/nDaBRVfFya90LGMbm83FWqHHDhZ14VNnPxBT9E ftzi1iiMgt2Ap6zTeo2NokRXP4QMV4u70zc4b46nY+cDlhOAO1tbO2ZfZIlg0ye7CKUc QRfnYQ7KK9Qt5s0e+lb5lKeg9719S5VMVEviyDlI+Xf5CODoOQcGopKjpIwISkA3I+mp cbDfGteoIjpQ3uUrH8/AEb10J2bCrfzBKigDLq2JQg6kReuIbPg55tpGZRIApOakMfDM RmYS545uAhF0OUJzvRuNRbQbtqc2/O2S9+NqrHdo1B/rEHXp7jG6j60cwb1dV8q0wvle plYg== X-Gm-Message-State: AO0yUKXiGbYQJ3pdzT9K1N9SAatCvke/rX9Dh+atNJIivWU5bXqnzyP4 v+8YHuIYzTEujOmH/peeBycx8zk7rr2QG97+vHN29qwa X-Google-Smtp-Source: AK7set/EjUAS/6lBSO4VA+N3vz1HDv4R1UQC4X+YQNYJjjxpBLmPtmSNI1m6M5/F9w1CTkZriOiK3qeb3HCfpaOHOq0= X-Received: by 2002:a81:ac5e:0:b0:52f:3399:ed08 with SMTP id z30-20020a81ac5e000000b0052f3399ed08mr4362898ywj.6.1677692039191; Wed, 01 Mar 2023 09:33:59 -0800 (PST) MIME-Version: 1.0 References: <20230301032238.566874-1-caiyinyu@loongson.cn> In-Reply-To: From: "H.J. Lu" Date: Wed, 1 Mar 2023 09:33:23 -0800 Message-ID: Subject: Re: [PATCH] x86: Fix bug about glibc.cpu.hwcaps. To: Noah Goldstein Cc: caiyinyu , libc-alpha@sourceware.org, adhemerval.zanella@linaro.org, carlos@redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3021.9 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 1, 2023 at 8:43 AM Noah Goldstein wro= te: > > On Wed, Mar 1, 2023 at 3:11=E2=80=AFAM caiyinyu wr= ote: > > > > > > =E5=9C=A8 2023/3/1 =E4=B8=8B=E5=8D=8812:19, Noah Goldstein =E5=86=99=E9= =81=93: > > > On Tue, Feb 28, 2023 at 9:22=E2=80=AFPM caiyinyu wrote: > > >> 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 *va= lp) > > >> } > > >> p +=3D len + 1; > > >> } > > >> - while (*p !=3D '\0'); > > >> + while (*c !=3D '\0'); > > >> } > > >> > > >> # if CET_ENABLED > > >> -- > > >> 2.31.1 > > >> > > > Can you make a bugzilla for this? > > bugzilla: > > > > https://sourceware.org/bugzilla/show_bug.cgi?id=3D30183 > > > > > Can you append '[BZ #30183]' to the commit message. > Otherwise looks good. Is it possible to add a testcase? --=20 H.J.