Skip to contentSkip to conversation

use __pa_symbol to calculate the address of a C symbol.

PATCH Applied Glauber Costa 2 participants 2 messages Aug 31, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 use __pa_symbol to calculate the address of a C symbol.

The use of __pa() to calculate the address of a C-visible symbol
is wrong, and can lead to unpredictable results. See arch/x86/include/asm/page.h for details.

It should be replaced with __pa_symbol(), that does the correct math here, by taking relocations into account.

---
 arch/x86/kernel/kvmclock.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/kvmclock.c +2 -2
index 223af43..e5efcdc 100644
@@ -50,8 +50,8 @@ static unsigned long kvm_get_wallclock(void)
 	struct timespec ts;
 	int low, high;
 
-	low = (int)__pa(&wall_clock);
-	high = ((u64)__pa(&wall_clock) >> 32);
+	low = (int)__pa_symbol(&wall_clock);
+	high = ((u64)__pa_symbol(&wall_clock) >> 32);
 	native_write_msr(MSR_KVM_WALL_CLOCK, low, high);
 
 	vcpu_time = &get_cpu_var(hv_clock);
Signature · 1 line
1.6.2.2
Applied
#1 lore raw
Quoted 7 lines · Glauber Costa

The use of __pa() to calculate the address of a C-visible symbol
is wrong, and can lead to unpredictable results. See arch/x86/include/asm/page.h for details.

It should be replaced with __pa_symbol(), that does the correct math here, by taking relocations into account.

Applied, thanks.

I note that the changelog entry says nothing about what component is involved and what the effect of the bug is. This reduces its usefulness for someone looking over the log and trying to see if a particular bug is fixed.

Signature · 1 line
error compiling committee.c: too many arguments to function