lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 30 Dec 2009 11:17:51 +0800
From:	Xiao Guangrong <xiaoguangrong@...fujitsu.com>
To:	Ingo Molnar <mingo@...e.hu>
CC:	Thomas Gleixner <tglx@...utronix.de>,
	"H. Peter Anvin" <hpa@...or.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Paul Mackerras <paulus@...ba.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/3] perf_event: support getting relocation offset

Support getting relocation offset by using 'inject' event

Signed-off-by: Xiao Guangrong <xiaoguangrong@...fujitsu.com>
---
 arch/x86/kernel/cpu/perf_event.c |    6 ++++++
 include/linux/perf_event.h       |    1 +
 kernel/perf_event.c              |   23 +++++++++++++++++++++--
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 11d2a7d..fbb39f6 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -2470,3 +2470,9 @@ void hw_perf_event_setup_online(int cpu)
 {
 	init_debug_store_on_cpu(cpu);
 }
+
+int perf_inject_get_relocate_offset(u64 *offset)
+{
+	*offset = relocate_offset;
+	return 0;
+}
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 6c93f88..2671234 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -428,6 +428,7 @@ enum perf_event_type {
 
 enum perf_inject_event {
 	PERF_INJECT_HZ = 0x01,
+	PERF_INJECT_RELOCATE_OFFSET = 0x02,
 };
 
 enum perf_callchain_context {
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 9343c6c..9331426 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -2012,6 +2012,12 @@ unlock:
 	return ret;
 }
 
+extern __weak int perf_inject_get_relocate_offset(u64 *offset)
+{
+	*offset = 0;
+	return 0;
+}
+
 static int perf_inject_get_hz(u64 *hz)
 {
 	*hz = HZ;
@@ -2050,10 +2056,23 @@ exit:
 
 static int perf_inject_ioctl(struct perf_event *event, unsigned int arg)
 {
-	if (!arg || arg & ~PERF_INJECT_HZ)
+	int ret = 0;
+
+	if (!arg || arg & ~(PERF_INJECT_HZ | PERF_INJECT_RELOCATE_OFFSET))
 		return -EINVAL;
 
-	return perf_inject_event(event, PERF_INJECT_HZ, perf_inject_get_hz);
+	if (arg & PERF_INJECT_HZ) {
+		ret = perf_inject_event(event, PERF_INJECT_HZ,
+					perf_inject_get_hz);
+		if (ret)
+			goto exit;
+	}
+
+	if (arg & PERF_INJECT_RELOCATE_OFFSET)
+		ret = perf_inject_event(event, PERF_INJECT_RELOCATE_OFFSET,
+					perf_inject_get_relocate_offset);
+exit:
+	return ret;
 }
 
 static int perf_event_set_output(struct perf_event *event, int output_fd);
-- 
1.6.1.2


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists