Skip to contentSkip to conversation

x86-64: Prevent gcc from optimizing away venosys_1()

PATCH In review Dave Anderson 3 participants 5 messages Jun 3, 2011 – Jun 6, 2011 1 message not in the archive x86

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 313387488.1201.1307114323524.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com

#1 lore raw

PATCH 1/1 x86-64: Prevent gcc from optimizing away venosys_1()

One of the changes in commit a4928cffe6435caf427ae673131a633c1329dbf3 made the venosys_1() system call static, which causes it to be optimized out of the kernel:

Author: Ingo Molnar <[email protected]>
Date: Wed Apr 23 13:20:56 2008 +0200

"make namespacecheck" fixes

Commit 2e8ad43ec07545780ce7992cb18e2d82c7abd24c had originally changed all vsyscalls from being static for the same reason:

Author: Andi Kleen <[email protected]>
Date: Mon Sep 12 18:49:24 2005 +0200

[PATCH] x86-64: Prevent gcc 4 from optimizing away vsyscalls

They were previously static.

---

arch/x86/kernel/vsyscall_64.c +1 -1
index 3e68218..60a34af 100644
@@ -222,7 +222,7 @@ vgetcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
 	return 0;
 }
 
-static long __vsyscall(3) venosys_1(void)
+long __vsyscall(3) venosys_1(void)
 {
 	return -ENOSYS;
 }
#2 lore raw

arch/x86/kernel/vsyscall_64.c vgetcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache) · line 225

Quoted 5 lines
arch/x86/kernel/vsyscall_64.c +1 -1
 	return 0;
 }
 
-static long __vsyscall(3) venosys_1(void)
+long __vsyscall(3) venosys_1(void)

Better add a __used too. Otherwise it can be optimized out again in some builds e.g. when someone enables gc-sections for the linker.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
#3 lore raw

----- Original Message -----

Quoted 8 lines

arch/x86/kernel/vsyscall_64.c vgetcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache) · line 225

Quoted 5 lines
arch/x86/kernel/vsyscall_64.c +1 -1
 	return 0;
 }
 
-static long __vsyscall(3) venosys_1(void)
+long __vsyscall(3) venosys_1(void)

Better add a __used too. Otherwise it can be optimized out again in some builds e.g. when someone enables gc-sections for the linker.

Considering that all of the vsyscall prototypes have this attribute:

#define __vsyscall(nr) \
                __attribute__ ((unused, __section__(".vsyscall_" #nr))) notrace

How would any of them work?

Dave

Quoted 4 lines

-Andi
--
[email protected] -- Speaking for myself only.

#4 lore raw
Quoted 12 lines · Dave Anderson

----- Original Message -----

Quoted 8 lines

arch/x86/kernel/vsyscall_64.c vgetcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache) · line 225

Quoted 5 lines
arch/x86/kernel/vsyscall_64.c +1 -1
 	return 0;
 }
 
-static long __vsyscall(3) venosys_1(void)
+long __vsyscall(3) venosys_1(void)

Better add a __used too. Otherwise it can be optimized out again in some builds e.g. when someone enables gc-sections for the linker.

Quoted 6 lines

Considering that all of the vsyscall prototypes have this attribute:

#define __vsyscall(nr) \
                __attribute__ ((unused, __section__(".vsyscall_" #nr))) notrace

How would any of them work?

unused is just to prevent warnings I think. used stops the optimizer from throwing it away.

It would make more sense to drop the unused and add an used. I think used prevents the warnings too.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
#5 lore raw
In reply to Dave Anderson
Quoted 10 lines · Dave Anderson

One of the changes in commit a4928cffe6435caf427ae673131a633c1329dbf3 made the venosys_1() system call static, which causes it to be optimized out of the kernel:

Author: Ingo Molnar <[email protected]>
Date: Wed Apr 23 13:20:56 2008 +0200

"make namespacecheck" fixes

Andy noticed this recently, so we got rid of that broken (and unused) syscall in:

bb5fe2f78ead: x86-64: Remove vsyscall number 3 (venosys)

which is in the tip:x86/vdso branch at:

http://people.redhat.com/mingo/tip.git/README

Thanks,

Ingo