From: Jason Baron <jbaron@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@elte.hu, mathieu.desnoyers@polymtl.ca, hpa@zytor.com,
tglx@linutronix.de, rostedt@goodmis.org, andi@firstfloor.org,
roland@redhat.com, rth@redhat.com, mhiramat@redhat.com,
fweisbec@gmail.com, avi@redhat.com, davem@davemloft.net,
vgoyal@redhat.com
Subject: [PATCH 10/11] sparc64: Add jump_label support
Date: Fri, 16 Apr 2010 11:24:58 -0400 [thread overview]
Message-ID: <ce9ace2ef55957bc7693ddc032c0412cfa0726f9.1271427118.git.jbaron@redhat.com> (raw)
In-Reply-To: <cover.1271427118.git.jbaron@redhat.com>
From: David S. Miller <davem@davemloft.net>
Add jump label support for sparc64.
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jason Baron <jbaron@redhat.com>
---
arch/sparc/Kconfig | 1 +
arch/sparc/include/asm/jump_entry.h | 16 ++++++++++++++
arch/sparc/include/asm/jump_label.h | 21 +++++++++++++++++++
arch/sparc/kernel/Makefile | 2 +
arch/sparc/kernel/jump_label.c | 38 +++++++++++++++++++++++++++++++++++
arch/sparc/kernel/module.c | 6 +++++
6 files changed, 84 insertions(+), 0 deletions(-)
create mode 100644 arch/sparc/include/asm/jump_entry.h
create mode 100644 arch/sparc/include/asm/jump_label.h
create mode 100644 arch/sparc/kernel/jump_label.c
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index d6781ce..0c581d4 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -29,6 +29,7 @@ config SPARC
select PERF_USE_VMALLOC
select HAVE_DMA_ATTRS
select HAVE_DMA_API_DEBUG
+ select HAVE_ARCH_JUMP_LABEL
config SPARC32
def_bool !64BIT
diff --git a/arch/sparc/include/asm/jump_entry.h b/arch/sparc/include/asm/jump_entry.h
new file mode 100644
index 0000000..6bb85e4
--- /dev/null
+++ b/arch/sparc/include/asm/jump_entry.h
@@ -0,0 +1,16 @@
+#ifndef _LINUX_JUMP_ENTRY_H
+#define _LINUX_JUMP_ENTRY_H
+
+/* Defined in a separate file, so that it can be used by user program modpost.c
+ * This file is included by include/asm/jump_label.h, in turn included by
+ * include/linux/jump_label.h. Kernel sources should only include
+ * include/linux/jump_label.h.
+ **/
+
+struct jump_entry {
+ __u32 code;
+ __u32 target;
+ __u32 name;
+};
+
+#endif
diff --git a/arch/sparc/include/asm/jump_label.h b/arch/sparc/include/asm/jump_label.h
new file mode 100644
index 0000000..32d2c2f
--- /dev/null
+++ b/arch/sparc/include/asm/jump_label.h
@@ -0,0 +1,21 @@
+#ifndef _ASM_SPARC_JUMP_LABEL_H
+#define _ASM_SPARC_JUMP_LABEL_H
+
+#include <linux/types.h>
+#include <asm/jump_entry.h>
+
+#define JUMP_LABEL_NOP_SIZE 4
+
+#define JUMP_LABEL(tag, label, cond) \
+ do { \
+ extern const char __jlstrtab_##tag[]; \
+ asm goto("1:\n\t" \
+ "nop\n\t" \
+ "nop\n\t" \
+ ".pushsection __jump_table, \"a\"\n\t"\
+ ".xword 1b, %l[" #label "], %c0\n\t" \
+ ".popsection \n\t" \
+ : : "i" (__jlstrtab_##tag) : : label);\
+ } while (0)
+
+#endif
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 0c2dc1f..599398f 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -119,3 +119,5 @@ obj-$(CONFIG_COMPAT) += $(audit--y)
pc--$(CONFIG_PERF_EVENTS) := perf_event.o
obj-$(CONFIG_SPARC64) += $(pc--y)
+
+obj-$(CONFIG_SPARC64) += jump_label.o
diff --git a/arch/sparc/kernel/jump_label.c b/arch/sparc/kernel/jump_label.c
new file mode 100644
index 0000000..c1aa2d8
--- /dev/null
+++ b/arch/sparc/kernel/jump_label.c
@@ -0,0 +1,38 @@
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/mutex.h>
+#include <linux/cpu.h>
+
+#include <linux/jump_label.h>
+#include <linux/memory.h>
+
+#ifdef HAVE_JUMP_LABEL
+
+void arch_jump_label_transform(struct jump_entry *entry, enum jump_label_type type)
+{
+ u32 val, *insn = (u32 *) entry->code;
+
+ val = *insn;
+ if (type == JUMP_LABEL_ENABLE) {
+ s32 off = (s32)entry->target - (s32)entry->code;
+ val = 0x40000000 | ((u32) off >> 2);
+ } else {
+ val = 0x01000000;
+ }
+
+ get_online_cpus();
+ mutex_lock(&text_mutex);
+ *insn = val;
+ flushi(insn);
+ mutex_unlock(&text_mutex);
+ put_online_cpus();
+}
+
+static const u8 jump_label_nop[JUMP_LABEL_NOP_SIZE] = { 0x01, 0x00, 0x00, 0x00 };
+
+const u8 *arch_get_jump_label_nop()
+{
+ return jump_label_nop;
+}
+
+#endif
diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c
index f848aad..37cf439 100644
--- a/arch/sparc/kernel/module.c
+++ b/arch/sparc/kernel/module.c
@@ -18,6 +18,9 @@
#include <asm/spitfire.h>
#ifdef CONFIG_SPARC64
+
+#include <linux/jump_label.h>
+
static void *module_map(unsigned long size)
{
struct vm_struct *area;
@@ -227,6 +230,9 @@ int module_finalize(const Elf_Ehdr *hdr,
const Elf_Shdr *sechdrs,
struct module *me)
{
+ /* make jump label nops */
+ apply_jump_label_nops(me);
+
/* Cheetah's I-cache is fully coherent. */
if (tlb_type == spitfire) {
unsigned long va;
--
1.7.0.1
next prev parent reply other threads:[~2010-04-16 15:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-16 15:24 [PATCH 00/11] jump label v7 Jason Baron
2010-04-16 15:24 ` [PATCH 01/11] jump label: notifier atomic call chain notrace Jason Baron
2010-04-16 15:24 ` [PATCH 02/11] jump label: base patch Jason Baron
2010-04-16 15:24 ` [PATCH 03/11] jump label: x86 support Jason Baron
2010-04-16 15:24 ` [PATCH 04/11] jump label: tracepoint support Jason Baron
2010-04-16 15:24 ` [PATCH 05/11] jump label: add module support Jason Baron
2010-04-16 15:24 ` [PATCH 06/11] jump label: move ftrace_dyn_arch_init to common code Jason Baron
2010-04-16 15:24 ` [PATCH 07/11] jump label: sort jump table at build-time Jason Baron
2010-04-16 15:24 ` [PATCH 08/11] jump label: initialize workqueue tracepoints *before* they are registered Jason Baron
2010-04-16 15:24 ` [PATCH 09/11] jump label: jump_label_text_reserved() to reserve our jump points Jason Baron
2010-04-16 15:24 ` Jason Baron [this message]
2010-04-16 15:25 ` [PATCH 11/11] jump label: add docs Jason Baron
2010-04-22 23:17 ` [PATCH 00/11] jump label v7 David Miller
2010-04-28 0:58 ` David Miller
2010-04-28 1:39 ` Tony Breeds
2010-04-28 1:49 ` Mathieu Desnoyers
2010-04-28 2:08 ` Tony Breeds
2010-04-28 2:13 ` Mike Frysinger
2010-04-28 14:09 ` Mathieu Desnoyers
2010-04-28 21:53 ` H. Peter Anvin
2010-04-29 18:15 ` Jason Baron
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=ce9ace2ef55957bc7693ddc032c0412cfa0726f9.1271427118.git.jbaron@redhat.com \
--to=jbaron@redhat.com \
--cc=andi@firstfloor.org \
--cc=avi@redhat.com \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mhiramat@redhat.com \
--cc=mingo@elte.hu \
--cc=roland@redhat.com \
--cc=rostedt@goodmis.org \
--cc=rth@redhat.com \
--cc=tglx@linutronix.de \
--cc=vgoyal@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).