[patch 5/8] Text Edit Lock - Alternative code for i386 and x86_64

From: Mathieu Desnoyers
Date: Fri Jul 13 2007 - 21:25:41 EST


alternative.c can use the text edit lock to remove CPU HOTPLUG special cases.
Also used by x86_64.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxx>
---
arch/i386/kernel/alternative.c | 10 ++++++++++
1 file changed, 10 insertions(+)

Index: linux-2.6-lttng/arch/i386/kernel/alternative.c
===================================================================
--- linux-2.6-lttng.orig/arch/i386/kernel/alternative.c 2007-07-13 16:08:14.000000000 -0400
+++ linux-2.6-lttng/arch/i386/kernel/alternative.c 2007-07-13 16:39:26.000000000 -0400
@@ -2,8 +2,10 @@
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/list.h>
+#include <linux/memory.h>
#include <asm/alternative.h>
#include <asm/sections.h>
+#include <asm/cacheflush.h>

#ifdef CONFIG_HOTPLUG_CPU
static int smp_alt_once;
@@ -185,9 +187,13 @@
__FUNCTION__, a->instr, instr);
}
#endif
+ kernel_text_lock();
+ kernel_text_mark_rw((unsigned long)instr, a->instrlen);
memcpy(instr, a->replacement, a->replacementlen);
diff = a->instrlen - a->replacementlen;
nop_out(instr + a->replacementlen, diff);
+ kernel_text_unmark((unsigned long)instr, a->instrlen);
+ kernel_text_unlock();
}
}

@@ -352,6 +358,8 @@
for (p = start; p < end; p++) {
unsigned int used;

+ kernel_text_lock();
+ kernel_text_mark_rw((unsigned long)p->instr, p->len);
used = paravirt_ops.patch(p->instrtype, p->clobbers, p->instr,
p->len);

@@ -359,6 +367,8 @@

/* Pad the rest with nops */
nop_out(p->instr + used, p->len - used);
+ kernel_text_unmark((unsigned long)p->instr, p->len);
+ kernel_text_unlock();
}

/* Sync to be conservative, in case we patched following

--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/