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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <66ba81a9-3fd0-4c6a-ab9d-1a02f8c89dd3@redhat.com>
Date: Tue, 24 Jun 2025 17:37:30 +0200
From: Thomas Huth <thuth@...hat.com>
To: Huacai Chen <chenhuacai@...nel.org>
Cc: WANG Xuerui <kernel@...0n.name>, loongarch@...ts.linux.dev,
 Andres Salomon <dilinger@...ued.net>, linux-kernel@...r.kernel.org,
 Ingo Molnar <mingo@...nel.org>, Ralf Baechle <ralf@...ux-mips.org>
Subject: Re: [PATCH v2] loongarch: Replace __ASSEMBLY__ with __ASSEMBLER__ in
 the loongarch headers

On 18/06/2025 16.39, Huacai Chen wrote:
> Hi, Thomas,
> 
> On Wed, Jun 11, 2025 at 8:03 PM Thomas Huth <thuth@...hat.com> wrote:
>>
>> From: Thomas Huth <thuth@...hat.com>
>>
>> While the GCC and Clang compilers already define __ASSEMBLER__
>> automatically when compiling assembler code, __ASSEMBLY__ is a
>> macro that only gets defined by the Makefiles in the kernel.
>> This is bad since macros starting with two underscores are names
>> that are reserved by the C language. It can also be very confusing
>> for the developers when switching between userspace and kernelspace
>> coding, or when dealing with uapi headers that rather should use
>> __ASSEMBLER__  instead. So let's now standardize on the __ASSEMBLER__
>> macro that is provided by the compilers.
> Though it seems the trend is to use __ASSEMBLER__, I found there are
> some old commits do the opposite:
> 
> 36396f3c36b04f79438f87a0fccfa76aa3de6af9 ("[MIPS]
> s/__ASSEMBLER__/__ASSEMBLY__/ for clarity sake.")
> 
> fc4ac7a5f5996712d9123ae4850948c640edb315 ("x86: use __ASSEMBLY__
> rather than __ASSEMBLER__")
> 
> Huacai

  Hi,

unfortunately, the commit messages of those two patches are not very helpful 
- one is just saying "for clarity sake" and the other one "As Ingo pointed 
out in a separate patch, we should be using __ASSEMBLY__" (but I failed to 
find that other patch where it might have been discussed). So it sounds to 
me like they tried to standardize on __ASSEMBLY__ just for consistency. 
However, that mission failed since other occurrences of __ASSEMBLER__ have 
been added to the kernel in the course of time. And __ASSEMBLER__ is also 
the better macro, indeed, since:

1) Userspace programs usually don't have __ASSEMBLY__ by default (unless it 
is set in the Makefile), so the uapi headers should really use __ASSEMBLER__ 
instead. And if we use __ASSEMBLER__ in the uapi headers, why should we 
still use another macro for the remaining kernel files?

2) As mentioned in the patch description already, macros starting with two 
underscores are names that are reserved by the C language, so it's better to 
avoid __ASSEMBLY__ (yeah, I know, the kernel mostly does not care, but still...)

3) Since a lot of other (userspace) projects use __ASSEMBLER__ instead of 
defining their own __ASSEMBLY__ macro, it's a constant source of confusion, 
see e.g.:
  https://stackoverflow.com/questions/28924355/gcc-assembler-preprocessor-not-compatible-with-standard-headers
  https://forums.raspberrypi.com/viewtopic.php?p=1652944#p1653834
  https://github.com/riscv-software-src/opensbi/issues/199
  https://lore.kernel.org/kvm/20250222014526.2302653-1-seanjc@google.com/

So I think we really should standardize on __ASSEMBLER__ nowadays.

The related cleanup patches for x86, parisc, sh and arc patches already got 
merged via their specific architecture tree:

  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=24a295e4ef1ca8
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8a141be3233af7
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cccaea1d66e94b
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e2b6a188625a2b
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9cc646950eefda
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=179e949719fe81
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2cb74be378675c

So it would be great if you could take this loongarch patch also through the 
loongarch tree!

  Thanks,
   Thomas


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ