[PATCH] x86: Fix bug about glibc.cpu.hwcaps.

caiyinyu caiyinyu@loongson.cn
Wed Mar 8 07:16:23 GMT 2023


在 2023/3/8 上午1:23, Noah Goldstein 写道:
> On Tue, Mar 7, 2023 at 7:18 AM caiyinyu <caiyinyu@loongson.cn> wrote:
>>
>> 在 2023/3/7 下午9:02, Xi Ruoyao 写道:
>>> On Tue, 2023-03-07 at 20:45 +0800, caiyinyu wrote:
>>>> 在 2023/3/2 下午12:22, H.J. Lu 写道:
>>>>> On Wed, Mar 1, 2023 at 6:36 PM caiyinyu <caiyinyu@loongson.cn>
>>>>> wrote:
>>>>>> Recorded in [BZ #30183]:
>>>>>>
>>>>>> 1. export GLIBC_TUNABLES=glibc.cpu.hwcaps=-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=en_US.UTF-8
>>>>>> p -- LC_NUMERIC=C
>>>>>> ...
>>>>>>
>>>>>> 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 = valp->strval;
>>>>>> +  const char *p = valp->strval, *c;
>>>>>>       struct cpu_features *cpu_features =
>>>>>> &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 += len + 1;
>>>>>>         }
>>>>>> -  while (*p != '\0');
>>>>>> +  while (*c != '\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.




More information about the Libc-alpha mailing list