From: Jeremy Fitzhardinge Subject: Re: [PATCH RFC 7/8] s390/jump-label: add arch_jump_label_transform_early() Date: Fri, 30 Sep 2011 09:03:51 -0700 Message-ID: <4E85E867.8080809@goop.org> References: <1317394099.11297.54.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <1317394099.11297.54.camel@localhost.localdomain> Sender: linux-kernel-owner@vger.kernel.org To: Jan Glauber Cc: Steven Rostedt , "David S. Miller" , David Daney , Michael Ellerman , Jason Baron , the arch/x86 maintainers , Xen Devel , Linux Kernel Mailing List , Jeremy Fitzhardinge List-Id: xen-devel@lists.xenproject.org On 09/30/2011 07:48 AM, Jan Glauber wrote: > On Thu, 2011-09-29 at 16:26 -0700, Jeremy Fitzhardinge wrote: >> From: Jeremy Fitzhardinge >> >> This allows jump-label entries to be modified early, in a pre-SMP >> environment. >> >> Signed-off-by: Jeremy Fitzhardinge >> Cc: Jan Glauber > Hi Jeremy, > > Your patch looks fine, if you can fix the minor compiler warnings > below. Excluding stop_machine() on pre-SMP also looks safer too me. Do you think there would be an actual problem, or are you just being cautious? It seems to me - in general - stop_machine could just be defined to be = a no-op (ie, just directly calls the callback) until enough SMP is initialized for it to make sense, rather than having to make every user work around it (if there's a chance they might call it early). > CC arch/s390/kernel/jump_label.o > arch/s390/kernel/jump_label.c: In function =E2=80=98__jump_label_tran= sform=E2=80=99: > arch/s390/kernel/jump_label.c:41:2: error: =E2=80=98rc=E2=80=99 undec= lared (first use in this function) > arch/s390/kernel/jump_label.c:41:2: note: each undeclared identifier = is reported only once for each function it appears in > arch/s390/kernel/jump_label.c:41:2: warning: passing argument 1 of =E2= =80=98probe_kernel_write=E2=80=99 makes pointer from integer without a = cast [enabled by default] > include/linux/uaccess.h:108:21: note: expected =E2=80=98void *=E2=80=99= but argument is of type =E2=80=98jump_label_t=E2=80=99 > arch/s390/kernel/jump_label.c:28:19: warning: unused variable =E2=80=98= args=E2=80=99 [-Wunused-variable] > make[2]: *** [arch/s390/kernel/jump_label.o] Error 1 > > Like so? =46rom 9572689d1e5e6f54a1936a1dca09a6920d1bce27 Mon Sep 17 00:00:00 200= 1 =46rom: Jeremy Fitzhardinge Date: Thu, 29 Sep 2011 10:58:46 -0700 Subject: [PATCH] s390/jump-label: add arch_jump_label_transform_early() This allows jump-label entries to be modified early, in a pre-SMP environment. Signed-off-by: Jeremy Fitzhardinge Cc: Jan Glauber diff --git a/arch/s390/kernel/jump_label.c b/arch/s390/kernel/jump_labe= l.c index 44cc06b..4fbe63b 100644 --- a/arch/s390/kernel/jump_label.c +++ b/arch/s390/kernel/jump_label.c @@ -18,26 +18,15 @@ struct insn { } __packed; =20 struct insn_args { - unsigned long *target; - struct insn *insn; - ssize_t size; + struct jump_entry *entry; + enum jump_label_type type; }; =20 -static int __arch_jump_label_transform(void *data) +static void __jump_label_transform(struct jump_entry *entry, + enum jump_label_type type) { - struct insn_args *args =3D data; - int rc; - - rc =3D 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; + int rc; =20 if (type =3D=3D JUMP_LABEL_ENABLE) { /* brcl 15,offset */ @@ -49,11 +38,33 @@ void arch_jump_label_transform(struct jump_entry *e= ntry, insn.offset =3D 0; } =20 - args.target =3D (void *) entry->code; - args.insn =3D &insn; - args.size =3D JUMP_LABEL_NOP_SIZE; + rc =3D probe_kernel_write((void *)entry->code, &insn, JUMP_LABEL_NOP_= SIZE); + WARN_ON_ONCE(rc < 0); +} =20 - stop_machine(__arch_jump_label_transform, &args, NULL); +static int __sm_arch_jump_label_transform(void *data) +{ + struct insn_args *args =3D data; + + __jump_label_transform(args->entry, args->type); + return 0; +} + +void arch_jump_label_transform(struct jump_entry *entry, + enum jump_label_type type) +{ + struct insn_args args; + + args.entry =3D entry; + args.type =3D type; + + stop_machine(__sm_arch_jump_label_transform, &args, NULL); +} + +void __init arch_jump_label_transform_early(struct jump_entry *entry, + enum jump_label_type type) +{ + __jump_label_transform(entry, type); } =20 #endif J