Skip to contentSkip to conversation

x86: vget_cycles() __always_inline

PATCH Applied Hugh Dickins 2 participants 2 messages Apr 26, 2008 – Apr 28, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: vget_cycles() __always_inline

Mark vget_cycles() as __always_inline, so gcc is never tempted to make the vsyscall vread_tsc() dive into kernel text, with resulting SIGSEGV.

This was a self-inflicted wound: I've not seen that happen with unhacked sources; but for debug reasons I'd changed my x86/Makefile to compile no-unit-at-a-time, and that in conjunction with OPTIMIZE_INLINING=y ended up with vget_cycles() in kernel text. Perhaps it can happen in other ways: safer to use __always_inline.

---

 include/asm-x86/tsc.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-x86/tsc.h +1 -1
@@ -32,7 +32,7 @@ static inline cycles_t get_cycles(void)
 	return ret;
 }
 
-static inline cycles_t vget_cycles(void)
+static __always_inline cycles_t vget_cycles(void)
 {
 	/*
 	 * We only do VDSOs on TSC capable CPUs, so this shouldnt
Applied
#1 lore raw
Quoted 9 lines · Hugh Dickins

Mark vget_cycles() as __always_inline, so gcc is never tempted to make the vsyscall vread_tsc() dive into kernel text, with resulting SIGSEGV.

This was a self-inflicted wound: I've not seen that happen with unhacked sources; but for debug reasons I'd changed my x86/Makefile to compile no-unit-at-a-time, and that in conjunction with OPTIMIZE_INLINING=y ended up with vget_cycles() in kernel text. Perhaps it can happen in other ways: safer to use __always_inline.

applied, thanks Hugh - i agree that this is worth fixing.

Ingo