[RFC PATCH 8/9] Ksplice: ARM support

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeffrey Brian Arnold
Date: Friday, September 12, 2008 - 9:49 pm

Add support for Ksplice on ARM.

Signed-off-by: Jeffrey Brian Arnold <jbarnold@mit.edu>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Tim Abbott <tabbott@mit.edu>
---
 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@mit.edu>
+ *  Copyright (C) 2008  Anders Kaseorg <andersk@mit.edu>,
+ *                      Tim Abbott <tabbott@mit.edu>
+ *
+ *  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

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH 0/9] Ksplice: Rebootless kernel updates, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 1/9] Ksplice: Make find_symbol return a struct ..., Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 2/9] Ksplice: Add module_data_address (the anal ..., Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 3/9] Ksplice: Add functions for walking kallsym ..., Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 4/9] Ksplice: Make needed symbol and module fun ..., Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 5/9] Ksplice: Architecture-independent core, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 5/9] Ksplice core (architecture independent), Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 6/9] Ksplice: Documentation, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 6/9] Ksplice documentation, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 7/9] Ksplice: x86-32 and x86-64 support, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 8/9] Ksplice: ARM support, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 9/9] Ksplice: Add support for building Ksplice ..., Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
Re: [RFC PATCH 0/9] Ksplice: Rebootless kernel updates, Alexey Dobriyan, (Fri Sep 12, 10:12 pm)
Re: [RFC PATCH 0/9] Ksplice: Rebootless kernel updates, Jeff Arnold, (Sun Sep 14, 1:24 pm)