Skip to content

[X86_32] Miscompilation with __llvm_retpoline_push #35677

@llvmbot

Description

@llvmbot
Bugzilla Link 36329
Resolution FIXED
Resolved on Feb 14, 2018 02:10
Version 6.0
OS Linux
Blocks #35152
Attachments Config file for kernel build
Reporter LLVM Bugzilla Contributor
CC @zmodem,@tstellar

Extended Description

After a call via __llvm_retpoline_push, code in the calling function seems confused about where %esp points.

Reproduced with llvm/clang master (r324745 / r324741 resp.) and also with 6.0 branch (r324726 / r324719 resp) with r326645 added to the latter.

To reproduce:

git clone git://git.infradead.org/linux-retpoline.git
cd linux-retpoline
git checkout clang
cp /where/you/downloaded/the/attached/config .config
make CC=/where/is/your/clang bzImage
qemu-system-i386 -display none -serial stdio -kernel arch/x86/boot/bzImage -append earlyprintk=ttyS0,keep

Observe the output from mp_register_ioapic():
[ 0.000000] mp_register_ioapic, 0 fec00000 0 c1b31e88
[ 0.000000] At line 412, gsi_base is 0
[ 0.000000] At line 425, gsi_base is -1043707140
[ 0.000000] At line 427, gsi_base is -1043707140

Between line 412 and 425, gsi_base got clobbered.

Now uncomment the CFLAGS_io_apic_b line in arch/x86/kernel/apic/Makefile and repeat, to disable the retpoline. Observe the problem go away.

To eliminate the external thunks as a cause of this problem, also retest with
CFLAGS_io_apic_b.o += -mno-retpoline-external-thunk -mretpoline
The problem persists even when we let LLVM emit its own thunks.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions