From: Uros Bizjak Date: Wed, 2 Apr 2025 18:08:07 +0000 (+0200) Subject: x86/idle: Remove .s output beautifying delimiters from simpler asm() templates X-Git-Tag: v6.16-rc1~195^2~26^2~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=19c3dcd953bc8961ab486cf05f5dd45455393c42;p=thirdparty%2Flinux.git x86/idle: Remove .s output beautifying delimiters from simpler asm() templates Delimiters in asm() templates such as ';', '\t' or '\n' are not required syntactically, they were used historically in the Linux kernel to prettify the compiler's .s output for people who were looking at compiler generated .s output. Most x86 developers these days are primarily looking at: 1) objdump --disassemble-all .o 2) perf top's live kernel function annotation and disassembler feature that uses /dev/mem. ... because: - this kind of assembler output is standardized regardless of compiler used, - it's generally less messy looking, - it gives ground-truth instead of being some intermediate layer in the toolchain that might or might not be the real deal, - and on a live kernel it also sees through the kernel's various layers of runtime patching code obfuscation facilities, also known as: alternative-instructions, tracepoints and jump labels. There are some cases where the .s output is the most useful tool, such as alternatives() code generation, but other than that these delimiters used in simple asm() statements mostly add noise to the source code side, which isn't desirable for assembly code that is fragile enough already. Remove the delimiters for , which also happens to make the GCC inliner's asm() instruction length heuristics more accurate... [ mingo: Wrote a new changelog to give historic context and to give people a chance to object. :-) ] Signed-off-by: Uros Bizjak Signed-off-by: Ingo Molnar Cc: Andy Lutomirski Cc: Brian Gerst Cc: Juergen Gross Cc: Andrew Cooper Cc: Rik van Riel Cc: "H. Peter Anvin" Cc: Peter Zijlstra Cc: Rafael J. Wysocki Cc: Linus Torvalds Link: https://lore.kernel.org/r/20250402180827.3762-3-ubizjak@gmail.com --- diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h index 3377869ff2e8b..0e020a69b4315 100644 --- a/arch/x86/include/asm/mwait.h +++ b/arch/x86/include/asm/mwait.h @@ -34,8 +34,8 @@ static __always_inline void __monitor(const void *eax, u32 ecx, u32 edx) static __always_inline void __monitorx(const void *eax, u32 ecx, u32 edx) { - /* "monitorx %eax, %ecx, %edx;" */ - asm volatile(".byte 0x0f, 0x01, 0xfa;" + /* "monitorx %eax, %ecx, %edx" */ + asm volatile(".byte 0x0f, 0x01, 0xfa" :: "a" (eax), "c" (ecx), "d"(edx)); } @@ -78,8 +78,8 @@ static __always_inline void __mwaitx(u32 eax, u32 ebx, u32 ecx) { /* No MDS buffer clear as this is AMD/HYGON only */ - /* "mwaitx %eax, %ebx, %ecx;" */ - asm volatile(".byte 0x0f, 0x01, 0xfb;" + /* "mwaitx %eax, %ebx, %ecx" */ + asm volatile(".byte 0x0f, 0x01, 0xfb" :: "a" (eax), "b" (ebx), "c" (ecx)); } @@ -138,13 +138,13 @@ static __always_inline void mwait_idle_with_hints(unsigned long eax, unsigned lo */ static inline void __tpause(u32 ecx, u32 edx, u32 eax) { - /* "tpause %ecx, %edx, %eax;" */ + /* "tpause %ecx, %edx, %eax" */ #ifdef CONFIG_AS_TPAUSE - asm volatile("tpause %%ecx\n" + asm volatile("tpause %%ecx" : : "c"(ecx), "d"(edx), "a"(eax)); #else - asm volatile(".byte 0x66, 0x0f, 0xae, 0xf1\t\n" + asm volatile(".byte 0x66, 0x0f, 0xae, 0xf1" : : "c"(ecx), "d"(edx), "a"(eax)); #endif