[RFC v2 PATCH 8/9] Ksplice: ARM support

From: Jeffrey Brian Arnold
Date: Sat Sep 13 2008 - 01:18:28 EST


Add support for Ksplice on ARM.

Signed-off-by: Jeffrey Brian Arnold <jbarnold@xxxxxxx>
Signed-off-by: Anders Kaseorg <andersk@xxxxxxx>
Signed-off-by: Tim Abbott <tabbott@xxxxxxx>
---
arch/arm/Kconfig | 1 +
arch/arm/kernel/ksplice-arch.c | 79 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/kernel/ksplice-arch.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 70dba16..e73f205 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -14,6 +14,7 @@ config ARM
select HAVE_OPROFILE
select HAVE_ARCH_KGDB
select HAVE_KPROBES if (!XIP_KERNEL)
+ select HAVE_KSPLICE if (!XIP_KERNEL)
select HAVE_KRETPROBES if (HAVE_KPROBES)
select HAVE_FTRACE if (!XIP_KERNEL)
select HAVE_DYNAMIC_FTRACE if (HAVE_FTRACE)
diff --git a/arch/arm/kernel/ksplice-arch.c b/arch/arm/kernel/ksplice-arch.c
new file mode 100644
index 0000000..981cf75
--- /dev/null
+++ b/arch/arm/kernel/ksplice-arch.c
@@ -0,0 +1,79 @@
+/* Copyright (C) 2007-2008 Jeffrey Brian Arnold <jbarnold@xxxxxxx>
+ * Copyright (C) 2008 Anders Kaseorg <andersk@xxxxxxx>,
+ * Tim Abbott <tabbott@xxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <linux/thread_info.h>
+#define KSPLICE_IP(x) thread_saved_pc(x)
+#define KSPLICE_SP(x) thread_saved_fp(x)
+
+static const struct ksplice_symbol trampoline_symbol = {
+ .name = NULL,
+ .label = "<trampoline>",
+};
+
+static const struct ksplice_reloc trampoline_reloc = {
+ .symbol = &trampoline_symbol,
+ .pcrel = 1,
+ .addend = -8,
+ .size = 4,
+ .dst_mask = 0x00ffffffL,
+ .rightshift = 2,
+ .signed_addend = 1,
+};
+
+static abort_t trampoline_target(struct ksplice_pack *pack, unsigned long addr,
+ unsigned long *new_addr)
+{
+ abort_t ret;
+ uint32_t word;
+ if (probe_kernel_read(&word, (void *)addr, sizeof(word)) == -EFAULT)
+ return NO_MATCH;
+
+ if ((word & 0xff000000) != 0xea000000)
+ return NO_MATCH;
+
+ ret = read_reloc_value(pack, &trampoline_reloc, addr, new_addr);
+ if (ret != OK)
+ return ret;
+
+ *new_addr += addr;
+ return OK;
+}
+
+static abort_t prepare_trampoline(struct ksplice_pack *pack,
+ struct ksplice_trampoline *t)
+{
+ t->size = 4;
+ *(uint32_t *)t->trampoline = 0xea000000;
+ return write_reloc_value(pack, &trampoline_reloc,
+ (unsigned long)t->trampoline,
+ t->repladdr - t->oldaddr);
+}
+
+static abort_t handle_paravirt(struct ksplice_pack *pack,
+ unsigned long pre_addr, unsigned long run_addr,
+ int *matched)
+{
+ *matched = 0;
+ return OK;
+}
+
+static bool valid_stack_ptr(const struct thread_info *tinfo, const void *p)
+{
+ return p > (const void *)tinfo
+ && p <= (const void *)tinfo + THREAD_SIZE - sizeof(long);
+}
--
1.5.4.3

--
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/