[RFC v2 PATCH 9/9] Ksplice: Add support for building Ksplice as a module

From: Jeffrey Brian Arnold
Date: Sat Sep 13 2008 - 01:19:39 EST


From: Tim Abbott <tabbott@xxxxxxx>

Export the symbols needed to build Ksplice as a module.

Signed-off-by: Tim Abbott <tabbott@xxxxxxx>
---
arch/Kconfig | 2 +-
arch/x86/mm/init_32.c | 5 +++--
arch/x86/mm/init_64.c | 3 ++-
kernel/kallsyms.c | 1 +
kernel/module.c | 9 +++++++++
kernel/sched.c | 1 +
6 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 9d5a843..cfbbcf3 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -28,7 +28,7 @@ config KPROBES
If in doubt, say "N".

config KSPLICE
- bool "Ksplice rebootless kernel updates"
+ tristate "Ksplice rebootless kernel updates"
depends on KALLSYMS_ALL && MODULE_UNLOAD && SYSFS && \
FUNCTION_DATA_SECTIONS
depends on HAVE_KSPLICE
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 5998d5c..549b021 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -1036,7 +1036,8 @@ void mark_rodata_ro(void)
unsigned long start = PFN_ALIGN(_text);
unsigned long size = PFN_ALIGN(_etext) - start;

-#if !defined(CONFIG_DYNAMIC_FTRACE) && !defined(CONFIG_KSPLICE)
+#if !defined(CONFIG_DYNAMIC_FTRACE) && \
+ !defined(CONFIG_KSPLICE) && !defined(CONFIG_KSPLICE_MODULE)
/* Dynamic tracing and Ksplice modify the kernel text section */
set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
printk(KERN_INFO "Write protecting the kernel text: %luk\n",
@@ -1050,7 +1051,7 @@ void mark_rodata_ro(void)
printk(KERN_INFO "Testing CPA: write protecting again\n");
set_pages_ro(virt_to_page(start), size>>PAGE_SHIFT);
#endif
-#endif /* !CONFIG_DYNAMIC_FTRACE && !CONFIG_KSPLICE */
+#endif /* !CONFIG_DYNAMIC_FTRACE && !CONFIG_KSPLICE && !CONFIG_KSPLICE_MODULE */

start += size;
size = (unsigned long)__end_rodata - start;
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 31db657..dec6325 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -857,7 +857,8 @@ void mark_rodata_ro(void)
unsigned long rodata_start =
((unsigned long)__start_rodata + PAGE_SIZE - 1) & PAGE_MASK;

-#if defined(CONFIG_DYNAMIC_FTRACE) || defined(CONFIG_KSPLICE)
+#if defined(CONFIG_DYNAMIC_FTRACE) || \
+ defined(CONFIG_KSPLICE) || defined(CONFIG_KSPLICE_MODULE)
/* Dynamic tracing and Ksplice modify the kernel text section */
start = rodata_start;
#endif
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 47d3e94..ef47021 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -178,6 +178,7 @@ int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
}
return module_kallsyms_on_each_symbol(fn, data);
}
+EXPORT_SYMBOL_GPL(kallsyms_on_each_symbol);

static unsigned long get_symbol_pos(unsigned long addr,
unsigned long *symbolsize,
diff --git a/kernel/module.c b/kernel/module.c
index 2acb646..d2fa540 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -63,6 +63,7 @@
/* List of modules, protected by module_mutex or preempt_disable
* (add/delete uses stop_machine). */
DEFINE_MUTEX(module_mutex);
+EXPORT_SYMBOL_GPL(module_mutex);
static LIST_HEAD(modules);

/* Waiting for a module to finish initializing? */
@@ -324,6 +325,7 @@ const struct kernel_symbol *find_symbol(const char *name,
DEBUGP("Failed to find symbol %s\n", name);
return NULL;
}
+EXPORT_SYMBOL_GPL(find_symbol);

/* Search for module by name: must hold module_mutex. */
struct module *find_module(const char *name)
@@ -336,6 +338,7 @@ struct module *find_module(const char *name)
}
return NULL;
}
+EXPORT_SYMBOL_GPL(find_module);

#ifdef CONFIG_SMP
/* Number of blocks used and allocated. */
@@ -612,6 +615,7 @@ int use_module(struct module *a, struct module *b)
no_warn = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name);
return 1;
}
+EXPORT_SYMBOL_GPL(use_module);

/* Clear the unload stuff of the module. */
static void module_unload_free(struct module *mod)
@@ -878,6 +882,7 @@ int use_module(struct module *a, struct module *b)
{
return strong_try_module_get(b) == 0;
}
+EXPORT_SYMBOL_GPL(use_module);

static inline void module_unload_init(struct module *mod)
{
@@ -2689,6 +2694,7 @@ struct module *__module_text_address(unsigned long addr)
return mod;
return NULL;
}
+EXPORT_SYMBOL_GPL(__module_text_address);

struct module *module_text_address(unsigned long addr)
{
@@ -2700,6 +2706,7 @@ struct module *module_text_address(unsigned long addr)

return mod;
}
+EXPORT_SYMBOL_GPL(module_text_address);

struct module *__module_data_address(unsigned long addr)
{
@@ -2717,6 +2724,7 @@ struct module *__module_data_address(unsigned long addr)
}
return NULL;
}
+EXPORT_SYMBOL_GPL(__module_data_address);

struct module *module_data_address(unsigned long addr)
{
@@ -2728,6 +2736,7 @@ struct module *module_data_address(unsigned long addr)

return mod;
}
+EXPORT_SYMBOL_GPL(module_data_address);

/* Don't grab lock, we're oopsing. */
void print_modules(void)
diff --git a/kernel/sched.c b/kernel/sched.c
index cc1f81b..bd385b6 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1736,6 +1736,7 @@ inline int task_curr(const struct task_struct *p)
{
return cpu_curr(task_cpu(p)) == p;
}
+EXPORT_SYMBOL_GPL(task_curr);

static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu)
{
--
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/