lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a918b221-b7f3-9994-9a7a-d10345aa30df@loongson.cn>
Date: Tue, 27 May 2025 11:17:19 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Xi Ruoyao <xry111@...111.site>, Huacai Chen <chenhuacai@...nel.org>
Cc: loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH] LoongArch: Do not include larchintrin.h

On 2025/5/21 下午1:41, Xi Ruoyao wrote:
> On Tue, 2025-05-20 at 14:49 +0800, Tiezhu Yang wrote:
>> larchintrin.h is a system header of compiler, include it in the
>> kernel header may lead to the fatal error "'larchintrin.h' file
>> not found".
>>
>> There are two related cases so far:
>>
>> (1) When compiling samples/bpf, it has been fixed in the latest
>> kernel [1].
>>
>> (2) When running bcc script, it has been fixed in the latest
>> bcc [2] [3], like this:
>>
>> $ /usr/share/bcc/tools/filetop
>> In file included from <built-in>:4:
>> In file included from /virtual/include/bcc/helpers.h:54:
>> In file included from arch/loongarch/include/asm/page.h:7:
>> In file included from arch/loongarch/include/asm/addrspace.h:9:
>> arch/loongarch/include/asm/loongarch.h:11:10: fatal error: 'larchintrin.h' file not found
>>     11 | #include <larchintrin.h>
>>        |          ^~~~~~~~~~~~~~~
>> 1 error generated.
>>
>> Maybe there are same errors for the other unknown projects, it is
>> annoyance to add the include path each time. In order to avoid such
>> errors once and for all, do not include larchintrin.h, just use the
>> builtin functions directly.
> 
> Sorry, but in GCC those builtin functions are not documented and may
> subject to change in the future.  Only the larchintrin.h interface is
> documented.

AFAICT, the LoongArch Base Built-in Functions are listed in the GCC
documentation [1], they will not be changed easily and frequently in
my opinion.

__builtin_loongarch_cpucfg()
__builtin_loongarch_csrrd_w()
__builtin_loongarch_csrrd_d()
__builtin_loongarch_csrwr_w()
__builtin_loongarch_csrwr_d()
__builtin_loongarch_csrxchg_w()
__builtin_loongarch_csrxchg_d()
__builtin_loongarch_iocsrrd_w()
__builtin_loongarch_iocsrrd_d()
__builtin_loongarch_iocsrwr_w()
__builtin_loongarch_iocsrwr_d()

> Thus if you don't want to rely on GCC for those operations, you may need
> to write inline asm...

so these builtin functions can be used directly and safely.

[1] 
https://gcc.gnu.org/onlinedocs/gcc/LoongArch-Base-Built-in-Functions.html

Thanks,
Tiezhu


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ