Skip to content

Commit d0a8d93

Browse files
nickdesaulniersIngo Molnar
authored andcommitted
x86/paravirt: Make native_save_fl() extern inline
native_save_fl() is marked static inline, but by using it as a function pointer in arch/x86/kernel/paravirt.c, it MUST be outlined. paravirt's use of native_save_fl() also requires that no GPRs other than %rax are clobbered. Compilers have different heuristics which they use to emit stack guard code, the emittance of which can break paravirt's callee saved assumption by clobbering %rcx. Marking a function definition extern inline means that if this version cannot be inlined, then the out-of-line version will be preferred. By having the out-of-line version be implemented in assembly, it cannot be instrumented with a stack protector, which might violate custom calling conventions that code like paravirt rely on. The semantics of extern inline has changed since gnu89. This means that folks using GCC versions >= 5.1 may see symbol redefinition errors at link time for subdirs that override KBUILD_CFLAGS (making the C standard used implicit) regardless of this patch. This has been cleaned up earlier in the patch set, but is left as a note in the commit message for future travelers. Reports: https://lkml.org/lkml/2018/5/7/534 ClangBuiltLinux/linux#16 Discussion: https://bugs.llvm.org/show_bug.cgi?id=37512 https://lkml.org/lkml/2018/5/24/1371 Thanks to the many folks that participated in the discussion. Debugged-by: Alistair Strachan <[email protected]> Debugged-by: Matthias Kaehlcke <[email protected]> Suggested-by: Arnd Bergmann <[email protected]> Suggested-by: H. Peter Anvin <[email protected]> Suggested-by: Tom Stellar <[email protected]> Reported-by: Sedat Dilek <[email protected]> Tested-by: Sedat Dilek <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Acked-by: Juergen Gross <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 0e2e160 commit d0a8d93

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

arch/x86/include/asm/irqflags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Interrupt control:
1414
*/
1515

16-
static inline unsigned long native_save_fl(void)
16+
extern inline unsigned long native_save_fl(void)
1717
{
1818
unsigned long flags;
1919

arch/x86/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ obj-y += alternative.o i8253.o hw_breakpoint.o
6161
obj-y += tsc.o tsc_msr.o io_delay.o rtc.o
6262
obj-y += pci-iommu_table.o
6363
obj-y += resource.o
64+
obj-y += irqflags.o
6465

6566
obj-y += process.o
6667
obj-y += fpu/

arch/x86/kernel/irqflags.S

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#include <asm/asm.h>
4+
#include <asm/export.h>
5+
#include <linux/linkage.h>
6+
7+
/*
8+
* unsigned long native_save_fl(void)
9+
*/
10+
ENTRY(native_save_fl)
11+
pushf
12+
pop %_ASM_AX
13+
ret
14+
ENDPROC(native_save_fl)
15+
EXPORT_SYMBOL(native_save_fl)
16+
17+
/*
18+
* void native_restore_fl(unsigned long flags)
19+
* %eax/%rdi: flags
20+
*/
21+
ENTRY(native_restore_fl)
22+
push %_ASM_ARG1
23+
popf
24+
ret
25+
ENDPROC(native_restore_fl)
26+
EXPORT_SYMBOL(native_restore_fl)

0 commit comments

Comments
 (0)