On 18/03/2025 9:19 am, Roger Pau Monne wrote: > When enabling UBSAN with clang, the following error is triggered during the > build: > > common/wait.c:154:9: error: symbol '.L_wq_resume' is already defined > 154 | "push %%rbx; push %%rbp; push %%r12;" > | ^ > <inline asm>:1:121: note: instantiated into assembly here > 1 | push %rbx; push %rbp; push %r12;push %r13; push %r14; push > %r15;sub %esp,%ecx;cmp $4096, %ecx;ja .L_skip;mov %rsp,%rsi;.L_wq_resume: rep > movsb;mov %rsp,%rsi;.L_skip:pop %r15; pop %r14; pop %r13;pop %r12; pop %rbp; > pop %rbx > | > ^ > common/wait.c:154:9: error: symbol '.L_skip' is already defined > 154 | "push %%rbx; push %%rbp; push %%r12;" > | ^ > <inline asm>:1:159: note: instantiated into assembly here > 1 | push %rbx; push %rbp; push %r12;push %r13; push %r14; push > %r15;sub %esp,%ecx;cmp $4096, %ecx;ja .L_skip;mov %rsp,%rsi;.L_wq_resume: rep > movsb;mov %rsp,%rsi;.L_skip:pop %r15; pop %r14; pop %r13;pop %r12; pop %rbp; > pop %rbx > | > > ^ > 2 errors generated. > > The inline assembly block in __prepare_to_wait() is duplicated, thus > leading to multiple definitions of the otherwise unique labels inside the > assembly block. GCC extended-asm documentation notes the possibility of > duplicating asm blocks: > >> Under certain circumstances, GCC may duplicate (or remove duplicates of) >> your assembly code when optimizing. This can lead to unexpected duplicate >> symbol errors during compilation if your asm code defines symbols or >> labels. Using ‘%=’ (see AssemblerTemplate) may help resolve this problem. > Workaround the issue by latching esp to a local variable, this prevents > clang duplicating the inline asm blocks. > > Suggested-by: Jan Beulich <jbeul...@suse.com> > Signed-off-by: Roger Pau Monné <roger....@citrix.com>
Acked-by: Andrew Cooper <andrew.coop...@citrix.com>