From 5d5e879ea7a5247cbdf156c4294a39bd3372f4d5 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 17 Feb 2009 17:48:08 -0500 Subject: [PATCH] Rename the Ksplice modules to the new -old/-new style. Signed-off-by: Tim Abbott --- kmodsrc/Makefile.in | 6 +++--- kmodsrc/ksplice.c | 16 +++++++++------- ksplice-apply.in | 38 +++++++++++++++++++------------------- ksplice-create.in | 8 ++++---- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/kmodsrc/Makefile.in b/kmodsrc/Makefile.in index 0460f7d..b0bad49 100644 --- a/kmodsrc/Makefile.in +++ b/kmodsrc/Makefile.in @@ -53,9 +53,9 @@ $(obj)/$(KSPLICE_CORE).o: fake-ksplice.o = endif define ksplice-mod-vars -obj-m += $(KSPLICE).o $(KSPLICE)-helper.o -$(KSPLICE)-objs = $(ksplice-new-code-objs) -$(KSPLICE)-helper-objs = $(ksplice-old-code-objs) +obj-m += $(KSPLICE)-new.o $(KSPLICE)-old.o +$(KSPLICE)-new-objs = $(ksplice-new-code-objs) +$(KSPLICE)-old-objs = $(ksplice-old-code-objs) CFLAGS_new-code-$(target).o = $(ksplice-mod-cflags) CFLAGS_old-code-$(target).o = $(ksplice-mod-cflags) CPPFLAGS_ksplice.lds = $(ksplice-mod-cflags) -P diff --git a/kmodsrc/ksplice.c b/kmodsrc/ksplice.c index c809a29..20ed0e9 100644 --- a/kmodsrc/ksplice.c +++ b/kmodsrc/ksplice.c @@ -1184,10 +1184,10 @@ static void cleanup_symbol_arrays(struct ksplice_mod_change *change) } /* - * The primary and helper modules each have their own independent + * The new_code and old_code modules each have their own independent * ksplice_symbol structures. uniquify_symbols unifies these separate * pieces of kernel symbol information by replacing all references to - * the helper copy of symbols with references to the primary copy. + * the old_code copy of symbols with references to the new_code copy. */ static abort_t uniquify_symbols(struct ksplice_mod_change *change) { @@ -1509,8 +1509,8 @@ static void *map_writable(void *addr, size_t len) } /* - * Ksplice adds a dependency on any symbol address used to resolve relocations - * in the primary module. + * Ksplice adds a dependency on any symbol address used to resolve + * relocations in the new_code module. * * Be careful to follow_trampolines so that we always depend on the * latest version of the target function, since that's the code that @@ -1998,7 +1998,7 @@ static abort_t try_addr(struct ksplice_mod_change *change, const struct module *run_module = __module_address(run_addr); if (run_module == change->new_code_mod) { - ksdebug(change, "run-pre: unexpected address %lx in primary " + ksdebug(change, "run-pre: unexpected address %lx in new_code " "module %s for sect %s\n", run_addr, run_module->name, sect->symbol->label); return UNEXPECTED; @@ -3278,7 +3278,7 @@ static abort_t create_safety_record(struct ksplice_mod_change *change, if (rec == NULL) return OUT_OF_MEMORY; /* - * The helper might be unloaded when checking reversing + * The old_code might be unloaded when checking reversing * patches, so we need to kstrdup the label here. */ rec->label = kstrdup(sect->symbol->label, GFP_KERNEL); @@ -3404,6 +3404,7 @@ static bool patches_module(const struct module *a, const struct module *b) { #ifdef KSPLICE_NO_KERNEL_SUPPORT const char *name; + const char *modname = b == NULL ? "vmlinux" : b->name; if (a == b) return true; if (a == NULL || !strstarts(a->name, "ksplice_")) @@ -3413,7 +3414,8 @@ static bool patches_module(const struct module *a, const struct module *b) if (name[0] != '_') return false; name++; - return strcmp(name, b == NULL ? "vmlinux" : b->name) == 0; + return strstarts(name, modname) && + strcmp(name + strlen(modname), "_new") == 0; #else /* !KSPLICE_NO_KERNEL_SUPPORT */ struct ksplice_module_list_entry *entry; if (a == b) diff --git a/ksplice-apply.in b/ksplice-apply.in index 30a1a2a..a2042af 100644 --- a/ksplice-apply.in +++ b/ksplice-apply.in @@ -79,11 +79,11 @@ if (defined $core) { } } -my @helpers = (); -foreach my $helper (glob('ksplice-*-helper.ko')) { - (my $primary = $helper) =~ s/\-helper\.ko$/.ko/; - die unless(-e $primary && -e $helper); - (my $target = $primary) =~ s/^ksplice-[^_]+_(.*)\.ko/$1/; +my @old_code_mod_files = (); +foreach my $old_code_mod_file (glob('ksplice-*-old.ko')) { + (my $new_code_mod_file = $old_code_mod_file) =~ s/-old\.ko$/-new.ko/; + die unless(-e $new_code_mod_file && -e $old_code_mod_file); + (my $target = $new_code_mod_file) =~ s/^ksplice-[^_]+_(.*)-new\.ko/$1/; if ($target ne 'vmlinux' && runstr("lsmod") !~ m/^${target}\s/m) { if (!$partial) { cleanup_modules(); @@ -91,17 +91,17 @@ foreach my $helper (glob('ksplice-*-helper.ko')) { die "Module $target to be patched not loaded"; } } - push @helpers, $helper; + push @old_code_mod_files, $old_code_mod_file; } -foreach my $helper (@helpers) { - (my $primary = $helper) =~ s/\-helper\.ko$/.ko/; - if(!load_module($primary)) { - die "Error loading primary module $primary"; +foreach my $old_code_mod_file (@old_code_mod_files) { + (my $new_code_mod_file = $old_code_mod_file) =~ s/-old\.ko$/-new.ko/; + if(!load_module($new_code_mod_file)) { + die "Error loading new code module $new_code_mod_file"; } - if(!load_module($helper)) { + if(!load_module($old_code_mod_file)) { my $debugfile = get_debug_output("init_$kid", $debug); - print STDERR "Error loading helper module $helper\n"; - (my $module = $primary) =~ s/-/_/g; + print STDERR "Error loading old code module $old_code_mod_file\n"; + (my $module = $new_code_mod_file) =~ s/-/_/g; $module =~ s/\.ko//; cleanup_modules(); if($debugon && defined $debugfile) { @@ -134,12 +134,12 @@ mkpath("/var/run/ksplice/updates/$kid"); copy("patch", "/var/run/ksplice/updates/$kid/patch") if (-e "patch"); copy("description", "/var/run/ksplice/updates/$kid/description") if (-e "description"); if (!$nounload) { - foreach my $helper (@helpers) { - $helper =~ s/-/_/g; - $helper =~ s/\.ko$//; - (my $primary = $helper) =~ s/_helper$//; - runval('rmmod', $helper); - runval('rmmod', $primary) if ($partial && refcount($primary) == 0); + foreach my $old_code_mod_file (@old_code_mod_files) { + (my $old_code_mod = $old_code_mod_file) =~ s/-/_/g; + $old_code_mod =~ s/\.ko$//; + (my $new_code_mod = $old_code_mod) =~ s/-old$/-new/; + runval('rmmod', $old_code_mod); + runval('rmmod', $new_code_mod) if ($partial && refcount($new_code_mod) == 0); } } print "Done!\n"; diff --git a/ksplice-create.in b/ksplice-create.in index 532196e..891f7d0 100644 --- a/ksplice-create.in +++ b/ksplice-create.in @@ -301,10 +301,10 @@ foreach my $mod (@modules) { (my $target = $mod) =~ s/-/_/g; my $mid = "${kid}_$target"; my $module = "ksplice-$mid"; - rename("$tmpdir/ksplice-modules/extra/$module.ko", "$ksplice/$module.ko"); - print CONTENTS "primary $target ksplice_$mid $module.ko\n"; - rename("$tmpdir/ksplice-modules/extra/$module-helper.ko", "$ksplice/$module-helper.ko"); - print CONTENTS "helper $target ksplice_$mid $module-helper.ko\n"; + rename("$tmpdir/ksplice-modules/extra/$module-new.ko", "$ksplice/$module-new.ko"); + print CONTENTS "new_code $target ksplice_$mid $module-new.ko\n"; + rename("$tmpdir/ksplice-modules/extra/$module-old.ko", "$ksplice/$module-old.ko"); + print CONTENTS "old_code $target ksplice_$mid $module-old.ko\n"; } if ($standalone) { rename("$tmpdir/ksplice-modules/extra/ksplice-$kid.ko", "$ksplice/ksplice-$kid.ko"); -- 2.11.4.GIT