From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id 480FD3857838 for ; Tue, 7 Mar 2023 17:23:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 480FD3857838 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-x529.google.com with SMTP id k10so31438717edk.13 for ; Tue, 07 Mar 2023 09:23:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678209799; 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=p2C2VOgSpzs9uCRSsTfg65oTPysoCSXmStVn1BFX8wY=; b=hPjM8k/jOgTUPvhVFnymNtJ+TK3wAYoiT/tqG7y/vbVbDi8DcH6j7xfLsX5BDHLvuT U028t2mXMr8DVo7ac7k4jS8fbRci/EQ2ZFtVLxcR8s6+FRKr0qxfWZxStu95kdFYpp5w S+0ED+df8Ppp918Tn7kvxJxXzRrlzKcm/T4YuK/phm8CvsuBRbQEXKBvyPFqA+bsVSUj J4Q6ivjGpFZMgItKV4BcgBXKsuq7LZyrrDm3Chq67fWsW++9mPVlTtI+NfmQOqnV/eUr 4QaxDQ5DB7F+4gThToV4MScH9taTKGydnPeEUJDLdx4lXFKWSIe/slinNQbbUlMaJSP4 A78w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678209799; 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=p2C2VOgSpzs9uCRSsTfg65oTPysoCSXmStVn1BFX8wY=; b=pan8xYwvo481Y6Zg1IEymr8o5LPvcbq42ZNl9GJeGhC8YOZV73a1C0ejaWKi4L6uJn g2h1vRFhQJV6rYu0QCRt56ANEEeIobO6CRe7SpJyNGzB2Leftt8K8jhNmnXG6KETyB6Q tNk351W+TZogZUav0/pdNTPp8oOmY+gEsV6Bu6KxpfbmORxmW6UAc0DPBgaiLnXWTiMe qshimeDJGuiRY+B9iDavV4lmRpQGrRSvdRA6ENubjN9je3Uujj9bRs2d3FGSeN1p85pI 1r5XEVr/Gq4GRHg222cDKP3B7dUL6BU+9MsReNhsdL6pyMQqaHw/MccVwl9QepPU4OOy 72UA== X-Gm-Message-State: AO0yUKVzvZo/pDD9oyoZuT6b+VxxgwaBYa8PN4yGWGIU0cJFgIUYLU3j C0WgG6aMp6X1LA2ef336UtHJKXKOqm7Lk8LEchM= X-Google-Smtp-Source: AK7set9+9qIUDSdYvzwFAyRewQe8MsYKf7Q1nmV8WHqAe8inPaRQtinb6QrwLqBoXmdmsnLSWTdkvun44tZaUvQv8z4= X-Received: by 2002:a17:906:6a93:b0:8b1:7ac6:318a with SMTP id p19-20020a1709066a9300b008b17ac6318amr6982318ejr.4.1678209798888; Tue, 07 Mar 2023 09:23:18 -0800 (PST) MIME-Version: 1.0 References: <20230302023349.3194099-1-caiyinyu@loongson.cn> <092a02df-58c3-633d-e44f-56d32535f775@loongson.cn> In-Reply-To: <092a02df-58c3-633d-e44f-56d32535f775@loongson.cn> From: Noah Goldstein Date: Tue, 7 Mar 2023 11:23:07 -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 Tue, Mar 7, 2023 at 7:18=E2=80=AFAM caiyinyu wrot= e: > > > =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 t= o > > 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? >