Re: [PATCH 0/3] selftests: Remove duplicate CPUID wrappers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Shuah,

On 2/7/2022 10:00 AM, Shuah Khan wrote:

> 
> This will work fine on newer versions of gcc/clang. However this could
> fail when mainline kselftest is used on stable releases on test rings
> and so on, especially if they have older versions of gcc/clang.

Indeed. It thus seems that kselftest has a minimal required version for
gcc/clang that is not the current mainline minimal version but the
minimal version of the oldest supported stable kernel, which is v4.9.

__cpuid_count() was added to gcc in commit:
cb0dee885cb30b4e9beeef070cf000baa7d09abe and thus available since
gcc 4.4.

Looking at Documentation/Changes or later Documentation/process/changes.rst
kernels v4.9 and v4.14 have the minimal required version of
gcc of 3.2. So this change would encounter an issue if mainline
kselftest is used to test a v4.9 or v4.14 kernel on a system that only
supports its minimal gcc.

Kernel v4.19 moved the gcc minimal required version to 4.6 that does
contain this macro.

There does not seem to be a minimum required version of clang/LLVM
in v4.19. The first time I see a minimal version for Clang/LLVM
for a stable kernel is in kernel v5.10 with Clang/LLVM minimal
version 10.0.1 and from what I can tell the __cpuid_count() macro
was added to Clang/LLVM in version 3.4.0 
(commit 4dcb5dbb53ea4fbeab48bc6bc3c4d392361dabc1).

> 
> We will have to find a solution for this. Instead of deleting the local
> define, let's keep it under ifndef __cpuid_count
> 
> /usr/lib/gcc/x86_64-linux-gnu/11/include/cpuid.h
> 
> #define __cpuid_count(level, count, a, b, c, d)                         \
>   __asm__ __volatile__ ("cpuid\n\t"                                     \
>                         : "=a" (a), "=b" (b), "=c" (c), "=d" (d)        \
>                         : "0" (level), "2" (count))
> 

Will do. I see that gcc obtained the volatile qualifier in v11.1 so I can use
the most recent macro as you have here.

Reinette



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux