From: Jan Glauber <jang@linux.vnet.ibm.com>
To: Jason Baron <jbaron@redhat.com>
Cc: peterz@infradead.org, hpa@zytor.com,
mathieu.desnoyers@polymtl.ca, rostedt@goodmis.org, mingo@elte.hu,
tglx@linutronix.de, andi@firstfloor.org, roland@redhat.com,
rth@redhat.com, masami.hiramatsu.pt@hitachi.com,
fweisbec@gmail.com, avi@redhat.com, davem@davemloft.net,
sam@ravnborg.org, ddaney@caviumnetworks.com,
michael@ellerman.id.au, linux-kernel@vger.kernel.org,
schwidefsky@de.ibm.com
Subject: Re: [PATCH 0/2] jump label: update for .39
Date: Thu, 10 Mar 2011 17:41:23 +0100 [thread overview]
Message-ID: <20110310164123.GA19663@hal> (raw)
In-Reply-To: <cover.1299702291.git.jbaron@redhat.com>
On Wed, Mar 09, 2011 at 03:47:24PM -0500, Jason Baron wrote:
> Hi,
>
> Re-fresh of updates against latest -tip tree.
Hi Jason,
here are the s390 bits, tested successfully on top of your patches
so it would be nice to have this in .39 too.
The s390 support depends on the JUMP_TABLE being in the RW section
which is not the case in .38 and leads to a protection exception
there.
--Jan
Subject: [PATCH] jump_label: Add s390 support
From: Jan Glauber <jang@linux.vnet.ibm.com>
Implement the architecture backend for jump label support on s390.
For a shared kernel booted from a NSS silently disable jump labels
because the NSS is read-only. Therefore jump labels will be disabled
in a shared kernel and can't be activated.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Jan Glauber <jang@linux.vnet.ibm.com>
---
arch/s390/Kconfig | 1
arch/s390/include/asm/jump_label.h | 34 +++++++++++++++++++++
arch/s390/kernel/Makefile | 2 -
arch/s390/kernel/jump_label.c | 59 +++++++++++++++++++++++++++++++++++++
arch/s390/kernel/module.c | 1
5 files changed, 96 insertions(+), 1 deletion(-)
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -87,6 +87,7 @@ config S390
select HAVE_KERNEL_LZO
select HAVE_GET_USER_PAGES_FAST
select HAVE_ARCH_MUTEX_CPU_RELAX
+ select HAVE_ARCH_JUMP_LABEL if !MARCH_G5
select ARCH_INLINE_SPIN_TRYLOCK
select ARCH_INLINE_SPIN_TRYLOCK_BH
select ARCH_INLINE_SPIN_LOCK
--- /dev/null
+++ b/arch/s390/include/asm/jump_label.h
@@ -0,0 +1,34 @@
+#ifndef _ASM_S390_JUMP_LABEL_H
+#define _ASM_S390_JUMP_LABEL_H
+
+#include <linux/types.h>
+
+#define JUMP_LABEL_NOP_SIZE 6
+
+#ifdef CONFIG_64BIT
+#define ASM_PTR ".quad"
+#else
+#define ASM_PTR ".long"
+#endif
+
+static __always_inline bool arch_static_branch(struct jump_label_key *key)
+{
+ asm goto("0: brcl 0,0\n"
+ ".pushsection __jump_table, \"aw\"\n"
+ ASM_PTR " 0b, %l[label], %0\n"
+ ".popsection\n"
+ : : "X" (key) : : label);
+ return false;
+label:
+ return true;
+}
+
+typedef unsigned long jump_label_t;
+
+struct jump_entry {
+ jump_label_t code;
+ jump_label_t target;
+ jump_label_t key;
+};
+
+#endif
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -23,7 +23,7 @@ CFLAGS_sysinfo.o += -Iinclude/math-emu -
obj-y := bitmap.o traps.o time.o process.o base.o early.o setup.o \
processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o \
s390_ext.o debug.o irq.o ipl.o dis.o diag.o mem_detect.o \
- vdso.o vtime.o sysinfo.o nmi.o sclp.o
+ vdso.o vtime.o sysinfo.o nmi.o sclp.o jump_label.o
obj-y += $(if $(CONFIG_64BIT),entry64.o,entry.o)
obj-y += $(if $(CONFIG_64BIT),reipl64.o,reipl.o)
--- /dev/null
+++ b/arch/s390/kernel/jump_label.c
@@ -0,0 +1,59 @@
+/*
+ * Jump label s390 support
+ *
+ * Copyright IBM Corp. 2011
+ * Author(s): Jan Glauber <jang@linux.vnet.ibm.com>
+ */
+#include <linux/module.h>
+#include <linux/uaccess.h>
+#include <linux/stop_machine.h>
+#include <linux/jump_label.h>
+#include <asm/ipl.h>
+
+#ifdef HAVE_JUMP_LABEL
+
+struct insn {
+ u16 opcode;
+ s32 offset;
+} __packed;
+
+struct insn_args {
+ unsigned long *target;
+ struct insn *insn;
+ ssize_t size;
+};
+
+static int __arch_jump_label_transform(void *data)
+{
+ struct insn_args *args = data;
+ int rc;
+
+ rc = probe_kernel_write(args->target, args->insn, args->size);
+ WARN_ON_ONCE(rc < 0);
+ return 0;
+}
+
+void arch_jump_label_transform(struct jump_entry *entry,
+ enum jump_label_type type)
+{
+ struct insn_args args;
+ struct insn insn;
+
+ if (type == JUMP_LABEL_ENABLE) {
+ /* brcl 15,offset */
+ insn.opcode = 0xc0f4;
+ insn.offset = (entry->target - entry->code) >> 1;
+ } else {
+ /* brcl 0,0 */
+ insn.opcode = 0xc004;
+ insn.offset = 0;
+ }
+
+ args.target = (void *) entry->code;
+ args.insn = &insn;
+ args.size = JUMP_LABEL_NOP_SIZE;
+
+ stop_machine(__arch_jump_label_transform, &args, NULL);
+}
+
+#endif
--- a/arch/s390/kernel/module.c
+++ b/arch/s390/kernel/module.c
@@ -407,6 +407,7 @@ int module_finalize(const Elf_Ehdr *hdr,
{
vfree(me->arch.syminfo);
me->arch.syminfo = NULL;
+ jump_label_apply_nops(me);
return 0;
}
prev parent reply other threads:[~2011-03-10 16:41 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-09 20:47 [PATCH 0/2] jump label: update for .39 Jason Baron
2011-03-09 20:47 ` [PATCH 1/2] jump label: introduce static_branch() interface Jason Baron
2011-03-10 20:54 ` Steven Rostedt
2011-03-10 20:56 ` Steven Rostedt
2011-03-11 2:05 ` Ralf Baechle
2011-03-11 2:15 ` Steven Rostedt
2011-03-10 21:01 ` Steven Rostedt
2011-03-10 21:18 ` Jason Baron
2011-03-11 2:02 ` Ralf Baechle
2011-03-09 20:47 ` [PATCH 2/2] dynamic debug: add jump label support Jason Baron
2011-03-10 3:36 ` [PATCH 0/2] jump label: update for .39 Steven Rostedt
2011-03-10 14:11 ` Mathieu Desnoyers
2011-03-10 14:46 ` Jason Baron
[not found] ` <BLU0-SMTP690BB959832A97E002293396C80@phx.gbl>
2011-03-10 15:38 ` Steven Rostedt
2011-03-10 17:27 ` David Daney
2011-03-10 18:04 ` Steven Rostedt
2011-03-10 18:20 ` Jason Baron
2011-03-10 18:35 ` Steven Rostedt
2011-03-10 18:47 ` David Daney
2011-03-10 18:53 ` Steven Rostedt
2011-03-10 18:57 ` David Daney
2011-03-10 19:25 ` Steven Rostedt
2011-03-10 19:45 ` Steven Rostedt
2011-03-10 19:53 ` Jason Baron
2011-03-10 20:01 ` Steven Rostedt
2011-03-10 21:22 ` Mathieu Desnoyers
[not found] ` <BLU0-SMTP311155BEBE5F141636A6E596C80@phx.gbl>
2011-03-10 21:42 ` Steven Rostedt
2011-03-10 22:11 ` David Daney
2011-03-10 22:24 ` Steven Rostedt
2011-03-10 22:48 ` Mathieu Desnoyers
[not found] ` <BLU0-SMTP101D168109508CC1B82F0E496C80@phx.gbl>
2011-03-10 23:16 ` Steven Rostedt
2011-03-10 23:25 ` David Daney
2011-03-10 23:32 ` Thomas Gleixner
2011-03-10 23:43 ` Steven Rostedt
2011-03-10 23:51 ` Thomas Gleixner
[not found] ` <BLU0-SMTP39EE03AE86CF0F0E5C570596C80@phx.gbl>
2011-03-11 0:38 ` Ralf Baechle
2011-03-11 1:19 ` Michael Ellerman
2011-03-11 2:39 ` Mathieu Desnoyers
2011-03-10 21:39 ` Mathieu Desnoyers
2011-03-10 21:11 ` Mathieu Desnoyers
2011-03-10 21:14 ` Mathieu Desnoyers
[not found] ` <BLU0-SMTP2489AC44910467F37596A496C80@phx.gbl>
2011-03-10 21:34 ` Steven Rostedt
2011-03-10 22:02 ` Mathieu Desnoyers
2011-03-10 16:41 ` Jan Glauber [this message]
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=20110310164123.GA19663@hal \
--to=jang@linux.vnet.ibm.com \
--cc=andi@firstfloor.org \
--cc=avi@redhat.com \
--cc=davem@davemloft.net \
--cc=ddaney@caviumnetworks.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jbaron@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=michael@ellerman.id.au \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=roland@redhat.com \
--cc=rostedt@goodmis.org \
--cc=rth@redhat.com \
--cc=sam@ravnborg.org \
--cc=schwidefsky@de.ibm.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox