From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Paul Mackerras <paulus@samba.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/3] x86: record relocation offset
Date: Wed, 30 Dec 2009 11:16:57 +0800 [thread overview]
Message-ID: <4B3AC629.4030504@cn.fujitsu.com> (raw)
In-Reply-To: <4B3AC5CD.1000502@cn.fujitsu.com>
Record relocation offset, perf tools will use it
to adjust kernel symbol address
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
arch/x86/boot/compressed/head_32.S | 2 ++
arch/x86/boot/compressed/head_64.S | 3 +++
arch/x86/include/asm/bootparam.h | 3 ++-
arch/x86/kernel/asm-offsets_32.c | 1 +
arch/x86/kernel/asm-offsets_64.c | 1 +
arch/x86/kernel/cpu/perf_event.c | 4 ++++
6 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index f543b70..dc9748a 100644
--- a/arch/x86/boot/compressed/head_32.S
+++ b/arch/x86/boot/compressed/head_32.S
@@ -151,6 +151,8 @@ relocated:
movl %ebp, %ebx
subl $LOAD_PHYSICAL_ADDR, %ebx
jz 2f /* Nothing to be done if loaded at compiled addr. */
+
+ movl %ebx, BP_relocate_offset(%esi)
/*
* Process relocations.
*/
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index faff0dc..8170f32 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -90,6 +90,9 @@ ENTRY(startup_32)
addl %eax, %ebx
notl %eax
andl %eax, %ebx
+ movl %ebx, %eax
+ subl $LOAD_PHYSICAL_ADDR, %eax
+ movl %eax, BP_relocate_offset(%esi)
#else
movl $LOAD_PHYSICAL_ADDR, %ebx
#endif
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index 6be33d8..80b8d1f 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -88,7 +88,8 @@ struct boot_params {
__u8 _pad2[4]; /* 0x054 */
__u64 tboot_addr; /* 0x058 */
struct ist_info ist_info; /* 0x060 */
- __u8 _pad3[16]; /* 0x070 */
+ __s32 relocate_offset; /* 0x070 */
+ __u8 _pad3[12]; /* 0x074 */
__u8 hd0_info[16]; /* obsolete! */ /* 0x080 */
__u8 hd1_info[16]; /* obsolete! */ /* 0x090 */
struct sys_desc_table sys_desc_table; /* 0x0a0 */
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
index dfdbf64..8028e3b 100644
--- a/arch/x86/kernel/asm-offsets_32.c
+++ b/arch/x86/kernel/asm-offsets_32.c
@@ -148,4 +148,5 @@ void foo(void)
OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
OFFSET(BP_version, boot_params, hdr.version);
OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
+ OFFSET(BP_relocate_offset, boot_params, relocate_offset);
}
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
index 4a6aeed..fbfa5f3 100644
--- a/arch/x86/kernel/asm-offsets_64.c
+++ b/arch/x86/kernel/asm-offsets_64.c
@@ -127,6 +127,7 @@ int main(void)
OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
OFFSET(BP_version, boot_params, hdr.version);
OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
+ OFFSET(BP_relocate_offset, boot_params, relocate_offset);
BLANK();
DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index c223b7e..11d2a7d 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -26,8 +26,10 @@
#include <asm/apic.h>
#include <asm/stacktrace.h>
#include <asm/nmi.h>
+#include <asm/setup.h>
static u64 perf_event_mask __read_mostly;
+static s32 relocate_offset;
/* The maximal number of PEBS events: */
#define MAX_PEBS_EVENTS 4
@@ -2173,6 +2175,8 @@ void __init init_hw_perf_events(void)
pr_info("Performance Events: ");
+ relocate_offset = boot_params.relocate_offset;
+
switch (boot_cpu_data.x86_vendor) {
case X86_VENDOR_INTEL:
err = intel_pmu_init();
--
1.6.1.2
next prev parent reply other threads:[~2009-12-30 3:18 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-30 3:15 [PATCH 0/3] perf_event: fix getting symbol error if kernel is relocatable Xiao Guangrong
2009-12-30 3:16 ` Xiao Guangrong [this message]
2009-12-30 13:15 ` [PATCH 1/3] x86: record relocation offset Arnaldo Carvalho de Melo
2009-12-30 19:45 ` H. Peter Anvin
2009-12-30 20:39 ` Arnaldo Carvalho de Melo
2009-12-30 21:58 ` Arnaldo Carvalho de Melo
2009-12-30 22:22 ` James Bottomley
2009-12-30 3:17 ` [PATCH 2/3] perf_event: support getting " Xiao Guangrong
2009-12-30 3:18 ` [PATCH 3/3] perf tools: adjust symbol address Xiao Guangrong
2009-12-30 13:10 ` Arnaldo Carvalho de Melo
2009-12-31 2:59 ` Xiao Guangrong
2009-12-31 10:29 ` Arnaldo Carvalho de Melo
2009-12-31 10:49 ` Xiao Guangrong
2009-12-31 11:08 ` Arnaldo Carvalho de Melo
2009-12-31 11:30 ` Xiao Guangrong
-- strict thread matches above, loose matches on Subject: below --
2009-12-30 22:09 [PATCH 1/3] x86: record relocation offset H. Peter Anvin
2009-12-30 23:26 H. Peter Anvin
2009-12-30 23:41 ` James Bottomley
2009-12-30 23:46 ` H. Peter Anvin
2009-12-31 0:30 ` Arnaldo Carvalho de Melo
2009-12-31 3:00 ` Xiao Guangrong
2009-12-31 10:36 ` Arnaldo Carvalho de Melo
2009-12-31 10:50 ` Xiao Guangrong
2010-01-01 9:27 ` Ingo Molnar
2009-12-31 2:58 ` Xiao Guangrong
2009-12-31 0:53 ` Frank Ch. Eigler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B3AC629.4030504@cn.fujitsu.com \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.