Supports placing immediate values in init code
We need to put the immediate values in RW data section so we can edit them
before init section unload.
This code puts NULL pointers in lieu of original pointer referencing init code
before the init sections are freed, both in the core kernel and in modules.
TODO : support __exit section.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: "Frank Ch. Eigler" <fche@redhat.com>
---
Documentation/immediate.txt | 8 ++++----
include/asm-generic/vmlinux.lds.h | 8 ++++----
include/asm-powerpc/immediate.h | 4 ++--
include/asm-x86/immediate.h | 6 +++---
include/linux/immediate.h | 7 ++++++-
include/linux/module.h | 2 +-
init/main.c | 1 +
kernel/immediate.c | 31 +++++++++++++++++++++++++++++--
kernel/module.c | 2 ++
9 files changed, 52 insertions(+), 17 deletions(-)
Index: linux-2.6-lttng/kernel/immediate.c
===================================================================
--- linux-2.6-lttng.orig/kernel/immediate.c 2008-04-16 11:24:03.000000000 -0400
+++ linux-2.6-lttng/kernel/immediate.c 2008-04-16 11:24:25.000000000 -0400
@@ -22,6 +22,7 @@
#include <linux/cpu.h>
#include <linux/stop_machine.h>
+#include <asm/sections.h>
#include <asm/cacheflush.h>
/*
@@ -30,8 +31,8 @@
static int imv_early_boot_complete;
static int wrote_text;
-extern const struct __imv __start___imv[];
-extern const struct __imv __stop___imv[];
+extern struct __imv __start___imv[];
+extern struct __imv __stop___imv[];
static int stop_machine_imv_update(void *imv_ptr)
{
@@ -118,6 +119,8 @@ void imv_update_range(const struct __imv
int ret;
for (iter = begin; iter < end; iter++) {
mutex_lock(&imv_mutex);
+ if (!iter->imv) /* Skip removed __init immediate values */
+ goto skip;
ret = apply_imv_update(iter);
if (imv_early_boot_complete && ...err. When turn off CONFIG_IMMEDIATE, "struct __imv" is not defined. is cause following warnings. include/linux/immediate.h:81: warning: 'struct __imv' declared inside parameter list include/linux/immediate.h:81: warning: its scope is only this definition or declaration, \ which is probably not what you want if CONFIG_IMMEDIATE is on, imv_unref() is declared. but if CONFIG_IMMEDIATE is off, imv_unref_init() is declared instead imv_unref() it cause following error. CC kernel/module.o kernel/module.c: In function 'sys_init_module': kernel/module.c:2211: error: implicit declaration of function 'imv_unref' kernel/module.c:2211: error: 'struct module' has no member named 'immediate' kernel/module.c:2211: error: 'struct module' has no member named 'immediate' kernel/module.c:2211: error: 'struct module' has no member named 'num_immediate' make[1]: *** [kernel/module.o] Error 1 and, in kernel/module.c#sys_init_module(), it cause following error. CC kernel/module.o kernel/module.c: In function 'sys_init_module': kernel/module.c:2211: error: 'struct module' has no member named 'immediate' kernel/module.c:2211: error: 'struct module' has no member named 'immediate' kernel/module.c:2211: error: 'struct module' has no member named 'num_immediate' make[1]: *** [kernel/module.o] Error 1 bellow patch fixed these. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> --- include/linux/immediate.h | 8 ++++++-- include/linux/module.h | 21 +++++++++++++++++++++ kernel/module.c | 3 ++- 3 files changed, 29 insertions(+), 3 deletions(-) Index: b/include/linux/immediate.h =================================================================== --- a/include/linux/immediate.h 2008-04-19 19:53:03.000000000 +0900 +++ b/include/linux/immediate.h 2008-04-19 20:04:58.000000000 +0900 @@ -56,6 +56,10 @@ extern void imv_unref(struct __imv *begi * Generic immediate values: a simple, standard, memory load. */ +/* empty ...
I prefer to add an ifdef CONFIG_IMMEDIATE to module.c to follow what I have already done previously. Defining this empty structure is a bit odd. Here is the updated patch. Thanks for testing/reporting this. Mathieu Immediate Values Support init Supports placing immediate values in init code We need to put the immediate values in RW data section so we can edit them before init section unload. This code puts NULL pointers in lieu of original pointer referencing init code before the init sections are freed, both in the core kernel and in modules. TODO : support __exit section. Changelog: - Fix !CONFIG_IMMEDIATE Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> CC: Rusty Russell <rusty@rustcorp.com.au> CC: "Frank Ch. Eigler" <fche@redhat.com> CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> --- Documentation/immediate.txt | 8 ++++---- include/asm-generic/vmlinux.lds.h | 8 ++++---- include/asm-powerpc/immediate.h | 4 ++-- include/asm-x86/immediate.h | 6 +++--- include/linux/immediate.h | 4 ++++ include/linux/module.h | 2 +- init/main.c | 1 + kernel/immediate.c | 31 +++++++++++++++++++++++++++++-- kernel/module.c | 4 ++++ 9 files changed, 52 insertions(+), 16 deletions(-) Index: linux-2.6-lttng/kernel/immediate.c =================================================================== --- linux-2.6-lttng.orig/kernel/immediate.c 2008-04-19 09:10:20.000000000 -0400 +++ linux-2.6-lttng/kernel/immediate.c 2008-04-19 09:20:53.000000000 -0400 @@ -22,6 +22,7 @@ #include <linux/cpu.h> #include <linux/stop_machine.h> +#include <asm/sections.h> #include <asm/cacheflush.h> /* @@ -30,8 +31,8 @@ static int imv_early_boot_complete; static int wrote_text; -extern const struct __imv __start___imv[]; -extern const struct __imv __stop___imv[]; +extern struct __imv __start___imv[]; +extern struct __imv ...
OK. I tested and confirmed your latest patch solved my reporting problem. Thanks. --
