From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id 840173858D33 for ; Wed, 1 Mar 2023 16:43:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 840173858D33 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-x530.google.com with SMTP id d30so56379123eda.4 for ; Wed, 01 Mar 2023 08:43:05 -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=5mKO0ZhmAVrJQDcnc+Jult9sxRr5hNQOJ84NKTU6e0k=; b=Fcxzowq8k318HCS8CJK9z9oo7/p1TtKtDLKIbdUI1BMOnJY/DpylDkyWxICIk5McOQ 1Bc2s5lyojI5crJZUilPZX40L/wjYYqmcytI+PeUFbyfm+bqqNOMMD6eUiBLc1CGZ6v/ H/cyebasIcQ0NK0erbSM6MrwL+uaMkkLtrXpobFEG5Av+LUD66amyFq4QCb6xz1o9GZF vzAe8TwzcnzqhA8zGcXyYw4t4p3QbJMI6lI6MyzFS04dfJexIXY8ENbbXOrBzVSNL92Y /8vT0XtSNTBvtdblUg+gXaSbamYxSMEXeqEQEkOzIh4c7z1Ns0MuUIzOCqdrUM2ra2yq 4BAg== 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=5mKO0ZhmAVrJQDcnc+Jult9sxRr5hNQOJ84NKTU6e0k=; b=G3CzuhppqcpL3MlpgVm0pfqeHh68iq1Qe0jRsHDwpJo7bue1Z7RdB5PdI/hDp4NrsZ TanZdk7T3DSjxMCvQ3ffpPuioLuUhV+EGRPNOfNn5HHgOKrFwrdbW+KezDNUHx8DCfNe jEBjfesad5PVqP6TSqRYuPdwdskrmuQfe4ORHSeQ5qolOpeAvKTuo8mHrSLZYdM5M8WC lAFEhftNpPsfcfXALageWBO6T4AFclCH7lgPmQjAaqeMUB8MHyWnCLM6bPeIKDFXtZhq nBRT7RfRyQYfPJChVRiPvhOTz0wWQnyWMfqFIIWbjyYU1LRAsiSTP4wRMbYOYq+XOY30 zLPQ== X-Gm-Message-State: AO0yUKXNLttJ97AWicO1Q9xxIrRafZIwFjr72SAphmcFmvO0NfcTDMQn po0y4jCsxxaV56P20RtmbuwhNKBETXR8pS7PSl0= X-Google-Smtp-Source: AK7set/zYbwMl9nCfOH+qZsY7WBFlaTSci1n0ayNBXG1UtW5I9fFYoW6eSgfMfvP4Ub+e/Oi6aKmSVvErnt8nQLcOdI= X-Received: by 2002:a17:906:d82:b0:87b:db55:4887 with SMTP id m2-20020a1709060d8200b0087bdb554887mr3426653eji.4.1677688984017; Wed, 01 Mar 2023 08:43:04 -0800 (PST) MIME-Version: 1.0 References: <20230301032238.566874-1-caiyinyu@loongson.cn> In-Reply-To: From: Noah Goldstein Date: Wed, 1 Mar 2023 10:42:52 -0600 Message-ID: Subject: Re: [PATCH] x86: Fix bug about glibc.cpu.hwcaps. To: caiyinyu Cc: libc-alpha@sourceware.org, adhemerval.zanella@linaro.org, hjl.tools@gmail.com, carlos@redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.4 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 3:11=E2=80=AFAM caiyinyu wrot= e: > > > =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 *va= lp) > >> NOTE: the IFUNC selection may change over time. Please check a= ll > >> 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 > >> > > 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.